akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

vvi a(3,vector<int>(3));
rep(i,3){
    rep(j,3){
        cin >> a.at(i).at(j);
    }
}
int n;
cin >> n;
vi b(n);
rep(i,n) cin >> b[i];

rep(i,3){
    rep(j,n){
        if(a.at(i).at(0) == b[j]) a.at(i).at(0) = 0;
        if(a.at(i).at(1) == b[j]) a.at(i).at(1) = 0;
        if(a.at(i).at(2) == b[j]) a.at(i).at(2) = 0;
    }
}

rep(i,3){
    if(a.at(i).at(0) == 0 && a.at(i).at(1) == 0 && a.at(i).at(2) == 0 ){
        cout << "Yes" << endl;
        return 0;
    }
    if(a.at(0).at(i) == 0 && a.at(1).at(i) == 0 && a.at(2).at(i) == 0 ){
        cout << "Yes" << endl;
        return 0;
    }
}
if(a.at(0).at(0) == 0 && a.at(1).at(1) == 0 && a.at(2).at(2) == 0 ){
        cout << "Yes" << endl;
        return 0;
}
if(a.at(0).at(2) == 0 && a.at(1).at(1) == 0 && a.at(2).at(0) == 0 ){
        cout << "Yes" << endl;
        return 0;
}
cout << "No" << endl;



//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

	int n, a[25],b[25],c[25],d[25],k=0,x,s=0; 
	cin >> n>>a[1];
    for(int i=2;i<=n;i++){
        cin>>a[i];
       // cout<<a[i]-a[i-1]<<endl;
        if(a[i]-a[i-1]==1){
            k++;
            d[k]=a[i-1];
           // cout<<"*"<<d[k]<<endl;
        }
    }	
    for(int i=1;i<=n;i++){
        cin>>b[i];
        s+=b[i];
        //cout<<"$"<<s<<endl;
    }
    for(int i=1;i<n;i++){
        cin>>c[i];
    }
    for(int i=1;i<=k;i++){
        x=d[i]; 
    //    cout<<"%"<<x<<endl;
        s+=c[x];
    //    cout<<"^"<<s<<endl;
    }
    cout<<s;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
for i in range(n - 1):
    r1, r2 = map(int, input().split())
    if r1 >= t and r2 >= a:
        multiple = 1
    elif r1 < t and r2 >= a:
        multiple = (t-1) // r1 + 1
    elif r1 >= t and r2 < a:
        multiple = (a-1) // r2 + 1
    else:
        multiple = max((t-1) // r1, (a-1) // r2) + 1
    t, a = r1 * multiple, r2 * multiple
print(t+a)

Measured memory_bytes: 38768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define M_PI 3.14159265358979323846
#define MOD 1000000007
#define int ll
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<long long, long long> pll; typedef cc_hash_table<int, int, hash<int>> intHashTable;
struct custom_hash { static uint64_t splitmix64(uint64_t x) { 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); } };
inline int powMod(int a, int b) { int x = 1; while (b > 0) { if (b&1) x = (x*a) % MOD; a = (a*a) % MOD; b >>= 1; } return x; }
inline int multiply(int x, int y) { return ((x % MOD) * (y % MOD)) % MOD; }
inline int divide(int x, int y) { return ((x % MOD) * powMod(y % MOD, MOD-2)) % MOD; }
inline int ceil(int a, int b) { return (a+b-1)/b; }
int gcd (int a, int b) { while (b) { a %= b; swap(a, b); } return a; }
int lcm (int a, int b) { return a / gcd(a, b) * b; }
int inverseMod(int a, int m) { a = a % m; for (ll x = 1; x < m; x++) if ((a * x) % m == 1) return x; return -1; }
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
int str_replace(string& str, const string& from, const string& to, int limit = -1) { if(from.empty()) return 0; size_t start_pos = 0; int cnt = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); cnt++; if (cnt == limit) break; } return cnt; }
template<int D, typename T> struct vec : public vector<vec<D - 1, T>> { static_assert(D >= 1, "Vector dimension must be greater than zero!");  template<typename... Args> vec(int n = 0, Args... args) : vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)) { } }; template<typename T> struct vec<1, T> : public vector<T> { vec(int n = 0, T val = T()) : vector<T>(n, val) { }};

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int a, b, c, d; cin >> a >> b >> c >> d;
    bool turn = true;
    while (true)
    {
        if (turn) c -= b;
        else a -= d;
        if (a <= 0) { cout << "No\n"; return 0; }
        if (c <= 0) { cout << "Yes\n"; return 0; }
        turn = !turn;
    }
    return 0;
}

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

