akhauriyash/Code-Regression huggingface dataset:
using System;
namespace DS
{
    class Program
    {
        static void Main(string[] args)
        {
           
            int n = Convert.ToInt32(Console.ReadLine());
            string[] nums = Console.ReadLine().ToString().Split(' ');
            int[] stones = new int[n];
            for (int i = 0; i < n; i++)
                stones[i] = Convert.ToInt32(nums[i]);
           int[] cost = new int[n];
            cost[0] = 0;
            cost[1] = Math.Abs(stones[1] - stones[0]);

            for(int i=2;i<n;i++)
            {
                cost[i] = Math.Min(cost[i-1] + Math.Abs(stones[i] - stones[i - 1]),
                            cost[i-2] + Math.Abs(stones[i] - stones[i - 2]));
            }
            
            Console.WriteLine(cost[n-1]);
        }
    }
}

Measured memory_bytes: 16992
#include <stdio.h>
#include <stdlib.h>

int main(void){
 char str[4];
 scanf("%s",&str);
 int A=atoi(str)/1000;
 int B1=atoi(str)-A*1000;
 int B=B1/100;
 int C1=atoi(str)-A*1000-B*100;
 int C=C1/10;
 int D=atoi(str)-A*1000-B*100-C*10;
 if(A+B+C+D==7){
 printf("%d+%d+%d+%d=7",A,B,C,D);
 }else if(A-B+C+D==7){
 printf("%d-%d+%d+%d=7",A,B,C,D);
 }else if(A+B-C+D==7){
 printf("%d+%d-%d+%d=7",A,B,C,D);
 }else if(A+B+C-D==7){
 printf("%d+%d+%d-%d=7",A,B,C,D);
 }else if(A-B-C+D==7){
 printf("%d-%d-%d+%d=7",A,B,C,D);
 }else if(A-B+C-D==7){
 printf("%d-%d+%d-%d=7",A,B,C,D);
 }else if(A+B-C-D==7){
 printf("%d+%d-%d-%d=7",A,B,C,D);
 }else if(A-B-C-D==7){
 printf("%d-%d-%d-%d=7",A,B,C,D);
 }




}








Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


int main()
{
    ll n,L,T;
    cin >> n >> L >> T;
    vl x(n),w(n);
    rep(i,n) cin >> x[i] >> w[i];

    vl z(n);
    rep(i,n) {
        if(w[i] == 1) z[i] = (x[i] + T) % L;
        if(w[i] == 2) z[i] = ((x[i] - T) % L + L) % L;
    }
    vl v;
    if(w[0] == 1) {
        for(int i = 1; i < n; ++i) {
            if(w[i] == 2) v.push_back(x[i]-x[0]);
        }
    }
    if(w[0] == 2) {
        for(int i = n-1; i > 0; --i) {
            if(w[i] == 1) v.push_back(L-x[i]+x[0]);
        }
    }
    ll p = (2*T)/L, q = (2*T)%L;
    ll collide_count = p*SZ(v);
    rep(j,SZ(v)) {
        if(v[j] <= q) collide_count++;
    }

    // 蟻rがz[0]にいる
    // 蟻rと重なっている蟻がいるとき(その位置をyとおく)
    // w[0] = 1 ⇒ 蟻rの位置は右側のy
    // w[0] = 2 ⇒ 蟻rの位置は左側のy
    ll r, y = z[0];
    if(w[0] == 1) r = collide_count % n;
    if(w[0] == 2) r = n - collide_count % n;
    sort(z.begin(), z.end());

    //蟻rがz[pos]にいる(zはsort済み)
    ll pos;
    if(w[0] == 1) {
        rep(i,n) {
            if(z[i] == y) pos = i;
        }
    }
    if(w[0] == 2) {
        drep(i,n) {
            if(z[i] == y) pos = i;
        }
    }
    // 蟻0がz[base]にいる
    ll base = ((pos + n) - r) % n;
    rotate(z.begin(), z.begin() + base, z.end());

    rep(i,n) cout << z[i] << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main() {
    ll n, m, k,i,j,h;
    string s;
    cin >> s;
    ll ss=s.size();
    ll ten[200000];
    ten[0]=1;
    ll dp[ss + 1][13];
    for(i = 0; i <= ss; i++) {
        for(j = 0; j < 13; j++) {
            dp[i][j] = 0;
        }
    }
    for(i=1;i<200000;i++){
        ten[i] = (10*ten[i-1]) % 13;
    }
    dp[0][0] = 1;
    for(i=1;i<=ss;i++){
        if(s[ss-i]!='?'){
            ll x = ((s[ss - i] - '0') * ten[i-1]) % 13;
            for(j = 0; j < 13; j++) {
                dp[i][j]=dp[i-1][(j-x+13)%13];
            }
        }else{ 
            for(h=0;h<=9;h++){
                ll x = (h * ten[i - 1]) % 13;
                for(j=0;j<13;j++){
                    dp[i][j] = (dp[i][j] + dp[i - 1][(j - x + 13) % 13]) % MOD;
                }
            }
        }
    }
    cout << dp[ss][5] << endl;
    return 0;
}


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

#define K 50
int A, B;
char grid[2 * K + 1][2 * K + 1];

void Print() {
  cout << 2 * K << " " << 2 * K << endl;
  for (int row = 1; row <= 2 * K; ++row) {
    for (int col = 1; col <= 2 * K; ++col) {
      cout << grid[row][col];
    }
    cout << endl;
  }
  cout << endl;
}

int main() {
  cin >> A >> B;
  for (int row = 1; row <= 2 * K; ++row) {
    for (int col = 1; col <= 2 * K; ++col) {
      if (1 <= row && row <= K)
        grid[row][col] = '#';
      else
        grid[row][col] = '.';
    }
  }
  int r = 1, c = 1;
  for (int i = 1; i <= A - 1; ++i) {
    grid[r][c] = '.';
    c += 2;
    if (c > 2 * K) {
      r += 2;
      c = 1;
    }
  }
  r = K + 2, c = 1;
  for (int i = 1; i <= B - 1; ++i) {
    grid[r][c] = '#';
    c += 2;
    if (c > 2 * K) {
      r += 2;
      c = 1;
    }
  }
  Print();
}


Measured memory_bytes: 256
# 前回のやつを保存しつつあたま+1からみていって前回のと同じの場合、長さ1なら更に+1したもの、それ以外は。。。。ありえないので考えなくていい
s = input()
pre = s[0]
ans = 1
idx = 1
# print(pre) 確認用
while idx < len(s):
    if len(pre) == 1:
        if pre != s[idx]:
            ans += 1
            pre = s[idx]
            idx += 1
        else:
            if idx + 1 < len(s):
                # まだ追加できる
                pre = s[idx:idx + 2]
                idx += 2
                ans += 1
            else:
                # 終了
                pre = s[idx - 1:]
                idx += 1
    else:
        # 前回で2文字使っているので今回は1文字でいい
        pre = s[idx]
        ans += 1
        idx += 1
    # print(pre) 確認用
print(ans)


Measured memory_bytes: 3500
// https://atcoder.jp/contests/dp/tasks/dp_o
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define infinity (ll)4e18
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;
ll a[21][21];

ll solve(ll dp[], ll n, ll bit)
{
    if (dp[bit] != -1)
        return dp[bit];
    ll count = 0, temp = bit;
    for (ll i = 0; i < n; i++)
        if (bit & (1 << i))
            count++;
    dp[bit] = 0;
    for (ll i = 0; i < n; i++)
    {
        if (a[count - 1][i] && (bit & (1 << i)))
            dp[bit] = (dp[bit] + solve(dp, n, bit ^ (1 << i))) % mod;
    }
    return dp[bit];
}

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

    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++)
        for (ll j = 0; j < n; j++)
            cin >> a[i][j];
    ll size = pow(2, n);
    ll dp[size];
    memset(dp, -1, sizeof(dp));
    dp[0] = 1;
    cout << solve(dp, n, size - 1) % mod << endl;
    return 0;
}

