akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return

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...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;

const ll mod=1e9+7;
const ll N=2e5+5;
ll i,j;

/*


*/

vi dp(N,0);
void solve(){
    in(n);
    vi a(n); lelo(a);
    dp[1]=0;
    dp[2]=abs(a[1]-a[0]);
    for(i=3;i<=n;i++){
    	dp[i]=min(dp[i-2]+abs(a[i-1]-a[i-3]),dp[i-1]+abs(a[i-1]-a[i-2]));
    }
    ce(dp[n]);
}

int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
}

/*


*/

  

Measured memory_bytes: 5628
def main():
    n = int(input())
    s = list(map(int, list(input())))
    ans = 0
    for i in range(1000):
        c = 0
        for j in s:
            if i % 10 == j:
                if c == 2:
                    ans += 1
                    break
                c += 1
                i //= 10
    print(ans)

main()

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    char ch,card[4][13]={false};
    int n,a,i;
    cin>>n;
    for(i=0;i<=n-1;i++){
        cin>>ch>>a;
        if(ch=='S'){
            card[0][a-1]=true;
        }if(ch=='H'){
            card[1][a-1]=true;
        }if(ch=='C'){
            card[2][a-1]=true;
        }if(ch=='D'){
            card[3][a-1]=true;
        }
       
    }
 for(int i=0; i<4; i++){
            for(int j=0; j<13;j++){
				if(card[i][j]==false){
				if(i==0)cout<<"S "<<j+1<<endl;
				else if(i==1)cout<<"H "<<j+1<<endl;
				else if(i==2)cout<<"C "<<j+1<<endl;
				else if(i==3)cout<<"D "<<j+1<<endl;
				}
            }
        }
    return 0;
}


Measured memory_bytes: 3096
import java.io.*;
import java.util.*;

public class Main{
    public void run(){
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            String[] arg = br.readLine().split(" ");
            int n = Integer.parseInt(arg[0]);
            int m = Integer.parseInt(arg[1]);
            int[] array = new int[m-1];
            Map<Integer, Integer> map = new HashMap<>();
            for(int i = 0 ;i < m; i++){
                String[] input = br.readLine().split(" ");
                if(!map.containsKey(Integer.parseInt(input[0])))
                    map.put(Integer.parseInt(input[0]), 1);
                else
                    map.put(Integer.parseInt(input[0]), map.get(Integer.parseInt(input[0])) + 1);
                if(!map.containsKey(Integer.parseInt(input[1])))
                    map.put(Integer.parseInt(input[1]), 1);
                else
                    map.put(Integer.parseInt(input[1]), map.get(Integer.parseInt(input[1])) + 1);
            }
            boolean flag = true;
            for(int a : map.keySet()){
                if(map.get(a) % 2 != 0){
                    flag = false;
                    break;
                }
            }
            if(flag)System.out.println("YES");
            else System.out.println("NO");
        }catch(Exception e){

        }
    }
    public static void main(String... args){
        new Main().run();
    }
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int n; cin >> n;
    vi l(n);
    rep(i, n) cin >> l[i];

    int ans = 0;
    sort(all(l));
    reverse(all(l));
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                if (l[i] == l[j] or l[i] == l[k] or l[j] == l[k])
                    continue;
                if(l[i] < l[j] + l[k]) ans++;
            }
        }
    }

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

Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++ i)
using namespace std;
#define LL long long
#define MX 1000000000000000000

int main()
{
  int n;
  cin >> n;
  
  vector<LL> a(n);
  rep(i, n) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  LL prod = 1;
  rep(i, n)
  {
    if (a.at(i) == 0)
    {
      cout << 0 << endl;
      return 0;
    }
    if (prod > MX / a.at(i))
    {
      cout << -1 << endl;
      return 0;
    }
    prod *= a.at(i);
  }
  
  cout << prod << endl;
  return 0;
}


Measured memory_bytes: 4012
import sys
input = sys.stdin.readline
N = int(input())
def inputs():return [int(x) for x in input().split()]
shogen=[[None]*(N) for _ in range(N)]
for i in range(N):
    a=int(input())
    for j in range(a):
        x,y=inputs()
        shogen[i][x-1]=y
