akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
const int inf = 1e9;
string maxstr = string(500, 'z');

struct info{
	int pos;
	string str;
	info(int pos, string str):pos(pos),str(str){}
	info(){}
	bool operator<(const info &a) const{
		return (str.length()==a.str.length())? str>a.str: str.length()>a.str.length();
	}
};

int main(){
	while(1){
		int n,a,s,g;
		cin >> n >> a >> s >> g;
		if(n==0) break;
		
		vector<vector<pair<int, string> > > adj(n);
		for(int i=0; i<a; i++){
			int x,y;
			string lab;
			cin >> x >> y >> lab;
			adj[x].push_back(make_pair(y, lab));
		}
		
		priority_queue<info> wait;
		wait.push(info(s, ""));
		vector<vector<string> > minstr(n, vector<string>(6*2*n, maxstr));
		minstr[s][0] = "";
		while(!wait.empty()){
			int pos = wait.top().pos;
			string str = wait.top().str;
			int len = str.length();
			wait.pop();
			if(str > minstr[pos][len]) continue;
			
			for(int i=0; i<(int)adj[pos].size(); i++){
				int npos = adj[pos][i].first;
				string nstr = str +adj[pos][i].second;
				int nlen = nstr.length();
				if(nlen < 6*2*n && nstr < minstr[npos][nlen]){
					minstr[npos][nlen] = nstr;
					wait.push(info(npos, nstr));
				}
			}
		}
		
		string ansf = maxstr;
		for(int i=0; i<=(n-1)*6; i++){
			ansf = min(ansf, minstr[g][i]);
		}
		string anss = ansf;
		for(int i=(n-1)*6+1; i<6*2*n; i++){
			anss = min(anss, minstr[g][i]);
		}
		if(ansf != anss || ansf == maxstr){
			cout << "NO" << endl;
		}else{
			cout << ansf << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

const int INF = 1e9 + 5;
int main() {
	int n, k; cin >> n >> k;
	vi h(n);
	for (int i = 0; i < n; i++){
		cin >> h[i];
	}
	vi dp(n);
	for (int i = 1; i < n; i++){
		dp[i] = INF;
		for (int j = 1; j <= k; j++){
			if (i - j < 0) break;
			dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
		}
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <math.h>
#include <stdbool.h>


int ASC( void *a,  void *b) {
	return strcmp(*(const char **)a, *(const char **)b);//降順
}
int GCD(int a, int b) {	//最大公約数
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int min(int a, int b ) {
	if (a < b) {
		return a;
	}
	else
		return b;
}
int max(int a, int b) {
	if (a < b)
		return b;
	else
		return a;
}
int main(void)
{
	int d, t, s;
	scanf("%d%d%d",&d,&t,&s);
	int ans = t*s;
	if (ans >= d)
		printf("Yes");
	else
		printf("No");
	return 0;
}


Measured memory_bytes: 1732
#include<stdio.h>

int main(void)
{
	int n,i,count=1,kp;
  	scanf("%d",&n);
  	int a[n];
  	for(i=0;i<n;i++) scanf("%d",&a[i]);
  	kp = a[0];
  	for(i=1;i<n;i++) 
    {
    	if(kp<=a[i])
        {
			count++; 
            kp = a[i];
        }
    }
    printf("%d\n",count);
	return 0; 
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0){
				return;
			}		
			int[] max = new int[m];
			for(int i = 0;i < n;i++){
				int d = sc.nextInt()-1;
				int v = sc.nextInt();
				max[d] = Math.max(v,max[d]);
			}
			int ans = 0;
			for(int i = 0;i < m;i++){
				ans += max[i];	
			}
			System.out.println(ans);
		}
	}
}



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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-8
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;


int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    string s ;
    cin>> s ;
    int c=0 ;
    if(s.length()<4) cout<< "No" ;
    else
      {
        if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I') cout<< "Yes" ;
        else cout<< "No" ;
      }
  }


Measured memory_bytes: 256
s=sorted(input())
t=sorted(input(),reverse=True)
for i in range(min(len(s),len(t))):
    if s[i]<t[i]:
        print("Yes")
        break
    elif s[i]>t[i]:
        print("No")
        break
    else:
        if i==min(len(s),len(t))-1 and len(s)<len(t):
            print("Yes")
            break
        elif i==min(len(s),len(t))-1 and len(s)>=len(t):
            print("No")
            break

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





int main(){
  int N;
  cin>>N;
  int a[N+1];
  for(int i=0;i<N+1;i++){
    a[i]=0;
  }
  for(int i=2;i<N+1;i++){
    int x=i;
    for(int j=2;j<=i;j++){
      while(x%j==0){
        x/=j;
        a[j]++;
      }
      if(x==1){
        break;
      }
    }
  }
  
  
  int ans=0;
  
  for (int p = 0; p <N+1; ++p) {
        if (a[p] >= 74) ++ans;
    }

    
    for (int p = 0; p < N+1; ++p) {
        for (int q = 0; q < N+1; ++q) {
            if (p == q) continue;
            if (a[p] >= 4 && a[q] >= 14) ++ans;
            if (a[p] >= 2 && a[q] >= 24) ++ans;
        }
    }

    
    for (int p = 0; p < N+1; ++p) {
        for (int q = 0; q < N+1; ++q) {
            for (int r = q + 1; r < N+1; ++r) {
                if (p == q || r == p) continue;
                if (a[p] >= 2 && a[q] >= 4 && a[r] >= 4) ++ans;
            }
        }
    }
    cout<<ans<<endl;
  
  

  



}


  
  

  

  




Measured memory_bytes: 256
a[6]={2,3,5,10,12,15},b[6]={380,550,850,1520,1870,2244},m[51],T;
int s(n){int d=5;if(m[n]>9998)for(;~d;d--)if(a[d]<=n){T=s(n-a[d])+b[d];if(m[n]>T)m[n]=T;}return m[n];}
main(n){for(n=1;n<51;n++)m[n]=9999;for(;scanf("%d",&n),n;)printf("%d\n",s(n/100));exit(0);}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        int v;
        cin >> v;
        p[v - 1] = i;
    }
    int ans = 1;
    for (int l = 1, i = 0; i < N - 1; i++) {
        if (p[i] < p[i + 1]) {
            l++, ans = max(ans, l);
        } else {
            l = 1;
        }
    }
    cout << N - ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int n;
	cin>>n;
	if(n>=400 && n<=599) cout<<8;
	else if(n>=600 && n<=799) cout<<7;
	else if(n>=800 && n<=999) cout<<6;
	else if(n>=1000 && n<=1199) cout<<5;
	else if(n>=1200 && n<=1399) cout<<4;
	else if(n>=1400 && n<=1599) cout<<3;
	else if(n>=1600 && n<=1799) cout<<2;
	else cout<<1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main()
{
	int i;
	char buf[100001] = { 0 };
	char test[27] = { 0 };
	
	scanf("%s", buf);

	for (i = 0; buf[i]; i++) {
		test[buf[i] - 'a'] = 1;
	}

	for (i = 0; test[i]; i++);

	if (i == 26) {
		printf("None");
	} else {
		printf("%c", 'a' + i);
	}
	return 0;
}


Measured memory_bytes: 256
count=[]
A=[]
string=""
while True:
    string=input()
    if string=="-":
        for i in range(len(A)):
            print(A[i])
        break
    else:
        m=int(input())
        for i in range(m):
            h=int(input())
            count.append(h)
        for i in range(m):
            string=string[count[i]:]+string[0:count[i]]
        A.append(string)
        count=[]



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

long INF = 1L<<60;
void main() {
    int[] input = readln.split.to!(int[]);
    int D = input[0];
    int N = input[1];
    int[] T = new int[D];
    foreach(i; 0..D) T[i] = readln.chomp.to!int;
    int[] A = new int[N];
    int[] B = new int[N];
    int[] C = new int[N];
    foreach(i; 0..N) {
        input = readln.split.to!(int[]);
        A[i] = input[0];
        B[i] = input[1];
        C[i] = input[2];
    }
    sort!("a[2]<b[2]")(zip(A, B, C));

    long[][] dp = new long[][](D, N);
    foreach(i; 0..D) {
        dp[i][] = -INF;
        foreach(j; 0..N) {
            if (A[j]<=T[i] && T[i]<=B[j]) {
                if (i==0) {
                    dp[i][j] = 0;
                } else {
                    foreach(k; 0..N) {
                        dp[i][j] = max(dp[i][j], dp[i-1][k]+abs(C[k]-C[j]));
                    }
                }
                break;
            }
        }
        foreach_reverse(j; 0..N) {
            if (A[j]<=T[i] && T[i]<=B[j]) {
                if (i==0) {
                    dp[i][j] = 0;
                } else {
                    foreach(k; 0..N) {
                        dp[i][j] = max(dp[i][j], dp[i-1][k]+abs(C[k]-C[j]));
                    }
                }
                break;
            }
        }
    }
    dp.back.reduce!max.writeln;
}

Measured memory_bytes: 2896
///*****************************************************///
///*.......................Faiyaj Bin Amin............................*///
///*...................................................................*///
///*.........................KUET CSE 2K17......................*///
///*...................................................*///
///*****************************************************///

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define fastio      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define ret return
#define rep(q, i, n) for(int q=i; q<n; q++)
#define forn(i, n) for(int i=0; i<n; i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pdd pair<double, double>

#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define seecontent(v) for(auto x : v) { cout << x << " ";} cout << "\n\n";

#define PI 2*acos(0.0)
#define lcm(a, b)  ((a / __gcd(a, b) ) * b)

#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)

#define mx 100005
#define INF 1e18
#define MOD 1000000007
#define MIN 0

//template <typename T>  using orderedSet =
//    tree<T, null_type, less_equal<T>,
//    rb_tree_tag, tree_order_statistics_node_update>; //find_by_order, order_of_key


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0}; // Directional
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

