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

long long n,a[75],k,gap,mid[75],num;
vector<pair<int,int> > occ;
vector<int> sol;

int main(){
    
    //cout<<"-1"<<endl;
    //return 0;

	cin>>n>>k;
	
	for(int i=0;i<n;i++){
        cin>>a[i];
        
        gap+=max(0ll,(k+1)-a[i]);
        if(((k+1)-a[i])>0)
        occ.push_back({(k+1)-a[i],i+1});
    }
    
    if(gap>k){
        cout<<"-1\n";
        return 0;
    }
    
    int cont=0;
    sort(occ.begin(),occ.end());
    
    reverse(occ.begin(),occ.end());
    
    int last;
    
    if(occ.size()>1)last=occ[occ.size()-1].second;
    else last=n;
    
    //cout<<last<<endl;
    
    gap=k;
    
	for(int i=0;gap>0;gap--){
	    
	    if(cont<occ.size()){
        	    
	    mid[i]=occ[cont].second;
	    
	    //cout<<mid[i]<<endl;
	    
	    occ[cont].first--;
	    
	    if(occ[cont].first==0)cont++;
        }
        else{
            for(int j=0;j<n;j++){
                if((i-1<0 || mid[i-1]!=j+1) && (i+1>=k || mid[i+1]!=j+1)){
                    mid[i]=j+1;
                    break;
                }
            }
        }
	    
	    if((i+1<k && mid[i]==mid[i+1]) || (i-1>=0 && mid[i]==mid[i-1])){
	        cout<<"-1\n";
	        return 0;
        }
	    
	    if(i+2>=k){
	        i=1;
        }
        else
            i+=2;
    }
	
	
	for(int i=0;i<k;i++){
	    if(i==0){
            for(int j=0;j<n;j++){
                if((j+1)!=mid[0]){
                    sol.push_back(j+1);
                    num++;
                }
            }
            sol.push_back(mid[0]);
            num++;    
        }
        else{
            for(int j=0;j<n;j++){
                if((j+1)!=mid[i-1] && (j+1)!=mid[i]){
                    sol.push_back(j+1);
                    num++;
                }
            }
            sol.push_back(mid[i]);
            num++;  
        }
    }
    
    for(int j=0;j<n;j++){
        if((j+1)!=mid[k-1]){
            sol.push_back(j+1);
            num++;
        }
    }
    
    cout<<sol.size()<<endl;
    for(int i=0;i<sol.size();i++)cout<<sol[i]<<" ";
    cout<<endl;
            
return 0;
}


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

int main(){
  int n,t,array[100],array2[100],ans=1001;
  cin>>n>>t;
  for(int i=0;i<n;i++){
    cin>>array[i]>>array2[i];
    if(array2[i]<=t){
      ans=min(ans,array[i]);
    }
  }
  if(ans-1001){
    cout<<ans<<endl;
  }else{
    cout<<"TLE"<<endl;
  }
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    cum = 0
    t = 0
    for i in range(N-1):
        cum += A[i]
        if 2*cum < A[i+1]:
            t = i+1
    ans = N - t
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 20380
#include <iostream>

using namespace std;

int main(void){
  int n;
  cin >> n;
  if(n%10==9){
    cout << "Yes" << endl;
    return 0;
  }
  else if(n/10==9){
    cout << "Yes" << endl;
    return 0;
  }
  else{
    cout << "No" << endl;
    return 0;
  }
}


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

int main() {
	int a, b, c, n;
	cin >> n;
	for (int i=0;i<n;i++) {
    bool ok = false;
		cin >> a >> b >> c;
    if (a < c && b < c) {
      ok = (a*a+b*b == c*c);
    } else if (a < b && c < b) {
      ok = (a*a+c*c == b*b);
    } else {
      ok = (b*b+c*c == a*a);
    }
    cout << (ok?"YES":"NO") << endl;
	}

  return 0;
}

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


def isPrime(n):
    if n == 0 or n == 1:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    for i in range(3, int(n ** 0.5) + 1, 2):
        if n % i == 0:
            return False
    return n != 1


for i in range(X*2+1):
    num = X + i
    if isPrime(num):
        break

print(num)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int a,b;
	cin>>a>>b;
	cout<<a+b/2<<endl;
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int m;
        string s;cin>>s;
        if(s=="-")break;
        cin>>m;
        for(int i=0;i<m;i++){
            int h;cin>>h;
            string a="";
            for(int j=h;j<s.size();j++){
                a+=s[j];
            }
            for(int j=0;j<h;j++){
                a+=s[j];
            }
            s=a;
        }
        cout<<s<<endl;
    }
}




