akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = n-1; i >= 0; --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using in = int64_t;
using P=pair<in,in>;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string s,t;

int main(){
    set<int> st;
    int n;
    int x;
    cin >> n;
    rep(i,n){
        cin >> x;
        st.insert(x);
    }
    cout << st.size() << endl;
    return 0;
}

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

using namespace std;

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

  int n;
  cin >> n;
  vector<vector<int>> data(n-1, vector<int>(3));
  for (int i = 0; i < n-1; ++i) {
    cin >> data[i][0] >> data[i][1] >> data[i][2];
  }
  for (int i = 0; i < n-1; ++i) {
    int t = data[i][0] + data[i][1];
    for (int j = i+1; j < n-1; ++j) {
      int cj = data[j][0];
      int sj = data[j][1];
      int fj = data[j][2];
      if (t < sj) t = sj;
      else if (t%fj != 0) t += fj-(t%fj);
      t += cj;
    }
    cout << t << endl;
  }
  cout << 0 << endl;


  return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int a = sc.nextInt();
                int b = sc.nextInt();
                int c = sc.nextInt();
                sc.close();
                System.out.println(c / 2 * (a + b));
        }
}

Measured memory_bytes: 35548
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0,1,-1,1,-1},dy={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll H,W,kotae=0;
    cin>>H>>W;
    char c[H][W];
    vector<vector<ll>> ans(H,vector<ll> (W,0));
    vector<vector<ll>> U(H,vector<ll> (W,0));
    vector<vector<ll>> D(H,vector<ll> (W,0));
    vector<vector<ll>> L(H,vector<ll> (W,0));
    vector<vector<ll>> R(H,vector<ll> (W,0));
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            cin>>c[i][j];
            if(c[i][j]=='.'){
                U[i][j]++;
                D[i][j]++;
                L[i][j]++;
                R[i][j]++;
            }
        }
    }
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            if(c[i][j]=='#') continue;
            if(0<=j-1) L[i][j]+=L[i][j-1];
            if(0<=i-1) U[i][j]+=U[i-1][j];
        }
    }
    for(ll i=H-1;i>=0;i--){
        for(ll j=W-1;j>=0;j--){
            if(c[i][j]=='#') continue;
            if(j+1<W) R[i][j]+=R[i][j+1];
            if(i+1<H) D[i][j]+=D[i+1][j];
        }
    }
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            if(c[i][j]=='#') continue;
            ll cnt=U[i][j]+D[i][j]+R[i][j]+L[i][j]-3;
            chmax(kotae,cnt);
        }
    }
    cout<<kotae<<endl;
}

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

int main()
{
 int a, b;

 while(cin >> a >> b){
  int mas = a + b;
  int n = 0;
  while(true){
   n++;
   mas /= 10;

   if(mas == 0) break;
  }
  cout << n << '\n';
 }

 return 0;
}

Measured memory_bytes: 1160
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 1010;
const int MAXM = 10010;
const int MAXK = 16;
const int MAXQ = 200010;

int h, n, a[MAXN], b[MAXN], dp[MAXM];

int solve(int u) {
    if (dp[u] != -1) return dp[u];
    int res = 1000000000;
    FOR(i,1,n) res = min(res, solve(max(0, u - a[i])) + b[i]);
    return dp[u] = res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> h >> n;
    FOR(i,1,n) cin >> a[i] >> b[i];
    FOR(i,0,h) dp[i] = -1;
    dp[0] = 0;
    cout << solve(h);
    return 0;
}


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

int main()
{
	int k;
	while (scanf("%d", &k), k){
		int s = 0;
		for (int i = 0; i < k * (k - 1) / 2; i++){
			int a;
			scanf("%d", &a);
			s += a;
		}
		printf("%d\n", s / --k);
	}
	return 0;
}

Measured memory_bytes: 1188
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll res = a * c;
    res = max(res, a * d);
    res = max(res, b * c);
    res = max(res, b * d);
    cout << res;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long int lli;

using namespace std;

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

    vector<lli> P(M, 0), Y(M, 0);
    vector<lli> d[N+1];

    for(lli i=0; i<M; i++){
        cin>>P[i]>>Y[i];
        d[P[i]].push_back(Y[i]);
    }

    for(lli i=1; i<=N; i++){
        sort(d[i].begin(), d[i].end());
    }

    for(lli i=0; i<M; i++){
        cout<<setw(6)<<setfill('0')<<P[i];
        cout<<setw(6)<<setfill('0')<<(lli)(lower_bound(d[P[i]].begin(), d[P[i]].end(), Y[i]) - d[P[i]].begin()) + 1<<endl;
    }

}

Measured memory_bytes: 8576
#include <stdio.h>
#include <string.h>
#define N 100001

typedef struct
{
  char b[100];
  int c;
} A;

void enqueue(A);
A dequeue();

A a[N];
int n,head,tail;

