akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static BufferedReader reader;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		String[] t = readLine();
		char[] s = t[0].toCharArray();
		int cnt = 0;
		for(int i=0;i<s.length/2;i++) {
			if(s[i]!=s[s.length-1-i]) {cnt++;}
		}
		
		//String[] s = readLine();
		print(cnt);
	}
	
	//functions here
	//note that all methods should be STATIC
	private static double getDistance(int[] p1,int[] p2) {
		double s = 0;
		for(int i=0;i<p1.length;i++) {
			s+=(p1[i]-p2[i])*(p1[i]-p2[i]);
		}
		return Math.sqrt(s);
	}
	
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vi vector<int>


ll gcd(ll x, ll y){
  ll smaller=min(x,y);
  ll bigger=max(x,y);
  
  if (bigger%smaller==0){
    return smaller;
  }
  else {
    return gcd(smaller,bigger%smaller);
  }
}






int main(){


  ll k;
  cin>>k;
  
  ll sum=0;
  
  rep2(a,1,k+1){
    rep2(b,1,k+1){
      rep2(c,1,k+1){
        sum+=gcd(a,gcd(b,c));
      }
    }
  }
  
  cout<<sum<<endl;
  
}





Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
inline int xmod(int a, int b) {
    int ret = a % b;
    return (ret >= 0) ? ret : ret + b;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    int len=1000050;
    vector<int> li(len);
    int fi=0, la=0;

    string op;
    int key;
    for (int i=0; i<n; ++i) {
        cin >> op;
        if (op == "insert") {
            cin >> key;
            fi = xmod(fi-1, len);
            li[fi] = key;
            continue;
        } else if (op == "deleteFirst") {
            while (li[fi] == -1) fi = (fi+1) % len;
            fi = (fi+1) % len;
        } else if (op == "deleteLast") {
            while (li[xmod(la-1, len)] == -1) la = xmod(la-1, len);
            la = xmod(la-1, len);
        } else if (op == "delete"){
            cin >> key;
            for (int j=fi; j!=la; j=(j+1)%len) {
                if (li[j] == key) {
                    li[j] = -1;
                    break;
                }
            }
        }
    }

    bool nospace = true;
    for (int i=fi; i!=la; i=(i+1)%len) {
        if (li[i] == -1) continue;
        if (nospace) {
            cout << li[i];
            nospace = false;
        } else {
            cout << " " << li[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4900
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int cnt[5];

string s;

int main(){

  s = stin();
  YYS( c , s ){
    cnt[c-'a']++;
  }

  sort(cnt, cnt+3);

  if( cnt[2] - cnt[0] <= 1 ){
    puts( "YES" );
  } else {
    puts( "NO" );
  }
  
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "0\n"; return;}
#define mkp make_pair

const int N = 2e5 + 7;

map <int, int> calc;
int a[N];

void solve() {
    int n; cin >> n;
    loop(i, n)
        cin >> a[i];
    int ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        ans += calc[a[i] + i];
        ++calc[i - a[i]];
    }
    cout << ans;
}

signed main() {
    srand(time(NULL));
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 27784
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val S = readLine()!!

    var answer = 0L

    var prev = ' '

    for (i in 0 until N) {
        val c = S[i]
        if (c != prev) {
            answer++
        }
        prev = c
    }



    println(answer)
}

Measured memory_bytes: 33944
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n,w;
	cin >> n >> w;
	vector<pair<ll,ll> > v;
	ll l=0;
	for(int i=0;i<n;i++)
	{
		ll x,y;
		cin >> x >> y;
		l+= y;
		v.push_back(make_pair(x,y));
	}
	//wt profit
	vector<ll> dp(l+1,INT_MAX);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=l;j>=0;--j)
		{
			if(j-v[i].second >=0)
			dp[j]= min(dp[j],v[i].first+dp[j-v[i].second]);
		}
	}
	int ans=0;
	for(int i=0;i<=l;i++)
	{
		if(dp[i]<=w)
		ans= i ;
	}
	cout <<ans;
	return 0;
	}


Measured memory_bytes: 1024
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>
#include<set>
#include<map>
#include<cmath>
using namespace std;
const int maxn=2e5+10;
typedef long long LL;
const LL mod=1e9+7;
const double pi=acos(-1.0);
LL n,m;
LL a[10005];
int main()
{
    LL sum=0;
    scanf("%lld%lld",&n,&m);
    for(LL i=1;i<=m;i++){
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    if(sum>n){
        printf("-1\n");
    }
    else{
        printf("%lld\n",n-sum);
    }
    return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    
    int n;
    cin >> n;
    
    map<string, int> money;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        money[s]++;
    }
    
    int m;
    cin >> m;
    for(int i = 0; i < m; i++){
        string s;
        cin >> s;
        money[s]--;
    }
    
    int ans = 0;
    for(auto p : money) ans = max(ans, p.second);
    cout << ans << endl;
    
}


