akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double L;
    cin >> L;
    cout << fixed << setprecision(10) << pow(L/3,3) << "\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	double R, G;
	cin >> R >> G;
	printf("%.0f\n", G * 2 - R);
	return 0;
}

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

void solve(long long a){
    cout << a + a*a + a * a * a << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    solve(a);
    return 0;
}


Measured memory_bytes: 3688
#include <iostream>

int main(){
	using namespace std;
	long suu,j,k;
	string moji;
	cin >> suu >> moji;
	j = moji.length();
	char hennkougo[j];
	int i[j];
	for (k = 0; k < j; k++) {
		i[k] = (int)moji[k];
		i[k] += suu;
		if (i[k] > 90) {
			i[k] -= 26;
		}
		hennkougo[k] = (char)i[k];
		cout << hennkougo[k];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int n, a, cur; long long ret;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a >= cur + 2) ret += (a - 1) / (cur + 1);
		if (cur == 0 || a == cur + 1) cur++;
	}
	cout << ret << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    
    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program1
{
    static void Main(string[] args)
    {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');

        int N = int.Parse(input[0]);
        int A = int.Parse(input[1]);
        int B = int.Parse(input[2]);

        int ans1 = 0;
        int ans2 = 0;

        if(A > B)
        {
            ans1 = B;
        }
        else
        {
            ans1 = A;
        }

        if(N > (A + B))
        {
            ans2 = 0;
        }
        else
        {
            ans2 = (A + B) - N;
        }

        //出力
        Console.WriteLine(ans1 + " " + ans2);
    }
}

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

int main(){
    int N;
    cin >> N;
    int ans[100000];
    int x,y,z;
    for(x=0; x<100000; x++){
        ans[x]=0;
    }
    for(x=1; x<=100; x++){
        for(y=1; y<=100; y++){
            for(z=1; z<=100; z++){
                ans[x*x + y*y + z*z + x*y + y*z + z*x]++;
            }
        }
    }
    for(x=1; x<=N; x++){
        cout << ans[x] << endl;
    }
    system("pause");
    return 0;
}

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

using namespace std;

long long int maxim(long long int a,long long int b)
{

if(a>b)
{

    return a;
}
return b;
}

long long int minim(long long int a,long long int b)
{

if(a<b)
{

    return a;
}
return b;
}

long long int gcd(long long int a,long long int b)
{

if(b==0)
{

    return a;
}
return gcd(b,a%b);
}

long long int power(long long int a, long long int b)
{
    if(b==0)
    {
        return 1;
    }
    if(b==1)
    {
        return a;
    }
    long long int c = 1;
    while (b)
    {
        if (b & 1){
        c = (c * a)%1000000007;
        }
        a = ((a%1000000007) * (a%1000000007)%1000000007);
        b >>= 1;
    }
    return c;
}

void solve()
{
long long int n,k;
cin>>n>>k;
int a[100000];
int dp[100000];

long long int i;
for(i=0;i<n;i++)
{
    cin>>a[i];
}

dp[0]=0;
dp[1]=abs(a[1]-a[0]);

long long int j;
for(i=2;i<n;i++)
{
    long long int ans=LONG_LONG_MAX;
    for(j=i-1;j>=i-k;j--)
    {
        if(j<0)
        {
            break;
        }
        ans=minim(dp[j]+abs(a[i]-a[j]),ans);


    }
    dp[i]=ans;


}

cout<<dp[n-1]<<endl;

}

int main()
{

long long int t;

    solve();

return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    if(c>a+b)cout << a+b+b+1 << endl;
    else cout << c+b << endl;

}


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

int main() {
  char c;
  cin >> c;
  if(c-'A' >= 0 && c-'A' <= 25){
    cout << "A" << endl;
  }else{
    cout << "a" << endl;
  }
  
  return(0);
}

Measured memory_bytes: 3592
import string
import bisect

S, T = input(), input()
lS, lT = len(S), len(T)

l = {s: [] for s in string.ascii_lowercase}
for i in range(lS):
    l[S[i]].append(i)

id, ans = -1, 0
for i in range(lT):
    if len(l[T[i]]) == 0:
        print(-1)
        exit()
    else:
        tmp = l[T[i]][(bisect.bisect(l[T[i]], id)) % len(l[T[i]])]
        if id >= tmp:
            ans += lS
        id = tmp

print(ans + id + 1)


Measured memory_bytes: 8184
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MOD			1000000007
#define FOR(i,l,r)	for(int i=l;i<=r;i++)
#define REP(i,n)	for(int i=1;i<=n;i++)
#define REP0(i,n)	for(int i=0;i<n;i++)
#define PB			push_back
#define MP			make_pair
#define PII			pair<int,int>
#define VI			vector<int>
#define ALL(x)		(x).begin(),(x).end()
int n;
double x,sum;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		sum+=1.0/x;
	}
	cout<<setprecision(9)<<1.0/sum<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