/**------------------------------------BITMASK------------------------------------------**/
//int Change(int N, int pos){return N= N^(1<<pos);}
//bool Check(int N, int pos){return (bool)(N &(1<<pos));}  /// check bit 0 or 1
/**-----------------------------------------------------------------------------------------------**/

//using namespace __gnu_pbds;
using namespace std;

ll col[mx], cnt[mx], dist[mx];
vector< pair < int,int> > adj[mx];
bool vis[mx];

void dfs(int u)
{
    vis[u]=true;
    for(auto x:adj[u])
    {
        if(vis[x.ff]==false)
        {
            dist[x.ff]=dist[u]+x.ss;

            if(dist[x.ff]%2)
                col[x.ff]=1;
            else
                col[x.ff]=0;

            dfs(x.ff);
        }
    }
}

int main()
{
    fastio;
    int n,u,v,w;
    cin>>n;

    forn(i, n-1)
    {
        cin >> u>>v>>w;
        adj[u].pb({v,w});
        adj[v].pb({u,w});

        cnt[u]++;
        cnt[v]++;
    }

    int root;
    forn(i,n+1)
    {
        if(cnt[i]==1)
            root=i;
    }

    dfs(root);
    for(int i=1; i<=n; i++)
    {
        cout << col[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 16784
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int a = in.nextInt();
        int b = in.nextInt();
        if(a>12) out.println(b);
        else if(a>5) out.println(b/2);
        else out.println(0);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N;
  in(N);
  map<string, int> m;
  ll ans = 0;
  rep(i, 0, N) {
    string si;
    in(si);
    sort(all(si));
    ans += m[si]++;
  }
  print(ans);
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
 
//g++ -std=c++11
//g++ -std=c++1z 

using namespace std;

typedef long long ll;
const long long INF = 1e18+10;
#define PI 3.14159265

int main() {
 
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
 
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s1,s2;

    cin >> s1 >> s2;

    bool sepuede = true;
    for (int i=0; i<min(s1.size(), s2.size()); i++) {
        if(s1[i] != s2[i])
            sepuede = false;
    }

    if(sepuede)
        cout << "Yes\n";
    else
        cout << "No\n";    
    return 0;
}


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

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& vec) {
    out << "[";
    for (int x : vec) out << x << ", ";
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
    #define dbg_var(x) cerr << #x << ": " << x << endl;
#endif


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    LL a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k % 2 == 0) cout <<  a-b << '\n';
    else cout << b-a << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
using namespace std;

ll a[114514];
void in(ll num) {
  cout << num << endl;
  string h;
  cin >> h;
  if (h == "Male") {
    a[num] = 1;
  } else if (h == "Female") {
    a[num] = 2;
  } else {
    a[num] = 0;
  }
}
int main() {
  ll n;
  cin >> n;
  ll ok = 0, ng = n;
  in(0);
  ll c = a[0];
  while (ng - ok > 3) {
    ll m = (ng + ok) / 2;
    c = a[ok];
    in(m);
    if (a[m] == 0) {
      return 0;
    }
    if (c == a[m] && (m - ok) % 2 == 0) {
      ok = m;
    } else if (c != a[m] && (m - ok) % 2) {
      ok = m;
    } else {
      ng = m;
    }
  }
  cout << ok + 1 << endl;
  cout << ok + 2 << endl;
}


Measured memory_bytes: 852
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	cin >> n;
	cin.get();

	while(n--)
	{
		string str;

		getline(cin, str);

		REP(i, 6, str.size())
			if(str.substr(i - 6, 7) == "Hoshino")
				str[i] = 'a';

		cout << str << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
    string wea[3] = {"Sunny", "Cloudy", "Rainy"};
    string input;
    cin >> input;
    for(int i =0 ;i<3 ;i++){
        if(input == wea[i]){
                if(i==2){
                    cout << wea[0];
                    break;
                }
            cout << wea[i+1];
            break;
        }
}

    return 0;
}


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

#define MAX 1000001

int main(){
  bool p[MAX];
  memset(p, 1, sizeof(p));
  p[1] = p[0] = 0;
  for(int i = 0 ; i < MAX ; i++){
    if(p[i]){
      for(int j = 2 * i ; j < MAX ; j += i){
	p[j] = 0;
      }
    }
  }

  int n, sum;
  while(cin >> n, n){
    int cnt = 0;
    for(int i = 0 ; i <= n/2 ; i++){
      if(p[i] == 1 && p[n - i] == 1) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 0
N,H = [int(i) for i in input().split()]
a_max = 0
b = []
for i in range(N):
    a_,b_ = [int(i) for i in input().split()]
    if a_max < a_:
        a_max = a_
    b.append(b_)

b.sort()
b  = b[::-1]
ans  = 0 
i=0
while True:
    if a_max > b[i]:
        break
    H -= b[i]
    i +=1
    ans +=1
    if H <=0 or i>=N:
        break

#print(b)
#print(ans,H,i,a_max)
if H >0:
    if H % a_max==0:
        ans += H//a_max
    else:
        ans += H//a_max +1

print(ans)


Measured memory_bytes: 7832
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;

int main(void) {
  int n;
  cin >> n;
  int ans[4] = {0, 0, 0, 0};
  rep(i, n) {
    string s;
    cin >> s;
    if (s == "AC") ans[0]++;
    if (s == "WA") ans[1]++;
    if (s == "TLE") ans[2]++;
    if (s == "RE") ans[3]++;
  }
  cout << "AC x " << ans[0] << endl;
  cout << "WA x " << ans[1] << endl;
  cout << "TLE x " << ans[2] << endl;
  cout << "RE x " << ans[3] << endl;
  return 0;
}

Measured memory_bytes: 3624
package main

import (
    "fmt"
)

func main() {
    var s string
    var ans string
    fmt.Scan(&s)
    for _, c := range s {
        if c == 'B' && len(ans) > 0 {
            ans = ans[:len(ans)-1]
        } else if c == '0' || c == '1' {
            ans += string(c)
        }
    }
    fmt.Println(ans)
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    abc085B(args)
    //abc088B(args)
    //abc105B(args)
    //abc087B(args)
    //abc081B(args)
    //abc095(args)
    //abc086(args)
    //tutorial(args)
}

fun abc085B(args: Array<String>) {
    val N = readLine()!!.toInt()
    val di = listOf<Int>().toMutableList()
    for (i in 0 until N) {
        di.add(readLine()!!.toInt())
    }

    println(di.toMutableSet().size)
}


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

int main()
{
  int n;
  cin >> n;
  
  int a[n+1];
  for(int i = 1; i <= n; i++) cin >> a[i];
  
  int i = 1, j = 1;
  int ans = 1;
  while(i <= n){
    if(a[j] == 2){
      cout << ans << endl;
      return 0;
    }
    j = a[j];
    i++;
    ans++;
  }//while
  
  cout << -1 << endl;
}


Measured memory_bytes: 4028
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <cmath>

using namespace std;
typedef uint uint32_t;

int A[100002];

int main() {
    uint N;
    cin >> N;
    int sum = 0, pre = 0, i;
    for (i = 0; i < N; i++) {
        cin >> A[i];
        sum += abs(A[i] - pre);
        pre = A[i];
    }
    A[i] = 0;
    sum += abs(A[i] - A[i-1]);
    // cout << i << endl;
    // for (int i = 0; i < N + 1; i++) {
    //     cout << "A[" << i << ']' <<  A[i] << endl;
    // }
    // cout << sum << endl;
    pre = 0;
    for (i = 0; i < N; i++) {
        cout << sum + abs(A[i+1] - pre) - abs(A[i] - pre) - abs(A[i+1] - A[i]) << endl;
        pre = A[i];
    }
    // cin >> x;
    // cout << x * x * x << endl;
    // scanf("%u %u", &x, &y);
}


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

int main(){
  int x, y; cin >> x >> y;
  int group[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  cout << (group[x] == group[y] ? "Yes" : "No") << endl;
}

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

int main() {
  long long N;
  cin >> N;

  vector<long long> a(N);
  for (long long i = 0; i < N; i++) {
    cin >> a[i];
  }

  long long sum = 0;
  bool f = true;
  while (f) {
    f = false;

    for (long long i = 0; i < N; i++) {
      long long k = a[i] / N;
      if (k == 0) {
	continue;
      }

      a[i] -= k * N;
      sum += k;
      f = true;

      for (long long j = 0; j < N; j++) {
	if (j == i) {
	  continue;
	}

	a[j] += k;
      }
    }
  }

  cout << sum << endl;

  return 0;
}


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

int main(){
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int price = 0;
	price += min(a+b, 2*c)*min(x, y);

	if (x >= y) {
		price += min(a, 2*c)*(x-y);
	} else {
		price += min(b, 2*c)*(y-x);
	}

	cout << price << endl;
}


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

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

Measured memory_bytes: 256
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0) return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p; }
#define flush fflush(stdout)
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

int main()
{
    IOS;//ifstream fin("input.txt");ofstream fout("output.txt");
    string s,t;
    cin>>s>>t;
    int n=s.length(),m=t.length();
    int dp[n+1][m+1];
    for(int i=0;i<=m;i++)
        dp[0][i]=0;
    for(int i=0;i<=n;i++)
        dp[i][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    int i=n,j=m;string s1="";
    while(i>0&&j>0)
    {
        if(s[i-1]==t[j-1])
        {
            s1=s[i-1]+s1;
            i--;j--;
        }
        else
        {
            if(dp[i][j]==dp[i-1][j])
            {
                i--;
            }
            else
                j--;
        }
    }
    cout<<s1<<endl;
    return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#define MAXV 1000003
#define LENGTH 14
#include <string.h>
#include <stdio.h>
#define M  1000003
char A[MAXV][LENGTH];

using namespace std;

int getKey(char x)
{
    if(x=='A')
        return 1;
    else if(x=='C')
        return 2;
    else if(x=='G')
        return 3;
    else if(x=='T')
        return 4;
    else return 0;
}
int h1(int key){
    return key % M;
}
int h2(int key){
    return 1 + key%(M-1);
}
long long h(int i,int key){
    return (h1(key)+i*h2(key))%M;
}
long long getChar(char str[]){
    long long num = 0,p = 1,i;
    for(i = 0;i < strlen(str);i++)
    {
        num += p*(getKey(str[i]));
        p *= 4;
    }
    return num;
}
int Insert(char str[])
{
    long long j,i = 0;
    long long key = getChar(str);
    while(1)
    {
        j = h(i,key);
        if(strlen(A[j])==0)
        {
            strcpy(A[j],str);
            return 1;
        }
        else
            i++;
    }
}
int findKey(char str[])
{
    long long j,i = 0;
    long long key = getChar(str);
    while(1)
    {
        j = h(i,key);
        if(strlen(A[j])==0)return 0;
        else if(strcmp(A[j],str)==0)
            return 1;
        else
            i++;
    }
}
int main()
{
    char com[12],s[14];
    int n;
    scanf("%d",&n);
    for (int i = 0; i < MAXV; i++ ) A[i][0]='\0';
    for(int i = 0;i < n;i++)
    {
        scanf("%s %s",com,s);
        if(com[0]=='i')
        {
            Insert(s);
        }
        else if(com[0]=='f')
        {
            if(findKey(s))
                printf("yes\n");
            else
                printf("no\n");
        }
    }
}



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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 105;
int ara[N];
int main()
{
    int n;
    cin >> n;
    REP(i,n)cin >> ara[i];
    sort(ara,ara + n);

    double s = ara[0];
    for(int i = 1;i < n;i++){
        s = (s + ara[i])/2;
    }
    cout << fixed << setprecision(9) << s << "\n";


}



Measured memory_bytes: 256
/*input
ABA

*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> vii;
#define pb push_back
#define print(a) for(auto x:a){cout<<x<<' ';}cout<<endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve(){
    string s;cin>>s;
    sort(s.begin(), s.end());
    if(s[0]=='A' && s[2]=='B')
        cout<<"Yes\n";
    else
        cout<<"No\n";
    
}

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

Measured memory_bytes: 256
/*
 * DATE : 2017-07-07
 * Algo :
*/
#include<bits/stdc++.h>
using namespace std;
/*------- Constants---- */

#define LL                      long long
#define Ulong                   unsigned long long
#define FOR(I,A,B)              for(long long i=0; i < n ; i++ )
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-9
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
    register char c = getchar();x = 0;
    int neg = 0;
    for(; ((c<48 || c>57) && c != '-'); c = getchar());
    if(c=='-'){neg = 1;c = getchar();}
    for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
    long long ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 1e5+5;

int lev[N];
vector<int> G[N];
int P[N];
int sub[N];
void dfs(int u,int p)
{
    sub[u] = 1;
    for(auto x: G[u]) if(x != p ) {
        lev[x] = 1 + lev[u];
        dfs(x,u);
        P[x] = u;
        sub[u] += sub[x];
    }

}
int main()
{
    int n,u,v;
    cin >> n;
    for(int i = 1;i <= n - 1; i ++ ) {
        cin >> u  >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    lev[1] = 0;
    dfs(1,-1);
    int st = n;
    vector<int> vec;
    while(st != 1) {
        vec.push_back(st);
        st = P[st];
    }
    vec.push_back(st);

    reverse(all(vec));
    int now = n;
    int j = vec.size() - 1;
    for(int i = 0; i < j - 1; ) {
        i ++;
        if(i + 1 < j ) j --, now = vec[j];
    }
    long long x = sub[now];
    long long y = n - sub[now];
    if(x < y) printf("Fennec\n");
    else printf("Snuke\n");
    return 0;
}


Measured memory_bytes: 13820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

typedef pair<int, int> P;
ll modnum = 1e9+7;



int main() {
    int n,k; cin >> n >> k;
    // スターグラフが最短距離=2の数が最大になるグラフ
    // この数は1からN-1までの和
    // 1から最短経路2の頂点は2,3,4...N-1
    // 2から最短経路2の頂点は3,4...N-1
    // 3からは4,5..
    // N-2からはN-1
    int maximum = (n-1)*(n-2)/2;
    // スターグラフでKより少ない場合は作れないので-1を出力
    if(maximum < k) cout << -1 << endl;
    else {
        vector<P> res;
        // スターグラフの構築, Nに対して1..N-1を結び
        for(int i=1; i < n; i++) res.emplace_back(i, n);

        // 例えば1と2を結ぶ線を繋ぐと、もともとは1-N-2の最短経路=2が潰されるので
        // 最短経路=2の数を1つだけ減らせる
        int rem = maximum - k;
        int ci = 1, cj = 2;
        for(int i=0; i < rem; i++) {
            res.emplace_back(ci, cj);
            cj++;
            // とりあえず, 1に対して2,3,4,...N-1を結んでいく
            // 全て達したら、2に対して3,4...N-1
            // それも達したら3に対して4,5...N-1
            // という感じで埋めれる
            if(cj == n) {
                ci++;
                cj = ci + 1;
            }
        }
        cout << res.size() << endl;
        for(auto p : res) cout << p.first << " " << p.second << endl;
    }
    return 0;
}


Measured memory_bytes: 384
Mod = 10**9+7
n = [0,0]
n[0],n[1] = map(int,input().split())
a = [0,0]
for j in range(2):
  x = list(map(int,input().split()))
  s = 0
  for i in range(n[j]):
    s = (s+x[i]*(2*i+1-n[j]))%Mod
  a[j] = s
print((a[0]*a[1])%Mod)

Measured memory_bytes: 18624
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_owned()
}

mod segtree {
    pub struct SegTree<T, F: Fn(T, T) -> T> {
        vec: Vec<T>,
        num_leaf: usize,
        fnc: F,
        id: T,
    }

    impl<T: Clone, F: Fn(T, T) -> T> SegTree<T, F> {
        pub fn new(n: usize, fnc: F, id: T) -> Self {
            let b_num = std::mem::size_of::<usize>() * 8;
            let lz = n.leading_zeros();
            let tz = n.trailing_zeros();

            let num_leaf = if lz + tz + 1 == b_num as u32 {
                n
            } else {
                1usize << (b_num - lz as usize)
            };
            let vec_size = (num_leaf << 1) - 1;

            Self {
                id: id.clone(),
                vec: vec![id; vec_size],
                num_leaf: num_leaf,
                fnc: fnc,
            }
        }

        pub fn update(&mut self, i: usize, val: T) {
            let mut idx = i + self.num_leaf - 1;
            self.vec[idx] = val;
            while idx > 0 {
                idx = (idx - 1) / 2;
                self.vec[idx] = (self.fnc)(
                    self.vec[idx*2+1].clone(),
                    self.vec[idx*2+2].clone()
                );
            }
        }

        pub fn query(&self, a: usize, b: usize) -> T {
            self.query_sub(a, b, 0, 0, self.num_leaf)
        }

        /// [a, b) の区間に対するクエリについて
        /// ノードk: 区間[l, r) 相当 が答える
        fn query_sub(&self, a: usize, b: usize, k: usize, l: usize, r: usize) -> T {
            if r <= a || b <= l {
                self.id.clone()
            } else if a <= l && r <= b {
                self.vec[k].clone()
            } else {
                let c1 = self.query_sub(a, b, 2*k+1, l, (l+r)/2);
                let c2 = self.query_sub(a, b, 2*k+2, (l+r)/2, r);
                (self.fnc)(c1, c2)
            }
        }
    }
}

use segtree::SegTree;

fn gcd(mut a: usize, mut b: usize) -> usize {
    std::mem::swap(&mut a, &mut b);
    while b != 0 {
        let r = a%b;
        a = b;
        b = r;
    }
    a
}

fn main() {
    let n = read!(usize);
    let a = read!([usize]);

    let mut st = SegTree::new(n, gcd, 0);
    for i in 0..n {
        st.update(i, a[i]);
    }
    let mut max = 0;
    for i in 0..=n {
        let tmp = gcd(st.query(0, i), st.query(i+1, n));
        if tmp > max {
            max = tmp;
        }
    }
    println!("{}", max);
}


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

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	int e = b - a;
	string ans;
	if (e <= 0) {
		ans = "delicious";
	} else if (e <= x) {
		ans = "safe";
	} else {
		ans = "dangerous";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;

struct Time {
  int hour;
  int min;
  bool operator<(const Time& t) const;
  bool operator==(const Time& t) const;
};

bool Time::operator<(const Time& t ) const {
  if( this->hour != t.hour ) {
    return this->hour < t.hour;
  }
  return this->min < t.min;
}

bool Time::operator==(const Time& t ) const {
  return this->hour == t.hour && this->min == t.min;
}

int main() {
  int n, m;
  vector<Time> v;
  cin >> n;
  for( int i = 0; i < n; i++ ) {
    int hi, mi;
    cin >> hi >> mi;
    Time a;
    a.hour = hi;
    a.min = mi;
    v.push_back( a );
  }

  cin >> m;

  for( int i = 0; i < m; i++ ) {
    int hi, mi;
    cin >> hi >> mi;
    Time a;
    a.hour = hi;
    a.min = mi;
    v.push_back( a );
  }

  sort( v.begin(), v.end() );

  int len = v.size();
  int iout = 0;
  Time prev;
  prev.hour = -9999;
  prev.min = -9999;
  for( Time &t: v ) {
    if( prev == t ) {
      continue;
    }
    if( iout != 0 ) {
      cout << " " << flush;
    }
    cout << t.hour << ":" << flush;
    if( t.min < 10 ) {
      cout << "0" << flush;
    }
    cout << t.min << flush;
    iout++;
    prev = t;
  }
  cout << endl;

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1220
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,c] <- getIntList
    st <- replicateM n $ do
        [s,t,c] <- getIntList
        return (c,(s-1,t))
    let st' = f $ sort st
            where f [] = []
                  f (x:[]) = (x:[])
                  f ((c1,(s1,t1)) : (c2,(s2,t2)) : xs)
                      | c1 == c2 && t1 == s2+1 = f ((c1,(s1,t2)) : xs)
                      | otherwise = (c1,(s1,t1)) : f ((c2,(s2,t2)) : xs)
    let result = VU.create $ do
            vec <- VUM.replicate 100002 (0 :: Int)
            forM_ st' $ \(_,(s,t)) -> do
                VUM.modify vec succ s
                VUM.modify vec pred t
            return vec
    let ans = VU.maximum $ VU.scanl (+) 0 result
    print ans

Measured memory_bytes: 79756
#include <stdio.h>
#define R_MAX 20
int m[R_MAX*4+1];
int main(){
	int r,n,x1,x2,h;
	for(;scanf("%d%d",&r,&n),r;memset(m,0,sizeof(m))){
		int left=0,right=0;
		for(;n;n--){
			scanf("%d%d%d",&x1,&x2,&h);x1=2*x1+2*R_MAX;x2=2*x2+2*R_MAX;
			for(;x1<=x2;x1++)if(m[x1]<h)m[x1]=h;
		}
		//for(x1=-2*r-1;x1<=2*r+1;x1++)printf("%d %d\n",x1,m[x1+2*R_MAX]);
		//0〜2*rなるxに対する、p(x,m[x+r])との距離がrとなる、x=r上の点
		double ret=-1;
		for(x1=0;x1<=2*r;x1++){
			int x=x1-r;
			int d=x>0?x:-x;
			double y=-sqrt(r*r-d*d);
			//入出力は通っているので一安心なのですが、この辺結構怪しいです
			if(x==0){
				if(ret<0||ret>y+r+m[2*R_MAX-1])ret=y+r+m[2*R_MAX-1];
				if(ret<0||ret>y+r+m[2*R_MAX+1])ret=y+r+m[2*R_MAX+1];
			}else{
				int add=x1==0||x1==2*r?0:x/d;
				if(ret<0||ret>y+r+m[2*R_MAX+2*x+add])ret=y+r+m[2*R_MAX+2*x+add];
			}
		}
		printf("%.4f\n",ret);
	}
	return 0;
}

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

int main(){
  int N; cin >> N;
  vi L(N);
  rep(i,N) cin >> L[i];
  sort(L.begin(), L.end(), greater<int>());
  int ans = 0;
  for (int i=0; i<N-2; i++){
    for (int j=i+1; j<N-1; j++){
      if (L[j] < L[i] / 2) break;
      for (int k=j+1; k<N; k++){
        if (L[i] < L[j] + L[k]){
          ans += 1;
        }
        else break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef long double ld;
int n;
double a[55];
priority_queue <double,vector<double>,greater<double> > q;

int main(){
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=1;i<=n;++i)q.push(a[i]);
	while(q.size()>1){
		double u=q.top();q.pop();
		double v=q.top();q.pop();
		q.push((u+v)/2.0);
	}
	printf("%.12lf\n",q.top());
	return 0;
}

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

long long merge(int v[], int l, int m, int r) {
    auto n1 = m - l;
    auto n2 = r - m;
    long long ret = 0;
    vector<int> L(n1 + 1), R(n2 + 1);
    for (int i = 0; i < n1; i++) L[i] = v[l + i];
    for (int i = 0; i < n2; i++) R[i] = v[m + i];
    L[n1] = INT_MAX;
    R[n2] = INT_MAX;
    
    int i = 0;
    int j = 0;
    for (int k = l; k < r; k++) {
        if (L[i] <= R[j]) { v[k] = L[i++]; }
        else { v[k] = R[j++]; ret += n1 - i; } 
    }
    return ret;
}

long long merge_sort(int v[], int l, int r) {
    if (l + 1 < r) {
        auto m = (l + r) / 2;
        return merge_sort(v, l, m) + 
            merge_sort(v, m, r) +
            merge(v, l, m, r);
    }
    return 0;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, x;
    cin >> n;
    int v[600000];
    for (int i = 0; i < n; i++) { cin >> v[i]; }
    cout <<  merge_sort(v, 0, n) << endl;
    return 0;
}


Measured memory_bytes: 4428
class UnionFind:
    def __init__(self, n):
        self.n = n
        # 各要素の親要素の番号を格納するリスト
        # 要素が根（ルート）の場合は-(そのグループの要素数)を格納する
        self.parents = [-1] * n

    def find(self, x):
        """要素xが属するグループの根を返す
        """
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        """要素xが属するグループと要素yが属するグループをくっつける
        """
        x = self.find(x)
        y = self.find(y)
        # すでにくっつてるのでそのまま返す
        if x == y:
            return
        # 大きい方(x)に小さい方(y)をくっつけたいので、
        # 大小が逆なら入れ替える
        if self.size(x) < self.size(y):
            x, y = y, x
        # xのサイズを更新する
        self.parents[x] += self.parents[y]
        # yの親をxに変更する
        self.parents[y] = x

    def size(self, x):
        """要素xが属するグループのサイズ（要素数）を返す
        """
        return -self.parents[self.find(x)]


N, M = map(int, input().split())
AB = []
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    AB.append((a, b))
AB.reverse()

# すべて崩落した状態
ans = [N*(N-1)//2]

uf = UnionFind(N)
# 後ろから1本ずつ繋げていく
# ただし最後の1本を繋げるのは不要（初期状態は出力しないから）
for i in range(M-1):
    a, b = AB[i]
    inconvenience = ans[-1]
    if uf.find(a) != uf.find(b):
        # 繋がることで不便さが解消される
        inconvenience -= uf.size(a) * uf.size(b)
        uf.union(a, b)
    ans.append(inconvenience)

# 出力は崩落した順
ans.reverse()
for a in ans:
    print(a)


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std ;
int main(){
    int X;
    cin >> X;
    int A=0;
    int Ans;
    for(int i=1;i<=360;i++){
        A = A+X;
        A = A%360;
        if(A==0){
            Ans = i;
            break;
        }
    } 
    cout << Ans  << endl;  
 }

Measured memory_bytes: 3600