akhauriyash/Code-Regression huggingface dataset:
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define pool(i,a,b) for(int i=a;i>=b;i--)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

vector<set<int>> g;
vb vis;

int dfs(int u)
{
  int ans=1;
  if(vis[u])
    return 0;
  vis[u]=1;
  for(auto v:g[u])
  {
    if(!vis[v])
      ans+=dfs(v);
  }

  return ans;
}



void solve()
{
  int n,m;
  cin>>n>>m;
  g=vector<set<int>>(n+1);
  vis=vb(n+1,false);
  rep(i,m)
  {
    int u,v;
    cin>>u>>v;
    g[u].insert(v);
    g[v].insert(u);
  }

  int ans=0;
  for(int i=1;i<=n;i++)
  {
    if(!vis[i])
    {
      ans=max(ans,dfs(i));
    }
  }

  cout<<ans<<endl;

} 

int main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  ios::sync_with_stdio(false);
  cin.tie(0);

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

  return 0;
}


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

#define rep(i,k,n) for(int i = k; i < n; i++)  
#define repp(i,a,n,k) for(typeof(a) i=a;i!=n;i+=k)

#define int long long
#define all(a) a.begin(),a.end()       

#define pb push_back
typedef long long ll; 
typedef pair<int, int> ii;
typedef pair<int,ii > iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<char> vchar;

#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)

#define ff first
#define ss second

#define lb lower_bound
#define ub upper_bound
#define me max_element

#define INF 1000000000
//#define mod 998244353
#define mod 1000000007
#define endl "\n"


  


int modPow(int a, int b);
int modInv(int a);     


vi gr[5005];
bool vis[5005];
int p[5005],c[5005];

vi xx;
bool sig =0;

int dfs(int n, int cost){
    if(vis[n])return {cost};
    vis[n]=1;

    xx.pb(c[n]);
    cost += c[n];
    if(gr[n][0]==n){
        sig = 1;
        return (cost);
    }
    return dfs(gr[n][0], cost);

}



void solve(){

    int n,k;
    cin >> n >> k;
    int waha = k;
    
    rep(i,0,n)cin >> p[i];
    rep(i,1,n+1)cin >> c[i];

    rep(i,0,n){
        gr[i+1].pb(p[i]);
    }
    int ans = -1e18;

    rep(i,1,n+1){

        xx.clear();
        sig = 0;

        int temp = dfs(i,0);

        int anss =0;
        if(sig==1){
                
            ans = max({ans, temp, temp*k});
            continue;
        }

        if(xx.size()>0){
            
            anss += (k/xx.size())*temp;
            anss-=temp;

            int left = xx.size();
            left = k%xx.size();
            
            int add =0;
            if((k/xx.size()) == 0){
                add = -1e18;
                anss = 0;
            }
            if(k/xx.size()==1){
                add = -1e18;
            }
        
            
            rep(j,0,xx.size()){
                int sum = 0;
                rep(it,0,left + ((k>=xx.size()) * xx.size())){
                    sum+=xx[(j+it)%xx.size()];
                    add = max(add,sum);
                }
            }
            
            int add2 = -1e18;
            rep(j,0,xx.size()){
                int sum = 0;
                rep(it,0,min((ll)xx.size(),waha)){
                    sum+=xx[(j+it)%xx.size()];
                    add2 = max(add2, sum);
                }
            }

            anss += add;
            ans = max({ans,anss, add2});

        }
    }
    cout << ans <<endl;



}


// Recheck if it is 2^9 or 10^9 
//check for long long overflow
//while adding and subs check if mod becomes -ve
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;




signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed;
    //cout <<setprecision(6);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
   // int test=1; cin >> test; while(test--)
    solve();
}

int modPow(int a, int b){
    if(b==0)return 1;
    if(b%2==0){
        int x = a*a;
        x%=mod;
        return modPow(x,b/2);
    }
    return (a*modPow(a,b-1))%mod;
}


int modInv(int a){
    return modPow(a,mod-2);
}





Measured memory_bytes: 4116
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

int n, m, d;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n >> m >> d;
    

    if(d == 0){
        printf("%.9f\n", (double)(m-1)/n);
    }else{
        int x = (n-1) * 2;
        x -= (d - 1) * 2;
        double ans = (double)x / (n*n) * (m-1);
        
        printf("%.9f\n", ans);
    }

}


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