Measured memory_bytes: 16640
import java.util.*;
 
public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int H[] = new int[N];
    int Max = 0;
    
    for (int i = 0; i < N; i++){
      H[i] = scan.nextInt();
    }
    
    for (int i = 0; i < N; i++){
      if(H[i]-1 > Max){
        Max = H[i]-1;
      } else if(H[i] < Max){
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
}

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

int main() {
 int n; cin >> n;
 ll ans=1;
 rep(i,n)ans*=3;
 int cnteven=0;
 rep(i,n){
   int a; cin >> a;
   if(a%2==0)cnteven++;
 }
 ll d=pow(2,cnteven);
 cout << ans-d <<endl; 

}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String input_line = input.readLine();

		String[] coordinate_group = input_line.split(" ");

		double coordinate_x = Double .parseDouble(coordinate_group[0]);

		double coordinate_y = Double .parseDouble(coordinate_group[1]);

		double coordinate_xi = Double .parseDouble(coordinate_group[2]);

		double coordinate_yi = Double .parseDouble(coordinate_group[3]);

		double x_distance = Math.pow(coordinate_x - coordinate_xi, 2);

		double y_distance = Math.pow(coordinate_y - coordinate_yi, 2);

		double distance = Math.sqrt(x_distance + y_distance);

		System.out.println(distance);

	}

}

