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

using lint = long long;

struct node {
    bool done;
    int cost;
    vector<int> tos;
};

void dfs(int init_pos, int pos, vector<node>& nodes, vector<vector<lint>>& costs) {
    nodes[pos].done = true;
    costs[init_pos].push_back(nodes[pos].cost);
    for (int i = 0; i < nodes[pos].tos.size(); i++) {
        int npos = nodes[pos].tos[i];
        if (nodes[npos].done == false) {
            dfs(init_pos, npos, nodes, costs);
        }
    }
}

struct que_element {
    lint cost;
    int num, pos;
    bool operator < (const que_element that) const {
        return cost > that.cost;
    }
};

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

    int n, m;
    cin >> n >> m;
    vector<node> nodes(n);
    for (int i = 0; i < n; i++) {
        cin >> nodes[i].cost;
    }
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        nodes[x].tos.push_back(y);
        nodes[y].tos.push_back(x);
    }

    vector<vector<lint>> costs(n, vector<lint>(0));
    for (int i = 0; i < n; i++) {
        if (nodes[i].done == false) {
            dfs(i, i, nodes, costs);
        }
    }

    int num_disjoints = 0;
    for (int i = 0; i < n; i++) {
        if (costs[i].size() > 0) {
            sort(costs[i].begin(), costs[i].end());
            num_disjoints++;
        }
    }
    lint ans = 0;
    int num_selected = 2 * (num_disjoints - 1);
    if (n < num_selected) {
        ans = -1;
    } else if (num_selected == 0) {
        ans = 0;
    } else {
        priority_queue<que_element> que;
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (costs[i].size() > 0) {
                ans += costs[i][0];
                count++;
                if (costs[i].size() > 1) {
                    que.push({costs[i][1], i, 1});
                }
                
            }
        }
        while (count < num_selected) {
            auto used = que.top();
            que.pop();
            ans += used.cost;
            count++;
            if (used.pos + 1 < costs[used.num].size()) {
                que.push({costs[used.num][used.pos + 1], used.num, used.pos + 1});
            }
        }
    }

    if (ans < 0) {
        cout << "Impossible" << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 10112
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{

    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int c = 0;
        List<long> list = aaaa(0, n);
        
        foreach(long i in list.Where( x=> x<=n))
        {
            string a = i.ToString();
            if(a.IndexOf("3") >= 0 && a.IndexOf("5") >= 0 && a.IndexOf("7") >= 0 &&
                a.Replace("3", "").Replace("5", "").Replace("7", "").Length == 0)
            {
                c++;
            }
        }

        Console.WriteLine(c.ToString());

    }

    static List<long> aaaa(long s, long limit)
    {
        if(s >= limit)
        {
            return null;
        }

        List<long> sss = new List<long>();
        long m = s * 10;
        if(m+3 <= limit)
        {
            sss.Add(m + 3);
        }
        if (m + 5 <= limit)
        {
            sss.Add(m + 5);
        }
        if (m + 7 <= limit)
        {
            sss.Add(m + 7);
        }

        List<long> ss = new List<long>();

        foreach (long st in sss)
        {
            List<long> l = aaaa(st, limit);
            if(l == null)
            {
                break;
            }
            ss.AddRange(l);
        }

        sss.AddRange(ss);
        return sss;
    }

}



Measured memory_bytes: 20568
#include "bits/stdc++.h"

using namespace std;

#define endl            "\n"
#define sz(x)          (int) (x.size())
#define all(v)          v.begin(), v.end()
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;



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

    int n, x, t; cin >> n >> x >> t;
    int c = 0;
    while(n >= x){
        n -= x;
        c += t;
    }
    if(n) c += t;
    cout << c;
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int X = scan.nextInt();
        int count = 0;
      
        for(int a = 0 ; a <= A; a ++){
          for(int b = 0 ; b <= B; b++){
            for(int c = 0 ; c <= C; c++){
               int t = a *500 + b * 100 + c * 50;
               if(t == X){
                 count ++;
               }
            }
          }
        }
      System.out.println(count);
    }
}

Measured memory_bytes: 35712
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    
  int n,m;
  cin >> n >> m;

  int a[m],b[m];
  for(int i=0;i<m;i++)cin >> a[i] >> b[i];

  int s=0;


  for(int i=0;i<m;i++){
    UnionFind tree(n);
    for(int j=0;j<m;j++){
      if(i!=j)tree.unite(a[j]-1,b[j]-1);
    }

    bool ok=true;
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        if(!tree.same(j,k)){
          s++;
          ok=false;
          break;
        }
      }
      if(!ok)break;
    }
  }

  cout << s << endl;

}


