akhauriyash/Code-Regression huggingface dataset:
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  200005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
ll a[N];
ll n,k;
bool f(ll x)
{
	ll cnt=0;
	rep(i,1,n)
	{
		if(a[i]<0)
		{
			ll lo=0,h1=i-1;
			while(lo<h1)
			{
				//cout<<lo<<endl;
				ll mid=(lo+h1+1)/2;
				if(a[mid]*a[i]>=x)
					lo=mid;
				else h1=mid-1;
			}
			if(a[lo]*a[i]>=x)
			{
				cnt+=i-lo-1;
			}
			else if(a[0]*a[i]<x)cnt+=i;
		}
		else if(a[i]>0)
		{
			ll lo=0,h1=i-1;
			while(lo<h1)
			{
				// cout<<i<<' '<<lo<<' '<<x<<endl;
				ll mid=(lo+h1+1)/2;
				if(a[mid]*a[i]<x)
					lo=mid;
				else h1=mid-1;
			}
			if(a[lo]*a[i]<x)
				cnt+=lo+1;
		}
		else
		{
			if(x>0) cnt+=i;
		}
	}
	// cout<<"x "<<x<<' '<<cnt<<endl;
	return (cnt<k);
}
void solve()
{
	cin>>n>>k;
	rep(i,0,n) cin>>a[i];
	sort(a,a+n);
	ll lo=-1e18,h1=1e18,ans=-1e18;
	while(lo<=h1)
	{
		ll mid=(lo+h1)/2;
		// cout<<lo-1e18<<' '<<h1-1e18<<endl;
		if(f(mid))
		{
			lo=mid+1;
			ans=mid;
		}
		else h1=mid-1;
	}
	cout<<ans<<endl;
}
signed main()
{
	
		/***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
//  #ifndef ONLINE_JUDGE
//       // for getting input from input.txt
//      freopen("input.txt", "r", stdin);
// //     // for writing output to output.txt
// //     freopen("output1.txt", "w", stdout);
//  #endif
	// ios_base::sync_with_stdio(false);
	// cin.tie(0);
	// cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;
 
public class Main{
 
     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        check(n);
     }
     
     public static void check(String n){
         String[] s = n.split("");
         int a = Integer.parseInt(s[0]);
         int b = Integer.parseInt(s[1]);
         int c = Integer.parseInt(s[2]);
         int d = Integer.parseInt(s[3]);
         if (a+b+c+d==7){
              System.out.println(a+"+"+b+"+"+c+"+"+d+"="+7);
         }else if (a+b+c-d==7){
              System.out.println(a+"+"+b+"+"+c+"-"+d+"="+7);
         }else if (a+b-c+d==7){
              System.out.println(a+"+"+b+"-"+c+"+"+d+"="+7);
         }else if (a+b-c-d==7){
              System.out.println(a+"+"+b+"-"+c+"-"+d+"="+7);
         }else if (a-b+c+d==7){
              System.out.println(a+"-"+b+"+"+c+"+"+d+"="+7);
         }else if (a-b+c-d==7){
              System.out.println(a+"-"+b+"+"+c+"-"+d+"="+7);
         }else if (a-b-c+d==7){
              System.out.println(a+"-"+b+"-"+c+"+"+d+"="+7);
         }else if (a-b-c-d==7){
              System.out.println(a+"-"+b+"-"+c+"-"+d+"="+7);
         }
     }
}

Measured memory_bytes: 21844
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

int N;
lng sum[200010];

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

    cin >> N;
    REP(i, N) {
        cin >> sum[i];
        if(i > 0) sum[i] += sum[i-1];
    }

    lng ans = 1LL << 40;
    FOR(i, 0, N-2) {
        lng x = sum[i];
        lng y = sum[N-1] - sum[i];
        ans = min(ans, max(x-y, y-x));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	unsigned long int a=2,b=1,t=0;
  	int n; cin>>n;
  	if(n==1){cout<<1<<endl; return 0;}
  	if(n==2){cout<<3<<endl; return 0;}
  	for (int i=3;i<=n;i++){
      		t=a;
  		    a=b;
      		b=t+b;      
    }
  	cout<<a+b<<endl;
  	
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
bool graph[30][30];
int a[30],b[30];
const int nmax=8;
int dfs(int v,int N,bool visited[nmax]){
    bool all_visited=true;
    for(int i=0;i<N;i++){
        if(visited[i]==false) all_visited=false;
    }
    if(all_visited){
        return 1;
    }
    int ret=0;
    for(int i=0;i<N;i++){
        if(!graph[v][i]) continue;
        if(visited[i]) continue;

        visited[i]=true;
        ret+=dfs(i,N,visited);
        visited[i]=false;
    }
    return ret;
}

bool visited[nmax];
int main() {
    int N,M;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;

    }
   visited[0]=true;
    
    
    cout<<dfs(0,N,visited)<<endl;



    return 0;
}

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

int n,k,ans=0;


int main(){
    string s;
    cin>>s;
    if(s[0]=='R'||s[0]=='U'||s[0]=='D'){
    for(int i=1;i<s.length();i++){

        if(i%2==0){
            if(s[i]=='R'||s[i]=='U'||s[i]=='D')++ans;
            else{
                //cout<<"No";
                --ans;
                break;
            }
        }
        
        else{
            
            if(s[i]=='L'||s[i]=='U'||s[i]=='D')++ans;
            else{
                //cout<<"No";
                --ans;
                break;
                }
            }
        }
    }
    else{
        --ans;
    }

    if(ans==s.length()-1)cout<<"Yes";
    else cout<<"No";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define INF 2001
#define WHITE 0
#define BLACK 1
int n,a[N][N];
int d[N],pi[N],color[N];

void prim()
{
  int i,u,mincost;
  for(i=0; i<n; i++) {
    d[i] = INF;
    pi[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;
  
  while(1){
    mincost = INF;
    for(i=0; i<n; i++) {
      if(color[i] != BLACK && d[i] < mincost) {
	mincost = d[i];
	u = i;
      }
    }

    if(mincost == INF)  break;

    color[u] = BLACK;
    for(i=0; i<n; i++) {
      if(a[i][u] != -1){
	if(color[i] != BLACK && a[i][u] < d[i]) {
	  pi[i] = u;
	  d[i] = a[i][u];
	}
      }
    }
  }
}

int main()
{
  int i,j,sum=0;
  
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    for(j=0; j<n; j++) 
      scanf("%d",&a[i][j]);
  }
  prim();
  for(i=0; i<n; i++) 
    if(pi[i]!=-1) sum+=d[i];
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 636
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a[] = new int[5];
    for (int i = 0; i < 5; i++) {
      a[i] = sc.nextInt();
    }
    int k = sc.nextInt();

    for (int i = 0; i < 4; i++) {
      for (int j = i + 1; j < 5; j++) {
        if (a[j] - a[i] > k) {
          System.out.println(":(");
          return;
        }
      }
    }
    System.out.println("Yay!");
  }
}

Measured memory_bytes: 23124
n = int(input())
#2**n通りの正直者を全列挙してそれを矛盾が生じないか試していき最大値を求める 競合してる証言をピック　True or False で判断する
jud = [[-1 for i in range(n)] for j in range(n)]
xy = []
ayasi = []
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        jud[i][x-1] = y
Max = 0
for i in range(2**n):
    li = []
    flag = True
    cnt = 0
    for j in range(n):
        if ((i >> j) & 1):
            li.append(1)

        else:
            li.append(0)
    for k in range(n):
        if li[k] == 1:
         for l in range(n):
             if jud[k][l] != -1:
                 if jud[k][l] != li[l]:
                     flag = False
                     break

    if flag:
        Max = max(sum(li),Max)
print(Max)


Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
      	int i = 0;
        int min = N + 1;
        int count = 0; 
      	int P[] = new int[N];
      	for(i = 0;i < N;i++){
          P[i] = sc.nextInt();
          if(P[i] < min){
            min = P[i];
            count += 1;
          }
        }
       System.out.println(count);            
    }
}

Measured memory_bytes: 60348
#include <stdio.h>

int main(){
	int w, h, x, y, r;

	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	if (x - r >= 0 && x + r <= w){
		if (y - r>=0 && y + r <= h){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2684
n, y = gets.chomp.split(" ").map(&:to_i)
judge = false
sum = 0
num1000 = 0
0.upto(n) do |num10000|
  0.upto(n - num10000) do |num5000|
    num1000 = n - num10000 - num5000
    sum = num10000 * 10000 + num5000 * 5000 + num1000 * 1000
    if sum == y
      puts "#{num10000} #{num5000} #{num1000}"
      judge = true
      break
    end
  end
  if judge == true
    break
  end
end
if judge == false
  puts "-1 -1 -1"
end

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

#define ll long long

// ll fact(int n){
// 	ll f=1;
// 	for (int i = 2; i <= n; ++i)
// 	{
// 		/* code */
// 		f*=i;
// 	}
// 	return f;
// }

int main(){
	string s1,s2;
	cin>>s1>>s2;
	int c=0;
	for (int i = 0; i < 3; ++i)
	{
		/* code */
		if(s1[i]==s2[i])
			c++;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

type Student struct {
	Number     int
	inClassNum int
}

type ByClassNum []Student

func (a ByClassNum) Len() int           { return len(a) }
func (a ByClassNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByClassNum) Less(i, j int) bool { return a[i].inClassNum < a[j].inClassNum }

func main() {

	var N int
	fmt.Scan(&N)

	slice := make([]int, N)

	for i := 0 ; i < N ; i++ {
		fmt.Scan(&slice[i])
	}

	var ans int = 0

	for i := 0 ; i < N ; i++ {
		for j := i ; j < N ; j++ {
			if( i != j) {
				ans += slice[i]*slice[j]
			}
		}
	}


	fmt.Println(ans)

}


Measured memory_bytes: 512
#入力して単語に分けてリスト化
s=input().split()
#print(s)

ss=[]
for w in s:
    a=w.find("apple")
    p=w.find("peach")
    #find関数は見つからなかったら-1を返す
    if a!=-1:
        w=w.replace("apple","peach")
    elif p!=-1:
        w=w.replace("peach","apple")
    ss.append(w)
print(" ".join(ss))



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

int main(){
    int a,b; cin >> a >> b;
    int ans=max(a+b,a-b);
    cout << max(ans,a*b) << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}

    int sum = 0;
    rep(i, n) {sum+=a[i];}
    double th = (double)sum / (double)(4*m);
    int ok = 0;
    rep(i, n) {
        if (th <= a[i]){
            ok++;
        }
    }
    if (ok >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
K, A, B = [int(i) for i in input().split()]

bisk = 1
if A + 2 <= B:
    pon = A - bisk
    bisk += K if A > K else pon
    K -= K if A > K else pon
    bisk += (B - A) * (K // 2)
    K %= 2

bisk += K
print(bisk)

Measured memory_bytes: 3060
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

int main()
{
  int X;
  cin >> X;

  int div = X/100;
  int mod = X%100;
  if (mod<=div*5)
    cout << 1 << endl;
  else
    cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
from sys import stdin

def main():
    K, X = map(int, input().split())

    min_ = max(X - K + 1, -1000000)
    max_ = min(X + K -1, 1000000)
    ans = [i for i in range(min_, max_ + 1)]
    print(*ans)

input = lambda: stdin.readline()
main()


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<functional>
#include<cstring>

using namespace std;
typedef long long ll;
int N=1<<17;
ll dat[1<<18];
int id[1<<18];
int n,r,l;
int d[1000001],t[1000001],x[1000001];
int timel[100001];

void init(){
	memset(dat,0,sizeof(dat));
	for(int i=N;i<N*2;i++)id[i]=i-N;
}

void update(int k,ll a){
	k+=N-1;
	dat[k]+=a;
	while(k>0){
		k=(k-1)/2;
		if(dat[k*2+1]>=dat[k*2+2]){
			dat[k]=dat[k*2+1];
			id[k]=id[k*2+1];
		}else{
			dat[k]=dat[k*2+2];
			id[k]=id[k*2+2];
		}
	}
}

int main(void){
	scanf("%d%d%d",&n,&r,&l);
	for(int i=0;i<r;i++)scanf("%d%d%d",&d[i],&t[i],&x[i]);
	int nt=0;
	init();
	for(int i=0;i<r;i++){
		timel[id[0]]+=t[i]-nt;
		nt=t[i];
		update(d[i],x[i]);
	}
	timel[id[0]]+=l-nt;
	int sum=0,rid=0;
	for(int i=0;i<n;i++){
		if(sum<timel[i])sum=timel[i],rid=i;
	}
	printf("%d\n",rid+1);
	return 0;
}

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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int a, b;
    cin>>a>>b;

    if((a+b)%2==0){
        cout<<(a+b)/2<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }

    return 0;
}

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

int main(){
  long long x;
  cin >> x;
  //ここまで入力

  long long ans = 0;
  //6点，5点を繰り返し行えばよい
  //1周期が11点なので，何周行えるかを計算する
  //1周で2回の操作を要することも考慮する
  ans += x/11*2;

  //11点の周期を限界まで行った後，何点残っているか
  x %= 11;

  //残りが0点ならそれが答え
  if(x == 0)
    cout << ans << endl;
  //残りが6点以下ならあと1回の操作で終了
  else if(x <= 6)
    cout << ans + 1 << endl;
  //7点以上あるなら，2回の操作を要する
  else
    cout << ans + 2 << endl;

  return 0;
}


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

int main() {
 int a, b, c, d ;
    cin >> a >> b >> c >> d ;
  int l = a+b , r = c+d ;
   if( l > r )
     cout << "Left" << endl;
  else if(l == r)
    cout<< "Balanced" << endl;
  else if( l < r )
    cout<< "Right" <<endl;
  }

Measured memory_bytes: 3568
N,M = map(int,input().split())
L = list(map(int,input().split()))
L.sort()
P = []
S = 0
for i in range(M-1):
  P.append(L[i+1]-L[i])
P.sort()
if N >= M:
  print(0)
else:
  for i in range(N-1):
    S += P[M-2-i]
  print(L[M-1]-L[0]-S)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n, k; cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int sum = 0;
    rep(i, k) sum += p[i];
    cout << sum;
}


Measured memory_bytes: 3656
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;

using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,h; cin >> a >> b >> h;
    int s = (a+b)*h/2;
    cout << s << "\n";
}



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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int lcm(int a,int b){return a*b/gcd(a, b);}

int main()
{
  char c;
  cin >> c;
  if ('A' <= c && c <= 'Z')
    cout << 'A' << endl;
  else
    cout << 'a' << endl;
}

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

void check(int &ans,int N,int &M,vector<int> sw,vector<vector<int>> &vec,vector<int> &p){
   if(N==0){
     
    bool x=true;
    for(int i=0;i<M;i++){
      int y=0;
      for(int j=0;j<vec[i].size();j++){
        y+=sw[vec[i][j]-1];
      }
      if(y%2!=p[i]){
        x=false;
        break;
      }
    }
    if(x){
      ans++;
    }
     return;
  }
  check(ans,N-1,M,sw,vec,p);
  sw[N-1]=(sw[N-1]+1)%2;
  check(ans,N-1,M,sw,vec,p);  
}



int main(){
  int N,M; cin >> N >> M;
  vector<vector<int>> vec(M);
  
  for (int i = 0; i < M; i++){
    int k;
    cin >> k;
    vec[i].resize(k);
    for(int j = 0; j < k; j++){
      cin >> vec[i][j];
    }
  }

  vector <int> p(M);
  for(int i = 0; i < M; i++){
    cin >> p[i];
  }

  int ans = 0;
  vector<int> sw(N,0);
  check(ans,N,M,sw,vec,p);
  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n;
long long ans,dp[2*N];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		long long a;
		cin>>a;
		dp[i+1]=dp[i]+a;
	}
	ans=abs(dp[n]-dp[1]-dp[1]);
	for(int i=1;i<n;i++)
		ans=min(ans,abs((dp[n]-dp[i])-dp[i]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/*********** TEMPLATE ENDS HERE *************/

const int DIM = 1e5 + 7;

vi v[DIM];

main()
{
	IOS
	
	int n;
	cin >> n;
	
	int p = sqrt(2 * n);
	
	if(p * (p + 1) != 2 * n)
	{
		cout << "No";
		return 0;
	}
	
	cout << "Yes\n";
	
	int k = p + 1;
	
	int line = 1;
	int nr = 0;
	int per = p;
	
	while(line < k)
	{
		int x = 1;
		for(int i = 1; i <= per; i++)
		{
			v[line].pb(nr + i);
			v[line + x].pb(nr + i);
			x++;
		}
		
		nr += per;
		per--;
		
		line++;
	}
	
	cout << k << '\n';
	
	for(int i = 1; i <= k; i++)
	{
		cout << k - 1 << ' ';
		for(auto j : v[i])
			cout << j << ' ';
		cout << '\n';
	}
}




Measured memory_bytes: 4736
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    int ans=0;
    cin>>ans;
    ans=0;
    cin>>s;
    for (int x=0;x<s.size()-2;x++){
        if (s[x]=='A'  && s[x+1]=='B' && s[x+2]=='C') ans++;
    }
    
    cout<<ans;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [0]*m
for i in range(m):
    a[i] = int(input())
mod = 10**9 + 7

dp = [-1]*(n+1)
dp[0] = 1
dp[1] = 1
for i in range(m):
    dp[a[i]] = 0
#print(dp)
for i in range(n-1):
    if dp[i+2] == -1:
        dp[i+2] = (dp[i+1] + dp[i]) % mod
    elif dp[i+2] == 0:
        dp[i+2] = 0
#print(dp)
print(dp[n] % mod)

Measured memory_bytes: 45912
N, L = map(int, input().split())
 
res = 0
for i in range(N):
  res += i + L
 
if L == 0:
  print(res)
elif L > 0:
  print(res - L)
elif L < 0:
  if N + L > 0:
    print(res)
  else:
    print(res - L - N + 1)

Measured memory_bytes: 3060
#include<stdio.h>
int bsort(int a[],int n){
	int i,j,num=0;
	for(i=0;i<n-1;i++){
		for(j=0;j<n-i-1;j++){
			if(a[j+1]<a[j]){
				int temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
				num++;
			}
		}
	}
	return num;
}
int main(void){
	int i,n,num,x[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){scanf("%d",&x[i]);}
	num=bsort(x,n);
	printf("%d",x[0]);
	for (i=1;i<n;i++){printf(" %d",x[i]);}
	printf("\n%d\n",num);
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=55;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n;
long double ans;
int main()
{
	n=read();
	for(int i=1;i<=n;i++){
		int x=read();
		ans+=1.0/(long double)x;
	}
	printf("%.8Lf\n",1.0/ans);
}


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

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int LG = 20;
const double EPS = 3e-16;

int main(){
//	freopen("ex.in", "r", stdin);
//	freopen("ex.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n; cin >> n;
	cout << n * n;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define NIL -1

typedef struct {
  int parent;
  int left;
  int right;
}Tree;
Tree T[MAX];

void print(int id);

int main(){
  int i,j,n,p,a,r,b;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=T[i].left=T[i].right=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&p,&a);
    for(j=0;j<a;j++){
      scanf("%d",&r);
      T[r].parent=p;
      if(j==0) T[p].left=r;
      else if(j>0) T[b].right=r;
      b=r;
    }
  }

  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}

void print(int id){
  int depth=0;
  int u=T[id].parent;

  while(u!=NIL){
    u=T[u].parent;
    depth++;
  }
  
  if(depth==0){
    printf("node %d: parent = %d, depth = %d, root, ",id,T[id].parent,depth);
  }
  else if(T[id].left==NIL){
    printf("node %d: parent = %d, depth = %d, leaf, ",id,T[id].parent,depth);
  }
  else{
    printf("node %d: parent = %d, depth = %d, internal node, ",id,T[id].parent,depth);
  }

  u=T[id].left;
  printf("[");
  if(u!=NIL){
    printf("%d",u);
  }
  while(u!=NIL){
    u=T[u].right;
    if(u!=NIL){
      printf(", %d",u);
    }
  }
  printf("]\n");
}

Measured memory_bytes: 1788
#include<stdio.h>
int main(){
    int X,A,B;
    scanf("%d %d %d",&X,&A,&B);
    if(A-B>=0){
        printf("delicious");
    }else if(A-B+X>=0){
        printf("safe");
    }else{
        printf("dangerous");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    string s;
    ll k;
    cin >> s >> k;
    int n = s.length();
    for(ll i = 0; i < n; ++i){
        if(i >= k){
            cout << 1 << "\n";
            return 0;
        }
        if(s[i] != '1'){
            cout << s[i] << "\n";
            return 0;
        }
    }
    cout << 1 << "\n";
}

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

int main() {
    int n, m;
    cin >> n >> m;
    int k[15];
    int s[15][15];
    for(int i=0; i< m; ++i){ 
        cin >> k[i];
        for(int j=0; j<k[i]; ++j){ 
            cin >> s[i][j];
        }
    }
    int p[15];
    for(int i=0; i<m; ++i){
        cin >> p[i];
    }
    int ans=0;
    for(int i=0; i < (1 << n); ++i){
        bool a=true;
        for(int j=0; j<m; ++j){
            int count  = 0;
            for(int l=0; l<k[j]; ++l){
                if((i >> (s[j][l]-1)) & 1){
                    count  +=1;
                }
            }
            if(count%2==p[j]){}
            else{
                a=false;
                break;
            }
        }
        if(a){
            ans +=1;
        }
    }
    cout << ans << endl;
}


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

int main(void) {
  ios::sync_with_stdio(false);
  int N, T;
  cin >> N >> T;
  vector<pair<int, int>> AB(N);
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    AB[i] = {a, b};
  }
  sort(AB.begin(), AB.end());

  int maxT = T + 3000;
  vector<int> DP(maxT + 1, 0);
  int answer = 0;
  rep(i, N) {
    for (int j = T - 1; j >= 0; --j) {
      answer = max(answer, DP[j] + AB[i].second);
      DP[j + AB[i].first] = max(DP[j + AB[i].first], DP[j] + AB[i].second);
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

using namespace std;
typedef long long llong;

#define MAX

int main()
{
  int x;
  for (int i = 1; i <= 5; i++)
  {
    scanf("%d", &x);
    if (x == 0)
      printf("%d", i);
  }

  return 0;
}

Measured memory_bytes: 1700
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		if(check(str)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
	
	public static boolean check(String str) {
		int Count = 0;
		for(int i = 0; i < str.length(); i++) {
			if(i%2 == 0) {
				if((str.charAt(i) == 'R') || (str.charAt(i) == 'U')||(str.charAt(i) == 'D')) {
					Count++;
				}
			}else {
				if((str.charAt(i) == 'L') || (str.charAt(i) == 'U')||(str.charAt(i) == 'D')) {
					Count++;
				}
			}
		}
		if(Count == str.length()) {
			return true;
		}else {
			return false;
		}
		
	}
}

Measured memory_bytes: 23764
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    X = input()
    answer = len(X)
    cnt_s = 0
    for x in X:
        if x == "S":
            cnt_s += 1
            continue
        if cnt_s > 0:
            cnt_s -= 1
            answer -= 2
            
    print(answer)


if __name__ == "__main__":
    main()


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  string s; cin >> s;
  sort(ALL(s));
  if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static Scanner scan;

    public static void main(String[] args) {
        scan = new Scanner(System.in);
        while (true) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (x == 0 && y == 0) {
                break;
            }
            comp(x,y);
        }
    }

    private static void comp(int x,int y) {
        if (x < y) {
            System.out.println(x +" "+y);
        } else {
            System.out.println(y +" "+x);
        }
    }
}

Measured memory_bytes: 27292
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int m=s.nextInt();
    ArrayList<Integer>[] graph=new ArrayList[n];
    for(int i=0;i<n;i++)
      graph[i]=new ArrayList<Integer>();
    for(int i=0;i<m;i++){
      int x=s.nextInt();
      int y=s.nextInt();
      graph[x-1].add(y-1);
    }
    int[] dp=new int[n];
    for(int i=0;i<n;i++){
      dfs(i,graph,dp);
    }
    int max=Integer.MIN_VALUE;
    for(int i=0;i<n;i++){
      max=Math.max(dp[i],max);
    }
    
    System.out.println(max);
  }
  public static int dfs(int i, ArrayList<Integer>[] graph, int[] dp){
    if(graph[i].size()==0){
      return 0;
    }
    if(dp[i]!=0)
      return dp[i];
    dp[i]=Integer.MIN_VALUE;
    for(int j=0;j<graph[i].size();j++){
      dp[i]=Math.max(dp[i],dfs(graph[i].get(j),graph,dp)+1);
                     }
                   return   dp[i];
                     }
}
 

Measured memory_bytes: 100424
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	long long n,s;
	cin>>n;
	s=(1+n)*n/2;
	for(int i=1;i<=n;i++)
	if(i%3==0 || i%5==0)
	s=s-i;
	cout<<s;
return 0;
}

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

using namespace std;
 
 


//c++ templte for help.......................................................................................................................................................

typedef long long ll;

template<typename... T>
void print1(T... t){
	((cout<<t<<" "),...);
}

template<typename... T>
void print2(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			if(i!=0) cout<<"\t\t";
			else cout<<"\t";
			for(ll j=0;j<(ll)ans[i].size();j++){
				cout<<ans[i][j]<<" ";
			}
			if(i!=(ll)ans.size()-1)
			cout<<endl;
		}
}	
#define deb(...) {cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; }
#define vdeb(...) {cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;}

// to return everything in string
#define ret(...) {stringstream returnn;returnn<<__VA_ARGS__;return returnn.str();}

stringstream retvec;
template<typename... T>
void returnvector(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			for(ll j=0;j<(ll)ans[i].size();j++){
				retvec<<ans[i][j];
				if(j!=(ll)ans[i].size()-1)
					retvec<<" ";
			}
			if(i!=(ll)ans.size()-1)
				retvec<<endl;
		}
}
#define vret(...) {returnvector(__VA_ARGS__);return retvec.str();}
	


//for loop
#define fo(i,n) for(int i=0;i<(ll)n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
template<typename T>
void printV(T vec){
	fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	cout<<endl;
	}
	
 
#define M ll(998244353)
const ll INF=ll(1e9+5);
 
//iterate map
template<typename T>
void itR(T map){
	 for(auto itr=map.begin();itr!=map.end();itr++){
				deb(itr->first,itr->second);
			}
	cout<<endl;
}

//c++ template for help.....................................................................................................................................................

string solve(){
	ll n;
	cin>>n;
	
	string ans="";
	for(int i=0;i<n;i++){
		ans+="ACL";
	}
	ret(ans);
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	ret("");
	
}

int main() {
	cout<<setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);

	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		string ans1=solve();
		if(ans1!="")
			cout<<ans1<<endl;
	//}
	return 0;
}


















