akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=MOD;
const int INF = 1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);
const int N=100005;

void solve()
{
    int n,m,q;
    cin>>n>>m>>q;
    int a[n],b[m];int mn=INF;
    for(int i=0;i<n;i++)
    {cin>>a[i];
        mn=min(mn,a[i]);
    }
    int ans=mn;
    mn=INF;
    for(int j=0;j<m;j++)
    {   cin>>b[j];
        mn=min(mn,b[j]);
    }
    ans+=mn;int x,y,c;
    while(q--)
    {
        cin>>x>>y>>c;
        ans=min(ans,a[x-1]+b[y-1]-c);
    }
    cout<<ans<<endl;
}

int32_t main()
{
    
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    
    int t;
    t=1;
     //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}



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

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {

            String S = Console.ReadLine();
            String[] line = S.Split(' ');
            long A = long.Parse(line[0]);
            long B = long.Parse(line[1]);
            long C = long.Parse(line[2]);
            long D = long.Parse(line[3]);

            if(C > D)
            {
                long tmp = C;
                C = D;
                D = tmp;
            }

            long X = C * D;
            long C1 = C;
            long D1 = D;
            long r = C % D;

            while(r != 0)
            {
                C1 = D1;
                D1 = r;
                r = C1 % D1;
            }

            X = X / D1;
            int f = 0;

            long C2 = B / C - A / C;
            long D2 = B / D - A / D;
            long X2 = B / X - A / X;

            if(A % C != 0 && A % D != 0)
            {
                f = 1;
            }

            Console.WriteLine((B - A) - (C2 + D2 - X2) + f);

        }



    }
}

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

int main(){
    vector <int> A(5);
    rep(i,5) cin >> A[i];
    
    int num=0;
    int ans=0;
    int min=10;
    rep(i,5){
        if (min>A[i]%10 && A[i]%10!=0){
            min=A[i]%10;
            num=i;
        }
    }
    
    rep(i,num){
        if (A[i]%10==0) ans+=A[i];
        else{
            ans=ans+10-(A[i]%10) + A[i];
        }    
    }
    for (int i=num+1; i<5; i++){
        if (A[i]%10==0) ans+=A[i];
        else{
            ans=ans+10-(A[i]%10) + A[i];
        }
    }
    ans+=A[num];
    cout << ans << endl;
    
}

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

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

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

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

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

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

ll chooseModP(ll n, ll m, int p, vector<ll>& fact, vector<ll>& invfact) {
    ll c = 1;
    while (n || m) {
        ll a = n % p, b = m % p;
        if (a < b) return 0;
        c = c * fact[a] % p * invfact[b] % p * invfact[a - b] % p;
        n /= p; m /= p;
    }
    return c;
}


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

    const ll mod = 1000000007, LIM = 200005; ///include-line
    ll* inv = new ll[LIM] - 1; inv[1] = 1;
    rep(i,2,LIM) inv[i] = mod - (mod / i) * inv[mod % i] % mod;

    vector<ll> fact(LIM, 1), invfact(LIM, 1);
    fact[0] = 1, invfact[0] = 1;
    rep(i, 1, LIM) fact[i] = fact[i - 1] * i % mod;
    rep(i, 1, LIM) invfact[i] = invfact[i - 1] * inv[i] % mod;

    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i, 0, n) cin >> v[i];
    sort(all(v));

    Mod ttl = 0;
    rep(i, 0, n) {
        if (i + 1 >= k) {
            ttl = ttl + Mod(v[i]) * chooseModP(i, k - 1, mod, fact, invfact);
        }
    }
    reverse(all(v));
    rep(i, 0, n) {
        if (i + 1 >= k) {
            ttl = ttl - Mod(v[i]) * chooseModP(i, k - 1, mod, fact, invfact);
        }
    }
    cout << ttl.x << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a,b, c=0, n, k;
string s,t;
//cout<<<<endl;


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


Measured memory_bytes: 256
import math
A,B,C,D = map(int,input().split())
A_rad = math.radians(C*30 + 0.5*D)
B_rad = math.radians(D*6)

A_x,A_y = A*math.sin(A_rad),A*math.cos(A_rad)
B_x,B_y = B*math.sin(B_rad),B*math.cos(B_rad)

print(math.sqrt((A_x-B_x)**2 + (A_y-B_y)**2))

Measured memory_bytes: 9512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>

using namespace std;

void solve();

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

void solve(){

	long N,T;
	long X=0;
	cin >> N >> T;

	vector<long> v(N);

	for(vector<long>::iterator i=v.begin();i<v.end();i++){
		cin >> *i;
	}

	for (long i=1;i<N;i++){
		v[i]-v[i-1]>=T?X+=T:X+=(v[i]-v[i-1]);
	}

	cout << X+T << endl;

}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

#define long long long

long n, s, m;
long w[101], v[101], dp[101][100000];