Measured memory_bytes: 24412
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
pair<int,int> BA[100000];
pair<int,int> C[100000];
void Calc(){
	int N = rei();
	for(int i=0;i<N;i++){
		BA[i].second = rei();
	}
	for(int i=0;i<N;i++){
		BA[i].first = rei();
	}
	sort(BA,BA+N);
	for(int i=0;i<N;i++){
		C[i] = {BA[i].second,i};
	}
	sort(C,C+N);
	for(int i=0;i<N;i++){
		if(C[i].first > BA[i].first){
			cout << "No" << endl;
			return;
		}
	}
	for(int i=0;i<N-1;i++){
		if(C[i+1].first <= BA[i].first){
			cout << "Yes" << endl;
			return;
		}
	}
	int c = 1;
	int p = C[0].second;
	while(p != 0){
		c++;
		p = C[p].second;
	}
	if(c == N){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

using Row = vector<int64>;
using Mat = vector<Row>;

int64 dp[3010][3010] = {};
bool visited[3010][3010] = {};
int32 N;
vector<int64> a;

int64 dfs(int32 l, int32 r){
	if(visited[l][r]) return dp[l][r];
	if(l == r) return 0;
	visited[l][r] = 1;
	int32 rest = r-l;
	if(rest%2 == N%2){
		dp[l][r] = max(dfs(l+1,r)+a[l], dfs(l,r-1)+a[r-1]);
	}else{
		dp[l][r] = min(dfs(l+1,r)-a[l], dfs(l,r-1)-a[r-1]);
	}
	return dp[l][r];
}

int main(void){
	cin >> N;
	a.resize(N);
	REP(i, N) cin >> a[i];
	REP(i, N+1){
		REP(j, N+1){
			if((j-i)%2 == N%2)
				dp[i][j] = INF_LL;
			else
				dp[i][j] = -INF_LL;
		}
	}
	cout << dfs(0, N) << endl;
}



Measured memory_bytes: 79872
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000000000000002
#define N 400003
#define pb push_back
#define endl "\n"
char a[3000][3000];
ll b[3000][3000];
using namespace std;

int main()
{
    ll h,w;cin>>h>>w;
    for(ll i=0;i<h;i++)
    {
        for(ll j=0;j<w;j++)
        {
            cin>>a[i][j];
            
        }
    }
    char ab='#';
    int flag=0;
    for(ll i=1;i<w;i++)
    {
        if(a[0][i]==ab)
        {
            b[0][i]=0;
            flag=1;
        }
       
        if(flag==0)b[0][i]=1;
        else b[0][i]=0;
    }flag=0;
    for(ll i=0;i<h;i++)
    {
        if(a[i][0]==ab)
        {
            b[i][0]=0;
            flag=1;
        }
        else{
            if(flag==0)b[i][0]=1;
        
            else {
                b[i][0]=0;
            }
        }
    }
    for( ll i=1;i<h;i++)
    {
        for(ll j=1;j<w;j++)
        {
            if(a[i][j]==ab)
            {
                b[i][j]=0;
            }
            else{
                b[i][j]=((b[i-1][j]+b[i][j-1]))%1000000007;
            }
            
        }
    }
    cout<<b[h-1][w-1]<<endl;  return 0;
}


Measured memory_bytes: 28032
#include<iostream>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

char suits[4] = {'S', 'H', 'C', 'D'};
int cards[4][13] = {0};

int main() {
  int n; cin >> n;
  REP(i, n) {
    char suit;
    int rank;
    cin >> suit >> rank;
    REP(j, 4) {
      if (suits[j] == suit) cards[j][rank - 1] = 1;
    }
  }
  REP(i, 4) {
    REP(j, 13) {
      if (cards[i][j] == 0) printf("%c %d\n", suits[i], j + 1);
    }
  }
}


Measured memory_bytes: 3132
extern crate core;

use std::io::{self, Read};
use std::iter;

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input
        .split("\n")
        .skip(1)
        .map(|line| {
            let ll = line.split_whitespace()
                .map(|x| x.parse::<i32>().unwrap())
                .collect::<Vec<_>>();
            //c,s,f
            (ll[0], ll[1], ll[2])
        })
        .collect::<Vec<_>>();
    let mut result: Vec<String> = Vec::new();
    for (i, _) in list.iter().enumerate() {
        let mut now_time = 0;
        for &(c, s, f) in list.iter().skip(i) {
            for k in (0..) {
                let t = s + k * f;
                if now_time <= t {
                    now_time = t + c;
                    break;
                }
            }
        }
        result.push(now_time.to_string());
    }
    result.join("\n") + "\n0"
}

#[test]
fn test() {
    let tests = vec![
        ("3\n6 5 1\n1 10 1", "12\n11\n0"),
        ("4\n12 24 6\n52 16 4\n99 2 2", "187\n167\n101\n0"),
        ("4\n12 13 1\n44 17 17\n66 4096 64", "4162\n4162\n4162\n0"),
    ];
    for (i, (input, output)) in tests.into_iter().enumerate() {
        println!("test:{}", i);
        assert_eq!(run(input.to_string()), output.to_string());
    }
}


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

wa=0
ans1=0
for i in range(n):
    wa+=a[i]
    if i%2==0:
        if wa==0:
            wa=1
            ans1+=1
        elif wa>0:
            pass
        else:
            ans1+=1-wa
            wa=1
    else:
        if wa==0:
            wa=-1
            ans1+=1
        elif wa<0:
            pass
        else:
            ans1+=wa+1
            wa=-1
wa=0
ans2=0
for i in range(n):
    wa+=a[i]
    if i%2:
        if wa==0:
            wa=1
            ans2+=1
        elif wa>0:
            pass
        else:
            ans2+=1-wa
            wa=1
    else:
        if wa==0:
            wa=-1
            ans2+=1
        elif wa<0:
            pass
        else:
            ans2+=wa+1
            wa=-1

print(min(ans1,ans2))


Measured memory_bytes: 63216
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa;cin>>nyaa;

void solve() {
	ll s, t, p, q, m, y;
	cin >> s >> t >> p >> q >> m >> y;
	cout << (s^t^y) << endl;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
//stop
	return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
  
int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  int ans=0;
  for(int i=0;i<n;i++){
    cin >> s[i];
    
  }
  sort(s.begin(),s.end());
  for(int i=0;i<n;i++){
      if(s[i]!=s[i+1]) ans++;
    }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;
const long long MOD = pow(10,9)+7;
int N;
unordered_map<int,int> cnt0,cnt1;
pair<long long,long long> get(vector<vector<long long>>& adj,vector<bool>& vu,int node){
  long long c0 = -1,c1 = -1;
  if(cnt0.count(node)) c0 = cnt0[node];
  if(cnt1.count(node)) c1 = cnt1[node];
  if(c0 == -1 or c1 == -1){
    long long tmp0 = 1, tmp1 = 1;
    for(int i : adj[node]){
      if(!vu[i]){
        vu[i] = true;
	pair<long long,long long> p = get(adj,vu,i);
        tmp0 = (tmp0*(p.first+p.second))%MOD;
        tmp1 = (tmp1*p.first)%MOD;
      }
    }
    c0 = tmp0;
    c1 = tmp1;
    cnt0[node] = c0;
    cnt1[node] = c1;
  }
  //cout << node << " " << c0 << " " << c1 << endl;
  return make_pair(c0,c1);
}
int main(){
  int a,b;
  cin >> N;
  vector<vector<long long>> adj(N+1);
  for(int i = 1; i < N; ++i){
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vector<bool> vu(N+1);
  vu[1] = true;
  pair<long long,long long> p = get(adj,vu,1);
  cout << (p.first+p.second)%MOD;
  return 0;
}

Measured memory_bytes: 20936
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
int n;
const int str_size=10;

int main(){
  scanf("%d", &n);
  vector<vector<char>> data(n,vector<char>(str_size));
  for(int i=0; i<n; i++){
    char dmy; scanf("%c", &dmy);
    for(int j=0; j<str_size; j++){
      scanf("%c", &data[i][j]);
    }
  }
  
  for(int i=0; i<n; i++){
    sort(data[i].begin(), data[i].end());
  }
  sort(data.begin(), data.end());
  
  int count=1;
  vector<int> comb;
  for(int i=0; i<n-1; i++){
    if(equal(data[i].begin(), data[i].end(), data[i+1].begin(), data[i+1].end())){
      count++;
    }else{
      if(count!=1){
        comb.emplace_back(count);
        count = 1;
      }
    }
  }
  comb.emplace_back(count);
  
  ll ans=0;
  for(ll t : comb){
    ans += t*(t-1)/2;
  }
  printf("%llu\n", ans);
}

Measured memory_bytes: 5888
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import qualified Data.Map as MP
import Data.Maybe

make xs = VU.foldl' step MP.empty xs
    where
        step m x =
            case MP.lookup x m of
                Just _ -> MP.adjust (+1) x m
                Nothing -> MP.insert x 1 m

solve m = MP.foldl step 0 m
    where
        step i v
            | odd v = i + 1
            | otherwise = i

main = do
    n <- readLn :: IO Int
    xs <- VU.replicateM n (fst . fromJust . B.readInt <$> B.getLine)
    let m = make xs
    print $ solve m

Measured memory_bytes: 19068
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
} edge;
int main( void ){
	int N;
	string S; cin >> N >> S;
	int ans = 0;
	rep(div, 1, N-1){
		map<char, bool> mp;
		int cnt = 0;
		rep(i,0,div){
			mp[S[i]] |= true;
		}
		rep(i,div, N){
			if (mp[S[i]]){
				mp[S[i]] = false;
				cnt ++;
			}
		}
		ans = max(ans, cnt);
	}
	cout << ans <<  endl;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <iostream>

#define MAX_SET (1000)

using namespace std;

void draw_chessboard(int H, int W);

int main()
{  
    int  i;
    int* H = new int[MAX_SET + 1];
    int* W = new int[MAX_SET + 1];
    int  size;

    for (int i = 0; i < MAX_SET + 1; i++) {
         do {
             cin >> H[i] >> W[i];
         } while (H[i] > 300 || W[i] > 300);

         if (H[i] == 0 && W[i] == 0) {	    
             size = i;
	     break;
         }
    }
    
    for (int i = 0; i < size; i++) {
         draw_chessboard(H[i], W[i]);    
         cout << endl;         
    }

    delete[] H;
    delete[] W;
 
    return (0);
} 

void draw_chessboard(int H, int W)
{    
     for (int i = 1; i <= H; i++) {
          if (i % 2 == 1) {
              for (int j = 1; j <= W; j++) {
	   	   if (j % 2 == 1) {
		       cout << "#";
                   } else {
		       cout << ".";
                   }
              }
          } else {
	      for (int j = 1; j <= W; j++) {
		   if (j % 2 == 0) {
		       cout << "#";
                   } else {
		       cout << ".";
                   }
	      }
          }

          cout << endl;
     }
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    double t, x;
    cin >> t >> x;
    cout << t / x << endl;
}


Measured memory_bytes: 3796
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long k = sc.nextLong();

        long result = a-b;
        if (Math.abs(result) > 1000000000000000000L)
            System.out.println("Unfair");
        else if (k%2 == 0)
            System.out.println(result);
        else
            System.out.println(-result);
    }
}

Measured memory_bytes: 23636
fun Boolean.toInt() = if (this) 1 else 0

fun main(args: Array<String>) {
  val s = readLine()!!
  val ans = (s.length % 2 == 0).toInt() xor (s.first() == s.last()).toInt()
  println(if (ans == 0) "First" else "Second")
}


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

struct node {
	int val;
	bool operator <(const node& x) const {
		return x.val < val;
	}
};

priority_queue <node> q;
long long ans;
int A, B, C, a[100005], b[100005], c[100005], X, Y;

bool cmp(int a, int b) { return a > b; }

int main() {
	cin>>X>>Y>>A>>B>>C;
	for(int i = 1; i <= A; i++) cin>>a[i];
	for(int i = 1; i <= B; i++) cin>>b[i];
	for(int i = 1; i <= C; i++) cin>>c[i];
	sort(a + 1, a + A + 1, cmp);
	sort(b + 1, b + B + 1, cmp);
	sort(c + 1, c + C + 1, cmp);
	for(int i = 1; i <= X; i++) {
		ans += (long long) a[i];
		q.push((node) {a[i]} );
	}
	for(int i = 1; i <= Y; i++) {
		ans += (long long) b[i];
		q.push((node) {b[i]});
	}
	for(int i = 1; i <= C; i++) {
		int top = q.top().val; 
		q.pop();
		if(c[i] > top) ans += (long long) (c[i] - top);
		else break;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2552
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;



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

    if (x >= 30) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}



Measured memory_bytes: 3620
//libs

#include <bits/stdc++.h>

//other stuff

using namespace std;

//function call

//main

int main(){
	int n, p;
	cin >> n >> p;
	bool ans = 0;
	for (int i = 0; i< n; i++){
		int a;
		cin >> a;
		if (a % 2 == 1)
			ans = 1;
	}
	if (!ans){
		if (p == 0)
			cout << (long long)pow(2, n) << endl;
		else
			cout << 0 << endl;
		return 0;
	}
	cout << (long long)pow(2, n-1) << endl;
return 0;
}

//functions



Measured memory_bytes: 256
N = int(input())
happiness = []
for i in range(N):
    a, b = map(int, input().split())
    happiness.append((a, b, a+b, i))

T = []
A = []
eaten = [False]*N

happiness1 = sorted(happiness, key=lambda x:(x[2], x[0], x[1]))
happiness2 = sorted(happiness, key=lambda x:(x[2], x[1], x[0]))

for i in range(N):
    if i % 2 == 0: # Takahashi
        while True:
            a, _, _, idx = happiness1.pop()
            if not eaten[idx]:
                eaten[idx] = True
                T.append(a)
                break
    else: # Aoki
        while True:
            _, b, _, idx = happiness2.pop()
            if not eaten[idx]:
                eaten[idx] = True
                A.append(b)
                break

print(sum(T) - sum(A))

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


long long max_box_area_in_histogram(vector<int>& a) {
    int N = a.size();

    vector<int> L(N);
    stack<int> st;

    for (int i=0; i<N; ++i) {
        while (!st.empty() && a[st.top()] >= a[i]) {
            st.pop();
        }
        L[i] = (st.empty() ? -1 : st.top())+1;
        st.push(i);
    }

    while (!st.empty()) st.pop();

    vector<int> R(N);
    for (int i=N-1; i>=0; --i) {
        while (!st.empty() && a[st.top()] >= a[i]) {
            st.pop();
        }
        R[i] = (st.empty() ? N : st.top())-1;
        st.push(i);
    }

    long long smax = 0;
    for (int i=0; i<N; ++i) {
        int h = a[i], w = R[i] - L[i] + 1;
        // ll s = (long long)h * w;
        ll s = (long long)(h + 1)*(w + 1);
        smax = max(smax, s);
    }

    return smax;
}

ll solve(int H, int W, vector<string>& s) {
    vvi a(H-1, vi(W-1, 0));
    rep(r, H-1) {
        rep(c, W-1) {
            a[r][c] = (s[r][c] == '#') ^ (s[r][c+1] == '#')
                    ^ (s[r+1][c] == '#') ^ (s[r+1][c+1] == '#');
        }
    }

    ll best = max(W, H);

    vi histo(W-1, 0);
    rep(r, H-1){
        rep(c, W-1) {
            if (a[r][c]) histo[c] = 0;
            else         histo[c]++;
        }
        best = max(best, max_box_area_in_histogram(histo));
    }

    return best;
}

int main() {
    int H, W; cin >> H >> W;
    vector<string> s(H);
    rep(i, H) cin >> s[i];
    cout << solve(H,W,s) << endl;
    return 0;
}


Measured memory_bytes: 20096
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    n = I()
    h = LI()
    ok = 0
    ng = 0
    ans = 0

    for i,x in enumerate(h):
        if x>0:
            ok = i
            break
    else:
        ok = n

    while ok != n:
        for i,x in enumerate(h[ok+1:]):
            if x == 0:
                ng = ok + 1 + i
                break
        else:
            ng = n
        # print(ok,ng)
        sub = [0]*ok + [1]*(ng-ok) + [0]*(n-ng)

        for i in range(n):
            h[i] -= sub[i]
        # print(h)
        for i,x in enumerate(h):
            if x>0:
                ok = i
                break
            else:
                ok = n
        ans += 1

    print(ans)
main()

Measured memory_bytes: 9848
#include <iostream>

using std::cin;
using std::cout;

bool cards[26][14];

int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		char s; int r;
		cin >> s >> r;
		cards[s - 'A'][r] = 1;
	}
	for(int i = 1; i <= 13; i++) if(!cards['S' - 'A'][i]) cout << "S " << i << '\n';
	for(int i = 1; i <= 13; i++) if(!cards['H' - 'A'][i]) cout << "H " << i << '\n';
	for(int i = 1; i <= 13; i++) if(!cards['C' - 'A'][i]) cout << "C " << i << '\n';
	for(int i = 1; i <= 13; i++) if(!cards['D' - 'A'][i]) cout << "D " << i << '\n';
	return 0;
}