Measured memory_bytes: 3196
A,B,C,X,Y = map(int,input().split())
ans = 10**12
T=max(X,Y)
for i in range(T+1):
    x =A*max(0,X-i)
    y=B*max(0,Y-i)
    ans=min(ans,x+y+2*C*i)
print(ans)

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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  vector<ll> A(N);
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  ll sum1 = A.at(0);
  ll sum2 = sum - sum1;
  ll ans = abs(sum1 - sum2);
  for (int i = 1; i < N-1; i++) {
    sum1 += A.at(i);
    sum2 -= A.at(i);
    ans = min(ans, abs(sum1 - sum2));
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1792
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define INF 2140000000
#define MOD 1000000007

int main() {
	int r, c, n, pr, pc;

	cin >> r >> c >> n >> pr >> pc;

	string a, b;

	cin >> a >> b;

	int temp = pc;

	for (int i = 0; i < n; ++i) {

		if (a[i] == 'R') {
			temp++;
		}

		if (temp > c) {
			cout << "NO" << endl;
			return 0;
		}

		if (b[i] == 'L' && temp != 1) {
			temp--;
		}
	}

	temp = pc;

	for (int i = 0; i < n; ++i) {

		if (a[i] == 'L') {
			temp--;
		}

		if (temp < 1) {
			cout << "NO" << endl;
			return 0;
		}

		if (b[i] == 'R'  && temp != c) {
			temp++;
		}
	}

	temp = pr;

	for (int i = 0; i < n; ++i) {

		if (a[i] == 'D') {
			temp++;
		}

		if (temp > r) {
			cout << "NO" << endl;
			return 0;
		}

		if (b[i] == 'U' && temp != 1) {
			temp--;
		}
	}

	temp = pr;

	for (int i = 0; i < n; ++i) {

		if (a[i] == 'U') {
			temp--;
		}

		if (temp < 1) {
			cout << "NO" << endl;
			return 0;
		}

		if (b[i] == 'D' && temp != r) {
			temp++;
		}
	}

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int last=0,cnt=1,len;
    string s;
    cin>>len;
    cin>>s;
    last=s[0];
    for(int i=1;i<len;i++){
        if(s[i]!=last)
            cnt++;
        last=s[i];
    }
    cout<<cnt<<endl;


    return 0;
}


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

int A[2019],ans;

int main(){
  string s;cin>>s;
  int n=s.size();
  A[0]++;
  for(int i=0,t=1,pre=0;i<n;i++){
    ans+=A[(pre+=(s[n-1-i]-'0')*t)%=2019]++;
    (t*=10)%=2019;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3692
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int start = sc.nextInt();
		ArrayList<HashMap<Integer, Integer>> graph = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    graph.add(new HashMap<>());
		}
		for (int i = 0; i < m; i++) {
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int c = sc.nextInt();
		    graph.get(a).put(b, c);
		}
		PriorityQueue<Path> queue = new PriorityQueue<>();
		queue.add(new Path(start, 0));
		int[] costs = new int[n];
		Arrays.fill(costs, Integer.MAX_VALUE);
		while (queue.size() > 0) {
		    Path p = queue.poll();
		    if (costs[p.idx] <= p.value) {
		        continue;
		    }
		    costs[p.idx] = p.value;
		    for (Map.Entry<Integer, Integer> entry : graph.get(p.idx).entrySet()) {
		        queue.add(new Path(entry.getKey(), p.value + entry.getValue()));
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int x : costs) {
		    if (x == Integer.MAX_VALUE) {
		        sb.append("INF");
		    } else {
		        sb.append(x);
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
	
	static class Path implements Comparable<Path> {
	    int idx;
	    int value;
	    
	    public Path(int idx, int value) {
	        this.idx = idx;
	        this.value = value;
	    }
	    
	    public int compareTo(Path another) {
	        return value - another.value;
	    }
	}
}



Measured memory_bytes: 350456
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll a,b,c;
 sc(a);sc(b);sc(c);
 pr((a+b)*c/2);

return 0;}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl;
#define mod 1000000007
#define pb push_back
#define endl '\n'




int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	if(m==n) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}

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


int main() {

  long long int n, k;
  cin >> n >> k;

  string s;
  cin >> s;

  k--;
  s[k] = s[k] - ('A' - 'a');

  cout << s << endl;

  return 0;

}


Measured memory_bytes: 764
#include <iostream>
#include <cmath>

using namespace std;

string s;

void solve(){
    if(s=="Sunny"){
        cout<<"Cloudy";
    }else if(s=="Cloudy"){
        cout<<"Rainy";
    }else{
        cout<<"Sunny";
    }
    cout<<"\n";
}

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

Measured memory_bytes: 3456
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
string eval(string s) {
	int n = s.size();
	s += s;
	string ans = "~";
	for (int i = 0; i < n; ++i) {
		ans = min(ans, s.substr(i, n));
	}
	return ans;
}
int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	int N = X + Y + Z;
	string ans = string(X, 'a') + string(Y, 'b') + string(Z, 'c');
	string cur_ev = eval(ans);
	while (true) {
		// 2-opt
		bool found = false;
		for (int i = 0; i < N && !found; ++i) {
			for (int j = 1; j < N && !found; ++j) {
				for (int k = 0; k <= N - j; ++k) {
					string cyclic = ans.substr(i) + ans.substr(0, i);
					string nxt = cyclic.substr(j, k) + cyclic.substr(0, j) + cyclic.substr(j + k);
					string ev = eval(nxt);
					if (ev > cur_ev) {
						cur_ev = ev;
						ans = nxt;
						found = true;
						break;
					}
				}
			}
		}
		if (!found) break;
	}
	cout << cur_ev << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MAX 100005

int n,m,t;
vector<vector<int>> G(MAX,vector<int>(0));
vector<int> color(MAX,0),prenum(MAX),parent(MAX),lowest(MAX);

void dfs(int c,int p){
    prenum[c]=lowest[c]=t;
    t++;
    color[c]=1;
    int next;
    for(int i=0;i<G[c].size();i++){
        next=G[c][i];
        if(!color[next]){
            parent[next]=c;
            dfs(next,c);
            lowest[c]=min(lowest[c],lowest[next]);
        }
        else if(next!=p){
            lowest[c]=min(lowest[c],prenum[next]);
        } 
    }
}

void art_points(){
    t=1;
    dfs(0,-1);

    set<int> ans;
    int np=0;
    for(int i=1;i<n;i++){
        if(parent[i]==0){
            np++;
        }
        else if(prenum[parent[i]]<=lowest[i]) ans.insert(parent[i]);
    }
    if(np>1) ans.insert(0);
    for(auto it=ans.begin();it!=ans.end();it++){
        cout<<*it<<endl;
    }
}

int main(){
    int a,b;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    art_points();
}


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

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}

int main()
{
	int A=read(),B=read();
	print(6-A-B); 

	return 0;
}

Measured memory_bytes: 256
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
#include <map>
#include <utility>
//using
using namespace std;
using vi = vector <int>;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
 //各位の和　
int wa(ll x)
{
ll sum = 0;
while(x!=0){
  sum += x% 10;
  x /= 10;
}
return sum;
}
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文
//if(isupper('A'))->大なら真


//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll  n;
  cin>>n;
  vl h(n);
  rep(i,n)
  {
    cin>>h[i];
  }
  rep(i,n-1)
  {
    p=h[i+1]-h[i];
    if(q==0)
    {
      if (p>=0)
      {
        h[i]--;
        q=0;
      }else if (p==-1)
      {
        h[i]--;
        q=1;
      }else
      {
        print("No")return 0;
      }
    }else
    {
      if (p>=1)
      {
        h[i]--;
        q=0;
      }else if (p==0)
      {
        h[i]--;
        q=1;
      }else
      {
        print("No")return 0;
      }
    }
    
  }
  print("Yes")
}

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

