akhauriyash/Code-Regression huggingface dataset:
#![allow(dead_code, unused_imports, deprecated)]
 
use std::collections::HashMap;
use std::cmp::Reverse;
 
use proconio::input;
use proconio::marker::*;

fn main() {
  input!{
    n: usize,
    s: Bytes,
  };

  let mut res = 0;
  if n > 3 {
    let mut dp: HashMap<_, _> = HashMap::new();
    dp.entry(b'R').or_insert(vec![0usize; n]);
    dp.entry(b'G').or_insert(vec![0usize; n]);
    dp.entry(b'B').or_insert(vec![0usize; n]);

    dp.entry(s[n - 1]).and_modify(|e|
      e[n - 1] += 1
    );

    for i in (0..(n - 1)).rev() {
      for &c in ([b'R', b'G', b'B']).iter() {
        dp.entry(c)
          .and_modify(|e|
            e[i] = e[i + 1] + if c == s[i] { 1 } else { 0 }
          );
      }
    }

    let rest = |ca: u8, cb: u8| -> u8 {
      let s = b'R' as usize + b'G' as usize + b'B' as usize;
      (s - ca as usize - cb as usize) as u8
    };
    for i in 0..(n - 1) {
      for j in i..n {
        if s[i] != s[j] && j + 1 < s.len() {
          res += dp[&rest(s[i], s[j])][j + 1];
          if j + (j - i) < s.len() && rest(s[i], s[j]) == s[j + (j - i)] {
            res -= 1;
          }
        }
      }
    }
  }
  
  println!("{}", res);
}


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

using namespace std; 

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

int main() {
    
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;

  S[K-1] = S[K-1]+32;
  
 cout << S << endl;
  return 0;
}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 256
require 'pp'

def gets; ARGF.gets; end

class Solver

  def main
    n = gets.chomp.to_i
    ts = gets.split.map(&:to_i)
    t_sum = ts.inject(:+)

    m = gets.chomp.to_i
    m.times do |i|
      p, x = gets.split.map(&:to_i)
      diff = x - ts[p-1]
      puts t_sum + diff
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	double t,x; cin >> t >> x;
	cout << setprecision(5) << t/x << endl;
}