Measured memory_bytes: 256
import math
class Dot:
    x=0.0
    y=0.0
    def __init__(self,x,y):
        self.x=x
        self.y=y
    def __lt__(self,other):
        return self.x < other.x
    def print(self):
        x=self.x
        y=self.y
        print("{:.8f} {:.8f}".format(x,y))       
def kock(n,a,b,dots):
    if n == 0:
        return
    s=Dot((2*a.x+b.x)/3,(2*a.y+b.y)/3)
    t=Dot((a.x+2*b.x)/3,(a.y+2*b.y)/3)
    rad=math.radians(60)
    x=(t.x-s.x)*math.cos(rad)-(t.y-s.y)*math.sin(rad)+s.x
    y=(t.x-s.x)*math.sin(rad)+(t.y-s.y)*math.cos(rad)+s.y
    u=Dot(x,y)

    kock(n-1,a,s,dots)
    s.print()
    dots.append(s)
    kock(n-1,s,u,dots)
    u.print()
    dots.append(u)
    kock(n-1,u,t,dots)
    t.print()
    dots.append(t)
    kock(n-1,t,b,dots)

if __name__ == "__main__":
    n=int(input())
    dots=[]
    dot1=Dot(0,0)
    dot2=Dot(100,0)
    dots.append(dot1)
    dots.append(dot2)
    dot1.print()
    kock(n,dot1,dot2,dots)
    dot2.print()


Measured memory_bytes: 6524
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
typedef long long lint;
const int N=1e5+5;
int n,m;
lint st[N],cnt[N],add_p[N];

template <class T> inline T nxi(){
	T x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

int main(){
#ifndef ONLINE_JUDGE
//	freopen("a.in","r",stdin);
#endif
	n=nxi<int>(),m=nxi<int>();
	int pt=1;
	st[1]=n;
	for(int i=1;i<=m;++i){
		const lint x=nxi<lint>();
		while(pt&&st[pt]>=x) --pt;
		st[++pt]=x;
	}
	m=pt;
	cnt[m]=1;
	st[m+1]=(lint)2e18;//This one
	for(int i=m;i>1;--i){
		lint cur=st[i];
		for(int tp=i-1;cur>=st[1];cur%=st[tp]){
			tp=std::upper_bound(st+1,st+tp+1,cur)-st-1;
			cnt[tp]+=cur/st[tp]*cnt[i];
		}
		add_p[cur]+=cnt[i];
	}
	for(int i=st[1];i;--i){
		add_p[i-1]+=add_p[i];
	}
	for(int i=1;i<=n;++i){
		printf("%lld\n",(st[1]>=i?cnt[1]:0)+add_p[i]);
	}
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>

using namespace std;
int main()
{
    int N;

    cin >> N;

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

    sort( d , d+N );

    // for ( i = 0; i < N; i ++ ) cout << d[i] << " ";
    // cout << endl;
    // cout << d[N/2-1] << " " << d[N/2] << endl;

    cout << d[N/2] - d[N/2-1] << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if(a == 1){ a = 14; }
    if(b == 1){ b = 14; }
    if(a > b){
        cout << "Alice" << endl;
    }
    if(a < b){
        cout << "Bob" << endl;
    }
    if(a == b){
        cout << "Draw" << endl;
    }
}

Measured memory_bytes: 256
//Case i: x

#include <stdio.h>

int main()
{
    int x;
    int i=0;

    while(1) {
        scanf("%d", &x);

        if(x==0) {
            break;
        }

        i++;

        printf("Case %d: %d\n", i, x);
    }
    return 0;
}

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

r, g, b = 0, 0, 0
for i in range(N):
    if S[i] == 'R':
        r += 1
    elif S[i] == 'G':
        g += 1
    else:
        b += 1
c = r*g*b
for i in range(N - 2):
    for j in range(i, N - 1):
        k = 2 * j - i
        if k >= N:
            continue
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            c -= 1
print(c)

Measured memory_bytes: 79496
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

int N, a;
bool colors[8];
int free_colors = 0;

void color_judge(int a)
{
    for (int i = 1; i <= 8; i++) {
        if (a < i * 400) {
            colors[i - 1] = true;
            return;
        }
    }
    free_colors++;
    return;
}

int count_colors()
{
    int cnt = 0;
    for (int i = 0; i < 8; i++) {
        cnt += colors[i];
    }
    return cnt;
}

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a;
        color_judge(a);
    }

    cout << max(count_colors(), 1) << " " << count_colors() + free_colors << endl;
    return 0;
}

