akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  int n[5];

  REP(i, 5) cin >> n[i];
  sort(n, n+5, greater<int>());

  REP(i, 4) cout << n[i] << ' ';
  cout << n[4] << endl;
}

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

void print_preorder(const vector<pair<int, int> >& nodes, const vector<int>& node_val, const int r){
  if(r<0) return;
  cout << ' ' << node_val[r];
  print_preorder(nodes, node_val, nodes[r].first);
  print_preorder(nodes, node_val, nodes[r].second);
}
 
void print_inorder(const vector<pair<int, int> >& nodes,  const vector<int>& node_val, const int r){
  if(r<0) return;
  print_inorder(nodes, node_val, nodes[r].first);
  cout << ' ' << node_val[r];
  print_inorder(nodes, node_val, nodes[r].second);
}
   
 
void print_postorder(const vector<pair<int, int> >& nodes, const int r, int geta, bool& first_print){
  if(r<0) return;
  print_postorder(nodes, nodes[r].first, geta, first_print);
  print_postorder(nodes, nodes[r].second, geta, first_print);
  
  cout << (first_print ? "": " ")  << (r+geta);
  first_print = false;
}
 
int main(){
  std::ios_base::sync_with_stdio(false);
 
  int n, r=-1, h=0;
  cin >> n;
  vector<pair<int, int> > nodes(n);
  vector<int> node_val(n, 0);
  
 
  for(int i=0; i<n; ++i){
    string inst;
    cin >> inst;
    if(inst[0] == 'p'){ //print
      print_inorder(nodes, node_val, r);
      cout << endl;
      print_preorder(nodes, node_val, r);
      cout << endl;
    }
    else if(inst[0] == 'i'){
      int v;
      cin >> v;
      
      if (h == 0) {
	r = h;
	node_val[h] = v;
	nodes[h].first = nodes[h].second = -1;
	++h;
	continue;
      }

      //h>0, r>=0
      node_val[h] = v;
      nodes[h].first = nodes[h].second = -1;
      
      int* p = &r;
      while(*p >= 0){
	if(node_val[*p] > node_val[h]){
	  p = &(nodes[*p].first);
	}
	else{
	  p = &(nodes[*p].second);
	}
      }
      
      //*p < 0
      *p = h;
      ++h;
    }
    else{
      cout << "?" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 7008
/* 
    Author : Jeff Ahn
    Sun 02 Aug 2020 05:02:54 AM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'

int n, d;

signed main() {
  fastio;
  cin >> n >> d;
  int res = 0;
  rep(i, n) { 
    int x, y;
    cin >> x >> y;
    if (x*x + y*y <= d*d) res++;
  }
  cout << res << endl;

}


Measured memory_bytes: 3648
integer :: n, i, j, ans = 0, z(5000) = 0
character(5000) :: s
read*, n
read*, s
do i = 1, n-1
  z(i:n) = z_algorithm(s(i:n))
  !i 今回のダジャレの前句の起点
  !j 今回のダジャレの後句の起点
  !あいあいあーの場合
  !i=1,j=3のときにz=3となっているが真ん中のあが被ってしまう為j-iと比べて小さい方を採用する必要がある
  do j = i+1, n
    ans = max(ans,min(j-i,z(j)))
  end do
end do

print"(I0)",ans

contains

function z_algorithm(s) result(z)
  character(*) :: s
  integer :: z(len_trim(s)), n, i, j, k
  z=0
  n=len_trim(S)
  z(1) = n
  i = 1
  j = 0
  do while (i < n)
    do while (i+j < n .and. s(j+1:j+1) == s(i+j+1:i+j+1))
      j = j+1
    end do
    z(i+1) = j
    if (j == 0) then
      i = i+1
      cycle
    end if
    k = 1
    do while (i+k < n .and. k + z(k+1) < j)
      z(i+k+1) = z(k+1)
      k = k+1
    end do
    i = i+k
    j = j-k
  end do
end function
end

Measured memory_bytes: 768
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n;
vector<P> g[100010];
int c[100010];
int k;
void dfs(int x, int p, int cp){
	int c1=1;
	for(auto q:g[x]){
		int y=q.first;
		if(y==p) continue;
		if(c1==cp) c1++;
		c[q.second]=c1;
		dfs(y, x, c1);
		c1++;
	}
}
int main()
{
	cin>>n;
	for(int i=0; i<n-1; i++){
		int a, b;
		cin>>a>>b;
		a--; b--;
		g[a].push_back({b, i});
		g[b].push_back({a, i});
	}
	for(int i=0; i<n; i++){
		k=max(k, (int)g[i].size());
	}
	dfs(0, -1, -1);
	cout<<k<<endl;
	for(int i=0; i<n-1; i++){
		cout<<c[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 9344
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int PopStack(vector<int> &vec){
    int out;
    out = vec.back();
    //cout << "pop: " << out << endl;
    vec.pop_back();
    return out;
}

int main(){
    char formula[1000];
    int temp;
    vector<int> stack_num;

    while( scanf("%s", formula) != EOF ){
        if(formula[0]=='+'){
            
            temp = PopStack(stack_num) + PopStack(stack_num);
            stack_num.push_back(temp);
            //cout << "+  " << temp << endl;
        } else if(formula[0] == '-'){
            
            temp = PopStack(stack_num) - PopStack(stack_num);
            temp = -temp;
            stack_num.push_back(temp);
            //cout << "-  " << temp << endl;
        } else if(formula[0] == '*'){
            
            temp = PopStack(stack_num)*PopStack(stack_num);
            stack_num.push_back(temp);
            //cout << "*  " << temp << endl;
        }else
        {
            temp = atoi(formula);
            stack_num.push_back(temp);
            //cout << formula << endl;
        }
    }
    cout << stack_num.back() << endl;

    return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int dp[50][500][500];

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

    int N, A, B;
    cin >> N >> A >> B;
    vector<int> a(N), b(N), c(N);
    for(int i = 0; i < N; ++i)  cin >> a[i] >> b[i] >> c[i];
    for(int i = 0; i <= N; ++i){
        for(int j = 0; j <= 400; ++j){
            for(int k = 0; k <= 400; ++k){
                dp[i][j][k] = INF;
            }
        }
    }
    dp[0][0][0] = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j <= 400; ++j){
            for(int k = 0; k <= 400; ++k){
                if(dp[i][j][k] == INF)  continue;
                chmin(dp[i + 1][j][k], dp[i][j][k]);
                chmin(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
            }
        }
    }
    int ans = INF;
    for(int i = 1; max(A, B) * i <= 400; ++i){
        chmin(ans, dp[N][A * i][B * i]);
    }
    if(ans == INF)  ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 35860
str = gets.chomp
replace_ans = 0
reverse_ans = 0
print_ans   = ''
ans_arr = []
i = 0

gets.to_i.times {
  line = gets.chomp
  if line.include?("replace")
    replace_arr = []
    replace_arr = line.split
    replace_first_num = replace_arr[1].to_i
    replace_end_num   = replace_arr[2].to_i
    replace_str       = replace_arr[3]
    str[replace_first_num..replace_end_num] = replace_str
    replace_ans = str

  elsif line.include?("reverse")
    reverse_arr = []
    reverse_arr = line.split
    reverse_first_num = reverse_arr[1].to_i
    reverse_end_num  = reverse_arr[2].to_i
    str[reverse_first_num..reverse_end_num] = str[reverse_first_num..reverse_end_num].reverse
    reverse_ans = str

  else
    print_arr = []
    print_arr = line.split
    line_first_num = print_arr[1].to_i
    line_end_num   = print_arr[2].to_i
    ans_arr[i] = str[line_first_num..line_end_num]
    i += 1
  end

}

ans_arr.each do |str|
  puts str
end



Measured memory_bytes: 6920
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fastin ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
ll ans,n;
int main(){
	cin>>n;
	rep(i,1,n){
		ans+=((n-1ll)/(ll)i);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3748
let () =
  let n, m, x = Scanf.scanf "%d %d %d" (fun n m x -> n, m, x) in
  let a = Array.init m (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let (l, r) =  Array.fold_left (fun (l, r) ai  -> if ai < x then (l+1, r) else (l, r+1)) (0,0)  a in
  Printf.printf "%d\n" (if r < l then r else l) 

Measured memory_bytes: 2432
#include<stdio.h>
#include<string.h>
#include<map>
using namespace std;
struct  node
{
	int a;
	int b;
}No[1000000+100];
int root[55];
int find(int now)
{
	if(root[now]>=0)
		return root[now]=find(root[now]);
	return now;
}
int merge(int a,int b)
{
	a=find(a);
	b=find(b);
	if(a!=b)
	{
		if(-root[a]>-root[b])
		{
			root[a]+=root[b];
			root[b]=a;
			return -root[a];
		}
		else
		{
			root[b]+=root[a];
			root[a]=b;
			return -root[b];
		}
	}
	else
		return -root[a];
}
int max(int a,int b)
{
	return a>b ?a:b; 
}
int main()
{
	int N,M;
	scanf("%d %d",&N,&M);
	for(int i=0;i<M;i++)
		scanf("%d %d",&No[i].a,&No[i].b);
	int sum=0;
	for(int i=0;i<M;i++)
	{
		memset(root,-1,sizeof(root));
		int maxx=0;
		for(int k=0;k<M;k++)
			if(k!=i)
				maxx=max(maxx,merge(No[k].a,No[k].b));
		if(maxx==N)
			sum++;
	}
	printf("%d\n",M-sum);
	return 0;
 } 

Measured memory_bytes: 128
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0007&lang=jp

#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  long long x = 100000;
  for (auto i=0; i<n; i++) {
    x *= 1.05;
    if (x%1000 != 0) {
      x = (x/1000 + 1) * 1000;
    }
  }
  cout << x << endl;
}

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

namespace ConsoleApp15
{
    class Class21
    {
        static void Main()
        {
            var nt = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = nt[0], T = nt[1];
            var t = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long sum = 0;
            for(int i = 0; i < N-1; i++)
            {
                if (t[i + 1] - t[i] < T)
                    sum += t[i + 1] - t[i];
                else
                    sum += T;
            }
            sum += T;
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 28384
#include <stdio.h>

int main(void) {
	int n, i;
	long int r[200000];
	scanf("%d", &n);
	for(i = 0; n > i; i++){
		scanf("%ld", &r[i]);
	}
	int small = r[0]+1, maxp = 0;
	long int ans = r[1] - r[0];
	for(i = 0; n-1 > i; i++){
		int j;
		if(small > r[i]){
		small = r[i];
		for(j = i+1; n > j; j++){
			if(ans < r[j] - r[i]) ans = r[j] - r[i];
		}
		}
	}
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 2160
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		long N = sc.nextInt();

		boolean b = false;
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (i*j == N) {
					System.out.println("Yes");
					b = true;
					break;
				}
			}
			if (b) {
				break;
			}
		}

		if (!b) {
			System.out.println("No");
		}
	}
}

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

int main(){
  ll n=0,a=0,b=0,c=0;
  
 cin >> n;
 cin >> a;
 cin >> b;
  c = a * b;
  
  if(c >= n){
   cout << "Yes" <<endl;
  }
  else {
   cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cstdlib>
#include <typeinfo>
#include <list>
#include <stdio.h>
#include <math.h>

using namespace std;

int MAX_R = 10;
int MAX_C = 10000;
vector<vector<int>> gril;

int main() {
//  int gril[MAX_R][MAX_C];
  int r, c;
  int osenbei;
  while(1){
    scanf("%d %d", &r, &c);
    if(r == 0 && c == 0) return 0;
    gril = {};
    for (int i = 0; i < r; i++){
      gril.push_back({});
      for (int j = 0; j < c; j++){
        scanf("%d", &osenbei);
        gril[i].push_back(osenbei);
      }
    }

    int ans = 0;
    for (int mask = 0; mask < (1 << r); mask++) {
      vector<int> sum_of_0(c, 0);

      for (int r_pos = 0; r_pos < r; r_pos++) {
        if (mask & (1 << r_pos)){
          for (int i = 0; i < c; i++) if(gril[r_pos][i] == 1) sum_of_0[i]++;
        }else{
          for (int i = 0; i < c; i++) if(gril[r_pos][i] == 0) sum_of_0[i]++;
        }
      }

      int tmp = 0;
      for (int i = 0; i < c; i++) tmp += max(sum_of_0[i], r - sum_of_0[i]);
      ans = max(ans, tmp);
    }
    printf("%d\n", ans);
  }
  return 0;
}

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

int main() {
	int max = 0;
	int count = 0;
	int n;
	cin >> n;
	long long int h[n];
	for(int i=0;i<n;i++){
		cin >> h[i];
	}
	
	for(int i=0;i<n-1;i++){
		if(h[i]>=h[i+1]){
			count ++;
			if(max < count) max = count;
		}
		else count = 0;
	}
	
	cout << max << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int mex=100001;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
ll int tree[800001];
void update(int n,int l,int r,int pos,int val)
{
    if(l==r&&l==pos) 
    {
        tree[n]=val;
        return;
    }
    if(l>pos||r<pos) return;
    int mid=(l+r)/2;
    update(2*n,l,mid,pos,val);
    update(2*n+1,mid+1,r,pos,val);
    tree[n]=max(tree[2*n],tree[2*n+1]);
}
int query(int n,int l,int r,int l1,int r1)
{
    if(l1<=l&&r1>=r) return tree[n];
    if(l1>r||r1<l) 
    {
        int k=-1e9;
        return k;
    }
    int mid=(l+r)/2;
   int c1= query(2*n,l,mid,l1,r1);
    int c2=query(2*n+1,mid+1,r,l1,r1);
    return max(c1,c2);
}
signed main()
{
    fo(i,0,800001) tree[i]=-1e9;
    ll int n;
    cin>>n;
    vector<pair<ll int,ll int> > v;
    veci v1;
    fo(i,0,n)
    {
        int x,d;
        cin>>x>>d;
        v.pb({x,d});
        v1.pb(x);
    }
    sort(all(v));
    sort(all(v1));
    ll int dp2[n]={0};
    rfo(i,n-1,0)
    {
        int ps=lb(all(v1),v[i].fi+v[i].se)-v1.bg;
        ps--;
        //if(ps==n) dp2[i]=n;
         if(ps==i) dp2[i]=i;
        else dp2[i]=query(1,0,n-1,i,ps);
        //cout<<i<<" "<<ps<<" "<<dp2[i]<<endl;
        update(1,0,n-1,i,dp2[i]);
        
    }
    ll int dp[n+1]={0};
    dp[n]=1;
    
    rfo(i,n-1,0)
    {
       // cout<<dp2[i]<<endl;
        dp[i]=(dp[i+1]+dp[dp2[i]+1])%mod;
    }
    
    dp[0]%=mod;
    cout<<dp[0]<<endl;
}

Measured memory_bytes: 14956
import java.util.*;

public class Main{
  public static long wt[]=new long[101];
  public static int v[]=new int[101];
  public static int n;
  public static long w;
  public static long dp[][]=new long[101][100001];
  public static long go(int value,int index){
    if(index==n){
      if(value==0)
      return 0;
      else
      return 1000000009;
    }
    if(dp[index][value]!=-1){
    return dp[index][value];
    }
    if(v[index]<=value){
      dp[index][value]=Math.min(wt[index]+
        go(value-v[index],index+1),go(value,index+1));
    }
    else{
      dp[index][value]=go(value,index+1);
    }
    return dp[index][value];
  }
  public static long solve(int sum){
    for(int i=0;i<=n;i++){
      for(int j=0;j<=sum;j++)
      dp[i][j]=-1;
    }
    for(int i=sum;i>=0;i--){
      if(go(i,0)<=w){
        return i;
      }
    }
    return 0;
  }
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in); 
    n=sc.nextInt();
    w=sc.nextInt();
    int sum=0;
    for(int i=0;i<n;i++)
    {
      wt[i]=sc.nextLong();
      v[i]=sc.nextInt();
      sum+=v[i];
    }
    System.out.println(solve(sum));
  }
}

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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const ll _INF = 1e18+7;
const int mxn = 1e5+7;

int par[mxn], sz[mxn];

int fpar(int x){
	if (par[x] == x) return x;
	return par[x] = fpar(par[x]);
}

void join(int a, int b){
	a = fpar(a), b = fpar(b);
	if (a != b){
		if (a > b) swap(a, b);
		par[b] = a;
		sz[a] += sz[b];
		sz[b] = 0;
	}
}

int main(){
	setIO();
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) par[i] = i, sz[i] = 1;
	for (int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		join(a, b);
	}
	int cmp = 0;
	for (int i = 0; i < n; i++){
		if (sz[i]) cmp++;
	}
	cout << cmp-1 << endl;
}

Measured memory_bytes: 4432
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define INF (ll)1e9+5
#define dif 0.0000000001
#define pp pair<ll,ll> 
#define vv vector< pair<ll ,ll> > 
#define vi vector<ll> 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

ll n;
vector<ll> adj[100005];

void bfs(ll x,ll dist,vector<ll> &distance)
{
	distance[x]=dist;
	
	for(auto y:adj[x])
	{
		if(distance[y]==-1)
		{
			bfs(y,dist+1,distance);
		}
	}
}

int main() {
	
	cin>>n;
	
	ll u,v,i,a,b;
	vector<ll> f(100005,-1),l(100005,-1);
	
	for(i=1;i<n;i++)
	{
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	
	bfs(1,0,f);
	bfs(n,0,l);
	
	a=b=0;
	
	/*for(i=1;i<n;i++)
	{
		cout<<f[i]<<' ';
	}
	cout<<'\n';
	
	for(i=1;i<n;i++)
	{
		cout<<l[i]<<' ';
	}
	cout<<'\n';*/
	for(i=2;i<n;i++)
	{   
		
		if(f[i]<=l[i])
			a++;
		else
			b++;
	}
	//cout<<a<<' '<<b<<'\n';
	if(a>b)
		cout<<"Fennec";
	else
		cout<<"Snuke";
	// your code goes here
	return 0;
}

Measured memory_bytes: 11904
# def gcd(a_gcd, b_gcd):
#     while b_gcd != 0:
#         a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
#     return a_gcd
#
#
# def lcm(a_lcm, b_lcm):
#     return a_lcm * b // gcd(a_lcm, b_lcm)
#
#
# def max_sum(N_max_sum, a_max_sum):
#     dp = [0] * (N_max_sum + 1)
#     for i in range(N_max_sum):
#         dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
#     return dp[N]
#
#
# def knapsack(N_knapsack, W, weight, value):
#     inf = float("inf")
#     dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
#     for i in range(W+1):
#         dp[0][i] = 0
#
#     for i in range(N_knapsack):
#         for w in range(W+1):
#             if weight[i] <= w:
#                 dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
#             else:
#                 dp[i+1][w] = dp[i][w]
#     return dp[N_knapsack][W]
#
#
# class UnionFind:
#     def __init__(self, n):
#         self.par = [i for i in range(n+1)]
#         self.rank = [0] * (n+1)
#
#     # 検索
#     def find(self, x):
#         if self.par[x] == x:
#             return x
#         else:
#             self.par[x] = self.find(self.par[x])
#             return self.par[x]
#
#     # 併合
#     def union(self, x, y):
#         x = self.find(x)
#         y = self.find(y)
#         if self.rank[x] < self.rank[y]:
#             self.par[x] = y
#         else:
#             self.par[y] = x
#             if self.rank[x] == self.rank[y]:
#                 self.rank[x] += 1
#
#     # 同じ集合に属するか判定
#     def same_check(self, x, y):
#         return self.find(x) == self.find(y)
#
# S = input()
# N = int(input())
# A = list(map(int, input().split()))
# X = [int(input()) for _ in range(N)]

r, D, x = map(int, input().split())

for i in range(1, 11):
    x = r * x - D
    print(x)















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

int main() {
  int N, a;
  cin >> N >> a;
  
  int r = N % 500;
  
  if (r <= a) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

bool g[60][60];
int nNode, nEdge;

int counter;
int visited[60];

int dfs(int u) {
  if(visited[u] == counter) {
    return 0;
  }
  visited[u] = counter;
  int res = 1;
  REP(v, nNode) {
    if(g[u][v]) {
      res += dfs(v);
    }
  }
  return res;
}

int main(void) {
  scanf("%d%d", &nNode, &nEdge);
  REP(i, nEdge) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    g[a][b] = g[b][a] = true;
  }
  int res = 0;
  REP(i, nNode) {
    REP(j, i) {
      if(g[i][j]) {
        g[i][j] = g[j][i] = false;
        ++counter;
        if(dfs(0) != nNode) {
          ++res;
        }
        g[i][j] = g[j][i] = true;
      }
    }
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a,b,c,d,e,i,j,k,l,n,m,x,y,t,p;
    string st;
    cin>>st;
    l=st.size();
    if(st[l-1]=='s')
    {
        st.push_back('e');
        st.push_back('s');
    }
    else
    {
        st.push_back('s');
    }
    cout<<st<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define sort stable_sort 
using namespace std; 

int _; 

int n;
long long money=1000,stock=0,a[105]; 
 
int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",a+i);
	for(int i=0;i<n-1;i++)
	{
		if(a[i] >= a[i+1])
			continue;
		money=money%a[i]+money/a[i]*a[i+1];
	}
	printf("%lld\n",money);
	return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;

  if (((n/10) % 111 ==0) || ((n%1000) % 111 ==0) ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    //Buffet
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] A = new int[n];
        for (int i = 0; i < n; i++) A[i] = sc.nextInt() - 1;
        int[] B = new int[n];
        for (int i = 0; i < n; i++) B[i] = sc.nextInt();
        int[] C = new int[n - 1];
        for (int i = 0; i < n - 1; i++) C[i] = sc.nextInt();
        System.out.println(sln(A, B, C, n));
        sc.close();
    }

    private static int sln(int[] A, int[] B, int[] C, int n) {
        int res = 0;
        for (int i = 0; i < n; i++) {
            res += B[i];
            if (i > 0 && A[i] - A[i - 1] == 1) res += C[A[i] - 1];
        }
        return res;
    }
}


Measured memory_bytes: 25172
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] temp = scanner.nextLine().split(" ");
		long n = Long.parseLong(temp[0]);
		long a = Long.parseLong(temp[1]);
		long b = Long.parseLong(temp[2]);

		double cnt = Math.floor(n / (double)(a + b));
		long ans = (long)cnt * b;


		long diff = n - (long)cnt * (a + b);

		ans += diff > a ? diff - a : 0;

		System.out.println(n - ans);


	}
}