long cal(int idx, long val) { 
    //if (idx > n && val == 0) return 0;
    if (val == 0) return 0;
    if (idx > n) return 1e18;
    if (dp[idx][val] != -1) return dp[idx][val];
    dp[idx][val] = 0;

    if (val - v[idx] >= 0) dp[idx][val] = min (cal(idx + 1, val), cal(idx + 1, val - v[idx]) + w[idx]);
    else dp[idx][val] = cal(idx + 1, val);
    return dp[idx][val];
}

void FastInput() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
}

void Input() {
    cin >> n >> m;
    for (int i = 1; i <= n; i ++) cin >> w[i] >> v[i], s += v[i];
    for (int i = 0; i <= n; i ++)
        for (int j = 0; j <= s; j ++) dp[i][j] = -1;
}

void Solve() {
    for (int i = s; i >= 1; i --) {
        long res = cal(1, i);
        if (res <= m) {
            cout << i;
            return;
        }
    }
}

int main() {
    FastInput();
    Input();
    Solve();
}

Measured memory_bytes: 79232
#include<stdio.h>
int main(void){
  //printf("input wethear");
  char wethear[3];
  scanf("%s",wethear);
  int count=0;
  int max=0;
  int i;
  //printf("%s",wethear);
  for(i=0;i<3;i++){
    if(wethear[i]=='R'){
      count++;
     // printf("%d",count);
      if(max<count){
        max=count;
      }
    }else{
      count=0;
    }
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	bool flg = true;
	ll N;
	std::cin >> N;
	ll A;
	rep(i, 0, N) {
		std::cin >> A;
		if (A % 2 == 0 && A % 3 != 0 && A % 5 != 0) {
			flg = false;
		}
	}
	if (flg) {
		std::cout << "APPROVED" << endl;
	}
	else {
		std::cout << "DENIED" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
X, N = list(map(int, input().split()))
if N==0:
    print(X)
else:
    ps = list(map(int, input().split()))
    sub_abs = 0
    while True:
        if (X-sub_abs) not in ps:
            print(X-sub_abs)
            break
        if (X+sub_abs) not in ps:
            print(X+sub_abs)
            break
        sub_abs += 1

Measured memory_bytes: 9180
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
a, b = map(int, input().split())
List = [0]*10
ans = -1

for i in range(10):
    List[i] = b*10+i

for i in List:
    if int(i*0.08) == a:
        ans = i
        break;

print(ans)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderBeginnerContest
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // 064-B
            var N = int.Parse(Console.ReadLine());

            var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList() ;

            line.Sort();

            long d = 0;
            for (int i = 1; i < line.Count; i++)
            {
                d += line[i] - line[i - 1];
            }

            Console.WriteLine(d);
        }
    }
}


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

int h, w, ch, cw, dh, dw;
char C[2005][2005];
bool passed[2005][2005];

bool in_range(int X, int Y) {
	return (X>=0 && X<h && Y>=0 && Y<w);
}

signed main() {
	cin>>h>>w>>ch>>cw>>dh>>dw;
	ch--, dh--, cw--, dw--;
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) cin>>C[i][j];
	}
	
	deque <pair <pair <int, int>, int> > Q = {{{ch, cw}, 0}};
	set <pair <int, int> > dir = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
	while (!Q.empty()) {
		int x = Q.front().first.first, y = Q.front().first.second;
		int f = Q.front().second;
//		cout<<x<<" "<<y<<" "<<f<<"\n";
		Q.pop_front();
		if (x==dh && y==dw) {
			cout<<f;
			return 0;
		}
		
		if (passed[x][y]) continue;
		passed[x][y] = 1;
		
		for (int i=-2; i<=2; i++) {
			for (int j=-2; j<=2; j++) if (in_range(x+i, y+j)) {
				if (C[x+i][y+j] == '#' || passed[x+i][y+j]) continue;
				if (dir.count({i, j})) Q.push_front({{x+i, y+j}, f});
				else Q.push_back({{x+i, y+j}, f+1});
			}
		}
	}
	cout<<-1;
}


Measured memory_bytes: 8772
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];

  int sum,ans1=0,ans2=0;

  sum=0;
  rep(i,n){
    sum+=a[i];
    if(i%2){//-
      if(sum>=0){
	ans1+=sum+1;
	sum=-1;
      }
    }else{//+
      if(sum<=0){
	ans1+=abs(sum)+1;
	sum=1;
      }
    } 
  }
  sum=0;
  rep(i,n){
    sum+=a[i];
    if(i%2){//+
      if(sum<=0){
	ans2+=abs(sum)+1;
	sum=1;
      }
    }else{//-
      if(sum>=0){
	ans2+=sum+1;
	sum=-1;
      }
    }
  }
  cout<<min(ans1,ans2)<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	int n;
	cin >> n;
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	if (ans == 1) {
		ans = 10;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream in = System.in;
        final byte[] buffer = new byte[200001];
        int buflen = 0;
        buflen = in.read(buffer);
        int c=0;
        long s=0;
        for (int i=0; i<buflen; ++i) {
            if (buffer[i]=='B') {
                ++c;
            } else if (buffer[i]=='W') {
                s+=c;
            }
        }
       	System.out.println(s);
    }
}