#print(shogen)
ans = -10**8
for bit in range(1,1<<N):
    #print(bit)
    ans1 = 0
    for i in range(N):
        if not bit&1<<i:
         # print(bit&1<<i,bit)
          continue
        for j in range(N):
            if shogen[i][j]==None:
                if j==N-1:
                    ans1+=1
                    #print(i,j,bit)
                continue
            elif shogen[i][j]==1 and bit&1<<j:
                if j==N-1:
                    ans1+=1
                continue
            elif shogen[i][j]==0 and not bit&1<<j:
                if j==N-1:
                    ans1+=1
                continue
            else:
                ans1=0
                break
        else:
            continue
        break
    ans = max(ans1,ans)
print(ans)

Measured memory_bytes: 3064
A = list(map(int, input().split()))
t=0


while max(A)-min(A)>1:
    x = min(A)
    A.remove(x)
    A.append(x+2)
    t += 1

P = A.count(max(A))
if P == 1:
    t+=1
elif P == 2:
    t += 2

print(t)

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

char getGrade(int m,int f,int r){
    int sum = m+f ;
    char grade;
    if(m== -1 || f==-1){
        grade = 'F';
    }else if(80<=sum){
        grade ='A';
    }else if(65<=sum && sum <80){
        grade ='B';
    }else if(50<=sum && sum <65){
        grade ='C';
    }else if(30<=sum && sum< 50){
        if(50<=r)grade ='C';
        else grade ='D';
    }else if( sum < 30){
        grade = 'F';
    }
    return grade;
}

int main(){
    int m,f,r;
    while(1){
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1)break;
        cout << getGrade(m,f,r)<< endl;
    }
    return 0;
}


Measured memory_bytes: 3088
n = gets.to_i
a = gets.split.map(&:to_i)
mask = a[0] == 0 ? 0 : a[1..-1].map {|i| 1 << i }.inject(:|) 
(0..2**n-1).each do |b|
  puts ("#{b}: " + (0..n-1).select {|i| b[i] == 1 } * ' ').strip if b & mask == mask
end



Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;
char s[505][505];
int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin >> n >> m;
    int h = 100, w = 100;
    REP(i, h) REP(j, w) s[i][j] = (i < h / 2) ? '.' : '#';
    n --; m--;
    REP(i, h / 4) REP(j, w / 2) {
            if (m) {
                m --;
                s[i*2][j*2] = '#';
            }
            if (n) {
                n --;
                s[h-1 - i*2][w-1 - j*2] = '.';
            }
        }
    cout << h << " " << w << endl;
    REP(i, h) {
        REP(j, w) cout << s[i][j];
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String ans = "None";
        char tmp='a';
        for(int i = 0; i < 26; i++) {
            String strTmp = String.valueOf(tmp);
            if (!s.contains(strTmp)) {
            	ans=strTmp;
            	break;
            }
            tmp++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 27124
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;

int main(){
	int n, k, x, ans=0;
	cin >> n;
	cin >> k;
	for(int i=0; i<n; i++){
		cin >> x;
		ans += min(x, k-x);
	}

	cout << 2*ans <<endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		if(m <= n){
			System.out.println(0);
			return;
		}

		int x[] = new int[m];

		for(int i = 0; i < m; i++){
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);
		int left[] = new int[m];
		int sum = 0;
		for(int i = 1; i < m; i++){
			left[i] = x[i] - x[i - 1];
			sum += left[i];
//			System.out.println(left[i]);
		}
		Arrays.sort(left);

		int skippable = 0;
		for(int i = 0; i < n - 1; i++){
			skippable += left[m - i - 1];
//			System.out.println(skippable);
		}


		System.out.println(sum - skippable);
	}
}


Measured memory_bytes: 49528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
int x,y;
cin >> x>> y;
if(x==y){
    cout << (x-1)*(x-1) << endl;
}else{
    cout << (x-1)*(y-1) << endl;
}
return 0;
}

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

int main(){
    int N;
    cin >> N;
    int count[N]={}; 
    for(int i=0;i<N-1;i++){
        int a;
        cin >> a;
        a--;
        count[a]++;
    }
    for(int i=0;i<N;i++){
        cout << count[i] << endl;
    }
    return 0;
    return 0;
}

Measured memory_bytes: 4408
#include <stdio.h>


int main(void){

        int sum = 0;
        int count = 0;

        double m;
        int n;
        scanf("%d%lf",&n,&m);

        double s[n];
        double a[n];
        //char s[n],a[n];

        for(int i=0;i<n;i++){
                scanf("%lf",&s[i]);
                sum += s[i];
        }   

        for(int i=0;i<n;i++){
                a[i] = s[i]/sum;
                //printf("%f",a[i]);
                if(a[i] >= 1.0/4/m){
                        count++;
                }   
        }   

//printf("%d",count);

        if(count >= m){ 
                printf("Yes\n");
        }else{
                printf("No\n");
        }   
return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))
#define N 100005

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);

