akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int ans = int.MaxValue;
        for (int i = 1; i <=N/2+1; i++)
        {
            string A = i.ToString();
            string B = (N - i).ToString();
            int num = 0;
            foreach (var item in A)
            {
                num += item - '0';
            }
            foreach (var item in B)
            {
                num += item - '0';
            }

            ans = Math.Min(ans, num);
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 30204
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_sums, b_sums = [0], [0]
for i in range(n):
    a_sums.append(a_sums[i] + a[i])
for i in range(m):
    b_sums.append(b_sums[i] + b[i])

ans = 0
j = m
for i in range(n + 1):
    if a_sums[i] > k:
        break
    while a_sums[i] + b_sums[j] > k:
        j -= 1
    ans = max(ans, i + j)

print(ans)

Measured memory_bytes: 47308
use std::io::*;
use std::str::FromStr;
use std::collections::BTreeSet;

fn main() {
	let n: usize = read();
	let mut books = BTreeSet::new();
	let mut temp: String;
	let mut cnt: usize = 0;
	for _ in 0..n {
		temp = read();
		if !books.contains(&temp) {
			cnt += 1;
			books.insert(temp);
		}
	}
	println!("{}", cnt);
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 16312
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi                  3.14159265359
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

int main()
{
    ll n;cin>>n;
    ll x[n];
    rep(i,0,n)cin>>x[i];

    ll ans=INF;
    rep(i,1,101)
    {
        ll cnt=0;
        rep(j,0,n)
            cnt+=((x[j]-i)*(x[j]-i));
        ans=min(ans,cnt);
    }
    cout<<ans;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

s = [0] * m

for i in range(n):
    a = list(map(int, input().split()))[1:]
    for x in a:
        s[x-1] += 1

ans = 0
for x in s:
    if x == n:
        ans += 1
print(ans)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  float h,a;
  int ans;
  cin >> h >> a;
  ans = ceil(h/a);
  cout << ans << endl;
}


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

namespace ABC_C
{
    class C087
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A1 = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
            int[] A2= Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();

            int max = 0;
            for(int i = 0; i < N; i++)
            {
                int count = A1.Take(i + 1).Sum() + A2.Skip(i).Sum();
                if (count > max) max = count;
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13396
N, M = map(int, input().split())
S = [0] * N
L = [0] * M
for i in range(M):
  L[i] = [int(x) - 1 for x in input().split()]
P = [int(x) for x in input().split()]
cnt = 0
for i in range(2 ** N):
  n = i
  for j in range(N):
    S[j] = n % 2
    n //= 2
  for k in range(M):
    L[k][0] = 0
    for l in L[k][1:]:
      L[k][0] ^= S[l]
  light = True
  for k in range(M):
    light &= (L[k][0] == P[k])
  cnt += 1 if light else 0
print(cnt)

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, W; 
char C[1005][1005];
ll DP[1005][1005];
bool visited[1005][1005];

int main(){
  cin >> H >> W;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> C[i][j];
    }
  }

  for (int i = 0; i < H; i++){
    if (C[i][0] == '#') break;
    DP[i][0] = 1;
  }
  for (int j = 0; j < W; j++){
    if (C[0][j] == '#') break;
    DP[0][j] = 1;
  }

  for (int i = 1; i < H; i++){
    for (int j = 1; j < W; j++){
      if (C[i][j] == '#') continue;
      DP[i][j] = DP[i-1][j] + DP[i][j-1];
      DP[i][j] %= MOD;
    }
  }
  cout << DP[H-1][W-1] << endl;

  return 0;
}


Measured memory_bytes: 12444
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;

const ll MOD_CONST = 1000000007;



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

	ll cnt = 0;
	for (int b = k+1; b <= n; b++) {
		
		cnt += 1LL*(b - k) * (n / b);
		cnt += max(n % b - (k-1), 0);
		if (k == 0) {
			cnt--;
		}
	}
	cout << cnt << endl;
}  



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

#define INF 1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    VI count(1e05 + 2, 0);
    int n;
    cin >> n;
    int temp;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        count[temp]++;
        count[temp + 1]++;
        count[temp + 2]++;
    }
    int max_count = 0;
    for (int i = 0; i < 1e05 + 2; i++) {
        if (count[i] > max_count) {
            max_count = count[i];
        }
    }
    cout << max_count << endl;
    return 0;
}



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

