akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#define D_MAX 1000000000
#define N_MAX 100000
#define M_MAX 10000
#define TRUE  1
#define FALSE 0

int d;
int n;
int m;

int ad[N_MAX+1];
int ak[M_MAX+1];

void input(void){
  int i;
  scanf("%d",&d);
  if( d != 0){
    scanf("%d",&n);
    scanf("%d",&m);
    ad[0] = 0;
    for( i=1; i<=n-1; i++){
      scanf("%d",&ad[i]);
    }
    ad[n] = d;
    for( i=1; i<=m; i++){
      scanf("%d",&ak[i]);
    }
  }
}

int calcDist(int k){
	int i;
	int minDist = d;
	int tmpDist;
	int halfDist = d >> 1;
	
	for( i=0; i<=n; i++){
		tmpDist = abs(ad[i]-k);
		/*
		if( tmpDist > halfDist ){
			tmpDist = d-tmpDist;
		}
		*/
		if( minDist > tmpDist ){
			minDist = tmpDist;
		}
	}
	return minDist;
}

int main(void){
	int i;
	int sumDist = 0;
	while( 1 ){
		input();
		if( d == 0 ){
			break;
		}
		for( i=1; i<=m; i++){
			sumDist += calcDist(ak[i]);
		}
		printf("%d\n",sumDist);
		sumDist = 0;
	}
}



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

using namespace std ;
typedef long long ll;
typedef string str;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<int, int> pii;
typedef vector<pii> vpii ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}

//xのy乗をpで割った余り

ll pow(ll x,ll y,ll m){
    ll res = 1 ;
    if(y>0){
        res = pow(x,y/2,m) ;
        if(y%2==0){
            res = (res*res)%m ;
        }
        else{
            res = (((res*res)%m)*x)%m ;
        }
    }
    return res ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m ;
  cin >> n >> m ;
  int ans = 0 ;
  int time = 1900*m+100*(n-m) ;
  int per = pow(2,m,MOD) ;
  cout << time*per <<endl ;
  
  
  
  
  return 0 ;
}