Measured memory_bytes: 35692
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def bin_search(arr,ls,c):
    l=ls-1
    r = len(arr)
    while (r-l) > 1:
        m = l + (r-l)//2
        if arr[m] >= c:
            r = m
        else:
            l = m
    return l-ls+1

def resolve():
    readline=sys.stdin.readline

    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    arr.sort()
    ans=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            c = arr[i] + arr[j]
            ans += bin_search(arr,j+1,c)
    print(ans)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


Measured memory_bytes: 77820
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<string>
#include<cstdio>
using namespace std;
typedef long long LL;
#define For(a,b,c) for(int a=b;a<=c;a++)
#define For_(a,b,c) for(int a=b;a>=c;a--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define debug(x) cout<<#x<<" "<<x<<" "
int read(){
    int r=0,f=1;
    char c=getchar();
    while(!isdigit(c)){
        if(c=='-')
          f=-1;
        c=getchar();
    }
    while(isdigit(c)){
        r=(r<<1)+(r<<3)+c-'0';
        c=getchar();
    }
    return r*f;
}

int main(){
    string s,t;
    cin>>s>>t;
    int ans = 0,l = s.size();
    For(i,0,l-1){
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=105;
int n,tong[N],a[N];
int main(){
	n=read();
	for(int i=1;i<=n;i++)tong[a[i]=read()]++;
	sort(&a[1],&a[n+1]);
	for(int i=a[1]+1;i<=a[n];i++)if(tong[i]<2){
		puts("Impossible"); return 0;
	}
	//cout<<tong[a[1]]<<" "<<((a[n]&1)?2:1)<<endl;
	if(tong[a[1]]!=((a[n]&1)?2:1)){
		puts("Impossible"); return 0;
	}
	puts("Possible"); 
}

Measured memory_bytes: 256
// in the name of Allah

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

const ll mod = 998244353;

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll a, ll b) {
	if(b == 0) return 1;
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

const int N = 2e5 + 5;

int n;
ll a[N];
ll sum[N];
ll dp[N][5];

ll memo(int idx, int st) {

	if(idx == n+1) {
		return 0;
	}

	if(dp[idx][st] != -1) return dp[idx][st];
	ll res = 1e18;
	if(st == 0) {
		res = min(res, memo(idx+1, st) + a[idx]);
		res = min(res, memo(idx, 1));
	}
	else if(st == 1) {
		if(a[idx] > 0) res = min(res, memo(idx+1, st) + (a[idx]%2));
		else res = min(res, memo(idx+1, st) + 2);
		res = min(res, memo(idx, 2));
	}
	else if(st == 2) {
		res = min(res, memo(idx+1, st) + (a[idx]%2 == 0));
		res = min(res, memo(idx, 3));
	}
	else if(st == 3) {
		if(a[idx] > 0) res = min(res, memo(idx+1, st) + (a[idx]%2));
		else res = min(res, memo(idx+1, st) + 2);
		res = min(res, memo(idx, 4));
	}
	else {
		res = min(res, memo(idx+1, st) + a[idx]);
	}
return dp[idx][st] = res;

}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i=1; i<=n; i++) cin >> a[i];
	memset(dp, -1, sizeof dp);
	cout << memo(1, 0) << endl;
	return 0;
}