int main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    int cnt=0;
    rep(i,n-1)if(s[i]!=s[i+1])cnt++;
    cout<<n-1-max(0,cnt-2*k)<<endl;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	bool ok = true, c = false;
	for (int i = 0; i < s.length(); i++)
	{
		if (i == 0)
		{
			if (s[i] != 'A')
				ok = false;
		}
		else
		{
			if (s[i] == 'C')
			{
				if (c || 2 > i || i == s.length() - 1)
					ok = false;
				c = true;
			}
			else if (s[i] < 'a' || 'z' < s[i])
				ok = false;
		}
	}
	if (ok && c)
		cout << "AC" << endl;
	else
		cout << "WA" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.collection.immutable.TreeMap
import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val List(o, e) = input.split(LINE_SEPARATOR).toList.map(_.toSeq.toList)
    var i = 0
    (o ++ e).foldLeft(""){(s, c) =>
      val r = if (i % 2 == 1) s + e(i / 2) else s + o(i / 2)
      i += 1
      r
    }
  }


  def factorize(x: Long): List[Long] = {
    def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {
      case false if x % a == 0 => foo(x / a, a    , a :: list)
      case false               => foo(x    , a + 1, list)
      case true                => x :: list
    }
    foo(x)
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """xyz
      |abc""".stripMargin -> """xaybzc
                                   |""".stripMargin,
    """atcoderbeginnercontest
      |atcoderregularcontest""".stripMargin -> """aattccooddeerrbreeggiunlnaerrccoonntteesstt"""
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 25420
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

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

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 4003;

int n, m;
int a[N], b[N];
int sr[N], sg[N], sb[N];
char s[N];

int main()
{
    n = gi();
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i+=1)
    {
        sr[i] = sr[i - 1] + (s[i] == 'R');
        sg[i] = sg[i - 1] + (s[i] == 'G');
        sb[i] = sb[i - 1] + (s[i] == 'B');
    }
    LL ans = 0;
    for (int i = 1; i <= n; i+=1)
        for (int k = i + 1; k <= n; k+=1)
        {
            if (s[i] == s[k]) continue;
            int xr = 0, xg = 0, xb = 0;
            if (s[i] == 'R') xr = 1;
            else if (s[i] == 'G') xg = 1;
            else if (s[i] == 'B') xb = 1;
            if (s[k] == 'R') xr = 1;
            else if (s[k] == 'G') xg = 1;
            else if (s[k] == 'B') xb = 1;
            int now = 0;
            if (!xr) now = 1;
            else if (!xg) now = 2;
            else now = 3;
            if ((k - i) & 1)
            {
                if (now == 1) ans += sr[k] - sr[i - 1];
                else if (now == 2) ans += sg[k] - sg[i - 1];
                else ans += sb[k] - sb[i - 1];
            }
            else
            {
                if (now == 1) ans += sr[k] - sr[i - 1] - (s[(k + i) >> 1] == 'R');
                else if (now == 2) ans += sg[k] - sg[i - 1] - (s[(k + i) >> 1] == 'G');
                else ans += sb[k] - sb[i - 1] - (s[(k + i) >> 1] == 'B');
            }
        }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3852
#include<iostream>
#include<vector>//可変長配列
#include<algorithm>//sort,二分探索,など
#include<map>//map(辞書)
#include <cmath>

using namespace std;

int main(void){
    int N, D;
    cin >> N >> D;
    long x, y;
    double l;
    int count = 0;
    for(int i = 0; i < N; i++){
        cin >> x >> y;
        l = sqrt(x*x + y*y);
        if(l <= D){
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(2e4) + 17;

int n, m, x, y, z;
ll dp[41][1 << 17][2];

bool read() {
    if (!(cin >> n >> x >> y >> z))
        return false;

    return true;
}

void add(ll& a, ll b) {
    a += b;

    if (a >= INF)
        a -= INF;
}

void solve() {
    m = x + y + z;
    int ind = ((1 << (z - 1)) | (1 << (y + z - 1)) | (1 << (x + y + z - 1)));
    dp[0][0][0] = 1;

    for (int len = 0; len < n; ++len)
        for (int mask = 0; mask < (1 << m); ++mask)
            for (int nx = 1; nx <= 10; ++nx) {
                int smask = mask;
                smask <<= nx;
                smask |= (1 << (nx - 1));
                smask &= (1 << m) - 1;

                if ((smask & ind) == ind) {
                    add(dp[len + 1][smask][1], dp[len][mask][0]);
                    add(dp[len + 1][smask][1], dp[len][mask][1]);
                } else {
                    add(dp[len + 1][smask][0], dp[len][mask][0]);
                    add(dp[len + 1][smask][1], dp[len][mask][1]);
                }
            }

    ll ans = 0;

    forn (mask, (1 << m))
        add(ans, dp[n][mask][1]);

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 82176
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

long long pow_mod(long long x, long long n, long long mod_num) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) { res = (res * x) % mod_num; }
        x = (x * x) % mod_num;
        n = (n >> 1);
    }
    return res;
}

class Combi_Num {
    public:
    long long mod_num;
    std::vector<long long> fac, den;
    Combi_Num() {}
    Combi_Num(const int n, const int mod_num_in) {
        mod_num = mod_num_in;
        fac.resize(n+1, 0);
        den.resize(n+1, 0);
        fac[0] = 1;
        den[0] = 1;
        for (int i = 1; i <= n; i++) {
            fac[i] = (fac[i-1] * i) % mod_num;
            den[i] = (den[i-1] * pow_mod(i, mod_num - 2, mod_num)) % mod_num;
        }
    }

    long long calc(const int n, const int r) {
        return (fac[n] * ((den[r] * den[n-r]) % mod_num)) % mod_num;
    }

    //long long calc_inv(const int n, const int r) {
    //    return (den[n] * ((fac[r] * fac[n-r]) % mod_num)) % mod_num;
    //}
};

const int MAX_N = 1050;
const long long MOD = (long long)1000000007;

Combi_Num combi_num = Combi_Num(MAX_N * 10, MOD);

int N, A, B, C, D;

struct Sub_Pattern {
    long long num;
    long long pattern_num;
};

long long calc_sub_pattern_num(const long long i, const long long j) {
    long long ret = 1;
    for (long long n = i * j; n >= i; n -= i) {
        ret = (ret * combi_num.calc(n, i)) % MOD;
    }
    ret = (ret * combi_num.den[j]) % MOD;
    return ret;
}

std::vector<Sub_Pattern> sub_pattern[MAX_N];

long long dp[MAX_N][MAX_N] = {};

int main(int argc, char **argv) {
    std::cin >> N >> A >> B >> C >> D;
    
    //std::vector<long long> sub_group;
    for (int i = A; i <= B; i++) {
        Sub_Pattern sub;
        sub.num = 0;
        sub.pattern_num = 1;
        sub_pattern[i].push_back(sub);
        for (int j = C; j <= D; j++) {
            if (i * j <= N) {
                sub.num = j;
                sub.pattern_num = calc_sub_pattern_num(i, j);
                sub_pattern[i].push_back(sub);
            }
        }
    }

    //std::cout << calc_pattern(N, 1, 0) << std::endl;

    dp[A-1][0] = 1;
    for (int i = A; i <= B; i++) {
        for (auto sub : sub_pattern[i]) {
            for (int cn = 0; cn <= N; cn++) {
                if (cn + i * sub.num <= N) {
                    long long tmp = dp[i-1][cn];
                    tmp = (tmp * combi_num.calc(N - cn, i * sub.num)) % MOD;
                    tmp = (tmp * sub.pattern_num) % MOD;
                    dp[i][cn + i * sub.num] = (dp[i][cn + i * sub.num] + tmp) % MOD;
                }
            }
        }
    }

    std::cout << dp[B][N] << std::endl;

    return 0;
}

Measured memory_bytes: 8832
#include <stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; /* keyを発見 */
    if(key > A[mid]) left = mid + 1; /* 後半を探索 */
    else if(key < A[mid]) right = mid; /* 前半を探索 */
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 2120
#include <iostream>
#include <algorithm>
#include <vector>

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<std::pair<int, int>> es(m);
    for (auto& e : es) {
        std::cin >> e.first >> e.second;
        --e.first, --e.second;
    }
    std::reverse(es.begin(), es.end());

    std::vector<std::vector<bool>> ss(n);
    std::vector<bool> ok(n, true);

    for (int v = 0; v < n; ++v) {
        auto& s = ss[v];
        s.assign(n, false);
        s[v] = true;

        for (auto e : es) {
            if (s[e.second]) std::swap(e.first, e.second);

            if (s[e.second]) {
                ok[v] = false;
            } else if (s[e.first]) {
                s[e.second] = true;
            }
        }
    }

    int ans = 0;
    for (int v = 0; v < n; ++v) {
        if (!ok[v]) continue;
        for (int u = 0; u < v; ++u) {
            if (!ok[u]) continue;

            bool valid = true;
            for (int w = 0; w < n; ++w) {
                if (ss[v][w] && ss[u][w]) valid = false;
            }
            if (valid) ++ans;
        }
    }

    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RSLong;
            var ans = Calc(n[1]) ^ Calc(n[0] - 1);
            WriteLine(ans);
        }

        public static long Calc(long a)
        {
            if (a < 0) return 0;
            // 10^3 <= 1024 = 2^10
            // 10^12 <= 2^40
            long ans = 0;
            for (int i = 1; i <= 45; i++)
            {
                long cnt;

                if (i == 1)
                {
                    cnt = ((a + 1) / 2) % 2;
                    ans += cnt << (i - 1);
                    continue;
                }
                long loop = (long)Pow(2, i);
                long amari = (a % loop) + 1;
                amari -= loop / 2;

                if (amari <= 0) cnt = 0;
                else cnt = amari % 2;
                ans += cnt << (i - 1);
            }
            return ans;
        }
    }
    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