Arr = ["AC","WA","TLE","RE"]
Dict = {}
for i in range(N):
    A = input()
    if (A not in Dict):
        Dict[A] = 0
    Dict[A] += 1
for i in Arr:
    print(i,"x",Dict[i] if i in Dict else 0)

Measured memory_bytes: 9196
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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;
}
const int MOD = 1000000007;
int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    int maxx = X;
    int miny = Y;

    rep(i, 0, N) {
        int a;
        cin >> a;
        if(a > maxx) {
            maxx = a;
        }
    }
    rep(i, 0, M) {
        int a;
        cin >> a;
        if(a < miny) {
            miny = a;
        }
    }
    if(maxx >= miny) {
        cout << "War" << endl;
    } else {
        cout << "No War" << endl;
    }
}

Measured memory_bytes: 256
/*
THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define r(i,s,l) for(int i=s;i<l;i++)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<long long,long long>
#define ss second
#define ff first
#define N 2000005
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    fast();
    int a,b,c;
    cin>>a>>b>>c;
    int x=a-b;
    int y=c-x;
    if(y<=0)
        cout<<0;
    else
        cout<<y;

    return 0;

}



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

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
	 //cout<<x<<' '<<y<<endl;
    return d;
}

int main()
{
	ll x,y;
	ll a,b;
	cin >> a >> b;
	extGCD(a,b,x,y);
	cout<<x<<' '<<y<<endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli solve(){
	string s, t;
	cin>>s>>t;
	lli n = s.length();
	lli m = t.length();
	vector<vll> dp(n+1, vll(m+1, 0));
	loop(i, 1, n+1){
		loop(j, 1, m+1){
			if(s[i-1] == t[j-1])
				dp[i][j] = 1 + dp[i-1][j-1];
			else
				dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
		}
	}
	string res;
	lli i = n, j=m;
	while(i > 0 && j > 0){
		if(s[i-1] == t[j-1]){
			res.pb(s[i-1]);
			i--;
			j--;
		}
		else{
			if(dp[i-1][j] == dp[i][j])
				i--;
			else
				j--;
		}
	}
	reverse(res.begin(), res.end());
	cout<<res<<"\n";
	return 0;
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

Measured memory_bytes: 70784
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索
不変なもの・偶奇に注目

*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
#include<set>
using namespace std;
#define INF 1LL<<60
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,bool> P;
//typedef pair< pair<int,int>,pair<int,int> > p;
//#define int ll int main->signed main
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

//https://www.hamayanhamayan.com/entry/2017/07/23/233641

int N,M;
int A[310][310];

int check(int x){
    vector< queue<int> > vq(N);
    vector<int> used(M,0);
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++) vq[i].push(A[i][j]);
    }

    while(true){
        map<int,int> M;
        for(int i=0;i<N;i++){
            M[vq[i].front()]++;
        }
        vector<int> ng;
        for(auto p:M){
            if(x<p.second) ng.push_back(p.first);
        }
        if(ng.size()==0) return 1;
        for(auto j:ng){
            used[j]=1;
        }

        for(int i=0;i<N;i++){
            while(!vq[i].empty() && used[vq[i].front()]) vq[i].pop();
            if(vq[i].empty()) return 0;
        }
    }

}

int main(){
    cin>>N>>M;
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin>>A[i][j];
            A[i][j]--;
        }
    }
    int ng=0,ok=N;
    while(ng+1!=ok){
        int x=(ng+ok)/2;
        if(check(x)) ok=x;
        else ng=x;
    }
    cout<<ok<<endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int a,b,c;
int main()
{
//////////////////////////a
    a=read(),b=read();c=6-a-b;cout<<c<<"\n";
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i

s = []
i = 1

while (i <= n)
    x = i
    if ( x % 3 == 0 )
        s.push(i)
        i += 1
        next
    else
        while (x != 0)
            if ( x % 10 == 3)
                s.push(i)
                break
            else
                x = x/10;
            end
        end
    end
	i += 1
end

puts ' ' + s.join(' ')


Measured memory_bytes: 6944
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    priority_queue<int> que;
    REP(i, N) {
        int a;
        cin >> a;
        que.push(a);
    }

    REP(i, M) {
        int top = que.top();
        que.pop();
        que.push(top / 2);
    }

    ll ans = 0;
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 892
/*
 * atcoder/abc161/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

ll N, M;
vector<ll> A;
ll S = 0;

void input() {
  cin >> N >> M;
  ll a;
  loop(n,0,N) {
    cin >> a;
    A.push_back(a);
    S += a;
  }
}

void solve() {
  ll count = 0;
  for (auto&&a: A) {
    count += 4 * M * a >= S;
  }
  
  if (count >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int w, h, n;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> w >> h >> n;
	if (h > w) swap(h, w);
	cout << (n + w - 1) / w << endl;

	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200000
using namespace std;
int n,a[N+5];map<int,int> s,g;
int main()
{
	RI i;for(scanf("%d",&n),i=1;i<=n;++i) scanf("%d",a+i),++s[a[i]];
	RI ans=0,t=1<<30;for(sort(a+1,a+n+1),i=n;i;--i)
	{
		if(g[a[i]]) {--g[a[i]];continue;}--s[a[i]];
		W((a[i]<<1)<t) t>>=1;s[t-a[i]]&&(--s[t-a[i]],++g[t-a[i]],++ans);
	}return printf("%d\n",ans),0;
}

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

void solver(){
	int n , ans = 0;
	scanf("%d",&n);
	int cnt = 0 , cpy = n;
	while(cpy)cnt++,cpy/=10;
	if(cnt & 1){
		int num = 1;
		for(int i = 1 ; i < cnt ; ++i)num *= 10;
		ans += n - num + 1;
		for(int i = cnt-2 ; i > 0 ; i-=2){
			int sum = 8;
			for(int j = 1 ; j < i ; ++j){
				sum *= 10;
				sum += 9;
			}
			ans += sum + 1;
		}
	}else{
		for(int i = cnt-1 ; i > 0 ; i-=2){
			int sum = 8;
			for(int j = 1 ; j < i ; ++j){
				sum *= 10;
				sum += 9;
			}
			ans += sum + 1;
		}
	}
	printf("%d\n",ans);
	return;
}

int main(){
	int q = 1;
	//scanf("%d",&q);
	while(q--){
		solver();
	}
	return 0;
}


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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;



void one_case() {
    int h, w, d;
    cin >> h >> w >> d;
    int n = h * w  +1;
    vector<int> x(n), y(n);
    vector<int> dist(n);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int a;
            cin >> a;
            x[a] = i;
            y[a] = j;
        }
    }
    for (int a = d; a <= h * w; ++a) {
        dist[a] = dist[a - d] + abs(x[a] - x[a - d]) + abs(y[a] - y[a - d]);
    }

    int q;
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << dist[r] - dist[l] << "\n";
    }
}


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


    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


Measured memory_bytes: 2176
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char S[4011];

int ord(char c) {
    if (c == 'R') return 0;
    if (c == 'G') return 1;
    return 2;
}

void MAIN() {
    scanf("%d", &N);
    scanf("%s", S);
    LL ans = 0;
    REP (i, N) {
	int L[3] = {};
	int R[3] = {};
	for (int j=i-1; j>=0; j--) L[ord(S[j])]++;
	for (int j=i+1; j<N; j++) R[ord(S[j])]++;
	int a = ord(S[i]);
	int b = (a+1) % 3;
	int c = (b+1) % 3;

	ans += (LL)L[b] * R[c];
	ans += (LL)L[c] * R[b];

	for (int k=1; i-k>=0 && i+k<N; k++) {
	    b = ord(S[i-k]);
	    c = ord(S[i+k]);
	    if (a != b && b != c && c != a) ans--;
	}
    }
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3836
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

const array<int, 4> dx{ 0, 1, 0, -1 };
const array<int, 4> dy{ 1, 0, -1, 0 };

int set_distance(int i, int j, int k, vector<vector<array<int, 4>>>& dist_table, vector<string>& table)
{
    if (dist_table[i][j][k] == -1)
    {
        dist_table[i][j][k] = 0;
        if (table[i][j] == '.')
        {
            dist_table[i][j][k] += 1;
            const int ny = i + dy[k];
            const int nx = j + dx[k];
            if (0 <= ny && ny < dist_table.size() && 0 <= nx && nx < dist_table[0].size())
            {
                dist_table[i][j][k] += set_distance(ny, nx, k, dist_table, table);
            }
        }
    }
    return dist_table[i][j][k];
}

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> table(h);
    for (auto& r : table)
    {
        cin >> r;
    }

    vector<vector<array<int, 4>>> dist_table(h, vector<array<int, 4>>(w));
    for (auto& r : dist_table)
    {
        for (auto& c : r)
        {
            fill(c.begin(), c.end(), -1);
        }
    }

    for (int k = 0; k < 4; k++)
    {
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (dist_table[i][j][k] == -1 && table[i][j] == '.')
                {
                    set_distance(i, j, k, dist_table, table);
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (table[i][j] == '.')
            {
                ans = max<int>(
                    ans, dist_table[i][j][0] + dist_table[i][j][1] + dist_table[i][j][2] + dist_table[i][j][3] - 3);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 67200
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String target = br.readLine().toLowerCase();
        String str;
        String[] strArr;
        int count = 0;
        int i;
        while (!(str = br.readLine()).equals("END_OF_TEXT")) {
            strArr = str.toLowerCase().split(" ");
            for (i = 0; i < strArr.length; i++) {
                if (strArr[i].equals(target)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 24200
#include<iostream>
#include<stdio.h>
#include<cctype>
using namespace std;
int main(){
    char ch;
    int num;
    int counter[26] = {};
    
    while(scanf("%c", &ch) != EOF){
        
        if(isalpha(ch)){ 
            if(islower(ch)){
                 int num = ch - 'a';
                counter[num] += 1;
            }
            
            else if(isupper(ch)){
                int num = ch - 'A';
                counter[num] += 1;
            }
        }
    }
    
    for(int i = 0; i < 26; i++){
        ch = i + 'a';
        
        cout << ch << " " << ":" << " " << counter[i] << endl;
    }
}


Measured memory_bytes: 3156
def main():
    S = input()
    N = len(S)
    pre = ''
    i = 0
    plus = 1
    ans = 0
    while i < N:
        if pre != S[i:i+plus]:
            ans += 1
            pre = S[i:i+plus]
            i = i+plus
            plus = 1
        else:
            plus += 1
            if i + plus > N:
                break
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41180
#include<bits/stdc++.h>
using namespace std;
string s;
int K,N;
int main() {
	cin >> N>>K;
 
	cin >> s;
		
	s[K-1 ] = s[K-1 ] + 32;  //K[0]カラ始まってるからK-1にしている。
	
	cout << s << endl;
 
 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  int n,a[1000],q;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  cin>>q;
  for(int i=0;i<q;i++){
    int c,b,e;
    cin>>c>>b>>e;
    if(c){
      int r=-(int)1e9;
      for(int j=b;j<e;j++) r=max(r,a[j]);
      cout<<r<<endl;
    }else{
      int r=(int)1e9;
      for(int j=b;j<e;j++) r=min(r,a[j]);
      cout<<r<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3068
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String o = sc.next();
		String e = sc.next();
		String s = "";
		int countO = 0;
		int countE = 0;
		int n = o.length() + e.length();
		for (int i = 1; i <= n; i++) {
			if (i % 2 == 1) {
				s += o.charAt(countO);
				countO++;
			}else {
				s += e.charAt(countE);
				countE++;
			}
		}
		System.out.println(s);
		sc.close();
	}
}


Measured memory_bytes: 39032
//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long LL;
#define fi first
#define se second
#define th third
#define mp make_pair
#define gc getchar
#define pb push_back
struct trio{
	int fi,se,th;
	trio(int _fi,int _se,int _th){
		fi=_fi;
		se=_se;
		th=_th;
	}
	trio(){
	}
	friend bool operator<(trio a,trio b){
		if(a.fi!=b.fi)
			return a.fi<b.fi;
		if(a.se!=b.se)
			return a.se<b.se;
		return a.th<b.th;
	}
	void sort(){			//fi terkecil
		if(se<fi)
			swap(se,fi);
		if(th<fi)
			swap(th,fi);
		if(th<se)
			swap(th,se);
	}
	void berikut(){
		int se1,fi1,th1;
		se1=(fi>>1)+(th>>1);
		fi1=(th>>1)+(se>>1);
		th1=(fi>>1)+(se>>1);
		se=se1;
		fi=fi1;
		th=th1;
	}
	bool isodd(){
		return ((fi&1)||(se&1)||(th&1));
	}
};
set<trio> sudah;
int main()
{
	int A,B,C,ans=0;
	cin>>A>>B>>C;
	trio now=trio(A,B,C);
	while(true)
	{
		if(now.isodd())
			break;
		now.sort();
		if(sudah.find(now)!=sudah.end())
		{
			ans=-1;
			break;
		}
		sudah.insert(now);
		now.berikut();
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const double eps = 1e-11;
const int inf = 1ll << 62;

signed main(){
	string s,t;cin>>s>>t;
	int s1=s.size(),t1=t.size();
	
	string ans="~";
	
	for(int i=0;i<=s1-t1;i++){
		string ne;
		int flg=1;
		for(int j=0;j<i;j++)ne.push_back(s[j]);
		rep(j,t1){
			if(s[j+i]==t[j]||s[j+i]=='?')ne.push_back(t[j]);
			else flg=0;
			}
		for(int j=i+t1;j<s1;j++)ne.push_back(s[j]);	
		rep(j,s1){
			if(ne[j]=='?')ne[j]='a';
			}
			if(flg){
				if(ans>ne)ans=ne;
				}	
		}
		if(ans=="~")puts("UNRESTORABLE");
		else cout<<ans<<endl;
	}


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

using namespace std;

int n=0;
int l[2001];

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

	cin >> n;
	for (int i=0; i<n; i++)
	{
		cin >> l[i];
	}		
	sort(l, l+n);
	long long res=0;
	for (int i=0; i<n; i++)
	{
		for (int j=i+1; j<n; j++)
		{
			int ind1=0,ind2=0;
			auto it1 = upper_bound(l, l+n, l[j]-l[i]);		
			auto it2 = lower_bound(l, l+n, l[i]+l[j]);
			if (it2==l || it1==l+n)
				continue;
			it2--;
			ind1 = it1-l;	
			ind2 = it2-l;
			int cnt=ind2-ind1+1;
			if (i>=ind1 && i<=ind2)
				cnt--;
			if (j>=ind1 && j<=ind2)
				cnt--;
			res+=max(0, cnt);
			//cout << i << ' ' << j << ' ' << ind1 << ' ' << ind2 << endl;
		}
	}
	cout << res/3;
	return 0;
}


Measured memory_bytes: 384
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
 
using namespace std;
 
#define MAX_V 2048
#define INF 1e9

int n,x,y;

vector<int> get_neighbors(int i) {
    vector<int> nb;
    if (i > 0) {
        nb.push_back(i-1);
    }
    if (i < n-1) {
        nb.push_back(i+1);
    }
    if (i==x){
        nb.push_back(y);
    }
    if (i==y){
        nb.push_back(x);
    }
    return nb;
}

int main() {
    cin>>n>>x>>y;
    --x;
    --y;
    vector<int> cnt(n, 0);
    for(int i = 0; i < n; ++i) {
        vector<int> d(n, INF);
        d[i]=0;
        queue<int> q;
        q.push(i);
        while (!q.empty()) {
            int t = q.front();
            q.pop();
            for (int nb : get_neighbors(t)) {
                if (d[nb]!=INF)
                    continue;
                d[nb]=min(d[nb],d[t]+1);
                q.push(nb);
            }
        }
        for(int x : d)
            ++cnt[x];
    }
    for (int k = 1; k < n; ++k) {
        cout<<cnt[k]/2<<"\n";
    }
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <set>
#include <cmath>
#include <algorithm>
#include <locale>

#define int long long
#define pb(n) push_back(n)
#define For(n,i) for(int (i)=0;(i)<(n);(i)++)
//#define ForJ(n) for(int j=0;j<n;j++)
//#define ForK(n) for(int k=0;k<n;k++)
#define Pr(n) cout<<n<<endl;
#define INS(v,n) for(int i=0;i<n;i++){cin >>v.at(i);}//vector 代入
#define ELM 100001 //問題によっては1000000001に変更
using namespace std;

int Product_set_min(int la,int ra,int lb,int rb){//A<B
    int r=0;;
    if (la<ra&&ra<lb&&lb<rb) {
        r= 0;
    }else if(la<=lb&&lb<=ra&&ra<=rb){
        r= lb;
    }else if(lb<=la&&la<=ra&&ra<=rb){
        r= la;
    }else if(lb<=la&&la<=rb&&rb<=ra){
        r= la;
    }else if(lb<rb&&rb<la&&la<ra){
        r= 0;
    }
    return r;
}
int Product_set_max(int la,int ra,int lb,int rb){//A<B
    int r=0;;
    if (la<ra&&ra<lb&&lb<rb) {
        r= 0;
    }else if(la<=lb&&lb<=ra&&ra<=rb){
        r= ra;
    }else if(lb<=la&&la<=ra&&ra<=rb){
        r= ra;
    }else if(lb<=la&&la<=rb&&rb<=ra){
        r= rb;
    }else if(lb<rb&&rb<la&&la<ra){
        r= 0;
    }
    return r;
}
string min (string m){
    transform(m.begin(), m.end(), m.begin(),towlower);
    return m;
}
signed  main(){
    int n,x;
    cin >> n>>x;
    vector<int> m(n);
    int sum=0;
    For(n, i){
        cin>>m.at(i);
         sum+=m[i];
    }
    int min = *min_element(m.begin(), m.end());
    cout<<n+(x-sum)/min<<endl;
    return 0;
}



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

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

using namespace std;


int main()
{
  int A,X;

  cin >> X >> A;

  if(X < A)cout << 0 << endl;
  else if(X >= A)cout << 10 << endl;

  return 0;
}

Measured memory_bytes: 256
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    cnt = 0
    for d1, d2 in map(str.split, args[1:]):
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if 3 <= cnt:
            return 'Yes'
    return 'No'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

ll n, t, q, x[100000], a[100000];
int d[100000];
vector<ll>v;


int main() {
	scanf("%lld%lld%lld", &n, &t, &q);
	rep(i, n)scanf("%lld%d", &a[i], &d[i]);
	rep(i, q)scanf("%lld", &x[i]);
	rep(i, n - 1) {
		if (d[i] == 1 && d[i + 1] == 2 && a[i + 1] - a[i] <= t * 2) {
			d[i] = d[i + 1] = 0;
			a[i] = a[i + 1] = (a[i + 1] + a[i]) / 2;
			v.push_back(a[i]);
		}
	}
	rep(i, n) {
		if (!d[i])continue;
		ll j = lower_bound(v.begin(), v.end(), a[i]) - v.begin();
		if (j < v.size() && d[i] == 1 && v[j] - a[i] <= t) {
			a[i] = v[j];
			d[i] = 0;
		}
		j--;
		if (0 <= j&&d[i] == 2 && a[i] - v[j] <= t) {
			a[i] = v[j];
			d[i] = 0;
		}
	}
	rep(j, q) {
		int i = x[j] - 1;
		if (d[i] == 1)printf("%lld\n", a[i] + t);
		else if (d[i])printf("%lld\n", a[i] - t);
		else printf("%lld\n", a[i]);
	}
}

Measured memory_bytes: 4516
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 1000000000
using namespace std;
typedef long long ll;
const int MAXN=1e9+10;
const int MAX=2e5+10;
const double eps=1e-6;

int n;
int num[MAX],s[MAX];

int main(){
    #ifdef ONLINE_JUDGE
    #else
   // freopen("in.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif

    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",&s[i]);
        num[i]=s[i];
    }
    sort(num+1,num+n+1);
    int jugea,jugeb,a,b;
    jugea=jugeb=0;
    a=n/2;b=a+1;
    for(int i=1;i<=n;i++){
        if(s[i]==num[a]&&!jugea){
            cout<<num[b]<<endl;
            jugea=1;
            continue;
        }
        else if(s[i]==num[b]&&!jugeb){
            //cout<<a<<" "<<num[b]<<"*"<<endl;
            cout<<num[a]<<endl;
            jugeb=1;
            continue;
        }
        //cout<<"*"<<i<<endl;
        if(s[i]<=num[a])  cout<<num[b]<<endl;
        else    cout<<num[a]<<endl;
    }


    return 0;
}

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

lint h, w;

int main() {
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (h * w % 2 == 0) {
        cout << h * w / 2 << endl;
    } else {
        cout << (h * w + 1) / 2 << endl;
    }
}

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

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (Math.abs(x - a) < Math.abs(x - b)) {
            _out.println("A");
        } else {
            _out.println("B");
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21844
# AOJ 1147: ICPC Score Totalizer Software
# Python3 2018.7.14 bal4u

while True:
	n = int(input())
	if n == 0: break
	s, vmin, vmax = 0, 1001, -1
	for i in range(n):
		a = int(input())
		vmin = min(vmin, a)
		vmax = max(vmax, a)
		s += a
	print((s-vmin-vmax)//(n-2))


Measured memory_bytes: 5600
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
S = input()

i= 0
ans = 0
moji1 = ""
moji2 = ""
while i < len(S):
    if i == 0:
        moji1 = S[i]
        ans += 1
    else:
        moji2 = moji2 + S[i]
        if moji1 != moji2:
            ans += 1
            moji1 = moji2
            moji2 = ""
        else:
            moji2 = moji2 + S[i]
    i += 1

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

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

int main() {
    vector< char > vec(4);
    rep(i, 4) { cin >> vec.at(i); }
    vector< int > num(4);
    rep(i, 4) { num.at(i) = vec.at(i) - '0'; }

    for (int tmp = 0; tmp < (1 << 3); tmp++) {
        int ret = num.at(0);
        bitset< 3 > op(tmp);
        for (int i = 0; i < 3; i++) {
            if (op.test(i)) {
                ret += num.at(i + 1);
            } else {
                ret -= num.at(i + 1);
            }
        }
        if (ret == 7) {
            cout << num.at(0);
            for (int i = 0; i < 3; i++) {
                if (op.test(i)) {
                    cout << "+";
                } else {
                    cout << "-";
                }
                cout << num.at(i + 1);
            }
            cout << "=7" << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, m; cin >> n >> m;
	
	i64 ma = 0;
	for(i64 i = 1; i * i <= m; i++) {
		if(m % i) continue;
		
		if(m / i >= n) ma = std::max(ma, i);
		if(i >= n) ma = std::max(ma, m / i);
	}
	
	cout << ma << endl;
	return 0;
}


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

double dp[310][310][310];
int main(){
	LL N; 
    cin >> N;
	vector<LL> vp(4);
	for(LL i = 0; i < N; i++){
		LL a; 
        cin >> a;
		vp[a]++;
	}
	for(LL c = 0; c <= N; c++) for(LL b = 0; b <= N; b++) for(LL a = 0; a <= N; a++){
        int sum = a+b+c;
		if(a == 0 && b == 0 && c == 0 || sum > N) continue;
		if(a > 0) dp[a][b][c] += dp[a-1][b][c]*a;
		if(b > 0) dp[a][b][c] += dp[a+1][b-1][c]*b;
		if(c > 0) dp[a][b][c] += dp[a][b+1][c-1]*c;
        dp[a][b][c] += N;
        dp[a][b][c] *= 1.0/(a+b+c);
	}
	cout << setprecision(15) << dp[vp[1]][vp[2]][vp[3]] << endl;
}

Measured memory_bytes: 225536
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N,W;
    cin >> N >> W;
    vector<int> wt(N),val(N);
    ffor(i,N) cin >> wt[i] >> val[i];
    vector<vector<int>> dp(N + 1,vector<int>(W + 1));
    dp[0][0] = 0;
    // dp[i][j] -> max value for i items considered and w max weight

    for(int i = 1; i <= N; ++i)
    {
        for(int j = 0;j <= W; ++j)
        {
            // not taking ith item
            dp[i][j] = dp[i - 1][j];
            // if we can take current item
            if(j - wt[i - 1] >= 0)
            dp[i][j] = max(dp[i][j],dp[i - 1][j - wt[i - 1]] + val[i - 1]);
        }
    }

    // answer will be dp[N][W]
    cout << dp[N][W];
    // O(N*W)
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FOOR(i,a,b) for(int i=a;i<=b;i++)
#define FI first
#define SE second
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int MOD=1e9+7;
const int INF=1e9+7;
const double PI=3.141592653589793238462643383279;
//
int N;
PA T[100000];
PA Z[100000];
int main(){
    cin>>N;
    FOR(i,0,N){
      cin>>T[i].FI;
      T[i].SE=i;
      cin>>Z[i].FI>>Z[i].SE;
    }
    sort(T,T+N);
    int nx=0,ny=0;
    int nt=0;
    FOR(i,0,N){
      int tt=T[i].FI;
      int p=T[i].SE;
      int D=abs(Z[p].FI-nx)+abs(Z[p].SE-ny);
      int time=tt-nt;
      if(D>time){
        Yes(0);
        return 0;
      }else if((time-D)%2==0){
        nt=tt;
        nx=Z[p].FI;
        ny=Z[p].SE;
        continue;
      }else{
        Yes(0);
        return 0;
      }
    }
    Yes(1);
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int M = stdIn.nextInt();
		int[] a = new int[A];
		int[] b = new int[B];
		int minA = (int)1e6;
		int minB = (int)1e6;
		for(int i = 0; i < A; i++) {
			a[i] = stdIn.nextInt();
			if(a[i] < minA) minA = a[i];
		}
		for(int i = 0; i < B; i++) {
			b[i] = stdIn.nextInt();
			if(b[i] < minB) minB = b[i];
		}
		
		int min = minA+minB;
		for(int i = 0; i < M; i++) {
			int x = stdIn.nextInt();
			int y = stdIn.nextInt();
			int c = stdIn.nextInt();
			if(a[x-1]+b[y-1]-c < min) {
				min = a[x-1]+b[y-1]-c;
			}
		}
		
		System.out.println(min);

	}

}

Measured memory_bytes: 132680
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    rep(i,0,n) cin>>a.at(i);
    
    ll x,y;
    x=((k+1)*k/2)%MOD;
    y=((k-1)*k/2)%MOD;
    
    ll ans=0;
    rep(i,0,n){
        ll cnt_l=0;
        rep(j,0,i){
            if(a.at(i)>a.at(j)) cnt_l++;
        }
        ans+=cnt_l*y;
        ans%=MOD;
        
        ll cnt_r=0;
        rep(j,i+1,n){
            if(a.at(i)>a.at(j)) cnt_r++;
        }
        ans+=cnt_r*x;
        ans%=MOD;
    }
    
    cout<<ans<<endl;
}


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

int func(int x){
  int ans;
  for(int i=1;i<10000000;i++){
    if(i*x%360 == 0){
      ans = i;
      break;
    }
  }
  
  return ans;
}

int main(){
  int x;
  cin >> x;
  cout << func(x) << endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
//const int MOD = 1e9+7;
const int MOD = 998244353;

long long modpow(long long a, long long b){
	long long c = 1;
	while(b > 0){
		if(b & 1) c = c * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return c;
}

int main(){
	
	int n; cin>>n;
	vector<int> d(n);
	for(int i=0; i<n; i++){
		int d0; cin>>d0;
		if((i!=0)&&(d0==0)){
			cout << 0 << endl;
			return 0;
		}
		if((i==0)&&(d0!=0)){
			cout << 0 << endl;
			return 0;
		}
		d.at(d0)++;
	}
	ll sum{1};
	for(int i=1; i<n-1; i++){
		(sum *= modpow(d.at(i-1),d.at(i)) ) %= MOD;
		if(d.at(i)==0) break;
	}
	if(d.at(0)!=1) sum = 0;
	for(int i=0; i<n-1; i++){
		if((d.at(i)==0)&&(d.at(i+1)>0)) sum=0;
	}
	cout << sum << endl;

	
}



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

using namespace std;

const int inf = 1e9 + 7;
const int N = 205;

int n, a[N], b[N], c[N], d[N], ans;
int g[N][N], mt[N], used[N];

bool try_kuhn(int v){
      if(used[v]) return false;
      used[v] = 1;
      for(int i = 1; i <= n + n; i ++){
            if(g[v][i] && (mt[i] == -1 || try_kuhn(mt[i]))){
                  mt[i] = v;
                  return true;
            }
      }
      return false;
}

int main(){
      cin >> n;

      for(int i = 1; i <= n; i ++){
            cin >> a[i] >> b[i];
      }
      for(int i = 1; i <= n; i ++){
            cin >> c[i] >> d[i];
      }

      for(int i = 1; i <= n; i ++){
            for(int j = 1; j <= n; j ++){
                  if(a[i] <= c[j] && b[i] <= d[j]){
                        g[i][j + n] = 1;
                        g[j + n][i] = 1;
                  }
            }
            mt[i] = -1;
            mt[i + n] = -1;
      }

      for(int i = 1; i <= n; i ++){
            for(int j = 1; j <= n + n; j ++)
                  used[j] = 0;
            try_kuhn(i);
      }
      for(int i = 1; i <= n; i ++){
            if(mt[i + n] != -1) ans ++;
      }

      cout << ans << endl;
}


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

using namespace std;

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int x;
    x = r * 100 + g * 10 + b;
    if (x % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<string.h>
using namespace std;
int main()
{
	string s;
	while (getline(cin, s)){
		while (true){
			for (int i = 0; i < s.size(); i++){
				if (s[i] == 'z'){
					s[i] = 'a';
				}
				else if (s[i] != ' '&&s[i] != '.'){
					s[i]++;
				}
			}
			if (s.find("the") != -1)break;
			if (s.find("this") != -1)break;
			if (s.find("that") != -1)break;
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a < 10 && b < 10)
    {
        cout << a * b << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int D,G,ans=1e9,i;
	scanf("%d %d",&D,&G);
	int p[D+1],c[D+1];
	for(i=1;i<=D;i++)scanf("%d %d",&p[i],&c[i]);
	int list;
	//num << n でnumが2^n倍される
	//1 << D = 2^D
	for(list=0; list<(1<<D); list++){
		int score=0, num=0, rest_max;
		for(i=1; i<=D; i++){
			if(list>>(i-1) & 1){
			//listを左にiビットシフトし、1とのビット論理和
			//=> listの2進数表記のi桁目が１なら解く
				score += 100*i*p[i] + c[i];
				num += p[i];
			}
			else{
				rest_max = i;//解いていない
			}
		}
		if(score<G){
			int s1 = 100*rest_max;//中途半端に解く問題の点数
			int need = (G-score+s1-1)/s1;
			if(need > p[rest_max]) continue;//以下を実行せず次のループへ
			num += need;
		}
		ans = ans<num? ans: num;	
	}
	printf("%d",ans);	
	return 0;
}

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

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

  vector<int> vec(N)
  ;for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end()); 
  reverse(vec.begin(), vec.end());
 
  int sumA = 0;
  for (int i = 0; i < N; i+=2) {
    sumA += vec.at(i);
  }
  
  int sumB = 0;
  for (int i = 1; i < N; i+=2) {
    sumB += vec.at(i);
  }
  
  cout << sumA - sumB << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    Sort(a);
    
    double ans = a[0];
    For(i, n-1){
        ans = (ans + a[i+1]) / 2;
    }
    Cout(ans);
}


Measured memory_bytes: 256