Measured memory_bytes: 256
#include <cmath>
#include <iostream>
using namespace std;
bool IsPrime(int v)
{
    int r = sqrt(v);
    for(int i = 2; i <= r; ++i){
        if(v % i == 0){
            return false;
        }
    }
    return true;
}
int main()
{
    int n;
    cin >> n;
    int c = 0;
    for(int i = 0; i < n; ++i){
        int v;
        cin >> v;
        c += IsPrime(v);
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3060
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	static final long MOD = 1000000007;
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		long all = BigInteger.valueOf(2).modPow(BigInteger.valueOf(n), BigInteger.valueOf(MOD)).longValue() - 1;

		System.out.println((all - calc(n, a) - calc(n, b) + MOD * 2) % MOD);
	}

	public static long calc(long n, long r) {
		long p = 1;
		long q = 1;

		for (long i = 0; i < r; i++) {
			p = p * (n - i) % MOD;
			q = q * (i + 1) % MOD;
		}

		return BigInteger.valueOf(q).modInverse(BigInteger.valueOf(MOD)).multiply(BigInteger.valueOf(p)).mod(BigInteger.valueOf(MOD)).longValue();
	}
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int a, b, c, k;

int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    cin >> a >> b >> c >> k;
    if (a < b) {
        swap (a, b);
    }
    if (a < c) {
        swap (a, c);
    }
    while (k > 0) {
        a*=2;
        k--;
    }
    cout << a+b+c << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def divi(n):
  res = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      res.append(i)
      if i != n // i:
        res.append(n // i)
  return res

def main():
  n = ni()

  x = divi(n)
  
  ans = 1e18+7
  for i in range(0, len(x), 2):
    # print(x[i])
    try:
      ans = min(ans, x[i] - 1 + x[i+1] - 1)
    except:
      ans = min(ans, (x[i] - 1) * 2)  
  print(ans)
  
main()

Measured memory_bytes: 3272
#include<iostream>
using namespace std ;
#define MAX 100

int main()
{
	int N,i,j,k,key;
	int A[MAX] ;

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

	for(j=1;j<N+1;j++){
		for(k=0;k<N+1;k++){
			if(k <(N-1)) cout << A[k] << ' ' ;
			if(k==(N-1)) cout << A[k] <<endl ;
		}
		key = A[j];
		i = j-1 ;

		while((i>(-1)) && (A[i]>key))
		{
			A[i+1] = A[i] ;
			i--;
		}

		A[i+1] = key ;
	}

	return 0;
}

Measured memory_bytes: 1164
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import Data.Maybe


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    n <- readLn
    as <- r (n-1)
    let x = U.create $ do
        um <- UM.replicate n (0 :: Int)
        U.mapM_ (\a -> UM.modify um succ (a-1)) as 
        return um
    U.mapM_ print x



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

using namespace std;

long long const INF = 2e16;

int const N = 105;
int const M = 26;

struct matrix {
	long long a[M][M];

	matrix operator*(matrix const& oth) const {
		matrix ret;
		for (int i = 0; i < M; ++i)
			for (int j = 0; j < M; ++j) {
				ret.a[i][j] = INF;
				for (int p = 0; p < M; ++p)
					for (int q = 0; q < M; ++q) 
						if (p != q)
							ret.a[i][j] = min(ret.a[i][j], a[i][p] + oth.a[q][j]);
			}
		return ret;
	}
} A;

matrix KSM(matrix a, int k) {
	matrix ret = a;
	--k;
	for ( ; k; k >>= 1, a = a * a)
		if (k & 1)
			ret = ret * a;
	return ret;
}
 
int f[N][26];

int main() {
	string s;
	long long m;
	static int a[N];

	cin >> s >> m;
	for (int i = 0; i < (int)s.size(); ++i)
		a[i] = s[i] - 'a';

	int n = s.size();
	for (int i = 0; i < 26; ++i) {
		memset(f, 127 / 2, sizeof(f));
		f[0][i] = i != a[0];
		for (int j = 1; j < n; ++j) {
			for (int k = 0; k < 26; ++k) 
				for (int p = 0; p < 26; ++p)
					if (k != p)
						f[j][k] = min(f[j][k], f[j - 1][p] + (a[j] != k));
		}
		for (int j = 0; j < 26; ++j)
			A.a[i][j] = f[n - 1][j];
	}

	/*
	for (int i = 0; i < M; ++i) {
		for (int j = 0; j < M; ++j)
			cerr << A.a[i][j] << ' ';
		cerr << '\n';
	}
	*/

	matrix ans = KSM(A, m);
	long long anss = INF;
	for (int i = 0; i < M; ++i)
		for (int j = 0; j < M; ++j)
			anss = min(anss, ans.a[i][j]);
	cout << anss << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int n,f,e,j,k,i;
  char m[1001],my[1001],c[10],mc[1001];
  scanf("%s",m);
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d %d",c,&f,&e);
    if(c[0]=='p'){
      for(k=f;k<=e;k++){
	printf("%c",m[k]);
      }
      printf("\n");
    }else if(c[3]=='e'){
      j=e;
      for(k=f;k<=e;k++){
	my[j]=m[k];
	j--;
      }
      for(k=f;k<=e;k++){
	m[k]=my[k];
      }
    }else if(c[3]=='l'){
      scanf("%s",mc);
      j=0;
      for(k=f;k<=e;k++){
	m[k]=mc[j];
	j++;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1004
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	a := readInt()
	b := readInt()
	if b%a == 0 {
		println(a + b)
	} else {
		println(b - a)
	}
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

bool isp(int x){
  for(int i=2;i*i<=x;i++){
    if(x%i==0) return false;
  }
  return true;
}

void solve(){
  vector<int> ok(100010,0);
  for(int i=3;i<=100000;i+=2){
    ok[i] = isp(i)&isp((i+1)/2);
  }
  vector<ll> sums(100010+1,0);
  rep(i,100010) sums[i+1] = sums[i] + ok[i];
  int Q; cin >> Q;
  rep(q,Q){
    int l, r; cin >> l >> r;
    r++;
    cout << sums[r]-sums[l] << '\n';
  }
}

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


Measured memory_bytes: 4568
#include<iostream>
#include<cassert>
using namespace std;
struct mat
{
	int w;
	int h;
};
typedef struct mat mat_t;
int mulnum(mat_t,mat_t);
long long min(long long a,long long b);

int n;
mat_t a[101];
long long dp[101][101] ;

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i].h >> a[i].w;
	}
	for(int x = 0;x<n;x++){
		for(int y =0;y<n;y++){
			dp[x][y] = 2000000;
			if(x == y) dp[x][y] = 0;
		}
	}
	int i = 0;
	int j = 1;
	for(int l = 1;l<n;l++){
		i = 0;
		for(j=l;j<n;j++){
			for(int k = i;i <= k && k < j;k++){
				dp[i][j] = min(dp[i][j],dp[i][k] + dp[k+1][j] + a[i].h *a[k].w * a[j].w);
			}
			i++;
		}
	}
	/*
	for(int x = 0;x<n;x++){
		for(int y=0;y<n;y++){
			cerr << dp[x][y] << " ";
		}
		cerr << endl;
	}
	*/
	cout << dp[0][n-1] << endl;
}

int mulnum(mat_t a,mat_t b){
	assert(a.h == b.w);
	return a.h*a.w*b.h;
}

long long min(long long a,long long b) {
	return a<b? a:b;
}

Measured memory_bytes: 3112
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int a, b;
  cin >> a >> b;
  int n = 1;
  int x = 0;
  while(n < b) n += a - 1, x++;
  cout << x << endl;
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
    int n;
	cin >> n;
	vector<string> w(n);
  	rep(i,n) {
      	cin >> w[i];
      	if(i != 0 && w[i-1][w[i-1].size()-1] != w[i][0]){
        	puts("No");
          	return;
        }
    }
	sort(all(w));
  	rep(i,n-1){
    	if(w[i] == w[i+1]){
        	puts("No");
          	return;        
        }
    }
  
  	puts("Yes");
  	return;
}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int tot = 0;
		int ans = 0;

//		System.out.println("a "+a);
//		System.out.println("b "+b);
//		System.out.println("c "+c);
//		System.out.println("x "+x);
		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				for (int k = 0; k <= c; k++) {
					tot = i * 500 + j *100 + k * 50;
					if (tot == x) {
//						System.out.print(" i "+i);
//						System.out.print(" j "+j);
//						System.out.println(" k "+k);
//						System.out.println(tot);
						ans ++;
					}
				}
			}
			
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22868
while True:
    line = input().split()
    a = int(line[0])
    op = line[1]
    b = int(line[2])

    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    elif op == '?':
        break


