akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second
 
template<class T> bool ckmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<class T> bool ckmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

const int N = 1e5;
vi adj[N+1];
int dist1[N+1];
int dist2[N+1];
//dist2 je v tj. Aoki
//dist1 je u tj. Takahashi

void dfs(int *dist, int s, int p = -1)
{
    if(p == -1)
        dist[s] = 0;
    else
        dist[s] = dist[p] + 1;
    for(auto e : adj[s])
    {
        if(e == p)
            continue;
        dfs(dist, e, s);
    }
}

int ans = 0;

void dfs2(int s, int p = -1)
{
    ckmax(ans, dist2[s]);
    for(auto e : adj[s])
    {
        if(e == p)
            continue;
        if(dist1[e] <= dist2[e])
            dfs2(e, s);
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n, u, v;
    cin >> n >> u >> v;

    for(int i = 0; i < n-1; ++i)
    {
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    dfs(dist1, u);
    dfs(dist2, v);

    dfs2(u);

    cout << ans-1 << "\n";
}


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

int main(){
  int n, m;
  cin >> n >> m;
  long long ans = 0;
  vector<pair<long long, long long>> a(n);
  for(int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++){
    if(a[i].second <= m){
      ans += a[i].first * a[i].second;
      m -= a[i].second;
    }else{
      ans += m * a[i].first;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4812
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
using namespace std;

int main() {
	int a, b;
	string s;
	cin >> a >> b;
	cin >> s;
	for (int i = 0; i < a + b + 1; i++) {
		if (i != a) {
			if (s[i] != '0'&&s[i] != '1'&&s[i] != '2'&&s[i] != '3'&&s[i] != '4'&&s[i] != '5'&&s[i] != '6'&&s[i] != '7'&&s[i] != '8'&&s[i] != '9') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (s[i] != '-') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import itertools

operator = ["+", "-", "*"]
form1 = "(({} {} {}) {} ({} {} {}))"
form2 = "((({} {} {}) {} {}) {} {})"

def command(x, y, z):
	if z == "+" : return x + y
	if z == "-" : return x - y
	if z == "*" : return x * y

def isExpression(var):
	a,b,c,d = map(int,var)
	for first in operator:
		ans1 = command(a, b, first)
		for second in operator:
			ans2 = command(c, d, second)
			ans3 = command(ans1, c, second)
			for third in operator:
				if command(ans1, ans2, third) == 10:
					return form1.format(a, first, b, third, c, second, d)
				if command(ans3, d , third)   == 10:
					return form2.format(a, first, b, second, c, third, d)
	return "0"

while True:
	num = map(int,raw_input().split())
	if num == [0, 0, 0, 0] : break
	
	num = list(itertools.permutations(num, 4))
	
	source = "0"
	for var in num:
		source = isExpression(var)
		if source != "0":
			break
		
	print source

Measured memory_bytes: 6552
#include<stdio.h>
int main(void){
    int a,b,c,d,e;
    int time = 0;
    scanf("%d\n%d\n%d\n%d\n%d\n",&a,&b,&c,&d,&e);
	if      (a < 0 && b < 0) time = c * (b-a);
	else if (a > 0 && b > 0) time = e * (b-a);
	else                     time = c * (-a) + d + e * b;
    printf("%d\n",time);
}



Measured memory_bytes: 2076
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var S = cin.Read;
            WriteLine(S.Equals("ABC") ? "ARC" : "ABC");
        }

    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }


        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 26168
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,num;
  cin >> n;
  while(n!=0){
    num = n % 10;
  	if(num==7){
      cout<<"Yes";
      return 0;
    }
    n = n /10;
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3600
n = int(input())
a = list(map(int,input().split()))

t = sum (a)
ans = 10 ** 10 + 1
X = 0
for i, x in enumerate(a):
    X += x
    Y = t - X
    ans = min(ans, abs(X-Y))
    if i+ 1 == n -1:
        break

print(ans)


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

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

	long long int res = 0;
	int n,t;
	vector <int> v;

	cin >> n;

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

	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			res += v[i]*v[j];
		}
	}

	cout << res << '\n';
	
	return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n) {
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(rall(a));
    rep(i, n) a[i] *= i + 1;
    cout << accumulate(all(a), 0) << endl;
  }
}

Measured memory_bytes: 3032
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class abc075_c{
    public static void Main(){
        string[] str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0]);
        int m = int.Parse(str[1]);
        var edges = new Dictionary<int, List<int>>();
        var inputs = new List<string>();
        for(int i=0; i<m; i++){
            int[] num = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            inputs.Add(string.Format("{0} {1}", num[0]-1, num[1]-1));
        }
        for(int i=0; i<m; i++){
            int[] line = inputs[i].Split(' ').Select(s => int.Parse(s)).ToArray();
            if(edges.ContainsKey(line[0])){
                edges[line[0]].Add(line[1]);
            }
            else{
                edges[line[0]] = new List<int>();
                edges[line[0]].Add(line[1]);
            }
            if(edges.ContainsKey(line[1])){
                edges[line[1]].Add(line[0]);
            }
            else{
                edges[line[1]] = new List<int>();
                edges[line[1]].Add(line[0]);
            }
        }
        int ans = 0;
        /*foreach(var set in edges){
            Console.WriteLine("@@@@@ {0} @@@@@",set.Key);
            Console.WriteLine(string.Join(" ",set.Value));
        }*/
        for(int i=0; i<m; i++){
            var cur = inputs[i].Split(' ').Select(s => int.Parse(s)).ToArray();
            edges[cur[0]].Remove(cur[1]);
            if(!IsConnected(cur[0], cur[1], edges, n)){
                ans++;
                //Console.WriteLine("*****{0} {1}*****", cur[0], cur[1]);
            }
            edges[cur[0]].Add(cur[1]);
        }
        Console.WriteLine(ans);
    }
    public static bool IsConnected(int start, int goal, Dictionary<int, List<int>> edges, int n){
        bool[] already = new bool[n];
        bool ret = false;
        var queue = new Queue<int>();
        queue.Enqueue(start);
        //Console.WriteLine("{0} --------",start);
        while(queue.Count > 0){
            int cur = queue.Dequeue();
            //Console.WriteLine(cur);
            if(cur == goal){
                ret = true;
                break;
            }
            foreach(var v in edges[cur]){
                if(!already[v]){
                    queue.Enqueue(v);
                }
            }
            already[cur] = true;
        }
        return ret;
    }
}


Measured memory_bytes: 19416
#include<stdio.h>
int main()
{
int a;

scanf("%d",&a);



if(a<=599 && a>=400) printf("8");
else if(a<=799 && a>=600) printf("7");
else if(a<=999 && a>=800) printf("6");  
  else if(a<=1199 && a>=1000) printf("5");
  else if(a<=1399 && a>=1200) printf("4");
  else if(a<=1599 && a>=1400) printf("3");
  else if(a<=1799 && a>=1600) printf("2");
  else if(a<=1999 && a>=1800) printf("1");
  
return 0;}

Measured memory_bytes: 1640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int A,B,C,D; cin >> A >> B >> C >> D;

    while (true) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << ln;
            return 0;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << ln;
            return 0;
        }
    }
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int a = 100000000;
	int b = 0;
	string str;cin >> str;
	
	REP(i,str.size())
	{
		if(str[i] == 'C'&& a == 100000000)a = i;
		if(str[i] == 'F')b = i;
	}
	
	if(a<b)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