Measured memory_bytes: 3112
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    int d = Integer.parseInt(sc.next());
    while (true) {
      c -= b;
      if (c <= 0) {
        pw.println("Yes");
        return;
      }
      a -= d;
      if (a <= 0) {
        pw.println("No");
        return;
      }
    }
  }
}


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

#define DIV 1000000007

long long n, m;
long long x[100005];
long long y[100005];

int main(){
	cin >> n >> m;
	for(long long i = 0; i < n; i++){
		cin >> x[i];
	}
	for(long long i = 0; i < m; i++){
		cin >> y[i];
	}


	long long xsum = 0;
	for(long long i = 0; i < n; i++){
		//plus
		xsum += x[i] * max((long long)0, i);
		xsum = (xsum + DIV)%DIV;
		//minus
		xsum -= x[i] * max((long long)0, n - 1 - i);
		xsum = (xsum + DIV)%DIV;
	}

	long long ysum = 0;
	for(long long i = 0; i < m; i++){
		//plus
		ysum += y[i] * max((long long)0, i);
		ysum = (ysum + DIV)%DIV;
		//minus
		ysum -= y[i] * max((long long)0, m - 1 - i);
		ysum = (ysum + DIV)%DIV;
	}
	cout << (xsum * ysum)%DIV << endl;
}