using ll = long long;
#define int ll

const int mod = 1e9 + 7;

void add_self(int& a, int b)
{
	a += b;
	if(a >= mod)
	{
		a -= mod;
	}
}

void sub_self(int& a,int b)
{
	a -= b;
	if(a < 0)
	{
		a += mod;
	}
}

int32_t main()
{
	int n,k;
	scanf("%lld%lld",&n,&k);
	vector<int> dp(k + 1);
	dp[0] = 1;
	for(int child=0;child<n;child++)
	{
		int up_to;
		scanf("%lld",&up_to);
		vector<int> fake(k + 1);
		for(int used=k;used>=0;used--)
		{
			int tmp = dp[used];
			int L = used + 1;
			int R = used + min(up_to, k - used);
			if(L <= R)
			{
				add_self(fake[L], tmp);
				if(R + 1 <= k)
				{
					sub_self(fake[R + 1], tmp);
				}
			}
		}
		int prefix_sum = 0;
		for(int i=0;i<=k;i++)
		{
			add_self(prefix_sum,fake[i]);
			add_self(dp[i],prefix_sum);
		}
	}
	printf("%lld\n",dp[k]);
	return 0;
}

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

# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ;

# define ll long long
# define C continue;

# define pb push_back
# define vi vector < int >
# define vll vector < ll >

# define I insert

# define pii pair < int , int >
# define pll pair < ll , ll >
# define F first
# define S second

# define vpii vector < pair < int , int > >
# define vpll vector < pll >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()

# define ld long double
# define PQ priority_queue

# define vc vector < char >
# define vb vector < bool >
# define vs vector < string >

# define vvi vector < vector < int > >
# define vvll vector < vector < ll > >
# define vvc vector < vector < char > >
# define vvb vector < vector < bool > >

# define allcomp(v) v.begin() , v.end() , comp

# define pp(n) printf("%.10Lf",n);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .
/// Start using lower bound !!

void solve ( int test_case )
{
    string s ;
    cin >> s ;

    cout << s[0] << s[1] << s[2] ; line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

ll N,M,ans=0,cnt,now;

int main(){
    cin>>N>>M;
    ll A[N];
    rep(i,N){
        cin>>A[i];
        A[i]=A[i]%M;
    }
    rep(i,N-1){
        A[i+1]=(A[i+1]+A[i])%M;
    }
    sort(A,A+N);
    now=0;
    cnt=1;
    rep(i,N){
        if(now==A[i]){
            cnt++;
        }
        else{
            // printf("cnt : %lld\n",cnt);
            ans+=cnt*(cnt-1);
            // out(ans);
            cnt=1;
            now=A[i];
        }
    }
    ans+=cnt*(cnt-1);
    // rep(i,N){
    //     printf("%lld ",A[i]);
    // }
    // out("");
    out(ans/2);
    

}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int X = sc.nextInt();
    int c = 0;
    
    for(int i=0; i<A+1; i++) {
      for(int j=0; j<B+1; j++) {
        for(int k=0; k<C+1; k++) {
          if(X == 500*i + 100*j + 50*k) {
            c++;
          }
        }
      }
    }
   System.out.println(c);
  }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1000000 + 10;
int n;
ll a[maxn];

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    sort(a, a + n);
    int x, y;
    bool fg1 = false, fg2 = false;
    for(int i = n-1; i > 0; i--)
    {
        if(a[i] == a[i-1])
        {
            x = i;
            fg1 = true;
            break;
        }
    }
    if(fg1)
    {
        for(int i = n-1; i > 0; i--)
        {
            if(a[i] == a[i-1] && i != x && i != (x-1))
            {
                y = i;
                fg2 = true;
                break;
            }
        }
    }
    if(fg1 && fg2)
    {
        ll ans = a[x] * a[y];
        printf("%lld\n", ans);
    }
    else printf("0\n");
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
 
long long func(long long x,long long y){
    if(y == 0)return 1;
    else if(y % 2 == 0){
        return func(x*x%1000000007,y/2);
    }else{
        return x*func(x,y-1)%1000000007;
    }
}
 