using namespace std;
int main(){
	while(1){
		int n; int x[10205],y[10205];
		scanf("%d",&n); if(n==0) return 0;
		for(int i=0;i<n;i++) scanf("%d",&x[i]);
		for(int k=0;k<=10000;k++){
			for(int i=0;i<n;i++) if(x[i] != i+1) goto nxt;
			cout << k << endl; break; nxt:; if(k==10000){puts("-1");break;}
			for(int i=0;i<n;i++) y[i] = x[i]-1;
			y[n] = n; int nxt = 0;
			for(int i=0;i<=n;i++) if(y[i] != 0){x[nxt++] = y[i];}
			n = nxt;
		}
	}
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define INF             1e9
#define INFL            1e12
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cout << endl;
#define HOISE           cout << "hoise" << endl
#define PAUSE           system("pause")
#define DEBUG(x)        cout << #x << " = " << x << endl
#define READ            freopen("alu.txt", "r", stdin)
#define WRITE           freopen("vorta.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)

#define MASK(x)         for(int i = 0; i < 8; i++){ if(x&(1<<i)){ cout << i << " "; } } cout << endl;

typedef long long ll;
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pff;

const int MAX = 1e5 + 2;
const int MAXLOG = log2(MAX) + 2;
const int MAXN = 1e6 + 2;
const int MOD = 998244353 ;
const double PY = acos(-1.0);

void solve()
{
    ll n;
    cin >> n;
    ll a, b;
    cin >> a >> b;

    ll majhe = b-a-1;
    if(majhe%2 == 1){
        cout << (majhe+1)/2;
        return;
    }

    ll dis1 = a-1 + 1 + majhe/2;
    ll dis2 = n-b + 1 + majhe/2;
    cout << min(dis1, dis2);
}

int32_t main()
{
//    READ;
//    WRITE;
    FASTIO;

    solve();

//    int tc;
//    cin >> tc;
//    for(int nc = 1; nc <= tc; nc++){
//        solve();
//    }

    return 0;
}



Measured memory_bytes: 256
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(d)]
t = [int(input()) for i in range(d)]
ans = 0
l = [0 for i in range(26)]
for i in range(d):
    ans += s[i][t[i] - 1]
    l = list(map(lambda x:x+1, l))
    l[t[i] - 1] = 0
    for j in range(26):
        ans -= c[j] * l[j]
    print(ans)

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

