akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b;
    while(cin>>a>>b){
        cout<<max((a+b),max((a-b),(a*b)))<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool a[10]={};
bool ok(int x){
  while(x != 0){
    if(a[x%10]) return false;
    x /= 10;
  }
  return true;
}

int main(){
  int n,k,tp;
  cin>>n>>k;
  for(int i=0;i<k;i++){
  	cin>>tp;
    a[tp]=true;
  }
  while(!ok(n)) n++;
  cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> va(n),ans(n);
    for (int i=0; i<n; i++) {
        cin >> va[i];
        ans[i] = 0;
    }
    for (int i=n; i>0; i--) {
        int cnt=0;
        for (int j=i; j<=n; j+=i) {
            cnt += ans[j-1];
        }
        if (cnt % 2 != va[i-1]) ans[i-1] = 1;
    }
    int cnt=0;
    for (int i=0; i<n; i++) {
        if (ans[i] == 1) {
            cnt ++;
        }
    }
    cout << cnt << "\n";
    for (int i=0; i<n; i++) {
        if (ans[i] == 1) {
            cout << i+1 << " ";
        }
    }
    cout << "\n";
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    string s; cin >> s;
    int ans = 0;


    REP(i,n) {
        if (i != n-1 && s[i] == 'r') {
            if (s[i] == s[i+1]) ans++;
        } else if (i != 0) {
            if (s[i] == s[i-1]) ans++;
        }
    }

    ans = min(ans + k * 2,n-1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  ll ac=0,wa=0,tle=0,re=0;
  cin >> n;
  string s;
  REP(i,n){
    cin>>s;
    if (s=="AC")ac++;
    if (s=="WA")wa++;
    if (s=="TLE")tle++;
    if (s=="RE")re++;
  }


  cout<<"AC x "<<ac<<endl;
  
  cout<<"WA x "<<wa<<endl;
  
  cout<<"TLE x "<<tle<<endl;
  
  cout<<"RE x "<<re<<endl;
  return 0;
}

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

using namespace std;

int main() {
    map<string, int> mp;

    int q;
    cin >> q;
    while (q--) {
        int op;
        string s;
        cin >> op >> s;
        if (op == 0) {
            int x;
            cin >> x;
            mp[s] = x;
        } else {
            cout << mp[s] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 27692
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>

using namespace std;

const int N = 88;
int A[N][N], B[N][N];
bool memo[N][N][4 * N * N];
int h, w, ans;
void solve(int i, int j, int sum) {
    if (i == h || j == w)
        return;
    if (i == h - 1 && j == w - 1) {
        ans = min({ans, abs(sum + A[i][j]), abs(sum + B[i][j])});
        return;
    }
    int s = sum + 80 * (h + w);
    bool &ret = memo[i][j][s];
    if (ret)
        return;
    memo[i][j][s] = 1;
    solve(i + 1, j, sum + A[i][j]);
    solve(i + 1, j, sum + B[i][j]);
    solve(i, j + 1, sum + A[i][j]);
    solve(i, j + 1, sum + B[i][j]);
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> B[i][j];
            int tmp = A[i][j];
            A[i][j] -= B[i][j];
            B[i][j] -= tmp;
        }
    }

    ans = INT_MAX;
    solve(0, 0, 0);
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 211968
#define NDEBUG

#include <cassert>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

constexpr double EPS = 1e-8;

struct point {
	double x, y;
	point(double x_, double y_):x(x_), y(y_) {}

	inline point operator+(const point &p) const {
		return point(x + p.x, y + p.y);
	}

	inline point operator-(const point &p) const {
		return point(x - p.x, y - p.y);
	}

	inline point operator*(double s) const {
		return point(x * s, y * s);
	}
};

inline double dot(const point &a, const point &b) {
	return a.x * b.x + a.y * b.y;
}

inline double cross(const point &a, const point &b) {
	return a.x * b.y - a.y * b.x;
}

inline double norm(const point &p) {
	return p.x * p.x + p.y * p.y;
}

struct line {
	point a, b;
	line(const point &a_, const point &b_):a(a_), b(b_) {}
};

inline point project(const line &l, const point &p) {
	const point diff = l.b - l.a;
	return l.a + diff * (dot(p - l.a, diff) / norm(diff));
}

inline point reflect(const line &l, const point &p) {
	return p + (project(l, p) - p) * 2.0;
}

inline point crosspoint(const line &l, const line &m) {
	const double tmp = cross(l.b - l.a, m.b - m.a);
	if(abs(tmp) < EPS) return l.a;
	return m.a + (m.b - m.a) * (cross(l.b - l.a, l.a - m.a) / tmp);
}
 
typedef pair<bool, int> result; // is point, idx
 
vector<point> points;
vector<line> lines;

result parse(string::const_iterator &);
 
int number(string::const_iterator &it) {
	int sign = 1;
	while(*it == '-') {
		sign = -1;
		++it;
	}

	int res = 0;
	while(isdigit(*it)) {
		res = res * 10 + *it - '0';
		++it;
	}
	return sign * res;
}

result factor(string::const_iterator &it) {
	assert(*it == '(');
	++it;
	if(*it == '-' || isdigit(*it)) {
		const double x = number(it);
		assert(*it == ',');
		++it;
		const double y = number(it);
		assert(*it == ')');
		++it;
		points.emplace_back(x, y);
		return make_pair(true, points.size() - 1);
	}
	else {
		const result res = parse(it);
		assert(*it == ')');
		++it;
		return res;
	}
}
 
result parse(string::const_iterator &it) {
	result res = factor(it);

	while(*it == '@') {
		++it;
		result tmp = factor(it);

		switch(res.first + tmp.first) {
		case 2: // point@point
		{
			lines.emplace_back(points[res.second], points[tmp.second]);
			res = make_pair(false, lines.size() - 1);
			break;
		}
		case 1: // line@point
		{
			if(res.first) swap(res, tmp);
			points.emplace_back(reflect(lines[res.second], points[tmp.second]));
			res = make_pair(true, points.size() - 1);
			break;
		}
		case 0: // line@line
		{
			points.emplace_back(crosspoint(lines[res.second], lines[tmp.second]));
			res = make_pair(true, points.size() - 1);
			break;
		}
		default: assert(false);
		}
	}

	return res;
}
 
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	for(string s; cin >> s && s != "#";) {
		points.clear();
		lines.clear();

		string::const_iterator it = s.cbegin();
 		const result ans = parse(it);
		const point p = points[ans.second];
		cout << p.x << ' ' << p.y << endl;
	}
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    ll n;
    ll a,b;
    Scll3(n,a,b);

    ll x;
    ll ans = 0;

    Scll(x);
    ll tmp = x;
    Rep(i,n-1){
        Scd(x);
        ans += min(b,a*(x-tmp));
        tmp = x;
    }

    printf ("%llu\n", ans);

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>

typedef struct node {
        int key;
        struct node *left;
        struct node *right;

        node();
} node;

node::node()
        : left(nullptr), right(nullptr)
        {
        }

void inOrder(node *p)
{
        if (p == nullptr) {
                return;
        }
        inOrder(p->left);
        printf(" %d", p->key);
        inOrder(p->right);
}

void preOrder(node *p)
{
        if (p == nullptr) {
                return;
        }
        printf(" %d", p->key);
        preOrder(p->left);
        preOrder(p->right);
}

class BinaryTree {
public:
        node *root;
        BinaryTree();
        void insert(int newKey);
        bool find(int key);
        void print();
};

BinaryTree::BinaryTree()
        : root(nullptr)
        {
        }

void BinaryTree::insert(int newKey)
{
        node **p, *newNode;

        for (p = &root; *p != nullptr;) {
                if (newKey == (*p)->key) {
                        return;
                }
                p = (newKey < (*p)->key) ? &(*p)->left : &(*p)->right;
        }
        newNode = new node();
        newNode->key = newKey;
        *p = newNode;
}

bool BinaryTree::find(int key)
{
        node *p;

        for (p = root; p != nullptr;) {
                if (key == p->key) {
                        return true;
                }
                p = (key < p->key) ? p->left : p->right;
        }

        return false;
}

void BinaryTree::print()
{
        inOrder(root);
        putchar('\n');
        preOrder(root);
        putchar('\n');
}

int main()
{
        BinaryTree tree;
        int m, key;
        char com[10];

        scanf("%d", &m);
        for (int i = 0; i < m; i++) {
                scanf("%s", com);
                if (com[0] == 'i') {
                        scanf("%d", &key);
                        tree.insert(key);
                }
                else if (com[0] == 'f') {
                        scanf("%d", &key);
                        tree.find(key) ? printf("yes\n") : printf("no\n");
                }
                else {
                        tree.print();
                }
        }

        return 0;
}

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

using namespace std;

#define ll				long long
#define pb				push_back
#define w(x)			int x; cin>>x; while(x--)
#define mp      		make_pair
#define mod     		1000000007
#define inf     		1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define endl	  		"\n"
#define sp 				" "
#define ca(x) 			"Case "<<x<<": "
#define all(x) 			x.begin(), x.end()
#define loop(i,a,n)		for (int i = a; i < (n); ++i)
#define rloop(i,a,n)	for (int i = n; i >= (a); --i)
#define in(n)			long long n ; scanf("%lli",&n);
#define yes				cout << "YES"<<endl
#define no				cout << "NO"<<endl



int main()
{
	int n ; cin >> n;
	ll a[n]; ll c = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	if (n > 2)
	{	sort(a, a + n);

		for (int i = 0; i < n - 2; ++i)
		{
			loop(j, i + 1, n - 1)
			{
				loop(k, j + 1, n)
				{

					if (a[i] + a[j] > a[k] && a[i] != a[j] && a[i] != a[k] && a[k] != a[j] )
						c++;


				}
			}
		}
	}
	cout << c;

	return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k,res=0;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	while(b<=a)b<<=1,res++;
	while(c<=b)c<<=1,res++;
	if(res<=k)puts("Yes");
	else puts("No");
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
#define fr first
#define sc second
#define pii pair<int, int>
#define all(v) v.begin(), v.end()

using namespace std;

const ll MOD = 1000000007;

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

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

    vector<ll> pos, neg;

    for (int i = 0; i < n; i++) {
        ll temp;
        cin >> temp;
        if (temp >= 0) {
            pos.push_back(temp);
        } else {
            neg.push_back(-1 * temp);
        }
    }
    sort(all(pos));
    sort(all(neg));

    int i = (int)pos.size() - 1;
    int j = (int)neg.size() - 1;

    int rem = k;
    ll ans = 1;

    if (i == -1 && k % 2 == 1) {
        for (i = 0; i < k; i++) {
            ans = (ans * neg[i]) % MOD;
        }
        ans = (ans * (MOD - 1)) % MOD;
    } else {
        while (rem > 0) {
            if (rem > 1 && j > 0 && (i < 1 || neg[j] * neg[j - 1] > pos[i] * pos[i - 1])) {
                // if  {
                ans = (ans * neg[j]) % MOD;
                j--;
                ans = (ans * neg[j]) % MOD;
                j--;
                rem -= 2;
                // }
            } else {
                if (i >= 0) {
                    ans = (ans * pos[i]) % MOD;
                    i--;
                } else {
                    ans = (ans * neg[j]) % MOD;
                    ans = (ans * (MOD - 1)) % MOD;
                    j--;
                }
                rem--;
            }
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 5484
import java.lang.*;
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        ArrayList retu = new ArrayList<Integer>();
        for (int i = 0;i<s.length()-1;i++){
            String sub = s.substring(i,i+2);
            if (sub.equals("RL")){
                retu.add(i);
            }
        }
        retu.add(-100);
        int sks = 0;
        int[] ba = new int[s.length()];
        for(int i = 0;i<s.length();i++){
            if(i==(int)retu.get(sks)){
                ba[i] = i;
            }else if(i==((int)retu.get(sks)+1)){
                ba[i] = i;
                sks++;
            }else if(s.charAt(i)=='R'){
                int kari = (int)retu.get(sks) - i;
                if(kari%2 == 0){
                    ba[i] = i + kari;
                }else{
                    ba[i] = i + kari + 1;
                }
            }else{
                int kari = i - (int)retu.get(sks-1);
                if(kari%2 == 0){
                    ba[i] = i - kari;
                }else{
                    ba[i] = i - kari + 1;
                }
            }
        }
        int[] result = new int[s.length()];
        for(int i = 0;i<s.length();i++){
            result[i] = 0;
        }
        for(int i = 0;i<s.length();i++){
            int kari = ba[i];
            result[kari] += 1;
        }
        for(int i = 0;i<s.length();i++){
            System.out.print(result[i]+" ");
        }
        System.out.println();
        sc.close();
    }
}

Measured memory_bytes: 48632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;


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

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int N; cin >> N;
    int i;
    vector<int> a(N);
    rep(i,N) cin>>a[i];
    int ans=0;
    for(i=0;i<N;i+=2){
        if(a[i]%2==1) ans++;
    }
    AA(ans);
    return 0;
}

Measured memory_bytes: 3564
from itertools import accumulate as ac
import copy
n, k = map(int, input().split())
A = list(map(int, input().split()))

def one_term(lis):
    imos = [0] * n

    for i, a in enumerate(lis):
        left = max(0, i - a)
        right = min(n, i + a + 1)
        imos[left] += 1
        try:
            imos[right] -= 1
        except:
            pass
    return list(ac(imos))

ans = A
for i in range(k):
    ans = one_term(ans)
    if ans.count(n) == n:
        break
print(*ans, sep=" ")

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

int main(){
	int x,y,z;
	cin >> x >> y >> z;
	cout << (x-z)/(y+z) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<list>
using namespace std;

int a[60][60];

int main()
{
	int h,w;cin>>h>>w;
	char c;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>c;
			if(c=='#')a[i][j]=1;
			else a[i][j]=0;
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(a[i][j]==1)cout<<"#";
			else
			{
				int s=0;
				s=a[i-1][j-1]+a[i-1][j]+a[i-1][j+1]+a[i][j+1]+a[i][j-1]+a[i+1][j+1]+a[i+1][j]+a[i+1][j-1];
				cout<<s;
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;


public class Main {
	
	public static boolean solve(String line) {
		Stack<Character> parens = new Stack<Character>();
		for (int i = 0; i < line.length(); i++) {
			char c = line.charAt(i);
			switch (c) {
			case '(':
			case '[':
				parens.push(c);
				break;
			case ')':
			case ']':
				if (parens.isEmpty()) {
					return false;
				} else {
					switch (parens.pop()) {
					case '(':
						if (c != ')') {
							return false;
						}
						break;
					case '[':
						if (c != ']') {
							return false;
						}
						break;
					}
				}
				break;
			}
		}
		return parens.isEmpty();
	}

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
		String output = "";
		String line;
		while ((line = r.readLine()) != null) {
			if (line.equals(".")) {
				break;
			} else {
				if (!output.equals("")) {
					output += "\n";
				}
				output += solve(line) ? "yes" : "no";
			}
		}
		System.out.println(output);
	}

}

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

int main() {
  int n;
  cin >> n;
  double ans = 0;
  rep(i,n){
    double x;
    string u;
    cin >> x >> u;
    if(u == "JPY") ans +=x;
    else ans += 380000 * x;
  }

  printf("%.6f\n",ans);
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a; i<=b; ++i)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using vl=vector<ll>;
using vp=vector<pll>;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll x;
    cin>>x;
    cout<<(x>=30 ? "Yes" : "No");
    return 0;
}

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

int main(void){
	int n;
	int a[250];
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	// make_heap(a,a+n);
	for(int i=0;i<n;i++){
		cout<<"node "<<i+1<<": key = "<<a[i]<<", ";
		if(i!=0)cout<<"parent key = "<<a[(i-1)/2]<<", ";
		if(2*i+1<n)cout<<"left key = "<<a[2*i+1]<<", ";
		if(2*i+2<n)cout<<"right key = "<<a[2*i+2]<<", ";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll N,M;
double dp[650];
vector<ll> paths[650];
double ans;
void input()
{
	
	cin>>N>>M;
	for(ll i=1;i<=M;i++)
	{
		ll s,t;
		cin>>s>>t;
		paths[s].pb(t);
	}
}
void f(ll block)
{
	dp[N]=0;
	for(ll i=N-1;i>=1;i--)
	{
		double sum=0;
		double mx=0;
		ll num=paths[i].size();
		for(auto to:paths[i])
		{
			sum+=dp[to];
			if(dp[to]>mx)
			{
				mx=dp[to];
			}
		}
		if(block==i&&num>=2)
		{
			sum-=mx;
			num--;
		}
		dp[i]=sum/num+1;
	}
	if(dp[1]<ans)
	{
		ans=dp[1];
	}
	return ;
}
void solve()
{
	input();
	ans=1e18;
	for(ll i=0;i<=N-1;i++)
	{
		f(i);
	}
	cout<<setprecision(10)<<ans<<"\n";
	return ;
}
int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>
#define Fori(g) for(int i=0;i<g;i++)
#define	Forj(g) for(int j=0;j<g;j++)
#define min(aa,bb) return (aa<bb)?aa:bb
#define max(aa,bb) return (aa<bb)?bb:aa

int main(){
	int r;
	scanf("%d",&r);
	printf("%d\n",r*r);
	return 0;
}

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

int main() {
  int N, C, K;
  cin >> N >> C >> K;
  vector<int> T(N);

  for(int i = 0; i < N; i++){
    cin >> T.at(i);
  }

  sort(T.begin(), T.end());
  int res = 0;

  for(int i = 0; i < N;){
    res++;
    int start = i;
    while(i < N && T[i] - T[start] <= K &&
    i - start < C) i++;
  }
  cout << res << endl;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


vector<vector<int> >adj;
int sz[200005];

void dfs(int ver,int pr)
{
  sz[ver]++;
  for(auto i:adj[ver])
  {
    if(i!=pr)
    {
      dfs(i,ver);
      sz[ver]+=sz[i];
    }
  }
}

int a=0,b=1;
const int mod=1e9+7;
int power[200005];
int ans=0;
int modInverse(int a, int m) 
{ 
    int m0 = m; 
    int y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        int q = a / m; 
        int t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 
  

void dfs2(int ver,int pr)
{
  int x=0,y=0;
  x=(power[sz[ver]-1]-1+mod)%mod;
  for(auto i:adj[ver])
  {
    if(i!=pr)
    {
      sz[ver]-=sz[i];
      sz[i]+=sz[ver];
      dfs2(i,ver);
      sz[i]-=sz[ver];
      sz[ver]+=sz[i];
    }
  }
  for(auto i:adj[ver])
  {
    y+=power[sz[i]]-1+mod;
    y%=mod;
  }
  x+=mod-y;
  x%=mod;
  ans+=x;
  ans%=mod;
}

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

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif  

  power[0]=1;
  for(int i=1;i<=200000;i++)
    power[i]=(power[i-1]*2)%mod;

  int n;
  cin>>n;
  adj.resize(n+1);
  int x,y;
  for(int i=0;i<n-1;i++)
  {
    cin>>x>>y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1,0);
  dfs2(1,0);
  ans*=modInverse(power[n],mod);
  ans%=mod;
  cout<<ans;

}

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



int main(){
    ll n,m;
    cin>>n>>m;
    ll l;
    
    for(ll i=m/n;i>0;i--){
        if(m%i==0){
            l=i;
            break;
        }
        
    }
    
    cout<<l<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int h,w;cin>>h>>w;
  char a;int gr[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a;
      if(a=='.'){
        gr[i][j]=1;
      }else{
        gr[i][j]=0;
      }
    }
  }
  int m=0,gr2[h][w];
  int gy[h],re[w];
  fill(gy,gy+h,0);
  fill(re,re+w,0);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      m+=gr[i][j];
    }
    if(m==w){
      gy[i]=1;
    }
    m=0;
  }
  m=0;
  for(int i=0;i<w;i++){
    for(int j=0;j<h;j++){
      m+=gr[j][i];
    }
    if(m==h){
      re[i]=1;
    }
    m=0;
  }
  for(int i=0;i<h;i++){
    if(gy[i]==0){
      for(int j=0;j<w;j++){
        if(re[j]==0){
          if(gr[i][j]==0){
            cout << '#';
          }else{
            cout << '.';
          }
        }
      }
      cout << endl;
    }
  }
}

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

using namespace std;
const int mod = 1000000007;
const int N = 200005;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
/* #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif */	
	int n;
	cin>>n;
	int arr[n][3];
	int ans[n][3];
	memset(ans,0,sizeof(ans));
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin >> arr[i][j];
		}
	}
	ans[0][0] = arr[0][0];
	ans[0][1] = arr[0][1];
	ans[0][2] = arr[0][2];
	for(int i=1;i<n;i++){
		for(int j=0;j<3;j++){
			int maxx = 0;
			for(int k=0;k<3;k++)
				if(j != k)
					maxx = max(maxx,ans[i-1][k] );
			ans[i][j] += arr[i][j] + maxx;
		}
	}
	int maxx =0;
	for(int i=0;i<3;i++)
	maxx = max(maxx,ans[n-1][i]);
	cout<<maxx;
	return 0;
}

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

long long gcd(long x, long y)
{    if (y == 0)
        return x;
    return gcd(y, x % y);}
long long lcm(long x, long y){ return x * y / gcd(x, y);}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}


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

    vector<pair<long long,long long>> s(N);

    for(int i=0;i<N;i++){
        long long a,b;
        cin>>a>>b;
        s[i] = make_pair(a,b);
    }

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

    long long ans=0,sum=0;

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

        if((M-sum)<=s[i].second){
            ans+=(M-sum)*s[i].first;
            break;
        }else{
            ans+=s[i].second*s[i].first;
            sum+=s[i].second;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(void) {
  int n,a;
  cin >> n;
  int b=n;
  while(true) {
    a += (b%10);
    b /= 10;
    if(b<1) break;
  }
  if(n%a==0) cout << "Yes" <<endl;
  else cout << "No" << endl;
}



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

int main(){
    int i;
    int c[3] = {};
    string s;
    cin >> s;
    for(i=0; i<3; i++){
        if(s[i] == 'a' && c[0] == 0){
            c[0]++;
        }else if(s[i] == 'b' && c[1] == 0){
            c[1]++;
        }else if(s[i] == 'c' && c[2] == 0){
            c[2]++;
        }else{
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
    char s[100];
    scanf("%s", s);
    int len = strlen(s);
    char end = s[len - 1];
    len = len - 2;
    printf("%c", s[0]);
    printf("%d", len);
    printf("%c\n", end);
}


Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import math
#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	s=input().rstrip().decode('utf-8')
	n=len(s)
	if s[n-1]=="<":
		s+=">"
		n+=1
	
	dai=0
	syo=0
	
	ans=0
	s+="a"
	
	for i in range(n):
		if s[i]=="<":
			dai+=1
		elif s[i]==s[i+1]==">":
			syo+=1
		else:
			syo+=1
			deka=max(dai,syo)
			mini=min(dai,syo)-1
			ans+=deka*(deka+1)//2+(mini)*(mini+1)//2
			dai=syo=0
	print(ans)
	
	
	
	
	
	
	
	
	
	
	

	
if __name__ == '__main__':
	main()

Measured memory_bytes: 4112
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define MOD 1000000007
#define PI acos(-1)
int main()
{
	IOS
	ll n,k,q;
	cin>>n>>k>>q;
	ll a[q+1];
	ll i;
	ll stu[n+1];
	for(i=1;i<=n;i++)
	stu[i]=k;
	for(i=1;i<=q;i++)
	cin>>a[i];
	map<ll,ll> mp;
	for(i=1;i<=q;i++)
	{
		mp[a[i]]++;
	}
	for(i=1;i<=n;i++)
	{
		stu[i]=stu[i]-(q-mp[i]);
		if(stu[i]<=0)
		cout<<"No\n";
		else
		cout<<"Yes\n";
	}
}

Measured memory_bytes: 8448
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int k,n;
int main(){
	k=read(),n=read();
	printf("%d\n",n==1?0:k-n);
	return 0;
}



Measured memory_bytes: 3724
#include <stdio.h>

int sum(int n)
{
	if (n == 0){
		return 0;
	}
	return n + sum(n - 1);
}

int main(void)
{
	int n;

	while (scanf("%d", &n) != EOF){
		printf("%d\n", sum(n) + 1);
	}

	return 0;
}

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

int main()
{
  int64_t h, w;
  cin >> h >> w;
  
  if (h == 1 || w == 1)
  {
    cout << 1 << endl;
    return 0;
  }
  
  int64_t h_odd = h / 2;
  if (h % 2 != 0) h_odd ++;
  
  int64_t h_even = (h - 1) / 2;
  if ((h - 1) % 2 != 0) h_even ++;

  int64_t masu_sum = 0;
  
  for (int64_t i = 0; i < w; i ++)
  {
    if (i % 2 == 0) masu_sum += h_odd;
    else masu_sum += h_even;
  }
  
  cout << masu_sum << endl;
  
  return 0;
}


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

int main(){
    int x;
    cin >> x;
    int x0 = x % 10;
    for (int i = 0; i < 130; i++){
        int j = -130 - x0 + i;
        while (j < i){
            if (pow(i,5)-pow(j,5)==x){
                cout << i << " " << j << endl;
                exit(0);
            }
            j += 10;
        }
    }
    return 0;
}

Measured memory_bytes: 4012
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<float> x(n),y(n);
    for(int i= 0; i < n; i++){
        cin >> x[i] >> y[i];
    }
    float sum = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            float d = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
            d *= (n - 1);
            d *= 2;
            sum += d;
        }
    }
    int k = n * (n - 1);
    cout << setprecision(10) << sum / k << endl;
}

Measured memory_bytes: 256
package main

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

type Alds14c struct {
	// hash array
	data []string
	// hash length
	length int
}

func main() {
	a := NewAlds14c()
	a.main()
}

func NewAlds14c() *Alds14c {
	a := &Alds14c{}
	a.length = 1<<20 - 1
	//a.length = 16777216
	a.data = make([]string, a.length)
	return a
}

func (a *Alds14c) main() {
	scanner := bufio.NewScanner(os.Stdin)
	res := a.solve(scanner)
	for _, v := range res {
		fmt.Println(v)
	}
}

func (a *Alds14c) getKey(v string) int {
	getValue := func(c byte) int {
		key := 0
		switch c {
		case 'A':
			key = 1
		case 'C':
			key = 2
		case 'G':
			key = 3
		case 'T':
			key = 4
		}
		return key
	}
	sum := 0
	p := 1
	for _, c := range []byte(v) {
		sum += p * getValue(c)
		p *= 5
	}
	return sum
}

// open address hash functions
func (a *Alds14c) h1(v int) int {
	return v % a.length
}
func (a *Alds14c) h2(v int) int {
	return 1 + (v % (a.length - 1))
}

func (a *Alds14c) insert(v string) {
	key := a.getKey(v)
	i := 0
	for {
		h := (a.h1(key) + i*a.h2(key)) % a.length
		if a.data[h] == v {
			// already inserted
			break
		} else if a.data[h] == "" {
			// insert because new value
			a.data[h] = v
			break
		}
		i++
	}
}

func (a *Alds14c) find(v string) bool {
	key := a.getKey(v)
	i := 0
	for {
		h := (a.h1(key) + i*a.h2(key)) % a.length
		if a.data[h] == v {
			return true
		}
		if a.data[h] == "" {
			return false
		}
		i++
	}
}

func (a *Alds14c) solve(scanner *bufio.Scanner) []string {

	res := make([]string, 0)

	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	n *= 2

	for i := 0; i < n; i++ {
		scanner.Scan()
		cmd := scanner.Text()

		scanner.Scan()
		value := scanner.Text()

		if cmd == "insert" {
			a.insert(value)
		} else if cmd == "find" {
			if a.find(value) {
				res = append(res, "yes")
			} else {
				res = append(res, "no")
			}
		}
	}

	return res
}



Measured memory_bytes: 56844
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <unordered_map> 
#include<list>

using namespace std;

int main(void) {

	int age;
	scanf("%d", &age);

	if (age == 1) {
		printf("Hello World");
	}
	else {

		
		int a,b;

		a = b = 0;

		scanf("%d", &a);
		scanf("%d", &b);
		printf("%d", a + b);
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h,c,ans,s,A=0,a,b;
  cin >> w >> h >> c;
  //  int A = __gcd(w,h);
  s = w*h;
  for(int i=1;i<=min(w,h);i++){
    if( w % i == 0 && h % i == 0 ) {
      A = max(A,i);
    }
  }
  if(w>=h) {
    a = w/A;
    b = h/A;
  }
  if(w<h) {
    a = h/A;
    b = w/A;
  }
  ans = a*b;
  cout << ans*c << endl;
  return 0;
}


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

int main(void) {
    string a, b, c;
    cin >> a >> b >> c;
    int d = 'a' - 'A';
    cout << (char)(a[0] - d) << (char)(b[0] - d) << (char)(c[0] - d);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	cout << "ABC" << setw(3) << setfill('0') << n << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  ll ans = 0;
  for(int i=1; i<=n; i++) {
    for(int j=i; j<=n; j+=i) {
      ans += j;
    }
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
#define MAX 25
#define NIL -1

struct Node
{
	int parent, left, right;
};

Node T[MAX];

void preParse(int u) {
	if (u == NIL)
		return;
	cout << " " << u;
	preParse(T[u].left);
	preParse(T[u].right);
}

void inParse(int u){
	if (u == NIL)
		return;
	inParse(T[u].left);
	cout << " " << u;
	inParse(T[u].right);
}

void postPause(int u) {
	if (u == NIL)
		return;
	postPause(T[u].left);
	postPause(T[u].right);
	cout << " " << u;
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		T[i].parent = T[i].left = T[i].right = NIL;
	}
	for (int i = 0; i < n; i++) {
		int id, l, r;
		cin >> id >> l >> r;
		T[id].left = l;
		T[id].right = r;
		T[l].parent = id;
		T[r].parent = id;
	}
	int root;
	for (int i = 0; i < n; i++) {
		if (T[i].parent == NIL)
			root = i;
	}
	cout << "Preorder" << endl;
	preParse(root);
	cout << endl;

	cout << "Inorder" << endl;
	inParse(root);
	cout << endl;

	cout << "Postorder" << endl; 
	postPause(root);
	cout << endl;
	return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <functional>
using namespace std;

int n, m, sum; string S[109], T[109]; map<string, int>M;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
		M[S[i]]++;
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> T[i];
		M[T[i]]--;
	}
	for (int i = 0; i < n; i++) {
		sum = max(sum, M[S[i]]);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	ll h, w, n;
	cin >> h >> w >> n;
	map<pair<ll, ll>, ll> mp;
	rep(i, n) {
		ll p, q;
		cin >> p >> q;
		p--, q--;
		rep(k, 9) {
			ll nx = p + dx[k], ny = q + dy[k];
			if (1 <= nx and nx <= h - 2 and 1 <= ny and ny <= w - 2) mp[{nx, ny}]++;
		}
	}
	vector<ll> ans(10);
	for (auto p : mp) ans[p.second]++;
	ll sum = 0;
	for (auto p : ans) sum += p;
	ans[0] = (h - 2) * (w - 2) - sum;
	for (auto p : ans) cout << p << endl;
	return 0;
}

Measured memory_bytes: 56576
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<pii>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

const int N=1e5+5;
int dp[N];

int  powermod(int  x, int  y, int p )
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}

int32_t main() 
{
    fast;
    int n,k;cin>>n>>k;
    for(int i=k;i>=1;i--)
    	dp[i]=powermod(k/i,n,mod);


    for(int i=k;i>=1;i--)
    {
    	for(int j=2*i;j<=k;j+=i)
    		dp[i]-=dp[j],dp[i]+=mod,dp[i]%=mod;
    }

    int ans=0;
    for(int i=1;i<=k;i++)
    {
    	int num=i*dp[i];
    	num%=mod;
    	ans+=num,ans%=mod;
    }
    cout<<ans;
}

Measured memory_bytes: 4436
#include<stdio.h>

#define Max 500000
#define Sen 1000000000

int count;
int l[Max / 2 + 2], r[Max / 2 + 2];

void merge(int a[], int n, int left, int mid, int right){
  int n1, n2, i, j, k;
  n1 = mid - left;
  n2 = right - mid;

  for(i = 0 ; i < n1 ; i++) l[i] = a[left + i];
  for(i = 0 ; i < n2 ; i++) r[i] = a[mid + i];
  l[n1] = r[n2] = Sen;

  i = 0;
  j = 0;
  for(k = left ; k < right ; k++){
    count++;
    if(l[i] <= r[j]){
      a[k] = l[i++];
    }
    else{
      a[k] = r[j++];
    }
  }
}

void mergeSort(int a[], int n, int left, int right){
  if(left + 1 < right){
    int mid;

    mid = (left + right) / 2;
    mergeSort(a, n, left, mid);
    mergeSort(a, n, mid, right);
    merge(a, n, left, mid, right);
  }
}


int main(){
  int a[Max], n, i;
  count = 0;

  scanf("%d", &n);
  for(i = 0 ; i < n ; i++) scanf("%d", &a[i]);

  mergeSort(a, n, 0 , n);

  for(i = 0 ; i < n ; i++){
    if(i) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");

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

  return 0;
}


Measured memory_bytes: 5596
#include <iostream>

using namespace std;


int main(void) {
    
    int A, B;
    
    cin >> A >> B;
    
    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
        
        cout << "Possible";
        
    }
    else {
        
        cout << "Impossible";
        
    }
    
    return 0;
    
}

Measured memory_bytes: 256
h,w=map(int,input().split())
n=int(input())
arr=list(map(int,input().split()))
def nextPoint(i,j):
    if i%2==0 and j<w-1:
        return (i,j+1)
    elif i%2==1 and j>0:
        return (i,j-1)
    elif j==0 or j==w-1:
        return(i+1,j)

ans = [[0 for col in range(w)] for row in range(h)]
cur=(0,0)
for i in range(n):
    for _ in range(arr[i]):
        ans[cur[0]][cur[1]]=i+1
        cur=nextPoint(cur[0],cur[1])
for row in ans:
    print(' '.join(list(map(str,row))))


Measured memory_bytes: 3564
N = int(input())

a_s, b_s, c_s = [], [], []
for _ in range(N):
    a, b, c = map(int, input().split())
    a_s.append(a)
    b_s.append(b)
    c_s.append(c)

dp = [{} for _ in range(N+1)]
dp[0]["a"] = a_s[0]
dp[0]["b"] = b_s[0]
dp[0]["c"] = c_s[0]

for i in range(1, N):
    dp[i]["a"] = max(dp[i-1]["b"]+a_s[i],
                     dp[i-1]["c"]+a_s[i])
    dp[i]["b"] = max(dp[i-1]["a"]+b_s[i],
                     dp[i-1]["c"]+b_s[i])
    dp[i]["c"] = max(dp[i-1]["a"]+c_s[i],
                     dp[i-1]["b"]+c_s[i])
    # print(dp)
print(max(dp[N-1]["a"], dp[N-1]["b"], dp[N-1]["c"]))


Measured memory_bytes: 97752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

typedef long long i64;
typedef pair<i64,i64> P;

int n;
vector<int> a;

int main()
{
	cin >> n;
	for(int i = 0;i < n;i++)
	{
		int t;
		cin >> t;
		a.push_back(t);
	}

	sort(a.rbegin(),a.rend());

	int A = 0;
	int B = 0;

	int cou = 0;

	for(int x : a)
	{
		if(cou % 2 == 0)
		{
			A += x;
		}
		else
		{
			B += x;
		}
		cou++;
	}

	cout << A - B << endl;
	return 0;

	

}


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

int N;
vector<vector<int>> es;
constexpr long long MOD = 1000000007;
long long memo[2][100001];

long long dfs(int par, int par_color, int node) {
  long long ret1 = 1, ret2 = 1;
  // cerr << par << " " << node << endl;

  if (memo[par_color][node] != 0) return memo[par_color][node];

  // 白の時のみ黒を許可
  if (par_color == 1) {
    for (int child : es[node]) {
      if (child == par) continue;
      ret1 = (ret1 * dfs(node, 0, child)) % MOD;
    }
  } else {
    ret1 = 0;
  }
  for (int child : es[node]) {
    if (child == par) continue;
    ret2 = (ret2 * dfs(node, 1, child)) % MOD;
  }

  return memo[par_color][node] = (ret1 + ret2) % MOD;
}

int main(void) {
  cin >> N;
  es.resize(N);

  int x, y;
  for (int i = 0; i < N - 1; i++) {
    cin >> x >> y;
    x--;y--;
    es[x].push_back(y);
    es[y].push_back(x);
  }
  cout << dfs(-1, 1, 0) << endl;
  return 0;
}

Measured memory_bytes: 14208
n=int(input())
x=list(map(int, input().split()))
y=sorted(x)
a=y[n//2-1]
b=y[n//2]
if a==b:
  for _ in range(n): print(a)
else:
  for i in range(n):
    if x[i]<=a: print(b)
    else: print(a)

Measured memory_bytes: 104744
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 17 21:23:58 2019

@author: Yamazaki Kenichi
"""
import sys

N,M = map(int,input().split())
S = input()
T = input()
def a(x,y):
    if x == y:
        return x
    if min(x,y)<0:
        return 0
    if x > y:
        x,y = y,x
    x,y = y-x,x
    return a(x,y)

n = a(N,M)
if n == 1:
    if S[0] == T[0]:
        print(N*M)
    else:
        print(-1)
    sys.exit()
for i in range(n):
    if S[N//n*i] != T[M//n*i]:
        print(-1)
        sys.exit()
print(N*M//n)

Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>

int main(void){
  int n;
  scanf("%d", &n);
  int *h = (int *)malloc(n*sizeof(int));
  int i, j=0;
  int *judge = (int *)calloc(n-1, sizeof(int));
  int *ans = (int *)calloc(n-1, sizeof(int));
  int count;
  
  for(i=0; i<n; i++){
    scanf("%d", h+i);
    if(i>0){
      if(h[i] > h[i-1])
	judge[i-1] = 0;
      else
	judge[i-1] = 1;
    }
  }

  i = 0;
  while(i<n-1){
    if(i == 0){
      if(judge[i] == 1)
	count = 1;
    }
    else{
	if(judge[i] == 1){
	  if(judge[i-1] == 1)
	    count++;
	  else
	    count = 1;
	  if(i==n-2)
	    ans[j] = count; 
	}
	else{
	  if(judge[i-1] == 1){
	    ans[j] = count;
	    j++;
	  }
	}
    }
    i++;
  }

  int max = 0;
  for(i = 0; i < n-1; i++){
    if(ans[i] > max)
      max = ans[i];
  }

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


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int N_MAX = 100000;
const unsigned long long MAX = 1000000000000000000ULL;

int main(){
    int N;
    unsigned long long A[N_MAX];
    unsigned long long sum = 1ULL;
    bool zero = false;

    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> A[i];
        if(A[i] == 0ULL){
            zero = true;
        }
    }

    if(zero){
        cout << 0 << endl;
        return 0;
    }

    for(int i = 0;i < N;i++){
        if(ULLONG_MAX / sum > A[i]){
            sum *= A[i];
        }else{
            sum = 0;
            break;
        }
        if(sum > MAX){
            sum = 0;
            break;
        }
    }

    if(sum == 0)cout << -1 << endl;
    else cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, M; 
	cin>>N>>M;
	vector<vector<int> >vec(M);
	for(int i=0;i<M;++i){
		int k;
		cin>>k;
		vec[i].resize(k);
		for(int j=0;j<k;++j){
			cin>>vec[i][j];
			--vec[i][j];
		}
	}
	vector<int>p(M);
	for(int i=0;i<M;++i)cin>>p[i];
	int ans=0;
	for(int i=0;i<(1<<N);++i){
		bool ok=true;
		for(int j=0;j<M;++j){
			int c=0;
			for(int id=0;id<vec[j].size();id++){
				if((i>>vec[j][id])&1){
					++c;
				}
			}
			c%=2;
			if(c!=p[j]){
				ok=false;
			}
		}
		if(ok){
			++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256