Measured memory_bytes: 5592
n,a,b,c,d = gets.split.map(&:to_i)
S = gets.chomp
if S[a-1..[c,d].max-1].include?("##")
    puts "No"
    exit
end
if c<d
    puts "Yes"
else
    if S[b-2..d].include?("...")
        puts "Yes"
    else
        puts "No"
    end
end

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

using namespace std;

int waga[105];
int wart[105];

int opty[100005];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, w;

    cin>>n>>w;

    for(int i=1; i<=n; i++) {
        cin>>waga[i]>>wart[i];

    }

    for(int i=1; i<=100000; i++)opty[i]=1000000009;

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

        for(int j=100000; j>=1; j--) {

            if(j-wart[i]>=0 && opty[j-wart[i]]!=1000000009) {

                opty[j]=min(opty[j], opty[j-wart[i]]+waga[i]);
            }
        }
    }

    int wynik=0;

    for(int i=1; i<=100000; i++) {

        if(opty[i]<=w)wynik=max(wynik, i);
    }

    cout<<wynik;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
const long long mod = 1000000007;
//const long long mod = 998244353;
int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	for (int i = 0;; i++) {
		N /= K;
		if (N == 0) {
			printf("%d", i + 1);
			return 0;
		}
	}
	while (1)getchar();
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    int x;
    cin >> x;
    vector<bool> p(x,false);
    p[100] = p[101] = p[102] = p[103] = p[104] = p[105] = true;
    FOR(i,106,x+1){
        FOR(j,100,106){
            if (p[i-j]){
                p[i] = true;
            }
        }
    }
    cout << p[x];
    rn 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long mod = 1000000007;
    int h = sc.nextInt();
    int w = sc.nextInt();
    char[][] path = new char[h][w];
    for(int i=0;i<h;i++)path[i]=sc.next().toCharArray();
    long[][] cost = new long[h][w];
    cost[0][0]=1;
    for(int i=1;i<h;i++){
      if(path[i][0]=='.')cost[i][0]=cost[i-1][0];
      else cost[i][0]=0;
    }
    for(int i=1;i<w;i++){
      if(path[0][i]=='.')cost[0][i]=cost[0][i-1];
      else cost[0][i]=0;
    }
    for(int i=1;i<h;i++){
      for(int j=1;j<w;j++){
        if(path[i][j]=='.')cost[i][j]=(cost[i-1][j]+cost[i][j-1])%mod;
        else cost[i][j]=0;
      }
    }
    System.out.println(cost[h-1][w-1]);
  }
}