Measured memory_bytes: 3656
#include <stdio.h>

#define N 100000

int main(){
  int n,q,s[N],t[N],r,l,m,ans=0,i,j;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&s[i]);
  scanf("%d",&q);
  for(j=0; j<q; j++) scanf("%d",&t[j]);
  for(j=0; j<q; j++){
    l=0;
    r=n;
    while(l<r){
      m=(l+r)/2;
      if(s[m]==t[j]){
	ans++;
	break;
      }else if(s[m]<t[j]){
	l=m+1;
      }else{
	r=m;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 2324
n,m = [int(x) for x in input().split()]
f = set()
t = set()
ans = False
for i in range(m):
  a,b = [int(x) for x in input().split()]
  if a == 1:
    f.add(b)
  if b == n:
    t.add(a)
for i in f:
  if i in t:
    ans = True
    break
if ans:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 19012
import math
pi = math.pi

a, b, h, m = map(int, input().split())

hm = h*60 + m
hdr = pi * (90 - hm * 0.5) / 180

x1 = a * math.cos(hdr)
y1 = a * math.sin(hdr)

mdr = pi * (90 - m * 6) / 180

x2 = b * math.cos(mdr)
y2 = b * math.sin(mdr)

print(math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)))

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

int n,a;

int main() {
  cin >> n; 
  map<int,int> mp;
  rep(i,n){
  cin >> a;
  mp[a-1]++, mp[a]++, mp[a+1]++;
  }
  int ans=-1;
  for(auto m : mp)
  ans=max(m.second,ans);
  cout << ans << endl;
}

Measured memory_bytes: 4736
/* /\ In The Name of ALLAH /\
    Author : Jawahiir Nabhan */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 2e5 + 10;

int vis[MX],p[MX],res;
void init(int n){
    for(int i=0;i<=n;i++) p[i] = i,vis[i] = 1;
}
int findnemo(int r){
    if(p[r] == r) return r;
    return p[r] = findnemo(p[r]);
}
void unite(int u,int v){
    int x = findnemo(u);
    int y = findnemo(v);
    if(x != y){
        p[y] = x;
        vis[x] += vis[y];
    }
}
int main()
{
    int n,m; cin>>n>>m;
    res = 0;
    init(n);
    for(int i = 0;i < m;i++)
    {
        int x,y; cin>>x>>y;
        unite(x , y);
    }
    cout<<*max_element(vis + 1, vis + 1 + n)<<endl;
}


Measured memory_bytes: 5168
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N,M;cin>>N>>M;


    cout<<(N-1)*(M-1)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll x,ll y){
    ll r;
    while((r=x%y) !=0){
        x=y;
        y=r;
    }
    return y;
}