Measured memory_bytes: 256
from fractions import gcd
inputs = list(map(int, input().split()))
A,B,C,D = inputs
lcm=int(C*D/gcd(C,D))
BB=B-B//C-B//D+B//lcm
AA=(A-1)-(A-1)//C-(A-1)//D+(A-1)//lcm
print(BB-AA)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int n;
  cin >> n;
  vi p(n);
  rep(i,n) {
    cin >> p[i];
  }
  int ans = 0;
  srep(i,1,n-1) {
    int a = p[i-1];
    int b = p[i];
    int c = p[i+1];
    int mini = min(a,min(b,c));
    int maxi = max(a,max(b,c));
    if(b != mini && b != maxi) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double LD; 
typedef long long ll; 
#define int ll 
#define ff(i,a,b) for (int i = a; i < b; i++) 
#define bf(i,a,b) for (int i = a; i >= b; i--) 
#define all(v) v.begin(),v.end() 
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define F first 
#define S second
#define lb lower_bound   
#define ub upper_bound
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define one cout<<-1<<endl;
#define pi 3.141592653589793238
#define mod 1000000007

void solve(){
    string s;
    cin>>s;
    int ans=0;
    ff(i,0,s.size()){
        int cnt=0;
        while(s[i]=='R'){
            cnt++;
            i++;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}
signed main() {
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;
int gcd(ll a, ll b) { return (b % a == 0) ? a : gcd(b - a * (b / a), a); }
ll dp[3005][3005];
int main()
{
	ll i,j,k,t,n,m;string s1,s2;
	cin>>s1>>s2;
	n=s1.length();m=s2.length();
	//cout<<s1[1]<<" "<<s1[2]<<endl;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(s1[i-1]==s2[j-1])
			{
				dp[i][j]=1+dp[i-1][j-1];
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	i=n;j=m;vector<char>v;
	while(i>0&&j>0)
	{
		if(s1[i-1]==s2[j-1])
		{
			v.push_back(s1[i-1]);i--;j--;
		}
		else
		{
			if(dp[i][j-1]>dp[i-1][j]){j--;}
			else{i--;}
		}
	}
		for(i=v.size()-1;i>=0;i--)
		{
			cout<<v[i];
		}
//	cout<<dp[n][m]<<endl;
	return 0;
}

Measured memory_bytes: 74052
import java.util.*;
public class Main {

	static long[] a, p;
	
	static long dfs(int N, long X) {
		if(N == 0)
			return X <= 0 ? 0 : 1;
		else if(X <= a[N-1] + 1)
			return dfs(N-1, X-1);
		else
			return p[N-1] + 1 + dfs(N-1, X-a[N-1]-2);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long X = sc.nextLong();
		a = new long[N];
		p = new long[N];
		a[0] = p[0] = 1;
		for(int i = 1; i < N; i++) {
			a[i] = 2 * a[i-1] + 3;
			p[i] = 2 * p[i-1] + 1;
		}
		System.out.println(dfs(N, X));	
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n; cin >>n; int x=0,y=0;
  vector<int>p(n); vector<int>q(n);
  vector<int>a(n); vector<int>b(n);
  for(int i=0; i<n; i++) cin >>p[i];
  for(int i=0; i<n; i++) cin >>q[i];
  for(int i=0; i<n; i++){a[i]=i+1; b[i]=i+1;}
  do{
    if(p!=a) x++;
    else break;
  }
  while(next_permutation(a.begin(),a.end()));
  do{
    if(q!=b) y++;
    else break;
  }
  while(next_permutation(b.begin(),b.end()));
  cout <<abs(x-y);
}

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

Measured memory_bytes: 3668
use std::str::FromStr;
use std::io::stdin;
use std::collections::vec_deque::VecDeque;

fn main() {
    let n: usize = read();
    let vec: Vec<String> = read_vec();
    let mut results: VecDeque<&str> = VecDeque::new();
    for i in 0..n {
        if i % 2 == 0 {
            if n % 2 == 0 {
                results.push_back(&vec[i]);
            } else {
                results.push_front(&vec[i]);
            }
        } else {
            if n % 2 == 0 {
                results.push_front(&vec[i]);
            } else {
                results.push_back(&vec[i]);
            }
        }
    }
    for i in 0..(n - 1) {
        print!("{} ", results[i]);
    }
    println!("{}", results[n - 1]);
}

fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 20212
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll h, w,tmp,a,b,c,ans;
	vll d(3);
	in(h);
	in(w);
	ans = h * w;

	if (w % 3 == 0 || h % 3 == 0) {
		outn(0);
		return 0;
	}

	if (w > h) {
		tmp = w;
		w = h;
		h = tmp;
	}

	repeq(i, 1, h / 2) {
		d[0] = w * i;
		d[1] = (w / 2) * (h - i);
		d[2] = w * (h - i) - d[1];

		sort(d.begin(), d.end());
		ans = ans < d[2] - d[0] ? ans : d[2] - d[0];
		d[0] = w * i;
		d[1] = w * ((h - i)/2);
		d[2] = w * (h - i) - d[1];

		sort(d.begin(), d.end());
		ans = ans < d[2] - d[0] ? ans : d[2] - d[0];
	}
	tmp = w;
	w = h;
	h = tmp;


repeq(i, 1, h / 2) {
	d[0] = w * i;
	d[1] = (w / 2) * (h - i);
	d[2] = w * (h - i) - d[1];

	sort(d.begin(), d.end());
	ans = ans < d[2] - d[0] ? ans : d[2] - d[0];
	d[0] = w * i;
	d[1] = w * ((h - i) / 2);
	d[2] = w * (h - i) - d[1];

	sort(d.begin(), d.end());
	ans = ans < d[2] - d[0] ? ans : d[2] - d[0];
}

	outn(ans);

	return 0;


}


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


string solve(string in){
  string ans="";
  ans+=in[0];
  int pos=0;
  string op;
  char c;
  for(int i=1;i<in.size();){
    op=in.substr(i,2);
    c=in[i+2];
    i+=3;
    if(op=="->"){
      if(pos==ans.size()-1){
        ans=ans+c;
	pos++;
      }else{
        pos++;
      }
    }else{
      if(pos==0){
        ans=c+ans;
      }else{
        pos--;
      }
    }
  }
  return ans;
}

int main(){
  int n;
  cin>>n;
  string s;
  for(int i=0;i<n;i++){
    cin>>s;
    cout<<solve(s)<<endl;
  }
}

Measured memory_bytes: 1220
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<string>
#include<cstring>
#include<ctype.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	new_data_set;
//   <<implemented_sorted_vector>>  new_data_set p;
//   <<insert_like_set>>           insert(key):log(n)
//<<accessing_iterator_by_index>> find_by_order(idx):log(n)
//	    <<accessing_by_value>>   order_of_key(key):log(n)
// << replace less<int> by greater<int> for descending order>>
// find(key), erase(find(key)) works the same!
typedef long long ll;
typedef long l;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ERR(x) cout<<"#x:"<<x<<endl
#define ERR2(x,y) cout<<"#x:"<<x<<" "<<"#y:"<<y<<endl;
#define ERR3(x,y,z) cout<<"#x:"<<x<<" "<<"#y:"<<y<<" "<<"#z:"<<z<<endl;
#define show(v) for(auto e: v) cout<<e<<" ";
#define showArr(A,n) for(int i=0;i<n;i++) cout<<A[i]<<" ";
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define umpit unordered_map<ll,ll>::iterator
#define mpit map<ll,ll>::iterator
#define setit set<ll>::iterator
#define all(v) v.begin(),v.end()

int main()
{
	ll n,q;
	cin>>n;
	vector<ll>v(n);
	map<ll,ll>mp1;
	ll sum = 0;
	FOR(i,0,n)
	{
		cin>>v[i];
		mp1[v[i]]++;
		sum += v[i];
	}
	cin>>q;
	while(q--)
	{
		ll b,c;
		cin>>b>>c;
		sum += mp1[b]*(c-b);
		cout<<sum<<endl;
		//after processing
		ll x = mp1[b];
		mp1.erase(b);
		mp1[c]+=x;
	}
 	return 0;
}


Measured memory_bytes: 7932
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
		int n;
		cin >> n;
		if(n % 1000)
			cout << 1000 - (n % 1000) << "\n";
		else
			cout << 0 << "\n";
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define s(x)	cin>>x
#define p(x)	cout<<x<<"\n"
#define goog(x, y)  cout<<"Case #"<<x<<": "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpi;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
typedef long double ld;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);
int gcd(int a, int b) ;

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];


int dfsa(bool visited[],int st)
{   visited[st]=1;
    int ct=1;
    for(auto i:g[st])
    {   if(visited[i]) continue;
        ct+=dfsa(visited,i);
    }
    return ct;
}


void solve() {
  int n,m;cin>>n>>m;
  while(m--)
  { int a,b;cin>>a>>b;
    g[a].pb(b);
    g[b].pb(a);
  }
  bool visited[n+1]={0};
  vi vals;
  Fo(i,1,n+1)
  { if(!visited[i])
    vals.pb(dfsa(visited,i));
  }
  sortall(vals);
  //for(auto k:vals)
  //p(k);
  int res=vals[0];
  Fo(i,1,(int)vals.size())
  { res=res+(vals[i]-vals[i-1]);}
  p(res);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    //u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

Measured memory_bytes: 26464
a,b,c,x,y = map(int,input().split())
c_max = max(x,y)*2
#print(i) 0,2,4,6
tmp = 0
for i in range(0,c_max+1,2):
    if i == 0:
        tmp = a*x+b*y
        continue
    mi = i//2
    all_sum = max(0,(x-mi))*a+max(0,(y-mi))*b+i*c
    if all_sum <= tmp:
        tmp = all_sum
print(tmp)

Measured memory_bytes: 3064
from collections import Counter
n,k=map(int,input().split())
A=Counter([int(i) for i in input().split()])
values,counts=zip(*A.most_common())
a=len(values)
#print(counts)
#print(a)
if k<a:
    ans=0
    for i in range(k,a):
#        print(counts[i])
        ans+=counts[i]
    print(ans)
else:
    print(0)



Measured memory_bytes: 52192
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static long mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			Console.WriteLine(n * n);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <math.h>
typedef struct a{
  double x;
  double y;
}Point;
void kohho(Point,Point,int);
Point start,end;
int main(){
  int n;
  start.x=0;
  start.y=0;
  end.x=100;
  end.y=0;
  scanf("%d",&n);
  printf("%f %f\n",start.x,start.y);
  kohho(start,end,n);
  printf("%f %f\n",end.x,end.y);
  return 0;
}
void kohho(Point p1,Point p2,int dipth){
  if(dipth==0)return;
  Point s,t,u;
  s.x=(2*p1.x+p2.x)/3;
  s.y=(2*p1.y+p2.y)/3;
  t.x=(p1.x+2*p2.x)/3;
  t.y=(p1.y+2*p2.y)/3;
  u.x=(t.x-s.x)*cos(M_PI*60.0/180.0)-(t.y-s.y)*sin(M_PI*60.0/180.0)+s.x;
  u.y=(t.x-s.x)*sin(M_PI*60.0/180.0)+(t.y-s.y)*cos(M_PI*60.0/180.0)+s.y;
  kohho(p1,s,dipth-1);
  printf("%f %f\n",s.x,s.y);
  kohho(s,u,dipth-1);
  printf("%f %f\n",u.x,u.y);
  kohho(u,t,dipth-1);
  printf("%f %f\n",t.x,t.y);
  kohho(t,p2,dipth-1);
}



Measured memory_bytes: 2048
#include <iostream>
#include <stack>
#include <vector>
#include <string>
using namespace std;

int main(){
  int n,i,k,m;
  int s = 0;
  int ans = 100000000;
  int v[100] = {};

  cin >> n;
  for(i = 0; i < n; i++){
    cin >> v[i];
  }
  for(k = -100; k <= 100; k++){
    s = 0;
    for(i = 0; i < n; i++){
      m = (k - v[i]) * (k - v[i]);
      s = s + m;
    }
    if(s < ans) ans = s;
  }
  cout << ans;
}


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

int main()
{
	int K;
	scanf("%d", &K);
	std::vector<bool> visited(K);
	std::deque<std::pair<int, int>> bfs;
	bfs.push_back({1, 1});
	while (!bfs.empty())
	{
		auto num{bfs.front()};
		bfs.pop_front();
		if (visited[num.first]) continue;
		if (num.first == 0)
		{
			printf("%d\n", num.second);
			break;
		}
		visited[num.first] = true;
		bfs.push_back({(num.first + 1) % K, num.second + 1});
		bfs.push_front({num.first * 10 % K, num.second});
	}

	return 0;
}


Measured memory_bytes: 1024
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (A, B) = get!(i64, i64);

    let ans = vec![A + B, A - B, A * B].into_iter().max().unwrap();

    println!("{}", ans);
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int j=0;

  // ここにプログラムを追記
  for (int i=A; i<B+1; ++i) {
    int N1,N2,N3,N4,N5;
    N5 = (i-i%10000)/10000;
    N4 = (i%10000-i%1000)/1000;
    N3 = (i%1000-i%100)/100;
    N2 = (i%100-i%10)/10;
    N1 = i%10;
    if (N5 == N1 && N4 == N2) {
      j += 1;
    }
  }
  cout << j << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATravelingBudget solver = new ATravelingBudget();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATravelingBudget {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.println(Math.min(in.nextInt(), in.nextInt()) + Math.min(in.nextInt(), in.nextInt()));
        }

    }
}



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




int main() {
	int a[5];
	for (int i = 0; i < 5; i++) { cin >> a[i]; }
	
	int c = 10;
	int p = 0;
	for (int i = 0; i < 5; i++) {
		if (a[i] % 10 == 0) {
			p += a[i] / 10;
		}
		else {
			c = min(a[i] % 10, c);
			p += a[i] / 10 + 1;
		}
	}

	cout << (p - 1) * 10 + c << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
# import numpy as np
import bisect #bisect.bisect_left 値の挿入位置を返す関数


s = input()
t = input()
l = len(s)

idx_dict = defaultdict(list)

#各文字の index を取得
for i, v in enumerate(s):
    idx_dict[v].append(i)

#リストを ndarray に変換
#for key, value in idx_dict.items():
#    idx_dict[key] = np.array(value)

l = len(s)
rnd = 0
idx = 0
ans = 0
p_v = ''
# index のリストを取り出し、現在の idx と比べる
# idx より大きい値がない場合は一周ふやす
for v in t:
    # idx_dict の key に　v が存在しなかったら -1
    if v not in idx_dict:
        ans = -1
        break
    # 同じ文字が続いたら idx を 1 増やす
    if v == p_v:
        idx += 1
    arr = idx_dict[v]
    i = bisect.bisect_left(arr, idx)
    try:
        idx = arr[i]
    except IndexError:
        idx = arr[0]
        rnd += 1
    p_v = v

if not ans:
        ans = ((rnd * l) + idx) + 1
        
print(ans)

Measured memory_bytes: 8044
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    rep(i, N) {
        cout << S[i];
        cout << T[i];
    }
    cout << endl;
    return 0;
}


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

const int mxN = 5e5 + 5;
int BIT[mxN], a[mxN], last[mxN], answer[mxN], n, q;

struct Query {
	int l;
	int r;
	int idx;
} queries[mxN];

bool cmp(Query &x, Query &y) {
	return x.r < y.r;
}

void update(int node, int v) {
	while(node < mxN) {
		BIT[node] += v;
		node += node & -node;
	}
}

int get(int node) {
	int ret = 0;
	while(node) {
		ret += BIT[node];
		node -= node & -node;
	}
	return ret;
}

void solve() {
	memset(last, -1, sizeof last);
	int counter = 0;
	for(int i = 0; i < n; ++i) {
		if(last[a[i]] != -1)
			update(last[a[i]] + 1, -1);
		last[a[i]] = i;
		update(i + 1, 1);
		while(counter < q && queries[counter].r == i) {
			answer[queries[counter].idx] = get(queries[counter].r + 1) - get(queries[counter].l);
			++counter;
		}
	}
}

int main() {
	scanf("%d%d", &n, &q);
	for(int i = 0; i < n; ++i)
		scanf("%d", a + i);
	for(int i = 0; i < q; ++i) {
		scanf("%d%d", &queries[i].l, &queries[i].r);
		--queries[i].r;
		--queries[i].l;
		queries[i].idx = i;
	}
	sort(queries, queries + q, cmp);
	solve();
	for(int i = 0; i < q; ++i)
		printf("%d\n", answer[i]);
}


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

int main(){
    int N,iter=0;
    cin>>N;
    vector<int> n(N),p(N),q(N);
    for(int i=0;i<N;i++){
        cin>>p.at(i);
    }
    for(int i=0;i<N;i++){
        cin>>q.at(i);
    }
    iota(n.begin(),n.end(),1);
    map<vector<int>,int> ord;
    
    do{
        ord[n] = iter++;
    }while(next_permutation(n.begin(),n.end()));
    
    cout<<abs(ord[p]-ord[q])<<endl;
}


Measured memory_bytes: 5248
from typing import List


class DSU:
    def __init__(self, n: int) -> None:
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a <= self._n
        assert 0 <= b <= self._n
        x, y = self.leader(a), self.leader(b)
        if x == y:
            return x
        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a <= self._n
        assert 0 <= b <= self._n
        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n
        if self.parent_or_size[a] < 0:
            return a
        result = self.leader(self.parent_or_size[a])
        self.parent_or_size[a] = result
        return result

    def size(self, a: int) -> int:
        assert 0 <= a <= self._n
        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> List[List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]
        group_size = [0] * self._n
        for i in leader_buf:
            group_size[i] += 1
        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)
        result = [i for i in result if i]
        return result


import sys
input = sys.stdin.readline
n, q = map(int, input().split())
uf = DSU(n)
for i in range(q):
    t, u, v = map(int, input().split())
    if t:
        print(int(uf.same(u, v)))
    else:
        uf.merge(u, v)


Measured memory_bytes: 83000
import numpy as np
import sys
from numba import njit, i8

input = sys.stdin.readline

R, C, K = map(int, input().split())
table = [[0] * (C + 1) for _ in range(R + 1)]
for _ in range(K):
    r, c, v = map(int, input().split())
    table[r][c] = v
table = np.array(table, dtype=np.int64)


@njit((i8, i8, i8[:, :]), cache=True)
def solve(R, C, table):
    dp0 = np.zeros((R + 1, C + 1), dtype=np.int64)
    dp1 = np.zeros((R + 1, C + 1), dtype=np.int64)
    dp2 = np.zeros((R + 1, C + 1), dtype=np.int64)
    dp3 = np.zeros((R + 1, C + 1), dtype=np.int64)

    for r in range(1, R + 1):
        for c in range(1, C + 1):
            m = max(dp0[r - 1, c], dp1[r - 1, c], dp2[r - 1, c], dp3[r - 1, c])
            dp0[r, c] = max(m, dp0[r, c - 1])
            dp1[r, c] = max(m, dp1[r, c - 1])
            dp2[r, c] = max(m, dp2[r, c - 1])
            dp3[r, c] = max(m, dp3[r, c - 1])
            if t := table[r, c]:
                dp1[r, c] = max(dp1[r, c], m + t, dp0[r, c - 1] + t)
                dp2[r, c] = max(dp2[r, c], m + t, dp1[r, c - 1] + t)
                dp3[r, c] = max(dp3[r, c], m + t, dp2[r, c - 1] + t)
    return max(dp0[-1, -1], dp1[-1, -1], dp2[-1, -1], dp3[-1, -1])


print(solve(R, C, table))


Measured memory_bytes: 465560
#include<stdio.h>
int main(void){
  int n,m,a[101],i,s,sum,b[1001];
  scanf("%d %d",&n,&m);
  s=0;
  sum=0;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    s=s+a[i];
  }
  for(i=1;i<=1000;i++){
    b[i]=0;
  }
  for(i=0;i<n;i++){
    b[a[i]]++;
  }
  for(i=1000;i>=1;i--){
    if(b[i]>0){
      sum+=b[i];
      /*printf("%d\n",i);*/
    }
    if(s%(4*m)!=0){
    if(b[i]!=0&&i<(int)(s/(4*m))+1){
      printf("No\n");
      break;
    }
    }else{
     if(b[i]!=0&&i<s/(4*m)){
      printf("No\n");
      break;
    }
    }
    if(sum>=m){
      printf("Yes\n");
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

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;
}
using namespace std;

void solve(){
    ll x,y;
    cin>>x>>y;
    if(x%y)cout<<x<<endl;
    else cout<<-1<<endl;
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  
  int X, f = 0;
  
  cin >> X;
  
  for(int i = X; i > 0; i /= 10){
    
    f += i%10;
  }
  if(X%f == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<string>
#include<iostream>
#include<map>

using namespace std;

int main(){
  string worm;
  cin>>worm;
  
  while(worm != "0"){
    queue<pair<string,int> >que;
    que.push(make_pair(worm,0));
    map<string,bool> done_str;
    
    int ans = -1;
    
    while(!que.empty()){
      string s = que.front().first;
      int count = que.front().second;
      que.pop();

        
      string cmp_strR,cmp_strG,cmp_strB;

      cmp_strR.append(worm.size(), 'r');
      cmp_strG.append(worm.size(), 'g');
      cmp_strB.append(worm.size(), 'b');
      
      if(s == cmp_strR || s == cmp_strG || s == cmp_strB ){
	ans = count;
	break;
      }else if(done_str.find(s) != done_str.end()){
	continue;
      }else{
	done_str.insert(make_pair(s,true));
      }

      
      for(int i=0;i<s.size()-1;i++){
	if(s.at(i) != s.at(i+1)){
	  if(s.at(i) != 'r' && s.at(i+1)!='r'){
	    string tmp = s;
	    que.push(make_pair(tmp.replace(i,2,2,'r'),count+1));

	  }else if(s.at(i) != 'g' && s.at(i+1)!='g'){
	    string tmp = s;
	    que.push(make_pair(tmp.replace(i,2,2,'g'),count+1));

	  }else if(s.at(i) != 'b' && s.at(i+1)!='b'){
	    string tmp = s;
	    que.push(make_pair(tmp.replace(i,2,2,'b'),count+1));
	  }
	}
      }
    }

    if(ans < 0){
      cout<<"NA"<<endl;
    }else{
      cout<<ans<<endl;
    }
    
    cin>>worm;
  }

  return 0;
}

Measured memory_bytes: 3292
#include <cstdio>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;

int main(){
	typedef pair<int,int> pii;
	priority_queue<pii> pq;
	int n, r, l, d, t, x, u = 0;
	scanf("%d%d%d", &n, &r, &l);
	vector<int> s(n + 1), c(n + 1);
	for(int i = 1; i <= n; ++i){
		pq.push(pii(0, ~i));
	}
	for(int i = 0; ; ++i){
		if(i == r){
			t = l;
		}
		else{
			scanf("%d%d%d", &d, &t, &x);
		}
		while(1){
			if(s[~pq.top().second] == pq.top().first){
				c[~pq.top().second] += t - u;
				break;
			}
			pq.pop();
		}
		if(i == r){
			break;
		}
		s[d] += x;
		pq.push(pii(s[d], ~d));
		u = t;
	}
	int ans = max_element(c.begin(), c.end()) - c.begin();
	printf("%d\n", ans);
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int output = 1;
  for (int i = 0; i < N; i++) {
    if (output * 2 < output + K) {
      output *= 2;
    }
    else {
      output += K;
    }
  }
  cout << output << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
        using namespace std; 
        #define int long long
        # define pii pair<int,int>
        const int maxn=1e6+5;
        signed main() { 
            #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
            #endif
            ios::sync_with_stdio(0);
            cin.tie(0);
            int a,b;
            cin>>a>>b;
            char ch;
            cin>>ch;
            int d;
            cin>>d;
            b*=100;
            b+=d;
            cout<<(a*(b))/100;
        } 

Measured memory_bytes: 3632
import java.util.*;

// UVa 11504

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		
		if ((a == 7 && b == 5 && c == 5) || (a == 5 && b == 7 && c == 5) || (a == 5 && b == 5 && c == 7)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

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

import sys

debug = False

def log(text):
    if debug:
        print(text)


def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        lines.append(input())
        lines.append(input())
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    a_e = [int(e) for e in lines[:5]]

    return (a_e,)

def permutation(tmp):

    if len(tmp) == 0:
        return [[]]
    else:
        result = []
        for i in range(len(tmp)):
            head = tmp[i]
            tail = tmp[0:i] + tmp[i+1:]
            for r in permutation(tail):
                result.append([head] + r)
        return result

def solve(a_e):

    result = 130 * 5
    for r in permutation(a_e):
        if debug:
            log("r=%s" % r)
        total = 0
        for e in r[:4]:
            tmp = e + total
            m = tmp % 10
            if m == 0:
                total = tmp
            else:
                total = tmp + (10 - m)
            if debug:
                log("e=%d, tmp=%d, total=%s" % (e, tmp, total))
        total = total + r[4]
        if debug:
            log("total=%s" % total)

        if total < result:
            if debug:
                log("r=%s" % r)
            result = total
 
    return result

def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int x,y,z;
    in>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<'\n';
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int n = s.length();
        char ss , tt;
        int a = 0;
        for(int i = 0;i < n;i++){
            ss = s.charAt(i);
            tt = t.charAt(i);
            if(ss != tt){
                a++;
            }
        }
        System.out.println(a);
        sc.close();
    }
}

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

typedef long long ll;

const ll MOD = 1000000007;

ll pow_MOD(ll f, ll M) {
	if (M == 0)		return (ll)1;
	if (M == 1)		return f % MOD;
	if (M == 2)		return f * f % MOD;
	if (M % 2 == 0)	return pow_MOD(pow_MOD(f, M / 2), (ll)2) % MOD;
	/*else*/		return pow_MOD(pow_MOD(f, M / 2), 2) * (ll)f % MOD;
};

int main()
{
	int x, y; 
	cin >> x >> y;

	int n = x + y;
	if (n % 3)
	{
		cout << 0 << endl;
		return 0;
	}

	n /= 3;
	x -= n; y -= n;

	if (x < 0 || y < 0)
	{
		cout << 0 << endl;
		return 0;
	}

	vector<ll> fact(n + 1);
	fact[0] = fact[1] = (ll)1;
	for (int i = 2; i <= n; i++)
		fact[i] = fact[i - 1] * i % MOD;
	
	ll invX, invY;
	invX = pow_MOD(fact[x], MOD - 2);
	invY = pow_MOD(fact[y], MOD - 2);

	//cout << "fact[" << n << "]=" << fact[n] << endl;
	//cout << "invX=" << invX << endl;
	//cout << "invY=" << invY << endl;

	ll ans = fact[n] * (invX * invY % MOD) % MOD;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5504
<?php
fscanf(STDIN, "%d %d %d", $N, $M, $X);
$A = explode(" ", trim(fgets(STDIN)));

$left = $right = 0;

for ($i = 0; $i < $M; $i++) {
    if ($A[$i] > $X) {
        $right++;
    } else {
        $left++;
    }
}

echo min($left, $right) . PHP_EOL;


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    
    int N;
    cin >> N;
    vector<pair<ll,ll>> LR(N);
    ll mx = -inf;
    ll mn = inf;
    rep(i,N){
        cin >> LR[i].first >> LR[i].second;
        LR[i].second++;
        mx = max(mx,LR[i].first);
        mn = min(mn,LR[i].second);
    }
    sort(ALL(LR));
    ll ans = 0;
    for(auto z:LR){
        ans = max(ans,max(0LL,mn - mx) + z.second - z.first);
    }
    vector<pair<ll,ll>>t;
    rep(i,N){
        ll a = max(0LL,mn - LR[i].first);
        ll b = max(0LL,LR[i].second - mx);
        t.push_back({b,-a});
    }
    sort(ALL(t));
    ll w = inf;
    rep(i,N){
        auto z = t[i];
        z.second = -z.second;
        if(i){
            ans = max(ans,w + z.first);
        }
        w = min(w,z.second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3956
#![allow(non_snake_case)]
#![allow(unused_imports)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use itertools_num::ItertoolsNum;
use itertools::Itertools;

fn eval(v: &Vec<usize>, X: usize) -> bool {
    let mut flag = true;
    for i in 0..v.len() {
        if i == 0 {
            continue;
        } else {
            if v[i] < X {
                flag = false;
                break;
            }
        }
    }
    flag
}


#[fastout]
fn main() {
    let (N, M, X): (usize, usize, usize) = parse_line().unwrap();
    
    let mut vec : Vec<Vec<usize>> = Vec::new();
    let mut flag = false;
    let mut min_money: usize = 1e9 as usize;
    
    for _i in 0..N {
        let m: Vec<usize> = parse_line().unwrap();
        vec.push(m);
    }

    for i in 1..=N {
       for v in (0..N).combinations(i) {
           let mut sum_vec: Vec<usize> = vec![0; M+1];
           // println!("{:?}", &v);
           for j in v {
               for k in 0..M+1 {
                    sum_vec[k] += vec[j][k];
               }
           }
           flag = eval(&sum_vec, X);
           if flag && sum_vec[0] < min_money { min_money = sum_vec[0] }
           
           // println!("{:?} {}", sum_vec, flag)
       }
    }
    if min_money != 1e9 as usize {
        println!("{}", min_money)
    } else {
        println!("-1")
    }
    
}


Measured memory_bytes: 2196
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.1415;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;

	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

ll getGcd(ll a, ll b) {
	if (a < b) {
		ll temp = b;
		b = a;
		a = temp;
	}

	ll r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

int getNum(ll target) {

	int bottom = 0;
	int top = 151;
	while (1 < top - bottom) {
		int middle = (top + bottom) / 2;
		if (false/*target < line[middle]*/)top = middle;
		else bottom = middle;
	}
	return bottom;
}

int main() {

	string S, T; cin >> S >> T;
	string ans = "Yes";
	int diff = 0;
	for (int i = 0; i < T.size(); ++i) {
		if (i < S.size()) {
			if (S[i] != T[i]) {
				ans = "No";
				break;
			}
		}
		else {
			++diff;
			if (1 < diff) {
				ans = "No";
				break;
			}
		}
	}
	cout << ans << endl;
}




Measured memory_bytes: 5444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = INF;

int main()
{
ll n;
cin >> n;
ll t[n+1] = {};
rep(i, n)
{
    ll tt;
    cin >> tt;
    t[i+1]=tt+t[i];
}
vector<ll> v(4);

/* for (int i = 0; i < n+1; ++i) {
    cout << t[i] << " ";
}cout  << endl; */

ll ii;
for(ll i=2;i<=n-2;i++){
    ll mean1=t[i];
    auto itr = lower_bound(t,t+i+1, mean1/2);
    if(abs(t[itr - t]-t[i]+t[itr - t])>abs(t[itr - t-1]-t[i]+t[itr - t-1]))
    {v[0]=t[itr - t-1];v[1]=t[i]-t[itr - t-1];}
    else {v[0]=t[itr - t];v[1]=t[i]-t[itr - t];}

    ll mean2=t[n]-t[i];
    itr = lower_bound(t+i+1,t+n+1, mean2/2+t[i]);
    if(abs(t[itr - t]-t[i]-t[n]+t[itr - t])>abs(t[itr - t-1]-t[i]-t[n]+t[itr - t-1]))
    {v[2]=t[itr - t-1]-t[i];v[3]=t[n]-t[itr - t-1];}
    else {v[2]=t[itr - t]-t[i];v[3]=t[n]-t[itr - t];}

    /* for (int i = 0; i < v.size(); ++i) {
        cout << v[i] << " ";
    }cout  << endl; */

    sort(v.begin(), v.end());
    ans=min(ans,v[3]-v[0]);
    if(ans<v[3]-v[0])ii=i;
}

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

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

using namespace std;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int AB = A + B;
  int CD = C + D;

  if (AB > CD) {
    cout << "Left" << endl;
  }
  if (AB < CD) {
    cout << "Right" << endl;
  }
  if (AB == CD) {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int maxN = 100005;

class TaskE {
private:
	Debugger debugger;
	const int MOD = 998244353;
	vector<int> f;

	int inv(int x){
		int ans = 1;
		int e = MOD-2;
		while(e){
			if(e&1){
				ans = (long long)ans * x % MOD;
			}
			x = (long long) x * x % MOD;
			e/=2;
		}
		return ans;
	}

	int comb(int n, int k){
		int ans = (long long)f[n] * inv(f[k]) % MOD; 
		ans = (long long)ans * inv(f[n-k]) % MOD;
		return ans;
	}

public:

	void solveOne(int it){
		int n, m , k;
		cin >> n >> m >> k;
		f.assign(n+1, 0);
		f[0] = 1;
		for(int i = 1; i <= n; i++){
			f[i] = (long long)f[i-1] * i % MOD;
		}
		vector<int> calc(n+1);
		calc[1] = m;
		for(int i = 2; i <= n; i++){
			calc[i] = (long long) calc[i-1] * (m-1) % MOD;
		}

		int ans = 0;
		for(int pieces = n-k; pieces <= n; pieces++){
			ans += (long long)comb(n-1,pieces-1) * calc[pieces] % MOD;
			ans %= MOD;
		}
		cout << ans << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskE solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 4768
import static java.util.Arrays.sort;
import java.io.*;
import java.util.Collections;
public class Main {
	public static void main(String[] args) throws IOException {
		String s = new BufferedReader(new InputStreamReader(System.in)).readLine();
		String[] sarr = s.split(" ",0);
		Long[] nums = new Long[sarr.length];
		for(int i=0;i<sarr.length;i++)
			nums[i] = Long.parseLong(sarr[i]);
		sort(nums,Collections.reverseOrder());
		for(int i=0;i<nums.length-1;i++)
			System.out.printf("%d ",nums[i]);
		System.out.println(nums[nums.length-1]);
	}
}

Measured memory_bytes: 16928
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
    string a,b,str;
    int x=0,jin=1;
    cin>>a>>b;
    str=a+b;
    for(int i=str.size()-1;i>=0;i--)
    {
        x+=jin*(str[i]-'0');
        jin*=10;
    }
    if(sqrt(x)==floor(sqrt(x)))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
int main() {
ll n,m;
cin >> n >> m;
int left = 1;
int right = n;
rep (i,m){
	int a,b;
	cin >> a >> b;
	left = max(left,a);
	right = min(right,b);

}
cout << max(right-left + 1,0) << endl;


  
 }


 
 






Measured memory_bytes: 256