Measured memory_bytes: 49556
#include <bits/stdc++.h>
using namespace std;
vector<int>e[2005];int n,a[2005],vis[2005],ind[2005],use[2005];
void dfs(int x){vis[x]=1;for(int i=1;i<=n;i++) if(!vis[i]&&__gcd(a[i],a[x])!=1) e[x].push_back(i),ind[i]++,dfs(i);}
int main()
{
	scanf("%d",&n);for(int i=1;i<=n;i++) scanf("%d",&a[i]);sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) if(!vis[i]) dfs(i);
	for(int i=1;i<=n;i++) for(int j=n;j;j--) if(!use[j]&&!ind[j])
	{
		use[j]=1;printf("%d ",a[j]);
		for(int k=0;k<e[j].size();k++) ind[e[j][k]]--;
		break;
	}
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n;
    cin >> n;
    vector<int> l(n*2);
    rep(i,0,n*2) cin >> l[i];
    sort(l.begin(),l.end());
    int ans=0;
    for(int i=0; i<n*2; i+=2) ans+=min(l[i],l[i+1]);
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  ll sum=0;
  int si=s.size()-1;
  for(int bit=0; bit<(1<<si);++bit){
    ll tmp=s[0]-'0';
    for(int i=0;i<si;i++){
      if(bit&(1<<i)){
        sum+=tmp;
        tmp=0;
      }
      tmp=tmp*10+(s[i+1]-'0');
    }
    sum+=tmp;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 * C - Not so Diverse
 * https://atcoder.jp/contests/abc081/tasks/arc086_a
 **/
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    map<int, int> m;
    for(int i=0;i<N;i++) {
        cin >> A[i];
        if(m.count(A[i])==0){
            m[A[i]] = 1;
        } else {
            m[A[i]]++;
        }
    }

    int size = m.size();
    vector<int> hoge;
    for(auto mi:m) {
        hoge.push_back(mi.second);
    }
    sort(hoge.begin(), hoge.end());

    int ans = 0;
    if(size<=K) {
        ans = 0;
    } else {
        for(int i=0; i<size-K; i++) {
            ans += hoge[i];
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 11516
import sys
import math
import heapq
from collections import defaultdict, deque
from decimal import *
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

n=r()
a=rl()
a.sort(reverse=True)
b=[0,a[0]]
i=1
while len(b)<n and i<n:
    b.append(a[i])
    b.append(a[i])
    i+=1
print(sum(b[:n]))

Measured memory_bytes: 112060
def floor_sum(n, m, a, b):
    out = 0
    while True:
        out += (n - 1) * n * (a // m) // 2 + n * (b // m)
        a %= m
        b %= m
        y_max = (a * n + b) // m
        if y_max == 0:break
        x_max = y_max * m - b
        out += (n - (x_max + a - 1) // a) * y_max
        n, m, a, b = y_max, a, m, (a - x_max % a) % a
    return out

T=int(input())
for i in range(T):
  n,m,a,b=map(int,input().split())
  print(floor_sum(n,m,a,b))

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

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader r =
         new BufferedReader(new InputStreamReader(System.in));       
        String line = r.readLine();   
        
        int cnt=1;
        int buf[]= {0,0};
        while(line!=null){
            String st[] = line.split(" ",0);
            buf[0] = Integer.parseInt(st[0]);
            buf[1]= Integer.parseInt(st[1]);
            if (buf[0] == 0 && buf[1]==0) break;
            Arrays.sort(buf);
            System.out.println(buf[0]+" "+buf[1]);
            line = r.readLine();
        }        
    }
}

Measured memory_bytes: 27236
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;



int main() {
    char a; cin >> a;
    if((a - 'a')>= 0) {
        cout << "a" << endl; 
    } else {
        cout << "A" << endl; 
    }
    return 0;
}

Measured memory_bytes: 3632
<?php
fscanf(STDIN,"%d %d",$h,$w);
for($i=0; $i <$h ; $i++)
	fscanf(STDIN,"%s",$a[$i]);
for ($i=0; $i < $h; $i++)
{ 
	for ($j=0; $j < $w; $j++)
	{ 
		if($a[$i][$j]=='#')
		{
			$lineb[$i]++;
			$rowb[$j]++;
		}
	}
}

for ($i=0; $i < $h; $i++)
{
	$br=0;
	for ($j=0; $j < $w; $j++)
	{ 
		if($lineb[$i]>=1 && $rowb[$j]>=1)
		{
			printf("%s",$a[$i][$j]);
			$br++;
		}
	}
	if($br!=0)
		printf("\n");
}

Measured memory_bytes: 4604
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

N = int(input())
A = list(map(int, input().split()))

L = [0]
R = [0]

for n in range(N-1):
    L.append(gcd(L[n], A[n]))
    R.append(gcd(R[n], A[-1-n]))

M = []

for n in range(N):
    M.append(gcd(L[n], R[-1-n]))

ans = max(M)
print(ans)

Measured memory_bytes: 14052
n = int(input())
p= []
AC = 0
WA = 0
TLE = 0
RE = 0
 
for i in range(n):
  p.append(input())
  
for j in p :
  if j == "AC":
    AC += 1
  elif j == "WA":
    WA += 1
  elif j == "TLE":
    TLE += 1
  else:
    RE += 1


  
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))

Measured memory_bytes: 16188
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;
  h = min(h, 2*q);
  s = min(s, 2*h);
  d = min(d, 2*s);
  ll sum = n/2 * d;
  n %= 2;
  sum += n * s;
  dump(sum);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <iomanip>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    string res = "Yes";
    string yaki = "YAKI";
    REP(i,yaki.size())
    {
        if(s[i] != yaki[i])res = "No";
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] m = new int[n];
		int[] d = new int[n];
		int[] w = new int[n];
		for(int i=0;i<n;i++){
			m[i] = sc.nextInt();
			d[i] = sc.nextInt();
			w[i] = sc.nextInt();
		}
		
		double[][] dp = new double[1<<n][n];
		int[][] pre = new int[1<<n][n];
		int[][] wgt = new int[1<<n][n];
		for(int i=0;i<(1<<n);i++){
			Arrays.fill(dp[i], -1.0);
			Arrays.fill(pre[i], -1);
			Arrays.fill(wgt[i], -1);
		}
		dp[0][0] = 0;

		for(int j=0;j<1<<n;j++){
			for(int v=0;v<n;v++){
				if(dp[j][v]>-1){
					for(int u=0;u<n;u++){
						if((j&(1<<u))>0) continue;
						double q = dp[j][v] + Math.abs(d[v]-d[u])/(2000.0/(double)(70+wgt[j][v]));
						if(dp[j^(1<<u)][u]<=0 || dp[j^(1<<u)][u]>q){
							dp[j^(1<<u)][u] = q;
							pre[j^(1<<u)][u] = v;
							wgt[j^(1<<u)][u] = wgt[j][v] + w[u] * 20;
						}
					}
				}
			}
		}

		double min = Double.MAX_VALUE;
		int num = 0;
		for(int i=0;i<n;i++){
			if(dp[(1<<n)-1][i]>-1 && min>dp[(1<<n)-1][i]){
				min = dp[(1<<n)-1][i];
				num = i;
			}
		}
		
		ArrayList<Integer> list = new ArrayList<Integer>();
		list.add(m[num]);
		int s = (1<<n)-1;
		while(pre[s][num]!=-1){
			list.add(m[pre[s][num]]);
			int t = s^(1<<num);
			num = pre[s][num];
			s = t;
		}
		
		for(int i=list.size()-2;i>0;i--) System.out.print(list.get(i) + " ");
		System.out.println(list.get(0));
	}	
}