signed main(void)
{
	int a, b, c;
	cin >> a >> b >> c;

	if ((ll)c - a - b > 0 && (ll)4 * a * b < (ll)(c - a - b) * (c - a - b))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int a,b,c;
   scanf("%d %d %d",&a,&b,&c);

   if(a<=b && a<=c){
      if(b<=c){
         printf("%d %d %d\n",a,b,c);
      }
      else if(b>=c){
         printf("%d %d %d\n",a,c,b);
      }
   }
   else if(b<=a && b<=c){
      if(a<=c){
         printf("%d %d %d\n",b,a,c);
      }
      else if(a>=c){
         printf("%d %d %d\n",b,c,a);
      }
   }
   else if(c<=a && c<=b){
      if(a<=b){
         printf("%d %d %d\n",c,a,b);
      }
      else if(a>=b){
         printf("%d %d %d\n",c,b,a);
      }
   }


   return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    
    vector<int> a(100000,0);
    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        a.at(temp)++;
    }
    int ans = 0;
    for (int i = 0; i < 100000 - 2; i++) {
        ans = max(ans, a.at(i) + a.at(i + 1) + a.at(i + 2));
    }
    
    cout << ans << endl;
    
    return 0;
}


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

#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using pii = pair <int, int>;
using pll = pair <ll, ll>;
using ld = long double;
// mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
// const int mod = 998244353;
const ll inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-7;

const int N = 2e5 + 66;

ll a[N];

map <int, ll> dp[N];

map <int, bool> was[N];

int n;

ll go (int pos, int last) {
	if (last == 0) return 0ll;
	if ((n - pos + 2) / 2 < last || pos > n) return -INF;
	if (was[pos][last]) return dp[pos][last];
	was[pos][last] = true;
	ll mx = -INF;
	for (int i = pos + 1; i <= pos + 5 ; ++ i) {
		mx = max (mx, go (i, last));
		if (i > pos + 1)
			mx = max (mx, go (i, last - 1) + a[pos]);
	}
	return dp[pos][last] = mx;
}

void solve () {
	cin >> n;
	for (int i = 1 ; i <= n ; ++ i) {
		cin >> a[i];
	}
	cout << go (1, n / 2);
}

int main () {
	ios;
	// double start_time = clock();
	// cout << fixed << setprecision (10);
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
		cout << "\n";
	}
	// cerr << (clock() - start_time) / CLOCKS_PER_SEC;
}

Measured memory_bytes: 69212
#include <cstdio>
#include <cmath>
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <fstream>

using namespace std;
int m[10];

int main(){
  int n;
  int i = 0;
  int sum = 0;

  cin >> n;
  int  N = n;
  while(n>0){
   m[i] = n%10;
   n = n-n%10;
   n = n/10;
   i++;
  }
  for(int i=0;i<10;i++){
      sum += m[i];
  }

  if(N%sum == 0){
      cout << "Yes\n";

  }else {
      cout << "No\n";
  }

}


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

static class Program
{
    static int Solve(int L, int R, int d)
    {
        int count = 0;
        for (int i = L; i <= R; ++i)
        {
            if (i % d == 0) { ++count; }
        }
        return count;
    }

    static void Main(string[] args)
    {
        var V = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(Solve(V[0], V[1], V[2]));
    }
}


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

vector<int> Vx = {1,0,-1,0}, Vy = {0,1,0,-1};
int inf = 1001001001;