using namespace std;

int main() {
  long long n;
  cin>>n;
  vector<long long> l(n);
  for(long long i=0;i<n;i++){
    cin>>l[i];
  }
  long long ans=0;
  for(long long i=0;i<n-2;i++){
    for(long long j=i+1;j<n-1;j++){
      for(long long k=j+1;k<n;k++){
        if(l[i]<l[j]+l[k]&&l[j]<l[i]+l[k]&&l[k]<l[i]+l[j]){
          if(l[i]!=l[j]&&l[j]!=l[k]&&l[i]!=l[k]){
          ans++;
          }
        }
      }
    }
  }
  cout<<ans<<endl;
  

  
}

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

using namespace std;

int memo[200005];

const int INF = 100000000;

int main(void)
{
	int n;
	cin >> n;
	int f, s;
	f = -INF, s = -INF;
	int fp = 0;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		memo[i] = a;
		if (f < a)
		{
			f = a;
			fp = i;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		if (s < memo[i] && i != fp)
		{
			s = memo[i];
		}
	}
	for (int i = 0; i < n; ++i)
	{
		if (i != fp)
		{
			cout << f << endl;
		}
		else
		{
			cout << s << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 2432
import bisect

N = int(input())
Red = [tuple(map(int, input().split())) for _ in range(N)]
Blue = [tuple(map(int, input().split())) for _ in range(N)]
Done = [False] * N
Red.sort()
Blue.sort()
Redx = []
Redy = []
ans = 0
for x, y in Red:
    Redx.append(x)
    Redy.append(y)

for x, y in Blue:
    i = bisect.bisect_left(Redx, x)
    m = -1
    num = -1
    for j in range(i):
        if Redy[j] >= y or Done[j]:
            continue
        if Redy[j] > m:
            m = Redy[j]
            num = j
    if num != -1:
        ans += 1
        Done[num] = True
print(ans)




Measured memory_bytes: 67144
import Foundation
let N = Int(readLine()!)!
let a = readLine()!.split(separator: " ").map({Int($0)!})
var count = 0

for i in 0 ..< N {
    if (a[i].isMultiple(of: 2) != true) &&  Int(i).isMultiple(of: 2){
        count += 1
    }
}
print(count)

Measured memory_bytes: 13420
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;
int n,d;
int x[12][12];

int main(void){
    int ans=0;
    cin>>n>>d;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>x[i][j];
        }
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            int num=0;
            for(int k=0;k<d;k++){
                num+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            int l=0;
            while(true){
                if(l*l<num)l++;
                else{
                    if(l*l==num){
                        ans++;
                        break;
                    }
                    else break;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <iostream>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <math.h>
#include <cmath>
#include <stack>
#include <algorithm>
#include <list>
#include <array>
#include <valarray>
#include <unordered_map>
#include <cassert>
#include <random>
#include <cstring>
#include <bitset>

using namespace std;

typedef long double ld;
typedef long long li;
typedef vector<li> vec;
typedef vector<vector<li>> mt;
typedef pair<li, li> pll;

#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

double eps = 1e-9;
const int INF = 1e9 + 7;
const li LINF = 1e18 + 7;

int get(int x) {
	int res = 0;
	while (x) {
		res += x % 10;
		x /= 10;
	}

	return res;
}

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	int n;
	cin >> n;

	int ans = INF;

	for (int a = 1; a < n; ++a) {
		int b = n - a;

		ans = min(ans, get(a) + get(b));
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
R=list(list(map(int,input().split())) for _ in range(M))
S=[i for i in range(2,N+1)]

import itertools
count=0
for p in itertools.permutations(S):
  damage=0
  p=list(p)
  q=[1]
  for j in range(N-1):
    q.append(p[j])
  for i in range(N-1):
    if not([q[i],q[i+1]] in R) and not([q[i+1],q[i]] in R):
      damage=1
  if not(damage):
    count+=1


print(count)


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());

  int total = 0;
  for (int i = 0; i < N; i++) total += A[i];
  for (int i = 0; i < N; i++) if (total % 2 == 1 && A[i] % 2 == 1) total -= A[i];

  cout << total / 2 << endl;
}


Measured memory_bytes: 3168
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;

int main(){
  char s;
  cin >> s;

  if(s=='a') cout << "vowel" << endl;
  else if(s=='i') cout << "vowel" << endl;
  else if(s=='u') cout << "vowel" << endl;
  else if(s=='e') cout << "vowel" << endl;
  else if(s=='o') cout << "vowel" << endl;
  else cout << "consonant" << endl;

  return 0;
}


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


public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = new BufferedReader(
				new InputStreamReader(System.in));

		String line = breader.readLine();
		int num = Integer.valueOf(line);
		line = breader.readLine();
		String[] snum = line.split(" ");
		int max = Integer.valueOf(snum[0]);
		int min = max;
		long sum = max;
		for( int i = 1 ; i < num ; i++ ){
			int n = Integer.valueOf(snum[i]);
			if ( max < n ) {
				max = n;
			}
			if ( min > n ) {
				min = n;
			}
			sum += n;

		}
		System.out.println( min + " " + max + " " + sum);

	}

}

Measured memory_bytes: 25564
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[101010], Q;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	map<int, int> cnt;
	ll tot = 0;
	rep(i, 0, N) {
		cnt[A[i]]++;
		tot += A[i];
	}

	cin >> Q;
	rep(_, 0, Q) {
		int B, C; cin >> B >> C;

		tot += 1LL * (C - B) * cnt[B];
		cnt[C] += cnt[B];
		cnt[B] = 0;

		printf("%lld\n", tot);
	}
}







Measured memory_bytes: 8436
#include <stdio.h>
int main (){
 
  int n,a,b,c,i,j,result;
 
  scanf("%d",&n);
 
  for(i = 0; i < n; i++){
 
    result=0;
    scanf("%d %d %d",&a,&b,&c);
 
    while(a >= 1 && b >= 1 && c >= 1){
 
      result++;
      a--;
      b--;
      c--;
 
    }
 
    while(a >= 2 && b >= 1){
 
      result++;
      a -= 2;
      b--;
 
    }
 
    result += a/3;
 
    printf("%d\n",result);\
 
  }
 
  return 0;
 
}

Measured memory_bytes: 2672
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

A,B,DEGREE = map(int,input().split())

rad = math.radians(DEGREE)

S = A*B*math.sin(rad)/2.0
C = math.sqrt(A*A+B*B-2*A*B*math.cos(rad))
h = 2*S/A

print("%.10f %.10f %.10f"%(S,A+B+C,h))



Measured memory_bytes: 6424
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
int main() {
    // input
    int n; scanf("%d", &n);
    vector<int> a(n); repeat (i,n) scanf("%d", &a[i]);
    whole(sort, a);
    whole(reverse, a);
    // compute
    int z = 0;
    assert (z < n and z < a[z]);
    while (z+1 < n and z+1 < a[z+1]) ++ z;
    int dy = a[z] - z - 1;
    int dx = 0;
    while (z + dx+1 < n and z < a[z + dx+1]) ++ dx;
    bool result = (dy % 2 == 1) or (dx % 2 == 1);
    // output
    printf("%s\n", result ? "First" : "Second");
    return 0;
}

Measured memory_bytes: 640
#include <string>
#include <vector>
#include <iostream>

#pragma warning(disable : 4996)

#define mod 100000

using namespace std;

int H, W, dp[2][1 << 19][2][2]; string M[20];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	for (int i = 0; i < H; i++) cin >> M[i];

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	int maxbits = 1 << (W - 1);

	for (int i = 0; i < H * W - 1; i++)
	{
		for (int j = 0; j < maxbits; j++)
		{
			dp[(i ^ 1) & 1][j][0][0] = 0;
			dp[(i ^ 1) & 1][j][0][1] = 0;
			dp[(i ^ 1) & 1][j][1][0] = 0;
			dp[(i ^ 1) & 1][j][1][1] = 0;
		}

		for (int j = 0; j < maxbits; j++)
		{
			char c = M[(i + 1) / W][(i + 1) % W];

			int nxt = (j << 1) % (1 << (W - 1));

			int sum0 = (dp[i & 1][j][0][0] + dp[i & 1][j][1][0]) % mod;
			int sum1 = (dp[i & 1][j][0][1] + dp[i & 1][j][1][1]) % mod;

			if (c == 'J' || c == '?')
			{
				dp[(i ^ 1) & 1][nxt][0][0] += sum0;
				dp[(i ^ 1) & 1][nxt][0][1] += sum1;
			}

			if (c == 'O' || c == '?')
			{
				if ((M[i / W][i % W] == 'J' || M[i / W][i % W] == '?') && i % W != W - 1)
				{
					dp[(i ^ 1) & 1][nxt + 1][1][0] += dp[i & 1][j][0][0];
					dp[(i ^ 1) & 1][nxt + 1][1][1] += dp[i & 1][j][0][1];

					dp[(i ^ 1) & 1][nxt + 1][1][0] %= mod;
					dp[(i ^ 1) & 1][nxt + 1][1][1] %= mod;

					dp[(i ^ 1) & 1][nxt][1][0] += (sum0 - dp[i & 1][j][0][0] + mod);
					dp[(i ^ 1) & 1][nxt][1][1] += (sum1 - dp[i & 1][j][0][1] + mod);
				}
				else
				{
					dp[(i ^ 1) & 1][nxt][1][0] += sum0;
					dp[(i ^ 1) & 1][nxt][1][1] += sum1;
				}
			}

			if (c == 'I' || c == '?')
			{
				if (j & (1 << (W - 2)))
				{
					dp[(i ^ 1) & 1][nxt][1][1] += sum0;
				}
				else
				{
					dp[(i ^ 1) & 1][nxt][1][0] += sum0;
				}

				dp[(i ^ 1) & 1][nxt][1][1] += sum1;
			}

			dp[(i ^ 1) & 1][nxt][1][0] %= mod;
			dp[(i ^ 1) & 1][nxt][1][1] %= mod;
		}
	}

	int ret = 0;

	for (int i = 0; i < maxbits; i++)
	{
		ret += dp[(H * W - 1) % 2][i][0][1];
		ret += dp[(H * W - 1) % 2][i][1][1];

		ret %= mod;
	}

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

	return 0;
}

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

using namespace std;

#define rep(i,n,m) for(int i=n;i<(int)(m);i++)


int main() {
	
	string a, b, c;

	cin >> a >> b >> c;



	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}



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

const int maxN = 1e4 + 5;

string replace(string s,char a,char b) {
  for(auto &c : s)
    if(c == a) c = b;
  return s;
}

int N;
string S[maxN], T;

int main() {
  if(fopen("input.txt","r")) {
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  }
  
  std::cin >> N;
  for(int i = 1;i <= N; ++i)
    std::cin >> S[i];
  std::cin >> T;
  
  int a = 0, b = 0;
  for(int i = 1;i <= N; ++i) {
    string s = S[i];
    
    // if(s.size() == T.size()) {
    //   bool flag = true;
    //   for(int i = 0;i < (int) s.size(); ++i)
    // 	if(s[i] != '?' && s[i] != T[i]) flag = false;
    //   if(flag) continue;
    // }
    string s0 = replace(s, '?', 'a');
    string s1 = replace(s, '?', 'z');
    
    //assert(s0 <= s1);
    
    if(s1 < T) ++a;
    if(s0 > T) ++b;
  }

  for(int i = a + 1;i < N+1-b; ++i)
    printf("%d ", i);
  printf("%d\n", N+1-b);
  
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVVld = vector<VVld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  int N; cin >> N;
  VV a(N, V(N));
  rep(i, N) rep(j, N) cin >> a[i][j];

  int M = 1<<N;
  V dp(M);
  dp[0] = 1;

  rep2(bit, 1, M) {
    int n = __builtin_popcount(bit);
    rep(i, N) {
      if (bit>>i&1) {
        (dp[bit] += a[n-1][i] * dp[bit-(1<<i)]) %= MOD;
      }
    }
  }

  int ans = dp[M-1];
  cout << ans << endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

int main()
{
	char c;
	ll h,w,cnt=0;
	ll dx[]={0,-1,1,0};
	ll dy[]={-1,0,0,1};
	queue<pair<ll,ll>> q;
	cin >> h >> w;
	vvll v(h,vll(w,-1));
	rep(i,h){
		rep(j,w){
			cin >> c;
			if(c=='#'){
				v[i][j]=-2;
				cnt++;
			}
		}
	}
	v[0][0]=1;
	q.push(m_p(0,0));
	while(!q.empty()){
		pair<ll,ll> tmp=q.front();
		q.pop();
		rep(i,4){
			ll yy=tmp.first+dy[i];
			ll xx=tmp.second+dx[i];
			if(yy<0 || yy>=h || xx<0 || xx>=w) continue;
			if(v[yy][xx]==-1){
				v[yy][xx]=v[tmp.first][tmp.second]+1;
				q.push(m_p(yy,xx));
			}
		}
	}
	if(v[h-1][w-1]==-1) cout << -1 << endl;
	else cout << h*w-v[h-1][w-1]-cnt << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
DP=[[0]*(N+1) for i in range(4)]
for i in range(3):
  for j in range(N+1):
    DP[i+1][j]=max(DP[i][j],DP[i+1][j])
    if j+A[i]<=N:
      DP[i][j+A[i]]=max(DP[i][j+A[i]],DP[i][j]+B[i])
for i in range(N+1):
  N=max(N,i+DP[3][-i-1])
DP=[[0]*(N+1) for i in range(4)]
for i in range(3):
  for j in range(N+1):
    DP[i+1][j]=max(DP[i][j],DP[i+1][j])
    if j+B[i]<=N:
      DP[i][j+B[i]]=max(DP[i][j+B[i]],DP[i][j]+A[i])
for i in range(N+1):
  N=max(N,i+DP[3][-i-1])
print(N)

Measured memory_bytes: 852968
x, y, arg = 0, 0, 90 * Math::PI / 180

while gets
  r, deg = $_.split(",").map(&:to_i)
  x += r * Math.cos(arg)
  y += r * Math.sin(arg)
  arg -= deg * Math::PI / 180
end

puts x.to_i, y.to_i

Measured memory_bytes: 6168
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,a;
vector<P> v;
int main(void){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        v.push_back({a,i});
    }
    sort(v.begin(),v.end());
    for(auto x:v){
        cout<<x.second<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 2544
def spaceinput():
    return list(map(int,input().split(" ")))


N,M=spaceinput()

sima=[]
for i in range(M):
    sima.append(spaceinput())


sima=sorted(sima,key=lambda x:x[0])

#print(sima)

blr=[0,0]

count=0
for i in range(M):
    if sima[i][0]>=blr[1]:
        count+=1
        blr=sima[i][:]
    elif blr[1]>=sima[i][1]:
        blr[0]=sima[i][0]
        blr[1]=sima[i][1]

    else:
        blr[0]=sima[i][0]


print(count)


Measured memory_bytes: 29920
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    const ll MOD = 1e9+7;
    int N;
    cin >> N;
    vector<ll> x(N);
    for(auto& e: x) cin >> e;

    ll ans = 1;
    ll m = 0;
    for(auto& e: x){
        ans *= m+1;
        ans %= MOD;
        m = min(m+1, (e-1)/2+1);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    string s; cin >> s;
    // ll n = s.size();
    vector<ll> cumsum(n + 1);
    rep (i, n) cumsum[i + 1] = cumsum[i] + (s[i] == '#');
    ll ans = (ll)1e18;
    rep (i, n + 1) {
        chmin(ans,
            cumsum[i] + (n - i - (cumsum[n] - cumsum[i])));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5100
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
vector<vector<int>> happy(100010, vector<int>(3,0));
vector<vector<int>> dp(100010, vector<int>(3, 0));


int main(){
    cin >> n;
    rep(i, n){
        rep(j, 3){
            cin >> happy[i][j];
        }
    }
    
    rep(i, n){
        rep(j, 3){
            rep(k, 3){
                if(j == k) continue;
                chmax(dp[i+1][j], dp[i][k] + happy[i][j]);
            }
        }
    }

    int ans = max(max(dp[n][0], dp[n][1]), dp[n][2]);
    cout << ans << ln;
}
    

Measured memory_bytes: 11136
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	string str;
	cin >> str;
	int K;
	cin >> K;
	int size = str.size();
	for(int i=0;i<size;++i){
		if( str[i] == 'a' ) continue;
		int num = 26 - (str[i]-'a');
		if( num <= K ){
			str[i] = 'a';
			K -= num;
		}
	}
	if( K ){
		int num = ((str[size-1]-'a')+K)%26;
		str[size-1] = (char)('a'+num);
	}
	cout << str << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 592
unittest
{
	assert( [ "575" ].parse.expand.solve == 4 );
	assert( [ "3600" ].parse.expand.solve == 13 );
	assert( [ "999999999" ].parse.expand.solve == 26484 );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	return solve2( n, 0, 0, 0 );
}

long solve2( long m, long n, long d, byte f )
{
	auto dd = 10L ^^ d;
	auto r = 0L;
	
	if( f == 0b111 ) r += 1;
	
	auto n3 = n + 3L * dd;
	if( n3 <= m )
	{
		r += solve2( m, n3, d + 1, f | 0b100 );

		auto n5 = n + 5L * dd;
		if( n5 <= m )
		{
			r += solve2( m, n5, d + 1, f | 0b010 );
		
			auto n7 = n + 7L * dd;
			if( n7 <= m )
			{
				r += solve2( m, n7, d + 1, f | 0b001 );
			}
		}
	}
	
	return r;
}


Measured memory_bytes: 256
#ABC120B-K-thCommonDivisor.py

from sys import stdin

input = stdin.readline

A, B, K = list(map(int, input().split()))

commonDivisor = []

for i in range(1,101):
    if A % i == 0 and B % i == 0:
        commonDivisor.append(i)

print(commonDivisor[-K])


Measured memory_bytes: 2940
#include <stdio.h>
struct tree{
  int num;
  int k;
  int c;
  int s;
  int p;
  int d;
};

int main(){

  int n,i,j,k,c,el,pa,pc,in;
  struct tree id[100000];
  scanf("%d",&n);//ノードの数
  for(i=0;i<n;i++){
    id[i].p=-1;
  }

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

    scanf("%d",&in);
      scanf("%d",&id[in].k);//自分の番号、子供の数
    id[in].num=in;
  


    for(j=0;j<id[in].k;j++){

      if(j==0){ 
	scanf("%d",&id[in].c);//子供1の番号
	id[id[in].c].p=id[in].num;
	el=id[in].c;

      }

      else{
	scanf("%d",&id[el].s);//兄弟の番号
	el=id[el].s;
	id[el].p=id[in].num;
       
      }
    }

  }
 

  for(i=0;i<n;i++){
    if(id[i].p==-1)id[i].d=0;
   
    else {
    pa=id[i].p;
    pc=1;


   
      while(id[pa].p!=-1){
 
      pc++;
      pa=id[pa].p;
      }

  


    id[i].d=pc;
    }
  }
 


  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d,",i,id[i].p,id[i].d);
    if(id[i].p==-1) printf(" root, ");
    else if(id[i].k!=0)printf(" internal node, ");
    else printf(" leaf, ");
    
   

    printf("[");
    
    if(id[i].k!=0){ printf("%d",id[i].c);
      el=id[i].c;
    }
    if(id[i].k>=2){
      for(j=0;j<id[i].k-1;j++){
   
	if(j==id[i].k-2)  printf(", %d",id[el].s);
	else printf(", %d",id[el].s);
	el=id[el].s;
	//  if(id[i].k==3) printf("%d,",id[id[id[i].c].s].s);
      }

    }
printf("]\n");
  }
    return 0;
}

Measured memory_bytes: 2960
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#define maxn 1010
#define INF 0x3f3f3f3f
#define LL long long
#define ULL unsigned long long
#define E 1e-8
#define mod 1000000007
#define P pair<int,int>
using namespace std;
int main()
{
    int a[3];
    while(cin>>a[0]>>a[1]>>a[2])
        {
            int sum = 0,sum2 = 0;
        for(int i=0;i<3;i++){
            if(a[i] == 5)
            sum++;
        else
            if(a[i] == 7)
            sum2++;
        }
        if((sum == 2) && (sum2 == 1))
            cout << "YES" <<endl;
        else
            cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
from collections import deque

def dfs(corrent, cnt):
  if cnt == N-1:
    return 1
  visited[corrent] = True
  ret = 0
  for to in graph[corrent]:
    if visited[to] == True:
      continue
    ret += dfs(to, cnt+1)
  visited[corrent] = False
  return ret


N, M = map(int, input().split())
graph = [[] for _ in range(N)]

ans = 0
visited = [False]*(N)

for _ in range(M):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  graph[x].append(y)
  graph[y].append(x)

print(dfs(0, 0))

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

// types
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;

  vll a(n), b(n);
  REP(i, n)
    cin >> a[i];
  REP(i, n)
    cin >> b[i];

  ll sum = 0;
  ll cnt = 0;
  vll t(n);
  REP(i, n){
    t[i] = a[i]-b[i];
    if(t[i] < 0){
      cnt++;
      sum += -t[i];
    }
  }

  sort(t.begin(), t.end(), greater<ll>());
  ll i = 0;
  while(sum > 0 && i < n){
    sum -= t[i];
    cnt++;
    i++;
  }

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


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int X, A;
    cin >> X >> A;
    if(X < A) {
        printf("0\n");
    }
    else {
        printf("10\n");
    }
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
//typedef vector<vector<int> > matrix;
 
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
 
#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
 
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD=998244353;
const ll hell=1000000007;
const int INF = 1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);
 
double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };
 
const int N=200005;

int dp[3005][3005];
int pre[3005];
void solve()
{
int n;
cin>>n;
string s;
cin>>s;
dp[1][1]=1;

for(int i=2;i<=n;i++)
{
pre[0]=dp[i-1][0];
for(int j=1;j<=n;j++)
pre[j]=(pre[j-1]+dp[i-1][j])%hell;
if(s[i-2]=='>')
{
       for(int j=1;j<=i-1;j++)
       {
           dp[i][j]=(pre[i-1]-pre[j-1]+hell)%hell;
       }
}
else
{
    for(int j=2;j<=i;j++)
    {
        dp[i][j]=pre[j-1];
    }
}
}
int ans=0;
for(int i=1;i<=n;i++)
ans=(ans+dp[n][i])%hell;
cout<<ans<<endl;


}

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

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 1e9+7;

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

  cout << (n+1)/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" : "<<x<<'\n';
#define int long long
#define PI 3.141592653589793238

int get(int x){
	int t_ans = sqrt(2*x);
	if(t_ans*(t_ans+1)<=2*x)
		return t_ans;
	else
		return t_ans-1;
}

void solve()
{
	int n; cin>>n;
	vector<int> p;
	int cnt=0;
	while(n%2==0){
		n/=2;
		cnt++;
	}
	if(cnt)
		p.push_back(cnt);
	for(int i=3;i*i<=n;i+=2){
		cnt=0;
		while(n%i==0){
			n/=i;
			cnt++;
		}
		if(cnt) p.push_back(cnt);
	}
	if(n>1)
		p.push_back(1);
	int final_ans = 0;
	for(int i=0;i<p.size();i++){
		final_ans+=get(p[i]);
	}
	cout<<final_ans<<'\n';
}

main()
{
	int t=1;
	while(t--)
		solve();
}

Measured memory_bytes: 3724