int main()
{
  int i,q,total = 0;
  A d;

  scanf("%d%d",&n,&q);
  for(i = 0;i < n;i++)
    {
      if(scanf("%s%d",a[i].b,&a[i].c) == EOF) break;
    }
  head = 0;
  tail = n;
  while(head != tail)
    {
      d = dequeue();
      if(d.c > q)
	{
	  d.c = d.c - q;
	  total += q;
	  enqueue(d);
	} else
	{
	  total += d.c;
	  printf("%s %d\n",d.b,total);
	}
    }
  return 0;
}
void enqueue(A d)
{
  a[tail] = d;
  tail = (tail + 1) % N;
}
A dequeue()
{
  A d = a[head];
  head = (head + 1) % N;
  return d;
}
  
      
      
    
      



Measured memory_bytes: 12012
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(abs(x-a) > abs(x-b)) cout << 'B' << endl;
  else  cout << 'A' << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll h, w;

void solve() {
    ll ans = ll_inf;
    if (h % 3 == 0 || w % 3 == 0) ans = 0;
    else {
        ll a = h / 3, b = ll(ceil(double(h) / 3)), c = h - a - b;
        ans = min(ans,
                  max({a * w, b * w, c * w}) -
                  min({a * w, b * w, c * w}));
        a = w / 3, b = ll(ceil(double(w) / 3)), c = w - a - b;
        ans = min(ans,
                  max({a * h, b * h, c * h}) -
                  min({a * h, b * h, c * h}));

        repone(i, w - 1) {
            ans = min(ans,
                      max({h * i, ll(ceil(double(h) / 2) * (w - i)), (h / 2) * (w - i)}) -
                      min({h * i, ll(ceil(double(h) / 2) * (w - i)), (h / 2) * (w - i)}));
        }
        repone(i, h - 1) {
            ans = min(ans,
                      max({w * i, ll(ceil(double(w) / 2) * (h - i)), (w / 2) * (h - i)}) -
                      min({w * i, ll(ceil(double(w) / 2) * (h - i)), (w / 2) * (h - i)}));
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> h >> w;
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    bool a[4];
    memset(a,0,sizeof(a));
    string s;
    cin>>s;
    int n=s.length();
    for(int i=0;i<n;i++){
        if(s[i]=='N'){
            a[0]=true;
        }else if(s[i]=='S'){
            a[1]=true;
        }else if(s[i]=='W'){
            a[2]=true;
        }else{
            a[3]=true;
        }
    }
    if((a[0]^a[1])||(a[2]^a[3])){
        cout<<"No" <<endl;
    }else{
        cout << "Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
# Import
from collections import deque

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

# Implementation
N = read_int()

MAX_P = 1000006
isP = [True] * MAX_P
for i in range(2,MAX_P):
    if isP[i]:
        for j in range(2*i,MAX_P,i):
            isP[j] = False

P = [i for i in range(2,MAX_P) if isP[i]]
ans = 0
for p in P:
    cnt = 0
    while N % p == 0:
        N /= p
        cnt += 1
    dec = 1
    while cnt >= dec:
        cnt -= dec
        dec += 1
        ans += 1
if N > 1:
    ans += 1
print(ans)

Measured memory_bytes: 81256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(' ').map { it.toDouble() }.sorted()
    var res = v[0]
    for (i in 1 until n) {
        val tmp = v[i]
        res = (res+tmp)/2
    }
    println(res)
}


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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()

typedef pair<int, int> P;

template<class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b;
	cin >> a >> b;
	if (a + b == 15) cout << "+" << endl;
	else if (a * b == 15) cout << "*" << endl;
	else cout << "x" << endl;
	
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
  private static void solve(int n, ArrayDeque<Integer>[] matches) {
    int count = 0;
    int finished = 0;
    Set<Integer> entry = new HashSet<>();
    Deque<Integer> queue = new ArrayDeque<>();
    for (int i = 0; i < n; i++) queue.add(i);
    while (true) {
      entry.clear();
      while (!queue.isEmpty()) {
        int i = queue.poll();
        if (entry.contains(i) || matches[i].size() == 0) {
          continue;
        }
        int enemy = matches[i].peek();
        if (entry.contains(enemy) || matches[enemy].size() == 0) {
          continue;
        }
        if (i == matches[enemy].peek()) {
          entry.add(i);
          entry.add(enemy);
          matches[i].poll();
          matches[enemy].poll();
          queue.remove(enemy);
          if (matches[i].size() == 0) finished += 1;
          if (matches[enemy].size() == 0) finished += 1;
        }
      }
      if (entry.isEmpty()) {
        break;
      }
      queue.addAll(entry);
      count++;
    }
    if (finished < n) {
      System.out.println(-1);
    } else {
      System.out.println(count);
    }
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    ArrayDeque<Integer>[] matches = new ArrayDeque[n];
    for (int i = 0; i < n; i++) {
      ArrayDeque<Integer> player = new ArrayDeque<>();
      String[] row = sc.nextLine().split(" ");
      for (int j = 0; j < n - 1; j++) {
        player.add(Integer.parseInt(row[j]) - 1);
      }
      matches[i] = player;
    }
    sc.close();
    solve(n, matches);
  }
}


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

int main() {
  vector<int> x(5);
  for (int i = 0; i < 5; i++) cin >> x[i];
  cout << find(x.begin(), x.end(), 0) - x.begin() + 1 << endl;
}

Measured memory_bytes: 3544
//
// Created by kota_ on 2019/12/28.
//
#include <stdio.h>
#include <stdlib.h>

typedef struct node{
    int id;
    struct node *child;
    struct node *sibling;
    struct node *parent;
}Node;

typedef Node* Nodepointer;


Node make_1node(int id){
    Node ret;
    ret.id = id;
    ret.child = NULL;
    ret.sibling = NULL;
    ret.parent = NULL;
    return ret;
}

int get_parent_value(Nodepointer);
int get_depth(Nodepointer);


int main(){
    int i, j, n, id, k, depth;
    Nodepointer nodes, parent, child_left, child_right;
    scanf("%d", &n);
    nodes = malloc(sizeof(Node) * n);
    for(i = 0; i < n; i++){
        nodes[i] = make_1node(i);
    }
    for(i = 0; i < n; i++){
        scanf("%d %d", &id, &k);
        parent = &nodes[id];
        for(j = 0; j < k; j++){
            scanf("%d", &id);
            child_right = &nodes[id];
            child_right->parent = parent;
            if(j == 0){
                parent->child = child_right;
            }
            else{
                child_left->sibling = child_right;
            }
            child_left = child_right;
        }
    }
    for(i = 0; i < n; i++){
        parent = &nodes[i];
        printf("node %d: parent = %d, ", i, get_parent_value(parent));
        depth = get_depth(parent);
        printf("depth = %d, ", depth);
        if(depth == 0){
            printf("root, ");
        }
        else if(parent->child != NULL){
            printf("internal node, ");
        }
        else{
            printf("leaf, ");
        }
        printf("[");
        for(child_left = parent->child; child_left != NULL; child_left = child_left->sibling){
            printf("%d", child_left->id);
            if(child_left->sibling != NULL){
                printf(", ");
            }
        }
        printf("]\n");

    }
    free(nodes);
    return 0;
}

int get_parent_value(Nodepointer target) {
    if (target->parent == NULL) {
        return -1;
    } else {
        return target->parent->id;
    }
}

int get_depth(Nodepointer target){
    int depth = 0;
    while(target->parent != NULL){
        depth++;
        target = target->parent;
    }
    return depth;
}




Measured memory_bytes: 4716
import sys
Money_500 = int(input())
Money_100 = int(input())
Money_50  = int(input())
Amount    = int(input())
Count = 0

if Amount % 50 != 0 or Amount / 1 == 0 or Amount < 50 :
    print(Count)
    sys.exit()

for i in range(0,Money_500+1):
    if Amount < i * 500 :
        break

    for x in range(0,Money_100+1):
        if ( Amount - ( i * 500 )) - (x * 100) < 0 :
             break

        if ( Amount - (i * 500 ) - ( x * 100 )) / 50 <= Money_50 :
            Count += 1
print ( Count )

Measured memory_bytes: 3188
n,k=gets.to_s.split(" ").map{|s| s.to_i}
a=gets.to_s.split(" ").map{|s| s.to_i}
count=Array.new

for m in 0..n+1
  count[m]=0
end
for m in 0..n-1
  count[a[m]]+=1
end
count.delete(0)
count.sort!.reverse!
print n-(count[0..k-1].inject(:+))

Measured memory_bytes: 18872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	string s,t;
	ll ch[54];
	cin>>s>>t;
	for(ll i=0;i<n;i++){
		if(s[i]==t[i]){
			ch[i]=0;
		}
		else{
			if(i!=0&&s[i-1]==s[i]){
				ch[i]=2;
			}
			else{
				ch[i]=1;
			}
		}
	}
	ll num[54];
	num[0]=3;
	if(ch[0]==1){
		num[0]=6;
	}
	for(ll i=1;i<n;i++){
		if(ch[i-1]==0){
			num[i]=2;
		}
		else if(ch[i-1]==1){
			num[i]=1;
		}
		else{
			if(ch[i]==0){
				num[i]=1;
			}
			else{
				num[i]=3;
			}
		}
	}
	ll ans=1;
	for(ll i=0;i<n;i++){
		ans*=num[i];
		ans%=inf;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <sstream>
// #include <cmath>
// #include <map>
// #include <set>
// #include <deque>
// #include <stack>
// #include <vector>
using namespace std;
#define debug freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
// #define PI acos(-1)
typedef long long ll;
const ll mod=1e9+7;

int main()
{
	//debug;
	ios;
	ll K,X;
	cin>>K>>X;
	if(K*500>=X)
		cout<<"Yes";
	else
		cout<<"No";
    return 0;
}


Measured memory_bytes: 3548
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];

    sort(a.begin(), a.end());
    
    ll ans = 0, sum = 0;
    for(int i = 0; i < N; i++){
        if(a[i] <= x) x -= a[i], ans++;
    }
    if(ans == N && x != 0) ans--;

    cout << ans << endl;

    return 0;
}

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

#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c\n",c)

int main(void){
  int n,d;
  scanf("%d %d",&n,&d);
  int x[n][d],cnt=0;
  FOR(n){
    FORJ(d)scanf("%d",&x[i][j]);
    if(i){
      FORJ(i){
        int ans=0;
        for(int k=0;k<d;k++){
          ans+=pow(x[i][k]-x[j][k],2);
        }
        if(pow(ans,0.5)==(int)pow(ans,0.5))cnt++;
      }
    }
  }
  PRN(cnt);
  return 0;
}

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

long long int N, M, a[101010], A;
unordered_map<long long, long long> m;

int main(){
    scanf("%lld%lld", &N, &M);
    for(int i = 1; i <= N; ++i){
        scanf("%lld", a + i);
        a[i] += a[i - 1];
        a[i] %= M;
    }
    for(int i = 0; i <= N; ++i)++m[a[i]];
    for(auto i : m)A += i.second * (i.second - 1) / 2;
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 4492
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF 1<<29
#define LL_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

struct edge {
	int from, to, cost;
};

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL vmax(vi v, LL n) {
	int MAX = 0;
	f(i, 0, n) {
		MAX = max(MAX, v[i]);
	}
	return MAX;
}

LL vmin(vi v, LL n) {
	int MIN = LL_INF;
	f(i, 0, n) {
		MIN = min(MIN, v[i]);
	}
	return MIN;
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//エラトステネスの篩
void sieve(LL n) {
	vb s(n + 1, true);
	f(i, 2, n + 1) {
		for (int j = 2; i*j <= n; j++) {
			s[i*j] = false;
		}
	}
	cout << "2から" << n << "までの素数" << endl;
	f(i, 2, n + 1) {
		if (s[i]) {
			cout << i << " ";
		}
	}
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}


#pragma endregion 


/*****************************************************************************/
signed main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a < c&&c < b)||(b<c&&c<a)) {
		 _y();
	}
	else {
		_n();
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

const int INF = 1e9;
const long long LINF = 1e18;

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

    map<string, long long> m;
    for (int i = 0; i < N; i++) {
        string si;
        cin >> si;
        sort(si.begin(), si.end());
        
        if (m.end() == m.find(si)) {
            m[si] = 1;
        } else {
            ++m[si];
        }
    }

    long long ans = 0;
    for (map<string, long long>::iterator itr = m.begin(); itr != m.end(); ++itr) {
        // cout << itr->first << endl;
        ans += (itr->second) * (itr->second - 1) / 2;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
/*.....Bismillahir Rahmanir Rahim.....*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define pii pair<int, int>
#define  vi  vector<int> 
using namespace std;
typedef pair<int, pair<int, int>> pi;

void solve()
{
	int  n, a, b, ans = 0 ; 
	cin >> n >> a >> b ; 
	int x[n+1];
	for (int i=1;i<=n;i++) cin >> x[i] ; 
	for (int  i=2;i<=n;i++) {
		if ((x[i]-x[i-1])*a>b) ans += b;
		else ans += a*(x[i]-x[i-1]);
	}
	cout << ans << endl; 
}

signed main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return 0;
}
/*
7 1 100
40 43 45 105 108 115 124

7 1 2
24 35 40 68 72 99 103

*/

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int main(void) {
	int n;
	cin>>n;
	vector<int> a(n);
	REP(i, n) cin>>a[i];
	bool d = false;
	bool same = true;
	REP(i, n) {
		if(a[i] != a[0]) same = false;
	}
	if(same) {
		if(a[0] == n - 1) d = true;
		else {
			if(n / 2 >= a[0]) d = true;
		}
	}
	sort(ALL(a));
	if(a[n - 1] - a[0] == 1) {
		int fc = 0;
		int bc = 0;
		REP(i, n) {
			if(a[i] == a[0]) ++bc;
			else ++fc;
		}
		int col = a[n - 1];
		col -= bc;
		if(col > 0 && fc > 1 && fc / 2 >= col) d = true;
	}

	if(d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#define N 200005
using namespace std;

int n, m, cnt, tot, id[N], head[N << 3], dis[N << 3]; 
struct node
{
	int u, v, w;
	bool operator < (const node &p) const
		{
			return w < p.w; 
		}
} a[N];
struct edge { int to, next, cost; } e[N << 3];
bool vis[N << 3]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

inline void adde(int u, int v, int w) { e[++cnt] = (edge) { v, head[u], w }; head[u] = cnt; }

void bfs()
{
	memset(dis, 0x3f, sizeof(dis)); dis[1] = 0;
	deque<int> q;
	q.push_front(1);
	while(!q.empty())
	{
		int u = q.front(); q.pop_front();
		if(vis[u]) continue; vis[u] = 1; 
		for(int i = head[u]; i; i = e[i].next)
		{
			int v = e[i].to;
			if(dis[v] > dis[u] + e[i].cost)
			{
				dis[v] = dis[u] + e[i].cost; 
				if(!e[i].cost) q.push_front(v);
				else q.push_back(v); 
			}
		}
	}
}

int main()
{
	tot = n = read <int> (), m = read <int> (); 
	for(int i = 1; i <= m; i++)
		a[i].u = read <int> (), a[i].v = read <int> (), a[i].w = read <int> ();
	sort(a + 1, a + m + 1);
	int last = a[1].w;
	for(int i = 2; i <= m + 1; i++)
		if(a[i].w != a[last].w)
		{
			for(int j = last; j < i; j++)
			{
				if(!id[a[j].u]) id[a[j].u] = ++tot;
				if(!id[a[j].v]) id[a[j].v] = ++tot;
				adde(a[j].u, id[a[j].u], 1), adde(id[a[j].u], a[j].u, 0);
				adde(a[j].v, id[a[j].v], 1), adde(id[a[j].v], a[j].v, 0);
				adde(id[a[j].u], id[a[j].v], 0), adde(id[a[j].v], id[a[j].u], 0);
			}
			for(int j = last; j < i; j++)
				id[a[j].u] = id[a[j].v] = 0; 
			last = i; 
		}
	bfs();
	printf("%d\n", dis[n] == 0x3f3f3f3f ? -1 : dis[n]); 
	return 0; 
}


Measured memory_bytes: 31104
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut m: usize,
        mut ab: [(usize, usize); n]
    }

    ab.sort();
    let mut cost = 0;
    for (a, b) in ab {
        if m == 0 {
            break;
        }
        let num = std::cmp::min(m, b);
        cost += num * a;
        m -= num;
    }

    println!("{}", cost);
}

Measured memory_bytes: 5768
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

// 約数の列挙 O(√n)
vector<ll> divisor(ll n) {
    vector<ll> res;

    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }

    return res;
}

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

    vector<ll> divs = divisor(M);
    ll ans = 0;
    for (ll i = divs.size() - 1; i >= 0; i--) {
        if (M % divs[i] == 0) {
            ll sub_m = M / divs[i];
            if (sub_m >= N) {
                ans = max(ans, divs[i]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int N;
  cin >> N;
  if(N == 1){
    cout << "Hello World" << endl;
  } else {
    int A, B;
    cin >> A >> B;
    cout << A+B << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
struct Time
{
	int start;
	int end;
}times[100000];
bool cmp(Time a, Time b)
{
	return a.end <= b.end;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, i;
	int x, l;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> x >> l;
		times[i].start = x - l;
		times[i].end = x + l;
	}
	sort(times, times + n, cmp);
	int cnt = 1;
	int ed = times[0].end;
	for (i = 1; i < n; i++)
	{
		if (times[i].start >= ed)
		{
			cnt++;
			ed = times[i].end;
		}
	}
	cout << cnt;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int w,a,b;
	cin>>w>>a>>b;
	if(b==a||b==(a+w)||(b>a&&b<(a+w))||(b>a&&b==w))
	cout<<"0";
	else
	if(b<a)
		cout<<a-(w+b);
		else
		cout<<(b-(w+a));
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    string T;
    cin >> S >> T;
    cout << (S[0] == T[0]) + (S[1] == T[1]) + (S[2] == T[2]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PL;
typedef pair<int,int> P;
const int INF = 1e9;
const int MOD = 17;
const vector<int> dy = {-1,0,1,0};
const vector<int> dx = {0,1,0,-1};

struct UnionFind {
    int N;
    vector<int> parents;

    UnionFind(int _N) : N(_N){
        parents = vector<int>(N,-1);
    }

    int find(int x) { //xの親を返す
        if (parents[x] < 0) return x;
        return parents[x] = find(parents[x]);
    }
    
    void unite(int x, int y) {  //xとyの含むグループを併合
        int px = find(x);
        int py = find(y);
        if (parents[px] > parents[py]) swap(px,py); 
        if (px != py) {
            parents[px] += parents[py];
            parents[py] = px;
        }     
    }

    bool same(int x, int y) { //x,yが同じグループにいるか判定
        return find(x) == find(y);
    }

    int size(int x) { //xと同じグループのメンバーの個数
        return -parents[find(x)];
    }
    
    vector<int> root() {//ufの根を列挙
        vector<int> res;
        for (int i = 0; i < N; i ++) {
            if (parents[i] < 0) res.push_back(i);
        }
        return res;
    }

    int group_count() { //ufのグループの数を数える
        int cnt = 0;
        for (int i = 0; i < N; i ++) {
            if (parents[i] < 0) cnt ++;
        }
        return cnt;
    }
};


int main() {
    int N,Q; cin >> N >> Q;
    UnionFind uf(N);
    rep(i,Q) {
        int type,x,y; cin >> type >> x >> y;
        if (type == 0) {
            uf.unite(x,y);
        }
        else {
            if (uf.same(x,y)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
}


Measured memory_bytes: 3200
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0582

"""
import sys
from sys import stdin
from math import asin, pi, sqrt, degrees
input = stdin.readline


def main(args):
    triangle = 0                #  ????§???¢?????°
    right_triangle = 0          #  ??´?§?????§???¢
    acute_triangle = 0          #  ????§?????§???¢
    obtuse_triangle  = 0        #  ????§?????§???¢
    while True:
        lines = [int(x) for x in input().split()]
        lines.sort()
        a, b, c = lines[0], lines[1], lines[2]
        if a + b <= c:
            break
        triangle += 1

        if a**2 + b**2 == c**2:
            right_triangle += 1
            continue
        s = (a + b + c) / 2
        area = sqrt(s * (s - a) * (s - b) * (s - c))
        h = (2 * area) / c
        A = degrees(asin(h / b))
        B = degrees(asin(h / a))
        C = 180 - (A + B)
        if A < 90 and B < 90 and C < 90:
            acute_triangle += 1
        else:
            obtuse_triangle += 1

    print(triangle, right_triangle, acute_triangle, obtuse_triangle)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7816
#include<iostream>

using namespace std;

int main(){
  int n, i = 0,count = 0;
  long int num[100000];
  long int ans = 0, l, min = -1;
  cin >> n;
  while(i < n){
    cin >> l;
    num[i] = l;
    i++;
  }
  i = 0;
  while(i < n){
    if(num[i] < 0){
      count++;
      num[i] = -1 * num[i];
    }
    if(min > num[i] || min == -1){
      min = num[i];
    }
    ans += num[i];
    i++;
  }
  if(count % 2 == 1){
    ans -= 2 * min;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

vector<int> onoff;
vector<vector<int>> s;
vector<int> p;

int calc(){
    for(int i = 0; i < s.size(); i++){
        int val = 0;
        for(int j = 0; j < s[i].size(); j++){
            if(onoff[s[i][j]-1] == 1){
                val++;
            }
        }
        if(val%2==p[i]){
            ;
        }else{
            return 0;
        }
    }
    return 1;
}
int dfs(int n){
    if(onoff.size() == n){
        return calc();
    }
    int ret = 0;
    for(int i = 0; i <= 1; i++){
        onoff.push_back(i);
        ret += dfs(n);
        onoff.pop_back();
    }
    return ret;
}
int main(){
    int n, m;
    cin >> n >> m;

    s.resize(m);
    for(int i = 0; i < m; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int ts;
            cin >> ts;
            s[i].push_back(ts);
        }

    }
    p.resize(m);
    for(int i = 0; i < m; i++){
        cin >> p[i];
    }




    cout << dfs(n) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;
int main()
{
  llong A,B;
  cin >> A >> B;
  llong M=0;
  for(llong i=2; i<=min(A,B); i++){
    if(A%i==0 && B%i==0){
      M=i;
    }
  }
  if(M==0) cout << A*B << endl;
  else cout << A*(B/M) << endl;
}


Measured memory_bytes: 256
package main

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

var graph [2*1e5 + 1][]int

func main() {
	var N, Q int
	Scan(&N, &Q)
	ans := make([]int, N+1)

	for i := 1; i < N; i++ {
		var a, b int
		Scan(&a, &b)
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	for q := 0; q < Q; q++ {
		var p, x int
		Scan(&p, &x)
		ans[p] += x
	}

	dfs(1, -1, ans)
	for i := 1; i <= N; i++ {
		fmt.Printf("%d ", ans[i])
	}
}

func dfs(v int, p int, ans []int) {
	for _, t := range graph[v] {
		if t == p {
			continue
		}
		ans[t] += ans[v]
		dfs(t, v, ans)
	}
}

func Println(xs ...int) {
	vs := make([]interface{}, len(xs))
	for i := 0; i < len(xs); i++ {
		vs[i] = xs[i]
	}
	fmt.Println(vs...)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}

func ReadInt() (i int) { Scan(&i); return }

func ReadInts(n int) []int {
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&xs[i])
	}
	return xs
}

func ReadLine() string {
	var s string
	for {
		l, isPrefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		s += string(l)
		if !isPrefix {
			return s
		}
	}
}


Measured memory_bytes: 49452
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
int main(void)
{
    sync;
    int s,w;
    cin>>s>>w;
    if(s>w)
        cout<<"safe"<<endl;
    else
        cout<<"unsafe"<<endl;
    return 0;
}

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

int findSumOfDigits(int n) {
  int sum = 0;
  while(n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  int total = 0;
  cin >> N >> A >> B;
  for(int i = 1; i <= N; i++) {
    if(A <= findSumOfDigits(i) && findSumOfDigits(i) <= B) {
      total += i;
    }
  }
  cout << total << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			int c = scanner.nextInt();
			scanner.nextLine();
			int b[] = new int[m];
			for (int i = 0; i < m; i++) {
				b[i] = scanner.nextInt();
			}
			scanner.nextLine();
			int count = 0;
			for (int i = 0; i < n; i++) {
				int sum = 0;
				for (int j = 0; j < m; j++) {
					int a = scanner.nextInt();
					sum += a * b[j];
				}
				if ((sum + c) > 0) {
					count++;
				}
				scanner.nextLine();
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define vul vector<ull>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi2d vector<vi >
#define vl2d vector<vl >
#define vpll vector<pll >

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rz resize
#define fr(i,n) for(i=0;i<(n);i++)
#define frr(i,n) for(i=(n-1);i>=0;i--)
#define fre(i,n) for(i=0;i<=(n);i++)
#define frre(i,n) for (i=(n);i>=0;i--)
#define frab(i,a,b) for(i=(a);i<(b);i++)
#define freab(i,a,b) for(i=(a);i<=(b);i++)
#define frrab(i,a,b) for(i=(b-1);i>=a;i--)
#define frreab(i,b,a) for(i=(b);i>=a;i--)

#define sz(a) int((a).size())
#define mset(a,b) (memset(a,b,sizeof(a)))
#define max3(a,b,c) (max((a),max((b),(c))))
#define min3(a,b,c) (min((c),min((a),(b))))
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <ll> sprime;
vector<char> prime (1000000, true);
void sieve(ll n)
{
  //O(nloglogn) time
  sprime.pb(0);
  prime[0] = prime[1] = false;
  ll cnt = 0;
  for (ll i = 2; i <= n; ++i)
  {
    if (prime[i])
    {
      cnt++;
      sprime.pb(i);
      for (ll j = 2 * i; j <= n; j += i)
        prime[j] = false;
    }
  }
}
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p, ll MOD) { if (p == 0) return 1; ll z = fastpowMOD(a, p / 2, MOD); z = (z * z) % MOD; if (p % 2) z = (z * a) % MOD; return z; }
ll fastpow(ll a, ll p) { if (p == 0) return 1; ll z = fastpow(a, p / 2); z = (z * z); if (p % 2) z = (z * a); return z; }
#define inf LLONG_MAX
#define minf LLONG_MIN
#define pi 3.14
#define ex 2.71
const int mod= 1e9+7;
//*********************************************///
const int N = 1e5+5;
//int i,j;
ll dp[N][2];
vector<ll>G[N];
//0 is black 1 is white
ll n;
ll i;

void dfs(int v,int p)
{
  for(auto it:G[v])
  {
    if(it!=p)
    {
      dfs(it,v);
      dp[v][0]=((dp[v][0]%mod)*(dp[it][1]%mod))%mod;
      dp[v][1]=((dp[v][1]%mod)*((dp[it][0]+dp[it][1])%mod))%mod;
    }
  }
}

void solve()
{
  cin>>n;
  fr(i,n-1)
  {
    ll x,y;
    cin>>x>>y;
    G[x].pb(y);
    G[y].pb(x);
  }
  fr(i,n+1)
    dp[i][0]=dp[i][1]=1;
  dfs(1,-1);
  cout<<(dp[1][0]+dp[1][1])%mod<<endl;
}

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


Measured memory_bytes: 15232
#109_D
H,W=map(int,input().split())
A=[]
Ans=[]
for i in range(H):
    a=list(map(int,input().split()))
    if i%2==0:
        A+=a
    else:
        A+=a[::-1]
for i in range(H*W-1):
    if A[i]%2==1:
        A[i]-=1
        A[i+1]+=1
        y1=i//W+1
        x1=i%W+1 if y1%2==1 else W-i%W
        y2=(i+1)//W+1
        x2=(i+1)%W+1 if y2%2==1 else W-(i+1)%W
        Ans.append([y1,x1,y2,x2])
print(len(Ans))
for ans in Ans:
    print(*ans)

Measured memory_bytes: 29980
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[6];
int main()
{
	scanf("%d",&n);
	int t;
	for(int i=1;i<=n;++i)
	scanf("%d",&t),a[t%4]++;
	a[1]+=a[3];
	if(a[2]!=0) a[1]++;
	if(a[1]<=a[0]+1) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
N,A,B = map(str,input().split())
a = int(A)
b = int(B)
c = int(N) + 1 
all = 0
ans = 0
for count in range(c):
  test = str(count)
  ttt = list(test)
  for mozi in ttt:
    all = all + int(mozi)
  if all >= a and all <= b:
    ans = ans + count
  all = 0

print('{}'.format(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <algorithm>

using namespace std;

typedef pair<int,int> pii;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n, m;
    while(cin>>m, m){
        vector<pii> p(m);
        for(int i=0; i<m; i++) cin >> p[i].first >> p[i].second;

        cin >> n;
        vector<pii> q(n);
        for(int i=0; i<n; i++) cin >> q[i].first >> q[i].second;

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

        int ax=-1, ay=-1;
        rep(i,n){
            int dx = q[i].first - p[0].first;
            int dy = q[i].second - p[0].second;
            bool ok = true;
            rep(j,m){
                pii t(p[j].first + dx, p[j].second + dy);
                if(!binary_search(q.begin(), q.end(), t)){
                    ok = false;
                    break;
                }
            }
            if(ok){
                ax = dx;
                ay = dy;
            }
        }

        cout << ax << " " << ay << endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int i_max;
  int largest = -1;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] > largest) {
      largest = A[i];
      i_max = i;
    }
  }
  vector<int> B = A;
  sort(B.begin(), B.end());
  for (int i = 0; i < N; i++) {
    if (i == i_max) cout << B[N-2] << endl;
    else cout << B[N-1] << endl;
  }
}


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

int main() {
    int N;
    cin >> N;
    if(N % 1000== 0){
        cout << 0 << endl;
    }
    else
    {
        cout << 1000 - N % 1000 << endl;
    }
    
}

Measured memory_bytes: 3640
import math
a, b, x = map(int, input().split())
v = a ** 2 * b
vx = v - x

x = x / a * 2
vx = vx / a * 2


adig = math.degrees(math.atan(
  vx / (a ** 2)
))
bdig = math.degrees(math.atan(
  (b ** 2) / x
))

if math.tan(math.radians(adig)) * a <= b:
  print(adig)
else:
  print(bdig)


Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
double f[1005][1005],dis[1005],a[1005][3];
bool b[1005];
int main()
{
	int i,j,k,n;
	double xi,xs,ys,xt,yt;
	scanf("%lf%lf%lf%lf",&xs,&ys,&xt,&yt);
	scanf("%d",&n);
	a[0][0]=xs;a[0][1]=ys;a[0][2]=0;
	a[n+1][0]=xt;a[n+1][1]=yt;a[n+1][2]=0;
	for(i=1;i<=n;i++)
		scanf("%lf%lf%lf",&a[i][0],&a[i][1],&a[i][2]);
	n++;
	for(i=0;i<=n;i++)
		for(j=i+1;j<=n;j++){
			f[i][j]=f[j][i]=sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1]))-(a[i][2]+a[j][2]);
			if(f[i][j]<0)
				f[j][i]=f[i][j]=0;
		}
	for(i=0;i<=1003;i++) dis[i]=1e18;
	dis[0]=0; 
	for(i=0;i<n;i++){ 
		xi=1e18;
		k=0; 
		for(j=0;j<=n;j++){
            if(b[j]==0&&dis[j]<xi){ 
				xi=dis[j]; 
				k=j; 
			} 
        }
		b[k]=1; 
		for(j=0;j<=n;j++)
			dis[j]=min(dis[j],dis[k]+f[k][j]);
	}
	printf("%.9lf",dis[n]);
}

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

int main(void){
    int n;
    cin >> n;
    
    int time[501] = {0};
    int c, s, f;
    int i, j;
    for(i = 1; i <= n - 1; i++){
        cin >> c >> s >> f;
        for(j = 1; j <= i; j++){
            while(!(time[j] >= s && time[j] % f == 0)){
                time[j]++;
            }
            time[j] += c;
        }
    }
    
    for(i = 1; i <= n; i++){
        cout << time[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

int i,n ;

int number ;

long long int sum = 0 ;

int min = 0 ;

int max = 0 ;

scanf("%d",&n) ;

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

scanf("%d",&number) ;

if(i==0){

min = number ;

max = number ;

}

if(number<min) min = number ;

if(number>max) max = number ;

sum += number ;

}

printf("%d %d %lld\n",min,max,sum) ;

return 0 ;

}
 

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

#import
#import math
#import numpy as np
N = int(input())
A = list(map(int, input().split()))

def gcd(x, y):
    if x < y:
        t = x
        x = y
        y = t

    if y == 0:
        return x

    else:
        return gcd(y, x % y)

a = gcd(A[0], A[1])

for i in range(2, N):
    a = gcd(a, A[i])

print(a)


Measured memory_bytes: 19788
#include<stdio.h>

int main (){
	int number, A,B,C;
	scanf("%d", &number );
	A = number / 100;
	B = number % 100 / 10;
	C = number % 10;
	if (A == 7 || B == 7 || C == 7)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	
	return 0;
}

Measured memory_bytes: 1644