Measured memory_bytes: 20608
fn main() {
  let mut lines = vec!();
  for i in 0..2 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s);
    let x: Vec<i32> = s.trim().split_whitespace().map(|e| e.parse::<i32>().unwrap()).collect();
    lines.push(x);
  }
  let mons_num = lines.first().unwrap().first().unwrap();
  let skill_num = lines.first().unwrap().last().unwrap();
  let mut mons_hps = lines.last().unwrap().to_owned();
  mons_hps.sort();
  if mons_num <= skill_num {
    println!("0");
  } else {
    mons_hps.split_off((mons_num - skill_num) as usize);
    println!("{:?}",mons_hps.iter().map(|e|*e as u64).sum::<u64>());
  }
}


Measured memory_bytes: 10232
#include <iostream>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>

int main() {
    long long n, b, s;
    std::cin >> n >> s;
    std::bitset<30> k(s);
    std::deque<std::bitset<30>> q;
    q.push_back(k);
    for (auto i = 0; i < 30; i++) {
        if (k[i]) {
            k.flip(i);
            q.push_back(k);
            k.flip(i);
        } else {
            k.flip(i);
        }
    }
    std::vector<long long> ret(q.size());

    //std::for_each(q.begin(), q.end(), [](auto& x) { std::cout << x << std::endl; });

    for (auto j = 0ll; j < n; j++) {
        std::cin >> s >> b;
        std::bitset<30> a(s);
        for (decltype(q.size()) i = 0ll; i < q.size(); i++) {
            if ((q[i] | a) == q[i]) ret[i] += b;
        }
    }

    std::cout << *std::max_element(ret.begin(), ret.end()) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, K;
	cin >> N >> K;
	vector<int> vec(N);
	for(int i = 0; i < N; i++){
		vec.at(i) = 0;
    }
	for(int i = 0; i < K; i++){
		int j;
		cin >> j;
		for(int k = 0; k < j; k++){
			int l;
			cin >> l;
			vec.at(l - 1) = vec.at(l - 1) + 1;
        }
    }
	int A = 0;
	for(int i = 0; i < N; i++){
		if(vec.at(i) == 0){
			A++;
        }
    }
	cout << A;
}

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