Measured memory_bytes: 22032
fn main() {
    let n: usize = read();
    let h: Vec<i32> = read_to_vec(n);

    let mut f = vec![0; n];

    let mut rtn = 0;

    while !finished(&h, &f) {//与えられた配列と一致するまでループ
        let mut bef = false;
        for i in 0..n {
            if bef != (h[i] > f[i]) && h[i] > f[i] {
                rtn += 1;
            }
            if h[i] > f[i] {
                f[i] += 1;
                bef = true;
            } else {
                bef = false;
            }
        }
    }
    println!("{}", rtn);
}


// 以下使い捨て関数

fn finished(h: &[i32], f: &[i32]) -> bool {
    for i in 0..h.len() {
        if h[i] != f[i] {
            return false
        } else {
            continue;
        }
    }
    true
}

// 以下作り置き関数
use std::io::*;
use std::str::FromStr;

pub const MOD: i64 = 1_000_000_007;


/// 標準入力から
/// 空白文字で囲まれた1つのトークンを
/// 指定の型に変換する
pub 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")
}

/// 標準入力から
/// 空白文字で囲まれたn個のトークンを
/// 指定の型に変換し
/// Vecに格納する
pub fn read_to_vec<T: FromStr>(n: usize) -> Vec<T> {
    let mut v = Vec::with_capacity(n);
    for _i in 0..n {
        v.push(read());
    }
    v
}

/// 標準入力から
/// 空白文字で囲まれたm個のトークンを
/// 指定の型に変換したVecを
/// Vecにn個格納する
pub fn read_to_vec_in_vec<T: FromStr + Clone>(n: usize, m: usize) -> Vec<Vec<T>> {
    let mut v: Vec<Vec<T>> = vec![Vec::with_capacity(m); n];
    for i in 0..n {
        v[i] = read_to_vec(m);
    }
    v
}

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

using namespace std;
const int MAXN = 1e5+10;
int act[MAXN][4], n;
int memo[MAXN][4];
int pd(int day, int last_act){
    if(day == n) return 0;
    if(memo[day][last_act] != -1)
        return memo[day][last_act];
    int ans = 0;
    for(int i = 1; i <= 3; i++){
        if(i == last_act) continue;
        ans = max(ans, act[day][i] + pd(day+1, i));
    }
    return memo[day][last_act] = ans;
}
int main()
{
    cin >> n;
    memset(memo, -1, sizeof memo);
    for(int i = 0; i < n; i++){
        cin >> act[i][1];
        cin >> act[i][2];
        cin >> act[i][3];
    }

    cout << pd(0, 0) << "\n";
    return 0;
}


Measured memory_bytes: 11136
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
    	int b = sc.nextInt();
	    int c = sc.nextInt();
      	int d = sc.nextInt();      	     
      	int[] sum = {a+c, a+d, b+c, b+d};
      	Arrays.sort(sum);
      	System.out.println(sum[0]);
    }
}

Measured memory_bytes: 35680
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  double L;
  cin >> L;
  cout << fixed;
  cout << setprecision(12) << pow((L/3),3) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

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

  vector<int> ans;
  int count=0;
  if(N==0)  ans.push_back(0);
  while(N!=0){
    if(abs(N)%2==1){
      ans.push_back(1);
      if(count%2==0)  N--;
      else  N++;
    }
    else{
      ans.push_back(0);
    }
    N/=2;
    count++;
  }
  
  for(int i=ans.size()-1;i>=0;i--){
    cout << ans.at(i);
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=1033};
char a[N][N];

int main(){
	int n=ci(), m=ci(), k=ci();
	rep(i,0,n-1) scanf("%s",a[i]+1);
	int full = (1<<(n-1))-1;
	int ans = 1e9;
	rep(S,0,full){
		int now = 0;
		int b[12]={}, c[12]={}, tot=0;
		rep(i,0,n-2){
			c[i] = tot+1;
			if( S&(1<<i) ){
				b[++tot] = i;
				now++;
			}
		}
		c[n-1] = tot+1;
		b[++tot] = n-1;
		int d[12]={};
		bool ab = 0;
		rep(L,1,m){
			int e[12]={};
			rep(i,0,n) if( a[i][L]=='1' ) e[c[i]]++;
			bool fail = 0;
			rep(i,1,tot){
				if( e[i]>k ){ ab=1; }
				if( d[i]+e[i]>k ){ d[i]=0; fail=1; }
			}
			if( fail ){
				now++;
				rep(i,1,tot) d[i] = e[i];
			}else{
				rep(i,1,tot) d[i] += e[i];
			}
		}
		if( ab ) continue;
		if( ans>now ) ans=now;
	}
	printf("%d\n",ans);
	return 0;
}


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

class Program
{
    private int N;
    private int[]A;
    private void Scan()
    {
        N=int.Parse(Console.ReadLine());
        A=new int[N];
        var l=Console.ReadLine().Split(' ');
        for(int i=0;i<N;i++)
        {
            {
                A[i]=int.Parse(l[i]);
            }
        }
    }
    
    
    