Measured memory_bytes: 1792
#define cross(a1, b1, a2, b2) ((a1)*(b2)-(a2)*(b1))
int main(){
	double a[50],b[50],s,t,x;
	int n,c=1,i;
	for(;scanf("%d",&n),n;printf("%d %.1lf\n",c,fabs(s-t)),c++){
		for(i=0;i<n;i++)scanf("%lf%lf",a+i,b+i);
		for(i=s=t=0;i<n-1;i++){
			if((x=cross(a[i],b[i],a[i+1],b[i+1]))>0)s+=fabs(x)/2.0;
			else t+=fabs(x)/2;
		}
		if((x=cross(a[i],b[i],a[0],b[0]))>0)s+=fabs(x)/2;
		else t+=fabs(x)/2;
	}
exit(0);}

Measured memory_bytes: 656
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    ll n,ans=0;
    cin>>n;
    vector<ll>d(n);
    for(ll i=0;i<n;i++)cin>>d[i];
    for(ll i=0;i<n-1;i++){
        for(ll j=i+1;j<n;j++){
            if(i==j)continue;
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll i,j,n,m,k,cnt=0,ans=0,t=1;
    cin>>n>>m;
    ll a[n];
    rep(i,0,n) cin>>a[i];
    // ll pr[n+1]={0};
    // partial_sum(a,a+n,pr);
    sort(a,a+n);
    pll v;
    rep(i,0,m){
        cin>>j>>k;
        v.pb(mp(k,j));
    }
    sort(all(v));
    reverse(all(v));
    j=0;
    rep(i,0,m){
        cnt=v[i].S;
        while(j<n && cnt>0 && a[j]<=v[i].F) a[j]=v[i].F,j++,cnt--;
    }
    rep(i,0,n) ans+=a[i];
    ret(ans)
    return 0;
}

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

int main() {
  // 命令の行数を取得
  int N;
  cin >> N;
  int max = 0;
  int final_result = 0;
 
  for(int i = 1; i <= N; i++){
    // resultの初期化
    int result = 0;
    int num = i;
    while(true){
      if(num % 2 != 0){
        break; 
      }
      num /= 2;
      result ++;
    }
    /*
    cout << "max" << endl;
    cout << max << endl;
    cout << result << endl;
    cout << i << endl;
    */
    if(max < result){
      /*
      cout << "呼び出し" << endl;
      cout << i << endl;
      cout << max << endl;
      */
      max = result;
      final_result = i;
    }
  }
 if(max == 0){
   final_result = N;
 }
  cout << final_result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int t1=h1*60+m1;
    int t2=h2*60+m2;
    cout<<t2-t1-k<<endl;
    return 0;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main{
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		
		final int N_bits = 1 << N;
		
		int[] visited = new int[N_bits];
		Arrays.fill(visited, -1);
		LinkedList<Integer> queue = new LinkedList<Integer>();
		
		int init = 0;
		for(int i = 0; i < N; i++){
			init *= 2;
			init += sc.nextInt();
		}
		
		int[] arr = new int[M];
		for(int i = 0; i < M; i++){
			arr[i] = sc.nextInt();
		}
		
		visited[init] = 0;
		queue.add(init);
		
		
		while(!queue.isEmpty()){
			final int bit = queue.poll();
			boolean flag = true;
			//System.out.println(bit);
			
			
			int prev = ((bit) >> (N - 1)) != 0 ? 1 : 0;
			//System.out.println(prev);
			
			int run = 0;
			int cnt = 1;
			for(int pos = N - 2; pos >= 0; pos--){
				//System.out.println(pos + " " + Integer.toBinaryString((1 << (pos + 1)) - 1) + " "  + Integer.toBinaryString(bit));
				final int cur = ((bit & ((1 << (pos + 1)) - 1)) >> pos) != 0 ? 1 : 0;
				//System.out.println("but" + " " + pos + " > " + cur + " " + prev + " " + cnt + " " + run);
				if(prev == cur){
					cnt++;
				}else{
					if(arr[run] == cnt){
						run++;
						cnt = 1;
						prev = cur;
					}else{
						flag = false;
						break;
					}
				}
			}
			
			if(arr[run] != cnt){
				flag = false;
			}else{
				run++;
			}
			
			if(flag){
				System.out.println(visited[bit]);
				break;
			}
			
			for(int fst = 0; fst < N - 1; fst++){
				//for(int snd = fst + 1; snd < N; snd++){
				final int snd = fst + 1;
					final int fst_value = (bit & (1 << fst)) != 0 ? 1 : 0;
					final int snd_value = (bit & (1 << snd)) != 0 ? 1 : 0;
					
					final int next_bit = (bit & ~(1 << fst) & ~(1 << snd)) | (snd_value << fst) | (fst_value << snd);
					
					//System.out.println(next_bit);
					
					if(visited[next_bit] >= 0){
						continue;
					}
					visited[next_bit] = visited[bit] + 1;
					
					queue.add(next_bit);
				//}
			}
		}
		
		sc.close();
	}

	public static class Scanner {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		// 他のnextXXXもXXX.parseXXX()メソッドを使って作れるので省略

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 20288
#include <stdio.h>
#include <string.h>
int main(){
  int a, b, c;

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

  if(a == (b + c)){
    printf("Yes\n");
  }else if(b == (a + c)){
    printf("Yes\n");
  }else if(c == (a + b)){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n,h;cin >>n>>h;
    vector<ll>a(n);
    vector<ll>b(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i]>>b[i];
    }
    sort(all(a));
    sort(all(b));
    reverse(all(a));
    reverse(all(b));
    ll ans=0;
    for (int j = 0; j < n; ++j) {
        if(b[j]>=a[0]){
            h-=b[j];
            ans++;
            if(h<=0){
                cout <<ans<<endl;
                return 0;
            }
        }
    }
    ans+=(h-1)/a[0]+1;
    cout <<ans <<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;  
  vector<string> strn(N);
  for (int i=0;i<N;i++){
    string s;
    cin >>s;
    strn.at(i) = s;
  }
  
  int M;
  cin >>M;
  vector<string> strm(M);
  for (int i=0;i<M;i++){
    string t;
    cin >>t;
    strm.at(i) = t;
  }
  
  int ans = 0;
  
  for (int i=0;i<N;i++){
    int score = 0;
    for (int j=0;j<N;j++){
      if (strn.at(i) == strn.at(j)){
        score++;
      }
    }
    for (int j=0;j<M;j++){
      if (strn.at(i) == strm.at(j)){
        score--;
      }
    }
    ans = max(ans, score);
  }
  
  cout << ans << endl;
}




Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10 ** 9)

N = int(input())
T = [[] for i in range(N)]
for i in range(N - 1):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    T[a].append([b, c])
    T[b].append([a, c])

Q, K = map(int, input().split())
K -= 1

dist = [-1] * N
dist[K] = 0


def dfs(n):
    for to, cost in T[n]:
        if dist[to] < 0:
            dist[to] = dist[n] + cost
            dfs(to)


dfs(K)
for q in range(Q):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    print(dist[x] + dist[y])


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

int main(){
    ll n,m,x;
    cin>>n>>m>>x;
    ll c[n],a[n][m];
    for(ll i=0;i<n;i++){
        cin>>c[i];
        for(ll j=0;j<m;j++) cin>>a[i][j];
    }
    vector<ll> ans;
    for(ll i=1;i<pow(2ll,n);i++){
        vector<ll> v;
        ll j=i,temp[m],cost=0,check=0;
        while(j>0)  v.push_back(j%2),j/=2;
        for(j=v.size();j<n;j++) v.push_back(0);
        for(j=0;j<m;j++)    temp[j]=0;
        for(j=0;j<v.size();j++){
            if(v[j]==1){
                cost+=c[j];
                for(ll p=0;p<m;p++) temp[p]+=a[j][p];
            }
        }
        for(j=0;j<m;j++)    if(temp[j]<x)   check=-1;
        // cout<<cost<<endl;
        if(check==0)    ans.push_back(cost);
    }
    sort(ans.begin(),ans.end());
    if(ans.size()==0)   cout<<"-1"<<endl;
    else                cout<<ans[0]<<endl;
    
    return 0;
}


Measured memory_bytes: 4108
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100000)
#define MOD (998244353)


// Orderd Set 順序付き集合
// Treapで実装
typedef struct OSnode
{
    int val; //値
    struct OSnode* ch[2]; //左右の子
    int pri; //優先度
}OSnode;

OSnode* OSroot;

// rの子scを上に持ってくる
OSnode* OSrotate(OSnode*r, int sc)
{
    OSnode* nr = r->ch[sc];
    r->ch[sc] = nr->ch[1-sc];
    nr->ch[1-sc] = r;
    return nr;
}

OSnode* OSinsertSub(OSnode* r, OSnode* n)
{
    if(r==NULL) return n;
    int sc = r->val < n->val ? 1 : 0 ; //選択する子
    r->ch[sc] = OSinsertSub(r->ch[sc],n);

    if(r->pri > r->ch[sc]->pri) r = OSrotate(r,sc);
    return r;
}

void OSinsert(int val)
{
    OSnode* n = malloc(sizeof(OSnode));
    n->val = val;
    n->pri = rand();
    OSroot = OSinsertSub(OSroot, n);
}

// val 以上の最小の値のポインタを返す
OSnode* OSlower_bound(OSnode* r, int val)
{
    if(r==NULL) return NULL;
    else if(r->val >= val)
    {
        OSnode* res = OSlower_bound(r->ch[0], val);
        return res != NULL ? res : r;
    }else{
        return OSlower_bound(r->ch[1], val);
    }
}

// val 以下の最大の値のポインタを返す
OSnode* OSlower_boundRev(OSnode* r, int val)
{
    if(r==NULL) return NULL;
    else if(r->val <= val)
    {
        OSnode* res = OSlower_boundRev(r->ch[1], val);
        return res != NULL ? res : r;
    }else{
        return OSlower_boundRev(r->ch[0], val);
    }
}




int p[MAXN];
int ind[MAXN];

int main(void)
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&(p[i]));
        p[i]--;
        ind[p[i]] = i;
    }

    int64_t ans=0;
    for(int64_t x = n-1;x>=0;x--)
    {
        int i = ind[x];
        OSnode* lb = OSlower_boundRev(OSroot, i);
        int l1,l2;
        if(lb == NULL)
        {
            l1 = -1;
            l2 = -1;
        }else
        {
            l1 = lb->val;
            lb = OSlower_boundRev(OSroot, l1 -1);
            l2 = lb == NULL ? -1 : lb->val;
        }
        OSnode* rb = OSlower_bound(OSroot, i);
        int r1,r2;
        if(rb == NULL)
        {
            r1 = n;
            r2 = n;
        }else
        {
            r1 = rb->val;
            rb = OSlower_bound(OSroot, r1+1);
            r2 = rb == NULL ? n : rb->val;
        }
        ans += (((i-l1)*(r2-r1))+((r1-i)*(l1-l2))) * (x+1);
        OSinsert(i);
    }

    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 5632