using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	set<int> s = { A,B,C };

	if (s.size() == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 764
# https://atcoder.jp/contests/abc092/tasks/arc093_b

A, B = map(int, input().split())


# 仮に100*100にサイズを固定したとする
# 上半分を全部白に、下半分を全部黒にすれば必ず白領域黒領域1個ずつ作れる
# 50*100の領域に、違う色のマスは最大25*50敷き詰められるから500という制約ならば余裕で敷き詰められる
# 上半分に関してはB個-1個黒を敷き詰めれば良くて、下半分に関してはA-1個白を敷き詰めれば良い。(デフォは上がすべて白)

# 上半分の用意
n_B = B - 1
n_A = A - 1
print(100, 100)
for _ in range(25):
    out = []
    for i in range(100):
        if i % 2 == 0 and n_B > 0:
            out.append('#')
            n_B -= 1
        else:
            out.append('.')
    print(''.join(out))
    print('.' * 100)

# 下半分
for _ in range(25):
    out = []
    print('#' * 100)
    for i in range(100):
        if i % 2 == 0 and n_A > 0:
            out.append('.')
            n_A -= 1
        else:
            out.append('#')
    print(''.join(out))


Measured memory_bytes: 39024
import copy

def show(C):
    for i in range(len(C)):
        if i :
            print(' ', end = '')
        print(C[i], end = '')
    print()

def bubbleSort(C, N):
    for i in range(N):
        for j in range(N-1, i, -1):
            if C[j][1] < C[j-1][1]:
                C[j], C[j-1] = C[j-1], C[j]
    show(C)

def SelectionSort(D, N):
    for i in range(N):
        min_j = i
        for j in range(i, N):
            if D[j][1] < D[min_j][1]:
                min_j = j
        D[i], D[min_j] = D[min_j], D[i]
    show(D)

N = int(input())
C = [i for i in input().split()]
D = copy.copy(C)

bubbleSort(C, N)
print('Stable')
SelectionSort(D, N)
if C == D:
    print('Stable')
else:
    print('Not stable')



Measured memory_bytes: 6348
q = []
for i in range(100):
    if i%2 == 0: q.append("#")
    else: q.append(".")
while True:
    alm = 0
    a,b = map(int,input().split())
    if a + b == 0:
        break
    for i in range(a):
        for j in range(b):
            if (i + j)%2 == 0:
                print("#",end="")
            else:
                print(".",end="")
        print("")
    print("")


Measured memory_bytes: 7020
s=str(input())

n=len(s)
if n%2==0:
    s_1=list(s[:n//2])
    s_2=list(s[n//2:])
    s_2=s_2[::-1]

else:
    s_1=list(s[:n//2])
    s_2=list(s[n//2+1:])
    s_2=s_2[::-1]

cnt=0
for i in range(n//2):
    if s_1[i]==s_2[i]:
        continue
    else:
        cnt+=1

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
int a[10005];
int main(void){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i];
		n-=a[i];
	}
	cout<<max(n,-1)<<endl;
	    
}


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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n;
  cin >> n;

  vector<int> a(1<<n), b;
  for (int i = 0; i < (1<<n); ++i) {
    cin >> a[i];
  }

  const int inf = 1e9 + 5;
  sort(a.begin(), a.end());
  b.push_back(a.back());
  a.back() = inf;

  bool poss = 1;
  for (int i = 0; i < n; ++i) {
    sort(b.begin(), b.end());
    for (int j = (1<<i) - 1, r = (int)a.size() - 1; j >= 0; --j) {
      while (r >= 0 && a[r] >= b[j]) --r;
      if (r >= 0) {
        b.push_back(a[r]);
        a[r] = inf;
      }
    }
    if ((int)b.size() != (1<<(i+1))) poss = 0;
  }

  if (poss) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 2424
#include<stdio.h>

int max(int a,int b){
  if(a>b){return a;}
  return b;
}

int min(int a,int b){
  if(a<b){return a;}
  return b;
}

int isvalid(char s[],int l){
  int i,a=0,b=0;
  for(i=0;i<l;i++){
    if(s[i]=='A'){a++;}
    else{b++;}
    if(i==l-1){break;}
    if(max(a,b)==5 && min(a,b)<=3){return 0;}
  }
  return 1;
}

int main(){
  int i,j,a,b,na,nb;
  char s[16]={0};
  scanf("%d%d",&a,&b);
  for(i=0;i<(1<<(a+b));i++){
    na=0;nb=0;
    for(j=0;j<(a+b);j++){
      if((i&(1<<((a+b)-1-j)))==0){s[j]='A';na++;}
      else{s[j]='B';nb++;}
    }
    if(na!=a||nb!=b){continue;}
    if(isvalid(s,a+b)==1){
      printf("%s\n",s);
    }
  }
  return 0;
}



Measured memory_bytes: 2080
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

l,r,d = inm()
sm = 0
for i in range(l,r+1):
    if i%d==0:
        sm += 1
print(sm)


Measured memory_bytes: 61980
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
using namespace std;

int JOI,IOI;
string s;

int main(){
  while(cin>>s){
    int x=0;
    int y=0;
    for(int i=0,l=s.size();i<l-2;i++){
      if(s.substr(i,3)=="JOI"){x++;}
      if(s.substr(i,3)=="IOI"){y++;}
    }
    cout<<x<<"\n"<<y<<"\n";
  }
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int a, b;
    cin>>a>>b;
    int ans = (b - 1)/(a - 1);
    if((b-1)%(a-1) != 0) ans++;
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int x = 0, y = 0, side = 0, num = 0, index = 1;
  
  scanf("%d", &side);
  while (side != 0) {
    printf("Case %d:\n", index);
    index++;
    y = 0;
    while (y != side) {
      x = 0;
      while (x != side) {
	if (side > x + y)
	  num = 1 + (y + x + 1) % 2 * ((y + x + 1) * (y + x) / 2 + x) + (y + x + 2) % 2 * ((y + x + 1) * (y + x) / 2 + y);
	else
	  num = side * side - (y + x + 1) % 2 * ((side * 2 - (y + x + 1)) * (side * 2 - (y + x + 1) - 1) / 2 + side - (x + 1)) - (y + x + 2) % 2 * ((side * 2 - (y + x + 1)) * (side * 2 - (y + x + 1) - 1) / 2 + side - (y + 1));
	x++;
	if (num / 10 == 0)
	  printf("  %d", num);
	else
	  printf(" %d", num);
      }
      y++;
      putchar('\n');
    }
    scanf("%d", &side);
  }
  
  return(0);
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

signed main(){
    int n; cin >> n;
    int diffs = 0;
    reps(i,1,n){
        int a; cin >> a;
        if(a != i) diffs++;
    }
    cout << (diffs <= 2 ? "YES" : "NO") << endl;
}

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

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

    vector<int> a(n + 2);
    for (int i = 0; i < n; i++) cin >> a[i];

    sort(a.rbegin(), a.rend());

    vector<int> t;
    for (int i = 1; i < a.size(); i++) {
        if (a[i] == a[i - 1]) {
            t.push_back(a[i++]);
        }
    }
    cout << 1LL * t[0] * t[1] << endl;

    return 0;
}


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

typedef long long lint;
typedef pair<lint, int> Pr;

const lint INF = 1ll << 56;

int n, m, c;
vector<Pr> g[100000];
lint dsum = 0ll;

lint solve()
{
	lint res = INF;
	
	vector<lint> dist(n, INF);
	dist[0] = 0ll;
	vector<bool> vis(n, false);
	
	priority_queue<Pr, vector<Pr>, greater<Pr>> pq;
	pq.push(Pr(0ll, 0));
	while (pq.size()){
		int pos = pq.top().second;
		lint sum = pq.top().first;
		pq.pop();
		if (dist[pos] < sum) continue;
		vis[pos] = true;
		
		for (Pr &e : g[pos]){
			int to = e.second;
			lint cost = e.first;
			if (dist[to] > sum + cost){
				dist[to] = sum + cost;
				pq.push(Pr(sum + cost, to));
			}
			if (vis[to]){
				dsum -= cost;
			}
		}
		
		res = min(res, dist[pos] * c + dsum);
	}
	
	return res;
}

int main()
{
	scanf("%d %d %d", &n, &m, &c);
	for (int i = 0; i < m; i++){
		int a, b, d;
		scanf("%d %d %d", &a, &b, &d);
		g[--a].push_back(Pr(d, --b));
		g[b].push_back(Pr(d, a));
		dsum += d;
	}
	
	cout << solve() << endl;
	
	return 0;
}

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

#define rep(i, N) for(int i = 0; i < N; i++)
#define all(v) v.begin(), v.end()

int main(){
	long long N, K;
	cin >> N >> K;
	
	if(N > K){
		cout << 0 << endl;
		return 0;
	}
	
	const long long MOD = 1e9 + 7;

	long long ans = 1;
	rep(i, N){
		ans = (ans * (K - i)) % MOD;
	} 
	cout << ans << endl;
	
}




Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

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

    if(x==7 || x==5 || x==3) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>

int N;
int a[100005];
int main(){
  std::cin>>N;
  for(int i=0;i<N;++i){
    int temp;
    std::cin>>temp;
    ++a[temp];
  }
  
  long long ans=0;
  long long sum=a[0]+a[1];
  for(int i=1;i<99999;++i){
    sum+=a[i+1];
    ans=std::max(ans,sum);
    sum-=a[i-1];
  }
  
  std::cout<<ans<<std::endl;  
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=(a[i]-1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3588
def dfs(a, n, s)
  return (a.inject(:+) == s) ? 1 : 0 if a.size == n

  ans = 0
  (a.empty? ? 0 : a.max + 1).upto(9) do |i|
    ans += dfs(a + [i], n, s)
  end
  ans
end

while true
  n, s = gets.split(' ').map(&:to_i)
  break if n == 0 && s == 0
  puts dfs([], n, s)
end

Measured memory_bytes: 6100
from itertools import combinations

n = int(input())
names = {"M":0, "A":0, "R":0, "C":0, "H":0}
for _ in range(n):
    name = input()
    if name[0] in names.keys():
        names[name[0]] += 1

patterns = list(combinations(names.keys(), 3))

count = 0
for pattern in patterns:
    count += names[pattern[0]] * names[pattern[1]] * names[pattern[2]]

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
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; }

long long n, x;
int main() {
    cin >> n >> x;
    vector<long long> a(n, 0);
    for(int i = 0; i < n; ++i) cin >> a.at(i);

    long long sum = 0;
    for(int left = 0; left < n-1; ++left) {
        if(a.at(left)+a.at(left+1) > x) {
            long long rest = (a.at(left)+a.at(left+1)) - x;
            sum += rest;
            if(rest > a.at(left+1)) {
                a.at(left+1) = 0;
                a.at(left) -= (rest-a.at(left+1));
            }else {
                a.at(left+1) -= rest;
            }
        }
    }
    cout << sum << endl;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long X, long long Y, long long A, long long B, long long C, std::vector<long long> p, std::vector<long long> q, std::vector<long long> r){
    priority_queue<pair<int, int>> que;
    rep(i,0,C) que.push({r[i], 3 * i});
    rep(i,0,A) que.push({p[i], 3 * i + 1});
    rep(i,0,B) que.push({q[i], 3 * i + 2});
    int red = X, green = Y;
    queue<int> nos;
    ll answer = 0;
    while (true) {
        const auto p = que.top();
        que.pop();
        int value = p.first;
        if (p.second % 3 == 0) {
            nos.push(value);
        } else if (p.second % 3 == 1) {
            red--;
            answer += value;
        } else {
            green--;
            answer += value;
        }
        if (red + green == nos.size() || red == 0 || green == 0) break;
    }
    while (!nos.empty()) {
        if (red > 0) red--;
        else green--;
        answer += nos.front();
        nos.pop();
    }
    while (red != 0 || green != 0) {
        const auto p = que.top();
        que.pop();
        int value = p.first;
        if (p.second % 3 == 0) {
            if (red > 0) red--;
            else green--;
            answer += value;
        } else if (p.second % 3 == 1 && red > 0) {
            red--;
            answer += value;
        } else if (p.second %3 == 2 && green > 0) {
            green--;
            answer += value;
        }
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> p(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&p[i]);
    }
    std::vector<long long> q(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&q[i]);
    }
    std::vector<long long> r(C);
    for(int i = 0 ; i < C ; i++){
        scanf("%lld",&r[i]);
    }
    solve(X, Y, A, B, C, std::move(p), std::move(q), std::move(r));
    return 0;
}


Measured memory_bytes: 8688
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int a, b, c, d;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> a >> b >> c >> d;
	if ((a + d - 1) / d >= (c + b - 1) / b)
		cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b;
  while(true){
    cin>>a>>b;
    if(a==0&&b==0){
      break;
    }
    for(int i=0;i<a;i++){
      for(int j=0;j<b;j++){
	if(i==0||i==a-1||j==0||j==b-1){
	  cout<<"#";
	}
	else{
	  cout<<".";
	}
      }
      cout<<"\n";
    }
    cout<<'\n';
  }
  return(0);
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, total = 0;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
        total += A[i];
    }
    int m, p, x;
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> p >> x;
        cout << total + x - A[p - 1] << endl;
    }
}

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


using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    vector <int> a;
    vector <int> b;
    cin >> n;
    for (int i = 2; i<= 30000; i++){
        if (i % 2 == 0){
            a.push_back(i);
        }
        else{
            if (i % 3 == 0){
                a.push_back(i);
            }
            else{
                if (i % 5 ==0){
                    a.push_back(i);
                }
            }
        }
    }
    if (n == 3){
        cout << "2 5 63";
    }
    else {
        int sum = 0;
        for (int i = 0; i < n - 2; i++) {
            b.push_back(a[i]);
            sum += a[i];
        }
        int ost = 0;
        ost = sum % 30;
        ost = (30 - ost) % 30;
        int q = 0;
        int j = 0;
        for (int i = 0; i<30; i++){
            q = i;
            j = 0;
            if (i > ost){
                j = ost + 30 - i;
            }
            else{
                j = ost - i;
            }
            if (((q % 2 == 0) or (q % 5 == 0) or (q % 3 == 0)) and ((j % 2 == 0) or (j % 5 == 0) or (j % 3 == 0))){
                i = 30;
            }
        }
        int r = 30000 - 30;
        b.push_back(r +q);
        b.push_back(r + j);
        for (int i=0; i<b.size(); i++){
            cout << b[i] << ' ';
        }
    }

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define N 100
int m[101][101];


void min(int n,int *p){

  int i,j,k,l;
  for(i=1;i<=n;i++) m[i][i]=0;

  for(l=2;l<=n;l++) {
    
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=100000000;
      
      for(k=i;k<=j-1;k++){
    if(m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]){
      m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
    }
      }
    }
  }
}

    
int main(){

  int i,p[N+1],n;

  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d%d",&p[i-1],&p[i]);

  min(n,p);

  printf("%d\n",m[1][n]);

  return 0;

}
/*
#include<stdio.h>
#define N 100
int m[101][101];
 
 
void min(int n,int *p){
 
  int i,j,k,l;
  for(i=1;i<=n;i++) m[i][i]=0;
 
  for(l=2;l<=n;l++) {
     
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=100000000;
       
      for(k=i;k<=j-1;k++){
    if(m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]){
      m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
    }
      }
    }
  }
}
 
     
int main(){
 
  int i,p[N+1],n;
 
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d%d",&p[i-1],&p[i]);
 
  min(n,p);
 
  printf("%d\n",m[1][n]);
 
  return 0;
 
}
*/



Measured memory_bytes: 2044
def main():
    k, s = map(int, input().split())
    
    ans = 0
    for x in range(k + 1):
        for y in range(k + 1):
            z = s - x - y
            if z >= 0 and z <= k:
                ans += 1
    
    print(ans)
                    

if __name__ == '__main__':  
    main()

Measured memory_bytes: 2940
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    int cnt = 1;
    for(int i=0;i<N-1;i++){
      if(S[i]!=S[i+1]) cnt++;
    }
    cout << cnt <<endl;
    
  	return 0;
}



Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
    int A, B;
    cin >> A, cin >> B;
    int coins = 0;
    if (A > B) {
        coins += A;
        --A;
    } else {
        coins += B;
        --B;
    }
    if (A > B) {
        coins += A;
        --A;
    } else {
        coins += B;
        --B;
    }
    cout << coins << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

int main(){
  int N,M; cin>>N>>M;
  vector < vector <int> > data(M);
  for(int i=0;i<M;i++){
      int k; cin>>k;
      for(int j=0;j<k;j++){
          int s; cin>>s;
          data[i].push_back(s);
      }
  }

  vector <int> p(M);
  for(int i=0;i<M;i++){
      cin>>p[i];
  }


//ll bits = 0;
ll ans = 0;

for(int bits = 0;bits != (1<<N);bits++){
    bool flag = true;
   // cout<<bits<<endl;
    for(int i=0;i<M;i++){
        int save = 0;
        for(int j=0;j<data[i].size();j++){
            int sn = data[i][j];
            int mask = 1<<(sn-1);
            //cout<<mask<<endl;
            //cout<<mask<<endl;
            if((bits & mask) != 0) save++;
        }
        //cout<<bits<<" "<<" "<<i<<" "<<save<<endl;
        if(save % 2 == p[i]) continue;
        else {flag = false;break;}
    }

    if(flag) {ans++;}//cout<<"##"<<" "<<bits<<endl;}// cout<<bits<<endl;}

    
}

cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE
struct edge
{
   int to;
   int weight;
};

void DFS(int V,vector<vector<edge> > &GRAPH,vector<bool> used,vector<int> & node, int color)
{
  used[V] = true;
  // DEBUG(V);
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    
    int TO = GRAPH[V][i].to;
    int W = GRAPH[V][i].weight;
    if(used[TO] == false)
    {
    if(W%2 == 0)
    {
      node[TO] = color;
      DFS(TO,GRAPH,used,node,color);
    }
    else
    {
      node[TO] = color^1;
      DFS(TO,GRAPH,used,node,color^1);
    }
    }

  }
  

}

void solve(void)
{
  int N;
  cin>>N;
  vector<vector<edge> > GRAPH(N);
  for (int i = 0; i < N-1; i++)
  {
    int A,B,C;
    cin>>A>>B>>C;
    A--;B--;
    edge E1 = {B,C};
    edge E2 = {A,C};
    GRAPH[A].push_back(E1);
    GRAPH[B].push_back(E2);
  }
  vector<int> NODES(N);
  vector<bool> used(N);
  NODES[0] = 0;
  DFS(0,GRAPH,used,NODES,0);
  for (int i = 0; i < NODES.size(); i++)
  {
    cout<<NODES[i]<<endl;
  }
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 582272
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 300005;

int n, e, w, ce, cw, best;
char s[MAXN];

int main() {
    scanf("%d", &n);
    scanf(" %s", s);

    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') {
            e++;
        } else {
            w++;
        }
    }

    best = n - 1;

    for (int i = 0; i < n; i++) {
        best = min(best, cw + e - ce - (s[i] == 'E'));

        if (s[i] == 'E') {
            ce++;
        } else {
            cw++;
        }
    }

    printf("%d\n", best);

    return 0;
}

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

using namespace std;
static const long long maxLL = (long long) 1 << 62;
int main(void) {
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto &a: A) cin >> a;
    long long cost = maxLL;
    for (int x = -100; x <= 100; ++x) {
        long long sum = 0;
        for (int i = 0; i < n; ++i) {
            sum += (x - A[i]) * (x - A[i]);
        }
        cost = min(cost, sum);
    }
    cout << cost << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> X(M);

  for(int i = 0; i < M; i++){
    cin >> X.at(i);
  }

  sort(X.begin(), X.end());

  vector<int> dis(M-1, 0);
  for(int i = 0; i < M-1; i++){
    dis.at(i) = X.at(i+1) - X.at(i);
  }

  sort(dis.begin(), dis.end());

  int ans = 0;

  for(int i = 0; i < M - N; i++){
    ans += dis.at(i);
  }

  cout << ans << endl;

}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(std::vector<long long> A){
    if(A[0]+A[1]+A[2]>21) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	long long int n;
	cin >> n;
	long long int a, b;
	cin >> a >> b;
	vector<long long int>s;
	for (int i = 0; i < n; i++) {
		long long int c;
		cin >> c;
		s.push_back(c);
	}
	long long int ans = 0;
	for (int i = 1; i < n; i++) {
		if ((s[i] - s[i-1]) * a < b) {
			ans = ans + (s[i] - s[i-1]) * a;
		}
		else {
			ans = ans + b;
		}
	}
	cout << ans;
}

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

