akhauriyash/Code-Regression huggingface dataset:
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
struct UnionFind{
    vector<int> parent;
    vector<int> s;
 
    UnionFind(int n){
        parent.resize(n);
        s.resize(n, 1);
        for(int i = 0; i < n; i++) parent[i] = i;
    }
 
    int root(int node){
        if(parent[node] == node){
            return node;
        } else {
            return parent[node] = root(parent[node]);
        }
    }
 
    void unite(int x, int y){
        int rootx = root(x);
        int rooty = root(y);
        if(rootx == rooty) return;
        if(s[rootx] < s[rooty]) swap(rootx, rooty);
        s[rootx] += s[rooty];
        parent[rooty] = rootx;
    }
 
    bool isSame(int x, int y){
        return root(x) == root(y);
    }
 
    int size(int x){
        return s[root(x)];
    }
};
int main(void){
    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> e(m);

    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        e[i] = {a, b};
    }
    int ans = 0;
    rep(i, m){
        UnionFind uf(n);
        rep(j, m){
            if(i == j) continue;
            uf.unite(e[j].first, e[j].second);
        }
        if(uf.size(0) != n) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] aegs){
    	Scanner sc = new Scanner(System.in);
      	String s = sc.next();
      	int count = 0;
      	int i =	0;
      	int j = s.length() - 1;
      	for(;i<j;){
        	if(s.charAt(i) != s.charAt(j))
            	count++;
            i++;
            j--;
        }
        System.out.println(count);
      	sc.close();
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,n,k;
    t = 1;
    for(int i=0;i<t;i++)
    {
        cin>>n>>k;
        int arr[n];
        for(int j=0;j<n;j++)
        {
            cin>>arr[j];
        } 
        sort(arr,arr+n);
        int sum = 0;
        for(int i=0;i<k;i++)
        {
            sum+=arr[i];
        }
        cout<<sum;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
ll a[123456];
int main()
{
    ll n,k;
    cin>> n >>k;
    for (int i=0;i<n;i++)
    {
        cin >>a[i];
    }
    ll p=0;
    ll res=0;
    while(p<50)
    {
        ll cnt=0;
        for (int i=0;i<n;i++)
        {
            cnt+=!(a[i]&(1LL<<p));
        }
        if (cnt>n/2) res|=(1LL<<p);
        p++;
    }
    while(res>k)
    {
        if (((1LL<<p)&k)<((1LL<<p)&res)) res&=~(1LL<<p);
        p--;
    }
    //cout << res << endl;
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        ans+=res^a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

bool check(int m,int k)
{
	int blood[101];
	int eats[101]={0};
	for(int i=0;i<k;i++)
			scanf("%d",&blood[i]);

	for(int i=0;i<m;i++)
	{
		for(int j=0;j<k;j++)
		{
			int temp;
			scanf("%d",&temp);
			eats[j]+=temp;
		}
	}

	for(int i=0;i<k;i++)
		if(eats[i]>blood[i])
			return false;

		return true;
}

int main()
{
	int member,kind;
	while(true)
	{
		scanf("%d %d",&member,&kind);
		if(member==0 && kind==0)
			break;
		check(member,kind) ? printf("Yes\n") : printf("No\n");
	}
}

Measured memory_bytes: 732
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> inline void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> inline void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int main() {
    ll n; cin >> n;
    ll dp[n+1];
    FOR(i, 1, n+1) {
        dp[i] = 0;
    }

    FOR(i, 1, n+1) {
        ll temp = i;
        ll counter = 1;
        while(temp<=n) {
            dp[temp]++;
            counter++;
            temp = i * counter;
        }
    }

    ll ans = 0;
    FOR(i, 1, n+1) ans += dp[i] * i;
    print(ans);
    return 0;
}


Measured memory_bytes: 81712
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < 10000; ++i) {
    int aa = i * 8 / 100;
    int bb = i * 10 / 100;
    if (a == aa && b == bb){
		 cout << i << endl;
     	return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def kawaisou(a, b, c):
    if a == b and a != c:
        return True
    if a == c and a != b:
        return True
    if b == c and a != b:
        return True
    return False

def main():
    a, b, c = rli()
    if kawaisou(a, b, c):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

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")
}

fn main() {
    let n: usize = read();
    let mut a: Vec<u32> = (0..n).map(|_| read()).collect();

    a.sort();
    let yes = a[..].windows(2).all(|w| w[0] != w[1]);

    println!("{}", if yes { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define ff first
#define ss second
#define dd double
#define mod 1000000007

template<class K,class other=null_type,class cmp=less<K>> using ordered_set=tree<K,other,
cmp, rb_tree_tag, tree_order_statistics_node_update>;

inline ll md(ll x){
    return x<mod?x:x%mod;
}

ll power(ll x, ll y){
    if(y==0){
        return 1;
    }
    ll x_=power(x,y/2);
    if(y & 1){
        return md(md(x_*x_)*md(x));
    }
    else{
        return md(x_*x_);
    }
}

ll mod_inverse(ll x){
    return power(x,mod-2);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,k;
    cin>>n>>m>>k;
    ll arr1[n+1];
    ll arr2[m];
    FOR(i,1,n+1){
        cin>>arr1[i];
    }
    REP(i,m){
        cin>>arr2[i];
    }
    arr1[0]=0;
    FOR(i,1,n+1){
        arr1[i]+=arr1[i-1];
    }
    FOR(i,1,m){
        arr2[i]+=arr2[i-1];
    }
    ll ans=0;
    for(ll i=0;i<=n;i++){
        if(arr1[i]>k){
            break;
        }
        ll temp=k-arr1[i];
        auto pos=upper_bound(arr2,arr2+m,temp);
        pos--;
        ans=max(ans,i+(pos-arr2)+1);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6776
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n, m , x;
    cin >> n >> m >> x;
    vector<int> c(n), rikai(m, 0);
    vector<vector<int>> a(n, vector<int>(m));

    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    int ans = 1001001001;
    for(int bit = 0; bit < (1 << n); bit++){
        int tmp = 0;
        bool ok = false;
        
        for(int i = 0; i < m; i++) rikai[i] = 0;

        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                tmp += c[i];
                for(int j =0 ; j < m; j++){
                    rikai[j] += a[i][j];
                }
            }
        }
        for(int j = 0; j < m; j++){
            if(rikai[j] < x){
                ok = true;
                break;
            }
        }
        if(ok) continue;
        ans = min(ans, tmp);
    }
    if(ans == 1001001001) cout << -1 << endl;
    else cout << ans << endl;
    
    return 0;
}

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

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;

template<typename T>
void chmax(T &a, T &b){
	a = max(a, b);
}

template<typename T>
void chmin(T &a, T &b){
	a = min(a, b);
}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int n;

int solve(string ans, string s){
	REP(i, n){
		if((ans[i] == 'S' && s[i] == 'o') || (ans[i] == 'W' && s[i] == 'x')){
			if(ans[(i-1+n)%n] == '.')
				ans[(i-1+n)%n] = ans[(i+1)%n];
			else
				ans[(i+1)%n] = ans[(i-1+n)%n];
		}else{
			if(ans[(i-1+n)%n] == '.'){
				if(ans[(i+1)%n] == 'W')
					ans[(i-1+n)%n] = 'S';
				else
					ans[(i-1+n)%n] = 'W';
			}else{
				if(ans[(i-1+n)%n] == 'W')
					ans[(i+1)%n] = 'S';
				else
					ans[(i+1)%n] = 'W';
			}
		}
	}
	REP(i, n){
		if((s[i] == 'o' && ans[i] == 'S') || (s[i] == 'x' && ans[i] == 'W')){
			if(ans[(i-1+n)%n] != ans[(i+1)%n])
				return 0;
		}else{
			if(ans[(i-1+n)%n] == ans[(i+1)%n])
				return 0;
		}
	}
	cout << ans << endl;
	return 1;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> n;
	cin >> s;
	string ans(n, '.');
	ans[0] = 'S'; ans[1] = 'S';
	if(solve(ans, s)) return 0;
	ans = string(n, '.');
	ans[0] = 'S'; ans[1] = 'W';
	if(solve(ans, s)) return 0;
	ans = string(n, '.');
	ans[0] = 'W'; ans[1] = 'S';
	if(solve(ans, s)) return 0;
	ans = string(n, '.');
	ans[0] = 'W'; ans[1] = 'W';
	if(solve(ans, s)) return 0;
	cout << -1 << endl;
	return 0;
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			string[] str = Console.ReadLine().Split(' ');
			int[] p = new int[N];
			for (int i = 0; i < N; i++) p[i] = int.Parse(str[i]);
			int count = 0;
			for (int i = 0; i < N; i++)
			{
				if (i + 1 != p[i]) count++;
			}
			if (count == 0 || count == 2) Console.WriteLine("YES");
			else Console.WriteLine("NO");
			
		}
	}
}


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

const int INF = 1001001001;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> key;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        int s = 0;
        for(int j = 0; j < b; j++){
            int c;
            cin >> c;
            --c;
            s |= 1<<c;
        }
        key.emplace_back(s, a);
    }

    vector<int> dp(1<<n, INF);
    dp[0] = 0;
    for(int s = 0; s < (1<<n); s++){
        for(int i = 0; i < m;i++){
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if(ans == INF){
        ans = -1;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main() {
    int n;
    cin >> n;
    vector<int> a(n+1), b(n+1), c(n+1);
    rep(i,n) cin >> a[i] >> b[i] >> c[i];
    vector<vector<int>> dp(n+1, vector<int>(3));
    rep(i,n) {
        dp[i+1][0] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
        dp[i+1][1] = max(dp[i][0] + b[i], dp[i][2] + b[i]);
        dp[i+1][2] = max(dp[i][1] + c[i], dp[i][0] + c[i]);
    }
    int ans = max(dp[n][0], max(dp[n][1], dp[n][2]));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9860
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stdio.h>
#include <functional>
#include <chrono>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init,ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

template<class T>
T maxVec(vector<T> &v) {
	T ans = -INF;
	rep(i,0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}


template <class C>
void print(const C& c, std::ostream& os = std::cout)
{
	std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, ", "));
	os << std::endl;
}

ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}

bool sortreverse(ll a, ll b) {
	return a > b;
}

bool kansu(pll a, pll b) {
	return a.first < b.first;
}

ll kiriage(ll a, ll b) {
	if (a % b == 0)return a / b;
	return a / b + 1;
}


int main() {
	ll n, d,a;
	cin >> n >> d >> a;
	vector<pll> ls(n);
	rep(i, 0, n) {
		cin >> ls[i].first >> ls[i].second;
	}
	sort(ls.begin(), ls.end(), kansu);
	vl ruiseki(2*n+5);
	ll ans = 0;
	rep(i, 0, n) {
		ll x = ls[i].first, h = ls[i].second;
		ruiseki[i + 1] += ruiseki[i];
		if (h - ruiseki[i + 1] <= 0)continue;
		ll heru = kiriage((h - ruiseki[i + 1]), a);
		ans += heru;
		ll v = heru * a;
		ruiseki[i + 1] += heru * a;
		ll s = i, t = n;
		ll mid;
		while (t - s > 1) {
			mid = (s + t) / 2;
			if (ls[mid].first > x + 2 * d) {
				t = mid;
			}
			else {
				s = mid;
			}
		}
		ruiseki[t + 1] -= v;
		//print(ruiseki);
	}
	//print(ruiseki);
	printf("%lld\n", ans);
}

Measured memory_bytes: 6528
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<iostream>
#include<bitset>
#include<functional>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<random>
#include<ctime>
#include<complex>
using namespace std;
typedef long long LL;
mt19937 gene(233);
typedef complex<double> Complex;
#define fi first
#define se second
#define ins insert
#define pb push_back
inline char GET_CHAR(){
	const int maxn = 131072;
	static char buf[maxn],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++;
}
inline int getInt() {
	int res(0);
	char c = getchar();
	while(c < '0') c = getchar();
	while(c >= '0') {
		res = res * 10 + (c - '0');
		c = getchar();
	}
	return res;
}

inline int fastpo(int x, int n, int mod) {
	int res(1);
	while(n) {
		if(n & 1) {
			res = res * (LL)x % mod;
		}
		x = x * (LL) x % mod;
		n /= 2;
	}
	return res;
}

inline string itoa(int x, int width = 0) {
  string res;
  if(x == 0) res.push_back('0');
  while(x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}

const int N = 111;
const int LOG = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[N][N];
char a[N][N];
int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	memset(dp, 0x3f, sizeof(dp));
	dp[0][1] = 0; dp[1][0] = 0;
	for(int i = 1; i <= h; i++) {
		scanf("%s", a[i] + 1);
		for(int j = 1; j <= w; j++) {
			dp[i][j] = min(dp[i - 1][j] + (a[i - 1][j] != '#' && a[i][j] == '#'), dp[i][j - 1] + (a[i][j - 1] != '#' && a[i][j] == '#'));
		}
	}
	cout << dp[h][w] << endl;
}




Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pf push_front
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    ll a,k,mn = 1e9; cin>>a>>k;
    vec<ll> m(a);
    ll s=0;
    for(int q=0; q<a; q++){
        m[q] = q+k;
        s+=m[q];
        if(abs(m[q])<abs(mn)) mn = m[q];
    }
    cout<<s-mn;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

vll ans;
void f(string num){
  if(stoll(num)>3234566667) return;
  ans.push_back(stoll(num));

  char b = num[num.size()-1];
  if(b!='0') {
    char x = b - 1;
    f(num+x);
  }
  char x = b;
  f(num+x);
  if(b!='9'){
    char x = b + 1;
    f(num+x);
  }
}
int main(int argc, char const *argv[]) {
  for(ll i=1;i<=9;i++) f(to_string(i));
  sort(all(ans));
  ll n;std::cin >> n;
  //re(i, 20) std::cout << ans[i] << '\n';
  std::cout << ans[n-1] << '\n';
  return 0;
}


Measured memory_bytes: 1776
def coord_compress(A):
    B = {a: i for i, a in enumerate(sorted(set(A)), 1)}
    return [B[a] for a in A]

N = int(input())
A = [int(input()) for _ in range(N)]
A = coord_compress(A)
A_odd, A_even = A[::2], A[1::2]
ans = 0
for a in A_odd:
    if a % 2 == 0: ans += 1
print(ans)

Measured memory_bytes: 23196
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  string S; cin >>S;
  int N = S.size();
  bool n = false, w = false, s = false, e = false;
  rep(i, N){
    char c = S[i];
    if (c == 'N') n = true;    
    if (c == 'W') w = true;
    if (c == 'S') s = true;
    if (c == 'E') e = true;    
  }
  if (n == s && w == e){
    cout <<"Yes" <<endl;
  }else{
    cout <<"No" <<endl;
  }
}


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


using namespace std;

int main(){
  int red , green , blue;
  int k ;

  cin>>red>>green>>blue;

  cin>>k;
  int i = 0;

  while(red >= green){
     green*=2;
     i++;
  }
  while(green>=blue){
    blue*=2;
    i++;
  }
  if(i>k) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
   int n,m;
   cin>>n>>m;
   map<long long,long long> mp;
   for(int i=0;i<n;i++){
      int a,b;
      cin>>a>>b;
      mp[a]+=b;
   }
   long long ans=0;
   for(auto i=mp.begin();i!=mp.end();i++){
      if(m<=i->second){
         ans+=i->first*m;
         m=0;
         break;
      }
      else {
         ans+=i->first*i->second;
         m-=i->second;
      }
   }
   cout<<ans<<endl;
   
}

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

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            Console.WriteLine(x>=1200?"ARC":"ABC");
        }
    }
}