Measured memory_bytes: 256
ins = list(map(int, input().split()))
N = ins[0]
L = ins[1]
Ss = []

for i in range(N):
  Ss.append(input())

for i, a in enumerate(Ss):
  key = a
  j = i - 1

  while j >= 0 and Ss[j] > a:
    Ss[j + 1] = Ss[j]
    j = j - 1

  Ss[j + 1] = key

print(''.join(Ss))

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

using namespace std;

typedef pair<double,string> pds;

bool hikaku(pds lhs,pds rhs){
  if(lhs.first>rhs.first) return true;
  else if(lhs.first==rhs.first)return lhs.second<rhs.second;
  else return false;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  while(cin>>n,n){
    string l;
    double p,a,b,c,d,e,f,s,m;
    vector<pds> v;
    for(int i=0;i<n;i++){
      cin >>l>>p>>a>>b>>c>>d>>e>>f>>s>>m;
      double eff=(f*s*m-p)/(a+b+c+m*(d+e));
      v.push_back(make_pair(eff,l));
      //cout<<eff<<" "<<l<<endl;
    }
    sort(v.begin(),v.end(),hikaku);
    for(int i=0;i<n;i++){
      cout << v[i].second <<endl;//<< " "<<v[i].first<< endl;
    }
    cout <<"#" << endl;
  }
}

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

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;

int main(){
	int n, last_id;
	ll d, a, diff;
	vector<pair<ll, ll> > v;
	vector<ll> dec;
	cin>>n>>d>>a;
	v.assign(n, {0, 0});
	dec.assign(n, 0);
	for(int i=0;i<n;i++)
		cin>>v[i].first>>v[i].second;
	sort(v.begin(), v.end());
	ll ans = 0;
	ll t_diff = 0;
	int i = 0;
	while(i<n){
		ll spos = v[i].first+d;
		ll epos = spos+d;

		last_id = upper_bound(v.begin(), v.end(), make_pair(v[i].first-2*d, (ll)-1))-v.begin();
		if(last_id==0)
			diff = t_diff;
		else
			diff = t_diff-dec[last_id-1];

		ll num = (v[i].second-diff+a-1)/a;
		t_diff += a*num;
		ans += num;
		
		int j = i;
		while(j<n){
			if(v[j].first > epos)
				break;
			
			last_id = upper_bound(v.begin(), v.end(), make_pair(v[j].first-2*d, (ll)-1))-v.begin();
			if(last_id == 0)
				diff = t_diff;
			else
				diff = t_diff-dec[last_id-1];
			
			if(diff>=v[j].second){
				dec[j++] = t_diff;
			}
			else
				break;

		}
		i = j;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

const ll MXN=100005;
vector<edge> G[MXN];
vector<bool> B(MXN,false);
vl ans(MXN);

void bfs(ll x,ll d){
  B[x]=true;
  ans[x]=d;
  ll k=G[x].size();
  rep(i,k){
    if(B[G[x][i].to]==false){
      bfs(G[x][i].to,G[x][i].cost+d);
    }
  }
}

  
int main() {
  ll N;
  cin >> N;
  rep(i,N-1){
    ll a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    G[a].push_back({b,c});
    G[b].push_back({a,c});
  }
  ll Q,K;
  cin >> Q >> K;
  K--;
  bfs(K,0);
  rep(i,Q){
    ll x,y;
    cin >> x >> y;
    x--;y--;
    cout << ans[x]+ans[y] << '\n';
  }
}


Measured memory_bytes: 14336
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - TAKOYAKI FESTIVAL 2019
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

/* global variables */

int ds[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", ds + i);

  int sum = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      sum += ds[i] * ds[j];

  printf("%d\n", sum);
  return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> p(n);
  for (int i=0; i<n; i++)
    cin>>p.at(i);
  
  int z=0;
  for (int i=1; i<n-1; i++) {
    if ( (p.at(i-1)-p.at(i)) * (p.at(i+1)-p.at(i)) < 0 )
      z++;
  }
  cout<< z <<endl;
}


Measured memory_bytes: 256
import io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    val Array(n, k) = readLine.split(" ").map(_.toInt)
    val trees = (for {_ <- 1 to n} yield readInt()).sorted
    println((0 to n - k).map(i => trees(i + k - 1) - trees(i)).min)
  }
}

Measured memory_bytes: 40556
n=int(input())
dic={}
m=0
for i in range(n):
    s=input()
    if s in dic: dic[s]+=1
    else: dic[s]=1
    if dic[s]>m: m=dic[s]