#include<iostream>
#include<algorithm>
using namespace std;
int q,i,r,a,c,n,m;
int main(){
for(cin>>q;i<q;++i){
cin>>c>>a>>n;r=0;
m=min(c,min(a,n));r+=m;c-=m;a-=m;
m=min(c/2,a);c-=m*2;r+=m+c/3;
cout<<r<<endl;
}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	vector<int> b = a;
	vector<bool> mp(1000005);
	rrep(i, n) {
		if (a[i] == a[i - 1]) mp[a[i]] = true;
	}
	int ans = 0;
	for (int i = n - 1; i >= 0; --i) {
		int x = a[i];
		b.pop_back();
		if (mp[a[i]]) {
			ans++;
			continue;
		}
		vector<int> rec;
		for (int j = 1; j * j <= x; ++j) {
			if (x % j == 0) {
				rec.push_back(j);
				if (j * j != x) rec.push_back(x / j);
			}
		}
		bool ok = false;
		for (int c : rec) {
			if (binary_search(all(b), c)) {
				ok = true;
				break;
			}
		}
		if (ok) ans++;
	}
	cout << n - ans << endl;
	return 0;
}


Measured memory_bytes: 5096
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    lis = []
    a = list(map(int, input().split()))
    for j in range(m):
        lis.append(a[j] * b[j])
    if sum(lis) + c > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
