akhauriyash/Code-Regression huggingface dataset:
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 1000000007
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
int main() {
	int k, x;
	cin >> k >> x;
	k--;
	for (int i = x - k; i <= x + k; ++i) {
		cout << i << " ";
	}
	cout << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define mod1 998244353 
#define inf 1000000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'


const ll N=(ll)(1e9);

int main()
{
    fastio;
    #ifdef APNA_IO
        start_routine();
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);    
    #endif

    ll s;cin>>s;

    if(s==(ll)(1000000000000000000LL))
        return cout<<0<<" "<<0<<" "<<N<<" "<<0<<" "<<0<<" "<<N,0;

    if(s<=N) return cout<<"0 0 1 0 0 "<<s,0;

    ll a[6]={N,0,s%N,1+(s/N),0,1};
    for(ll i=0;i<6;i++) cout<<a[i]<<" ";


    #ifdef APNA_IO
        end_routine();
    #endif
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include <unordered_set>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  ll ans=0;
  ll a[n+1]={},b[n+2]={};
  rep(i,n)cin >> a[i+1];
  priority_queue<pll> que;
  rep(i,n){
    cin >> b[i+1];
    que.push({b[i+1],i+1});
  }
  a[0]=-inf;
  b[0]=b[n];
  b[n+1]=b[1];
  while(!que.empty()){
    pint p=que.top();
    int i=p.second;
    que.pop();
    ll k=(b[i]-a[i])/(b[i+1]+b[i-1]);
    ans+=k;
    b[i]-=k*(b[i-1]+b[i+1]);
//    if(i==0)b[n]=b[0];
    if(i==n)b[0]=b[n];
    if(i==1)b[n+1]=b[1];
//    if(i==n+1)b[1]=b[n+1];
    if(k>0)que.push({b[i],i});
  }
  rep(i,n){
    if(b[i+1]!=a[i+1]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 9456
import java.util.Scanner;

/**
 * https://abc065.contest.atcoder.jp/tasks/abc065_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		for(int i=0; i<N; i++) a[i] = sc.nextInt()-1;
		sc.close();
		
		boolean[] dp = new boolean[N];
		int i=0;
		int ans = 0;
		boolean f = false;
		while(!dp[i]){
			dp[i] = true;
			if(i==1){
				f = true;
				break;
			}else{
				ans++;
				i = a[i];
			}
		}
		
		System.out.println(f ? ans : -1);
	}

}


Measured memory_bytes: 52404
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int main()
{
    int n,i,tt,xx,yy;
    cin>>n;
    vector <int> t(n+1,0),x(n+1,0),y(n+1,0);
    x[0]=0;
    y[0]=0;
    for(i=1;i<=n;i++) cin>>t[i]>>x[i]>>y[i];
    for(i=1;i<=n;i++)
    {
        if(x[i]>=x[i-1]) xx=x[i]-x[i-1];
        else xx=x[i-1]-x[i];
        if(y[i]>=y[i-1]) yy=y[i]-y[i-1];
        else yy=y[i-1]-y[i];
        if(t[i]>=t[i-1]) tt=t[i]-t[i-1];
        else tt=t[i-1]-t[i];
        if((((tt-xx-yy)%2)!=0)or(tt<(xx+yy)))
        {
            cout<<"No"<<endl;
            system ("pause"); 
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    system ("pause"); 
    return 0;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9+10)
#define ll_MIN (ll)(-1e9*1e9-10)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
//using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX
 

int r,c,k;
int arr[3001][3001];
int dp[3001][3001][4];
bool v[3001][3001][4];


int s1(int i, int j, int tot)
{
  if(i >= r or j>=c)
    return ll_MIN;
  if(tot > 3)
    return ll_MIN;
  if(i==r-1 and j==c-1)
  {
    if(tot < 3)
      return arr[i][j];
    else
      return 0;
  }

  if(v[i][j][tot])
    return dp[i][j][tot];
  v[i][j][tot] = 1;
  dp[i][j][tot] = max(s1(i+1,j,0), s1(i,j+1,tot));
  int &x = dp[i][j][tot];
  if(tot <= 2)
  {
   x = max({x, arr[i][j] + max(s1(i+1, j, 0), s1(i, j+1, tot+1))});
  }
  return x;
}





void solve()
{
  cin >> r >> c >> k;
  for(int i=0; i<k; i++)
  {
    int x,y,v;
    cin >> x >> y >> v;
    arr[x-1][y-1] = v;
  }

  cout << s1(0,0,0);

}

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

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

using namespace std;

int n,k;
int v[100010];
int dp[100010];

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

    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        dp[i] = 1e9;
    }
    
    dp[0] = 0;
    
    for (int i = 0; i < n; ++i) 
        for (int j = i - 1, dk = k; j >= 0 and dk; j--, dk--) 
            dp[i] = min(dp[i], dp[j] + abs(v[i] - v[j]));
        
    cout << dp[n - 1] << "\n";
    return 0;
}


Measured memory_bytes: 1024
package main
import (
  "fmt"
  "strings"
)

func main() {
  var a string
  fmt.Scan(&a)
  array := strings.Split(a, "")
  
  result := 0
  for i := 0; i < len(array); i++ {
    if array[i] == "1" {
    	result++
    }
  }
  fmt.Printf("%v", result)
}

Measured memory_bytes: 640
#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 k = 1;
    rep(i,n){
        int a; cin >> a;
        if(a==k) k++;
    }
    
    cout << (k==1 ? -1 : n-k+1) << endl;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll k;
	cin >>n >>k;
	VI a(n);
	rep(i, n){ cin >>a[i]; a[i]--;}
	int cr =0;
	while(k>0){
		if(k&1) cr =a[cr];
		VI na(n);
		rep(i, n) na[i] = a[a[i]];
		swap(a, na);
		k >>= 1;
	}
	cout <<cr +1 <<"\n";
	return 0;
}


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

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

using namespace std;

int main() {
  string s;
  std::cin >> s;

  s += '0';

  int minv = 1000;
  for (int i = 1; i < s.size() - 2; ++i) {
    minv = min(minv, abs(stoi(s.substr(i - 1, 3)) - 753));
  }

  std::cout << minv << std::endl;
  return 0;
}


Measured memory_bytes: 3612
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	var n int
	fmt.Scan(&n)
	s := readLine()
	sn := strings.Split(s, " ")
	inputs := stringsToInts(sn)

	for _, v := range inputs {
		if v == 0 {
			fmt.Println(0)
			return
		}
	}

	var ans uint64 = 1
	for _, v := range inputs {
		if ans > 1e18/v {
			fmt.Println(-1)
			return
		}
		ans *= v
	}
	fmt.Println(ans)
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func stringsToInts(s []string) []uint64 {
	arr := make([]uint64, len(s))
	for i, v := range s {
		arr[i], _ = strconv.ParseUint(v, 10, 64)
	}
	return arr
}


Measured memory_bytes: 9448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll k,i,l,r;scanf("%lld",&k);
  ll d[k];pair<ll,ll> a[k+1] = {};
  a[0] = make_pair(2,2);
  for(i=k-1;i>=0;i--) scanf("%lld",&d[i]);
  for(i=0;i<k;i++){
    l = a[i].first/d[i]+(a[i].first%d[i] != 0);
    r = a[i].second/d[i];
    if(a[i].second<l*d[i]){
      printf("-1\n");return 0;
    }
    a[i+1].first = l*d[i];
    a[i+1].second = (r+1)*d[i]-1;
  }
  //for(i=0;i<=k;i++) printf("%lld %lld\n",a[i].first,a[i].second);
  printf("%lld %lld\n",a[k].first,a[k].second);
}

Measured memory_bytes: 6108
#include <stdio.h>
#include <stdlib.h>
  
typedef struct{
    int key;
    int left;
    int right;
} Node;
  
void insert(Node*, int, int);
void print1(Node*, int);
void print2(Node*, int);
  
int main()
{
    char s[10];
    Node *t;
    int m;
    int a;
    int i;
  
    scanf("%d", &m);
    t=(Node*)malloc(sizeof(Node)*m);
  
    int count=0;
    for(i=0; i<m; i++){
        scanf("%s", &s);
        if(s[0]=='i'){ scanf("%d", &a); insert(t, count, a); count++; }
        if(s[0]=='p'){
            if(count>0) print1(t, 0);
            printf("\n");
            if(count>0) print2(t, 0);
            printf("\n");
        }
    }
      
    return 0;
  
}
  
void print1(Node *t, int p)
{
    if(t[p].left>=0) print1(t, t[p].left);
    printf(" %d", t[p].key);
    if(t[p].right>=0) print1(t, t[p].right);
}
  
void print2(Node *t, int p)
{
    printf(" %d", t[p].key);
    if(t[p].left>=0) print2(t, t[p].left);
    if(t[p].right>=0) print2(t, t[p].right);
}
  
void insert(Node *t, int count, int z)
{
    int x=0, y;
    if(count<1) x=-1;
  
    t[count].key = z;
    t[count].left = -1;
    t[count].right= -1;
  
    while(x>=0){
        y = x; 
        if(z < t[x].key)
            x = t[x].left; 
        else
            x = t[x].right; 
    }
  
    if(count<1){}
    else if(z < t[y].key){
        t[y].left = count; 
    }
    else {
        t[y].right = count;
    }
}

Measured memory_bytes: 6464
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  vector<int > h(n);
  REP(i,n){
    cin >> h[i];
  }
  sort(all(h));
  int ans = 1e9;
  int tmp = 0;
  // REP(i, n){
  //   cout << h[i] << endl;
  // }
  REP(i, n - k + 1){
    tmp = h[i + k - 1] - h[i];
    ans = min(tmp, ans);
  }
  cout << ans << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll a, b;
    fori(a, 1, 3501) fori(b, 1, 3501)
    {
        ll N = 4 * a * b - n * b - n * a;
        ll D = n * a * b;
        if (N <= 0 || D <= 0)
            continue;
        if (D % N == 0)
            return cout << a << ' ' << b << ' ' << (D / N) << endl, 0;
    }
    assert(false);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  int cnt,ans=1e5;
  for(int i=1;i<=n/2;i++){
    cnt=0;
    int t=i;
    while(t){
      cnt+=t%10;
      t/=10;
    }
    t=n-i;
    while(t){
      cnt+=t%10;
      t/=10;
    }
    ans=min(ans,cnt);
    cerr<<i<<" "<<cnt<<endl;
  }
  cout<<ans;
}

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

int main(){
    int N;
    cin >> N;
    int digit_sum = 0;
    int tmp_N = N;
    while(tmp_N){
        digit_sum += tmp_N % 10;
        tmp_N /= 10;
    }
    if(N % digit_sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

void solve(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*c, max(a*d, max(b*c, b*d))) << endl;
}

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
//	cin >> t;
	while(t--){
		solve();
	}
	return 0;
}


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

int main(){
    int n,i,x=1,oldx=1;
    cin >> n;
    vector<int> dp(n+1);
    dp.at(0)=0;
    for(i=1;i<=n;i++){
        int check=0;
        dp.at(i)=min(dp.at(i-x)+1,dp.at(i-oldx)+1);
        if(i==1||i==6||i==9||i==36||i==81||i==216||i==729||i==1296||i==6561||i==pow(6,5)||i==pow(9,5)||i==pow(6,6)){
            dp.at(i)=1;
            check=1;
        }
        if(check){
            oldx=x;
            x=i;
        }
    }
    
    cout << dp.at(n) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define maxn 120000
int n, ans, a[maxn];

int read()
{
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k; 
}

struct node
{
	int sum, num;
	friend bool operator <(const node& a, const node& b)
	{ return a.sum > b.sum; }
}odd[maxn], even[maxn];

int main()
{
	n = read();
	for(int i = 1; i <= n; i ++) a[i] = read();
	for(int i = 1; i <= n; i ++)
	{
		if(i & 1) odd[a[i]].sum ++;
		else even[a[i]].sum ++;
	}
	for(int i = 1; i < maxn; i ++) odd[i].num = i, even[i].num = i;
	sort(odd + 1, odd + maxn); sort(even + 1, even + maxn);
	if(odd[1].num != even[1].num) ans = odd[1].sum + even[1].sum;
	else
	{
		ans = max(ans, odd[1].sum + even[2].sum);
		ans = max(ans, odd[2].sum + even[1].sum);
	}
	cout << n - ans << endl;
	return 0;
}

Measured memory_bytes: 2560
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<int> vl;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()                                                              
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) {cout<<n<<"\n" ; return ;}
#define po(n) cout << n <<"\n " 
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define PI acos(-1) 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#ifndef ONLINE_JUDGE
//#ifndef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#else
//#define debug(x...)
//#endif
//#define int ll 
long const M=1e9+7;
const long mxN =1e5+2 ;
const ll INF =1e18;
void solve(){ 
  Rep(i,5){
    int x ;
    cin >> x ;
    if(x==0){
      pf(i)
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //cout << setprecision(20) << fixed ;
  solve() ;
  // ll t ; cin >> t ; while(t--)solve() ;
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, x; scanf("%d%d", &n, &x);
	
	int now = 0, ans = 1;
	while(n--) {
		int d; scanf("%d", &d);
		now += d;
		if(now <= x) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


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

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char) 
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let x: usize = read();
  println!("{}",
    if x == 3 || x == 5 || x == 7 { "YES" }
    else { "NO" }
  );
}

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

using namespace std;

int main()
{
	int N, A[5]; long long sum = 0;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> A[i]; sum += A[i];

		if (A[i] > 4) { A[i] = 4; }
	}

	sort(A, A + N);

	if (N == 1)
	{
		cout << sum << endl;
	}
	else if (N == 2)
	{
		cout << sum - 1 << endl;
	}
	else if (N == 3)
	{
		cout << sum - 3 << endl;
	}
	else if (N == 4)
	{
		if (sum == 8)
		{
			cout << sum - 4 << endl;
		}
		else if (A[0] == 2)
		{
			cout << sum - 5 << endl;
		}
		else
		{
			cout << sum - 6 << endl;
		}
	}
	else
	{
		if (A[4] != 4)
		{
			cout << sum - (sum < 12 ? 6 : sum < 14 ? 7 : 8) << endl;
		}
		else if(A[0] == 2)
		{
			cout << sum - (A[1] == 2 ? 7 : 8) << endl;
		}
		else
		{
			cout << sum - (sum == 16 ? 8 : 6 + A[0]) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3156
#include"bits/stdc++.h"
using namespace std;

int main()
{
    int sumAC = 0;
    int sumWA = 0;
    bool ACs[100010] = { false };
    int WAs[100010] = {};

    int N, M; cin >> N >> M;

    int p = 0;
    string S = "";
    for (int i = 0; i < M; i++) {
        cin >> p >> S;
        if (S == "AC") {
            if (!ACs[p]) { 
                sumAC++;
                ACs[p] = true;
            }
        }
        else {
            if (!ACs[p]) { 
                WAs[p]++;
            }
        }
    }

    for (int i = 0; i <= N; i++) {
        if (ACs[i]) sumWA += WAs[i];
    }

    cout << sumAC << " " << sumWA << endl;

    return 0;
}

Measured memory_bytes: 768
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string t[] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
  string s;
  while (cin >> s) {
    if (odd(s.size())) {
      cout << "NA" << endl;
      continue;
    }
    stringstream ss;
    for (int i = 0; i < s.size(); i += 2) {
      if (s[i] < '1' || '6' < s[i] || s[i + 1] < '1' || '5' < s[i + 1]) {
        cout << "NA" << endl;
        goto next;
      }
      ss << t[s[i] - '1'][s[i + 1] - '1'];
    }
    cout << ss.str() << endl;
  next:;
  }
}

Measured memory_bytes: 3136
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

//ll mod = 1000000007;
ll mod = 998244353;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	//t %= mod;
	if (n % 2 == 1)t *= a;
	return t /*% mod*/;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

vector<pair<ll, ll>> prime_factorize(ll N) {
	vector<pair<ll, ll>> res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0;
		while (N % a == 0) {
			++ex;
			N /= a;
		}
		res.push_back({ a, ex });
	}
	if (N != 1) res.push_back({ N, 1 });
	return res;
}


int main() {
	ll n;
	cin >> n;
	string ans;
	while (n > 0) {
		n--;
		ll tmp = n % 26;
		ans.push_back('a' + tmp);
		n /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
const int Max = 2e3 + 5;
const int Mod = 1e9 + 7;

int n, k;
string s;
ll dp[Max][Max][2];

ll Try(int i, int j, bool b)
{
    if (j > k)
        return 0;
    if (i == n)
        return j == k;
    ll& ret = dp[i][j][b];
    if (ret + 1)
        return ret;
    ret = 0;
    int u = (b ? 9 : s[i] - '0');
    for (int l = 0; l <= u; l++)
        ret += Try(i + 1, j + (l > 0), b || l < s[i] - '0');
    return ret;
}

int main()
{
    GO;
    cin >> s;
    n = s.size();
    cin >> k;
    memset(dp, -1, sizeof(dp));
    cout << Try(0, 0, 0);
    return 0;
}

Measured memory_bytes: 63104
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <functional>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _I inline
#define _OP(t) _I operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H &&h, T... t){out(h);out(t...);}
template <typename... T> _OUTL(T... t){out(t...);outl();}
#define dbg(...) fprintf(stderr,__VA_ARGS__)
struct range{
	int e,b=0,s=1;range(int b,int e,int s):e(e),b(b),s(s){} range(int b,int e): e(e), b(b){} range(int e):e(e){}
	struct it{int v,s; it(int v,int s):v(v),s(s){} operator int()const{return v;} _I operator int&(){return v;}int operator*()const{return v;}
		_I it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

_T using V = vector<T>;

int main() {
	int N = 1 << 15;
	V<V<int>> d(4, V<int>(N));
	for (int i {1}, t {i}; d[0][t = i * i]++, i * i < N; i++)
		for (int j: range(1, 4))
			for (int k: range(t, N))
				d[j][k] += d[j - 1][k - t];
	for (int n; (n = in);) {
		int r {};
		for (int i: range(4))
			r += d[i][n];
		outl(r);
	}
}


Measured memory_bytes: 2932
#include<stdio.h>
int partition(int *A,int p,int r);

int main(){
  int i,x,n,A[100001];
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%d",&A[i]);}

  x=partition(&A,0,n-1);
  for(i=0;i<x;i++){printf("%d ",A[i]);}
  printf("[%d]",A[i]);
  i++;
  for(i;i<n;i++){printf(" %d",A[i]);}
  printf("\n");
}

int partition(int *A,int p,int r){
  int i,j,tmp,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}


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

int main() {
  int x,y;
  cin >> x >>y;
  bool ans = false;
  if((x == 4 || x == 6 || x == 9 || x == 11) &&
     (y == 4 || y == 6 || y == 9 || y == 11)) ans = true;
  else if((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) &&
          (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) ans =true;
  puts(ans?"Yes":"No");
  
}

Measured memory_bytes: 3596
H, W, K = map(int, input().split())
a = [input() for i in range(H)]
ans = 0
for i in range(1 <<H):
    for j in range(1 <<W):
        black = 0
        for k in range(H):
            for l in range(W):
                if (i >>k)&1 ==0 and (j >>l)&1 == 0 and a[k][l] == '#':
                    black += 1
        if black == K:
            ans += 1
print(ans)

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

int main(void){
	string s; cin >> s; bool ok = true; int n = s.size();
	if (s[0]=='0' || s[n-2]=='0' || s[n-1]=='1') ok = false;
	for(int i=2; i <= n-i; i++){
		if (s[i-1] != s[n-i-1]) ok = false;
		//cout << i << " " << n-i << endl;
	}
	if (!ok) {cout << -1 << endl; return 0;}
	s[n-1]='1';
	int w[n];
	for(int i=n-1; i>=0; i--) {
		if (s[i] == '1') w[i] = i+1;
		else w[i] = w[i+1];
	}
	for(int i=0; i<n-1; i++) {
		cout << i+1 << " " << w[i+1] << endl;
	}
}


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

#define F first
#define S second
#define pb push_back
#define ld long double
//#define int long long
#define ll long long

using namespace std;

const int MAXN = 1001 * 1001 ;

int cnt[MAXN] ;

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

    int n , m , h , w ;

    cin >> n >> m >> h >> w ;

    if(n%h==0&&m%w==0) return cout << "No" << endl , 0 ;

    cout << "Yes\n" ;

    if(n%h!=0)
    {
        int x = 2 * n / h , y = - (h-1) * x - 1 ;
        for(int i = 0 ; i < n ; i ++ , cout << '\n' ) for(int j = 0 ; j < m ; j ++ ) cout << (i%h==h-1?y:x) << ' ' ;
        return 0 ;
    }

     int x = 2 * m / w , y = - (w-1) * x - 1 ;
    for(int i = 0 ; i < n ; i ++ , cout << '\n' ) for(int j = 0 ; j < m ; j ++ ) cout << (j%w==w-1?y:x) << ' ' ;

    return 0;
}


Measured memory_bytes: 1408
import java.util.*;
import java.io.*;
public class Main {
    static long MOD = 1000000007;
    static long[] facts = new long[100001];
    static long[] invs = new long[100001];
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int N = nextInt();
        int K = nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = nextInt();
        }
        Arrays.sort(A);

        facts[0] = 1;
        invs[0] = 1;
        for (int i = 1; i < 100001; i++) {
            facts[i] = facts[i-1] * i % MOD;
            invs[i] = power(facts[i], MOD-2);
        }

        long maxSum = 0;
        for (int i = K; i <= N; i++) {
            maxSum += A[i-1] * ncr(i-1, K-1);
            maxSum = maxSum % MOD;
        }

        long minSum = 0;
        for (int i = N; i >= K; i--) {
            minSum += A[N-i] * ncr(i-1, K-1);
            minSum = minSum % MOD;
        }

        long sum = maxSum >= minSum ? maxSum - minSum : MOD + maxSum - minSum;
        System.out.println(sum % MOD);
    }

    public static long ncr(int n, int r) {
        return facts[n] * invs[r] % MOD * invs[n-r] % MOD;
    }

    // public static long fact(long n) {
    //     return n == 0 ? 1 : n * fact(n-1) % MOD;
    // }

    public static long power(long b, long n) {
        long res = 1;
        while (n > 0) {
            if ((n & 1) == 1) {
                res = res * b % MOD;
            }
            b = b * b % MOD;
            n = n >> 1;
        }
        return res;
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }
}

Measured memory_bytes: 63296
using System;
using System.Linq;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int result = 0;
            int[] num = new int[3];
            num = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            for(int i = num[0]; i <= num[1]; i++)
            {
                if (i % num[2] == 0)
                    result++;
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 28268
import sys
import math
import collections
import bisect
import copy

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    h, w = ns()
    mat = [list(input()) for _ in range(h)]
    visited = [[False for _ in range(w)] for __ in range(h)]

    B, W = 0, 1
    for y in range(h):
        for x in range(w):
            if mat[y][x] == "#":
                mat[y][x] = B
            else:
                mat[y][x] = W

    cnt = [0, 0]
    pos = [[0, 1], [0, -1], [1, 0], [-1, 0]]

    def bfs(y, x, here):
        visited[y][x] = True
        cnt[here] += 1

        for yi, xi in pos:
            ty = y + yi
            tx = x + xi
            if 0 <= ty < h and 0 <= tx < w:
                if not visited[ty][tx] and mat[ty][tx] == here ^ 1:
                    bfs(ty, tx, here ^ 1)

    ans = 0
    for y in range(h):
        for x in range(w):
            if not visited[y][x]:
                cnt = [0, 0]
                bfs(y, x, mat[y][x])
                ans += cnt[B] * cnt[W]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 248128
N = int(input())
A = [int(a)-1 for a in input()]

r = 1 if 1 in A else 2

def parity_of_nCk(n, k):
    return (n&k)==k

ans = 0
for i, a in enumerate(A):
    if a & r:
        if parity_of_nCk(N-1,i):
            ans ^= 1

print(ans*r)

Measured memory_bytes: 13632
import java.util.*;
public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        int cnt = bubbleSort(a,N);
        for (int i = 0; i < N; i++) {
            if(i > 0) System.out.print(" ");
            System.out.print(a[i]);
        }
        System.out.println();
        System.out.println(cnt);
        
        sc.close();
    }

    static int bubbleSort(int[] A,int N)
    {
        int cnt = 0;
        boolean flag = true;
        while(flag)
        {
            flag = false;
            for (int j = N-1; j >0; j--) {
                if(A[j] < A[j-1])
                {
                    int buf = A[j];
                    A[j] = A[j-1];
                    A[j-1] = buf;
                    flag = true;
                    cnt ++;
                }
            }
        }
        return cnt;
    }
}


Measured memory_bytes: 26380
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], m = tmp[1];
    int[] a = new int[m+1];
    foreach (i; 0 .. n) {
        int[] survey = readln.split.to!(int[]);
        foreach (x; survey[1..$]) {
            ++a[x];
        }
    }
    a.count(n).writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

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

#define mod 1000000007

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

using namespace std;
typedef long long ll; 

int main(void){
	
	int X, Y;
	
	cin >> X >> Y;
	
	cout << X + Y / 2;
	
	return 0;
}

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

int main() {
  std::string string;
  std::cin >> string;
  switch (string[0]){
    case 'S':
      if(string[1] == 'U'){
        std::cout << 7;
      }
      else std::cout << 1;
      break;
    case 'M':
      std::cout << 6;
      break;
    case 'T':
      if(string[1] == 'U') std::cout << 5;
      else std::cout << 3;
      break;
    case 'W':
      std::cout << 4;
      break;
    case 'F':
      std::cout << 2;
      break;
  }
  return 0;
}

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

using namespace std;

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

    int tmp = x - sum;

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

    int ans = tmp/m[0];

    cout << n + ans << endl;
    return 0;
}


Measured memory_bytes: 1016
#include<stdio.h>
#define MAX 100
#define INF 1e8
#define WHITE 0
#define GRAY  1
#define BLACK 2
 
int n,M[MAX][MAX];
 
void dijkstra(){
  int color[MAX],d[MAX],p[MAX],min,u;
  int i,j,v;
 
  for(i=0;i<n;i++){
    color[i] = WHITE;
    d[i] = INF;
  }
  d[0] = 0;
  p[0] = -1;
 
  while(1){
    min = INF;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<min){
    min = d[i];
    u = i;
      }
    }
 
    if(min == INF) break;
    color[u] = BLACK;
 
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INF){
    if(d[u]+M[u][v] < d[v]){
      d[v] = d[u] + M[u][v];
      p[v] = u;
      color[v] = GRAY;
    }
      }
    } 
  }
 
  for(i=0;i<n;i++) printf("%d %d\n",i,(d[i]==INF ? -1: d[i]));
}
 