Measured memory_bytes: 33244
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
using namespace std;

struct start { start() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(10);
}; }start;

typedef long long ll;


int main(){
    ll n,memo = 0;
    cin >> n;
    ll a[n];
    
    rep(i,0,n){
        cin >> a[i];
        memo += a[i];
    }
    
    sort(a,a+n);
    
    cout << a[0] << " " <<a[n-1] << " " << memo << endl;
    
    return 0;
}


Measured memory_bytes: 3240
def main():
    X, K, D = map(int, input().split())

    L = abs(X)

    r = L // D
    c = L % D

    if K < r:
        print(L - K * D)
    elif K == r:
        print(c)
    elif K == r + 1:
        print(D - c)
    else:  # K > r + 1:
        if K % 2 == r % 2:
            print(c)
        else:
            print(D - c)


if __name__ == '__main__':
    main()


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

int main()
{   
    int n,d,x;
    cin>>n>>d>>x;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<100;j++){
            if(j*a[i]+1>d) break;
            ans++;
        }
    }
    
    cout<<ans+x<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>

int main(void) 
{
    std::string str;
    int lens[3];
    int nolines;

    getline(std::cin, str);
    std::istringstream str_s(str);

    str_s >> nolines;

    int i;
    for (i = 0; i < nolines; i++) {
        getline(std::cin, str);
        std::istringstream str_s(str);

        str_s >> lens[0] >> lens[1] >> lens[2];

        std::sort(lens, lens+3);

        if (lens[2] * lens[2] == lens[0] * lens[0] + lens[1] * lens[1]) 
            std::cout << "YES" << std::endl;
        else
            std::cout << "NO"  << std::endl;
    }

    return 0;
}

Measured memory_bytes: 0
N, *_XY = open(0).read().split()
N = int(N)
XY = list(zip(*[map(int, iter(_XY))]*2))

import itertools
import numpy as np

routes = list(itertools.permutations(XY, N))

memo = {}
d_list = []

for r in routes:
    d = 0
    for i in range(N-1):
        if (r[i], r[i+1]) in memo.keys():
            d += memo[(r[i], r[i+1])]
        elif (r[i+1], r[i]) in memo.keys():
            d += memo[(r[i+1], r[i])]
        else:
            memo[(r[i], r[i+1])] = np.linalg.norm(np.array(r[i]) - np.array(r[i+1]))
            d += memo[(r[i], r[i+1])]
    d_list.append(d)

print(np.mean(d_list))

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

