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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    cin >> skipws;

    int n;

    for (;;) {
        cin >> n;
        if (!n)
            break;

        vector<vi> v(21, vi(21, 0));
        rep(i, 0, n) {
            int x, y;
            cin >> x >> y;
            v[x][y] = 1;
        }

        int m;
        cin >> m;
        int cx = 10, cy = 10;

        v[cx][cy] = 0;

        rep(i, 0, m) {
            int dx, dy;

            char d;
            int s;
            cin >> d >> s;

            switch (d) {
            case 'E':
                dx = 1, dy = 0;
                break;
            case 'S':
                dx = 0, dy = -1;
                break;
            case 'W':
                dx = -1, dy = 0;
                break;
            case 'N':
                dx = 0, dy = 1;
                break;
            }

            rep(i, 0, s) {
                cx += dx, cy += dy;
                v[cx][cy] = 0;
            }
        }

        int left = 0;
        rep(i, 0, 21) rep(j, 0, 21) left += v[i][j];
        cout << (left ? "No" : "Yes") << endl;
    }
}


Measured memory_bytes: 3044
#include <iostream>
#include <numeric>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#include <iterator>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;

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

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve();
	}

	void solve() {
		Scanner sc =  new Scanner(System.in);

		//上下左右
		int[] dx = {1, 0, -1, 0};
		int[] dy = {0, 1, 0, -1};

		int H = sc.nextInt();
		int W = sc.nextInt();

		char[][] charMap = new char[H][W];
		boolean[][] map = new boolean[H][W];

		Queue<Place> que = new ArrayDeque<Place>();

		// 入力文字列の抽出
		for (int i = 0; i < H; i++) {
			String s =  sc.next();
			charMap[i] = s.toCharArray();
			for (int j = 0; j < W; j++) {
				if (charMap[i][j] == '#') {
					que.add(new Place(i, j, 0));
					map[i][j] = true;
				}
			}
		}
		int max = 0;
		while (que.size() != 0){
			Place place = que.remove();

			for (int i = 0; i < 4; i++) {
				int x = place.getX() + dx[i];
				int y = place.getY() + dy[i];
				if (x < 0 || x >= H || y < 0 || y >= W) {
					continue;
				}
				if (! map[x][y]) {
					que.add(new Place(x,y, place.getCount() + 1));
					map[x][y] = true;
					max = place.getCount() + 1;
				}
			}
		}
		System.out.println(max);
	}

	// 場所を記憶
	class Place {
		private int x;
		private int y;
		private int count;

		public Place(int x, int y, int count) {
			this.x = x;
			this.y = y;
			this.count = count;
		}
		public int getX() {
			return this.x;
		}

		public int getY() {
			return this.y;
		}
		public int getCount() {
			return this.count;
		}
	}
}


Measured memory_bytes: 67872
require 'prime'

# util functions
def gcd(arr) # arr: Array of non-negative integers
  if arr.size < 2
    raise "array (#{arr}) size is less than 2."
  end
  
  def gcd_two(a, b) # assume b <= a
    return a if b % a == 0
    return gcd_two(b % a, a)
  end

  g = arr[0]
  for i in 1..arr.size - 1 do
    g = gcd_two([g, arr[i]].min, [g, arr[i]].max)
  end
  return g
end


# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

ap = inputs[1][0]
bp = inputs[1][1]
for i in 2..inputs.size-1
  aa = inputs[i][0]
  bb = inputs[i][1]

  ad = (ap + aa - 1) / aa
  bd = (bp + bb - 1) / bb

  mulv = [ad, bd].max
  ap = aa*mulv
  bp = bb*mulv

  pd [ap, bp]
end

puts ap+bp


Measured memory_bytes: 2300
import java.util.Scanner;
import java.io.FileInputStream;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();


		if ((A+X)<B) {
			System.out.println("dangerous");
		}else if (A>=B) {
			System.out.println("delicious");
		}else{
			System.out.println("safe");
		}
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<list>
#include<cmath>
#include<map>
using namespace std;
using ll = long long;
const int INF = 1e9;
#define rep(i,n)for(int i=0;i<n;++i)
#define p pair<int,int>
int main() {
	int n;
	cin >> n;
	int ev[100100] = { 0 };
	int ae;int  ao = 0;
	int anse = 0; int anso = 0;
	int sume = 0;int  sumo = 0;
	int od[100100] = { 0 };
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if (i % 2 == 0) {
			ev[a]++;
		}
		else {
			od[a]++;
		}
	}
	for (int i = 0; i < 100100; ++i) {
		if (anse <= ev[i]) {
			ae = anse;
			anse = ev[i];
			sume = i;
		}
		else if (ae < ev[i])
			ae = ev[i];
		if (anso <= od[i]) {
			ao = anso;
			anso = od[i];
			sumo = i;
		}
		else if (ao < od[i]) {
			ao = od[i];
		}
	}
	if (sumo != sume) {
		cout << n - anse - anso;
		return 0;
	}
	else {
		cout << min(n - anse - ao, n - anso - ae);
	}
	return 0;
}