ans=[]
for s in dic:
    if dic[s]==m: ans.append(s)
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 32096
#include <stdio.h>

int n, q, x1[10000], y1[10000], x2[10000], y2[10000], imos[10001];

int main()
{
	while (true)
	{
		scanf("%d", &n);
		scanf("%d", &q);

		if (n == 0 && q == 0) break;

		for (int i = 0; i < n; i++)
		{
			scanf("%d", &x1[i]);
			scanf("%d", &y1[i]);
			scanf("%d", &x2[i]);
			scanf("%d", &y2[i]);
		}

		int ret1 = 0;
		int ret2 = 0;

		for (int i = 0; i < 10000; i++)
		{
			for (int j = 0; j < n; j++)
			{
				if (y1[j] <= i && i < y2[j])
				{
					imos[x1[j]]++;
					imos[x2[j]]--;
				}
			}

			int sum = 0;

			for (int j = 0; j <= 10000; j++)
			{
				if ((sum == 0 && sum + imos[j] > 0) || (sum > 0 && sum + imos[j] == 0)) ret2++;

				sum += imos[j]; imos[j] = 0;

				if(sum > 0) ret1++;
			}
		}

		for (int i = 0; i < 10000; i++)
		{
			for (int j = 0; j < n; j++)
			{
				if (x1[j] <= i && i < x2[j])
				{
					imos[y1[j]]++;
					imos[y2[j]]--;
				}
			}

			int sum = 0;

			for (int j = 0; j <= 10000; j++)
			{
				if ((sum == 0 && sum + imos[j] > 0) || (sum > 0 && sum + imos[j] == 0)) ret2++;

				sum += imos[j]; imos[j] = 0;
			}
		}

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

		if (q == 2)
		{
			printf("%d\n", ret2);
		}
	}

	return 0;
}

Measured memory_bytes: 2880
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long a, long b, long x) {
    return a * a * b / 2.0 <= x ?
        atan(2.0 * (a * a * b - x) / a ^^ 3) * 180.0 / PI :
        atan((a * b * b) / 2.0 / x) * 180.0 / PI;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long a;
    a = input.front.to!long;
    input.popFront;

    long b;
    b = input.front.to!long;
    input.popFront;

    long x;
    x = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(a, b, x);
    else {
        auto ans = solve(a, b, x);

        static if (isFloatingPoint!(ReturnType!solve))
            writeln(format("%.9f", ans));
        else static if (is(ReturnType!solve == bool))
            writeln(ans ? YES : NO);
        else
            writeln(ans);
    }
}


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

const long long mod = 1e9 + 7;
vector <int> a[100005];
int n;
bool c[2][100005];
long long f[2][100005];
bool b[100005];

void inp()
{
    cin >> n;
    for (int i = 1; i < n; i++)
    {
        int x,y;
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
}

/// 0 = black & 1 = white
long long tryyy(int t, int u, int no)
{
    if (c[t][u]) return f[t][u];
    long long tmp = 1;
    if (t == 0)
    {
        for (int v : a[u])
        {
            if (no != v)
            tmp = (tmp * (tryyy(1,v,u)))%mod;
        }
    }
    else
    {
        for (int v : a[u])
        {
            if (no != v)
            tmp = (tmp * ((tryyy(0,v,u) + tryyy(1,v,u))%mod)) %mod;
        }
    }
    c[t][u] = true;
    f[t][u] = tmp;
    return tmp;
}


void proc()
{
    long long ans = (tryyy(0,1,0) + tryyy(1,1,0)) % mod;
    cout << ans;
}


int main()
{
    inp();
    proc();
    return 0;
}


Measured memory_bytes: 15872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC115
{
    class Program
    {
        static void Main(string[] args)
        {
              int D;
            D = int.Parse(Console.ReadLine());

             if ( D == 25 )
              Console.WriteLine("Christmas");

                else if (D == 24)
                  Console.WriteLine("Christmas Eve");

             else if (D == 23)
               Console.WriteLine("Christmas Eve Eve");

             else
              Console.WriteLine("Christmas Eve Eve Eve");

             Console.ReadKey();
        }
    }
}

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

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

  int ans = 1e5;
  bool tle = true;
  rep(i,N) {
    int c, t;
    cin >> c >> t;
    if(t <= T) {
      tle = false;
      ans = min(ans, c);
    }
  }

  if(tle) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }


  return 0;
}


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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;

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

  ll n, k;
  cin >> n >> k;

  if(k > ((n - 1)* (n - 2)) / 2){
    cout << -1 << '\n';
    return 0;
  }

  vector < pair < ll, ll > > p;
  //kaali.
  for(int i = 2; i <= n; i++){
    p.push_back({1, i});
  }
  ll k1 = ((n - 1)* (n - 2)) / 2;
  ll i = 2, j = 3;
  while(k1 > k){
    p.push_back({i,j});
    j++;
    if(j == n + 1){
      i++; j = i + 1;
    }
    k1--;
  }

  cout << p.size() << '\n';
  for(auto i : p) cout << i.first << " " << i.second << '\n';
}