    public void Solve()
    {
        Scan();
        Array.Sort(A,(a,b)=>-a.CompareTo(b));
        int q=0;
        int cnt=0;
        int[] ans=new int[2];
        int j=0;
        foreach(int i in A)
        {
            if(q!=i)
            {
                q=i;
                cnt=1;
            }
            else
            {
                cnt++;
                if(cnt==2)
                {
                    if(j<2)
                    {
                        ans[j]=i;
                        j++;
                    }
                 
                    cnt=0;   
                }
            }
        }
        Console.WriteLine((long)ans[0]*ans[1]);
        
    } 
    
    static void Main()
    {
        new Program().Solve();
    }
}

Measured memory_bytes: 20576
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 1000003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define sumall(v) accumulate(all(v),(ll)0)
#define sum accumulate
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
#define sp " "
#define zero (ll)0
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<" " ;}cout<<"\n" ;}
double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
/*vbool isprime(N,true);
vll spf(N,0);
vll prime;
void sieve()
{
    isprime[0] = isprime[1] = false;
    for(ll i = 2 ; i<N ; i++)
    {
        if(isprime[i])
        {
            for(ll j=2*i ; j<N ; j+=i)
            {
                isprime[j] = false;
                if(spf[j]==0)
                {
                    spf[j] = i;
                }
            }
            prime.pb(i);
        }
    }
}*//*
ll nck(ll n , ll k ,ll m=1e18+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}*/
ll n,m,k;
bool ok = false;
int main()
{
    FastIO ;
    PRECISION(10) ;
    ll a,b,c,d,i,j,t,x,y,z;//,x1,y1,z1,e,f;
    db p,q,r,u,w ;
    char ch,chr ;
    string str,st,str1,str2,str3,str4;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    cin>>n;
    b = 500;
    a = (n/b)*1000;
    n%=b;
    a+=(n/5)*5;
    cout<<a;
}

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

namespace AC {
#define ll long long
#define PLL pair<ll, ll>
#define PDD pair<double, double>
#define PDPLL pair<double, PLL>
#define PLPLL pair<ll, PLL>
#define pb push_back
#define fi first
#define se second
#define ls rt << 1
#define rs rt << 1 | 1

    const ll N = 2e5 + 66;

    ll BUGS = 1;

    inline ll read(){
        ll x = 0;    bool flag = 1;   char ch = getchar();
        while(ch < '0' || ch > '9') { if(ch == '-') flag = 0; ch = getchar(); }
        while(ch >= '0' && ch <= '9') { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); }
        if(flag) return x;  return (~(x - 1));
    }

    inline void read(ll arr[], ll s, ll e) { for(ll i = s; i <= e; ++i) arr[i] = read(); }

    inline void write(ll x){
        if(x < 0) { x = ~(x - 1); putchar('-'); }
        if(x > 9) write(x / 10); putchar(x % 10 + '0');
    }

    inline void print(ll x) { write(x); puts(""); }

    inline void print(ll arr[], ll s, ll e) {
        for(ll i = s; i <= e - 1; ++i) write(arr[i]), putchar(' ');
        write(arr[e]); puts("");
    }

    inline ll max3(ll a, ll b, ll c) { return max(a, max(b, c)); }

    inline ll min3(ll a, ll b, ll c) { return min(a, min(b, c)); }

    inline void debugNum(ll num, string ss) { cout << "BUGS" << BUGS++ << " : " << ss << " : " << num << endl; }

    inline void debugArr(ll arr[], ll s, ll e, string ss) {
        cout << "BUGS" << BUGS++ << " : " << ss << " : " << endl;
        for(ll i = s; i <= e; ++i) cout << "i : " << i << " val : " << arr[i] << endl;
    }

    inline void IO() {
        //ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
        //cout << setiosflags(ios::fixed) << setprecision(1); //保留小数点后1位
        //cout << setprecision(1); //保留1位有效数字
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
}using namespace AC;

ll n;
char ss[N];

int main() {
    //IO();
    while(~scanf("%lld%s", &n, ss)) {
        ll cnt = 0;
        for(ll i = 0; i < n; ++i) {
            if(ss[i] == 'R') cnt++;
        }
        ll ans = 0;
        for(ll i = 0; i < cnt; ++i) {
            if(ss[i] == 'W') ans++;
        }
        print(ans);
    }
    return 0;
}