int main(){

  long long d,g,p[11],c[11];
  cin>>d>>g;

  long long ans=1e9;

  for(int i=0;i<d;++i)cin>>p[i]>>c[i];

  for(int bit=0;bit<(1<<d);bit++){

    long long solv=0,point=0;

    for(int i=0;i<d;++i){

      if(bit&(1<<i)){

	solv+=p[i];
	point+=(i+1)*100*p[i]+c[i];

      }
      
    }

    if(bit==(1<<d)-1){

      ans=min(ans,solv);
      
    }else{

      for(int i=d-1;i>=0;--i){

	if(!(bit&(1<<i))){

	  if(point+(p[i]-1)*(i+1)*100>=g){

	    ans=min(ans,solv+max(0LL,(g-point+(i+1)*100-1)/((i+1)*100)));

	  }

	  break;

	}

      }

    }
    
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int w,h,x,y,r;
		Scanner sc = new Scanner(System.in);
		w = sc.nextInt();	//????????¢???x??§?¨?
		h = sc.nextInt();	//????????¢???y??§?¨?
		
		x = sc.nextInt();	//??????x??§?¨?
		y = sc.nextInt();	//??????y??§?¨?
		r = sc.nextInt();	//????????????

		w -= r;
		h -= r;
		
		if(r<=x && x<=w && r<=y && y<=h){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		sc.close();
	}

}

Measured memory_bytes: 26172
n = int(input())
s = input()
ans = 0

for i in range(1, n):
    a = s[:i]
    b = s[i:]
    a_al = []
    ans_t = 0

    for k in range(len(a)):
        for l in range(len(b)):
            if a[k] in a_al:
                continue
            if a[k] == b[l]:
                ans_t += 1
                a_al.append(a[k])
    if ans_t > ans:
        ans = ans_t

print(ans)


Measured memory_bytes: 73636
#include <iostream>
using namespace std;
int main(void){
    
    int X, ans=0;
    cin >> X;
    for(int i=0; i<=25; i++){
        for(int j=0; j<=20; j++){
            if(X==4*i + 7*j){
                ans++;
            }
        }
    }
    if(ans>0) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n, k int
	fmt.Sscan(getNextLine(scanner), &n, &k)

	ans := (n - 1) / (k - 1)
	if (n-1)%(k-1) > 0 {
		ans++
	}
	fmt.Println(ans)
}


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

template <typename T>
struct segtree_lazy {
	int n;
	vector<T> tree, lazy;
	T def = numeric_limits<T>::max(), none = numeric_limits<T>::max();
	
	segtree_lazy(int n_) {
		for (n = 1; n < n_; n *= 2) {
			
		}
		tree.assign(2 * n, def);
		lazy.assign(2 * n, none);
	}
	
	T merge(T a, T b) {
		return min(a, b);
	}
	
	void set_lazy(int index, T x) {
		tree[index] = x;
		lazy[index] = x;
	}
	
	void push(int index) {
		if (lazy[index] == none) {
			return;
		}
		set_lazy(2 * index, lazy[index]);
		set_lazy(2 * index + 1, lazy[index]);
		lazy[index] = none;
	}
	
	void fix(int index) {
		tree[index] = merge(tree[2 * index], tree[2 * index + 1]);
	}
	
	void update(int a, int b, int index, int l, int r, T x) {
		if (r <= a || b <= l) {
			return;
		}
		if (a <= l && r <= b) {
			set_lazy(index, x);
			return;
		}
		push(index);
		update(a, b, 2 * index, l, (l + r) / 2, x);
		update(a, b, 2 * index + 1, (l + r) / 2, r, x);
		fix(index);
	}
	
	void update(int l, int r, T x) {
		update(l, r, 1, 0, n, x);
	}
	
	T query(int a, int b, int index, int l, int r) {
		if (r <= a || b <= l) {
			return none;
		}
		if (a <= l && r <= b) {
			return tree[index];
		}
		push(index);
		T puni = query(a, b, 2 * index, l, (l + r) / 2);
		T muni = query(a, b, 2 * index + 1, (l + r) / 2, r);
		return merge(puni, muni);
	}
	
	T query(int l, int r) {
		return query(l, r, 1, 0, n);
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	segtree_lazy<int> seg(n);
	for (int i = 0; i < q; i++) {
		bool b;
		cin >> b;
		if (b) {
			int s, t;
			cin >> s >> t;
			cout << seg.query(s, t + 1) << endl;
		} else {
			int s, t, x;
			cin >> s >> t >> x;
			seg.update(s, t + 1, x);
		}
	}
	return 0;
}

Measured memory_bytes: 4988
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;
#define SZ(x)               ((int)(x).size())
#define all(x)              (x).begin(), (x).end()
#define loop(i, n)          for(int i = 0; i < (n); i++)
#define cont(i, n)          for(int i = 1; i <= (n); i++)
#define circ(i, a, b)       for(int i = (a); i <= (b); i++)
#define range(i, a, b, c)   for(int i = (a); ((c) > 0 ? i <= (b) : i >= (b)); i += (c))
#define foreach(it, v)      for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define y0          y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1          y1II11II11III11I1III11II111IIII1II1I1
#define pub         push_back
#define pob         pop_back
#define mak         make_pair
typedef long long   ll;
typedef long double lf;
const int   Inf = 0x3f3f3f3f;
const ll    INF = 0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */
template<int jt> struct ModInt {
	int x;
	ModInt(int v = 0) {x = v; if(x >= jt || x < 0) {x %= jt; if(x < 0) x += jt;}}
	ModInt(ll v) {x = v % jt; if(x < 0) x += jt;}
	operator int() const {return x;}
	friend inline ModInt &operator+=(ModInt &a, const ModInt &b) {a.x += b.x; if(a.x >= jt) a.x -= jt; return a;}
	friend inline ModInt operator+(ModInt a, const ModInt &b) {return a += b;}
	friend inline ModInt operator+(ModInt a, int b) {return a += ModInt(b);}
	friend inline ModInt operator+(int a, ModInt b) {return b += ModInt(a);}
	friend inline ModInt &operator++(ModInt &a) {return a += 1;}
	friend inline ModInt &operator-=(ModInt &a, const ModInt &b) {a.x -= b.x; if(a.x < 0) a.x += jt; return a;}
	friend inline ModInt operator-(ModInt a, const ModInt &b) {return a -= b;}
	friend inline ModInt operator-(ModInt a, int b) {return a -= ModInt(b);}
	friend inline ModInt operator-(int a, ModInt b) {return ModInt(a) - b;}
	friend inline ModInt &operator--(ModInt &a) {return a -= 1;}
	friend inline ModInt &operator*=(ModInt &a, const ModInt &b) {a.x = (ll)a.x * b.x % jt; return a;}
	friend inline ModInt operator*(ModInt a, const ModInt &b) {return a *= b;}
	friend inline ModInt operator*(ModInt a, int b) {return a *= ModInt(b);}
	friend inline ModInt operator*(int a, ModInt b) {return b *= ModInt(a);}
	static inline void exgcd(ll a, ll b, ll &x, ll &y) {b ? (exgcd(b, a % b, y, x), y -= a / b * x) : (x = 1, y = 0);}
	friend inline ModInt inv(const ModInt &a) {ll x, y; exgcd(a, jt, x, y); return x;}
	friend inline ModInt operator/(const ModInt &a, const ModInt &b) {return a * inv(b);}
	friend inline ModInt operator/(ModInt a, int b) {return a * inv(ModInt(b));}
	friend inline ModInt operator/(int a, ModInt b) {return ModInt(a) * inv(b);}
	friend inline ModInt operator/=(ModInt &a, const ModInt &b) {return a = a / b;}
};
const int jt = 998244353;
typedef ModInt<jt> mint;

int n, k;
int l[12], r[12];
mint dp[1 << 18];
mint qzh[1 << 18];

int main() {
	scanf("%d%d", &n, &k);
	cont(i, k) scanf("%d%d", l + i, r + i);
	dp[1] = qzh[1] = 1;
	circ(i, 2, n) cont(j, k) {
		dp[i] += qzh[max(0, i - l[j])] - qzh[max(0, i - r[j] - 1)];
		qzh[i] = dp[i] + qzh[i - 1];
	}
	printf("%d\n", int(dp[n]));
	return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include <string> 
using namespace std;
int max(int x, int y) {
	if (x > y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}


int A,B;
bool match[100001];


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace lib
{
	#define ll long long
	#define ull unsigned long long
	#define rgi register int
	#define rgl register long long
	#define rgc register char
	const double pi=acos(-1); 
	using namespace std;
	class fastio
	{
		private:
			#define _NUMLEN 112
			char _num[_NUMLEN],_ch; int _f,_head; bool _useSTD;
		public:
			fastio() {_f=0,_head=0,_useSTD=0,SUF=_ch=' ';}
			char SUF;
			inline void ioSTD() {_useSTD=1; ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); }
			inline void gc(char & _c) {if(_useSTD)cin>>_c; else _c=getchar(); }
			inline void pc(char _c) {if(_useSTD)cout<<_c; else putchar(_c); }
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				if(_useSTD)cin>>_x; else{
					_x=0; 
					while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch); 
					while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch); 
					_f&&(_x=-_x,_f=0); 
				}return *this; 
			}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				if(_useSTD)cout<<_x<<SUF; else{
					_T _k; 
					if(_x==0) {pc('0'),pc(SUF);return *this;} if(_x<0) pc('-'),_x=-_x;
					while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k; while(_head>0) pc(_num[_head]),--_head;
					pc(SUF);
				}return *this; 
			}
			inline fastio & operator >> (char & _x) {gc(_x);return *this;}
			inline fastio & operator << (char _x) {pc(_x);return *this;}
			template<typename _T> inline fastio & operator >> (_T & _x) {cin>>_x;return *this;}
			template<typename _T> inline fastio & operator << (_T _x) {cout<<_x;return *this;}
			#define edn pc('\n')
	}io;
	inline void fileio(string _r,string _w) {if(_r[0]!='-')freopen(_r.c_str(),"r",stdin); if(_w[0]!='-')freopen(_w.c_str(),"w",stdout); }
	#define mem(_x,_set) memset(_x,_set,sizeof(_x))
}
using namespace lib;
// ----------------------------