int n, a[N], s;

int main(){
    cin >> n;
    for (int i=1; i<=n; i++) cin >> a[i], s ^= a[i];
    if (!s) rc("Yes");
    rc("No");
    return 0;
}


Measured memory_bytes: 764
import java.util.*;

public class Main {
    static Scanner s = new Scanner(System.in);

    static class AmidaSwitch implements Comparable<AmidaSwitch> {
        int h, p, q;

        @Override
        public int compareTo(AmidaSwitch o) {
            return -(this.h - o.h);
        }

        AmidaSwitch(int h, int p, int q) {
            this.h = h;
            this.p = p;
            this.q = q;
        }
    }

    public static void main(String[] args) {
        AmidaSwitch[] list;

        while (true) {
            int n = s.nextInt();
            int m = s.nextInt();
            int a = s.nextInt();

            if (n == 0 && m == 0 && a == 0) break;
            list = new AmidaSwitch[m];

            int[] amida = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                amida[i] = i;
            }

            for (int i = 0; i < m; i++) {
                int h = s.nextInt();
                int p = s.nextInt();
                int q = s.nextInt();
                list[i]= new AmidaSwitch(h,p,q);
            }

            Arrays.sort(list);

            for (int i = 0; i < list.length; i++) {
                AmidaSwitch tempAmida = list[i];

                int temp = amida[tempAmida.p];
                amida[tempAmida.p] = amida[tempAmida.q];
                amida[tempAmida.q] = temp;
            }

            int ans=0;
            for(int i=1;i<amida.length;i++){
                if(amida[i]==a){
                    ans=i;
                    break;
                }
            }
            System.out.println(ans);
        }
    }


}

Measured memory_bytes: 74884
S = input()

N = len(S)
ans = 0
for i in range(N):
  for j in range(i, N):
    is_ACGT = True
    for k in range(i, j+1):
      if S[k] not in ['A', 'C', 'G', 'T']:
        is_ACGT = False
        break
    if is_ACGT:
      ans = max(ans, j-i+1)

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <string>

#define ll long long
#define rep(i, x) for(register ll i = 0; i < x; i++)

using namespace std;

int main()
{
  double D, T, S;
  cin >> D >> T >> S;

  if(D / T <= S){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3700
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const int MX = 100 * 1000 + 7;

ll dp[MX][3];
int c[MX][3];

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + c[i + 1][k]);
                }
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < 3; i++) {
        ans = max(ans, dp[n][i]);
    }

    cout << ans << "\n";
    return 0;
}



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



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

    ll ans=1; 
    rep(i,m){
      ans *=2;
     }
    cout << ((n-m)*100+1900*m) *ans<< endl;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	string s;
	cin>>s;
	int n = s.size();
	int ans1 = 0, ans2 = 0;
	for(int i = 0; i < n; i++){
		if(i&1){
			if(s[i] == '0')ans1++;
			else ans2++;
		}else{
			if(s[i] == '0')ans2++;
			else ans1++;
		}
	}
	cout<<min(ans1, ans2)<<endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int n,len;
    cin>>n>>len;
    string*s=new string[n];
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;i++)
    {
        cout<<s[i];
    }
    delete []s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    int x = 0;
    rep(i,n)if(s[i]=='#') ++x;

    int d = 0;
    int ans = min(x,n-x);
    for(int i=n-1; i>=0; --i){
        if(s[i]=='.'){
            ++d;
        }
        else --x;
        ans = min(ans, d+x);
    }

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


Measured memory_bytes: 640
a,b,c,d,e,f=map(int,input().split())

wa=[]
su=[]
for i in range(1,31):
  for j in range(0,31):
    x=i-j*a
    if x>=0:
      if x%b==0:
        wa.append(i*100)
        
for p in range(1,3001):
  for q in range(0,3001):
    y=p-q*c
    if y>=0:
      if y%d==0:
        su.append(p)
        
wa1=list(set(wa))
su1=list(set(su))

ans=0
ans1=[]
for r in wa1:
  for t in su1:
    if r+t<=f and t/r <= e/100:
      if t/(r+t)>=ans:
        ans=t/(r+t)
        ans1.append([r,t])
        