Measured memory_bytes: 13140
#include"bits/stdc++.h"

using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	if (A + B + 1 >= C) {
		cout << B + C;
	}
	else {
		cout << B + (A + B + 1);
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
f = [int(input().replace(' ',''),2) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]
prof = - 10 ** 10
for i in range(1,1 <<10):
	prof1 = 0
	for j,time in enumerate(f):
		prof1 += p[j][bin(i & time).count('1')]
	prof = max(prof,prof1)
print(prof)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


int N, M;
int s[100001];

int main() {
	cin >> N >> M;
	s[0] = 0;
	for (int i = 1; i < N; i++) {
		cin >> s[i];
		s[i] += s[i - 1];
	}

	int tmp = 0;
	int ans = 0;
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;

		ans += abs(s[tmp + a] - s[tmp]);
		
		ans %= 100000;

		tmp += a;
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 3484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a,b,q;
  cin >> a >> b >> q;
  vector<ll> s(a+2),t(b+2),x(q);
  s[0]=t[0]=-1e18;
  s[a+1]=t[b+1]=1e18;
  for(int i=1;i<=a;i++){
    cin >> s[i];
  }
  for(int i=1;i<=b;i++){
    cin >> t[i];
  }
  for(int i=0;i<q;i++){
    cin >> x[i];
    int u=distance(s.begin(),upper_bound(s.begin(),s.end(),x[i]));
    int v=distance(t.begin(),upper_bound(t.begin(),t.end(),x[i]));
    ll res=1e18;
    for(int j=u-1;j<=u;j++){
      for(int k=v-1;k<=v;k++){
        ll d1=abs(s[j]-x[i])+abs(t[k]-s[j]);
        ll d2=abs(t[k]-x[i])+abs(s[j]-t[k]);
        res=min({res,d1,d2});
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3712
#define NDEBUG
#include<deque>
#include<functional>
#include<utility>
#include<cstddef>
#include<cassert>

template<class T,class Container=std::deque<std::pair<T,std::size_t>>, class Compare = std::less<T>>
class SlidingMinimum{
public:
	using container_type = Container;
	using value_compare = Compare;
	using value_type = T;
	using size_type = typename container_type::size_type;
	using const_reference = const T&;
private:
	container_type c;
	value_compare comp;
	size_type s;
public:
	SlidingMinimum(const value_compare &x = value_compare()) :comp(x),s(1){}
	bool empty()const{
		return c.empty();
	}
	const_reference top()const{
		assert(!empty());
		return c.front().first;
	}
	size_type top_index()const{
		assert(!empty());
		return c.front().second - s;
	}
	void push(const value_type &x){
		size_type cnt = 1;
		while (!empty() && comp(x, c.back().first)){
			cnt += c.back().second;
			c.pop_back();
		}
		c.push_back(std::pair<value_type, size_type>(x, cnt));
	}
	void push(value_type &&x){
		size_type cnt = 1;
		while (!empty() && comp(x, c.back().first)){
			cnt += c.back().second;
			c.pop_back();
		}
		c.push_back(std::pair<value_type, size_type>(std::move(x), s));
	}
	void pop(){
		assert(!empty());
		if (c.front().second == s){
			c.pop_front();
			s = 0;
		}
		++s;
	}
	void clear(){
		c.clear();
		s = 1;
	}
};





#include<cstdio>
#include<utility>

int main(){
	using uint = unsigned int;
	uint n, l;
	scanf("%u%u", &n, &l);
	SlidingMinimum<uint> S;
	uint a;
	n -= l;
	while (l--){
		scanf("%u", &a);
		S.push(a);
	}
	printf("%u", S.top());
	while (n--){
		S.pop();
		scanf("%u", &a);
		S.push(a);
		printf(" %u", S.top());
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 3244
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int INF = 100000000;

int main(){
	while(1){
		int n, k;
		cin >> n >> k;
		if(!(n+k))break;

		vector<int> s(k);
		rep(i, k){
			cin >> s[i];
		}
		rep(i, n){
			rep(j, k){
				int b;
				cin >> b;
				s[j] -= b;
			}
		}

		sort(all(s));
		cout << (s[0] >= 0? "Yes":"No") << endl;
	}

	return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  
  int k=0;
  for(int i=0;i<n;i++)
    k+=a.at(i);
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  if(a.at(m-1)*4*m<k)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> L(n);
    for (int i = 0; i < n; i++) {
        cin >> L[i];
    }

    int ans = 0;
    sort(L.begin(), L.end(), greater<int>());
    for (auto itr1 = L.begin(); itr1 != L.end(); ++itr1) {
        int a = *itr1;
        for (auto itr2 = next(itr1); itr2 != L.end(); ++itr2) {
            int b = *itr2, key = a - b;
            auto itr3 = upper_bound(L.rbegin(), L.rend(), key);

            ans += max((int)(n - distance(L.begin(), itr2) - distance(L.rbegin(), itr3) - 1), 0);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
row=m
number=[]
judgment=[]
for p in range(row):
    a,b=input().split()
    number.append(int(a))
    judgment.append(b)

penalist = [0]*n
aclist = [0]*n
anscount=0
penacount=0

for i in range(0,m):
    if judgment[i] == 'WA':
        penalist[number[i]-1] += 1
    else:
        if aclist[number[i]-1] >= 1:
            pass
        else:
            aclist[number[i]-1] += 1
            anscount += 1
            penacount += penalist[number[i]-1]

print(anscount,penacount)

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

int main(){
	std::vector<int>v(10);
	for(int i=0;i<10;i++){
		int a;std::cin>>a;
		v[i]=a;
	}
	std::sort(v.begin(),v.end());
	std::cout<<v[9]<<std::endl;
	std::cout<<v[8]<<std::endl;
	std::cout<<v[7]<<std::endl;
	return 0;
}

Measured memory_bytes: 1208
#Weather Prediction 141
#一日ごとにSunny、Cloudy、Rainy
#Sは Sunny, Cloudy, Rainy のいずれかである

S = input('')
print()

if S =="Sunny":
    print('Cloudy')
elif S =="Cloudy":
    print('Rainy')
elif S =="Rainy":
    print('Sunny')

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

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    ll l, r; cin >> l >> r;
    if(r-l >= 2018){   //区間内に必ず0(mod2019)がある
        cout << 0 << '\n';
    }
    else{
        ll mini = 1e18;
        for(ll i = l; i < r; i++){
            for(ll j = l; j <= r; j++){
                if(i == j) continue;
                chmin(mini, ((i%2019)*(j%2019))%2019);
            }
        }
        cout << mini << '\n';
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int sz = 2e5+5;
ll int arr[sz]={0},arr1[sz]={0};
//ll int arr[100][100]= {0};
int prime[10005]= {0};
vector <ll int> vec,vec1,vec2;
//vector <pair <int,int>> vec;
set<ll int>st;

int main()
{
    double n;
    cin>>n;

    int k = ceil(n/1000);

    cout<<k*1000-n<<endl;
}


Measured memory_bytes: 3776
#!/usr/bin/env python3


def solv(n, dams):
    m = (sum(dams[::2]) - sum(dams[1::2])) // 2
    ans = [m*2]
    for i in range(n-1):
        m = dams[i] - m
        ans.append(m*2)
    return ans


if __name__ == '__main__':

    n = int(input())
    dams = [int(a) for a in input().split()]

    ans = solv(n, dams)

    print(' '.join([str(a) for a in ans]))


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	int N,M,a,b; cin>>N>>M;
  ll ans=0;
  vector<P> p(N);
  for(int i=0;i<N;i++) {
    cin>>a>>b;
    p[i]=make_pair(a,b);
  }
  sort(p.begin(),p.end());
  
  for(int i=0;i<N;i++){
  	if(M>p[i].second){
    	ans+=p[i].second*p[i].first;
      M-=p[i].second;
    }else{
    	ans+=M*p[i].first;
      M=0;
    }
  	if(M==0) break;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cins(s);
    string t = "2019/04/30";
    if(s<=t) cout << "Heisei" << nn;
    else
        cout << "TBD" << nn;
    return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

for i in range(N+1):
    for j in range(N+1-i):
        k = int((Y - (i*10000 + j*5000))/1000)
        if k == N - (i + j):
            print("{} {} {}".format(i, j, k))
            exit()
print("-1 -1 -1")


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-

import math
from fractions import gcd

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  A, B = readInts()
  g = gcd(A, B)

  ds = set()
  for n in range(1, math.floor(math.sqrt(g)) + 1):
    if g % n == 0:
      ds.add(n)
      ds.add(g // n)

  ds = sorted(ds)
  c = 0
  bs = [True for _ in range(len(ds))]
  for (i, n) in enumerate(ds):
    if n == 1:
      c += 1
      continue
    if bs[i]:
      c += 1
      for j in range(i+1, len(ds)):
        if ds[j] % n == 0:
          bs[j] = False
  print(c)

if __name__ == "__main__":
  main()


Measured memory_bytes: 5872
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
    unsigned long long N,A,B,x,y,z,r;
    cin>>N>>A>>B;
    if(N>=A+B){
        x=N/(A+B);
        y=N-x*(A+B);
        r=min(y,A);
        z=x*A+r;
        cout<<z<<endl;
    }else if(N>=A){
        cout<<A<<endl;
    }else{
        cout<<N<<endl;
    }
    
}

Measured memory_bytes: 256
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
int main()
{
	sync;
	string s;	
	cin>>s;
	ll n=s.length(),ans=0,cnt=0;

	for(ll i=0;i<n;i++)
	{
		if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')
		cnt++;
		else
		cnt=0;
		ans=max(ans,cnt);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
const int MaxN=500,MaxC=30;
int C[MaxC+5][MaxC+5];
int t[3][MaxN+5];
int N,c;
int ans=1e9;
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d %d",&N,&c);
	for(int i=1;i<=c;i++)
		for(int j=1;j<=c;j++)
			scanf("%d",&C[i][j]);
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++) {
			int x;
			scanf("%d",&x);
			for(int k=1;k<=c;k++)
				t[(i+j)%3][k]+=C[x][k];
		}
	for(int i=1;i<=c;i++)
		for(int j=1;j<=c;j++) {
			if(j==i)continue;
			for(int k=1;k<=c;k++) {
				if(k==j||k==i) continue;
				ans=min(ans,t[0][i]+t[1][j]+t[2][k]);
			}
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

H, W = list(map(int, input().split()))
A = np.array([list(input()) for _ in range(H)])

counts = np.zeros((H, W))
counts[A == '.'] = np.inf

for h in range(1, H):
    counts[h, :] = np.minimum(counts[h, :], counts[h - 1, :] + 1)
    counts[-1 - h, :] = np.minimum(counts[-1 - h, :], counts[-h, :] + 1)
for w in range(1, W):
    counts[:, w] = np.minimum(counts[:, w], counts[:, w - 1] + 1)
    counts[:, -1 - w] = np.minimum(counts[:, -1 - w], counts[:, -w] + 1)

print(int(np.max(counts)))


Measured memory_bytes: 33500
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
int main(){
    float a, b;
    cin >> a >> b;
    if(fmod(a+b, 2) >= 0.5) cout << int(a+b)/2+1 << endl;
    else cout << int(a+b)/2 << endl;
    return 0;
}

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

int a[210];

int main(){
    int N,i;
    cin >> N;
    for(i = 0; i < N; i++)
        cin >> a[i];

    int ans = 0;
    
    while(1){
        bool odd = false;
        for(i = 0; i < N; i++){
            if(a[i]%2 == 1)
                odd = true;
        }
        if(odd == true)
            break;
        ans++;
        for(i = 0; i < N; i++){
            a[i] /= 2;
        }
    }

    cout << ans << endl;

    return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int N=1e6+20;
const int M=30;

struct Union_find{
	Union_find(int n){par.resize(n);for(int i=0;i<n;i++) par[i]=i;}
	int find(int x){return (par[x]==x)?x:par[x]=find(par[x]);}
	void unite(int a,int b){a=find(a),b=find(b);par[a]=b;}
	bool same(int a,int b){return find(a)==find(b);}
	vector<int> par;
};
int main()
{
	int n,k,l;
	cin>>n>>k>>l;
	Union_find uf1(n);
	for(int i=0;i<k;i++)
	{
		int u,v;
		cin>>u>>v;
		uf1.unite(u-1,v-1);//vector par[i]从0开始标号 
	}
	
	Union_find uf2(n);
	for(int i=0;i<l;i++)
	{
		int p,q;
		cin>>p>>q;
		uf2.unite(p-1,q-1);
	}
	//题意:求出i->j既可以用通过roads到达又可以通过railways达到的city数量
	//先用并查集分好成两组(road,railway) 如果i两组的祖先为x,y j的祖先也为x,y则i->j即可通过road也可以通过railway(i->x->j),(i-y->j) 
	map<P,int> mp;
	for(int i=0;i<n;i++)
	{
		mp[make_pair(uf1.find(i),uf2.find(i))]++;
	}
	for(int i=0;i<n;i++)
	{
		cout<<mp[make_pair(uf1.find(i),uf2.find(i))]; 
		if(i==n-1)
		cout<<endl;
		else
		cout<<' ';
	}
	return 0;
} 

Measured memory_bytes: 13568
# import sys
from collections import defaultdict
# input = sys.stdin.readline
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    B = sorted(A)
    d = defaultdict( int)
    for i in range(N):
        d[B[i]] = i
    odd = 0
    for i in range(N):
        if (i+1)%2 == d[A[i]]%2 and d[A[i]]%2 == 1:
            odd += 1
    print(odd)
    
if __name__ == '__main__':
    main()

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

namespace Contest
{
	class Program
	{
		static void Main()
		{
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse);
            int[] rating = { 3200, 2800, 2400, 2000, 1600, 1200, 800, 400, 1 };
            int[] contestants = new int[rating.Length];
            foreach (var item in a)
            {
                for (int i = 0; i < rating.Length; i++)
                {
                    if (item >= rating[i])
                    {
                        contestants[i]++;
                        break;
                    }
                }
            }
            int count = contestants.Count(item => item > 0);
            if (contestants[0] > 0)
            {
                if (count == 1)
                {
                    Console.WriteLine($"1 {contestants[0]}");
                }
                else
                {
                    Console.WriteLine($"{count - 1} {count + contestants[0] - 1}");
                }
            }
            else
            {
                Console.WriteLine($"{count} {count}");
            }
#if DEBUG
			Console.ReadKey();
#endif
		}
	}
}

Measured memory_bytes: 13396
/*input
777
*/
#include "bits/stdc++.h"
#define ll long long
using namespace std;
int main()
{
	int n;
	cin>>n;
	while(n>0)
	{
		if((n%10)==7)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		n=(n/10);
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define maxn 5001
#define inf 1000000000000000000
ll p[maxn], pos[maxn], dp[maxn][maxn];
using namespace std;
int main()
{
    ll n, a, b, ans=inf;
    cin>>n>>a>>b;
    for(int i=1; i<=n; i++) cin>>p[i], pos[p[i]]=i;
    memset(dp, 1000000, sizeof dp);
    dp[0][0]=0;
    for(int i=1; i<=n; i++){
        for(int j=0; j<i; j++){
            if(pos[i]>pos[j]){
                dp[i][i]=min(dp[i-1][j], dp[i][i]);
                dp[i][j]=dp[i-1][j]+b;
            }
            else dp[i][j]=dp[i-1][j]+a;
        }
    }
    for(int i=1; i<=n; i++) ans=min(ans, dp[n][i]);
    cout<<ans;
}

Measured memory_bytes: 195712
import queue

X,N = map(int,input().split())
if N == 0:
  print(X)
else:
  p = list(map(int,input().split()))
  
  q = queue.Queue()

  q.put(X)

  while not q.empty():
    a = q.get()
    flag = "true"
    for i in p:
      if a==i:
        flag = "false"
        break
    if flag == "true":
      print(a)
      break
    else:
#    print(a,"は違うよ")
      if a != 0 and X-a >= 0:
        q.put(a-1)
      if a != 101 and X-a <= 0:
        q.put(a+1)

Measured memory_bytes: 9696
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>
#include <iomanip>

using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(ll i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
const ll MOD = 1e9 + 7;
set<char> alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };



int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    vvi g(N + 1);
    repp(i, N-1) {
        g[i].pb(i + 1);
        g[i + 1].pb(i);    
    }
    g[X].push_back(Y);
    g[Y].push_back(X);
    vvi dist(N + 1, vi(N + 1, -1));
    repp(i, N) {
        queue<int> q;
        q.push(i);
        dist[i][i] = 0;
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int u : g[v]) {
                if (dist[i][u] != -1)continue;
                q.push(u);
                dist[i][u] = dist[i][v] + 1;
            }
        }
    }
    vi ans(N);
    repp(i, N) {
        repp(j, N) {
            ans[dist[i][j]]++;
        }
    }
    repp(i, N - 1)cout << ans[i]/2 << endl;
}

Measured memory_bytes: 16128