// #define int ll
const int maxn=100004;
const int mod=998244353,inf=1000000007;

int ap[maxn],bp[maxn];

signed main()
{
	// fileio("tt.in","tt.out");
	// io.ioSTD();
	int a,b,m,x,y,c=inf,ans=0;
	io-a-b-m;
	for(rgi i=1;i<=a;++i) io-ap[i],c=min(c,ap[i]);
	ans+=c,c=inf;
	for(rgi i=1;i<=b;++i) io-bp[i],c=min(c,bp[i]);
	ans+=c;
	for(rgi i=1;i<=m;++i)
	{
		io-x-y-c;
		ans=min(ans,ap[x]+bp[y]-c);
	}
	io+ans;
	return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>

using namespace std;

int pollock[201];
int dp1[1000001] = { 0 };
int dp2[1000001] = { 0 };

void dp() {
	for (int i = 1; i <= 200; i++) {
		pollock[i] = i*(i + 1)*(i + 2) / 6;
	}

	for (int i = 0; i < 1000000; i++) {
		dp1[i] = i;
		dp2[i] = i;
	}

	for (int i = 2; i <= 1000000; i++) {
		for (int j = 1; j <= 200; j++) {
			if (pollock[j] > i) break;
			if (dp1[i - pollock[j]] + 1 < dp1[i]) dp1[i] = dp1[i - pollock[j]] + 1;
			if (pollock[j] % 2 == 1) {
				if (dp2[i - pollock[j]] + 1 < dp2[i]) dp2[i] = dp2[i - pollock[j]] + 1;
			}
		}
	}
}

int main() {
	dp();
	ifstream fin("test.txt");
	ofstream fout("ans.txt");
	int n;
	while (true) {
		cin >> n;
		if (n == 0) break;
		cout << dp1[n] << " " << dp2[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std; 
const int Max=50;
bool G[Max][Max];
bool visited[Max];
int N,M;

void dfs(int v){
  visited[v]=true;
  for(int v2=0;v2<N;v2++){
    if(G[v][v2]==false)continue;
    if(visited[v2]==true)continue;
    dfs(v2);
  }
}
int main(){
  int ans=0;
  cin>>N>>M;
  int a[Max],b[Max];
  
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      G[i][j]=false;
    }
  }
  
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i];
    a[i]--;
    b[i]--;
    G[a[i]][b[i]]=G[b[i]][a[i]]=true;
  }
  
  for(int i=0;i<M;i++){
    G[a[i]][b[i]]=G[b[i]][a[i]]=false;
    
    for(int j=0;j<N;j++) visited[j]=false;
    
    dfs(0);
    
    bool bridge=false;
    for(int j=0;j<N;j++) if(visited[j]==false)bridge=true;
    if(bridge)ans++;
    
    G[a[i]][b[i]]=G[b[i]][a[i]]=true;
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long count = 0;
		while(h > 0) {
			h = h/2;
			count++;
		}
		System.out.println(pow(2,count)-1);
		sc.close();
	}
	public static long pow(long x, long n) {
	    long sum = 1;
	    while (n > 0) {
	        if ((n & 1) == 1) {
	            sum = sum * x;
	        }
	        x = x*x;
	        n >>= 1;
	    }
	    return sum;
	}
}