Measured memory_bytes: 512
N, M = map(int, input().split())
S = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
A = list(map(int, input().split()))
A.sort()
A.reverse()
dp = [-1] * (N + 10)
dp[0] = 0
for i in range(N+1):
    for a in A:
        if(i - S[a] >= 0):
            dp[i] = max(dp[i - S[a]] * 10 + a, dp[i])
    
print(dp[N])


Measured memory_bytes: 14692
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  ll N;
  vector<ll> a(5);
  cin >> N;
  for (int i = 0; i < 5; i++) cin >> a[i];
  ll mn = *min_element(a.begin(), a.end());
  ll groups = (N + mn - 1) / mn;
  ll res = 4 + groups;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N, K, X, Y = sc.nextInt()
    val ans = if(N-K>=0) {
      K*X+(N-K)*Y
    } else {
      N*X
    }
    println(ans)
  }
}


Measured memory_bytes: 27436
#include <cstdio>
int dt[101][101];
int d[101], f[101];

int n;
int t=1;
void dfs(int s){
	d[s]=t++;
	for(int i=1;i<=n;i++){
		if(dt[s][i]&&d[i]==0){
			dfs(i);
		}
	}
	f[s]=t++;
}
int main(){
	int fi, v, g;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d %d",&fi,&v);
		for(int j=1;j<=v;j++){
			scanf("%d",&g);
			dt[fi][g]=1;
		}
	}
	d[1]=1;
	int flag=true;
	dfs(1);
	for(int i=1;i<=n;i++){
		if(!d[i]){
			dfs(i);
		}
	}
			
	for(int i=1;i<=n;i++){
		printf("%d %d %d\n",i,d[i],f[i]);
	}
	return 0;
}

Measured memory_bytes: 1068
#include <cstdio>
int main() {
    int b,r,g,c,s,t;
    while (scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t)) {
        if (!b&&!r&&!g&&!c&&!s&&!t) break;
        int res=100+12*(b+r)+13*(b*5+r*3)-c+4*g;
        t-=b*6+r*4+c+g+s;
        printf("%d\n",res-t*3);
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
int n,m;
cin>>n>>m;

vector<int>vc;
int sum=0;
for (int i = 0; i < n; ++i)
{

int a;
cin>>a;
vc.push_back(a);
sum+=a;
}

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

if(vc[i]*4*m>=sum)
{
	ct++;
}
	/* code */
}

if(ct>=m)
{
	cout<<"Yes"<<endl;
}
else{
	cout<<"No"<<endl;
}




	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;
    string t;
    cin>>t;
    int ans = 0;
    rep(i,0,n){
        if(i>=k&&t[i]==t[i-k]){
            t.replace(i,1,"n");
        }
        else{
            if(t[i]=='r'){ans+=p;}
            else if(t[i]=='s'){ans+=r;}
            else{ans+=s;}
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();;
        
        int[][] arr = new int[4][13];
        for (int i=0; i<n; i++) {
            String str1 = scanner.next();;
            int num = scanner.nextInt();;
            
            switch(str1){
                case "S":
                    arr[0][num-1] += 1;
                    break;
                case "H":
                    arr[1][num-1] += 1;
                    break;
                case "C":
                    arr[2][num-1] += 1;
                    break;
                case "D":
                    arr[3][num-1] += 1;
                    break;
            }
        }
        
        for (int i = 0; i < 4; i++){
            for (int j = 0; j < 13; j++) {
                if(arr[i][j] == 0){
                    String str2 = "";
                    switch(i){
                        case 0:
                            str2 = "S";
                            break;
                        case 1:
                            str2 = "H";
                            break;
                        case 2:
                            str2 = "C";
                            break;
                        case 3:
                            str2 = "D";
                            break;
                    }
                    System.out.println(str2 + " " + Integer.toString(j+1));
                }
            }
        }     
    }
}



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

int main()
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    if (A > B) {
        swap(A, B);
        swap(X, Y);
    }
    int min_cost = A * X + B * Y;
    if (2 * C <= A)
        min_cost = 2 * C * max(X, Y);
    else if (2 * C <= B)
        min_cost = 2 * C * Y + A * max(0, X - Y);
    else if (2 * C <= A + B) {
        min_cost = 2 * C * min(X, Y);
        min_cost += A * max(0, X - Y) + B * max(0, Y - X);
    }
    cout << min_cost << endl;
}