Measured memory_bytes: 256
import math._
object Main extends App {
    val Array(a, b, c) = io.StdIn.readLine.split(" ").map(_.toInt)
    val s = a * b * sin(Pi * c / 180) / 2
    println(s)
    println(a + b + sqrt(a * a + b * b - 2 * a * b * cos(Pi * c / 180)))
    println(2 * s / a)
}

Measured memory_bytes: 44108
#include <iostream>

using namespace std;

const long long int MAX_N = 86;

int main(int argc, char const *argv[]) {
  long long int n, l[MAX_N+1];
  cin >> n;
  l[0] = 2;
  l[1] = 1;
  for (size_t i = 2; i < MAX_N+1; i++) l[i] = l[i-1] + l[i-2];
  cout << l[n] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	final boolean DEBUG = false;

	class Node {
		int id;
		Node p, l, r;
		Node(int id) {
			this.id = id;
			this.p = this.l = this.r = null;
		}
		
		Node getRoot() {
			Node n = this;
			while (n.p != null)
				n = n.p;
			return n;
		}

		void preorder() {
			System.out.print(" " + this.id);
			if (this.l != null)
				this.l.preorder();
			if (this.r != null)
				this.r.preorder();
		}
		void inorder() {
			if (this.l != null)
				this.l.inorder();
			System.out.print(" " + this.id);
			if (this.r != null)
				this.r.inorder();
		}
		void postorder() {
			if (this.l != null)
				this.l.postorder();
			if (this.r != null)
				this.r.postorder();
			System.out.print(" " + this.id);
		}
	}

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Node[] nodes = new Node[n];
		for (int i = 0; i < n; i++)
			nodes[i] = new Node(i);
		for (int i = 0; i < n; i++) {
			int id = scan.nextInt();
			int left  = scan.nextInt();
			int right = scan.nextInt();
			if (left != -1) {
				nodes[id].l = nodes[left];
				nodes[left].p = nodes[id];
			}
			if (right != -1) {
				nodes[id].r = nodes[right];
				nodes[right].p = nodes[id];
			}
		}
		Node root = nodes[0].getRoot();
		System.out.println("Preorder");
		root.preorder();
		System.out.println("\nInorder");
		root.inorder();
		System.out.println("\nPostorder");
		root.postorder();
		System.out.println();
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



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

int main(){
  int n;
  cin >> n;
  vector<int>h(n);
  for(int i = 0; i < n; i++){
    cin >> h.at(i);
  }
  vector<int>ans(n);
  int a = 0;
  for(int i = 0; i < n-1; i++){
    if(h.at(i) >= h.at(i+1) ){
      ans.at(a)++;
    }
    else{
      a++;
    }
  }
  sort(ans.begin(),ans.end());
  reverse(ans.begin(),ans.end());
      
  cout << ans.at(0) << endl; 
  
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cstring>
int n,l,p[30],no[30];
bool out[30];
char d[30];
void work() {
	for (int i = 1; i <= n; ++i)
		no[i] = i;
	int ans =  0;
	memset(out,0,sizeof(out));
	for (int i = 1; i <= n; ++i) 
		if (d[i] == 'R') ans = std::max(ans,l - p[i]);
		else ans = std::max(ans,p[i]);
	for (int T = 1; T < ans; ++T) {
		for (int i = 1; i <= n; ++i)
			if (!out[i]) {
				if (d[i] == 'R') ++p[i];
				else --p[i];
			}
		for (int i = 1; i <= n; ++i)
			if (p[i] == 0 || p[i] == l) out[i] = true;
		for (int i = 1; i <= n; ++i)
			for (int j = i + 1; j <= n; ++j)
				if (!out[i] && !out[j] && p[i] == p[j])
					std::swap(no[i],no[j]);
	}
	printf("%d ",ans);
	int ansno = 0,t = 0;
	for (int i = 1; i <= n; ++i)
		if (!out[i]) {
			if (ansno == 0) ansno = no[i];
			else if (d[i] == 'L') ansno = no[i];
		}
	//printf("%d\n",t);
	printf("%d\n",ansno);
}
int main() {
	while (scanf("%d%d",&n,&l) != EOF) {
		if (n == 0 && l == 0) break;
		char s[3];
		for (int i = 1; i <= n; ++i) {
			scanf("%s%d",s,p + i);
			d[i] = s[0];
		}
		work();
	}
}
			

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

#define ll long long
#define ar array

int h, w, dp[100][100];
string g[100];

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

	cin >> h >> w;
	for(int i=0; i<h; ++i)
		cin >> g[i];
	dp[0][0]=g[0][0]!='.';
	for(int i=0; i<h; ++i) {
		for(int j=0; j<w; ++j) {
			if(!i&&!j)
				continue;
			dp[i][j]=1e9;
			if(i)
				dp[i][j]=min(dp[i][j], dp[i-1][j]+(g[i][j]!=g[i-1][j]));
			if(j)
				dp[i][j]=min(dp[i][j], dp[i][j-1]+(g[i][j]!=g[i][j-1]));
		}
	}
	cout << (dp[h-1][w-1]+(g[h-1][w-1]!='.'))/2;
}

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

int R, N;
int xl[40], xr[40], h[40];

double solve() {
    int hs[40];
    fill(hs, hs+40, 0);
    for (int j = 0; j < N; ++j) {
        for (int k = max(-R, xl[j]); k < min(R, xr[j]); ++k) {
            hs[k+R] = max(hs[k+R], h[j]);
        }
    }
    double ans = 10000;
    for (int j = 0; j < 2*R; ++j) {
        double t1 = hs[j] - sqrt(R*R - (j-R)*(j-R)) + R;
        double t2 = hs[j] - sqrt(R*R - (j-R+1)*(j-R+1)) + R;
        ans = min(ans, min(t1, t2));
    }
    return ans;
}

int main(){
    while (true) {
        cin >> R>> N;
        if (R == 0 && N == 0) break;
        for (int j = 0; j < N; ++j) {
            cin >> xl[j] >> xr[j] >> h[j];
        }
        printf("%.11f\n", solve());
    }
	return 0;
}

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

int main() {
  int D;
  cin >> D;
  string answer;
  if (D == 25) {
    answer = "Christmas";
  }
  else if (D == 24) {
    answer = "Christmas Eve";
  }
  else if (D == 23) {
    answer = "Christmas Eve Eve";
  }
  else {
    answer = "Christmas Eve Eve Eve";
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();

		int min = 1;
		int max = n;

		for(int i=0;i<m;i++){
			min = Math.max(min,sc.nextInt());
			max = Math.min(max,sc.nextInt());
		}

		int ans = Math.max(0,max-min+1);

		// 出力
		System.out.println(ans);
	}
}

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

#define MAX 200000

typedef struct{
  char name[10];
  int time;
}P;

P queue[MAX];
int head,tail;

void enqueue(P p){
  tail++;
  queue[tail] = p;
}

P dequeue(){
  P buf;
  buf = queue[head];
  head++;
  
  return buf;
}

int main(){
  int i, n, q, sum;
  P a;

  scanf("%d %d",&n, &q);
  for(i = 0; i < n; i++){
    scanf("%s", queue[i].name);
    scanf("%d", &queue[i].time);
  }

  tail = n - 1;
  
  while(head != tail + 1){
    a = dequeue();
    if(q < a.time){
      sum += q;
      a.time -= q;
      enqueue(a);
    }
    else{
      sum += a.time;
      printf("%s %d\n",a.name,sum);
    }

  }
  
  return 0;
}



Measured memory_bytes: 4664
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin>>a;
  for(int i=0;i<5;i++){
    cout<<a[i];
  }
  cout<<' ';
  for(int i=6;i<13;i++){
    cout<<a[i];
  }
  cout<<' ';
  for(int i=14;i<19;i++){
    cout<<a[i];
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define em emplace
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int INF = 1<<30;
constexpr ll LINF = 1LL<<58;
constexpr int mod = 1000000007;

vector<ll> dp(101010, LINF);

int main(){
    int n, w;
    cin >> n >> w;
    ll W[110], V[110];
    for (int i = 0; i < n; i++) cin >> W[i] >> V[i];
    dp[0] = 0LL;
    for (int i = 0; i < n; i++) {
        for (int j = 100100; j >= 0 ; j--) {
            if(j - V[i] >= 0) chmin(dp[j], dp[j - V[i]] + W[i]);
        }
    }
    ll ans = 0;
    for (int i = 0; i < 101010; i++) {
        if(dp[i] <= w) ans = i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string a,b,c;
    cin>>a>>b>>c;
    int x=0;
    int y=0;
    x=a.size()-1;
    y=b.size()-1;
    if(a.at(x)==b.at(0)&&b.at(y)==c.at(0)){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


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

int main(){
	
	int h, n, count = 0;
	
	cin >> h >> n;
	
	int a[n+5];
	
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for (int i = 0; i < n; i++){
		count++;
		h -= a[i];
		if (h <= 0){
			cout << "Yes";
			break;
		}
		if (i == n-1 && h > 0){
			cout << "No";
			break;
		}
	}

}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<int> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {

    int n;
    cin >> n;

    vector<P> activities(n);
    rep(i, n) cin >> activities[i].first >> activities[i].second;

    sort(activities.begin(), activities.end(), [](P p, P q) {
        return p.second < q.second;
    });

    vector<ll> endings(n);
    rep(i, n) endings[i] = activities[i].second;

    ll start = -1;
    int ans = 0;
    while (true) {
        int index = distance(endings.begin(), lower_bound(endings.begin(), endings.end(), start));
        for (int i = index; i < n; i++) {
            if (activities[i].first > start) {
                ans++;
                start = activities[i].second;
                continue;
            }
        }
        break;
    }

    cout << ans << endl;
}


Measured memory_bytes: 5148
#include <math.h>
#include <stdio.h>

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

//コンパイラ最適化
#pragma GCC optimize("Ofast")

/*

 */
//マクロ
// forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
// FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
#define SORT(x) sort(x.begin(), x.end())
//定数
#define INF 1000000000000  // 10^12:∞
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange
//略記
#define PB push_back  //挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素

typedef long long ll;

using namespace std;
int main() {
  int N;
  cin >> N;
  for (int i = 0; i <= N; i += 4) {
    int num = N - i;
    if (num % 7 == 0) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3548
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n;
  while(cin>>n,n+1){
    if(!n){cout<<0<<endl;continue;}
    vector<int>out;
    while(n){
      pb(out,n%4);
      n/=4;
    }
    rep(i,out.size())cout<<out[out.size()-i-1];
    cout<<endl;
  }


}

Measured memory_bytes: 1212
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
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;
}

//////////////////////////


#define N 10000
ll a[N];

int main(){fastio
    
    ll n,k;cin>>n>>k;
    rep (i,1,k){
        ll d;cin>>d;
        while(d--){
            ll c;cin>>c;
            a[c]++;
        }
    }
    ll ans=0;
    rep (i,1,n){
        if(a[i]==0)ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}



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

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Reads();
            WriteLine("A"+x[1][0]+"C");
        }
       

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define NIL -1
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int n;
int root;
int *p = new int[500000];    //    p---|  Unit
int *left2 = new  int[500000]; // left2 --|--------> T
int *right2 = new int[500000];//right2---|
int *key = new int[500000];  // key----|
  
void Init(){
  rep(i,500000){
    p[i]=left2[i]=right2[i]=key[i]=NIL;
  }
}
  
  
int FindRoot(){
  rep(i,n){
    if(p[i] == NIL){
      return i;
    }
  }
}
  
  
  
void TREE_INSERT(int z){
  int y = NIL; 
  int x = root;
  
  while(x != NIL){
    y = x;
    if(key[z] < key[x]){
      x = left2[x];
    }
    else x = right2[x];
  }
  p[z]=y;
  if(y == NIL){
    root = z;
  }
  else if(key[z] < key[y]){
    left2[y] = z;
  }else{
    right2[y] = z;
  }
  
}
  
void InorderTreeWalk(int x){
  if(x != NIL){
    InorderTreeWalk(left2[x]);
    printf(" %d",key[x]);
    InorderTreeWalk(right2[x]);
  }
}
  
void PreorderTreeWalk(int x){
  if(x != NIL){
    printf(" %d",key[x]);
    PreorderTreeWalk(left2[x]);
    PreorderTreeWalk(right2[x]);
  }
}
  
  
int main(){
  int val;
  string op;
  int zr;                    
  
  
  scanf("%d",&n);
  Init(); 
  root = -1;
  zr=0;
  while(n-- > 0){
    cin >> op;
    if(op == "insert"){
      scanf("%d",&val);
      key[zr]=val;        
      TREE_INSERT(zr);
      zr++;
    }else if(op == "print"){
      InorderTreeWalk(root);
      printf("\n");
      PreorderTreeWalk(root);
      printf("\n");
    }
  }
  
  delete [] p;
  delete [] left2;
  delete [] right2;
  delete [] key;
  
  return 0;
}



Measured memory_bytes: 10736
n, a, b, c, d = map(int, raw_input().split())
dp = [0]*(n+1)
dp[0] = 1

MOD = 10**9+7
fact = [1]*(n+1)
frev = [1]*(n+1)

rn = range(n, -1, -1)

for i in xrange(1, n+1):
    fact[i] = (fact[i-1] * i) % MOD
    frev[i] = pow(fact[i], MOD-2, MOD)
for g in xrange(a, b+1):
    y = frev[g]
    for i in rn:
        x = frev[n-i]
        dp[i] = (dp[i] + sum(dp[i-g*j] * fact[n-i+g*j] * x * pow(y, j, MOD) * frev[j] for j in xrange(c, min(d, i/g)+1))) % MOD
print dp[n]


Measured memory_bytes: 38684
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n;
  cin >> n;
  vector<ll> a[4];
  for (int i = 0; i < 4; i++) {
    a[i].resize(n + 1);
    a[i][0] = 0LL;
  }
  a[0][0] = 1LL;
  for (int i = 0; i < n; i++) {
    a[0][i + 1] = a[0][i] * 8 % MOD;
    a[1][i + 1] = (a[0][i] + a[1][i] * 9) % MOD;
    a[2][i + 1] = (a[0][i] + a[2][i] * 9) % MOD;
    a[3][i + 1] = (a[1][i] + a[2][i] + a[3][i] * 10) % MOD;
  }
  cout << a[3][n] % MOD << endl;
}

Measured memory_bytes: 34392
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		boolean poor = false;
		if(A == B && B == C){
			poor = false;
		}else if(A == B || B == C || A == C){
			poor = true;
		}
		if(poor){
			System.out.println("Yes");
		}else{
			System.out.println("No");			
		}
	}
}


Measured memory_bytes: 22228
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll a[200010];
ll ans[200010];
int main(){
    cin>>N;
    ll mx=0;
    for(ll i=0;i<N;i++){
        cin>>a[i];
        mx=max(mx,a[i]);
    }

    for(ll bit=0;(1ll<<bit)<=mx;bit++){
        ll cnt=0;
        for(ll i=0;i<N;i++){
            if(a[i] & (1ll<<bit))cnt++;
        }
        if(cnt%2==0) for(ll i=0;i<N;i++)  ans[i]+=(((bool)(a[i] & (1ll<<bit)))<<bit);
        else for(ll i=0;i<N;i++)  ans[i]+=((!(bool)(a[i] & (1ll<<bit)))<<bit);
    }

    for(ll i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }


    return 0;
}

Measured memory_bytes: 6644
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;

ll gcd( ll a, ll b ){//最大公約数
    ll tmp;
    if( a < b ) { tmp = a; a = b; b = tmp; }
    if( b < 1 ) return -1;

    if( a % b == 0 ) return b;
    return gcd( b, a % b );
}
ll lcm(ll a, ll b){//最小公倍数
    return a * b / gcd(a, b);
}
ll sosuu(ll x){
    for(int i = 2; i < x; i++){
        if(x % i == 0) return false;
    }

    return true;
}


//入力
int n;
int p[200010];

int main(){

    cin >> n;
    for(int i = 0; i < n; i++) cin >> p[i];

    int _min = p[0];
    int ans = 1;

    for(int i = 1; i < n; i++){
        if(_min >= p[i]){
            ans++;
            _min = p[i];
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N;
	cin >> N;
	cout << (1000 - (N % 1000)) % 1000 << endl;

	return 0;
}




Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main() {


    int N;
    int tn = -1;
    int A[210];
    int flg = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    while (true) {
        tn++;
        for (int i = 0; i < N; i++)
        {
            if (A[i] % 2 == 0) {
                A[i] = A[i] / 2;
            }
            else { flg = 1; }
           
        }
        if (flg == 1) break;
    }

    cout << tn << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

ll ceil(ll a, ll b) {  // a÷b以上の最小の整数
    if(b == 0) {
        return 0;
    }
    return (a+b-1)/b;
}

int main() {
    ll n;
    cin >> n;

    vl a(n+1);
    rep(i, n+1) {
        cin >> a[i];
    }

    vl x(n+1), y(n+1);
    x[n] = y[n] = a[n];
    for(ll i = n-1; i >= 0; i--) {
        x[i] = ceil(x[i+1], 2) + a[i];
        y[i] = y[i+1] + a[i];
    }

    if(1 < x[0]) {
        out(-1);
        re0;
    }
    
    vl z(n+1);
    z[0] = 1;
    ll ans = 1;
    exrep(i, 1, n) {
        z[i] = min(y[i], 2*(z[i-1] - a[i-1]));
        ans += z[i];
    }

    out(ans);
    re0;
}

Measured memory_bytes: 6336
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i,n) for(int i=(int)(n);i>=0;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------
 
signed main() {
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    cin >> V >> C;
    int res=0;
    for (auto i=0; i<N; i++) {
      if(V[i] > C[i]) res += V[i] - C[i];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int N,M;//N桁 
int s[10];//左からｓ桁目はcである
int c[10];
int c_all[10];
int ans=0;
int checker=0;
int main(void){
    scanf("%d %d",&N,&M);
    for(int i=0;i<M;i++){
        scanf("%d %d",&s[i],&c[i]);
    }
    
    for(int i=0;i<=999;i++){
        checker=0;
        string is =to_string(i);
        if(is.size()!=N){
            continue;
        }
        for(int j=0;j<M;j++){
            //printf("%d %d %d\n",i,is[s[j]-1]-'0',c[j]);
             if(is[s[j]-1]-'0'==c[j]){
                 checker++;
             }
        }
        if(checker==M){
            printf("%d",i);
            break;
        }
        
    }
    if(checker!=M){
        printf("%d",-1);
    }
}


Measured memory_bytes: 256
import sys


def main():
    ticket = list(input())

    op = [""] * 3

    for i in range(2):
        if i == 0:
            op[0] = "+"
        else:
            op[0] = "-"
        for j in range(2):
            if j == 0:
                op[1] = "+"
            else:
                op[1] = "-"
            for k in range(2):
                if k == 0:
                    op[2] = "+"
                else:
                    op[2] = "-"

                eq = ticket[0] + op[0] + ticket[1] + op[1] + ticket[2] + op[2] + ticket[3]
                # for n in range(3):
                #     eq += ticket[n] + op[n]
                # eq += ticket[-1]

                if eval(eq) == 7:
                    print(eq+"=7")
                    sys.exit()


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n,k,s; cin >> n >> k >> s;
  rep(i, n){
    if(i<k){
      cout << s;
    }else{
      if(s<(ll)1e+9){
        cout << s+1;
      }else{
        cout << s-1;
      }
    }
    if(i<n-1) cout << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<cmath>

typedef std::vector<int> Intvec;
const int Amax = (int)log2(1000000000);

bool CheckVecEven(Intvec &A) {
	for (int i = 0; i < A.size(); i++) {
		if (A[i] % 2 != 0) return false;
		else A[i] = (int)A[i] / 2;
	}
	return true;
}

int main(void) {
	int N = 0;
	Intvec A;

	std::cin >> N;
	A.resize(N);

	for (int i = 0; i < N; i++) std::cin >> A[i];
	
	int count = 0;
	while (count < Amax) {
		bool ret = true;

		if (CheckVecEven(A) == false) break;
		count++;
	}

	std::cout << count <<std::endl;
	
	return 0;
}

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

#define clock_starts() clock_t begin = clock()
#define clock_ends() clock_t end = clock()
#define print_running_time() double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC; \
printf("Elapsed Time : %.10f second(s)\n", elapsed_secs)
#define readfile(s) freopen(s, "r", stdin)
#define writefile(s) freopen(s, "w", stdout)
#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) v.begin(), v.end()
#define cin_cout_is_cool ios_base::sync_with_stdio(false); cin.tie(NULL)
#define printBinary(n) cout << #n << " = " << bitset<64>(n) << endl
#define min_pq priority_queue<int, vector<int>, greater<int> >
#define MEMSET(a,val) memset(a, val, sizeof a)
#define PB push_back
#define endl '\n'
#define cin(n) scanf("%d", &n)

template<typename T>T max(T a_,T b_,T c_) { return max(a_,max(b_,c_)); }
template<typename T>T min(T a_,T b_,T c_) { return min(a_,min(b_,c_)); }

typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef pair<double, double> pdd;

#define ceil(num,d) 		( (int)(num/d) + (num%d>0 ? 1 : 0) )
#define block_no(idx) 		( ceil(idx, BLOCK_SIZE) )
#define block_starting(idx) ( ((block_no(idx)-1) * BLOCK_SIZE) +1 )
#define block_ending(idx) 	( min(n, block_no(idx)*BLOCK_SIZE) )
#define block_ranking(idx) 	((idx%BLOCK_SIZE==0)?BLOCK_SIZE:idx%BLOCK_SIZE)

const int maxn = 100010;

int pre[maxn];
int p[maxn];

int isprime(int n) {
	if(n == 1) return 0;
	if(n == 2) return 1;
	for(int i=2; i*i <= n; i++) {
		if(n % i == 0) return 0;
	} return 1;
}

int32_t main () {
	//readfile("input.in");
	//writefile("output.out");
	for(int i=1; i<=100000; i++) p[i] = isprime(i);
	for(int i=1; i<=100000; i+=2) if(p[i] and p[(i + 1) >> 1]) pre[i] = 1;
	for(int i=1; i<=100000; i++) pre[i] += pre[i-1];
	int q; cin>>q;
	for(int i=1; i<=q; i++) {
		int l, r; cin>>l>>r;
		cout<<pre[r] - pre[l-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main() {
	long a, b, c, d;
 	cin >> a >> b;
    c = a / 0.08;
    d = b / 0.1;
    //cout << c << endl;
    //cout << d;
    for (int i = 0; i < 10000; i++){
        if (floor(i * 0.08) == a && floor(i * 0.1) == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
import itertools

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

As = list(itertools.combinations_with_replacement(range(1,M+1),N))

ans = 0
for A in As:
    sm = 0
    for abcd in abcds:
        a, b, c, d = abcd[0], abcd[1], abcd[2], abcd[3]
        if A[b-1] - A[a-1] == c:
            sm += d
    ans = max(ans, sm)
print(ans)


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

using namespace std;

typedef long long ll;

#define INF (int)1e9+7
#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 vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
//#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795


ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll N=2e5+1;

ll solve(ll t,vector<ll>& a,ll n)
{
  ll ans=0;
  for(int i=1;i<=n;i++)
    ans+=(a[i]-t)*(a[i]-t);

  return ans;

}


ll bx(ll n)
{
  ll temp=10;
  while(n)
  {
    temp=min(temp,n%10);
    n/=10;
  }
  return temp;
}

ll ax(ll n)
{
  ll temp=0;
  while(n)
  {
    temp=max(temp,n%10);
    n/=10;
  }
  return temp;
}



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

ll n,x=0,cnt=0,y=0;
cin>>n;
//set<<ll>s;

vl a(n+1);

for(int i=1;i<=n;i++)
  {
    cin>>a[i];
    x=max(x,a[i]);
  }

for(int i=1;i<=n;i++){
  if(a[i]==x)cnt++;
  else y=max(y,a[i]);
}

  if(cnt>1)
  {
    for(int i=1;i<=n;i++)cout<<x<<"\n";
  }

else 
{
  for(int i=1;i<=n;i++)
  {
    if(a[i]==x)cout<<y<<"\n";
    else cout<<x<<"\n";
  }
}
cout<<"\n";

return 0;

}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main(){
 string S;
 cin >> S;
 vector<int> aru(26);
for(char c :S){
  int idx = c-'a';
  aru[idx] = 1;
}
char ans;
int i;
for(i = 0; i<26; i++){
if(aru[i] == 0){
  ans = i + 'a';
  break;
}

}

if(i == 26){
  cout << "None" << endl;
}
  
else{
  cout << ans << endl;
}
}



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <regex>
 
using namespace std;
 
int main() {
    string s;
    cin >> s;
 
    cout << (regex_match(s, regex("^(dream|dreamer|erase|eraser)*$"))
                 ? "YES"
                 : "NO")
         << endl;
}

Measured memory_bytes: 39808
using System;
using System.Collections.Generic;
using System.Linq;

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

            var sum = 0;
            for (int i = 1; i <= N; i++)
                sum += i;

            Console.WriteLine(sum);
        }
    }
}

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

int main(){
  int N,L; cin >> N >> L;
  string S[100];
  for(int i=0; i<N; i++){
    cin >> S[i];
  }
  sort(S,S+N);
  for(int i=0; i<N; i++){
    cout << S[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
n = int(input())
rt = [int(input()) for v in range(n)]
max_diff = (10 ** 9) * -1
min_val = 10 ** 9
for j in range(1, n):
    min_val = min(rt[j-1], min_val)
    diff = rt[j] - min_val
    if max_diff < diff:
        max_diff = diff
print(max_diff)


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

using namespace std;

#define ll long long
#define ull unsigned long long

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

    int n;
    cin >> n;
    for (int i = 0, a; i < n; i++) {
        cin >> a;
        if (a % 2 == 0) {
            if (a % 3 != 0 && a % 5 != 0) {
                cout << "DENIED\n";
                return 0;
            }
        }
    }
    cout << "APPROVED\n";
}


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

int main(){
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0;i < N; i++){
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  reverse(data.begin(), data.end());
  int count = 0;
  for(int i = 0; i < N; i++){
    count += data.at(i)*pow(-1.0, i);
  }
  cout << count << endl;
}

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

vector<int> g[100005];

int dfs(int u) {
  vector<int> tmp;
  for (auto to : g[u]) {
    tmp.push_back(dfs(to));
  }
  if (tmp.size() == 0) return 1;
  sort(tmp.begin(), tmp.end()); reverse(tmp.begin(), tmp.end());
  int ma = 0;
  for (int i = 0; i < tmp.size(); i++) {
    ma = max(ma, tmp[i] + i);
  }
  return ma + 1;
}

main() {
  int n; cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a; cin >> a; --a;
    g[a].push_back(i + 1);
  }
  cout << dfs(0) - 1 << endl;
}

Measured memory_bytes: 15104
#include <map>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, c;
int main() {
	cin >> n >> m;
	map<pair<string, string>, int> d;
	for (int i = 0; i < n; i++) {
		cin >> c;
		vector<string> v(c);
		for (int j = 0; j < c; j++) cin >> v[j];
		sort(v.begin(), v.end());
		for (int j = 0; j < c; j++) {
			for (int k = j + 1; k < c; k++) {
				d[make_pair(v[j], v[k])]++;
			}
		}
	}
	vector<pair<string, string> > ret;
	for (pair<pair<string, string>, int> i : d) {
		if (i.second >= m) ret.push_back(i.first);
	}
	cout << ret.size() << endl;
	for (pair<string, string> i : ret) {
		cout << i.first << ' ' << i.second << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
  // input 1 
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);
  
  // definign variables

  int a, b, c, k;
  // input in variables
  cin >> a >> b >> c >> k;
  
  // logical execution

  int sum = 0;
  for (int i = 0; i < k; ++i) {
    // if else looping
    if (a > 0) {
      ++sum;
      --a;
      // el-if cond.
    } else if (b > 0) {
      --b;
    } else {
      --sum;
    }
  }
  // print answe 
  cout << sum << '\n';
// return value
  return 0;
}

Measured memory_bytes: 3688
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    X = input_number()
    t = 100
    cnt = 0
    while t < X:
        t = int(t * 1.01)
        cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> x(n);
    rep(i, n)cin >> x[i].first >> x[i].second;
    sort(x.begin(), x.end());

    ll ans = 4001001001001001001;
    rep(i, n-1)for(int j = i+1; j < n; j++){
        if(j-i+1 < k)continue;
        vector<ll> yy;
        for(int l = i; l <= j; l++)yy.push_back(x[l].second);
        sort(yy.begin(), yy.end());
        ll dy = 2002002002;
        rep(l, yy.size()-k+1)dy = min(dy, yy[l+k-1]-yy[l]);
        ans = min(ans, dy * (x[j].first-x[i].first));
    }
    cout << ans << endl;
}

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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;

typedef tree<pair<ll, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//Ordered set
//pbds s1
 
void testCase() {
    int n;
    cin >> n;
    int prev = 0;
    int ok = 0;
    for (int i=0; i<n; i++) {
        int a, b;
        cin >> a >> b;
        if (a == b)
            prev++;
        else
            prev = 0;
        if (prev >= 3)
            ok = 1;
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

ll Sum(ll x){
  return ((x + 1)*x)>>1;
}

int main(){
  int n,k; cin >> n >> k;
  vector<double> v(n); cin >> v;
  vector<double> sum(n);
  for(int i = 0; i < n; ++i){
    v[i] = Sum((ll)v[i])/v[i];
    sum[i] = (i>0?sum[i-1]:0) + v[i];
  }
  double ans = 0;
  for(int i = k-1; i < n; ++i){
    double pre = (i-k<0?0:sum[i-k]);
    ChangeMax(ans,sum[i]-pre);
  }
  cout << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);

	if(abs(a-c) <= d || (abs(a-b) <= d && abs(c-b) <= d)){

		printf("Yes\n");

	}else{

		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 3656
N = int(input())
A = [[0 for i in range(11)] for j in range(11)]
for i in range(1, N+1):
  A[int(str(i)[0])][int(str(i)[-1])] +=1

B = [[0 for i in range(11)] for j in range(11)]
for i in range(1, N+1):
  B[int(str(i)[0])][int(str(i)[-1])] +=1

ans = 0
for i in range(10):
  for j in range(10):
    ans += A[i][j] * B[j][i]
  
print(ans)

Measured memory_bytes: 3064
from bisect import bisect_left


def search(s, x):
    i = bisect_left(s, x)
    if i != len(s) and s[i] == x:
        return 1
    else:
        return -1


n = int(input())
s = list(map(int, input().split()))
s.sort()

q = int(input())
t = list(map(int, input().split()))
cnt = 0
for num in t:
    if search(s, num) == 1:
        cnt += 1

print(cnt)



Measured memory_bytes: 16748