int main() {
	int n, m;
	int t[100002], p[102], x[100002];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> x[i];
	}

	for (int i = 0; i < m; i++) {
		int sum_time = 0;
		for (int j = 0; j < n; j++) {
			if (j == p[i] - 1) sum_time += x[i];
			else sum_time += t[j];
		}
		cout << sum_time << 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);
		String winLoss = sc.nextLine();
		int wins =0;
		int loss=0;
		for(int i = 0; i<winLoss.length();i++){
			if (winLoss.charAt(i) == 'o'){
				wins++;
			}
			else if(winLoss.charAt(i)=='x'){
				loss++;
			}
			if(wins >= 8){
				System.out.println("YES");
				return;
			}
			if(loss>= 8){
				System.out.println("NO");
				return;
			}
			else if(i == winLoss.length()-1 && i != 15){
				if(15-loss >= 8)
					System.out.println("YES");
				else
					System.out.println("NO");
			}
		}
		return;
	}

}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define display(v) for (auto x : v) cout << x << ", "
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define endl '\n'
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
 
// DEBUG TEMPLATE by livw
void __print(int x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifdef INCLUDEWHENOFFLINE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main()
{
    fastio;
    ll n, k;
    cin >> k >> n;
    int arr[n];
    for (auto &x : arr) cin >> x;
    ll ans = 0;
    for (int i = 0; i < n - 1; i++)
        ans += arr[i + 1] - arr[i];
    ll sum = arr[0];
    sum += ans;
    sum += k - arr[n - 1];
    for (int i = 0; i < n - 1; i++)
    {
        ans = min(ans, sum - (arr[i + 1] - arr[i]));
    }
    cout << ans;


    return 0;
}



Measured memory_bytes: 1024
s = gets.chomp!.split('')
t = gets.chomp!.split('')
s_dup = s.inject({}) do |h, val|
  h[val] = 0 unless h.keys.include? val
  h[val] += 1
  h
end
t_dup = t.inject({}) do |h, val|
  h[val] = 0 unless h.keys.include? val
  h[val] += 1
  h
end
s_dup = s_dup.to_a.sort{|a, b| a[1] <=> b[1]}.select{|val| val[1] >= 2 }
t_dup = t_dup.to_a.sort{|a, b| a[1] <=> b[1]}.select{|val| val[1] >= 2 }
def check(s_, t_)
  if s_.length == t_.length
    s_ = s_.map{ |val| val[1] }
    t_ = t_.map{ |val| val[1] }
    if s_ == t_
      return true
    else
      return false
    end
  end
  return false
end
if s.uniq.length == t.uniq.length
  if check(s_dup, t_dup)
    puts "Yes"
  else
    puts "No"
  end
else
  puts "No"
end

Measured memory_bytes: 59516
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;

int main() {

	//ifstream cin("INPUT.txt");
	//ofstream cout("OUTPUT.txt");

	char code[11];
	char string[11];
	int length;
	int n, check, i, j, k;
	int count = 0;

	cin >> code >> n;
	length = strlen(code);

	for(i = 0; i < n; i++) {
	cin >> string;
		for(j = 0; j < 10; j++) {
			check = 1;
			for(k = 0; k < length; k++) {
				if(string[(j+k)%10] != code[k])
					check = 0;
			}
			if(check == 1) {
				count++;
				break;
			}
		}
	}

	cout << count << endl;

	return 0;

}

Measured memory_bytes: 1164
<?php
for($i=0; $i<5; $i++){
    $arr[] = trim(fgets(STDIN));
}

$array = [];
for($i=0; $i<5; $i++){
    $a = strlen($arr[0]);
    if($a == 2){
        if($arr[$i] % 10 != 0){
            $array[] = 10 - ($arr[$i] % 10);
        }else{
            $array[] = 0;
        }
    }else{
        if($arr[$i] % 10 != 0){
            $array[] = 10 - ($arr[$i] % 10);
        }else{
            $array[] = 0;
        }
    }
}

$end = array_keys($array,max($array));

$count = 0;
for($i=0; $i<5; $i++){
    if($i != $end[0]){
        $count += $array[$i] + $arr[$i];
    }
}

echo $count+$arr[$end[0]];
?>

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, A, B, C, D;
string S;

signed main() {
    cin >> N >> A >> B >> C >> D;
    cin >> S;
    A--;
    B--;
    C--;
    D--;
    FOR(i, A + 1, max(C,D)+1) {
        if(S[i] == '#' && S[i - 1] == '#') {
            cout << "No"
                 << "\n";
            return 0;
        }
    }
    bool judge = false;
    FOR(i, B, D + 1) {
        if(S[i] == '.' && S[i - 1] == '.' && S[i + 1] == '.') {
            judge = true;
        }
    }
    if(C < D) {
        cout << "Yes"
             << "\n";
    } else {
        Yes(bool(judge));
    }
    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    int score[n];
    int score1[n], score2[n], score3[n];
    for (int i = 0; i < n; ++i) {
        score[i] = 0;
        cin >> score1[i] >> score2[i] >> score3[i];
    }
    for (int i = 0; i < n; ++i) {
        bool flag1 = true, flag2 = true, flag3 = true;
        for (int j = 0; j < n; ++j) {
            if (i == j) continue;
            if (score1[i] == score1[j]) {
                flag1 = false;
            }
            if (score2[i] == score2[j]) {
                flag2 = false;
            }
            if (score3[i] == score3[j]) {
                flag3 = false;
            }
        }
        if (flag1) score[i] += score1[i];
        if (flag2) score[i] += score2[i];
        if (flag3) score[i] += score3[i];
    }
    for (int i = 0; i < n; ++i) {
        cout << score[i] << '\n';
    }
}


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

int main(){
  int A,B;
  cin>>A>>B;
  int sum=0;
  for(int i=A;i<=B;i++){
    if(i/10000==i%10&&i%10000/1000==i%100/10){
      sum++;
    }
  }
  cout<<sum<<endl;
}
  


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let K: usize = read();
    let P: Vec<usize> = (0..N).map(|_| read::<usize>()-1).collect(); //入力をデクリメントして、添字と合わせる。
    let C: Vec<i64> = (0..N).map(|_| read()).collect();
    
    let mut ans:i64 = std::i64::MIN;

    //各マスをスタートとして試す
    for si in 0..N{
        let mut x = si;
        let mut s:Vec<i64> = Vec::new(); //サイクルのコストを入れる
        let mut tot = 0; //コストの総和
        //サイクルの検出
        loop {
            x = P[x];
            s.push(C[x]);
            tot += C[x];
            //移動した先がsiであれば、サイクルと判定する。
            if x == si{
                break;
            }
        }

        let mut ruisekiwa:i64 = 0;//累積和をつくる
        for i in 0..s.len(){
            ruisekiwa += s[i];
            if i+1 > K{ //移動回数Kを超えて移動することはできないので、breakする
                break;
            }
            let mut now:i64 = ruisekiwa;
            if tot > 0{
                let e = (K-i-1)/s.len(); //サイクルを周回できる回数
                now += tot*e as i64;
                //println!("{}",now);
            }
            ans = std::cmp::max(ans,now);
        }
    }

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


Measured memory_bytes: 2240
n,m = map(int,input().split())
pst = [[] for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  pst[a].append(b)
s,t = map(int,input().split())
s -= 1
t -= 1
cnt = [[0,0,0] for _ in range(n)]
cnt[s][0] = 1
now = [s]
time = 0
while now:
  time += 1
  last = now
  now = []
  for x in last:
    for y in pst[x]:
      if cnt[y][time%3] == 0:
        cnt[y][time%3] = 1
        now.append(y)
  #print(time,cnt,now)
  if cnt[t][0] == 1:
    print(time//3)
    break
else:
  print(-1)

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

int main(){
   
    long int A,B,C,cnt=0;
    cin>>A>>B>>C;
    if(A==B&&B==C){
        if(A%2==0) cout<<-1<<endl;
        else cout<<0<<endl;
    }
    else{
        while(A%2!=1&&B%2!=1&&C%2!=1){
            long int a=A,b=B,c=C;
            A=(b+c)/2;
            B=(a+c)/2;
            C=(a+b)/2;
            cnt++;
        }
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 256
"""def power(x, y): 
    res = 1
    x=x
    while (y > 0): 
        if ((y & 1) == 1) : 
            res = (res * x) 
        y = y >> 1
        x = (x * x)
    return res""" 
"""def fact(n):
    if(n==0):
        return 1
    if(n==1):
        return 1
    return fact(n-1)+fact(n-2)"""

import math
#import combinations
#t=int(input())
#for _ in range(t):
#n=int(input())
#arr=list(map(int,input().split()))
n,m=map(int,input().split())
#count=0
ans=(m*(m-1))//2 + (n*(n-1))//2
print(ans)


Measured memory_bytes: 38384
#pragma region
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define rep(i, a, n) for (long long i = a; i <= n; ++i)
#define per(i, a, n) for (long long i = n; i >= a; --i)
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
template <typename T>
void read(T &x) {
    x = 0;
    char ch = getchar();
    ll f = 1;
    while (!isdigit(ch)) {
        if (ch == '-') f *= -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - 48;
        ch = getchar();
    }
    x *= f;
}
using namespace std;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#pragma endregion
const int maxn = 3005;
char s[maxn], t[maxn];
int dp[maxn][maxn];
int main() {
    IO;
    cin >> (s + 1) >> (t + 1);
    int n = strlen(s + 1), m = strlen(t + 1);
    rep(i, 1, n) rep(j, 1, m) {
        if (s[i] == t[j])
            dp[i][j] = dp[i - 1][j - 1] + 1;
        else
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
    string ans;
    int x = n, y = m;
    while (x && y) {
        if (s[x] == t[y]) {
            ans.push_back(s[x]);
            --x, --y;
        } else if (dp[x][y] == dp[x - 1][y])
            --x;
        else if (dp[x][y] == dp[x][y - 1])
            --y;
    }
    for (auto it = ans.rbegin(); it != ans.rend(); ++it)
        cout << *it;
}

Measured memory_bytes: 38252
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, m = map(int, input().split())
edges = [[]for _ in range(n)]
for _ in range(m):
    x, y = map(lambda x: int(x)-1, input().split())
    edges[x].append(y)


def dfs(v, parent):
    if visited[v]:
        return
    visited[v] = 1
    for v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, v)
        if dist[v] >= dist[v2]+1:
            continue
        dist[v] = dist[v2]+1


dist = [0]*n
visited = [0]*n

for i in range(n):
    if visited[i]:
        continue
    dfs(i, -1)

print(max(dist))


Measured memory_bytes: 201496