Measured memory_bytes: 3612
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String inputS = sc.next();
		String inputT = sc.next();
		String[] inputStringS = inputS.split("");
		String[] inputStringT = inputT.split("");
		int resPotision = -1;
		loop: for (int i = inputStringS.length - inputStringT.length; i >= 0; i--) {
			boolean judge = true;
			for (int j = 0; j < inputStringT.length; j++) {
				if (!"?".equals(inputStringS[i + j]) && !inputStringT[j].equals(inputStringS[i + j])) {
					judge = false;
					break;
				} else {
					continue;
				}
			}
			if (judge) {
				resPotision = i;
				break loop;
			}
		}
		if (resPotision >= 0) {
			for (int i = resPotision; i < inputStringT.length + resPotision; i++) {
				inputStringS[i] = inputStringT[i - resPotision];
			}
			for (int i = 0; i < inputStringS.length; i++) {
				if ("?".equals(inputStringS[i])) {
					System.out.print("a");
				} else {
					System.out.print(inputStringS[i]);
				}
			}
		} else {
			System.out.print("UNRESTORABLE");
		}
	}
}


Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main(){
    int a,b,answer;
    cin >> a >> b;
    while ( a != b){
        if (a>=b){
            if (a%b ==0){
                answer = b;
                break;
            }else{
                a %= b;
            }
        }else{
            if (b%a ==0){
                answer = a;
                break;
            }else{
                b %= a;
            }
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 3080
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")


#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define repi(i,a) for(auto i = a.begin(); i!= a.end() ;++i) 
#define repdi(i,a) for(auto i = a.rbegin(); i!=a.rend();++i) 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) (int)a.size() 
#define all(a) a.begin(),a.end()
#define M 998244353
#define limit 100000000

typedef vector<ll> vll;
typedef pair<ll,ll> pii;
typedef vector<pii> vpi;
typedef vector<vector<ll> > vv;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve() {
	int a , b, c, d; cin >> a >> b >> c >> d;
	while(a>0 || c>0) {
		c -= b;
		a -= d;
		if(c<=0) {
			cout <<"Yes" ; return ;
		}
		if(a<=0) {
			cout << "No"; return ;
		}
	}
}

signed main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif 

    fast;
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}
	return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.{NumericRange, Queue}
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val N, T = sc.nextInt
    println("%.20f".format(Array.fill(N)(sc.nextDouble, sc.nextDouble).map(x => T * x._2 / x._1).max))

  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


Measured memory_bytes: 60268
//https://atcoder.jp/contests/abc138/tasks/abc138_a
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a;
	cin>>a;
	string s;
	cin>>s;
	if(a>=3200)
	{
		cout<<s<<"\n";
	}
	else
	{
		cout<<"red"<<"\n";
	}
	return 0;
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(10 * n + 1, vector<int>(10 * n + 1, 100 * n + 1)));
    dp[0][0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10 * n + 1; j++) {
            for (int k = 0; k < 10 * n + 1; k++) {
                if (j >= a[i] && k >= b[i]) {
                    dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j - a[i]][k - b[i]] + c[i]);
                }
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
            }
        }
    }

    int mn = 100 * n + 1;
    for (int i = 1; i < 10 * n + 1; i++) {
        for (int j = 1; j < 10 * n + 1; j++) {
            if (i * mb == j * ma) {
                mn = min(mn, dp[n][i][j]);
            }
        }
    }

    if (mn == 100 * n + 1) {
        cout << -1 << endl;
    } else {
        cout << mn << endl;
    }
}


Measured memory_bytes: 27264
N, X = map(int, input().split())
X_list = list(map(int, input().split()))
kyori = [abs(X - x) for x in X_list]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


ans = kyori[0]
for i in range(1, N):
    ans = gcd(ans, kyori[i])
print(ans)


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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  for (int i = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());
  
  bool can1 = true;
  for (int i = 0; i < s.size();) {
    bool can2 = false;
    for (int j = 0; j < 4; j++) {
      if (s.substr(i, divide[j].size()) == divide[j]) {
        can2 = true;
        i += divide[j].size();
      }
    }
    if (!can2) {
      can1 = false;
      break;
    }
  }
  if (can1) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque…双方向リスト
//stack…FILO, 深さ優先探索
//queue…FIFO, 幅優先探索
//priority_queue…格納された最大値から順に取り出す
//pair…二つの値を一組
//tuple…複数の値を一組

const int mod = 1e9+7;