if len(ans1)==0:
  print(str(wa[0])+' '+str(0))
else:
  W=ans1[-1][0]
  S=ans1[-1][1]
  print(str(W+S)+' '+str(S))

Measured memory_bytes: 26540
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;


int main()
{
  // 整数の入力

  ll N, M;
  cin >> N >> M;
  vector<set<ll>> G(N);
  vector<ll> H;
  for(int i = 0;i < N;i++){
    ll h;
    cin >> h;
    H.push_back(h);
  }
  for (int i = 0; i < M; i++)
  {
    ll a, b;
    cin >> a >> b;
    a--;b--;
    G[a].insert(b);
    G[b].insert(a);
  }
  ll count = 0;
  for(int i = 0;i < N;i++){
    bool highest = true;
    for(auto to:G[i]){
      if (H[i] <= H[to]){
        highest = false;
        break;
      }
    }
    if (highest){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 18168
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template<class T>using vv = vector<vector<T>>;

#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif


const int INF = 1e9+7;
int main() {
  int N; cin >> N;
  int X, Y; cin >> X >> Y;
  --X, --Y;

  // rep(k, 1, N) {
  // }

  vv<int> distance(N, vi(N, INF));

  rep(i, N) {
    queue<int> q;
    q.push(i);
    distance[i][i] = 0;
    while (!q.empty()) {
      int p = q.front(); q.pop();
      if (p > 0) {
        if (chmin(distance[i][p-1], distance[i][p] + 1)) {
          q.push(p-1);
        }
      }
      if (p + 1 < N) {
        if (chmin(distance[i][p+1], distance[i][p] + 1))
          q.push(p+1);
      }
      if (p == X)
        if (chmin(distance[i][Y], distance[i][p] + 1)) {
          q.push(Y);
        }
      if (p == Y)
        if (chmin(distance[i][X], distance[i][p] + 1)) {
          q.push(X);
        }
    }
  }
  vi ans(N, 0);
  rep(i, N) rep(j, i, N) {
    ++ans[distance[i][j]];
  }
  rep(k, 1, N) {
    cout << ans[k] << endl;
  }


  return 0;
}


Measured memory_bytes: 16000
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

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

    int ans=1000000000;
    int price;
    for(Nab=0;Nab<2*max(X,Y)+1;Nab +=2){
        price = max((X-Nab/2)*A,0) + max((Y-Nab/2)*B,0) + Nab*C;
        ans = min(ans, price);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

N,M,P = map(int,(input().split()))
line = []
for i in range(M):
    a,b,c = map(int,(input().split()))
    line.append([a-1,b-1,-c+P])

min_distance = [float("inf")]*N # min_distance[i] は始点から街iまでの最短距離
min_distance[0] = 0 # 始点から始点への最短距離は0とする

def Bellman_Ford(S,V,E,distance):
    update = False
    flag = 0
    for _ in range(V):
        for s,g,d in distance: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
            if min_distance[s] != float("inf") and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
                min_distance[g] = min_distance[s] + d # 最短距離を上書きする
                update = True
        if not update:
            flag = 1
            break
    return min_distance,flag

def Bellman_Ford2(S,V,E,distance):
    for _ in range(V):
        for s,g,d in distance: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
            if min_distance[s] != float("inf") and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
                min_distance[g] = -float("inf")
                if g == N-1:
                    print(-1)
                    exit()
                    break
        else:
            continue
        break
    return min_distance

min_distance,flag = Bellman_Ford(1,N,M,line)

if flag == 1:
    ans = min_distance[N-1]
    print(max(-ans,0))
else:
    min_distance = Bellman_Ford2(1,N,M,line)
    ans = min_distance[N-1]
    if ans == -float("inf"):
        print(-1)
    else:
        print(max(-ans,0))

#print(min_distance)


Measured memory_bytes: 75888
//  Created by liszt on 2019/07/21.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,l; cin>>n >>l;
    string s[110];
    for(int i=0;i<n;i++)cin>>s[i];
    sort(s,s+n);
    for(int i=0;i<n;i++)cout<<s[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

type FloatSlice []float64

func (a FloatSlice) Len() int           { return len(a) }
func (a FloatSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a FloatSlice) Less(i, j int) bool { return a[i] > a[j] }

type Value struct {
	value float64
	ok    bool
}

// main is...
func main() {
	var n int
	fmt.Scanln(&n)

	var sc = bufio.NewScanner(os.Stdin)
	if sc.Scan() {
		array := strings.Fields(sc.Text())[:n]
		fmt.Print(runC(array))
	}
}

// runC is run
func runC(arrayStr []string) float64 {
	n := len(arrayStr)
	var array = make([]float64, n)

	for idx, value := range arrayStr {
		valueInt, _ := strconv.Atoi(value)
		array[idx] = float64(valueInt)
	}

	sort.Float64s(array)
	var ret float64 = 0

	for idx, value := range array {
		if idx == 0 {
			ret = (value + array[idx+1]) / 2
			continue
		}
		if idx == 1 {
			continue
		}
		ret = (ret + value) / 2
	}
	return ret

	// arrayRet := make([]float64, Fact(n))
	// ret := float64(0)
	// c := 0

	// for i := 0; i < n-1; i++ {
	// 	for j := i + 1; j < n; j++ {
	// 		array2 := make([]Value, n)
	// 		for idx, value := range array {
	// 			array2[idx].value = value
	// 			array2[idx].ok = false
	// 		}
	// 		ret = (array[i] + array[j]) / 2

	// 		array2[i].ok = true
	// 		array2[j].ok = true
	// 		for idx, value := range array2 {
	// 			if array2[idx].ok {
	// 				continue
	// 			}
	// 			ret = (ret + value.value) / 2
	// 			array2[idx].ok = true
	// 		}

	// 		// arrayRet[c] = ret
	// 		arrayRet = append(arrayRet, ret)
	// 		c++
	// 	}
	// }

	// sort.Sort(FloatSlice(arrayRet))

	// return arrayRet[0]
}

// 階乗
// https://qiita.com/ozwk/items/4ffdba8e83df1171ac39
func Fact(n int) int {
	if n > 1 {
		return n * Fact(n-1)
	}
	return 1
}


Measured memory_bytes: 640
def exclude_not_exist_point(sink_points)
  sink_points.reject do |x, y|
    x < 0 or x >= 10 or y < 0 or y >= 10
  end
end

def small_sink_points(x, y)
  exclude_not_exist_point([
    [x - 1, y],
    [x, y + 1],
    [x, y],
    [x, y - 1],
    [x + 1, y],
  ])
end

def medium_sink_points(x, y)
  sink_points = []

  (-1..1).each do |x_offset|
    (-1..1).each do |y_offset|
      sink_points.push([x + x_offset, y + y_offset])
    end
  end

  exclude_not_exist_point(sink_points)
end

def large_sink_points(x, y)
  sink_points = []

  5.times do |i|
    case i
    when 0, 4
      sink_points.push([x + (i.zero? ? 2 : -2), y])
    when 1, 3
      sink_points.concat((-1..1).map { |y_offset|
        [x + (i == 1 ? 1 : -1), y + y_offset]
      })
    when 2
      sink_points.concat((-2..2).map { |y_offset|
        [x, y + y_offset]
      })
    end
  end

  exclude_not_exist_point(sink_points)
end

paper = Array.new(10) { Array.new(10) { 0 }}

while line = gets
  x, y, size = line.split(',').map(&:to_i)
  sink_points = []

  case size
  when 1
    sink_points = small_sink_points(x, y)
  when 2
    sink_points = medium_sink_points(x, y)
  when 3
    sink_points = large_sink_points(x, y)
  end

  sink_points.each do |point|
    paper[point[0]][point[1]] += 1
  end
end

not_colored_cell = 0
most_deep_num = 0

paper.each do |row|
  not_colored_cell += row.count(&:zero?)
  most_deep_num = row.max if row.max > most_deep_num
end

puts not_colored_cell, most_deep_num

Measured memory_bytes: 8656
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
inline int read(){
	int ret=0,p=1;
	char ch=getchar();
	while (ch<'0' || ch>'9'){if (ch=='-') p=-1;ch=getchar();}
	while (ch>='0' && ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*p;
}
struct str{
	int a,b;
}a[200000+3];
int n;
int ans[200000+3];
inline bool cmp(str a,str b){
	return a.a<b.a;
}
int main(){
	n=read();
	for (int i=1;i<=n;i++){
		a[i].a=read();a[i].b=i;
	}
	sort(a+1,a+n+1,cmp);
	int t=n/2;
	for (int i=1;i<=t;i++){
		ans[a[i].b]=a[t+1].a;
	}
	for (int i=t+1;i<=n;i++){
		ans[a[i].b]=a[t].a;
	}
	for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}

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

int main() {
    string N;
    cin>>N;
    bool ans = false;
    for(int i=0;i<N.size();++i){
        if(N[i]=='7')ans = true;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, Y;
    cin >> N >> Y;

    rep(i, N + 1) {
        rep(j, N + 1 - i) {
            if (Y == i * 10000 + j * 5000 + (N - i - j) * 1000) {
                cout << i << " " << j << " " << N - i - j << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define pii pair<int,int>
#define x first
#define y second

const int N=1e5+5;
int ans,n,a[N],b[N];
pii p[N];

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i],b[i]);
    int maa=*max_element(a+1,a+1+n);
	int mib=*min_element(b+1,b+1+n);
    for(int i=1;i<=n;i++) p[i]=pii(mib-a[i]+1,b[i]-maa+1);
    sort(p+1,p+1+n);
    int m2=1e9;
    for(int i=1;i<n;i++){
        m2=min(m2,p[i].y);
        ans=max(ans,p[i+1].x+m2);
    }
    for(int i=1;i<=n;i++){
        int cur=b[i]-a[i]+1;
        cur+=max(0,mib-maa+1);
        ans=max(ans, cur);
    }
    write(ans);
}

Measured memory_bytes: 5172
n = int(input())
H = [int(i) for i in input().split()]
dp = [0] * n

dp[1] = abs(H[0] - H[1])
for i in range(2, n):
    dp[i] = min(abs(H[i] - H[i - 1]) + dp[i -1], abs(H[i] - H[i - 2]) + dp[i - 2])
    
print(dp[-1])

Measured memory_bytes: 13928
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <map>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)

using namespace std;
typedef long long int ll;

const ll mod = 1000000000+7;

int four(int p3,int p2,int p1){
    return p3*16+p2*4+p1;
}


ll dp[100005][64];

int main(){
    int N;
    cin>>N;
    map<int,int> mp;
    mp[four(0,0,1)]=2;
    mp[four(1,0,1)]=2;
    mp[four(2,0,1)]=2;
    mp[four(3,0,1)]=2;
    mp[four(0,3,1)]=2;
    mp[four(0,1,3)]=2;
    mp[four(0,1,1)]=2;
    mp[four(0,1,0)]=2;
    mp[four(1,1,0)]=2;
    mp[four(2,1,0)]=2;
    mp[four(3,1,0)]=2;
    mp[four(0,0,2)]=1;
    mp[four(1,0,2)]=1;
    mp[four(2,0,2)]=1;
    mp[four(3,0,2)]=1;

    for(int i = 0;i <64;i++){
        dp[3][i]=1;
    }
    dp[3][four(0,1,2)]=0;
    dp[3][four(1,0,2)]=0;
    dp[3][four(0,2,1)]=0;
    for(int s = 3;s < N;s++){
        for(int p3 = 0;p3 < 4;p3++){
            for(int p2 = 0;p2 < 4;p2++){
                for(int p1 = 0;p1 < 4;p1++){
                    int no = -1;
                    if(mp.find(four(p3,p2,p1))!=mp.end()){
                        no = mp[four(p3,p2,p1)];
                    }
                    for(int p0 = 0;p0 < 4;p0++){
                        if(p0==no)
                            continue;
                        dp[s+1][four(p2,p1,p0)]+=dp[s][four(p3,p2,p1)];
                        dp[s+1][four(p2,p1,p0)]%=mod;
                    }
                }
            }
        }
    }
    ll ans = 0;
    for(int i = 0;i <64;i++){
        ans += dp[N][i];
        ans %= mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int kazu[] =new int[N+1];
        boolean flag = true;
        int ans = -1;
        for(int i=0;i<=N;i++){
            kazu[i]=-1;
        }
        for(int i=0;i<M;i++){
            int s = sc.nextInt();
            int c = sc.nextInt();
            if(kazu[s]!=-1 && kazu[s]!=c)flag=false;
            if(s==1 && c==0 && N!=1)flag = false;
            kazu[s] = c;
        }
        if(flag){
            String str="";
            for(int i=1;i<=N;i++){
                if(kazu[i]==-1){
                    kazu[i]=0;
                    if(i==1 && N!=1)kazu[i]=1;
                }
                str +=Integer.toString(kazu[i]);
            }
            ans=Integer.parseInt(str);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include<stdio.h>
int main(void){
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<b){
		
		if(b<c){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
		
	}else{
		
		printf("No\n");
		
	}
	
	return 0;
}


Measured memory_bytes: 2044
import heapq

X, Y, Z, K = map(int, input().split())
*A, = sorted(map(int, input().split()))
*B, = sorted(map(int, input().split()))
*C, = sorted(map(int, input().split()))

class Delicious (object):
	def __init__(self, x, y, z):
		self.x = x
		self.y = y
		self.z = z
	
	def total(self):
		return A[self.x] + B[self.y] + C[self.z]
		
	def __lt__(self, other):
		return self.total() > other.total()
	
ds = [Delicious(X-1, Y-1, Z-1)]
check = {}

for k in range(K):
	d = heapq.heappop(ds)
	while (d.x, d.y, d.z) in check:
		d = heapq.heappop(ds)
	check[d.x, d.y, d.z] = True
	print(d.total())
	if 0 < d.x:
		heapq.heappush(ds, Delicious(d.x-1, d.y, d.z))
	if 0 < d.y:
		heapq.heappush(ds, Delicious(d.x, d.y-1, d.z))
	if 0 < d.z:
		heapq.heappush(ds, Delicious(d.x, d.y, d.z-1))



Measured memory_bytes: 4980
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int d = sc.nextInt();

    if(d == 24){
        System.out.println("Christmas Eve");
    }else if(d == 23){
        System.out.println("Christmas Eve Eve");
    }else if(d == 22){
        System.out.println("Christmas Eve Eve Eve");
    }else{
        System.out.println("Christmas");
    }
    
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
#define endl '\n'

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n >> m){
        cout << ((n + 1) / 2 >= m ? "YES" : "NO") << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,K = map(int, input().split())
    MOD = 10**9+7

    for i in range(1,K+1):
        if N-K+1-i < 0:
            print(0)
        else:
            a = factorial(N-K+1)//(factorial(N-K+1-i)*factorial(i))
            b = factorial(K-1)//(factorial(K-i)*factorial(i-1))
            print(a*b % MOD)

if __name__ == '__main__':
    main()

Measured memory_bytes: 20200
#include<bits/stdc++.h>                
using namespace std;
#define REP(i,n) for(auto i = 0; i < (n); ++i)
#define REP1(i,n) for(auto i = 0; i <= (n); ++i)
#define REPO(i,o,n) for(auto i = (o); i < (n); ++i)
#define REPR(i,n) for(auto i = (n); i >= 0; --i)
#define REPI(itr,v) for(auto itr=v.begin(); itr != v.end(); ++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin(); itr != v.rend(); ++itr)
#define ALL(v) v.begin(), v.end()
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}
#define push_back pb;
#define push_front pf; 
#define make_pair mp;
#define first fi;
#define second se;
typedef long long ll;

int main(void){
	int A, B, C;
	cin >> A >> B >> C;
	cout << min(A+B, min(B+C, C+A)) << endl;
}


Measured memory_bytes: 256
a,b,c = map(float, input().split())

import math
h = math.sin(math.radians(c)) * b
s = a * h / 2

a1 = math.cos(math.radians(c)) * b
a2 = a - a1
x = (a2 ** 2 + h ** 2) ** 0.5
l = a + b + x

print(s)
print(l)
print(h)


Measured memory_bytes: 5696
def main():
    s = int(input())
    if s == 10**18:
        print(0,0,10**9,0,0,10**9)
        exit()
    if s//(10**9)==0:
        x = s%(10**9)
        y = s//(10**9)
        print(0,end=" ")
        print(0,end=" ")
        print(10**9, end = " ")
        print(1, end = " ")
        print(x,end =" ")
        print(y,end=" ")
    else:
        x = 10**9 - s%(10**9)
        y = s//(10**9) + 1 
        print(0,end=" ")
        print(0,end=" ")
        print(10**9, end = " ")
        print(1, end = " ")
        print(x,end =" ")
        print(y,end=" ")

if __name__ == "__main__":
    main()

Measured memory_bytes: 40084
#include<cstdio>
const int N=1e5+7;
int flag,fa[N],val[N],n,m,i,j,x,y,z,p,q;
int find(int x){
	if(x==fa[x])return x;
	else{
		int tmp=fa[x];fa[x]=find(fa[x]);
		val[x]+=val[tmp];
		return fa[x];
	}
}
int main(){
	for(scanf("%d%d",&n,&m),i=1;i<=n;++i)fa[i]=i;
	for(;m--;){
		scanf("%d%d%d",&x,&y,&z);
		if(flag)continue;
		p=find(x);q=find(y);
		if(p==q){
			if(val[x]-val[y]!=z)flag=1;
		}else{
			fa[p]=q;
			val[p]=z+val[y]-val[x];
		}
	}
	puts(flag?"No":"Yes");
}

Measured memory_bytes: 896
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
Q = [tuple(map(int, input().split())) for _ in range(Q)]

res = 0

for A in combinations_with_replacement(range(1, M + 1), N):
    point = 0
    for a, b, c, d in Q:
        if A[b - 1] - A[a - 1] == c:
            point += d
    res = max(point, res)

print(res)

Measured memory_bytes: 9120
#!/usr/bin/env python3
import numpy as np

def solve(N, M, X, C, A):
    A = np.array(A)

    max_iq_list = sum(A)
    if min(max_iq_list) < X:
        print(-1)
        return

    cost_list = []
    for i in range(1, 2**N):
        book = []
        cost = 0
        for j in range(N):
            if ((i >> j) & 1):
                book.append(A[j])
                cost += C[j]
        if min(sum(np.array(book))) < X:
            pass
        else:
            cost_list.append(cost)

    print(min(cost_list))

def main():
    N, M, X = map(int, input().split())
    C = []
    A = []
    for i in range(N):
        C_A = list(map(int, input().split()))
        C.append(C_A[0])
        A.append(C_A[1:])
    solve(N, M, X, C, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27240
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>

using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;

int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll n;
	cin >> n;

	for(int i = 1;i<=n;i++)
	{
		ld y = 1.08;
		ld x = (ld) i * y;
		ll xx = (ll)x;
		if(xx==n) return cout << i << endl,0;
	}	cout << ":(\n";
	return 0;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 150

void trace(int *A, int n){
    for(int i=0;i<n;i++){
        if(i > 0) printf(" ");
        printf("%d",A[i]);
    }
    putchar('\n');
}

void bubbleSort(int *A, int n){
   int flag = 1;
   int counter=0;
   int a;
   int i=0;
   while(flag){
       flag = 0;
       for(int j=n-1;j>i;j--){
           if(A[j] < A[j-1]){
               a = A[j];
               A[j] = A[j-1];
               A[j-1] = a;
               flag = 1;
               counter +=1;
           }
        }
        i++;
    }
    trace(A,n);
    printf("%d\n",counter);
   
}
int main(){
    int n;
    int A[MAX];
    

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    bubbleSort(A,n);
    return 0;
    
}


Measured memory_bytes: 3132
n = int(input())
s = int(input())
if s == n:
    print(n+1)
    exit()
if s > n%2+n//2:
    print(-1)
    exit()
    

ans = float("INF")
for i in range(2,int(n**0.5)+1):
    x = n
    count = 0
    while x >= i:
        count += x%i
        x //= i
    if count + x == s:
        print(i)
        exit()
now = 2
li = int(n**0.5)+1
while True:

    x = n//now
    if x < li:
        break
    count = 0
    y = n
    while y >= x:
        count += y%x
        y //= x
    count += y
    if count <= s and (s-count)%now == 0:
        z = x-n//(now+1)
        if (s-count)//now < z:
            ans = x-(s-count)//now
    now += 1



print(min(ans,n-s+1))


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

int main()
{
  int n, m, ans = 0;
  cin >> n >> m;
  int cnt[m] = {0};
  for(int i = 0; i < n; i++)
  {
    int k;
    cin >> k;
    for(int j = 0; j < k; j++)
    {
      int x;
      cin >> x;
      x--;
      cnt[x]++;
    }
    for(int k = 0; k < m; k++)
    {
   	  if(n == cnt[k])
      {
  	    ans++;
      }
    }
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int n; cin >> n;
	int v[n], c[n];
	FOR(n) cin >> v[i];
	FOR(n) cin >> c[i];
	int ans = 0;
	FOR(n){
		if(v[i] > c[i]) ans += v[i] - c[i];
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long int
ll a[1000000+9]= {0};
using namespace std;
int main()
{
    ll n,k,j,i;
    cin>>n;
    ll s=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    cout<<s-n<<endl;
    return 0;
}


Measured memory_bytes: 256