int main(){
  int H,W,Ch,Cw,Dh,Dw;
  cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
  Ch--;Cw--;Dh--;Dw--;
  vector<vector<int>> S(H,vector<int>(W,inf));
  for(int i=0;i<H;i++){
    string s;
    cin >> s;
    for(int j=0;j<W;j++){
      if(s[j]=='#') S[i][j] = -1;
    }
  }
  
  priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> Q;
  Q.push(make_pair(0,make_pair(Ch,Cw)));
  S[Ch][Cw] = 0;
  while(!Q.empty()){
    pair<int,pair<int,int>> P = Q.top();
    Q.pop();
    int x = P.second.first, y = P.second.second;
    if(S[x][y]!=P.first) continue;
    
    for(int k=0;k<4;k++){
      int x2 = x + Vx[k], y2 = y + Vy[k];
      if(x2<0 || x2>=H) continue;
      if(y2<0 || y2>=W) continue;
      if(S[x2][y2]==-1) continue;
      if(S[x2][y2]>S[x][y]){
        S[x2][y2] = S[x][y];
        Q.push(make_pair(S[x2][y2],make_pair(x2,y2)));
      }
    }
    for(int i=-2;i<=2;i++){
      for(int j=-2;j<=2;j++){
        int x2 = x + i, y2 = y + j;
        if(x2<0 || x2>=H) continue;
        if(y2<0 || y2>=W) continue;
        if(S[x2][y2]==-1) continue;
        if(S[x2][y2]>S[x][y]+1){
          S[x2][y2] = S[x][y]+1;
          Q.push(make_pair(S[x2][y2],make_pair(x2,y2)));
        }
      }
    }
  }
  
  if(S[Dh][Dw]==inf) cout << -1 << endl;
  else cout << S[Dh][Dw] << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    ll a,b,c;
    cin >> a >> b >> c;

    ll ka = c-a-b;

    if(ka<=0)
    {
       cout << "No\n";
       return 0;
    }
    else
    {
        ll kh = ka*ka;
        ll cmp = 4*a*b;
        if(cmp < kh)
            cout << "Yes\n";
        else
            cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.split(" ").map { it.toInt() }
    val ans = Array(n[1]) { 0 }

    for (i in 0..(n[0] - 1)) {
        val a = readLine()!!.split(" ").map { it.toInt() }
        for (j in 1..a[0]) {
            ans[a[j]-1]++
        }
    }

    println(ans.count { it == n[0] })
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int64 A, B, N;
  cin >> A >> B >> N;
  int64 ret = 0;
  for(int64 k = N, i = 0; i <= 50000000 && k >= 0; i++, k--) {
    chmax(ret, A * k / B - A * (k / B));
  }
  for(int64 k = N / B * B, i = 0; i <= 50000000 && k >= 0; i++, k--) {
    chmax(ret, A * k / B - A * (k / B));
  }
  cout << ret << endl;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int n, m;
vector< vector< int > > adj;
vector< int > vis;

void dfs(int v, int d) {
	if (d == 3) return;
	vis[v] = 1;
	for (int u : adj[v]) dfs(u, d + 1);
}

int main() {
	while (cin >> n >> m, n) {	
		adj.assign(n, vector< int >());
		
		for_(i,0,m) {
			int a, b;
			cin >> a >> b;
			--a; --b;
			adj[a].push_back(b);
			adj[b].push_back(a);
		}
		
		vis.assign(n, 0);		
		dfs(0, 0);
		cout << accumulate(vis.begin(), vis.end(), int()) - 1 << endl;
	}
}

Measured memory_bytes: 3164
H,W,D = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for _ in range(H)]
Q = int(input())

tmp = [0]*(H*W)
for i in range(H):
    for j in range(W):
        tmp[A[i][j]-1] = [i,j]

ans = [0]*(H*W)
for i in range(D):
    bl = tmp[i][0]
    br = tmp[i][1]
    i += D
    zp = 0
    while i < H*W:
        l = tmp[i][0]
        r = tmp[i][1]
        ans[i] = abs(bl-l)+abs(br-r)+zp
        zp = ans[i]
        bl = l
        br = r
        i += D

jjj = []
for _ in range(Q):
    L,R = [int(i) for i in input().split()]
    jjj.append(ans[R-1]-ans[L-1])

[print(i) for i in jjj]


Measured memory_bytes: 77660
#include "bits/stdc++.h"
using namespace std;

struct edge { int to, cap, rev; };

vector<edge> G[210];
int level[210];
int iter[210];
int INF = 10000000;

void add_edge(int from, int to, int cap) {
	G[from].push_back({ to, cap, (int)G[to].size() });
	G[to].push_back({ from, 0, (int)G[from].size() - 1 });
}

void add_multi_edge(int v1, int v2, int cap) {
	G[v1].push_back({ v2, cap, (int)G[v2].size() });
	G[v2].push_back({ v1, cap, (int)G[v1].size() - 1 });
}

void BFS(int S) {
	memset(level, -1, sizeof(level));
	queue<int> Q;
	level[S] = 0;
	Q.push(S);
	while (!Q.empty()) {
		int V = Q.front(); Q.pop();
		for (edge E : G[V]) {
			if (E.cap > 0 && level[E.to] < 0) {
				level[E.to] = level[V] + 1;
				Q.push(E.to);
			}
		}
	}
}

int DFS(int V, int T, int F) {
	if (V == T) return F;
	for (int& i = iter[V]; i < G[V].size(); i++) {
		edge& E = G[V][i];
		if (E.cap > 0 && level[V] < level[E.to]) {
			int D = DFS(E.to, T, min(F, E.cap));
			if (D > 0) {
				E.cap -= D;
				G[E.to][E.rev].cap += D;
				return D;
			}
		}
	}
	return 0;
}

int max_flow(int S, int T) {
	int flow = 0;
	while (1) {
		BFS(S);
		if (level[T] < 0) return flow;
		memset(iter, 0, sizeof(iter));
		int F;
		while ((F = DFS(S, T, INF)) > 0) {
			flow += F;
		}
	}
}

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

int main() {
	long long N, X[100];
	map<long long, bool> mp;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> X[i], mp[X[i]] = true;
	vector<long long> V;
	for (int i = 0; i < N; i++) {
		if (!mp[X[i] - 1]) V.push_back(X[i]);
		if (!mp[X[i] + 1]) V.push_back(X[i] + 1);
	}
	long long Even = 0, Odd = 0;
	for (int i = 0; i < V.size(); i++) {
		if (V[i] % 2 == 0) add_edge(201, i, 1), Even++;
		else add_edge(i, 202, 1), Odd++;
	}
	for (int i = 0; i < V.size(); i++) {
		if (V[i] % 2 == 1) continue;
		for (int j = 0; j < V.size(); j++) {
			if (V[j] % 2 == 0) continue;
			if (isPrime(abs(V[i] - V[j]))) add_edge(i, j, 1);
		}
	}
	long long MAX = max_flow(201, 202);
	cout << MAX + ((Even - MAX) / 2 + (Odd - MAX) / 2) * 2 + ((Even - MAX) % 2) * 3 << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int main()

{

	int a,b;

	scanf("%d %d", &a,&b);

	if (a > b){ printf("a > b\n"); }

	if (a < b){ printf("a < b\n"); }

	if (a == b){ printf("a == b\n"); }
	return 0;

}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;




void solve(){
    int h,w;
    cin >> h >> w;
    char grid[h+10][w+10];
    rep(i,h+2){
        rep(j,w+2){
            grid[i][j] = '.';
        }
    }
    rep(i,h){
        rep(j,w){
            cin >> grid[i+1][j+1];
        }
    }
    string ans = "Yes";
    rep(i,h){
        rep(j,w){
            if(grid[i+1][j+1]=='#'){
                //全方位'.'ならfalse
                if(grid[i+1][j+2]=='.' && grid[i+1][j]=='.' && grid[i][j+1]=='.' && grid[i+2][j+1]=='.'){
                    ans = "No";
                }
            }
        }
    }
    cout << ans << endl;
}

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


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

int main() {
 
  int a;
  int b;
  cin >> a >> b;
  
  int num = (a + b) / 2;
  
  if((a + b) % 2 == 0){
    cout << num << endl;
  }
  else{
    cout << num + 1 << endl;
  }
}


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

using namespace std;

int main()
{
	ll n;
	cin>>n;
	string input ="";
	string s1 ="..##";
	string s2 =".#.#";
	string ans1 = "" , ans2="";
		bool balik = 1;
	while(input != "end")
	{
		if(balik == 1)
		{
			
			for(int i = 0; i  < 4;  i++)
			{
				string temp1 = ans1 , temp2 = ans2;
				temp1 += s1[i];
				temp2 += s2[i];
				cout<<temp1<<endl<<temp2<<endl;
				fflush(stdout);
				cin>>input;
				if(input == "end") return 0;
				if(input == "T" || input == "end")
				{
					ans1 = temp1;
					ans2 = temp2;
					if(ans1.size() == n) return 0;
					break;
				}
				else
				{
					if( i == 3)
					{
						balik = 0;
					}
				}
			}
		}
		if(balik == 0)
		{
			for(int i = 0; i  < 4;  i++)
			{
				string temp1 = ans1 , temp2 = ans2;
				temp1 = s1[i] + ans1;
				temp2 = s2[i] + ans2;
				cout<<temp1<<endl<<temp2<<endl;
				fflush(stdout);
				cin>>input;
				if(input == "end") return 0;
				if(input == "T" )
				{
					ans1 = temp1;
					ans2 = temp2;
					if(ans1.size() == n) return 0;
					break;
				}
				else
				{
					if( i == 3)
					{
						balik = 0;
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 724
unittest
{
	assert( [ "12" ].parse.expand.solve == 1 );
	assert( [ "5" ].parse.expand.solve == 0 );
	assert( [ "1000000000000000000" ].parse.expand.solve == 124999999999999995 );
}

unittest
{
	// 追加ケース
	import std.algorithm;
	import std.bigint;
	import std.format;
	BigInt test( long n )
	{
		if( n < 2 ) return BigInt( 1 );
		else        return n * test( n - 2 );
	}
	foreach( i; 0 .. 10001 )
	{
		auto k = format( "%d", test( i ) );
		assert( solve( i ) == k.length.signed - k.retro.find!( ( a ) => a != '0' ).walkLength.signed );
	}
}



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

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

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	// 10未満と奇数は末尾が0にならないので除外
	if( n < 10 || n % 2 == 1 ) return 0;
	
	// 10 * 5 ^^ i ごとに末尾の0が増える数が増える
	n /= 10;
	auto ans = n;
	for( auto i = 1L; 5L ^^ i <= n; i++ )
	{
		ans += n / ( 5L ^^ i );
	}
	return ans;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c;
	for(a=1;;a++){
		if(a == 10) break;
		for(b=1;;b++){
			if(b == 10) break;
			c=a*b;
			printf("%dx%d=%d\n",a,b,c);
		}
	}
	return 0;
}

Measured memory_bytes: 520
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
N=[i for i in range(1,n+1)]
p1=[i for i in range(1,n+1)]
q1=[i for i in range(1,n+1)]
def kaijou(x):
    if x==0:
        return 0
    elif x==1:
        return 1
    elif x==2:
        return 2
    elif x==3:
        return 6
    elif x==4:
        return 24
    elif x==5:
        return 120
    elif x==6:
        return 720
    elif x==7:
        return 5040

s1=1
s2=1
j=1
for i in p:
    s1 += kaijou(n-j)*int(p1.index(i))
    j+=1
    p1.remove(i)
j=1
for i in q:
    s2 += kaijou(n-j)*int(q1.index(i))
    j+=1
    q1.remove(i)
k=s1-s2
if k<0:
    print(-k)
else:
    print(k)


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

int main() {
  int n;

  while (cin >> n, n) {
    vector<int> k(n);
    for (auto &in : k) cin >> in;

    int ans = 0;
    for (int i = 0; i < n; ++i) {
      if (k[i]) {
        k[i]--;
        ans++;
      }
    }

    bool f = true;
    for (int i = 0; i < n; ++i) {
      if (k[i]) f = false;
    }

    if (f) cout << "NA" << endl;
    else cout << ans + 1 << endl;
  }
}

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

int n, m, R;
vector<int> r;
class Edge{
	public:
		long long cost;
		int from, to;
		Edge(long long c, int f, int t){
			cost = c;
			from = f;
			to = t;
		}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void readGraph(Graph &g, int E, bool D, bool C){ // E:NumofEdges, D:Directed, C:Costed
	for(int i=0; i<E; ++i){
		Edge e(0, 0, 0);
		if(!C) cin >> e.from >> e.to;
		else cin >> e.from >> e.to >> e.cost;
		--e.from;
		--e.to;
		g[e.from].push_back(e);
		if(!D){
			swap(e.from, e.to);
			g[e.from].push_back(e);
		}
	}
}
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}
bool operator < (const Edge &e, const Edge &f){
	return e.cost != f.cost ? e.cost > f.cost : e.from != f.from ? e.from < f.from : e.to < f.to;
}
constexpr long long INF = 1e18+9;
void dijkstra(int s, const Graph &g, vector<long long> &dist){
	int V = g.size();
	dist = vector<long long>(V, INF);
	dist[s] = 0;
	priority_queue<Edge> q;
	q.push(Edge(0, s, s));
	while(!q.empty()){
		Edge e = q.top();
		q.pop();
		if(dist[e.to] < e.cost) continue;
		for(int i=0; i<(int)g[e.to].size(); ++i){
			Edge f = g[e.to][i];
			if(dist[f.to] > dist[e.to] + f.cost){
				dist[f.to] = dist[e.to] + f.cost;
				q.push(Edge(dist[f.to], s, f.to));
			}
		}
	}
}
long long ans = INF;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m >> R;
	readVector(R, r);
	Graph g(n);
	readGraph(g, m, false, true);
	vector<long long> d[n];
	for(int i=0; i<n; ++i)
		dijkstra(i, g, d[i]);
	sort(r.begin(), r.end());
	for(int i=0; i<R; ++i)
		--r[i];
	do{
		long long tmp = 0;
		for(int i=1; i<R; ++i)
			tmp += d[r[i-1]][r[i]];
		ans = min(ans, tmp);
	}while(next_permutation(r.begin(), r.end()));
	cout << ans << "\n";
}

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


int main() {
 long long int n,k;
 cin>>n>>k;
 vector<long long int> a(n);
 for(int i=0;i<n;i++){
     cin>>a[i];
}
if(k>=n){
    cout<<0; return 0;
} 
sort(a.begin(),a.end(),greater<int>());
long long int sum=0;
for(int i=0;i<n;i++){
    if(i<k){
        continue;
    }
    else{
        sum+=a[i];
    }
}
 cout<<sum;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <iomanip>

int main(void){
  double a, b, x;
  std::cin >> a;
  std::cin >> b;
  std::cin >> x;
  long double theta;
  if(x <= a*a*b*0.5){
    theta = 90.00000000-atan(2*x/a/b/b)/M_PI*180.00000;
  }else{
    theta =  90.000 - atan(a*a*a/2/(a*a*b-x))/M_PI*180.0000;
      //std::cout << 90.000 - atan(a*a*a/2/(a*a*b-x))/M_PI*180;
  }
  std::cout << std::setprecision(11) << theta;
    
  return 0;
}


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

public class Main {

	void submit() {
		char[] s = nextToken().toCharArray();
		int k = nextInt();
		
		int n = s.length;
		
		int[][][] dp = new int[k + 1][n][n];
		for (int z = 0; z <= k; z++) {
			
			int[][] now = dp[z];
			int[][] prev = z == 0 ? null : dp[z - 1];
			
			for (int i = 0; i < n; i++) {
				now[i][i] = 1;
			}
			
			for (int i = 0; i + 1 < n; i++) {
				if (s[i] == s[i + 1]) {
					now[i][i + 1] = 2;
				} else {
					now[i][i + 1] = z > 0 ? 2 : 1;
				}
			}
			
			for (int len = 3; len <= n; len++) {
				for (int i = 0; i + len - 1 < n; i++) {
					int j = i + len - 1;
					
					now[i][j] = Math.max(now[i + 1][j], now[i][j - 1]);
					if (s[i] == s[j]) {
						now[i][j] = Math.max(now[i][j], now[i + 1][j - 1] + 2);
					}
					
					if (z > 0) {
						now[i][j] = Math.max(now[i][j], prev[i + 1][j - 1] + 2);
					}
					
				}
			}
			
		}
		
		out.println(dp[k][0][n - 1]);
	}

	void preCalc() {

	}

	void stress() {

	}

//	int lsp(char[] s) {
//		int n = s.length;
//		int[][] dp = new int[n][n];
//		for (int i = 0; i < n; i++) {
//			dp[i][i] = 1;
//		}
//		
//		for (int i = 0; i + 1 < n; i++) {
//			if (s[i] == s[i + 1]) {
//				dp[i][i + 1] = 2;
//			} else {
//				dp[i][i + 1] = 1;
//			}
//		}
//		
//		for (int len = 3; len <= n; len++) {
//			for (int i = 0; i + len - 1 < n; i++) {
//				int j = i + len - 1;
//				
//				dp[i][j] = Math.max(dp[i + 1][j], now[i + 1][j]);
//				if (s[i] == s[j]) {
//					now[i][j] = Math.max(now[i][j], now[i + 1][j - 1] + 2);
//				}
//				
//				if (z > 0) {
//					now[i][j] = Math.max(now[i][j], prev[i + 1][j - 1] + 2);
//				}
//				
//			}
//		}
//	}
	
	void test() {
//		char[] s = "atcodergrandcontest".toCharArray();
//		for (int i = 0; i < s.length; i++) {
//			for (int j = i + 1; j < s.length; j++) {
//				for (int k = j + 1; k < s.length; k++) {
//					char[] s1 = s.clone();
//					s1[i] = s1[j] = s1[k] = '?';
//					ans = Math.max(ans, lsp(s1));
//				}
//			}
//		}
//		System.err.println(ans);
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 168528
sx,sy,tx,ty = (int(i) for i in input().split())

ans = []

X = tx - sx
Y = ty - sy

for i in range(X):
    ans.append('R')
for i in range(Y):
    ans.append('U')
for i in range(X):
    ans.append('L')
for i in range(Y):
    ans.append('D')

ans.append('D')
for i in range(X + 1):
    ans.append('R')
for i in range(Y + 1):
    ans.append('U')
ans.append('L')
ans.append('U')
for i in range(X + 1):
    ans.append('L')
for i in range(Y + 1):
    ans.append('D')
ans.append('R')


for i in ans:
    print(i,end='')


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  string s;
  cin >> s;
  int n=s.size();
  vector<int>vec(3);
  rep(i,n){
    if(s[i]=='a')vec[0]++;
    if(s[i]=='b')vec[1]++;
    if(s[i]=='c')vec[2]++;
    
  }
  bool ok=true;
    int mx=max(vec[0],max(vec[1],vec[2]));
    int mn=min(vec[0],min(vec[1],vec[2]));
   if(mx>mn+1)ok=false;
  if(!ok)cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;     
}


Measured memory_bytes: 512
use std::env;
use std::io::*;
use std::str::*;

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

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let X = read::<String>();
    let X = X.chars().collect::<Vec<char>>();
    let Y = read::<String>();
    let Y = Y.chars().collect::<Vec<char>>();

    let x = X[0] as u8;
    let y = Y[0] as u8;

    if x < y {
        println!("<");
    } else if x > y {
        println!(">");
    } else {
        println!("=");
    }

}


Measured memory_bytes: 4352
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int cmd, index, val;
  int num_query, num_queue;

  cin >> num_queue >> num_query;
  priority_queue<int> que[num_queue];

  for (int i = 0; i < num_query; i++) {
    cin >> cmd;
    switch (cmd) {
      case 0:
        cin >> index >> val;
        que[index].push(val);

        break;

      case 1:
        cin >> index;
        if (!que[index].empty()) {
          cout << que[index].top() << endl;
        }
        break;

      case 2:
        cin >> index;
        if (!que[index].empty()) {
          que[index].pop();
        }
        break;
    }
  }
}




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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    if((A-B)%2==0){
        cout<<(B-A)/2<<endl;
    }else{//終わりだけでなく途中も？
        ll H;
        if(N%2==1)H=(N+1)/2;
        else H=N/2;
        if((A<H&&B<=H)||(A>H&&B>H)){
            ll ANS1=min(N-A,B-1);
            ll D=min(A,N-B)+1;//回数
            ll ANS2;
            if(A<=N-B){//cause
                ANS2=D+(B-D-1)/2;
            }else{
                ANS2=D+(N-(A+D))/2;
            }
            cout<<min(ANS1,ANS2)<<endl;
        }else{
            ll H=min(A,N-B)+1;//回数
            if(A<=N-B){//cause
                cout<<H+(B-H-1)/2<<endl;
            }else{
                cout<<H+(N-(A+H))/2<<endl;
            }
        }
    }


    return 0;
}

//1 2 3 4 5 6 7 8
//  A         B
//A       B    after2
//  A   B   after3
//    A    after 4
//考えるのは、偶数になったときと同様
//1 2 3 4 5 6 7 8 9
//A               B
//1 2 3 4 5 6 7 8 9
//  A         B
//    4
/*
      A     B
1 2 3 4 5 6 7 8 9
  A     B




*/



//a=97,z=122


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

void solve(){
  ll N, M;
  cin >> N >> M;
  ll a = 1, add = 1;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll t0 = 0;
  ll b = A[0];
  while(b % 2 == 0){
    t0++;
    b /= 2;
  }
  rep(i, N){
    ll t = 0;
    ll a = A[i];
    while(a % 2 == 0){
      t++;
      a /= 2;
    }
    if(t != t0){
      cout << 0 << endl;
      return;
    }
  }
  rep(i, N){
    A[i] /= 2;
    a = lcm(a, A[i]);
    if(a > M){
      cout << 0 << endl;
      return;
    }
    if(add != INFL){
      add = lcm(add, A[i] * 2);
    }
    if(add > M) add = INFL;
  }
  if(add == INFL){
    cout << 1 << endl;
    return;
  }
  ll ans = (M - a + add) / add;
  cout << ans << endl;
}


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


Measured memory_bytes: 1024
from bisect import bisect

a, b, q = map(int, input().split())
s = [-10 ** 11] + [int(input()) for _ in range(a)] + [10 ** 11]
t = [-10 ** 11] + [int(input()) for _ in range(b)] + [10 ** 11]
x = [int(input()) for _ in range(q)]

for xi in x:
    p, q = bisect(s, xi), bisect(t, xi)
    sl, sr = abs(s[p - 1] - xi), abs(s[p] - xi)
    tl, tr = abs(t[q - 1] - xi), abs(t[q] - xi)
    ans = min(max(sl, tl), sl + tr + min(sl, tr),
              max(sr, tr), sr + tl + min(sr, tl))
    print(ans)


Measured memory_bytes: 106816
import math
N, M = map(int, input().split())

def permutations_count(n, r):
  if n == 2:
    return 1
  elif n <= 1:
    return 0
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 偶数 + 偶数

total = permutations_count(N, 2)

# 奇数 + 奇数
total += permutations_count(M, 2)
print(total)

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

void S(vector<ll> &A){ sort(A.rbegin(),A.rend()); return;}

int main(){
  ll N,W; cin >> N >> W;
  
  vector<ll> w1; vector<ll> w2; vector<ll> w3; vector<ll>w4;
  
  ll a,b; cin >> a >> b; //w1  
  
  w1.push_back(b); //価値が大きい順にソートする
  
 for(ll i = 0; i < N - 1; i++){ ll w, u; cin >> w >> u;
    if( w == a){   w1.push_back(u);}
    if( w == a+1){ w2.push_back(u);}
    if( w == a+2){ w3.push_back(u);}
    if( w == a+3){ w4.push_back(u);}                            
                               }
  S(w1); S(w2); S(w3); S(w4);
  ll n1 = w1.size(); ll n2 = w2.size(); ll n3 = w3.size(); ll n4 = w4.size();
  
  ll ans = 0 ;
  
  vector<ll> C1(n1+1); vector<ll> C2(n2+1); vector<ll> C3(n3+1); vector<ll> C4(n4+1);
  C1[0] = 0; C2[0] = 0; C3[0] = 0; C4[0] = 0;
  
   for(ll i = 1; i <= n1; i++){C1[i] = C1[i-1] + w1[i-1];}
   for(ll i = 1; i <= n2; i++){C2[i] = C2[i-1] + w2[i-1];}
   for(ll i = 1; i <= n3; i++){C3[i] = C3[i-1] + w3[i-1];}
   for(ll i = 1; i <= n4; i++){C4[i] = C4[i-1] + w4[i-1];}
  
  
  
  
  for(ll i = 0; i <= n1; i++){
    for(ll j = 0; j <= n2; j++){
      for(ll k = 0; k <= n3; k++){
        for(ll l = 0; l <= n4; l++){
          if( i*a + j*(a+1) + k*(a+2) + l*(a+3) > W){ continue;}
          ll res = C1[i] + C2[j] + C3[k] + C4[l];
          ans = max( ans, res);
        }
      }
    }
  }
  
  cout << ans << endl; return 0;}
  

Measured memory_bytes: 256
H, W = map(int, input().split())
A = [input() for _ in range(H)]

skipRow = set()
skipCol = set()

for h, line in enumerate(A):
    if '#' not in set(line):
        skipRow.add(h)
for w in range(W):
    if all(A[h][w] == '.' for h in range(H)):
        skipCol.add(w)

for i in range(H):
    if i in skipRow:
        continue
    line = [a for w, a in enumerate(A[i]) if w not in skipCol]
    print(''.join(line))

Measured memory_bytes: 3064
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
using ll = long long; using ld = long double;
using pii = pair<int,int>; using pil = pair<int,ll>;
using pli = pair<ll,int>; using pll = pair<ll,ll>;
const int MOD = 1000000007, MOD2 = 998244353;
const int INF = 0x3f3f3f3f, INF2 = 0x3f3f3f37;
const ll LINF = 0x3f3f3f3f3f3f3f3f, LINF2 = 0x3f3f3f3f3f3f3f3d;



int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s; cin >> s;
    for (int i = 0; i < s.size(); ++i) cout << 'x';
}

Measured memory_bytes: 256
N = int(input())
C = list(map(int, input().split()))
C.sort(reverse = True)
res = 0
ans = 0
mod = 10**9+7
p = pow(2, N*2-2, mod)
for i in range(N):
    ans+=(C[i]*(i+2)%mod)*p
print(ans%mod)



Measured memory_bytes: 87500
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;

    string sss = s + s + s;

    if (sss.find(t) != std::string::npos){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

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

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#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, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 100005;
LL a[MAXN], pick[MAXN];

LL n;

int main() {
    GLL(n);

    LL stones = 0;

    FOR1(i, n) {
        GLL(a[i]);
        stones += a[i];
    }

    LL add = n * (n + 1) / 2;

    if (stones % add != 0) {
        cout << "NO\n";
        return 0;
    }

    LL turns = stones / add;
    LL picks = 0;

    FOR1(i, n) {
        int ni = i + 1; if (ni == n + 1) ni = 1;
        LL dif = a[i] - a[ni];

        if ((dif + turns) % n != 0) {
            cout << "NO\n";
            return 0;
        }
        else {
            pick[i] = (dif + turns) / n;
            
            if (pick[i] < 0) {
                cout << "NO\n";
                return 0;
            }

            picks += pick[i];
        }
    }

    if (picks == turns) {
        cout << "YES\n";
        return 0;
    }
    else {
        cout << "NO\n";
        return 0;
    }

    return 0;
}


Measured memory_bytes: 1792
#include <queue>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
const vector<int> dx = { 0, 1, 0, -1 };
const vector<int> dy = { 1, 0, -1, 0 };
int main() {
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for (int i = 0; i < H; ++i) {
		cin >> S[i];
	}
	vector<vector<int> > d(H, vector<int>(W, -1));
	queue<pair<int, int> > que;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (S[i][j] == '#') d[i][j] = 0, que.push(make_pair(i, j));
		}
	}
	int ans = 0;
	while (!que.empty()) {
		pair<int, int> u = que.front(); que.pop();
		ans = d[u.first][u.second];
		for (int i = 0; i < 4; ++i) {
			int tx = u.first + dx[i], ty = u.second + dy[i];
			if (0 <= tx && tx < H && 0 <= ty && ty < W && d[tx][ty] == -1) {
				d[tx][ty] = d[u.first][u.second] + 1;
				que.push(make_pair(tx, ty));
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13456
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main () {
  int a, b, k;
  cin >> a >> b >> k;
  int count = 0;
  int ans[110] = {0};
  for (int i = 1; i <= 100; ++i) {
    if (a % i == 0) {
      if (b % i == 0) {
        ++count;
        ans[count] = i;
      }
    }
  }
  cout << ans[count + 1 - k] << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll K;
    string S;
    cin  >> K >> S;
    if((int)S.size()<=K){
        cout << S << endl;
    }else{
        string res = "";
        res += S.substr(0, K);
        res += "...";
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 3656
#include <cctype>
#include <cstdio>
#include <cstring>
using namespace std;

int main(void)
{
  char input[1000];
  int i, len, sum;
  while (1) {
    scanf("%s", input);
    if (input[0] == '0') break;
    len = strlen(input);
    sum = 0;
    for (i = 0; i < len; i++) {
      sum += input[i] - '0';
    }
    printf("%d\n", sum);
  }
  return 0;
}

Measured memory_bytes: 964
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

ll N,A;
ll x[55];
ll dp[55][3000];
ll ans=0;
int main(){
    cin>>N>>A;
    REP(i,0,N) {
        cin>>x[i];
    }
    dp[0][0]=1;
    REP(i,0,N){
        RREP(k,1,N+1) {
            RREP(j,0,2600){
                if(j-x[i] >=0)dp[k][j] += dp[k-1][j-x[i]];
            }
        }
    }
    REP(i,1,N+1){
        ans+=dp[i][A*i];
    }
    p(ans);
    return 0;
}

Measured memory_bytes: 1408