template<typename T>
void remove(std::vector<T>& vector, char index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}
template<class T>
T mi(std::vector<T> &v) {
    T mini = 0;
    for(auto &i:v) mini = min(mini, i);
    return mini;
}
template <class T>
T pow(T x, T y, T n = numeric_limits<T>::max()) {
    if(y == 0) return 1;
    if(y % 2 == 0) return pow((x * x) % n, y / 2);
    return (x * pow(x, y - 1)) % n;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return !y ? x : gcd(x % y, y);
}

using Graph = vector<vector<int>>;

template <class T, class S>
class Edge {
  T to;  //辺の行き先
  S weight;  //辺の重み

public:
  Edge(T t, S w) : to(t), weight(w) {}
};

int ansi = 0;
ll ansl = 0;
double ansd = 0.0;

int accumul(int mul) {
  if (mul == 0) {
    return 1;
  } else {
    return mul * accumul(mul-1);
  }
}

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

  rep(i, 0, 1E9) {
    if (abs(a-i) == abs(b-i)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = pi*r*r;
        double length = 2*pi*r;
        System.out.printf("%f %f", area, length);
    }
}


Measured memory_bytes: 28296
#include<stdio.h>

int main(void){
  int a, i;
  int b[100];
  int c = 0;
  int pos = 0;
  scanf("%d", &a);
  for ( i = 0; i < a; i++ ) {
    scanf("%d", &b[i]);
  }
  while ( b[pos] == 0 ) {
    pos++;
  }
  while ( pos < a ) { 
  	for ( i = pos; b[i] > 0 && i < a; i++ ) {
    	b[i] -= 1;
  	}
    if ( pos == i ) {
      pos++;
    } else {
      c++;
    }
  }
  printf("%d", c);
  return 0;
}

Measured memory_bytes: 128
// abc132_f
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    ll N, K;
    cin >> N >> K;

    ll sqrt_n = (ll)sqrt(N);
    set<ll> st;
    REPN(i, 1, sqrt_n+1){
        st.insert(i);
        st.insert(N/i);
    }
    ll n = st.size();

    vector<ll> nums(ALL(st));

    vector<ll> cnt(n);
    cnt[0] = 1;
    REP(i, n - 1){
        cnt[n-i-1] = nums[n-i-1] - nums[n - i - 2];
        cnt[n-i-1] %= MOD;
    }

    vector<ll> dp(n);
    dp[0] = 1;

    REP(k, K){
        vector<ll> prev = dp;
        ll sm = 0;
        REP(i, n) {
            sm = (sm + prev[i]) % MOD;
            dp[n-1-i] = (sm * cnt[n-1-i]) % MOD;
        }
    }

    ll ans = 0;
    REP(i, n){
        ans += dp[i];
        ans %= MOD;
    }
    print(ans);




    return 0;
}

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

int INF=1e9;

int main(){
    while(true){

        vector<vector<int>> Load(100,vector<int>(100,INF)); 
        for(int i=0;i<20;i++){
            for(int j=0;j<20;j++){
                if(i==j) Load[i][j]=0;
            }
        }
        int n;
        cin>>n;
        if(n==0) break;
        int size=0;
        for(int i=0;i<n;i++){
            int a,b,c;
            
            cin>>a>>b>>c;
            size=max(size,max(a,b));
            Load[a][b]=c;
            Load[b][a]=c;
        }

        int FA=1e9;
        int num;
        int ans=0;
        for(int i=0;i<=size;i++){
            vector<int> d(13,INF);
            vector<bool>  u(100,false);
            d[i]=0;

            while(true){
                 int v=-1;
                    for(int j=0;j<=size;j++){
                        if(u[j]) continue;
                        if(v==-1||d[j]<d[v]) v=j;
                    }

                    if(v==-1) break;
                    u[v]=true;

                    for(int l=0;l<=size;l++){
                        if(d[l]>d[v]+Load[v][l]){
                            d[l]=d[v]+Load[v][l];
                        }
                    }
            }
            ans=0;
            for(int j=0;j<=size;j++)  ans+=d[j];
            if(FA>ans){
                num=i;
                FA=ans;
            }  
            //cout<<FA<<endl;   
        }

        cout<<num<<" "<<FA<<endl;
    }
}



Measured memory_bytes: 3168
import collections
N = int(input())
lsn = list(map(int,input().split()))
Q = int(input())
ls2 = []
for i in range(Q):
    Bi,Ci = map(int,input().split())
    ls2.append([Bi,Ci])
index = collections.Counter(lsn)
sum1 = sum(lsn)
for l in ls2:
    sum1 = sum1 +(l[1]-l[0])*index[l[0]]
    index[l[1]] += index[l[0]]
    index[l[0]] = 0
    print(sum1)

