akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 100050

#define ll long long
#define ld long double
#define lli long long int

#define pb emplace_back
#define INF 1000000000000

#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define loop(i,n) for (lli i = 0; i < n; i++)
#define loopitr(xt,vec) for (auto xt : vec)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)
#define loop_rev(i,n) for (lli i = n-1; i >= 0; i--)
#define FOR_REV(i,a,b) for (lli i = a; i >= b; i--)
#define itr :: iterator it
#define WL(t) while(t --)

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>
#define vi vector<lli>
#define vbool vector<bool>
#define seti set<lli>
#define pii pair<lli,lli>
#define pcc pair<char , char>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

#define endl '\n'

template <typename T>
void print(T x){cout<<x<<endl;}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<endl;}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<endl;}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvector(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvector(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define deb(x) cout<<#x<<" "<<x<<endl;



bool solve(string n){
  lli sum = 0;
  for(auto i:n){
 	sum+=i-'0';
  }
  if(sum%9==0) return true;
  return false;
}
int main(){
	fastio
	string n; cin>>n;
	if(solve(n))
		cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

// Author - Kevin Mathew
// Birla Institute of Technology, Mesra

ll n, k, a[((ll)(1e5 + 10L))], dp[((ll)(1e5 + 10L))];

ll solve(ll x){
	// cout << x << "-\n";
	if(x == n-1)
		return 0;
	if(x > n-1)
		return 9999999999999;
	if(dp[x] != -1)
		return dp[x];

	ll ans = LLONG_MAX;

	for(ll i=1;i<=k;i++)
		if(x + i < n)
			ans = min(ans, abs(a[x]-a[x+i]) + solve(x+i));

	// cout << ans << " " << x << "\n";
	return dp[x] = ans;
}

void te(){
	cin >> n >> k;
	for(ll i=0;i<n;i++){
		cin >> a[i];
		dp[i] = -1;
	}

	cout << solve(0) << "\n";
}

int main()
{
	//freopen("input.txt", "r", stdin);		//Comment
	//freopen("output.txt", "w", stdout);		//this out.
	ios::sync_with_stdio(false);			//Not
	cin.tie(NULL);							//this.
	cout.tie(0);							//or this.

	te();

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  int len = 0;
  
  int nowH;
  cin >> nowH;
  
  int H;
  for (int i = 1; i < N; i++) {
    cin >> H;
    if (nowH >= H) {
      len++;
      ans = max(ans, len);
    } else {
      len = 0;      
    }
    nowH = H;
  }
  
  cout << ans;  
}

Measured memory_bytes: 256
main = putStrLn . solve . lines =<< getContents

solve [as,bs,cs] =
    let f 'a' as' bs' cs'
            | null as' = "A"
            | otherwise = f (head as') (tail as') bs' cs'
        f 'b' as' bs' cs'
            | null bs' = "B"
            | otherwise = f (head bs') as' (tail bs') cs'
        f 'c' as' bs' cs'
            | null cs' = "C"
            | otherwise = f (head cs') as' bs' (tail cs')
    in f 'a' as bs cs


Measured memory_bytes: 508
MOD = 10**9 + 7

class Combination
  def initialize
    @fact = (1..10**6).to_a
    @fact.each_with_index do |e, idx|
      @fact[idx] = @fact[idx] * @fact[idx-1] % MOD if idx > 0
    end
  end

  def choose(n, r)
    return 0 if not (0 <= r and r <= n)
    return 1 if r == 0 or r == n
    fact(n) * inverse( fact(r) * fact(n-r) % MOD ) % MOD
  end

  def fact(n)
    @fact[n-1]
  end

  def inverse(x)
    pow(x, MOD-2)
  end

  def pow(x, n)
    ans = 1
    while n > 0
      ans = ans * x % MOD if n.odd?
      x = x * x % MOD
      n >>= 1
    end
    ans
  end
end

lines = $stdin.read
array = lines.split("\n")
X,Y = array[0].split(" ").map(&:to_i)

if (X+Y)%3!=0
  puts 0
  exit 0
end

# 2*n + 4*m = 2*X
# 2*n + m = Y
# 3*m = 2*X - Y
# n = (Y-m)/2
m = (2*X - Y) / 3
n = (Y-m)/2

if m<0 or n<0
  puts 0
  exit 0
end

comb = Combination.new
puts comb.choose(m+n,n)

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

using namespace std;
using ll=long long;

void solve() {
    int k,q;
    cin >> k >> q;
    vector<ll> d(k);
    for (auto& x: d) {
        cin >> x;
    }
    while (q--) {
        ll n,x,m;
        cin >> n >> x >> m;
        n--;
        x %= m;
        ll sum = 0;
        for (auto& x: d) {
            sum += x%m;
        }
        ll z = x + (n/k) * sum;
        {
            ll r = n%k;
            for (int i = 0; i < r; i++) {
                z += d[i]%m;
            }
        }
        
        ll res = z / m;
        for (int i = 0; i < k; i++) {
            if (d[i]%m == 0 && i < n) {
                res += 1 + (n-i-1) / k;
            }
        }
        res = n - res;
        cout << res << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

using namespace std;

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto n = readln.chomp.to!int;
  auto f = new int[][](n, 10);
  auto p = new int[][](n, 10);

  foreach (i; 0..n) {
    f[i] = readln.chomp.split.to!(int[]);
  }
  foreach (i; 0..n) {
    p[i] = readln.chomp.split.to!(int[]);
  }

  auto m = int.min;
  
  foreach (i; 1..2^^10) {
    auto cnt = new int[](n);
    foreach (j; 0..10) {
      if (i & 1 << j) {
        foreach (k; 0..n) {
          if (f[k][j]) {
            cnt[k]++;
          }
        }
      }
    }
    int lm;
    foreach (j; 0..n) {
      lm += p[j][cnt[j]];
    }

    m = max(lm, m);
  }

  m.writeln;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
long long a[100010];
long long b[100010];
int main()
{
	int n,l;
	cin>>n>>l;
	for(int i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	long long ans=0;
	int pos=0;
	for(int i=1;i<n;i++)
	  {
	  	if(a[i]+a[i+1]>ans)
	  	  {
	  	  	ans=a[i]+a[i+1];
	  	  	pos=i;
		  }
	  }
	if(ans>=l)
	  {
	  	printf("Possible\n");
	  	
	  	for(int i=n-1;i>pos;i--)
	  	  printf("%d\n",i);
	  	for(int i=1;i<pos;i++)
	  	  printf("%d\n",i);
		printf("%d\n",pos);
	  }
	else
	  {
	  	printf("Impossible\n");
	  }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define pb push_back
#define mk make_pair
#define ascSort(v) sort(v.begin(), v.end())
#define descSort(v) sort(v.begin(), v.end(), greater<int>())
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define umapi unordered_map<int,int>

const int m=998244353;
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>PBDS;

void FIO(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
}



int32_t main(){
	
	//FIO();
		int a,b,c,k;cin>>a>>b>>c>>k;
		int sum=0;
		int cards=k;

		sum+=min(cards,a);
		cards-=min(cards,a);
		if(cards){
			//sum+=min(cards,a);
			cards-=min(cards,b);
		}
		if(cards)
			sum-=cards;
		cout<<sum<<"\n";

	
		
	
	

	
	

	return 0;
	
		
}
		
		



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}

int main(){
    ll n,p;cin >> n >>p;
    if(n==1)cout << p <<endl,exit(0);
    vl cnt(1000010,0);
    for(int i=2;i<sqrt(p)+2;i++){
        while(p%i==0){
            cnt[i]++;
            p/=i;
        }
    }
    ll res=1;
    rep(i,1000010){
        if(cnt[i]>=n){
            rep(j,cnt[i]/n)res*=i;
        }
    }
    cout << res <<endl;
}

Measured memory_bytes: 11192
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,ans=0;
    cin >> n; 
    int a[n];
    for (int &i: a) cin >> i; 
    int cur=a[0],c=0;
    for (int i=1;i<n;i++){
        if (cur>=a[i]) c++;
        else c=0;
        cur = a[i];
        ans = max(ans,c);
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4424
/**
  *  Worg
  */
#include <iostream>

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

  int a = n % 10; n /= 10;
  int b = n % 10; n /= 10;
  int c = n % 10; n /= 10;
  int d = n % 10; n /= 10;

  if (a == b && b == c) {
    std::cout << "Yes\n"; return 0;
  }
  if (b == c && c == d) {
    std::cout << "Yes\n"; return 0;
  }

  std::cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <string>

const int maxH = 2000000;
const int infty = 2000000001;
using array = std::array<int, maxH>;
using iterator = array::iterator;

auto swap = [](iterator a, iterator b)
            {
              auto tmp = *a;
              *a = *b;
              *b = tmp;
            };

void maxHeapify(iterator begin, iterator end, int i)
{
  auto cur = begin + i -1;
  auto left = begin + 2*i -1;
  auto right = left + 1;

  //std::cout << *cur << ' ' << *left << ' ' << *right << std::endl;

  auto largest = cur;
  if (left < end && *left > *largest)
    largest = left;
  if (right < end && *right > *largest)
    largest = right;

  if (largest != cur)
    {
      swap(cur, largest);
      maxHeapify(begin, end, std::distance(begin, largest)+1);
    }
}

void buildMaxHeap(iterator begin, iterator end)
{
  auto H = std::distance(begin, end);
  for (int i=H/2; i>0; --i)
    {
      maxHeapify(begin, end, i);
    }
}

void insert(iterator begin, int &n, int key)
{
  auto end = begin + n;
  *end = key;
  ++n;

  auto parent = begin + n/2 - 1;
  while (*parent < *end && parent >= begin)
    {
      swap(parent, end);
      end = parent;
      parent = begin + (std::distance(begin, end)+1)/2 - 1;
    }
}

int extract(iterator begin, int &n)
{
  int max = *begin;
  *begin = *(begin + n - 1);
  maxHeapify(begin, begin+n, 1);
  --n;

  return max;
}
int main ()
{
  int n = 0;
  std::string order;
  std::array<int, maxH> heap;

  std::cin >> order;
  while (order != "end")
    {
      if (order == "insert")
        {
          int key;
          std::cin >> key;
          insert(heap.begin(), n, key);
        }
      else if (order == "extract")
        {
          std::cout << extract(heap.begin(), n) << std::endl;
        }
      std::cin >> order;
    }
}



Measured memory_bytes: 7076
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    int mx, mn;
    cin >> mx; mn = mx; 
    REP(i, n-1){
        int a; cin >> a;
        mx = max(mx, a);
        mn = min(mn, a);
    }
    cout << mx - mn << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
	long x, y, i, j, m, n, max = 0, min = 0, sum = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> x;
		if (i == 0) {
			max = x;
			min = x;
		}
		sum =sum +x;
		if (max < x) {
			max = x;
		}
		if (min > x) {
			min = x;
		}
	}
	printf("%ld %ld %ld\n", min, max, sum);
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

#define DBG 0

int N=50;
int K=250;
int A[50][50];

int cnt;

int q(int y1,int x1,int y2,int x2){
    if((y2-y1)*(x2-x1)==0)return 0;

    if(DBG){
        int res=0;
        for(int y=y1;y<y2;y++)for(int x=x1;x<x2;x++)res+=A[y][x];
        return res;
    }

    else{
        cout<<"? "<<y1<<" "<<x1<<" "<<y2-1<<" "<<x2-1<<endl;
        int p;cin>>p;
        return p;
    }
}


vector<int>lis[2555];
int dfs(int y1,int x1,int y2,int x2,int p){
    if(y1==y2)return 0;
    if(x1==x2)return 0;

    if((y2-y1)*(x2-x1)==p){
        for(int y=y1;y<y2;y++)for(int x=x1;x<x2;x++)A[y][x]=1;
        return 0;
    }

    if(p==0)return 0;
    int y3=(y1+y2)/2;
    int x3=(x1+x2)/2;

    int pl=q(y1,x1,y2,x3);
    int pu=q(y1,x1,y3,x2);

    int p11,p12,p21,p22;

    int cnt=2;

    if(pl==0){
        p11=p21=0;
        p12=pu;
        p22=p-pu;
    }
    else if(pl==p){
        p12=p22=0;
        p11=pu;
        p21=p-pu;
    }
    else if(pu==0){
        p11=p12=0;
        p21=pl;
        p22=p-pl;
    }
    else if(pu==p){
        p21=p22=0;
        p11=pl;
        p12=p-pl;
    }
    else{
        p11=q(y1,x1,y3,x3);
        p12=pu-p11;
        p21=pl-p11;
        p22=p-p11-p12-p21;
        cnt++;
    }

    cnt+=dfs(y1,x1,y3,x3,p11);
    cnt+=dfs(y1,x3,y3,x2,p12);
    cnt+=dfs(y3,x1,y2,x3,p21);
    cnt+=dfs(y3,x3,y2,x2,p22);

    lis[(y2-y1)*(x2-x1)].pb(cnt);
    return cnt;
}

signed main(){
    if(DBG){
        vector<pint>v;
        rep(i,N)rep(j,N)v.pb({i,j});
        srand((unsigned)time(NULL));
        random_shuffle(all(v));

        for(int i=0;i<K;i++){
            A[v[i].fi][v[i].se]=1;
        }
        int sum=0;
        const int B=7;
        for(int i=0;i<(N+B-1)/B;i++){
            for(int j=0;j<(N+B-1)/B;j++){
                int p=q(i*B,j*B,min(N,(i+1)*B),min(N,(j+1)*B));
                sum++;
                sum+=dfs(i*B,j*B,min(N,(i+1)*B),min(N,(j+1)*B),p);
            }
        }
        int cnt=0;
        rep(i,N)rep(j,N)cnt+=A[i][j];
        cout<<cnt<<endl;
        cout<<sum<<endl;

        cout<<dfs(0,0,N,N,K)<<endl;
    }

    else{
        int tmp;
        cin>>tmp;cin>>tmp;cin>>tmp;
        int mod;cin>>mod;

        const int B=7;
        for(int i=0;i<(N+B-1)/B;i++){
            for(int j=0;j<(N+B-1)/B;j++){
                int p=q(i*B,j*B,min(N,(i+1)*B),min(N,(j+1)*B));
                dfs(i*B,j*B,min(N,(i+1)*B),min(N,(j+1)*B),p);
            }
        }

        int p=1;
        int res=0;
        rep(i,N)rep(j,N){
            res=(res+p*A[i][j])%mod;
            p=p*2%mod;
        }

        cout<<"! "<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 848
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;

int main(){
 int n,m;
 cin>>n>>m;
 int a[n];
 int total =0;
 rep(i,n){
     cin>>a[i];
     total+=a[i];
 }
 int count =0;
 rep(i,n){
     if(a[i]*4*m>=total)count++;
 }
 if(count>=m)cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.InputStream;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner fs = new FastScanner();

        final int N = fs.nextInt();
        final long X = fs.nextLong();

        long[] x = new long[N];

        for (int i = 0; i < N; i++) x[i] = Math.abs(fs.nextLong() - X);

        long ans = gcd_n(x);

        System.out.println(ans);
    }

    public static long gcd(long a, long b)
    {
        long result = a;
        long k = 0;
        long n = b;

        do {
            k = result % n;
            result = n;
            n = k;
        } while (k != 0);

        return result;
    }

    public static long gcd_n(long[] numbers)
    {
        long l;
        l = numbers[0];

        for (int i = 0; i < numbers.length; i++)
            l = gcd(l, numbers[i]);

        return l;
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const int N = 1e4 + 5;
int dp[N], a[N], b[N];

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	int h, n;
	scanf("%d%d", &h, &n);
	for (int i = 0; i < n; i++) scanf("%d%d", &a[i], &b[i]);

	dp[0] = 0;
	for (int i = 1; i <= h; i++) {
		dp[i] = 1e9;
		for (int j = 0; j < n; j++) {
			int k = max(0, i - a[j]);
			dp[i] = min(dp[i], dp[k] + b[j]);
		}
	}
	printf("%d\n", dp[h]);
}


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

using namespace std;

int n, m;
vector<int> c;
vector<int> dp;

int main() {
    cin >> n >> m;
    dp.resize(n + 1, INF);
    c.resize(m);
    for (int i = 0; i < m; i++) {
        cin >> c[i];
    }

    dp[0] = 0;

    for (int i = 0; i < m; i++) {
        for (int j = c[i]; j <= n; j++) {
            dp[j] = min(dp[j], dp[j - c[i]] + 1);
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 3192
#![allow(dead_code)]
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};
#[fastout]
fn main() {
    input!(n: usize, x: usize, m: usize);

    let mut ans = Vec::with_capacity(1000);
    ans.push(x);

    for i in 1..n {
        let buff = ans[i - 1].pow(2) % m;
        if ans.contains(&buff) {
            let pos = ans.iter().position(|x| *x == buff).unwrap();
            let ans_len = ans.len();
            let wa = ans_len - pos;

            let count = (n - ans_len) / wa;
            let count_m = (n - ans_len) % wa;

            let mut sum = ans.iter().take(ans_len - wa + count_m).sum::<usize>();

            sum += ans.iter().skip(ans_len - wa).sum::<usize>() * (count + 1);
            println!("{}", sum);
            return;
        }

        ans.push(buff);
    }

    println!("{}", ans.iter().sum::<usize>());
}


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

using i64 = int64_t;

int main(){ 
  i64 a, b;
  cin >> a >> b;
  if((a+b)%2)
    cout << "IMPOSSIBLE" << endl;
  else
    cout << (a+b) / 2 << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll LINF = 1e18;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}

int main()
{
  int r,g,b,n;
  cin >> r >> g >> b >> n;
  vector<int> cnt(n+1,0);

  for(int i=0;i<=n/r;i++){
    for(int j=0;j<=n/g;j++){
      if(i*r+j*g <= n) cnt[i*r+j*g]++;
    }
  }
  int ans = 0;
  for(int i=0;i<=n/b;i++){
    if(i*b<=n) ans += cnt[n-i*b];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define INF 10000000
using namespace std;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

signed main(){
    string s;
    cin >> s;
    int cnt = 0;
    int flag = 0;
    //cout << s.size() << endl;
    rep(i,s.size()){
        if(s[0] != 'A') {
            cout << "WA" << endl;
            return 0;
        }
        if(i >= 2  && i < s.size()-1) {
            if(s[i] == 'C') flag++;
        }
        if(s[i] >= 65 && s[i] <= 90) cnt++;
        //cout << flag << " " << cnt << endl;
    }
    if(flag == 1 && cnt == 2) cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;
}

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

int main(){
    int n, m; cin >> n >> m;
    vector<int> v[n];
    bool exit[n] = {0};
    for(int i = 0; i < m; ++i){
        int a, b; cin >> a >> b;
        --a; --b;
        if(b == n - 1) exit[a] = 1;
        if(a == n - 1) exit[b] = 1;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i = 0; i < n; ++i){
        if(exit[i]){
            for(int u : v[i]){
                if(!u){
                    cout << "POSSIBLE\n";
                    return 0;
                }
            }
        }
    }
    cout << "IMPOSSIBLE\n";
    return 0;
}

Measured memory_bytes: 12144
k, n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [min(a[i+1]-a[i], k-(a[i+1]-a[i])) for i in range(len(a)-1)]
b.append(min(a[len(a)-1] - a[0], k-(a[len(a)-1] - a[0])))
print(sum(b)-max(b))



Measured memory_bytes: 25736
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

void preparse(int u) {
	if (u == NIL) {
		return;
	}
	printf(" %d", u);
	preparse(T[u].l);
	preparse(T[u].r);
}

void inparse(int u) {
	if (u == NIL) {
		return;
	}
	inparse(T[u].l);
	printf(" %d", u);
	inparse(T[u].r);
}

void postparse(int u) {
	if (u == NIL) {
		return;
	}
	postparse(T[u].l);
	postparse(T[u].r);
	printf(" %d", u);
}

int main(void)
{
	int i, v, l, r, root;

	scanf("%d", &n);

	for (i = 0;i < n;i++) {
		T[i].p = NIL;
	}

	for (i = 0; i < n;i++) {
		scanf("%d %d %d", &v, &l, &r);
		T[v].l = l;
		T[v].r = r;
		if (l != NIL) {
			T[l].p = v;
		}
		if (r != NIL) {
			T[r].p = v;
		}
	}

	for (i = 0;i < n;i++) {
		if (T[i].p == NIL) {
			root = i;
		}
	}

	printf("Preorder\n");
	preparse(root);
	printf("\n");
	printf("Inorder\n");
	inparse(root);
	printf("\n");
	printf("Postorder\n");
	postparse(root);
	printf("\n");

	return 0;
}
 



Measured memory_bytes: 2100
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll a[7];
int main()
{
	for (int i = 0; i < 7; i++)
		scanf("%lld", &a[i]);
	ll dap = a[1] * 2;
	ll update = 0;
	if (a[0] > 0&&a[3]>0&&a[4]>0)
	{
		update = 6 + ((a[0] - 1) / 2 * 4) + (a[3] - 1) / 2 * 4 + (a[4] - 1) / 2 * 4;
	}
	dap = dap + max(update, a[0] / 2 * 4 + a[3] / 2 * 4 + a[4] / 2 * 4);
	printf("%lld", dap/2);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int n;
	std::vector<std::vector<int> > A;
	std::vector<std::vector<int> > S;
	std::vector<int> dp;
	int result = -10000000;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif
	A.resize(n, std::vector<int>(n, 0));
	S.resize(n + 1, std::vector<int>(n, 0));

	for(int y = 0; y < n; y++){
		for(int x = 0; x < n; x++){
#if INPUT_FROM_FILE
			ifs >> A[y][x];
#else
			std::cin >> A[y][x];
#endif
		}
	}

	for(int x = 0; x < n; x++){
		S[1][x] = A[0][x];
	}

	for(int y = 1; y < n; y++){
		for(int x = 0; x < n; x++){
			S[y + 1][x] = S[y][x] + A[y][x];
		}
	}

	for(int y = 0; y < n; y++){
		dp.clear();
		dp.resize(n, 0);
		dp[0] = A[y][0];
		for(int x = 1; x < n; x++){
			dp[x] = std::max(dp[x - 1] + A[y][x], A[y][x]);
		}
		result = std::max(result, *std::max_element(dp.begin(), dp.end()));
	}

	for(int r0 = 0; r0 < n; r0++){
		for(int r1 = r0 + 1; r1 < n; r1++){
			std::vector<int> a(n, 0);

			for(int x = 0; x < n; x++){
				a[x] = S[r1 + 1][x] - S[r0][x];
			}
			dp.clear();
			dp.resize(n, 0);
			dp[0] = a[0];
			for(int x = 1; x < n; x++){
				dp[x] = std::max(dp[x - 1] + a[x], a[x]);
			}
			result = std::max(result, *std::max_element(dp.begin(), dp.end()));
		}
	}

	std::cout << result << std::endl;
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
	return 0;
}


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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  string s,t;
  cin >> s;
  cin >> t;

  int maxCount = 0;
  for(int i=0;i<s.length()-t.length()+1;i++){
    int count = 0;
    for(int j=0;j<t.length();j++){
      if(s[i+j]==t[j]) count++;
    }
    maxCount = max(maxCount,count);
  }
  cout << t.length()-maxCount << endl;
  
  return 0;
}



Measured memory_bytes: 3620
n=int(input())
a=[list(map(int,input().split())) for _ in range(n-1)]

def arrive(time,now):
  if time>a[now][1]:
    time=(time+a[now][2]-1)//a[now][2]*a[now][2]+a[now][0]
  else: time=a[now][1]+a[now][0]
  if now==n-2:
    return time
  else:
    return arrive(time,now+1)

for i in range(n-1):
  print(arrive(a[i][1],i))
print(0)

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

int main() {
	int n,k;
	cin >> n >> k;
	vector< int > a(n);
	for (auto& e:a)
		cin >> e;
	sort(a.begin(),a.end());
	int ans = 0;
	for (int i=0; i<k; i++)
		ans += a[i];
	cout << ans << '\n';
}


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

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> p(A), q(B), r(C);
  for (int i = 0; i < A; i++) cin >> p.at(i);
  for (int i = 0; i < B; i++) cin >> q.at(i);
  for (int i = 0; i < C; i++) cin >> r.at(i);
  sort(p.begin(), p.end(), greater<int>());
  sort(q.begin(), q.end(), greater<int>());
  priority_queue<int> pq;
  for (int i = 0; i < X; i++) pq.push(p.at(i));
  for (int i = 0; i < Y; i++) pq.push(q.at(i));
  for (int i = 0; i < C; i++) pq.push(r.at(i));
  long long ans = 0;
  for (int i = 0; i < X + Y; i++) {
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
const int INF = 1000000000;
int dp[MAXN], npos[MAXN];
char cval[MAXN];
int main(int argc, char const *argv[])
{
	string A;
	cin>>A;
	int n = A.length();
	vector <int> nxt(26,INF);
	dp[n] = 1;
	cval[n] = 'a';
	npos[n] = INF;
	for (int i = n - 1; i >= 0; --i)
	{
		nxt[A[i] - 'a'] = i;
		dp[i] = INF;
		cval[i] = '.';
		npos[i] = INF;
		for (int j = 25; j >= 0; --j)
		{
			if(nxt[j] == INF)
			{
				dp[i] = 1;
				cval[i] = ((char)(j + 'a'));
				npos[i] = INF;
			}
			else
			{
				if(dp[nxt[j] + 1] + 1 <= dp[i])
				{
					dp[i] = dp[nxt[j] + 1] + 1;
					cval[i] = ((char)(j + 'a'));
					npos[i] = nxt[j] + 1;
				}
			}
		}
	}
	string ans = "";
	int cpos = 0;
	while(cpos < INF)
	{
		ans+=cval[cpos];
		cpos = npos[cpos];
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 2308
def main():
  n = int(input())
  ss = [input() for _ in range(n)]
  
  from collections import Counter
  
  cc = Counter(ss)
  
  kk = ["AC", "WA", "TLE", "RE"]
  
  for k in kk:
    if k in cc:
      print(f"{k} x {cc[k]}")
    else:
      print(f"{k} x 0")


if __name__ == "__main__":
  main()


Measured memory_bytes: 79516
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> h(n);
    for(int i=0; i<n; i++) cin>>h[i];
    sort(h.begin(),h.end(),greater<>());
    ll cnt=0;
    for(int i=0; i<n; i++){
        if(k>0){
            k--;
            continue;
        }else{
            cnt+=h[i];
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1792
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = []
c = [0]
for i in range(n):
    if a[i] < 0:
        b.append(abs(a[i]))
    elif a[i] > 0:
        c.append(a[i])
    else:
        k-=1
if k == 0:
    print(0)
    exit()
b.append(0)
b = b[::-1]
if len(b) == 1:
    print(c[k])
    exit()
if len(c) == 1:
    print(b[k])
    exit()
ans = 10 ** 18
for i in range(len(b)):
    if k - i >= len(c):
        continue
    if i == k:
        break
    #print(2*b[i]+c[k-i],b[i]+2*c[k-i])
    ans = min(ans,min(2*b[i]+c[k-i],b[i]+2*c[k-i]))
print(ans)

Measured memory_bytes: 14480
use v5.18;

chomp (my $n = <STDIN>);
chomp (my @p = split / /, <STDIN>);
my $ans = 0;
for my $i (0..$n-1) {
  if ($p[$i] == $i+1) {
    if ($i == $n-1) {
      ($p[$i], $p[$i-1]) = ($p[$i-1], $p[$i]);
    } else {
      ($p[$i], $p[$i+1]) = ($p[$i+1], $p[$i]);
    }
    $ans++;
  }
}
say $ans;

Measured memory_bytes: 16716
#include "bits/stdc++.h"
using namespace std;
long n ;
 
int main() {
  cin >> n;
  long sum = 0;
  long ssum = 0;
  long d = 0;
  for(int i=0;i<n;i++){
    cin >> d;
    sum += d;
    ssum += d*d;
  }
  cout << ((sum * sum) - ssum)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    
    int max_p = -1;
    int sum = 0;
    for(int i = 0; i < N; i++) {
        int p;
        cin >> p;
        sum += p;
        max_p = max(max_p, p);
    }
    
    cout << sum - max_p/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int top = 0;
int stack[200];

// 配列の初期化
void initialize()
{
    top = 0;
}

// スタックが空か調べる
bool isEmpty()
{
    return top == 0;
}

// スタックに値を追加
void push(int x)
{
    stack[top + 1] = x;
    top++;
}

// スタックから値を取得
int pop()
{
    int x = stack[top];
    stack[top] = 0;
    top--;
    return x;
}

int main()
{
    int a, b, result;
    char input;

    // 入力受け取り
    while (scanf("%s", &input) != EOF)
    {
        // +なら足し算
        if (input == '+')
        {
            a = pop();
            b = pop();
            result = a + b;
            push(result);
        }
        else if (input == '-')
        {
            a = pop();
            b = pop();
            result = b - a;
            push(result);
        }
        else if (input == '*')
        {
            a = pop();
            b = pop();
            result = a * b;
            push(result);
        }
        else
        {
            push(atoi(&input));
        }
    }

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

    return 0;
}


Measured memory_bytes: 3232
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
/*
time:
wa:
反省:
考察:
*/
int main() {
    int n;
    cin >> n;
    vector <double> a(n);
    double sum = 0;
    int min_n = 110;
    double min = 110;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    double ave = sum/(double)n;
    for(int i = 0; i < n; i++){
        double a_p = ((a[i]-ave) > 0) ? (a[i]-ave) : (ave-a[i]);
        if(min > a_p){
            min = a_p;
            min_n = i;
        }
    }
    cout << min_n << endl;
    return 0;
}

Measured memory_bytes: 3728
# -*- coding: utf-8 -*-

n = int(raw_input())
l = map(int, raw_input().split())

l.sort()

n = l[-1:][0]
# Comb(n,r) = n!/((n-r)!*r!)

def factorial(n):
    buff = n
    c_n = 1
    while buff > 0:
        c_n = c_n * n
        buff = buff - 1
    return c_n

i = 0
flag = True
while i < len(l) - 1:
    if i == len(l) - 2: 
        break
    c1 = (n - l[i+1]) * l[i+1]
    c2 = (n - l[i]) * l[i]
    if c1 < c2:
        break
    i = i + 1
print("{} {}".format(n,l[i]))


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s;cin >> s;
    cout << 700 + ((s[0] == 'o') + (s[1] == 'o') + (s[2] == 'o'))*100 << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'

function Main(input) {

  input = input.trim().split(' ')

  const a = parseInt(input[0])
  const b = parseInt(input[1])

  let res = ''
  if (a < b) {
    for(let i = 0; i < b; ++i) {
      res += `${a}`
    }
  } else {
    for(let i = 0; i < a; ++i) {
      res += `${b}`
    } 
  }

  console.log(res)


}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define INF 0X7FFFFFFF
#define LL long long
using namespace std;
int N,M;
LL ans=0;
int map[105][105];
int F[105];
int Node[105];
bool flag[105];
inline void dfs(int cnt)
{
	LL temp=0;
	for(int i=1;i<=cnt-1;i++)
		Node[F[i]]=INF;
	for(int i=1;i<=cnt-1;i++)
		for(int j=1;j<=cnt-1;j++)
		{
			if(i==j)	continue;
			Node[F[i]]=min(Node[F[i]],map[F[i]][F[j]]);
		}
	for(int i=1;i<=cnt-1;i++)
	{
		if(Node[F[i]]==INF)
			Node[F[i]]=0;
		temp+=Node[F[i]];
	}
	if(temp>ans) ans=temp;
	if(cnt>14) return ;
	for(int i=F[cnt-1];i<=N;i++)
	{
		if(flag[i])	continue;
		bool tag=0;
		for(int j=1;j<cnt;j++)
		{
			if(i==F[j]) continue; 
			if(!map[i][F[j]])
			{
				tag=1;break;
			}
		}
		if(tag==1)	continue;
		F[cnt]=i;flag[i]=1;
		dfs(cnt+1);
		flag[i]=0;
	}
}
int main()
{
	int i,a,b,c;
	memset(map,0,sizeof(map));
	scanf("%d%d",&N,&M);
	for(i=1;i<=M;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		map[a][b]=c;
		map[b][a]=c;
	}
	dfs(1);
	printf("%lld\n",ans);
	return 0;
}
 

Measured memory_bytes: 1084
import java.util.*;
import java.lang.*;


public class Main {


    static void impossible(){
        System.out.println("-1");
        System.exit(0);
    }
    static void printList(List<Integer> l){
        int N = l.size();
        int n=0;
        for(int e:l){
            n++;
            System.out.print(e+(n<N ? " " : "\n"));
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int M = sc.nextInt();
        int N = 1<<M;
        int K = sc.nextInt();

        if(K>=N) impossible();
        if(M==1&&K==1) impossible();
        if(M==1&&K==0){
            System.out.println("0 0 1 1");
            System.exit(0);
        }

        LinkedList<Integer> list = new LinkedList<>();
        list.add(K);
        for(int n=0; n<N; n++) if(n!=K){
            list.addFirst(n);
            list.addLast(n);
        }
        list.addLast(K);
        printList(list);
    }
}

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

bool b[300000000];
char c[10], s[13];
int h() {
	int a = 0, p = 1, k = strlen(s);
	rep(j, k) {
		if (s[j] == 'A')a += p;
		if (s[j] == 'G')a += p * 2;
		if (s[j] == 'C')a += p * 3;
		if (s[j] == 'T')a += p * 4;
		p *= 5;
	}
	return a;
}
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		scanf("%s%s", c, s);
		if (!strcmp(c, "insert"))b[h()] = 1;
		else puts(b[h()] ? "yes" : "no");
	}
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
   int n;
   scanf("%d", &n);
   vector<int> a(n), b(n), c(n);
   for (int &x : a) scanf("%d", &x);
   for (int &x : b) scanf("%d", &x);
   for (int &x : c) scanf("%d", &x);
   sort(a.begin(), a.end());
   sort(b.begin(), b.end());
   sort(c.begin(), c.end());
   vector<ll> ways(n);
   int j = 0;
   for (int i = 0; i < n; i++) {
       while (j < n && a[j] < b[i]) j++;
       ways[i] = j;
   }
   for (int i = 1; i < n; i++) ways[i] += ways[i - 1];
   j  =0;
   ll res = 0;
   for (int i = 0; i < n; i++) {
       while (j < n && b[j] < c[i]) j++;
       if (j > 0) res += ways[j - 1];
   }
   cout << res << endl;
}



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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  // A > B のときGREATER、 A < B のときLESS、 A =
  //    B のときEQUALと出力せよ。
  if(a.size() > b.size() || (a.size() == b.size() && a > b))
    cout << "GREATER" << endl;
  else if(a == b)
    cout << "EQUAL" << endl;
  else
    cout << "LESS" << endl;
  return 0;
}


Measured memory_bytes: 256
n,q = map(int, input().split())
s = input()

a = [0] * (n+1)
for i in range(n-1):
    if s[i:i+2] == "AC":
        a[i+1] = a[i] + 1
    else:
        a[i+1] = a[i] 

for i in range(q):
    l,r = map(int, input().split())
    print(a[r-1] - a[l-1])




Measured memory_bytes: 6060
X = int(input())

num = [i ** 5 for i in range(400)]

for A in range(400):
    for B in range(400):
        if num[A] + num[B] == X:
            print(A, (-1)*B)
            exit(0)
        elif num[A] - num[B] == X:
            print(A, B)
            exit(0)

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


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

    int pow2 = 1;
    rep(i,M) pow2 *= 2; 

    cout << (1900*M + 100*(N-M))*pow2 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        
        boolean yellow = false;
        int N = s.nextInt();
        for(int i = 0; i < N; i++){
            if(s.next().charAt(0) == 'Y')
                yellow = true;
        }
        
        if(yellow){
            System.out.println("Four");
        }else{
            System.out.println("Three");
        }
    }
    
}


Measured memory_bytes: 21844
use std::io::*;
use std::str::*;
use std::cmp;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn read_nums(limit_num: usize) -> Vec<i32> {
    let mut vec: Vec<i32> = Vec::new();
    while let Some(n) = read() {
        vec.push(n);
        if vec.len() == limit_num {
            break;
        }
    }
    return vec;
}

fn main() {
    let n: i32 = read().unwrap();
    let k: i32 = read().unwrap();
    let x_list: Vec<i32> = read_nums(n as usize);
    let mut sum = 0;

    for x in x_list {
        sum += 2 * cmp::min(x, k - x);
    }
    println!("{}", sum);
}


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

typedef long long ll;
#define PrintLn(X) cout << X << endl

int main(void)
{
	ll N;
	cin >> N;
	ll ans = (N / 11) * 2;
	if(N % 11 == 0){
	}else if(N % 11 <= 6){
		ans += 1;
	}else{
		ans += 2;
	}
	PrintLn(ans);
	return 0;
}


Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#l = list(map(int, input().split()))

x = int(input())

yokin = 100

for i in range(1, 100000000000):
    yokin *= 101
    yokin = yokin //100
    if (yokin >= x):
        print(i)
        break


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

typedef long long ll;

const
 ll MOD=1e9+7;

int main()
{
	//freopen("input.txt","r",stdin);
	ll i,j,k,n;
	string s1,s2;
	cin>>n;
	cin>>s1>>s2;
	ll start;
	if (s1[0]==s2[0])
	 start=1;
	else
	 start=2;
	ll res=-1;
	ll kode;
	if (start==1)
	 {
	 	res=3;
	 	kode=1;
	 }
	else
	 {
	 	res=6;
	 	kode=2;
	 }
	i=start;
	ll pengali=2;
	while (i<s1.length())
	{
		//cout<<kode<<" kode\n";
		//cout<<res<<" res\n";
		if (s1[i]==s1[i+1])
		{
			if (kode==1)
			 {
			 	res*=2;
			 	res%=MOD;
			 }
			else
			 {
			 	res*=3;
			 	res%=MOD;
			 }
			i+=2;
			kode=2;
		}
		else
		 {
		 	if (kode==1)
		 	 {
		 	 	res*=2;
		 	 	res%=MOD;
			 }
			 i++;
			 kode=1;
		 }
	}
	//res%=MOD;
	cout<<res<<"\n";
}

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

int main(){
    string s,t;
    cin>>s>>t;
    int ans = 10000;
    int ls  = (int)s.size();
    int lt  = (int)t.size();
    rep(i,ls-lt+1){
        string ss = s.substr(i,lt);
        int count = 0;
        rep(j,lt){
            if(ss[j]!=t[j])count++;
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636