int main(){
    int m,n;
 
    scanf("%d %d",&m,&n);
 
    printf("%lld\n",func(m,n)%1000000007);
}


Measured memory_bytes: 2752
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <bitset>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-6
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FDR(i,a,n) for(int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mdsad
# define rch p<<1|1,mdsad+1,r
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline int Scan() {
     int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=100005;
//Code begin...

char s[2][55];
int sta[N], pos;
LL ans;

int main ()
{
    int n;
    scanf("%d",&n);
    FOR(i,0,1) scanf("%s",s[i]+1);
    int now=1;
    while (now<=n) {
        if (s[0][now]==s[1][now]) sta[++pos]=1, ++now;
        else sta[++pos]=2, now+=2;
    }
    FOR(i,1,pos) {
        if (i==1) {
            if (sta[i]==1) ans=3;
            else ans=6;
        }
        else {
            if (sta[i]==1&&sta[i-1]==1) ans=ans*2%MOD;
            else if (sta[i]==1&&sta[i-1]==2) ans=ans;
            else if (sta[i]==2&&sta[i-1]==1) ans=ans*2%MOD;
            else ans=ans*3%MOD;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int d, n;
  n = 26;
  cin >> d;
  vi c(n);
  rep(i, n) cin >> c[i];
  vvi s(d, vi(n));
  rep(i, d) rep(j, n) cin >> s[i][j];
  ll sc = 0;
  vi l(n);
  rep(i, d) {
    vl g(n);
    rep(j, n) {
      g[j] = s[i][j];
      rep(k, n) {
        if (j == k) {
        } else {
          g[j] += (ll)c[k] * (i - l[k]);
        }
      }
    }
    int mi = 0;
    ll mx = g[0];
    rep(j, n) {
      if (mx < g[j]) {
        mx = g[j];
        mi = j;
      }
    }
    sc += mx;
    l[mi] = 0;
    cout << mi + 1 << endl;
  }
  dump(sc);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

N = int(input())
lstA = []
line = input()
for s in line.split():
    lstA.append(int(s))

cnt = 0
success = True
while success:
    lstB = []
    for x in lstA:
        if x % 2 == 0:
            lstB.append(x // 2)
        else:
            success = False
            break
    if success:
        lstA = lstB
        cnt += 1
print(cnt)


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

int main(){
	int x;
	int y;
	cin >> x >> y;
	if (x > y){
		cout << "a > b" << endl;
	}
	else if (x == y){
		cout << "a == b" << endl;
	}
	else{
		cout << "a < b" << endl;
	}
	return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<array<int, 2>> v(m);
    if (n & 1) {
        for (int i = 0; i < m; i++) v[i] = {i, n-i-1};
        for (int i = 0; i < m; i++) {
            cout << v[i][0]+1 << " " << v[i][1]+1 << "\n";
        }
    } else {
        int c = 0;
        for (int i = 1; i * 2 <= n / 2; i++) {
            v[i-1][0] = 1-i, v[i-1][1] = i;
            c = i;
            if (i == m) break;
        }
        for (int i = c+1; i <= m; i++) {
            v[i-1][0] = -i, v[i-1][1] = i;
        }
        for (int i = 0; i < m; i++) {
            v[i][0] = (v[i][0] + n) % n;
            v[i][1] = (v[i][1] + n) % n;
            cout << v[i][0]+1 << " " << v[i][1]+1 << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int32_t main()
{
	fastIO
	inp_out();
	int n, k; 
	cin  >> n >> k; 
	vi a(n); 
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i]; 
	}

	while(k--)
	{
		vi pre(n + 1);
		bool done = true; 
		for(int i = 0; i < n; ++i)
		{
			pre[max(0ll, i - a[i])]++;
			pre[min(i + a[i] + 1, n)]--; 
		} 

		a[0] = pre[0]; 
		if(a[0] != n)
			done = false; 

		for(int i = 1; i < n; ++i)
		{
			pre[i] += pre[i - 1]; 
			a[i] = pre[i]; 
			if(a[i] != n)
				done = false; 
		}

		if(done)
			break; 

	}


	for(int i = 0; i < n; ++i)
		cout <<  a[i] << " "; 

	return 0;
}

Measured memory_bytes: 6340
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  int A,B;
  cin >> A >> B;
  if(B%A==0) print(A+B);
  else print(B-A);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000009
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int a[3],ans=mod;
int b[]={0,1,2};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    for (int i=0;i<3;i++) {
        cin>>a[i];
    }
    do {
        ans = min(ans,abs(a[b[1]]-a[b[0]])+abs(a[b[2]]-a[b[1]]));
    }while(next_permutation(b,b+3));
    cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  map<string, string> mp = {{"Sunny", "Cloudy"},
                            {"Cloudy", "Rainy"},
                            {"Rainy", "Sunny"}};
  cout << mp[s] << endk;
  return 0;
}


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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

const int MAX_K = 8;

int k, r[MAX_K], c[MAX_K];

bool killed[8][8];
int perm[8];

void update_killed(int, int);
void print_board();

int main() {
    cin >> k;
    REP(i, k) cin >> r[i] >> c[i];

    REP(i, 8) perm[i] = i;
    do {
        bool is_ok = true;
        REP(i, k) {
            if (perm[r[i]] != c[i]) is_ok = false;
        }

        if (is_ok == false) continue;

        REP(i, 8) {
            REP(j, 8) killed[i][j] = false;
        }

        REP(i, 8) {
            if (killed[i][perm[i]]) {
                is_ok = false;
                break;
            }

            update_killed(i, perm[i]);
        }

        if (is_ok == false) continue;
        print_board();
        break;
    } while (next_permutation(perm, perm + 8));
    return 0;
}

void update_killed(int r, int c) {
    REP(i, 8) {
        killed[r][i] = 1;
        killed[i][c] = 1;
        if (r-i >= 0 && c-i >= 0) killed[r-i][c-i] = 1;
        if (r-i >= 0 && c+i <  8) killed[r-i][c+i] = 1;
        if (r+i <  8 && c-i >= 0) killed[r+i][c-i] = 1;
        if (r+i <  8 && c+i <  8) killed[r+i][c+i] = 1;
    }
    return;
}

void print_board() {
    REP(i, 8) {
        REP(j, 8) {
            if (perm[i] == j) printf("Q");
            else printf(".");
        }
        printf("\n");
    }
    return;
}


Measured memory_bytes: 3088
rect_num = 0
diam_num = 0

while True:
    try:
        a,b,c = map(int, input().split(','))
        if a**2 + b**2 == c**2:
            rect_num += 1
        elif a == b:
            diam_num += 1
    except EOFError:
        break

print(rect_num)
print(diam_num)


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define P 1000000007
#define N_MAX 100003
typedef long long int ll;
using namespace std;
ll inv[N_MAX+1];
ll cinv[N_MAX+1];
ll fact[N_MAX+1];
ll finv[N_MAX+1];

void init(){
    cinv[0] = fact[0] = inv[0] = fact[1] = cinv[1] = inv[1] = 1;
    finv[0] = finv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
      fact[i] = (fact[i-1]*i)%P;
      inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
      cinv[i] = ((cinv[i-1]*i)%P + fact[i-1])%P;
      finv[i] = (finv[i-1]*inv[i])%P;
    }
}

int main(int argc, char const *argv[]) {
  init();
  ll N, ans=0;
  std::cin >> N;
  std::vector<ll> A(N);
  range(i, N) std::cin >> A[i];
  ll l, r;
  range(i, N){
    l = (cinv[i+1]*finv[i+1])%P;
    r = (cinv[N-i]*finv[N-i])%P;
    ans =  (ans+(A[i]*((l + r)%P + 1000000006)%P)%P)%P;
    //std::cout << ((((l + r)%P + 1000000006)%P)*fact[N])%P << '\n';
  }
  ans = (ans*fact[N])%P;
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4224
use std::cmp::{min, max};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn solve(n: usize, k: usize, xs: Vec<i32>) -> i32 {
    let dist = |x: i32, y: i32| {
        let l = max(-x,0);
        let r = max(y,0);

        l + r + min(l,r)
    };

    (0..n-k+1).map(|i| dist(xs[i], xs[i+k-1])).min().unwrap_or(0)
}

fn main() {
    input!{
        n: usize,
        k: usize,
        xs: [i32; n],
    }

    println!("{}", solve(n, k, xs.to_vec()));
}


Measured memory_bytes: 6396
#include <stdio.h>
int main()
{

int array[10000];
int key[10000];
int i,j,k,N,M,count=0;

scanf("%d", &N);
for(i=0;i<N;i++) {
scanf("%d",&array[i]);
}
scanf("%d", &M);
for(j=0;j<M;j++) {
scanf("%d",&key[j]);
}
for (k=0; k<M;k++){
for(i=0;i<N;i++){
if (array[i] == key[k]){
count++;
break;
}
}
}
printf("%d\n",count);
return 0;
}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
            var A = array[0];
            var B = array[1];
            var K = array[2];

            if (A >= K)
            {
                A -= K;
                K = 0;
            }
            else
            {
                K -= A;
                A = 0;
            }

            if (B >= K)
            {
                B -= K;
                K = 0;
            }
            else
            {
                K -= B;
                B = 0;
            }

            Console.WriteLine(A + " " + B);
        }
    }
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int N; cin >> N;
  vi x(N), y(N), h(N); REP(i,N) cin >> x[i] >> y[i] >> h[i];

  int H, Cx, Cy;
  int is;
  REP(i,N) {
    if (h[i] != 0) {
      is = i;
    }
  }

  REP(Cx,101) {
    REP(Cy,101) {
      bool flag = true;
      H = h[is]+abs(x[is]-Cx)+abs(y[is]-Cy);
      REP(i,N) {
        if (h[i]==0) {
          if (H-abs(x[i]-Cx)-abs(y[i]-Cy)>0) {
            flag = false;
            break;
          }
        }
        else {
          if (h[i]!=H-abs(x[i]-Cx)-abs(y[i]-Cy)) {
            flag = false;
            break;
          }
        }
      }
      if (flag == true) {
        printf("%d %d %d\n",Cx,Cy,H);
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gaus(int x){
  if(x %10 ==0){
    return x;
  }
  else{
    return x +(10-x%10);
  }
}
int abs(int x, int y) {
  if (x < y) {
    return y-x;
  }
  else{
    return x-y;
  }
}
int main(){
  vector<int> unko(5);
  for(int i=0;i<5;i++){
    cin>>unko.at(i);
  }
  int last =unko.at(4);
  for(int i=0;i<4;i++){
    for(int j =i+1; j<5;j++){
      if(min(unko.at(i)%10 ,unko.at(j)%10) != 0){
        if(min(unko.at(i)%10 ,unko.at(j)%10)<=last){
          last = min(unko.at(i)%10 ,unko.at(j)%10);
        }
      }
    }
  }
  int answer =0;
  for(int i=0;i<5;i++){
    answer += gaus(unko.at(i));
  }
  if(unko.at(0)%10 ==0 && unko.at(1)%10 == 0 && unko.at(2)%10 ==0 && unko.at(3)%10 ==0 && unko.at(4)%10 ==0){
    cout <<answer<<endl;
  }
  else{
    cout<<answer-10 +last<<endl;
  }
}

Measured memory_bytes: 256
k = int(input()) - 1
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(li[k])


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N,K;
    cin >> N >> K;
    int cnt[N]={};
    rep(i,K){
        int d;
        cin >> d;
        int A[d];
        rep(j,d){
            cin >> A[j];
            A[j]--;
        }
        rep(j,d) cnt[A[j]]++;
    }
    int ans=0;
    rep(i,N) if(cnt[i]==0) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli n;
vector<lli>six,nine;

lli dp[100100];
bool vis[100100];

lli func(lli now){
	if(DEBUG)cout<<"now="<<now<<endl;
	if(now<0)return INF;
	if(vis[now])return dp[now];
	vis[now]=true;
	if(now<6){
		return dp[now]=now;
	}

	lli rtn = INF;
	for(lli i=six.size()-1;i>=0;i--){
		rtn = min(rtn,func(now-six[i]));
	}
	for(lli i=nine.size()-1;i>=0;i--){
		rtn = min(rtn,func(now-nine[i]));
	}
	return dp[now]=rtn+1;
}

signed main(){

	cin>>n;

	lli s=6,nn=9;

	REP(i,0,100100)dp[i]=INF;
	dp[0]=0;

	while(s<1e7){
		six.push_back(s);
		s*=6;
	}
	while(nn<1e7){
		nine.push_back(nn);
		nn*=9;
	}

	cout<<func(n)<<endl;
 
	return 0;
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int r,g,b;

main() {
    cin >> r >> g >> b;
    if ((r*100+g*10+b)%4) ct("NO")
    else ct("YES")
}


Measured memory_bytes: 256
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
C = sum(A, [])
#print(C)
#8通り調べればよい
for i in range(N):
    for j in range(len(C)):
        if b[i] == C[j]:
            C[j] = 0


flag = False
#print(C)
#
if C[0] == C[1]==C[2]:
    flag = True
if C[3] == C[4]==C[5]:
    flag = True
if C[6] == C[7]==C[8]:
    flag = True
#
if C[0] == C[3]==C[6]:
    flag = True
if C[1] == C[4]==C[7]:
    flag = True
if C[2] == C[5]==C[8]:
    flag = True
#
if C[0] == C[4]==C[8]:
    flag = True
if C[2] == C[4]==C[6]:
    flag = True

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 101
int main(){
  int i,j,k,n,a,b,A[MAX],B[MAX][MAX];

  scanf("%d",&n);
  for(i=1; i<=n; i++)
    scanf("%d%d",&A[i-1],&A[i]);
 
  for(i=1; i<=n; i++)
    B[i][i] = 0;
 
  for(j=2; j<=n; j++){

    for(i=1; i<=n-j+1; i++){
      a = i + j -1;
      B[i][a] = 1000000;

      for(k=i; k<=a-1; k++){
	b = B[i][k] + B[k+1][a] + A[i-1]*A[k]*A[a];
	if(B[i][a] >= b)
	  B[i][a] = b;
      }
    }
  }
 
  printf("%d\n",B[1][n]);
   
  return 0;
}



Measured memory_bytes: 2052
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		List<String> S = new ArrayList<String>();
		List<Integer> P = new ArrayList<Integer>();
		List<String> tmp = new ArrayList<String>();
		Map<String,Integer> namePointIndex = new HashMap<>();


		for(int i = 0; i< N;i++) {
			String name=sc.next();
			Integer point = sc.nextInt();
			S.add(name);
			P.add(point);
			namePointIndex.put(name + String.valueOf(point), i+1);
		}

		Collections.sort(P,Collections.reverseOrder());
		Collections.sort(S);

		for(String name : S) {
			for(Integer point : P) {
				String key = name + String.valueOf(point);
				if(namePointIndex.containsKey(key) && !tmp.contains(key)) {
					tmp.add(key);
					System.out.println(namePointIndex.get(key));
				}
			}
		}

	}

}

Measured memory_bytes: 24148
#include<iostream>
#include<vector>
#include<list>
using namespace std;

int main(){
    int n, q, a, b, c;
    cin >> n >> q;

    vector<list<int>> v(n);

    for(int i = 0; i < q; i++){
        cin >> a;
        if(a == 0){
            cin >> b >> c;
            v[b].push_back(c);
        }else if(a == 1){
            cin >> b;
            list<int>::iterator it = v[b].begin();
            if(it != v[b].end())    cout << *it;

            while(++it != v[b].end()){
                cout << " " << *it;
            }
            cout << endl;
        }else if(a == 2){
            cin >> b >> c;
            v[c].splice(v[c].end(), v[b]);
        }
    }
    return 0;
}



Measured memory_bytes: 18648
#include<iostream>
#include<cstdio>

using namespace std;
typedef long long ll;
const int N = 100010;
int p[N];

int main()
{
	int n;
	scanf("%d", &n);
	
	ll sum = 0;
	for(int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		sum += x;
		p[x]++;
	}
	
	int T;
	scanf("%d", &T);
	while(T--)
	{
		int b, c;
		scanf("%d%d", &b, &c);
		sum += (ll)(c - b) * p[b];
		p[c] += p[b];
		p[b] = 0;
		printf("%lld\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 4104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,n) for(int i=a;i<n;i++)
#define pb(v) push_back(v)

int main() {
	//code
	
     ios_base::sync_with_stdio(false); 
     cin.tie(NULL);
      int n,k;
      cin>>n>>k;
      int a[n];
      
      f(i,0,n)
      cin>>a[i];
      int dp[n+k+1];
      dp[0]=0;
      dp[1]=abs(a[1]-a[0]);
      for(int i=2;i<k;i++)
      {
      	dp[i]=abs(a[i]-a[0]);
	  }
      for(int i=k;i<n;i++)
      {   vector<int>v;
            for(int j=i-k;j<i;j++)
            {    // cout<<dp[j]<<"d"<<dp[j]+abs(a[i]-a[j])<<"\n"<<endl;
            	v.pb(dp[j]+abs(a[i]-a[j]));
			}
	         
          dp[i]=*min_element(v.begin(),v.end());
        // cout<<dp[i]<<"sa";
     }
      cout<<dp[n-1]<<endl;
 return 0;

}



Measured memory_bytes: 1024
import math
A, B, X = list(map(int, input().split()))

if X > (A*A*B)/2:
    #Trapezoid
    C = (X/A*2)/A-B
    print(math.degrees(math.atan((B-C)/A)))

else:
    #Triangle
    H = (X/A*2)/B
    print(math.degrees(math.atan(B/H)))


Measured memory_bytes: 3188
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int x[200001],y[200001];
int main()
{
    int n;
    scanf("%d",&n);
    int mn=1000000000,mx=1;
    for (int i=1;i<=n;++i)
    {
        scanf("%d%d",x+i,y+i);
        if (x[i]>y[i])
            swap(x[i],y[i]);
        mn=min(mn,x[i]);
        mx=max(mx,y[i]);
    }
    if (mn==mx)
    {
        printf("0\n");
        return 0;
    }
    long long ans;
    {
        int mxl=1,mnr=1000000000;
        for (int i=1;i<=n;++i)
        {
            mxl=max(mxl,x[i]);
            mnr=min(mnr,y[i]);
        }
        ans=(long long)(mxl-mn)*(mx-mnr);
    }
    int both=0;
    for (int i=1;i<=n;++i)
        if (x[i]==mn&&y[i]==mx)
            ++both;
    if (both)
    {
        int tmp1=1000000000,tmp2=1;
        for (int i=1;i<=n;++i)
        {
            if (y[i]==mx&&x[i]!=mn)
                tmp1=min(tmp1,x[i]);
            else
                tmp1=min(tmp1,y[i]);
            if (x[i]==mn&&y[i]!=mx)
                tmp2=max(tmp2,y[i]);
            else
                tmp2=max(tmp2,x[i]);
        }
        ans=min(ans,(long long)(mx-mn)*min(mx-tmp1,tmp2-mn));
    }
    else
    {
        vector<pair<int,int>> out;
        int mni=1000000000,mxi=0;
        for (int i=1;i<=n;++i)
        {
            if (x[i]==mn)
            {
                mni=min(mni,y[i]);
                mxi=max(mxi,y[i]);
            }
            else if (y[i]==mx)
            {
                mni=min(mni,x[i]);
                mxi=max(mxi,x[i]);
            }
        }
        for (int i=1;i<=n;++i)
            if (x[i]!=mn&&y[i]!=mx)
            {
                if (y[i]<mni)
                    mni=y[i];
                else if (x[i]>mxi)
                    mxi=x[i];
            }
        for (int i=1;i<=n;++i)
            if (x[i]!=mn&&y[i]!=mx&&x[i]<mni&&y[i]>mxi)
                out.push_back(make_pair(x[i],y[i]));
        sort(out.begin(),out.end());
        int right=mxi;
        for (size_t i=0;i<out.size();++i)
        {
            ans=min(ans,(long long)(mx-mn)*(right-out[i].first));
            right=max(right,out[i].second);
        }
        ans=min(ans,(long long)(mx-mn)*(right-mni));
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int N = sc.nextInt();
		int max =H;
		if (max<W) {
			max = W;
		}
		if (N%max==0) {
			System.out.println(N/max);
		} else {
			System.out.println(N/max+1);
		}
	}
}

Measured memory_bytes: 21588
import sys
input = sys.stdin.buffer.readline

def main():
    N,K = map(int,input().split())
    a = list(map(int,input().split()))
    
    cum = [0]
    pluscum = [0]
    
    for i in range(N):
        cum.append(cum[-1]+a[i])
        if a[i] > 0:
            pluscum.append(pluscum[-1]+a[i])
        else:
            pluscum.append(pluscum[-1])

    ans = -(10**15)
    for i in range(N-K+1):
        ret = pluscum[i]+(pluscum[-1]-pluscum[i+K])+max((cum[i+K]-cum[i]),0)
        ans = max(ans,ret)
    
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 59504
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,ll>;
using Map = map<char,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll MOD=1000000007;
int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    ll ans=0;
    for(ll i=K;i<=N+1;i++){
        ans+=((N-i+1)%MOD)*i+1;
        ans%=MOD
    ;}
    cout<<ans<<endl;
    
return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define sz(a) (int)(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,c) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n)	for(int i=0;i<n;i++)
#define present(c,x) (c.find(x)!=c.end()) //for set/map etc.
#define cpresent(c,x) (find(all(c),x)!=c.end())
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pair<int,int>> vp;
int N=100001;
int mod=1e9+7;
int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
bool comp(int a, int b) 
{ 
    return (a < b); 
} 

void solve()
{
	int n;
	cin>>n;
	vi v(n);
	int x=0;
	fr(i,n){cin>>v[i];x=x^v[i];}
	fr(i,n)
	{
		cout<<(x^v[i])<<" ";
	}



}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	// int t;
	// cin>>t;
	// while(t--)
	// {
	// 	solve();
	// 	cout<<endl;
	// }
	solve();
	return 0;
	
}



Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
main()
{
  int n;
  cin>>n;
  if(n<10) cout<<n;
  else if(n<100) cout<<9;
  else if(n<1000) cout<<9+(n-99);
  else if(n<10000) cout<<909;
  else if(n<100000) cout<<909+(n-9999);
  else cout<<90909;
}

Measured memory_bytes: 256
from collections import deque
N,u,v = map(int,input().split())#u=高橋 v=青木
u -= 1
v -= 1 #0-indexed
cango = [[] for i in range(N)]
#辺入力
for i in range(N-1):
    A,B = map(int,input().split())
    cango[A-1].append(B-1)#0-indexed
    cango[B-1].append(A-1)
#BFS
pres = [-1]*N#直前に来た頂点 
fromaoki = [-1]*N
fromaoki[v] = 0
went = [False]*N
queue =deque()#append,popleft
queue.append([v,0])#[場所,前の頂点]
went[v] = True#青木スタート
while queue:
    curpos,prespos = queue.popleft()
    pres[curpos] = prespos
    for togo in cango[curpos]:
        if not went[togo]:
            went[togo] = True
            fromaoki[togo] = fromaoki[curpos]+1
            queue.append([togo,curpos])
#高橋-青木ルート検索
route=[]#[高橋(u)-ルート-青木(v)]こともある
tadori = u
while tadori!=v:
    route.append(tadori)
    tadori = pres[tadori]
route.append(v)

nekko = route[len(route)//2-1] #高橋が行けるギリギリの場所
cantgo = route[len(route)//2]
cango[nekko].remove(cantgo)
cango[cantgo].remove(nekko)

#根っこからの長さ探索
def BFS(start):
    dist = [-1]*N
    dist[start] = 0
    went = [False]*N
    queue =deque()#append,popleft
    queue.append(start)
    went[start] = True
    while queue:
        curpos = queue.popleft()
        for togo in cango[curpos]:
            if not went[togo]:
                went[togo] = True
                dist[togo] = dist[curpos]+1
                queue.append(togo)
    return dist

fromnekko = BFS(nekko)
maxdist = max(fromnekko)
maxpos = fromnekko.index(maxdist)
print(fromaoki[maxpos]-1)

Measured memory_bytes: 69612
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    if(a>=k){
        cout<<a-k<<" "<<b<<endl;
    }else{
        ll c = b-(k-a);
        cout<<0<<" "<<((c<0)?0:c);
    }
    cout<<endl;
    return 0;
}

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

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

    if(a%2 == 0 || b%2 == 0 || c%2 == 0){
        cout << 0 << endl;
    }else{
        cout << ((a+b+c)-min(a,min(b,c))-max(a,max(b,c)))*min(a,min(b,c)) << endl;
    }

    return 0;
}

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

using namespace std;

constexpr int MAX = 100000;

vector<int> G[MAX], LG[MAX];
bool visitedv[MAX], visitedl[MAX];

void dfsv(int);

void dfsl(int l)
{
    if (visitedl[l]) return;
    visitedl[l] = 1;

    for (const auto& v : G[l]) {
        dfsv(v);
    }
}

void dfsv(int v)
{
    if (visitedv[v]) return;
    visitedv[v] = 1;

    for (const auto& l : LG[v]) {
        dfsl(l);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;

    for (int i = 0; i < N; ++i) {
        int K;
        cin >> K;
        for (int j = 0; j < K; ++j) {
            int L;
            cin >> L; --L;           
            LG[i].emplace_back(L);
            G[L].emplace_back(i);
        }
    }
    
    dfsv(0);
    
    bool res = 1;
    for (int i = 0; i < N; i++) {
        res &= visitedv[i];
    }

    cout << (res ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 8704