Measured memory_bytes: 1024
import itertools
#import math
N = int(input())
L = list(map(int, input().split()))
cnt = 0
tmp_l = list(itertools.combinations(L,3))
for ls in tmp_l:
    if (ls[0] + ls[1] > ls[2]) & (ls[1] + ls[2] > ls[0]) & (ls[0] + ls[2] > ls[1]):
        if (ls[0] != ls[1] ) & (ls[1] != ls[2] ) & (ls[0] != ls[2] ):
            cnt += 1
print(cnt)









Measured memory_bytes: 86788
#include<bits/stdc++.h>
using namespace std;
#define int long long

int32_t main(){
  int n;
  cin>>n;
  double p[n];

  for(int i=0;i<n;i++)cin>>p[i];
  double dp[n+1][n+1];
  memset(dp,0.0,sizeof dp);
  dp[0][0]=1.0;

  for(int i=1;i<=n;i++){
    for(int j=0;j<=i;j++){
        if(j==0){
          dp[i][j]=dp[i-1][j]*(1.0-p[i-1]);
        }else{

          dp[i][j]=(dp[i-1][j]*(1.0-p[i-1])+dp[i-1][j-1]*p[i-1]);
        }

    }
  }
  double ans=0;
  for(int j=(n/2+1);j<=n;j++){
    ans+=dp[n][j];
  }
  cout<<setprecision(10)<<ans;
}


Measured memory_bytes: 70656
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m,r=map(int,input().split())
    R=list(map(lambda x:int(x)-1,input().split()))
    A=[[INF]*n for _ in range(n)]
    for _ in range(m):
        a,b,c=map(int,input().split())
        a-=1; b-=1
        A[a][b]=A[b][a]=c

    from itertools import product
    for k,i,j in product(range(n),repeat=3):
        A[i][j]=min(A[i][j],A[i][k]+A[k][j])

    # dp[V][x] : 経過済みの頂点V 最後の到達地点x
    N=2**r
    dp=[[INF]*r for _ in range(N)]

    # initialize dp[1<<x][x]=0
    for x in range(r):
        dp[1<<x][x]=0

    # iterate
    for V in range(N):
        for x in range(r):
            if(not (V>>x)&1): continue
            for y in range(r):
                if((V>>y)&1): continue # 既に y に到達している場合は考えない
                dp[V+(1<<y)][y]=min(dp[V+(1<<y)][y],dp[V][x]+A[R[x]][R[y]])

    # output
    print(min(dp[N-1][x] for x in range(r)))
resolve()

Measured memory_bytes: 61788
#include <iostream>
#define ll long long int

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

  int A[N+1];
  for(int i=0; i<N; i++){
    std::cin >> A[i];
  }
  A[N] = 0; //番兵

  ll count = 0;
  for(int i=0; i<N; i++){
    count += A[i]/2;
    A[i] -= (A[i]/2)*2;
    if(A[i] && A[i+1]){
      count++;
      A[i]--;
      A[i+1]--;
    }
  }
  std::cout << count << std::endl;

  return 0;
}

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

int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);cout.tie(NULL);
    int h,n,sum = 0,k;
    cin>>h>>n;
    for(int i = 0 ; i < n ; i++){
      cin>>k;
      sum += k;
    }
    if(sum >= h)cout<<"Yes\n";
  else cout<<"No\n";
}

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