Measured memory_bytes: 3992
#include<cstdio>
#include<algorithm>
using std::max;
int sum[210][210],n,m,a[210][210];
int dp[210][210][210][15];
char s[210]; 
int calc(int x1,int y1,int x2,int y2){
	return sum[x2][y2]-sum[x2][y1-1]-sum[x1-1][y2]+sum[x1-1][y1-1];
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",s+1);
		for(int j=1;j<=m;j++){
			if(s[j]=='.')a[i][j]=0;
			else a[i][j]=1;
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+a[i][j];
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			for(int k=1;k<=m;k++){
				int L=i,R=n,res=i-1;
				while(L<=R){
					int mid=(L+R)/2;
					if(calc(i,j,mid,k)==(mid-i+1)*(k-j+1)||calc(i,j,mid,k)==0)res=mid,L=mid+1;
					else R=mid-1;
				}
				dp[i][j][k][0]=res;
			}
	int X;
	for(X=1;dp[1][1][m][X-1]<n;X++)
		for(int len=1;len<=m;len++)
			for(int i=1;i<=n;i++)
				for(int j1=1,j2=len;j2<=m;j1++,j2++){
					if(dp[i][j1][j2][X-1]==n){
						dp[i][j1][j2][X]=n;
						continue;
					}
					dp[i][j1][j2][X]=dp[dp[i][j1][j2][X-1]+1][j1][j2][X-1];
					if(dp[i][j1][j2][X]==n)continue;
					int L=j1,R=j2,res=0;
					while(L<=R){
						int mid=(L+R)/2;
						int a1=dp[i][j1][mid][X-1],a2=dp[i][mid+1][j2][X-1];
						if(a1<a2)res=max(res,a1),R=mid-1;
						else res=max(res,a2),L=mid+1;
					}
					dp[i][j1][j2][X]=max(dp[i][j1][j2][X],res);
					}
	printf("%d\n",X-1);
}

Measured memory_bytes: 481792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    if(n == 2 && s[0] == s[1]){
        cout << "1 2" << endl;
        return 0;
    }
    rep(i, n - 2){
        if(s[i]==s[i+1]||s[i+1]==s[i+2]||s[i]==s[i+2]){
            cout << i + 1 << ' ' << i + 3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string s,t;
int n;

bool check(string str){
  for(int i=1;i<n-1;i++){
    if(s[i]=='o'){
      if(t[i]=='S')t+=t[i-1];
      else{
	if(t[i-1]=='S')t+='W';
	else t+='S';
      }
    }
    else{
      if(t[i]=='S'){
	if(t[i-1]=='S')t+='W';
	else t+='S';
      }
      else t+=t[i-1];
    }
  }
  bool ans=true;
  for(int i=0;i<=n;i++){
    if(t[i]=='S'){
      if(s[i]=='o'&&t[((i-1)+n)%n]!=t[(i+1)%n])ans=false;
      if(s[i]=='x'&&t[((i-1)+n)%n]==t[(i+1)%n])ans=false;
    }else{
      if(s[i]=='o'&&t[((i-1)+n)%n]==t[(i+1)%n])ans=false;
      if(s[i]=='x'&&t[((i-1)+n)%n]!=t[(i+1)%n])ans=false;
    }
  }
  if(ans)cout<<t<<endl;
  return ans;
}

int main(){
  cin>>n;
  cin>>s;
  t="SS";
  if(check(t))return 0;
  t="SW";
  if(check(t))return 0;
  t="WW";
  if(check(t))return 0;
  t="WS";
  if(check(t))return 0;
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void find(int a[],int x,int y){
    int i;
    int min=pow(2,31)-1;
    for(i=x;i<=y;i++){
        if(a[i]<min)min=a[i];
    }
    printf("%d\n",min);
}

int main(void){
    int i;
    
    int n;
    scanf("%d ",&n);
    
    int a[n];
    for(i=0;i<n;i++)a[i]=pow(2,31)-1;

    int q;
    scanf("%d\n",&q);
    
    int com,x,y;
    while(q--){
        scanf("%d %d %d\n",&com,&x,&y);
        switch(com){
            case 0:
                a[x]=y;
                break;
            case 1:
                find(a,x,y);
                break;
        }
    }

    return 0;
}



Measured memory_bytes: 2156
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
     Scanner sc=new Scanner(System.in);
     if(sc.hasNextInt()) 
      {
          int n=sc.nextInt();
          deployC obj=new deployC();
          obj.solve(n);
      }
        
  }
    
}
class deployC
{
    public void solve(int n)
    {
        int ans=0;
        for(int fir=1;fir<=Math.sqrt(n-1);fir++)
        {
            for(int sec=fir;sec*fir<=n-1;sec++)
            {
                ans++;
            }
        }
        if(ans!=0)
        {
        ans=ans*2;
        ans=ans-(int)Math.sqrt(n-1);
        System.out.println(ans);
        }
        else
            System.out.println(0);
    }
    
}


Measured memory_bytes: 27260
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=0;i<=b;i+=k) {
		if(i>=a) {
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define reep(i,n) for(ll i = n; i >-1; i--)
#define deb(variable) cout<<#variable<<"="<<variable<<endl
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999999;
const ll MOD=128;
const ll MAX_N=500010;
ll a,b,c,d,e,x,y,z,k,m,n,l,q,ans=0;
vl v,v1;
vp p;
string s;
ll solve(void){
    a=0;//vの位置
    b=0;//pの位置
    while(a<n){
      if(b>m-1)return ans;
        rep(i,p[b].second){
          if(a>n-1)return ans;
            if(v[a]<p[b].first)ans+=p[b].first-v[a];
            else return ans;
            a++;
        }
        b++;
    }
 
  return ans;
}
int main(){
    cin>>n>>m;
    rep(i,n){
     cin>>a;
     ans+=a;
     v.push_back(a);
    }
 
    rep(i,m){
        cin>>a>>b;
        p.emplace_back(b,a);
    }
 
    sort(v.begin(),v.end());
    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());
 
    cout<<solve()<<endl;
}

Measured memory_bytes: 3188
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/05/20 00:39:46
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int h,w,n; cin>>h>>w>>n;
  vector<pair<int,int>> XY(n);
  for (int i = 0; i < n; i++) {
    int x,y; cin>>x>>y; x--; y--;
    XY[i] = {x-y,y};
  }
  sort(XY.begin(), XY.end(), [](auto l, auto r){
    return l.second != r.second ? l.second<r.second : l.first < r.first;
  });

  int ans = h;
  int min_x = -1;
  int max_x = h;
  int i = 0;
  for (int y = 0; y < w; y++) {
    bool updmaxx = false;
    for (; i < n and max_x - min_x > 1 and XY[i].second == y; i++) {
      auto [x,y] = XY[i];
      if (x <= min_x) {
        continue;
      } else if (x == min_x+1) {
        min_x = x;
      } else if (x < max_x) {
        if (!updmaxx) {
          ans = min(ans, y + x);
          max_x = x;
          updmaxx = true;
        }
      } else if (max_x <= x) {
        if (!updmaxx) {
          max_x = x;
          updmaxx = true;
        }
        continue;
      }
    }
    if (max_x - min_x <= 1)
      break;
    if (!updmaxx)
      max_x = h;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4776
N, M = map(int, input().split())
gates = [list(map(int, input().split())) for _ in range(M)]
scope = [1, N]


class CountedAcID():
    def __init__(self, gates):
        self.gates = gates
        self.scope = [1, N]

    def run(self):
        self.__get_range()
        self.total = self.__return_num()


    def __get_range(self):
        for element in self.gates:
            self.scope[0] = self.__get_left(element[0], self.scope[0])
            self.scope[1] = self.__get_right(element[1], self.scope[1])

    def __get_left(self, element, left):
        if element > left:
            return element
        else:
            return left

    def __get_right(self, element, right):
        if element < right:
            return element
        else:
            return right

    def __return_num(self):
        if self.scope[1] > N:
            return N - self.scope[0] + 1

        else:
            return self.scope[1] - self.scope[0] + 1


c = CountedAcID(gates)
c.run()
num = c.total

if num < 0:
    print(0)
else:
    print(num)

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

int main()
{
	int N;
	int flag1 = 0;
	int flag2 = 0;
	cin >> N;
	int ue = N / 100;
	int shita = N % 100;
	if ((ue >= 1)&&(ue <= 12))
	{
		flag1 = 1;
	}

	if ((shita >= 1)&&(shita <= 12))
	{
		flag2 = 1;
	}

	if ((flag1 == 0)&&(flag2 == 0))
	{
		cout << "NA" << endl;
	}
	else if ((flag1 == 0)&&(flag2 == 1))
	{
		cout << "YYMM" << endl;
	}
	else if ((flag1 == 1)&&(flag2 == 0))
	{
		cout << "MMYY" << endl;
	}
	else if ((flag1 == 1)&&(flag2 == 1))
	{
		cout << "AMBIGUOUS" << endl;
	}
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

#define MAX_V 300
#define INF 1000000000000000
struct edge{int to, cost;};
int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
    priority_queue<Pii, vector<Pii>, greater<Pii>> que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(Pii(0, s));

    while(!que.empty()){
        Pii p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        REP(i, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(Pii(d[e.to], e.to));
            }
        }
    }
}

void add_edge(int from, int to, int cost){
    G[from].push_back(edge({to, cost}));
}


signed main(){

    int N;
    cin >> N;
    vector< pair<int, vector<int> > > A;
    int a;
    REP(i, N){
        REP(j, N){
            cin >> a;
            if(i < j){
                A.push_back(pair<int, vector<int> >(a, vector<int>({i, j})));
            }
        }
    }
    SORT(A);

    V = N;

    int ans = 0;
    REP(i, A.size()){
        int c = A[i].first;
        int s = A[i].second[0];
        int t = A[i].second[1];

        dijkstra(s);
        if(d[t] < c){
            cout << -1;
            return 0;
        }else if(d[t] > c){
            add_edge(s, t, c);
            add_edge(t, s, c);
            ans += c;
        }
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool solve(vector<string>& board, int p, vector<int>& row, vector<int>& col, int ch){
    const int N = board.size();
    if(p == N*N){
        bool ok = true;
        for(int i=0;i<N;i++) if(row[i] != 3 || col[i] != 3) ok = false;
        return ok;
    }
    int x = p/N, y = p%N;
    if(y != N-1 || row[x] == 3) if(solve(board, p+1, row, col, ch)) return true;
    if(y+1 < N && board[x][y] == '.' && board[x][y+1] == '.'){
        board[x][y] = board[x][y+1] = 'a'+ch;
        row[x]++;
        col[y]++;
        col[y+1]++;
        if(row[x] <= 3 && col[y] <= 3 && col[y+1] <= 3) if(solve(board, p+2, row, col, ch+1)) return true;
        board[x][y] = board[x][y+1] = '.';
        row[x]--;
        col[y]--;
        col[y+1]--;
    }
    if(x+1 < N && board[x][y] == '.' && board[x+1][y] == '.'){
        board[x][y] = board[x+1][y] = 'a' + ch;
        row[x]++;
        row[x+1]++;
        col[y]++;
        if(row[x] <= 3 && row[x+1] <= 3 && col[y] <= 3) if(solve(board, p+1, row, col, ch+1)) return true;
        board[x][y] = board[x+1][y] = '.';
        row[x]--;
        row[x+1]--;
        col[y]--;
    }
    return false;
}

vector<string> search(int N){
    vector<string> res(N, string(N, '.'));
    vector<int> row(N, 0), col(N, 0);
    solve(res, 0, row, col, 0);
    return res;
}

int main(){
    int N; cin >> N;
    if(N < 3){
        cout << -1 << endl;
        return 0;
    }
    if(N == 3){
        cout << "aab" << endl;
        cout << "b.b" << endl;
        cout << "baa" << endl;
        return 0;
    }
    vector<string> vs(N, string(N, '.'));
    int idx = 0;
    if(N%4==1){
        string a5[] = {
            "..abc",
            "..abc",
            "ddeef",
            "ggh.f",
            "iihjj"
        };
        for(int i=0;i<5;i++){
            for(int j=0;j<5;j++){
                vs[i][j] = a5[i][j];
            }
        }
        idx = 5;
    }
    if(N%4==2){
        string a6[] = {
            "...abc",
            "...abc",
            "ddee.f",
            "..gghf",
            "iij.h.",
            "kkj.ll"
        };
        for(int i=0;i<6;i++){
            for(int j=0;j<6;j++){
                vs[i][j] = a6[i][j];
            }
        }
        idx = 6;
    }
    if(N%4==3){
        string a7[] = {
            "....abc",
            "....abc",
            "....def",
            "....def",
            "gghh..i",
            "jjkk..i",
            "llmmnn."
        };
        for(int i=0;i<7;i++){
            for(int j=0;j<7;j++){
                vs[i][j] = a7[i][j];
            }
        }
        idx = 7;
    }
    while(idx < N){
        string a4[] = {
            "aabc",
            "ddbc",
            "efgg",
            "efhh"
        };
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                vs[idx+i][idx+j] = a4[i][j];
            }
        }
        idx += 4;
    }
    for(auto& s : vs) cout << s << endl;
}

Measured memory_bytes: 2304
//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <algorithm>
#define repe(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define mst(a, b)   memset((a), (b), sizeof(a))
#define gc() gutchar()
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pr;
typedef long long ll;
const double eps = 1e-5;
const int inf = 0x3f3f3f3f;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
const ll mod = 1e9+7;
const int N = 2e5+5;

ll dp[10][10], res;

int get(int x)
{
	while (x / 10)	x /= 10;
	return x;
}

int main()
{
	int n; cin >> n;
	repe(i, 1, n){
		dp[get(i)][i%10]++;
	}
	repe(i, 1, 9){
		repe(j, 1, 9){
			res += dp[i][j] * dp[j][i];
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 888
s=input()
s1='01'*(len(s)//2)+'0'*(len(s)%2)
s2='10'*(len(s)//2)+'1'*(len(s)%2)
ans1=0
ans2=0
for i,j,k in zip(s,s1,s2):
    if i!=j:ans1+=1
    if i!=k:ans2+=1
print(min(ans1,ans2))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define tr(container, it) \
for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define all(c) c.begin(), c.end()
#define sum(v) accumulate(all(v),0LL)
#define rep(i,s,n) for (int i=s; i<n; i++)
#define lli long long int
#define MOD 1000000007
#define pii pair <int,int> 
#define pll pair <lli, lli>
#define endl '\n'
#define debugv(c) for(auto hnvx : c) cout << hnvx <<" "; cout << endl;
#define debug(c) cout<<#c<<" := "<<c<<endl;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int k;
    cin>>k;
    int h[n];
    rep(i,0,n) cin>>h[i];
    int ans[n];
    ans[0]=0;
    //ans[1]=abs(h[1]-h[0]);
    //int temp;
    rep(i,1,n)
    {
        ans[i]=INT_MAX;
        rep(j,1,min(k+1,i+1))
        ans[i]=min(abs(h[i]-h[i-j])+ans[i-j],ans[i]);
    }
    //rep(i,0,n) cout<<ans[i]<<" "; cout<<endl;
    cout<<ans[n-1];
}


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

using namespace std;

// DP時の道具
template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		// aよりbの方が小さかったら、aの値をbの値に置き換える
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		// aよりbの方が大きかったら、aの値をbの値に置き換える
		a = b;
		return true;
	}
	return false;
}


int main() {
	int N, W;
	cin >> N >> W;
	vector<long long> w(N);
	vector<long long> v(N);
	for (int i = 0; i < N; i++) {
		cin >> w.at(i) >> v.at(i);
	}

	// 初期化
	vector<vector<long long>> dp(N+1, vector<long long>(W+1, 0));

	// 更新
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W; j++) {
			// i番目の品物を選ぶ
			if (j - w.at(i) >= 0) {
				chmax(dp.at(i+1).at(j), dp.at(i).at(j - w.at(i)) + v.at(i));
			}

			// i番目の品物を選ばない
			chmax(dp.at(i+1).at(j), dp.at(i).at(j));
		}
	}

	// 出力
	cout << dp.at(N).at(W) << endl;
}


Measured memory_bytes: 80256
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

#define f first
#define s second
pair<int,int> fa[100001];

int find(int x)
{
	if(fa[x].f==x&&fa[x].s==0) return x;
	int t=find(fa[x].f);
	fa[x]=make_pair(t,fa[fa[x].f].s+fa[x].s);
	//保证f[x]的父亲是其老祖宗 
	fa[x].f=t;
	return t;
}

int main()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;++i) fa[i]=make_pair(i,0);
	for(int i=1;i<=m;++i){
		int l,r,d;
		cin>>l>>r>>d;
		int x=find(l),y=find(r);
		if(x!=y)
		{
			if(x>y) fa[x]=make_pair(y,-(fa[l].s-fa[r].s+d));
			else fa[y]=make_pair(x,fa[l].s-fa[r].s+d);
		}
		else
		{
			if(fa[r].s-fa[l].s!=d)
			{
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <math.h>

int main(void) {
  long long a, b, c, k, i;
  long long n_a, n_b, n_c;
  
  scanf("%lld %lld %lld %lld", &a, &b, &c, &k);
  
  if (a - b > 1000000000000000000 || a - b < -1000000000000000000) {
    printf("Unfair\n");
  } else {
    printf("%lld\n", (a - b) * (long long) pow(-1.0, k % 2));
  }

  return 0;
}

Measured memory_bytes: 128
n = int(input())
l = list(map(int,input().split()))
ans = []
plus = sum(l)
minus = 0
for j in range(1,n,2):  
        
    minus += l[(j)%n]
ans.append(plus-2*minus)
for i in range(1,n):
    ans.append(2*l[i-1]-ans[i-1])

print(*ans)


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
ll i, j;
int main(){
    scanf("%lld",&N);
    fornum(i,0,N+5){
        if(i*108/100==N){
            printf("%lld", i);
            return 0;
        }

    }
    printf(":(");

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[n-1]-a[0]);
    }
}


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

using namespace std;

typedef long long ll;

const int N = 1e6 + 10;

int n;
int a[N];

bool check(int m) {
	int b[N];
	for (int i = 1; i <= 2 * n - 1; i++) b[i] = (a[i] >= m);

	int l = 0, r = 0;

	for (int i = n; i >= 1; i--, l++) {
		if (i != 1) if (b[i] == b[i - 1]) break;
	}
	for (int i = n; i <= 2 * n - 1; i++, r++) {
		if (i != 2 * n - 1) if (b[i] == b[i + 1]) break;
	}

	int k = min(l, r);
	if (k < n) return b[n] ^ (k % 2);
	return b[1];
}

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	cin >> n;
	for (int i = 1; i <= 2 * n - 1; i++) scanf("%d", &a[i]);

	int l = 1, r = 2 * n - 1;
	while (l != r) {
		int m = (l + r + 1) / 2;
		if (check(m)) l = m;
		else r = m - 1;
	}
	cout << l << endl;

	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <vector>

int main(int argc, const char** argv)
{
  	int tests = 0, ac = 0, wa = 0, tle = 0, re = 0;
  	std::cin >> tests;

  	std::vector< std::string > results( tests );
  	for ( int in = 0; in < tests; in++ ) std::cin >> results.at( in );
  
  	for ( int in = 0; in < tests; in++ )
    {
    	if ( results[ in ] == "AC" ) ac++;
      	if ( results[ in ] == "WA" ) wa++;
      	if ( results[ in ] == "TLE" ) tle++;
      	if ( results[ in ] == "RE" ) re++;
    }
  
  	std::cout << "AC x " << ac << std::endl;
  	std::cout << "WA x " << wa << std::endl;
  	std::cout << "TLE x " << tle << std::endl;
  	std::cout << "RE x " << re << std::endl;
  	return 0;
}

Measured memory_bytes: 6364
#include <bits/stdc++.h>
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  string s;
  cin >> s;

  int n = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'o') n++;
  }

  pr(700 + n * 100);

  return 0;
}


Measured memory_bytes: 256