Measured memory_bytes: 22612
from collections import deque
N = int(input())
Graph = [[] for i in range(N)]
for i in range(N-1):
    u,v,w = map(int, input().split())
    Graph[u-1].append((v-1, w))
    Graph[v-1].append((u-1, w))

used = [0]*N
Q = deque([0])
used[0] = 1
ans = [0]*N
while Q:
  i = Q.popleft()
  j = ans[i]
  for uv, w in Graph[i]:
    if used[uv]:
      continue
    if w%2 != 0:
      ans[uv] = j^1
    else:
      ans[uv] = j
    Q.append(uv)
    used[uv] = 1

print(*ans)

Measured memory_bytes: 41492
#!/usr/bin/env python3

INF = 10**9 + 1

def solve(n,a):
    ans = 0
    minusCount = 0
    minimumNum = INF
    lst = []
    for i in range(n):
        if a[i] < 0:
            minusCount += 1
        ans += abs(a[i])
        minimumNum = min(minimumNum,abs(a[i]))
    if minusCount % 2 == 0:
        pass
    else:
        ans -= minimumNum*2
    return ans


def main():
    N = int(input())
    a = list(map(int,input().split()))
    print(solve(N,a))

if __name__ == '__main__':
    main()


Measured memory_bytes: 20008
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N, a[10010];
	cin >> N;
	double an = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		an += (double)1 / a[i];
	}
	cout << (double)1 / an;
}

Measured memory_bytes: 256