Measured memory_bytes: 37224
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+10,mod=998244353;
int a[N],b[N],c[N],ans;
int s[N][3],two[N],n;
struct node{
	int x,y;
}p[N];
inline bool cmp(node p,node q){return p.x<q.x;}
void add(int x){
	while(x<=n)c[x]++,x+=x&(-x);
}
int sum(int x){
	int res=0;
	while(x){
		res+=c[x];
		x-=x&(-x);
	}
	return res;
}
void calc(int tot,int d){
	ans=(ans+(two[tot]-1)*d%mod)%mod;
}
signed main(){
	scanf("%lld",&n);
	two[0]=1;
	for(int i=1;i<=n;i++)two[i]=two[i-1]*2%mod;
	
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&p[i].x,&p[i].y);
		a[i]=p[i].x;
		b[i]=p[i].y;
	}
	sort(a+1,a+n+1);sort(b+1,b+n+1);
	sort(p+1,p+n+1,cmp);
	
	for(int i=1;i<=n;i++){
		p[i].x=lower_bound(a+1,a+n+1,p[i].x)-a;
		p[i].y=lower_bound(b+1,b+n+1,p[i].y)-b;
	}
	
	for(int i=1;i<=n;i++){
		int y=p[i].y;
		s[i][2]=sum(y-1),s[i][1]=i-s[i][2]-1;
		add(y);
	}
	memset(c,0,sizeof(c));
	for(int i=n;i>=1;i--){
		int y=p[i].y;
		int s4=sum(y-1),s3=n-i-s4;
		int tmp=ans;
	/*	cout<<"------"<<i<<endl;
		cout<<"#1:     "<<s[i][1]<<endl;
		cout<<"#2:     "<<s[i][2]<<endl;
		cout<<"#3:     "<<s3<<endl;
		cout<<"#4:     "<<s4<<endl;*/	
		calc(s[i][1]+s3,1);
		calc(s[i][1]+s[i][2],1);
		calc(s[i][2]+s4,1);
		calc(s3+s4,1);
		
		calc(s[i][1],-1);
		calc(s[i][2],-1);
		calc(s3,-1);
		calc(s4,-1);	
	//	cout<<ans-tmp<<endl;	
		add(y);
	}
	printf("%lld",(n*(two[n]-1)%mod-ans+mod)%mod);
}

Measured memory_bytes: 14336
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    ll x, y;
    cin >> x >> y;
    ll ret = 1;
    while(2*x <= y){
        ret++;
        x*=2;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define INF 1000000007
using namespace std;
typedef long long ll ;

int n,m,c;

pair<ll,ll> b[100005];
ll cant = 0;
ll price = 0;
int main(){
    fastio;
    cin>>n>>m;

	for(int i=0; i<n;i++){
		ll x,y;
		cin>>x>>y; // x=price , y = quantity
		b[i] = {x,y};
	}
	
	sort(b,b+n);
	
	for(int i=0; i<n;i++){
		ll x= b[i].first;
		ll y= b[i].second;
		if(m-cant > y) {cant+=y; price += x*y;}
		else{
			price+= (m-cant)*x;
			break;
		}
	}
	

	cout<<price<<"\n";
		
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;
typedef long long ll;
const int MAX = 1e5 + 10;
const int mod = 1e9+7;


void solve() {
    string s;
    cin>>s;
    int ans=0;
    int res=0;
    bool is=false;
    for(int i=0;i<s.size();i++){
        if(s[i]=='R'){
            is=true;
        }
        if(s[i]=='R'&&s[i+1]=='R'){
            ans++;
        }else{
            res=max(res,ans);
            ans=0;
        }
    }
    if(is){
        res++;
    }
    cout<<res;
}

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

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
	int a,b,c,i,m,n;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		n=a;
		a=b;
		b=n;
	}
	if(a>c){
		n=a;
		a=c;
		c=n;
	}
	if(b>c){
		n=b;
		b=c;
		c=n;
	}
	printf("%d %d %d\n",a,b,c);
			

return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll k,s; cin>>k>>s;
  ll ans=0;
  rep(i,k+1){
    rep(j,k+1){
      ll x=s-i-j;
      if(x<0 || k<x) continue;
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  string s;
  int cnt=0;
  cin >> s;
  for(int i=1; i<s.size(); i++){
    if(s[i-1]!=s[i]){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main()
{
int a,b,c,d;
cin>>a>>b>>c>>d;
cout<<max(a*b,c*d)<<endl;
}

Measured memory_bytes: 256
//ABC128A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int ans;
	if(a >= 13){
		ans = b;
	}else if(a >= 6){
		ans = b/2;
	}else{
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256