int main() {
  int n,K;
  cin >> n >> K;
  int x[n],y[n];
  for(int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  long long int ans = -1;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      for(int k = 0; k < n; k++) {
        for(int l = 0; l < n; l++) {
          long long int y1 = min(y[i],y[j]);
          long long int y2 = max(y[i],y[j]);
          long long int x1 = min(x[k],x[l]);
          long long int x2 = max(x[k],x[l]);
          int count = 0;
          for(int m = 0; m < n; m++) {
            if(x1 <= x[m] && x[m] <= x2 && y1 <= y[m] && y[m] <= y2) {
              count++;
            }
          }
          if(count >= K) {
            long long int tmp = (y2 - y1) * (x2 - x1);
            if(ans == -1 || ans >= tmp) {
              ans = tmp;
            }

          }

        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
class Node
    attr_accessor :index, :children, :parent

    def initialize()
        @children = [nil, nil]
        @parent = nil
    end

    def depth
        parent == nil ? 0 : parent.depth + 1
    end

    def degree
        children.length
    end

    def height
        if children.empty?
            0
        else
            children.map {|e| e.height }.max + 1
        end
    end

    def preorder_array
        left_array = children[0] == nil ? [] : children[0].preorder_array
        right_array = children[1] == nil ? [] : children[1].preorder_array
        [[self], [left_array], [right_array]].flatten
    end

    def inorder_array
        left_array = children[0] == nil ? [] : children[0].inorder_array
        right_array = children[1] == nil ? [] : children[1].inorder_array
        [[left_array], [self], [right_array]].flatten
    end

    def postorder_array
        left_array = children[0] == nil ? [] : children[0].postorder_array
        right_array = children[1] == nil ? [] : children[1].postorder_array
        [[left_array], [right_array], [self]].flatten
    end

    def insert(node)
        if @index >= node.index
            if @children[0] == nil
                @children[0] = node
            else
                @children[0].insert(node)
            end
        else
            if @children[1] == nil
                @children[1] = node
            else
                @children[1].insert(node)
            end
        end
    end

    def find(i)
        return true if @index == i
        if @index >= i && @children[0] != nil
            return children[0].find(i)
        elsif @index < i && @children[1] != nil
            return @children[1].find(i)
        end
        false
    end
end

root_node = nil

gets.to_i.times do
    s,i=gets.chomp.split(" ")
    
    if s == "insert"
        i = i.to_i
        if root_node == nil
            root_node = Node.new
            root_node.index = i
        else
            node = Node.new
            node.index = i
            root_node.insert(node)
        end
    elsif s == "find"
        i = i.to_i
        if root_node != nil && root_node.find(i)
            puts "yes"
        else
            puts "no"
        end
    else
        if root_node == nil
            puts ""
            puts ""
        else
            puts " " + root_node.inorder_array.map {|e|e.index}.join(" ")
            puts " " + root_node.preorder_array.map {|e|e.index}.join(" ")
        end
    end
end



Measured memory_bytes: 94640
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second

int main(){

	int W,H,x,y,r;

	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);

	if(0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H) {
		printf("Yes\n");
	}else {
		printf("No\n");
	}
	return 0;
}



Measured memory_bytes: 3148
N=int(input())
c=str(input())
num_R = c.count("R")
num_W = 0
ans = []
if num_R >= num_W:
    ans.append(num_R)
else:
    ans.append(num_W)
#print(ans)
for i in range(len(c)):
    if c[i] == "R":
        num_R -= 1
    else:
        num_W += 1
    if num_R >= num_W:
        ans.append(num_R)
    else:
        ans.append(num_W)
    #print(ans)
print(min(ans))


Measured memory_bytes: 83516
#include<bits/stdc++.h>
const int maxk=100001;
using namespace std;
int main()
{
   long long a,b,x;
   cin>>a>>b>>x;
   long long max;
   if(x>=b)
   {
       max=(long long)(a*(b-1)/b);
   } else
   {
       max=(long long )(a*x/b);
   }
   cout<<max;

}

Measured memory_bytes: 3632
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *AB = map(int, read().split())
    G = [[] for _ in range(N)]
    for a, b in zip(AB[::2], AB[1::2]):
        G[a - 1].append(b - 1)
        G[b - 1].append(a - 1)

    COM_MAX = K

    fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2, COM_MAX + 1):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    def mod_perm(n, r):
        if n < r:
            return 0
        if n < 0 or r < 0:
            return 0
        return fac[n] * (finv[n - r] % MOD) % MOD

    stack = deque([0])
    order = []
    parent = [-1] * N
    while stack:
        v = stack.pop()
        order.append(v)
        for nv in G[v]:
            if nv != parent[v]:
                stack.append(nv)
                parent[nv] = v

    A = [0] * N
    for v in reversed(order):
        tmp = 1
        child = 0
        for nv in G[v]:
            if nv != parent[v]:
                tmp = tmp * A[nv] % MOD
                child += 1

        colors = K if v == 0 else K - 2
        nodes = child + 1 if v == 0 else child

        A[v] = tmp * mod_perm(colors, nodes) % MOD

    print(A[0])
    return


if __name__ == '__main__':
    main()


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


int n,Y,M,D;
int ans;


int main(){


  cin >> n;
  while(n){
    cin >> Y >> M >> D;
    ans = 0;
    while( Y < 1000){

      while( M <= 10 ){

	if( Y%3 == 0 ){
	  while( D <= 20 ){
	    D++;
	    ans++;
	  }
	  D = 1;
	  M++;
	}else{
	  if( M%2 == 0 ){
	    while( D <= 19){
	      D++;
	      ans++;
	    }
	    D = 1;
	    M++;
	  }else{
	    while( D <= 20 ){
	      D++;
	      ans++;
	    }
	    D = 1;
	    M++;
	  }
	}
      }
      M = 1;
      Y++;
    }
    cout << ans << endl;
    n--;
  }  
  return 0;
}

Measured memory_bytes: 1160
n = int(input())
A = list(map(int, input().split()))

A.sort()
B = []
B.append([A[0], 1])
for i in range(1, n) :
    if A[i] != A[i-1] :
        B.append([A[i], 1])
    else :
        B[-1][1] += 1
#print(B)

ans = 0
for i in range(len(B)) :
    if B[i][0] < B[i][1] :
        ans += B[i][1] - B[i][0]
    elif B[i][0] > B[i][1] :
        ans += B[i][1]

print(ans)


Measured memory_bytes: 16880
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;

int main()
{
    string s;
    cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4) << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end());

	int ans = h[k - 1] - h[0];
	for (int i = 1; i <= n - k; i++) {
		ans = min(ans, h[k + i - 1] - h[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;
const int MAX_N = 110;
struct edge
{
    int to, cost, card;
    bool operator<(const edge &a) const { return cost > a.cost; }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int c, n, m, s, d;
    while (cin >> c >> n >> m >> s >> d, c | n | m)
    {
        s--, d--;
        vector<edge> G[MAX_N];
        for (int i = 0; i < m; i++)
        {
            int a, b, f;
            cin >> a >> b >> f;
            a--, b--;
            G[a].push_back({b, f, 0});
            G[b].push_back({a, f, 0});
            G[a].push_back({b, f / 2, 1});
            G[b].push_back({a, f / 2, 1});
        }
        priority_queue<edge> que;
        vector<vector<int>> dist(n, vector<int>(15, INF));
        dist[s][c] = 0;
        que.push({s, 0, c});
        while(que.size())
        {
            edge p = que.top(); que.pop();
            for(int u = 0; u < G[p.to].size(); u++)
            {
                edge e = G[p.to][u];
                int num = p. card - e.card;
                if(num < 0) continue;
                if(e.cost + dist[p.to][p.card] < dist[e.to][num])
                {
                    dist[e.to][num] = dist[p.to][p.card] + e.cost;
                    que.push({e.to, dist[e.to][num], num});
                }
            }
        }
        int ans = INF;
        for(int i = 0; i < 15; i++) ans = min(ans, dist[d][i]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)j; i<(int)n; i++)
int main() {
  int h,w; cin>>h>>w;
  char c[h][w];
  rep(i,0,h){
    rep(j,0,w) cin>>c[i][j];
  }
  rep(i,0,h){
    rep(j,0,w) cout<<c[i][j];
    cout<<endl;
    rep(j,0,w) cout<<c[i][j];
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

const int N = 10;
const int MAX = 101;
const int S = 1001;


ll dp[N][MAX][S];
int n,s;

void make(){
  
  for(int i = 0; i < MAX; i++) dp[1][i][i] = 1;

  for(int i = 1; i < N-1; i++)
    for(int j = 0; j < MAX; j++)
      for(int k = 0; k < S; k++){
	if(dp[i][j][k] == 0) continue;
	for(int l = j+1; l < MAX; l++)
	  if(k+l >= S) break;
	  else dp[i+1][l][k+l] += dp[i][j][k];
  }
}

int main(){
  make();
  while(cin >> n >> s && n+s){
    ll ans = 0;
    for(int i = 0; i < MAX; i++) ans += dp[n][i][s];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 7288
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf8");

var reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on("line", (line: string): void => {
  const num: number = parseInt(line);
  console.log(num === 1 ? 1 : num * (num + 1) / 2);
});

Measured memory_bytes: 9548
xy_list = list(map(int,input().split()))
x1 = xy_list[0]
y1 = xy_list[1]
x2 = xy_list[2]
y2 = xy_list[3]

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x1 - (y2 - y1)
y4 = y1 + (x2 - x1)

print(str(x3) + ' ' + str(y3) + ' ' + str(x4) + ' ' + str(y4))

Measured memory_bytes: 3064
N, M = map(int, input().split())

aLst = [0] * M
bLst = [0] * M

for i in range(M):
    a, b = map(int, input().split())
    aLst[i] = a
    bLst[i] = b

for i in range(1, N + 1):
    ans = aLst.count(i)
    ans += bLst.count(i)
    print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
  char a[1000];
  gets(a);
  int s,t=0,num=0,i;
  for(i=0;a[i]!='\0';i++);
  s=i--;
  for(i=0;i<s;i++)
  {
      if(a[i]=='A'||a[i]=='G'||a[i]=='C'||a[i]=='T')
      {
          num++;
      }
      else num=0;
      if(num>t)  t=num;
  }
  printf("%d",t);
return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <stack>
#include <queue>
#include <string>
#include <map>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d\n",a);
#define pfii(a,b) printf("%d %d\n",a,b);
#define pfl(a) printf("%lld\n",a);
#define pfll(a,b) printf("%lld %lld\n",a,b);
#define  SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;


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

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

int grid [1003][1003];


long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}
ll isprime(ll i){
    if (i==2 || i == 3){
        return 0;
    }
    bool ctr =0;
    for(ll k = 2;k*k <i;k++){
        if(i%k==0)ctr=1;
    }
    if(ctr)return 1;
    else return 0;

}

int main()
{
    string s;
    cin >> s;
   FOR(a,s.size()){

       if((a+1)%2 == 1){
           if(s[a] == 'L'){
               cout<<"No";
               return 0;
           }
       }else {
           if(s[a] == 'R'){
               cout<<"No";
               return 0;
           }
       }
   }
    cout <<"Yes";

  return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k;
string s, t;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> k;
	k = 2*k + 1;
	cout<<(ll)((n+k-1)/k);
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
typedef unsigned long long ull;
const int N=43+5;
const double eps=1e-6;
const int MOD=1e5+3;
const int INF=0x3f3f3f3f;
int main()
{
    int a,b,c;
    while(~scanf("%d/%d/%d",&a,&b,&c))
        printf("2018/%02d/%02d\n",b,c);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a , b , t;
  cin >> a >> b >> t;
  cout << b * (t / a) << endl;
  return 0;
}


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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto (i) = (vec).begin(); (i) != (vec).end(); (i)++)
#define vrREP(i, vec) for(auto (i) = (vec).end()-1;(i) != (vec).begin()-1;(i)--)

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class Solve{
  private:
    int n, a;
    Vint A;
    Wlli DP;
    /* ~~~~ 目的 : 平均が a となるものの個数を計算 ~~~~
    *  B[i] := A[i] - a  ; ただし, Aはソート済みとする
    *  DP[i][j] = B[0], ... B[i]を使って, 和が j となるようなものの個数
    *     ただし, nB[0] ≤ j ≤ nB[n-1]  (ただし, B[0] ≤ 0 and B[n-1] ≥ 0) -> そうでない場合は 0
    *     ここで, J := j - nB[0]と変数変換を行なう (0 ≤ J ≤ n(B[n-1]- B[0]) )
    *     " 以下において, t := -nB[0] ≥ 0 とおく "
    *                   s := n(B[n-1] - B[0])
    *  =>  DP[n-1][t]を計算したい !!!
    *  ==== 初期値について ====
    *  DP[0][t] = 1 (何も選ばない)
    *  DP[0][t + B[0]] = 1 (A[0]を選ぶ場合)
    *  DP[0][else] = 0
    *  ==== 漸化式について ====
    *  DP[i][j] = DP[i-1][j] (0 > j - B[i] or j - B[i] < s)
    *           = DP[i-1][j] + DP[i-1][j - B[i]] (B[i] ≤ j ≤ s + B[i])
    */
  public:
    Solve(int nn, int aa){
      n = nn;
      a = aa;
      A.resize(nn);
    }
    ~Solve(void){};
    void getIn(void){
      vREP(ele, A) cin >> *ele;
      sort(A.begin(), A.end());
    }
    void solving(void){
      if( (A.at(0) > a) || (A.at(n - 1) < a) ){
        cout << "0\n"; return;
      }
      vREP(ele, A) *ele -= a;
      int T = -(n * A.at(0));
      int S = n * (A.at(n-1) - A.at(0));
      DP.resize(n, Vlli(S + 1, 0));
      DP[0][T]++; DP[0][T + A.at(0)]++;
      FOR(i, 1, n){
        FOR(j, 0, S + 2){
          DP[i][j] = DP[i-1][j];
          if(A.at(i) <= j && j <= S + A.at(i)) DP[i][j] += DP[i-1][j-A.at(i)];
        }
      }
      cout << DP[n-1][T] - 1 << "\n";
    }

};


int main(void){
  int n, a; cin >> n >> a;
  Solve cls(n, a);
  cls.getIn();
  cls.solving();
  return 0;
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  int X = A, Y = 0;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      if (i == 0 && j == 0)
        continue;
      for (int k = 0; k < 100; k++) {
        for (int l = 0; l < 100; l++) {
          int x = 100 * A * i + 100 * B * j;
          int y = C * k + D * l;

          if (x + y <= F && y * 100 <= x * E &&
              (double)y / (x + y) >= (double)Y / (X + Y)) {
            X = x;
            Y = y;
          }
        }
      }
    }
  }
  cout << X + Y << ' ' << Y << endl;
}

Measured memory_bytes: 256