using namespace std;

int main(){
	//~ freopen("input.txt", "r", stdin);
	//~ freopen("output.txt", "w", stdout);
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++){
		if (s[i] != t[i])
			ans++;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3916
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,k;
  cin >> n >> k;
  int mx = (n-1)*(n-2)/2;
  if(mx<k){
    cout << -1 << endl;
    return 0;
  }
  int m = n-1+mx-k;
  cout << m << endl;
  rep(i,n-1)cout << 1 << " " << i+2 << endl;
  int add = mx-k;
  for(int i=2;i<n;i++){
    for(int j=i+1;j<n+1;j++){
      if(add==0)return 0;
      cout << i << " " << j << endl;
      add--;
    }
  }
  return 0;
}


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

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

  int expensive=0;
  int total=0;
  for(int i=0; i<n; i++){
    total += p[i];
    if(expensive<p[i]) expensive = p[i];
  }

  total -= expensive/2;

  cout << total << endl;

}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

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

int N, K;

int main() {
	scanf("%d %d", &N, &K);
	rep(i, K) {
		int w, h;
		scanf("%d %d", &w, &h);
		int tmp = min(N - w, w - 1);
		int tmp2 = min(N - h, h - 1);
		int ans = min(tmp, tmp2) % 3;
		if(ans == 0) printf("1\n");
		else if(ans == 1) printf("2\n");
		else printf("3\n");
	}
	return 0;
}