int divide(int n){
  int ans = 0;
  for(int i=1;i<=n;i++){
    if((n%i)==0) ans++;
  }
  return ans;
}
int main(){
  int N;
  cin >> N;
  int ans=0;
  for(int i=1;i<=N;i+=2){
    if(divide(i) == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
LI = lambda: list(map(int, input().split()))

a, b, c, d = LI()


def main():
    ans = a * c
    ans = max(ans, a * d)
    ans = max(ans, b * c)
    ans = max(ans, b * d)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n, _ := strconv.Atoi(stdin.Text())
	for i := 0; i < n; i++ {
		base := [3]bool{}
		score, out := 0, 0
		for stdin.Scan() {
			switch stdin.Text() {
			case "HIT":
				if base[2] { // 3塁
					score++
				}
				if base[1] { // 2塁
					base[2] = true
					base[1] = false
				}
				if base[0] { // 1塁
					base[1] = true
				}
				base[0] = true
			case "HOMERUN":
				for i := 0; i < 3; i++ {
					if base[i] {
						score++
						base[i] = false
					}
				}
				score++
			case "OUT":
				out++
			}
			if out >= 3 {
				fmt.Println(score)
				break
			}
		}
	}
}



Measured memory_bytes: 1052
#%%
a, b, k = map(int, input().split())
for i in range(k//2):
    if a%2 == 1:
        a -= 1
    a //= 2
    b += a
    if b%2 == 1:
        b -= 1
    b //= 2
    a += b

if k%2 == 1:
    if a%2 == 1:
        a -= 1
    a //= 2
    b += a

print(a, b)

    


#%%


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

int main()
{
    ll n, k;
    cin >> n >> k;
    ll h[n];
    for (int i=0; i<n; i++) {
        cin >> h[i];
    }
    sort (h, h+n);
    ll count = 0;
    if (k>n) {
        cout << '0';
        return 0;
    }
    for (int i=0; i<n-k; i++) {
        count += h[i];
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
using namespace std;
typedef long long LL;

int main(void)
{
	LL a,b,c,n;
	string s;
	cin >>s;
	sort(s.begin(),s.end());
	if (s[0] == s[1]) {
		if (s[2] == s[3]) {
			if (s[0] != s[3]) {
				cout <<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout <<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <stdlib.h>
using namespace std;

int main(void) {
	int a, b, c, x, n = 0;
	cin >> a >> b >> c >> x;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if((k + (2 * j) + (10 * i)) * 50 == x)n++;
				else if ((k + (2 * j) + (10 * i)) * 50 > x)break;
			}
		}
	}
	cout << n << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    long long ans = 0;
    for (int i=1; i<=n; i++){
        for (int j=1; j<=n; j++){
            for (int k=1; k<=n; k++){
                ans += __gcd(__gcd(i, j), k);
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3644
import math


def modinv(a, b, m):
    # a / b (mod m) を求める。
    # 例えば、 9 / 4 (mod 13) = 12となる。
    # まず、 1 / b (mod m) を求める。
    for i in range(m):
        if (i * m + 1) % b == 0:
            tmp = int((i * m + 1) / b)
            break

    # a / b (mod m) は、 1 / b (mod m) に a を掛けて余りを取れば求められる。
    return (tmp * a) % m


def factoring(n):
    pf = {}
    num = n

    if n == 1:
        return {}

    while True:
        flag = 0

        for i in range(2, math.floor(math.sqrt(n)) + 1):
            if num % i == 0:
                num = num / i
                flag = 1
                if i in pf:
                    pf[i] += 1
                else:
                    pf[i] = 1

                if num == 1.0:
                    return pf
                else:
                    break

        if flag == 0:
            if num in pf:
                pf[num] += 1
            else:
                pf[num] = 1
            return pf


N, M = map(int, input().split())
# 仕切りの数: N - 1 個
# 素数の約数p1の数: n1 個
# p2の数: n2個
# ... の重複組合せの個数を求める。
MOD = 10 ** 9 + 7

# まず、素因数分解を行う。
pf = factoring(M)

ans = 1
for key in pf:
    for i in range(pf[key]):
        ans = ans * (N - 1 + pf[key] - i) % MOD
    for i in range(2, pf[key] + 1):
        ans = modinv(ans, i, MOD)

print(ans)


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

int main()
{
    int n, m;
    cin >> n >> m;
    int ans = 0;
    vector<set<int>> b(m);
    for (int i = 0; i < m; i++)
    {
        int t;
        cin >> t;
        while (t--)
        {
            int a;
            cin >> a;
            b[i].insert(a);
        }
    }
    vector<int> on(m);
    for (int i = 0; i < m; i++)
        cin >> on[i];
    for (int i = 0; i < (1 << n); i++)
    {
        bool ok = 1;
        for (int j = 0; j < m; j++)
        {
            int sum = 0;
            for (int x : b[j])
            {
                if ((i >> (x - 1)) & 1)
                    sum++;
            }
            if (sum % 2 != on[j])
            {
                ok = 0;
                break;
            }
        }
        if (ok)
            ans++;
    }
    cout << ans << endl;
}


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

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

  int sum = 0, t;
  vector<int> v;
  rep(i,1,N) {
    sum += i;
    v.push_back(i);
    if (N < sum)
    {
      t = sum - N;
      break;
    }
  }

  for (int i : v)
  {
    if (i == t) continue;
    cout << i << endl;
  }

  return 0;
}


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

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),m=Integer.parseInt(s[1]);
        int i,max=0,c=0;
        ArrayList<Integer> g[]=new ArrayList[n];
        boolean vis[]=new boolean[n];
        for(i=0;i<n;i++)
        g[i]=new ArrayList<>();
        for(i=0;i<m;i++)
        {
            s=bu.readLine().split(" ");
            int u=Integer.parseInt(s[0])-1,v=Integer.parseInt(s[1])-1;
            g[u].add(v);
            g[v].add(u);
        }

        for(i=0;i<n;i++)
        if(!vis[i])
        {
            Queue<Integer> q=new LinkedList<>();
            vis[i]=true;
            q.add(i);
            c=0;
            while(!q.isEmpty())
            {
                int p=q.poll();
                c++;
                for(int x:g[p])
                if(!vis[x])
                {
                    vis[x]=true;
                    q.add(x);
                }
            }
            max=Math.max(max,c);
        }
        System.out.print(max);
    }
}


Measured memory_bytes: 80832
a,b,h,m = gets.split(' ').map(&:to_i)
h=h.to_f
m=m.to_f
#puts 90 * Math::PI / 180
#puts Math.cos(90 * Math::PI / 180)
#d = ((h * 5.0 + m / 12.0) - m).abs #* 60
lt = (h * 30.0) + (m * 0.5)
st = m * 6.0
d=(lt-st).abs
if d>180.0
  d = 360.0 -d
end
#puts lt
#puts st
#puts d
#rad = d * Math::PI / 180.0
#puts 2 * b * a * Math.cos(rad)
#naka = 2.0 * b * a * Math.cos(rad)
puts Math.sqrt(a**2.0 + b**2.0 - 2.0*b*a*Math.cos(d*Math::PI/180.0))


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

using namespace std;

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

	int n;
	cin >> n;
	vector<long long> c(100005);
	long long sum = 0;
	for(int i =0; i<n; ++i) {
		int a;
		cin >> a;
		c[a]++;
		sum += a;
	}
	int m;
	cin >> m;
	while(m--) {
		int a, b;
		cin >> a >> b;
		sum -= a * c[a];
		sum += b * c[a];
		c[b] += c[a];
		c[a] = 0;
		cout << sum << '\n';
	}
}

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

// io
#define get(i) scanf("%d", &i)
#define flush fflush(stdin)

// manipulations
#define f(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = n - 1; i >= 0; i--)
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define lowbit(x) (x & -x)
#define sz(x) int((x).size())

// built-in
#define bitcount __builtin_popcount
#define gcd __gcd

// short
#define pb push_back
#define fill(arr, a) memset(arr, a, sizeof(arr))

// useful bits
#define IN(i, l, r) (l <= i && i <= r)
#define relax(a, b) (a) = max((a), (b))
#define relaxi(a, b) (a) = min((a), (b))

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long ll;
typedef long double ld;

ll modpow(ll a, ll b, ll mod = (ll) (1e9 + 7)) 
{if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;}

// for rand
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// use uniform_int_distribution<int>(0, i)(rng)



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);


	int n, k;
	string s;
	cin >> n >> k >> s;
	VI res;
	f(i,n) {
		int j = i;
		while (j<n&&s[j]==s[i]) j++;
		res.pb(j);
		i=j-1;
	}
	int ans = 0;
	f(i,sz(res)) if (s[res[i]-1] == '1') {
		int j = max(0,i-2*k);
		relax(ans,res[i]-(j?res[j-1]:0));
	} else {
		int j = max(0,i-2*k+1);
		relax(ans,res[i]-(j?res[j-1]:0));
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1020
n,T = map(int,input().split())
t = list(map(int,input().split()))
c = 0
s = 0
for i in range(len(t)-1):
    if t[i+1]-t[i]<T:
        c+=t[i+1]-t[i]
    else:
        c+=T
c+=T
print(c)

Measured memory_bytes: 26836
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    long long int n, a, x;
    vector<long long int> v;
    cin >> n >> a;
    long long int i, j, k;
    
    for(i = 0; i < n; i++){
        cin >> x;
        v.push_back(x);
    }
    
    
    long long int dp[51][51][2501];
    
    for(i = 0; i <= n; i++){
        for(j = 0; j <= n; j++){
            for(k = 0; k <= 2500; k++){
                dp[i][j][k] = 0;
            }
        }
    }
    
    dp[0][0][0] = 1;
    
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            for(k = 0; k <= 2500; k++){
                if(dp[i][j][k]){
                    dp[i+1][j][k] += dp[i][j][k];
                    dp[i+1][j+1][k+v[i]] += dp[i][j][k];
                }
            }
        }
    }
    
    long long int ans = 0;
    
    for(i = 1; i < n+1; i++){
        ans += dp[n][i][i*a];
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 51072
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    long X=gl();
	    long Y=gl();
	    
	    int a=1;
	    while(Y/X>=2) {
	    	X*=2;
	    	a++;
	    }

	    System.out.print(a);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35748
n,a,b=map(int,input().split(" "))
array=[]
for i in range(1,n+1):
    j=i
    s=0
    while(j>0):
        dig=j%10
        s=s+dig
        j=int(j/10)
    if a<=s<=b:
        array.append(i)
print(sum(array))


Measured memory_bytes: 3300
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int N;
llint T[110];


llint gcd(llint a, llint b){
	return b==0 ? a : gcd(b, a%b);
}


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


llint solve(){
	llint ans = 1;
	rep(i, 0, N)
		ans = lcm(ans, T[i]);
	return ans;
}


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> T[i];
	
	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n = int(input())
    as_ = list(map(int, input().split()))
    counter_a = collections.Counter(as_)
    ans = 0
    for a, count in counter_a.items():
        if count == a:
            pass
        elif count < a:
            ans += count
        elif count > a:
            ans += count - a
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 18664
main ::IO()
main = do
    line <- getLine
    print $ minimum(func line)

func :: String -> [Int]
func [a, b, c] = [abs (753 - (read [a, b, c]))]
func (a:b:c:xs) = (head $ func [a, b, c]) : func (b:c:xs)
func [] = func (replicate 3 '0')
func [a] = func ((replicate 2 '0') ++ [a])
func [a, b] = func (['0', a, b])


Measured memory_bytes: 508
import java.util.*;

public class Main {
    private static int m, n;
    private static int[][] memo = new int[1<<11][1<<11];
    private static int[] f = new int[128];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            m = sc.nextInt();
            n = sc.nextInt();
            if (m == 0 && n == 0) break;
            
            for (int i=0; i<n; i++) {
                f[i] = sc.nextInt(2);
            }

            for (int i=0; i<(1<<m); i++) {
                for (int j=0; j<(1<<m); j++) {
                    memo[i][j] = -1;
                }
            }
            
            System.out.println(dp(0, 0));
        }
    }

    private static int dp(int q, int a) {
        if (memo[q][a] != -1) return memo[q][a];

        int count = 0;
        for (int i=0; i<n; i++) {
            if ((q & f[i]) == a) count++;
        }

        if (count <= 1) {
            memo[q][a] = 0;
            return memo[q][a];
        }

        int res = 10000;
        for (int i=0; i<m; i++) {
            if ((q>>i) % 2 == 1) continue;
            res = Math.min(res, Math.max(dp(q|(1<<i), a), dp(q|(1<<i), a|(1<<i))));
        }
        memo[q][a] = res + 1;
        return memo[q][a];
    }
}

Measured memory_bytes: 49528
#include <cstdio>

#define rep(i, N) for (int i = 0; i < N; ++i)

bool binarySearch(int A[], int l, int r, int key) {
    while (l < r) {
        int m = (l + r) / 2;
        if (key == A[m]) return 1;
        if (key > A[m]) l = m + 1;
        else if (key < A[m]) r = m;
    }
    return 0;
}

int main() {
    int n;
    scanf("%d", &n);
    int left = 0, right = n;
    int S[n];
    rep(i, n) scanf("%d", &S[i]);

    int q, sum = 0;
    scanf("%d", &q);
    int T[q];
    rep(i, q) scanf("%d", &T[i]);
    for (int &key: T) {
        if (binarySearch(S, left, right, key)) sum++;
    }

    printf("%d\n", sum);
    return 0;
}



Measured memory_bytes: 3288
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

const int maxn=100005;
int n,m,k,ans;
ll a[maxn],b[maxn];

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	rep(i,n)scanf("%I64d",&a[i]);
	sort(a,a+n);
	rep(i,n)b[i]=a[i]+k;
	int i=0;
	while(i<n)
	{
		int j=0,cur=b[i];
		while(j<m&&i<n&&a[i]<=cur)j++,i++;
		ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10000)
def resolve():
    A, B, C = list(map(int, input().split(" ")))
    print(rec(A, B, C, 0))

def rec(A, B, C, cnt):
    if A == B and B == C:
        return cnt
    
    MAX, MIN = max([A, B, C]), min([A, B, C])
    MID = A + B + C - MAX - MIN

    if MID - MIN >= 2:
        if MIN == A:
            res = rec(A+2, B, C, cnt+1)
        if MIN == B:
            res = rec(A, B+2, C, cnt+1)
        if MIN == C:
            res = rec(A, B, C+2, cnt+1)
    else:
        if MAX == C:
            res = rec(A+1, B+1, C, cnt+1)
        if MAX == A:
            res = rec(A, B+1, C+1, cnt+1)
        if MAX == B:
            res = rec(A+1, B, C+1, cnt+1)
    return res


    
if '__main__' == __name__:
    resolve()

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
int main(void){
    int r,c,rc,i,j,sumr,sumc[100];
    cin >> r >> c ;
    sumc[c]=0;
    for(i=0;i<r;i++){
        sumr=0;
        for(j=0;j<c;j++){
            if(i==0) sumc[j]=0;
            cin >> rc ;
            cout << rc << " " ;
            sumr+=rc;
            sumc[j]+=rc;
        }
        cout << sumr << endl;
        sumc[c]+=sumr;
    }
    for(i=0;i<=c;i++){
        cout << sumc[i] ;
        if(i==c) cout << endl;
        else cout << " " ;
    }
    
}



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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


struct Sieve { // 篩
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;} // 素数判定
  vector<int> factorList(int x) { // 素因数列挙
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) { // 素因数分解(ランレングス圧縮的なもの)
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      }
      else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


int main(){
  int n;
  cin >> n;
  Sieve s(n);
  ll ans = 0;
  rep(i,n) {
    ll cnt = 1;
    vP v = s.factor(i+1);
    for(P p : v) cnt *= (p.se + 1);
    ans += (i+1) * cnt;
  }
  cout << ans << endl;
}

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

using namespace std;

string tolowers(string b){
  string s = "";
  for(int i=0; i<b.length(); i++){
    s+=tolower(b[i]);
  }
  return s;
}
int main() {

  string a,b="";
  int cont = 0;
  cin >> a;
  while(b != "END_OF_TEXT"){
    cin >> b;
    if(a==tolowers(b)){cont++;}
  }
  cout << cont << endl;
  return 0;
}


Measured memory_bytes: 3164
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
def f(s, last):
    if len(s) == n:
        print(s)
    else:
        for i in range(97, last + 2):
            f(s + chr(i), last + 1 if i == last + 1 else last)


f('', 96)

Measured memory_bytes: 58200
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int S = scan.nextInt();
        if (S >= 0 && S <= 86400) {
            int h = S / 3600;
            int m = (S % 3600) / 60;
            int s = (S % 3600) % 60;
            System.out.println(h + ":" + m + ":" + s);
        }
    }
}