program kt
  implicit none
  integer :: i,jun,A,B,K,tp

  read(*,*) A,B,K

  tp=min(A,B)
!  write(*,*) tp                                                                

  jun=0
  do i=tp,1,-1
!     write(*,*) i                                                              
     if((mod(A,i)==0).and.(mod(B,i)==0)) then
        jun=jun+1
     endif
     if(jun.eq.K) then
        exit
     endif
  enddo
  write(*,'(i0)') i
end program kt

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

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long
const int N = 2e5 + 10;
const int MOD = 1e9 + 7;

int fact[N] , inv[N];
int n , w , a , b;

int fastpow(int a , int b){
	int ans = 1;
	a %= MOD;
	while(b){
		if(b&1)
			ans = (ans*a)%MOD;
		b >>= 1;
		a = (a*a)%MOD;
	}
	return ans;
}

void pre(){
	fact[0] = 1;
	for(int i = 1 ; i < N ; ++i){
		fact[i] = (fact[i-1]*i)%MOD;
	}
	inv[N-1] = fastpow(fact[N-1],MOD-2);
	for(int i = N-2 ; i >= 0 ; --i){
		inv[i] = ((i+1)*inv[i+1])%MOD;
	}
}

int ways(int n , int r){
	return (fact[n+r-2]*(inv[r-1]%MOD * inv[n-1]%MOD)%MOD)%MOD;
}

int32_t main(){
	boost;

	cin >> n >> w >> a >> b;
	pre();

	int out = 0;	
	for(int i = b+1 ; i <= w ; ++i){
		out += ((ways(n-a,i)%MOD)*ways(a,w-i+1)%MOD)%MOD;
		out %= MOD;
	}

	cout << out;
	return 0;
}	

Measured memory_bytes: 3328