ll lcm(ll x, ll y){
    x /= gcd(x,y);
    y /=gcd(x,y);
    return (x*y);
}

int main(){
    ll n,cnt=0;
    str s;
    cin >> n >> s;
    rep(i,n-2){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
	int A,B,M;
	cin >>A>>B>>M;
	int s=200000,t=200000;
	vector<int> p(A+1),q(B+1);
	for(int i=1;i<=A;i++){
		cin >>p[i];
		s=min(s,p[i]);
	}
	for(int i=1;i<=B;i++){
		cin >>q.at(i);
		t=min(t,q[i]);
	}
	int c=200000;
	int x,y,r;
	for(int i=1;i<=M;i++){
		cin >>x>>y>>r;
		c=min(c,p[x]+q[y]-r);
	}
	cout <<min(c,s+t);
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sw swap
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
 float n,a,b,c;
 vector<float> gu;
 cin >> n;
 rep(i,n)	{
 	cin >> a;
 	gu.pb(a);
 }
 SORT(gu);
 REVE(gu);
 rep(i,n-1){
 a=(gu[n-i-1]+gu[n-2-i])/2;
 gu.pob();
 gu.pob();
 gu.pb(a);
 	
 }
 cout <<gu[0];
 return 0;
  }

Measured memory_bytes: 256
N = int(input())
S = input()


A = ["SS", "SW", "WS", "WW"]

for j in range(4) :
    t = A[j]
    for i in range(1,N) :
        if S[i] == "o" :
            if t[i] == "S" :
                if t[i-1] == "S" :
                    t += "S"
                else :
                    t += "W"
            else :
                if t[i-1] == "S" :
                    t += "W"
                else :
                    t += "S"
        else :
            if t[i] == "S" :
                if t[i-1] == "S" :
                    t += "W"
                else :
                    t += "S"
            else :
                if t[i-1] == "S" :
                    t += "S"
                else :
                    t += "W"
    
    if t[0] == t[-1] :
        if S[0] == "o" and t[0] == "S" and (t[-2] == t[1]) :
            print(t[:-1])
            break
        elif S[0] == "o" and (t[0] == "W") and (t[-2] != t[1]) :
            print(t[:-1])
            break
        if S[0] == "x" and t[0] == "S" and (t[-2] != t[1]) :
            print(t[:-1])
            break
        elif S[0] == "x" and (t[0] == "W") and (t[-2] == t[1]) :
            print(t[:-1])
            break
else :
    print(-1)


Measured memory_bytes: 3700
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MN 40005
#define inf 0x3f3f3f3f
using namespace std;
int n,m,num=1,head[MN],lev[MN],iter[MN],S,T,que[MN];char mp[205][205];
struct edge{int to,next,w;}g[MN<<1];
void ins(int u,int v,int w){g[++num].next=head[u];head[u]=num;g[num].to=v,g[num].w=w;}
void insw(int u,int v,int w){ins(u,v,w);ins(v,u,w);} 
bool bfs(){
	memset(lev,0,sizeof(lev));memcpy(iter,head,sizeof(head));
	int h=1,t=1;que[1]=S;lev[S]=1;
	while(h<=t){
		int tmp=que[h++];
		for(int i=head[tmp];i;i=g[i].next)if(!lev[g[i].to]&&g[i].w)lev[g[i].to]=lev[tmp]+1,que[++t]=g[i].to;
	}return lev[T]!=0;
}
int dfs(int u,int flow){
	if(u==T)return flow;int used=0;
	for(int &i=iter[u];i;i=g[i].next)if(lev[g[i].to]==lev[u]+1&&g[i].w){
		int qaq=dfs(g[i].to,min(flow-used,g[i].w));
		if(qaq){
			g[i].w-=qaq,g[i^1].w+=qaq,used+=qaq;
			if(used==flow)return flow;
		}
	}return used;
}
int dinic(){
	int tot=0,now;
	while(bfs())do now=dfs(S,inf),tot+=now;while(now);
	return tot;
}
int po(int x,int y){return (x-1)*m+y;}
int main(){
	scanf("%d%d",&n,&m);int sx,sy,tx,ty;S=0,T=n+m+1;
	for(int i=1;i<=n;i++){
		scanf("%s",mp[i]+1);
		for(int j=1;j<=m;j++)
			if(mp[i][j]=='o')insw(i,j+n,1);
			else if(mp[i][j]=='S')sx=i,sy=j,insw(S,i,inf),insw(S,j+n,inf);
		 	else if(mp[i][j]=='T')tx=i,ty=j,insw(i,T,inf),insw(j+n,T,inf);
	}printf("%d\n",(sx==tx||sy==ty)?-1:dinic());
}


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

int main() {
    int64 N; cin >> N;
    auto solve = [&]() -> int64 {
        N /= 2;
        int64 res = 0;
        while(N > 0) res += N / 5, N /= 5;
        return res;
    };
    cout << (N % 2 ? 0 : solve()) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int N ,d ;
    vector<int> b;
    cin >> N;
    for(int i=0; i<N; i++) {
        cin >> d;
        b.push_back(d);
    }

    vector<int> a;
    for(int j=N; j>0; j--) {
        for(int i=j-1; i>=0; i--) {
            if ((i+1) == b[i]) {
                a.push_back(b[i]);
                b.erase(b.begin() + i);
                break;
            }
        }
    }
    
    reverse(a.begin(), a.end());

    if (b.empty()) {
        for(vector<int>::iterator it = a.begin(); it != a.end(); it++) {
            cout << *(it) << endl;
        }
    } else {
        cout << -1 << endl;
    }
}

    


Measured memory_bytes: 256
h,l[26],t[26],r[26],b[26],x,y,c,s;char m[50][51];S(){s=1;for(y=t[c];y<=b[c];y++)for(x=l[c];x<=r[c];x++)if(m[y][x]&&m[y][x]-65-c)s=0;}main(n){for(scanf("%*d");~scanf("%d%*d",&h);puts(n?"SUSPICIOUS":"SAFE")){int e[26]={n=0};for(y=h;y--;)for(x=-scanf("%s",m[y]);c=m[y][++x];)c>64?e[c-=65]?x<l[c]?l[c]=x:0,x>r[c]?r[c]=x:0,y<t[c]?t[c]=y:0,y>b[c]?b[c]=y:0:(l[c]=r[c]=x,t[c]=b[c]=y,e[c]=++n):0;for(;n&&~c;)for(c=26;c--;)if(e[c]&&(S(),s)){for(y=t[c];y<=b[c];)bzero(m[y++]+l[c],r[c]-l[c]+1);e[c]=!n--;break;}}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)


int main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt	
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	 #endif

    FAST
	//PRECISE

ll n;
cin>>n;
ve <ll> v(n);
FOR(i,0,n)
cin>>v[i];
ll ans=0;
ll sum=0;
FOR(i,0,n){
	ans+=sum*v[i]%M;
	ans%=M;
	sum+=v[i];
	sum%=M;
}
cout<<ans;

return 0;
 }

Measured memory_bytes: 4780
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int N, T, c, t;
    cin >> N >> T;
    int ans = INT_MAX;
    for(int i = 0; i < N; i++) {
        cin >> c >> t;
        if (t <= T) {
            ans = min(ans, c);
        }
    }
    if (ans == INT_MAX)
        cout << "TLE" << endl;
    else
        cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256