Measured memory_bytes: 26224
// susheel_7
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long int
#define pi 3.14159265358979
int main() 
{
    ll n,m,b,c,p,q,x,y,z,i,j,k,ans=0,count=0,flag=0;
    ll a[n+5];
    cin>>n;
    ans=n%1000;
    if(ans==0)
    cout<<ans;
    else
    cout<<1000-ans;
    return 0;
}

Measured memory_bytes: 3616
num = input()
A = int(num.split(' ')[0])
B = int(num.split(' ')[1])
C = int(num.split(' ')[2])
K = int(input())
num = [A,B,C]
while K>0:

    posi = num.index(max(num))
    num[posi]=num[posi]*2

    K=K-1

print(sum(num))


Measured memory_bytes: 3060
//                   ********** YATIN KWATRA **********

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long 
#define ld                      long double
#define ull                     unsigned long long 
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map                
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int> 
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795

using namespace std;

void INPUT() 
{  
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

/*
    
   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible ..
*/

const int W = 100005;
const int N = 105;

ll dp[N][W];
ll n,w;
pll v[N];

ll f(ll i, ll c)
{
  if(i == n or c == 0) return 0LL;

  if(dp[i][c] != -1) return dp[i][c];

  ll op1 = 0, op2 = 0;

  if(c >= v[i].ff)
  {
    op1 = v[i].ss + f(i+1,c-v[i].ff);
    op2 = f(i+1,c);
  }

  dp[i][c] = max(op1,op2);

  return dp[i][c];
}

void solve()
{ 
  
        cin >> n >> w;
        
        fo(i,0,n-1) cin >> v[i].ff >> v[i].ss;

        sort(v,v+n);

        memset(dp,-1,sizeof(dp));

        cout << f(0,w) << endl;

       
}
int main() {
    
    FIO
    INPUT();
    
    int t;
    t = 1;
    //cin >> t;
    
    while(t--)
    {
       solve();
    }
    return 0;
}


Measured memory_bytes: 85672
q = list()
n = int(input())
a = [input() for _ in range(n)]
col = [-1]*n
col[0] = 0
q.append(0)
while q:
  v = q.pop()
  for i in range(n):
    if a[v][i] == '0':
      continue
    if col[i] < 0:
      col[i] = col[v]^1
      q.append(i)
    elif col[i] == col[v]:
      print(-1)
      exit(0)

dist = [[10**3]*n for _ in range(n)]
for i in range(n):
  for j in range(n):
    if a[i][j] == '1':
      dist[i][j] = 1
    elif i == j:
      dist[i][j] = 0

for k in range(n):
  for i in range(n-1):
    for j in range(i+1,n):
      if dist[i][j] > dist[i][k] + dist[k][j]:
        dist[i][j] = dist[i][k] + dist[k][j]
        dist[j][i] = dist[i][j]
print(max(max(x) for x in dist)+1)

Measured memory_bytes: 3444
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define ADJ(x) ((x % 10 > 0)? 10*(x/10 + 1) : x)
#define END(x) (10 * (x/10 + 1) - x)

void solve(int *a, int n) {
    int adj[n], end[n], i, max_end = 0, i_max, sum;
    bool flag = false;
    for(i = 0; i < n; ++i) {
        adj[i] = ADJ(a[i]);
        end[i] = (END(a[i]) == 10) ? 0 : END(a[i]);
    }
    /*
    for(i = 0; i < n; ++i) {
        printf("%d %d\n", adj[i], end[i]);
    }
    */
    for(i = 0; i < n; ++i) {
        if(max_end < end[i]) {
            max_end = end[i]; i_max = i; flag = true;
        }
    }
    if(!flag) { i_max = -1; }
    //printf("i_max = %d\n", i_max);
    sum = 0;
    for(i = 0; i < n; ++i){
        if(i == i_max) { sum += a[i]; }
        else { sum += adj[i]; }
    }
    printf("%d\n", sum);
}

int main(void)
{
    int n = 5, i;
    int *a = (int*)malloc((n+1)*sizeof(int));
    for(i = 0; i < n; ++i) { scanf("%d", &a[i]); }
    solve(a, n);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    vector<int>a(5),b(5),c(5);
    rep0(i,5){
        cin>>a[i];
        b[i]=a[i]%10;
        c[i]=(10-b[i])%10;
    }
    sort(all(c));
    reverse(all(c));
    int ans=0;
    rep0(i,5){
        ans+=a[i];
        ans-=b[i];
        if(b[i]!=0){
            ans+=10;
        }
    }
    ans-=c[0];
    cout<<ans<<endl;
}

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

using namespace std;

int main(void){
	
	while( true ){
		unsigned int potato = 0;
		int n, m;
		vector<int> vpeople;

		cin >> n >> m;
		if( n == 0 && m == 0 ) break;

		for(int i = 0; i < n; i++) vpeople.push_back( i + 1 );

		while( vpeople.size() > 1 ){
			potato += m-1;
			potato %= vpeople.size();
			vpeople.erase(vpeople.begin()+potato);
		}
		cout << vpeople[0] << endl;
	}
}

Measured memory_bytes: 0
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;

static class F
{
   // Operation of Frequency of Appearance
   public static int[] OFA(int[] array)
   {
      return (from index in Enumerable.Range(0, array.Length) select (from value in array where value == array[index] select value).Count()).ToArray();
   }

   public static bool Equal(int[] x, int[] y)
   {
      if (x == null || y == null)
      { return object.ReferenceEquals(x, y); }

      return x.SequenceEqual(y);
   }
}

class MainClass
{
   static void Main(string[] args)
   {
      var stringBuilder = new StringBuilder();

      while (true)
      {
         int n = int.Parse(Console.ReadLine());
         if (n == 0)
         { break; }

         int[] beforeArray = null;
         int[] afterArray = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
         int operateCount = 0;

         while (!F.Equal(beforeArray, afterArray)) {
            beforeArray = afterArray;
            afterArray = F.OFA(afterArray);
            operateCount++;
         }
         operateCount--;

         stringBuilder.AppendLine(operateCount.ToString());
         foreach (int value in afterArray)
         {
            stringBuilder.AppendFormat("{0} ", value);
         }
         stringBuilder.Remove(stringBuilder.Length - 1, 1);
         stringBuilder.AppendLine();
      }

      Console.Write(stringBuilder.ToString());
   }
}


Measured memory_bytes: 10272
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
#define INF 1000000001

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int N;cin>>N;
  ll ma=-INF;
  int count=0;
  int F[101][11];
  ll PP[101][11];
  int Fj[11];
  for(int i=1;i<=N;i++){
    for(int j=1;j<=10;j++){
      cin>>F[i][j];
    }
  }
  for(int i=1;i<=N;i++){
    for(int j=0;j<=10;j++){
      cin>>PP[i][j];
    }
  }
  // for j配列(for N 固定配列に対しPの値和)
  REP(i1,2){
    REP(i2,2){
      REP(i3,2){
        REP(i4,2){
          REP(i5,2){
            REP(i6,2){
              REP(i7,2){
                REP(i8,2){
                  REP(i9,2){
                    REP(i10,2){
                      if(i1==0&&i2==0&&i3==0&&i4==0&&i5==0&&i6==0&&i7==0&&i8==0&&i9==0&&i10==0){
                        continue;
                      }
                      ll tmp=0;
                      Fj[1]=i1;
                      Fj[2]=i2;
                      Fj[3]=i3;
                      Fj[4]=i4;
                      Fj[5]=i5;
                      Fj[6]=i6;
                      Fj[7]=i7;
                      Fj[8]=i8;
                      Fj[9]=i9;
                      Fj[10]=i10;
                      for(int i=1;i<=N;i++){
                        count=0;
                        for(int j=1;j<=10;j++){
                          if((F[i][j]==1) && (Fj[j]==1)){
                            count++;
                          }
                        }
                        tmp = tmp + PP[i][count];
                        // P(PP[1][]);
                        // P(tmp);
                      }
                      ma=max(ma,tmp);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  P(ma);
  return 0;
}


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


def solve(sx: int, sy: int, tx: int, ty: int):
    x = tx-sx
    y = ty-sy

    print('U'*y+'R'*x
        +'D'*y+'L'*x
        +'L'+'U'*(y+1)+'R'*(x+1)+'D'
        +'R'+'D'*(y+1)+'L'*(x+1)+'U')

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    sx = int(next(tokens))  # type: int
    sy = int(next(tokens))  # type: int
    tx = int(next(tokens))  # type: int
    ty = int(next(tokens))  # type: int
    solve(sx, sy, tx, ty)

if __name__ == '__main__':
    main()


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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int n, k;
vi res;

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFIN
    freopen("input.txt", "r", stdin);
#endif

    cin >> n >> k;
    while (n) {
        res.eb(n % k);
        n /= k;
    }
    cout << int(res.size()) << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

int main(){
  ll N,M,X,i,k,sum,m;
  ll min = 11111111111;
  ll C[22];
  ll A[22][22];
  bool a = false;
  cin >> N >> M >> X;
  for(i=0;i<=N-1;i++){
    cin >> C[i];
    for(k=0;k<=M-1;k++)
      cin >> A[i][k];
      }
  for(int bit = 0;bit < (1<<N);bit++){
    bool x = true;
    sum = 0;
    for(k=0;k<=M-1;k++){
      m = 0;
      for(i=0;i<=N-1;i++){
        if (bit & (1 << i)) m += A[i][k];
        if (bit & (1 << i)) sum += C[i];
      }
      if(m<X) x = false;
    }
    if(x && sum < min) min = sum,a=true;  
  }
  if(a) cout << min/M << endl;
  else cout << -1;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 100010;

char s[maxn];
bool vis[26];

int main()
{
//	freopen("input.txt","r",stdin);
//	ios::sync_with_stdio(false); cin.tie(0);
	scanf("%s",&s);
	memset(vis,0,sizeof(vis));
	int len=strlen(s),cnt=0;
	for(int i=0;i<len;i++){
		vis[s[i]-'a']=1;
	}
	for(int i=0;i<26;i++){
		if(vis[i]==0){
			printf("%c",i+'a');
			cnt++;break;
		}
	}
	if(cnt==0) printf("None");
	printf("\n");
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
//#define bint int1024_t
#define ld long double
#define vect vector<ll>
#define unmap unordered_map
#define pb push_back
#define F first
#define pll pair<ll,ll>
#define S second
#define pi 3.1415926536
#define mod int(1e9+7)
#define mp make_pair
//ios_base::sync_with_stdio(false);cin.tie(NULL);
#define testcases ll t; cin>>t; while(t--)

using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    vect v(n);
    for(ll& i:v) cin>>i;
    sort(v.begin(),v.end(),greater<ll>());

    ll ans = v[0], c = n-2, i;

    for(i = 1; i < n; i++)
    {
        if(c<2) break;
        c -= 2;
        ans += v[i]*2;
    }
    if(c) ans += v[i];
    cout<<ans;

	return 0;
}


Measured memory_bytes: 4780