int main(){
  int u,k,v,c;
  int i,j;
 
  scanf("%d",&n);
  for(i=0;i<n;i++) for(j=0;j<n;j++) M[i][j]=INF;
   
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&M[u][v]);
    }
  }
  dijkstra();
   
  return 0;
}


Measured memory_bytes: 2140
import sys
sys.setrecursionlimit(10**7) 

def dfs(G,v):
    global ptr
    first_order[v] = ptr
    ptr += 1
    seen[v] = True
    for next in G[v]:
        if seen[next]:
            continue
        dfs(G,next)

    last_order[v] = ptr
    ptr+=1

n = int(input())
G = [[] for _ in range(n)]
for _ in range(n):
    a = list(map(int, input().split()))
    u = a[0]
    k = a[1]
    v = a[2:]
    for i in v:
        G[u-1].append(i-1)

seen = [False]*n
first_order = [0]*n
last_order = [0]*n
ptr = 0
for i in range(n):
    if seen[i]:
        continue
    dfs(G,i)

for i in range(n):
    print('{} {} {}'.format(i+1,first_order[i]+1,last_order[i]+1))


Measured memory_bytes: 5636
#B
S=input()

N=len(S)
con_2=S[:(N-1)//2]
con_3=S[((N+3)//2-1):]

if S==S[::-1] and con_2==con_2[::-1] and con_3==con_3[::-1]:
            print('Yes')
else:
    print('No')

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

using ll = long long int;

ll x;

ll ans;

int main(void) {
    // Here your code !
    scanf("%lld", &x);

    ll tmp = x / 11;

    if (x % 11 == 0) {
      ans = tmp * 2;
    }
    else if (tmp * 11 + 5 >= x || tmp * 11 + 6 >= x) {
      ans = tmp * 2 + 1;
    }
    else {
      ans = tmp * 2 + 2;
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define INF INT_MAX
#define N 100005
#define K 3
int n, k;
int arr[N][K];
int dp[N][K][K];
int solve(int idx, int last_k, int cur_k){
    int res, take = -1, leave = -1;
    if(idx == n)
        return 0;
    if(cur_k == K)
        return -1;
    if(~last_k && ~dp[idx][last_k][cur_k])
        return dp[idx][last_k][cur_k];
    if(cur_k == last_k)
        return dp[idx][last_k][cur_k] = solve(idx, last_k, cur_k+1);
    take = solve(idx+1, cur_k, 0);
    leave = solve(idx, last_k, cur_k+1);
    if(take == -1)
        return dp[idx][last_k][cur_k] = leave;
    take += arr[idx][cur_k];
    if(leave == -1)
        return dp[idx][last_k][cur_k] = take;
    if(idx == 1 && cur_k == 1 && last_k == 2)
        cout << take << ' ' << leave << '\n';
    return dp[idx][last_k][cur_k] = max(take, leave);
}
int main()
{
    cin >> n;
    memset(dp, -1, sizeof(dp[0][0][0]) * N * K * K);
    for(int i=0; i<n; ++i)
        for(int j=0; j<3; ++j)
            cin >> arr[i][j];
    cout << solve(0, -1, 0);
    return 0;
}

Measured memory_bytes: 18944
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

    for(int i=0; i<n; i++) a[i] = p[i];
    int ans=0;
    do {
        bool flag = true;
        for (int i=0; i<n; i++) {
            if(a[i] != q[i]) flag=false;
            }
        if (flag){
            cout << ans << endl;
            return 0;
        }
        ans++;
    } while(next_permutation(a.begin(), a.end()));

    swap(p,q);
    for(int i=0; i<n; i++) a[i] = p[i];
    ans=0;
    do {
        bool flag = true;
        for (int i=0; i<n; i++) {
            if(a[i] != q[i]) flag=false;
            }
        if (flag){
            cout << ans << endl;
            return 0;
        }
        ans++;
    } while(next_permutation(a.begin(), a.end()));
}

Measured memory_bytes: 3612
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int N=122223;
typedef struct process{
	char name[20];
	int time;
}P;
P Q[N];
int head,tail;
void enqueue(P x){
	Q[tail]=x;
	tail=(tail+1)%N;
}
P dequeue(){
	P x=Q[head];
	head=(head+1)%N;
	return x;
}
int main(){
	int n,q;scanf("%d %d",&n,&q);
	for(int i=0;i<n;i++) scanf("%s %d",Q[i].name,&Q[i].time);
	int tot=0;
	head=0;tail=n;
	while(head!=tail){
		int pq=q;
		P x=dequeue();
		if (x.time<=q){
			printf("%s %d\n",x.name,tot+x.time);
			pq=x.time;
		}
		else{
			x.time-=q;
			enqueue(x);
		}
		tot+=pq;
	} 
} 


Measured memory_bytes: 6064
n,m=map(int,input().split())
py=[list(map(int,input().split())) for _ in range(m)]
l=[1]*n
for i in range(m):
    py[i].append(i+1)
py.sort()
for i in range(m):
    py[i].append( str(py[i][0]).zfill(6) + str(l[py[i][0]-1]).zfill(6))
    l[py[i][0]-1]+=1
py.sort(key=lambda x:x[2])
for i in range(m):
    print(py[i][-1])

Measured memory_bytes: 39652
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void Yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

void solve() {
    string s; cin >> s;
    int length = s.size();
    string ans = "";
    ll K; cin >> K;
    rep(i,length){
        char t;
        int ascii = (int) s[i];
        int diff = ascii-97;
        int x = 26 - diff;
        if(diff == 0) {
            t = s[i];
        }else if(x > K){
            t = s[i];
        }else{
            t = 'a';
            K -= x;
        }
        if(i == length-1){
            t += K%26;
        }
        ans = ans + t;
    }
    print(ans);
  
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

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

int main(){
	bool p[100000];
	p[0]=p[1]=false;
	for(int i=2;i<100000;i++){
		p[i]=true;
	}
	for(int i=2;i*i<100000;i++){
		if(p[i])
			for(int j=i*i;j<100000;j+=i){
				p[j]=false;
			}
	}

	while(1){
		int count=0;
		int N;
		cin>>N;
		if(N==0)
			break;
		for(int i=2;i<(N/2)+1;i++){
			if(p[i]&&p[N-i])
				count++;
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 3180
from collections import Counter
n = int(input())
v = list(map(int, input().split()))

e = Counter(v[::2]).most_common() + [(0, 0)]#最も多いものは書き換えない
#コーナーケース対応、要素が超少ない場合
o = Counter(v[1::2]).most_common() + [(0, 0)]#偶奇で分けて考える

if e[0][0] != o[0][0]:#偶奇で最多が異なるなら、偶奇の最多を引く
    print(n - e[0][1] - o[0][1])
else:#偶奇で最多が同じなら、最多の次を検討して、最も書換を少なくする
    print(n - max(e[0][1]+o[1][1], e[1][1]+o[0][1]))


Measured memory_bytes: 20572