Measured memory_bytes: 3124
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int Max_N(300050);
const int MOD(1000000000 + 7);

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

inline void upd(int &a, int b)
{
	a = Add(a, b);
}

int N, F[Max_N][3][3];
char S[Max_N];

int main()
{
	scanf("%s", S + 1), N = strlen(S + 1), F[0][0][0] = 1;
	for (int i = 1;i <= N;++i)
		for (int cnt0 = 0;cnt0 <= 2;++cnt0)
			for (int cnt1 = 0;cnt1 <= 2;++cnt1)
			{
				if (S[i] != '1')//insert(0)
					upd(F[i][cnt0 + 1 == 3 ? 1 : cnt0 + 1][cnt1], F[i - 1][cnt0][cnt1]);
				if (S[i] != '0')//insert(1)
					if (cnt0)
						upd(F[i][cnt0 - 1][cnt1], F[i - 1][cnt0][cnt1]);
					else
						upd(F[i][0][min(cnt1 + 1, 2)], F[i - 1][cnt0][cnt1]);
			}
	int Ans(0);
	for (int cnt1 = 0;cnt1 <= 2;++cnt1)
		for (int cnt0 = 0;cnt0 <= cnt1;++cnt0)
			upd(Ans, F[N][cnt0][cnt1]);
	printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 11008
import sys,functools
if sys.version_info[0]>=3:
	maketrans=str.maketrans
else:
	from string import maketrans

O=lambda a:lambda b:a|b
A=lambda a:lambda b:a&b
X=lambda a:lambda b:a^b
while True:
	s=sys.stdin.readline().rstrip().translate(maketrans('+*^[]','OAX()'))
	if s=='.': break
	for c in 'abcd': s=s.replace(c,'(%s)'%c)
	s=s[1:-1]
	n=int(sys.stdin.readline())
	r=eval(s.translate(maketrans('abcd','%04d'%n)))
	print('%d %d'%(r,sum(r==eval(s.translate(maketrans('abcd','%04d'%i))) for i in range(10000))))


Measured memory_bytes: 6296
from collections import defaultdict

N = int(input())
A = list(map(int,input().split()))

DP = defaultdict(lambda: -10**18)

DP[(0,0)] = A[0]

for i in range(1,N):
    for j in range((i+1)//2-1,(i+2)//2):
        if j == 0:
            DP[(i,0)] = max(DP[(i-1,0)],A[i])
        else:
            DP[(i,j)] = max(DP[(i-1,j)],DP[(i-2,j-1)]+A[i])

print(DP[(N-1,N//2-1)])


Measured memory_bytes: 102644
n = int(input())
xyhs = tuple(tuple(map(int, input().split())) for _ in range(n))

cands = []
for cx in range(100 + 1):
    for cy in range(100 + 1):
        cand = None
        for x, y, h in filter(lambda xyh: xyh[2] > 0, xyhs):
            t = h + abs(x - cx) + abs(y - cy)
            if cand is None:
                cand = t
            elif cand != t:
                break
        else:
            cands.append((cx, cy, cand))

ans = None
for cx, cy, cand in cands:
    for x, y, h in filter(lambda xyh: xyh[2] == 0, xyhs):
        if abs(x - cx) + abs(y - cy) < cand:
            break
    else:
        ans = cx, cy, cand
        break

print(*ans)


Measured memory_bytes: 3828
import javax.swing.text.MaskFormatter;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int ans = (int)1e9;
        int A=scan.nextInt();
        int B=scan.nextInt();
        int C=scan.nextInt();
        int X=scan.nextInt();
        int Y=scan.nextInt();



        for(int i = 0;i < 2*(X+Y)+1;i++){
                int ABpizza = i;
                int Apizza = Math.max(X - i / 2,0);
                int Bpizza = Math.max(Y - i / 2,0);
                
                ans = Math.min(ans, Apizza * A + Bpizza * B + ABpizza * C);
        }
        System.out.println(ans);
    }
}

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

int main() {
  int A,B;
  cin >> A >> B;
  if(A%3==0 || B%3==0 || (A+B)%3==0){
  	cout << "Possible" << endl;
  }else{
  	cout << "Impossible" << endl;
  }
}

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

static const int MAXN = 1e5 + 10;

int data[MAXN];

int n;
int main()
{
    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; ++i)
    {
        scanf("%d" , data + i);
    }

    sort(data + 1 , data + 1 + n);
    /*int ans = 0x3fffffff;
    for(int i = 1 ; i <= n ; ++i)
    {
        ans = min(data[i] - data[1] + data[n] - data[i] , ans);
    }*/
    printf("%d" , data[n] - data[1]);
}


Measured memory_bytes: 256
import numpy as np
N, W = map(int, input().split())
l = sorted([tuple(map(int, input().split())) for i in range(N)], key=lambda x: x[0])
dp = np.zeros(W+1, dtype=int)
for i in range(N):
    w = l[i][0]
    dp[w:] = np.maximum(dp[w:], dp[:-w] + l[i][1])
print(dp[-1])

Measured memory_bytes: 22300
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define It iterator
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;


int main() {
    //freopen("test.in","r",stdin);
    string s; int n;
    cin>>s;
    n=s.length();
    if(n&1) {cout<<"No"; return 0;}
    rep(i,0,n/2){
        char a=s[i], b=s[n-i-1];
        if((a=='b')&&(b=='d')) continue;
        if((a=='d')&&(b=='b')) continue;
        if((a=='p')&&(b=='q')) continue;
        if((a=='q')&&(b=='p')) continue;
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n),ev(100001),od(100001);
  rep(i,n){
    cin >> a.at(i);
    if(i%2==0){
      od.at(a.at(i))++;
    }else{
      ev.at(a.at(i))++;
    }
  }
  ll maxiev=0,maxiod=0,soeev,soeod;
  rep(i,100001){
    if(maxiev<ev.at(i)){
      maxiev=ev.at(i);
      soeev=i;
    }
    if(maxiod<od.at(i)){
      maxiod=od.at(i);
      soeod=i;
    }
  }
  if(soeev!=soeod){
    cout << n/2-maxiev+n/2-maxiod;
  }else{
    if(maxiev<maxiod){
      ll q=0;
      rep(i,100001){
        if(soeev!=i && q<ev.at(i)){
          q=ev.at(i);
        }
      }
      cout << n/2-maxiod+n/2-q;
    }else if(maxiev>maxiod){
      ll q=0;
      rep(i,100001){
        if(soeod!=i && q<od.at(i)){
          q=od.at(i);
        }
      }
      cout << n/2-maxiev+n/2-q;
    }else{
      ll p=0,q=0;
      rep(i,100001){
        if(soeev!=i && q<ev.at(i)){
          q=ev.at(i);
        }
      }
      rep(i,100001){
        if(soeod!=i && p<od.at(i)){
          p=od.at(i);
        }
      }
      ll ans=max(p,q);
      cout <<n/2-ans+n/2-maxiod;
    }
  }
}
    

Measured memory_bytes: 5648
s = int(input())
a = [s]
count = 0
if s == 4 or s == 2 or s == 1:
    print(4)
else:
    for _ in range(1000):
        if s % 2 == 0:
            s = s // 2
        else:
            s = 3*s+1
        count += 1
        a.append(s)
        if s == 4:
            break
    print(count+4)


Measured memory_bytes: 2940
const main = (input) => {
  var N = input.split("\n")[0]-0;
  var lists = [];
  for(var i=1;i<=N;i++){
    var s = input.split("\n")[i].split(" ")[0];
    var p = input.split("\n")[i].split(" ")[1]-0;
    lists.push({idx:i, s:s, p:p});
  }
  lists.sort((a,b)=>{
    if(a.s == b.s){
      return b.p-a.p;
    }else{
      if(a.s>b.s) return 1;
      else return -1;
    }
  });
  lists.forEach(v=>console.log(v.idx));
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 21192
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n,t,a,index,i,temp;
    float min,curr;
    cin >> n >> t >> a;
    cin >> temp;
    index = 1;
    min = abs(a-t+0.006*temp);
    for(i=2;i<=n;i++){
        cin >> temp;
        curr = abs(a-t+0.006*temp);
        if(curr<min){
            min = curr;
            index = i;
        }
    }
    cout << index;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()
	_ = nextStr()
	a := nextInt()
	b := nextInt()
	u := nextStr()

	if u == s {
		a--
	} else {
		b--
	}

	fmt.Println(a, b)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	
	int c[3][3];
	
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			cin >> c[i][j];
		}
	}
	
	if(c[1][0] - c[0][0] != c[1][1] - c[0][1] || c[1][2] - c[0][2] != c[1][1] - c[0][1]){
		cout << "No" << endl;
		return 0;
	}
	if(c[2][0] - c[1][0] != c[2][1] - c[1][1] || c[2][2] - c[1][2] != c[2][1] - c[1][1]){
		cout << "No" << endl;
		return 0;
	}
	if(c[0][1] - c[0][0] != c[1][1] - c[1][0] || c[2][1] - c[2][0] != c[1][1] - c[1][0]){
		cout << "No" << endl;
		return 0;
	}
	if(c[0][2] - c[0][1] != c[1][2] - c[1][1] || c[2][2] - c[2][1] != c[1][2] - c[1][1]){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.LongStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	private static final long MOD = 1_000_000_007;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt(), k = scanner.nextInt();
			long xSum = LongStream.range(1, n).reduce(0L,
					(sum, next) -> (sum + next * (n - next) % MOD * m % MOD * m % MOD) % MOD);
			long ySum = LongStream.range(1, m).reduce(0L,
					(sum, next) -> (sum + next * (m - next) % MOD * n % MOD * n % MOD) % MOD);
			System.out.println((xSum + ySum) % MOD * combinationMod(n * m - 2, k - 2) % MOD);
		}
	}

	/**
	 * n_C_m mod MOD を計算する
	 * 
	 * @param n
	 * @param m
	 * @return n_C_m mod MOD
	 */
	private static long combinationMod(long n, int m) {
		long min = Math.min(m, n - m), max = Math.max(m, n - m);
		long factorialMin = LongStream.rangeClosed(1, min).reduce(1L, (result, next) -> result = result * next % MOD);
		long factorialMax = LongStream.rangeClosed(min + 1, max).reduce(factorialMin,
				(result, next) -> result = result * next % MOD);
		long factorialN = LongStream.rangeClosed(max + 1, n).reduce(factorialMax,
				(result, next) -> result = result * next % MOD);
		return factorialN * powMod(factorialMin, MOD - 2) % MOD * powMod(factorialMax, MOD - 2) % MOD;
	}

	/**
	 * n^m mod MOD を計算する
	 * 
	 * @param n
	 * @param m
	 * @return n^m mod MOD
	 */
	private static long powMod(long n, long m) {
		long result = 1L;
		while (m > 0) {
			if (1 == (1 & m)) {
				result = result * n % MOD;
			}
			n = n * n % MOD;
			m >>= 1;
		}
		return result;
	}
}


Measured memory_bytes: 36008