akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class ProblemC{
  long[] d = null;//sからの最短経路
  ArrayList<ArrayList<Edge>> g = new ArrayList<ArrayList<Edge>>();
  long inf = 1000000000;

  void solve(){
    Scanner scan = new Scanner(System.in);
    int v = scan.nextInt();
    int e = scan.nextInt();
    int r = scan.nextInt();

    d = new long[v];

    for(int i=0 ; i<v ; ++i){
      g.add(new ArrayList<Edge>());
    }

    for(int i=0 ; i<e ; ++i){
      int s = scan.nextInt();
      int t = scan.nextInt();
      int d = scan.nextInt();
      g.get(s).add(new Edge(t, d));
    }

    dijkstra(r, v);

    for(int i=0 ; i<d.length ; ++i){
      if(d[i] == inf) System.out.println("INF");
      else System.out.println(d[i]);
    }

  }

  void dijkstra(int r, int vn){
    PriorityQueue<IntPair> que = new PriorityQueue<IntPair>();
    for(int i=0 ; i<vn ; ++i) d[i] = inf;
    d[r] = 0;
    que.add(new IntPair(0, r));
    while(!que.isEmpty()){
      IntPair p = que.poll();//IntPair(Key:頂点番号, Value:最短距離)
      int v = p.value;//頂点番号
      if(d[v] < p.key) continue;
      for(int i=0 ; i<g.get(v).size() ; ++i){

        Edge e = g.get(v).get(i);
        if(d[e.to] > d[v] + e.cost){
          d[e.to] = d[v] + e.cost;
          que.add(new IntPair(d[e.to], (int)e.to));
        }
      }
    }//----end of while----
  }//----end of dijkstra----
}

class IntPair implements Comparable<IntPair>{
  public long key;
  public int value;

  IntPair(long key, int value){
    this.key = key;
    this.value = value;
  }

  public int compareTo(IntPair other){
    if(key < other.key) return -1;
    if(key > other.key) return 1;

    if(value < other.key) return -1;
    if(value > other.key) return 1;

    return 0;
  }
}

class Edge{
  int to = 0;
  int cost = 0;

  Edge(int to, int cost){
    this.to = to;
    this.cost = cost;
  }
}


public class Main{
  public static void main(String[] args){
    new ProblemC().solve();
  }
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

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

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());

    if(s<t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	string s; cin >> s;
	cout << s;
	if (s[s.size()-1] == 's')cout << "es" << endl;
	else cout << "s" << endl;
}

Measured memory_bytes: 3596
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iterator>
#include <map>
#include <unordered_map>
#define ll long long int
#define vi vector<long long int>
#define vvi vector<vi >
#define vpi vector<pair<ll,ll> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
using namespace std;
int main(){
	ll n,m,i,j,k=pow(10,9)+7;
	cin>>n>>m;
	vs v(n);
	for(i=0;i<n;i++) cin>>v[i];
	vvi d(n);
	for(i=0;i<n;i++) d[i]=vi(m,0);
	d[0][0]=1;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(v[i][j]=='#'||(!i&&!j)) continue;
			if(!i&&v[i][j-1]!='#') d[i][j]+=d[i][j-1];
			else if(!j&&v[i-1][j]!='#') d[i][j]+=d[i-1][j];
			else if(i&&j){
				if(v[i-1][j]!='#') d[i][j]+=d[i-1][j];
				if(v[i][j-1]!='#') d[i][j]+=d[i][j-1];
			}
			d[i][j]%=k;
		}
	}
	cout<<d[n-1][m-1]<<endl;
}


Measured memory_bytes: 9088
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

#define INF 1e9
#define MAXV 10005
#define MAXE 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll V,E, sum = 0;
bool used[MAXV] = {};
pii edges[MAXE] = {};
priority_queue<pii, vector<pii>, greater<pii> > Q;

class UnionFind {
    public:
        vector<int> rank, size, p;
    
    UnionFind(){}
    UnionFind(int n){
        rank.resize(n, 0);
        size.resize(n, 1);
        p.resize(n, 0);
        for(int i=0; i < n; i++) makeSet(i);
    }

    void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
        size[x] = 1;
    }

    bool same(int x, int y){
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y){
        link(findSet(x), findSet(y));
    }

    void link(int x, int y){
        if(rank[x] > rank[y]){
            p[y] = x;
            size[x] += size[y];
        } else {
            p[x] = y;
            size[y] += size[x];
            if(rank[x] == rank[y]){
                rank[y]++;
            }
        }
    }

    int findSet(int x){
        if( x!= p[x]){
            p[x] = findSet(p[x]);
        }
        return p[x];
    }

    int getSize(int x){
        return size[findSet(x)];
    }
};

void kruskal(){
    UnionFind uft(V);

    while(!Q.empty()){
        pii tmp = Q.top();
        int cst = tmp.first, id = tmp.second;
        Q.pop();
        pii e = edges[id];
        int u = e.first, v = e.second;
        // printf("(%d, %d): %d\n",u,v,cst);

        if(!uft.same(u,v)){
            sum += cst;
            uft.unite(u,v);
        }
    }

    cout << sum << endl;
}

int main(){
    cin >> V >> E;

    rep(i,E){
        int s, t, w;
        cin >> s >> t >> w;
        Q.push(make_pair(w,i));
        edges[i] = make_pair(s,t);
    }

    kruskal();
}



Measured memory_bytes: 4648
S = input()
N = len(S)
ans = "AC"
if S[0] != 'A':
  ans = "WA"
c = 0
for i in range(1,N):
  if 2 <= i <= N-2 and S[i] == "C":
    c += 1
  elif S[i] <"a" or "z" < S[i]:
    ans = "WA"
if c != 1:
  ans = "WA"
  
print(ans)



Measured memory_bytes: 9120
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

// #define int long long int

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;

bool cmp(pair<ll int, ll int> l, pair<ll int, ll int> r){
	return l.first > r.first;
}

int main(){
	fast;
	auto start = high_resolution_clock::now(); 
	ll int n, m;
	cin >> n >> m;

	vector<ll int> x(m);
	vector<pair<ll int, ll int> > diff(m-1);
	for (ll int i = 0; i < m; ++i){
		cin >> x[i];
		// trace1(x[i]);
	}
	sort(x.begin(), x.end());

	for(ll int i = 1 ; i < m ; i++){
		diff[i-1] = mp(x[i] - x[i-1], i);
		// trace2(x[i] - x[i-1], i);
	}

	sort(diff.begin(), diff.end(), cmp);
	for(ll int i = 1 ; i < m ; i++){
		// trace2(diff[i-1].first, diff[i-1].second)
		// trace2(x[i] - x[i-1], i);
	}


	if (n >= m){
		cout << 0 ;
	}
	else{
		vector<ll int> idx;
		for (ll int i = 0; i < n-1; ++i){
			idx.pb(diff[i].second);
			// trace2( diff[i].first, diff[i].second)
		}

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

		ll int moves = 0;
		ll int prev = 0;
		for(ll int i = 0 ; i < idx.size() ; i++){
			moves += x[idx[i] - 1] - x[prev];
			// trace3(moves, x[idx[i] - 1] , x[prev])
			prev = idx[i];
			// trace(moves, x[idx[i] - 1] , x[prev])
		}
		// cout << x[m - 1] <<  " " <<  x[prev] ; 
		cout << moves + x[m - 1] - x[prev];

	}

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define X first
#define Y second
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define D double
#define ll long long
#define REP(i,a) for(int i=0;i<a;i++)
#define REP1(i,a,b) for(int i=a;i<b;i++)
#define REP2(i,a,b) for(int i=a;i<=b;i++)
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define RREP1(i,a,b) for(int i=a;i>b;i--)
#define RREP2(i,a,b) for(int i=a;i>=b;i--)
#define SREP(i,x) for(auto i:x)
#define MS0(x) memset((x),0,sizeof((x)))
#define MS1(x) memset((x),-1,sizeof((x)))
#define MSF(x) memset((x),127,sizeof(x))
#define pb push_back
#define LE(x) (int)((x).size())
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<D,D>
#define im guagua
#define RI(x) x=rit()
#define RII(a,b) a=rit(),b=rit()
#define RIII(a,b,c) a=rit(),b=rit(),c=rit()
#define debug 0
const int INF = 0x7F7F7F7F;
const double EPS = 1e-10 ;
const ll mod7 = 1e9+7;
const ll mod9 = 1e9+9;
using namespace std;
inline ll rit(){
    ll f=0,key=1;
    char c;
    do{
        c=getchar();
        if(c=='-') key=-1;
    }while(c<'0' || c>'9');
    do{
        f=f*10+c-'0';
        c=getchar();
    }while(c>='0' && c<='9');
    return f*key;
}
inline void fprt(D f){
    printf("%.08lf",f);
}
void init(){
}
ll n,m;
void read(){
    RII(n,m);
}
void solve(){
    if(abs(n-m) > 1) {
        cout<<0<<endl;
        return ;
    }
    ll ans = 1;
    if(n == m){
        ans *= 2;
    }
    REP2(i,1,n){
        ans = (ans * i) % mod7;
    }
    REP2(i,1,m){
        ans=  (ans * i )% mod7;
    }
    cout<<ans<<endl;
}
int main(){
    int nn=1;
    // nn=rit();
    while(nn--){
        // while(cin>>n) 
            init(),read(),solve();
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        int h = scan.nextInt();

        int area = ((a +  b) * h)/2 ;

        System.out.println(area);

    }
}


Measured memory_bytes: 35652
#include <bits/stdc++.h>
using namespace std;
//long long a[200005];
//long long b[200005],c[200005];

int main ()
{

    long long int a,b, c,d,e,f,g,h,i,j,k,t,n,sum=0;

    cin >>a>>b ;
    if (a==b)
    {
        cout << "Yes"<<"\n";
    }
    else{

        cout << "No"<<"\n";
    }


}


Measured memory_bytes: 256
#include <stdio.h>

#define arr_print_d0dn(a, n) for(int i=0;i<(n)-1;++i)put_uint((a)[i]),putchar_unlocked(' ');put_uint((a)[(n)-1]),putchar_unlocked('\n')

#define INPUT__LENGTH (20000000)
char _in[INPUT__LENGTH];
char *_p = _in;
int read_uint() {
    int n = 0;
    while(47 < *_p && *_p < 58) n = 10 * n + (*_p++ & 0xf);
    _p++;
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
void counting_sort(int *dst, const int *src, const int N, const int max) {
    // 'int c[max+1] = {}' cannot initialize
    int c[10001] = {};
    for(int i = 0; i < N; ++i) c[src[i]]++;
    for(int i = 1; i < max; ++i) c[i] += c[i - 1];
    for(int i = N - 1; i >= 0; --i) {
        int x = src[i];
        int y = c[x];
        dst[c[src[i]]-- - 1] = src[i];
    }
}
int main(int argc, char **argv) {
    fread_unlocked(_in, 1, INPUT__LENGTH, stdin);
    int n = read_uint();
    int a[n], b[n];
    for(int i = 0; i < n; ++i) a[i] = read_uint();
    counting_sort(b, a, n, 10000);
    arr_print_d0dn(b, n);
    return 0;
}



Measured memory_bytes: 26724
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(string, "x", long, "y");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long a, b;
    scan(a, b);
    if(a <= 8 && b <= 8)
        writeln("Yay!");
    else
        writeln(":(");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

int main() {
  int r, g, b, n; cin >> r >> g >> b >> n;
  ll ans = 0;
  rep(i,n/r+1) {
    rep(j,n/g+1) {
      int sum = i*r + j*g;
      if (sum <= n && (n - sum) % b == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
using namespace std;
#define EPS 1e-9
typedef complex<double> P;

class comp{
public:
  double length;
  bool up,my;
  bool operator < (const comp & a)const{
    return length <  a.length;
  }
};

class point{
public:
  P data[2];
  bool up,my;
};

double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}
double dot(P a,P b){
  return a.real()*b.real()+a.imag()*b.imag();
}
bool ispointonline(P a1,P a2,P b){
  if ( abs(b-a1)+abs(b-a2)< abs(a1-a2)+EPS)return true;
  else return false;
}
bool isintersect(P a1,P a2,P b1,P b2){
  if ( ispointonline(a1,a2,b1) )return true;
  if ( ispointonline(a1,a2,b2) )return true;
  if ( ispointonline(b1,b2,a1) )return true;
  if ( ispointonline(b1,b2,a2) )return true;
  if ( cross(a2-a1,b1-a1)*cross(a2-a1,b2-a1) < 0 && 
       cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1) < 0)return true;
  else return false;
}
double distance_ls_p(P a1,P a2,P b1){
  if ( dot(a2-a1,b1-a1) <0)return abs(b1-a1);
  if ( dot(a1-a2,b1-a2) <0)return abs(b1-a2);
  return abs(cross(a2-a1,b1-a1))/abs(b1-a1);
}

P intersectpoint(P a1,P a2,P b1,P b2){
  double d1 = abs(cross(b2-b1,a1-b1));
  double d2 = abs(cross(b2-b1,a2-b1));
  double t = d1/(d1+d2);
  return a1 + (a2-a1)*t;
}

int compute(vector<point> a,P inp[2],int n){
  vector<comp> res;
  for(int i=0;i<a.size();i++){
    if ( isintersect(inp[0],inp[1],a[i].data[0],a[i].data[1])==false)continue;
    P tmp = intersectpoint(inp[0],inp[1],a[i].data[0],a[i].data[1]);
    double leng = abs(tmp-inp[0]);
    comp ins = {leng,a[i].up,a[i].my};
    res.push_back(ins);
  }
  if ( res.size() == 0)return 0;
  sort(res.begin(),res.end());
  int cnt = 0,myup,mymy = 1;
  if ( res[0].my == 1){
    myup = res[0].up;
  }else{
    myup = !res[0].up;
  }
  //cout << myup << endl;
  for(int i=1;i<res.size();i++){
    bool  my  = res[i].my,up = res[i].up;
    //cout << " up "  << up << " my " << my << " now " << myup << endl;
    if ( my == 1){
      if ( up != myup){
	cnt++;
	myup = !myup;
      }
    }else {
      if ( up == myup){
	cnt++;
	myup= !myup;
      }
    }
  }

  return cnt;
}


int main(){
  int te;
  for(cin >> te;te;te--){
    P inp[2];
    cin >> inp[0].real() >> inp[0].imag() >> inp[1].real() >> inp[1].imag();
    vector<point> a;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
      point temp;
      cin >> temp.data[0].real() >> temp.data[0].imag() 
	  >> temp.data[1].real() >> temp.data[1].imag() 
	  >> temp.my >> temp.up;
      a.push_back(temp);
    }
    cout       << compute(a,inp,n) << endl;
  }
  return 0;
}

Measured memory_bytes: 988
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define LL long long
using namespace std;

int main(void) {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  const int dx=tx-sx, dy=ty-sy;

  cout << string(dy, 'U') << string(dx, 'R');
  cout << string(dy, 'D') << string(dx, 'L');
  cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') << 'D';
  cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U';
  cout << endl;
  return 0;
}


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

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    
    sort(a.begin(),a.end());
    cout<<a[a.size()-1]-a[0];
    

    
    return 0;
    }


Measured memory_bytes: 3596
#include <iostream>
#include <string>
using namespace std;
// 奇数文字列における回文判定の関数
bool isPalidrome(string s){
    int j = 0;
    for (int i=0;i<(int)s.size()/2;++i){
        j = s.size()-i-1;
        if (s[i]!=s[j]) return false;
    }
    return true;
}
int main(){
    string s;
    cin >> s;
    if (isPalidrome(s)){
        if(isPalidrome(s.substr(0,(int)s.size()/2))) {
            cout << "Yes";
        } else {
            cout << "No";
        }
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>

using namespace std;

int main(){
	string s;
	string t;
	cin >> s;
	cin >> t;
	bool bad = false;

	int size = s.size();
//	cout << size;

	for(int i = 0; i < size; i++){
		if(s[i] != t[i]){
			bad = true;
//			cout << i;
			break;
		}
	}

	if(bad)
		cout << "No";
	else
		cout << "Yes";
}

Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
        int x = sc.nextInt();

        int[] l = new int[n];

        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }

        int[] d = new int[n + 1];

        int i = 1;
        while (i < n + 1) {
            d[i] = d[i - 1] + l[i - 1];
            i++;
        }

        Arrays.sort(d);
        int res = 0;
        int index = 0;
        while (true) {
            if (n + 1 <= index)
                break;

            if (d[index] <= x) {
                res++;
            } else {
                break;
            }
            index++;
        }

        out.println(res);
        out.flush();
    }

    //    public static void calcD(Map<Integer, Integer> dic, int index, )

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <atcoder/scc>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  using namespace atcoder;
  
  int n, m;
  cin>>n>>m;
  int a[m], b[m];
  REP(i, m) cin>>a[i]>>b[i];
  
  scc_graph graph(n);
  REP(i, m) graph.add_edge(a[i], b[i]);
  vector<vector<int>> cmps = graph.scc();
  
  int k = cmps.size();
  cout << k << endl;
  REP(i, k){
    int l = cmps[i].size();
    cout << l << ' ';
    for(int v: cmps[i]) cout << v << ' ';
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 44500
N = int(input())
a = [int(x) for x in input().split()]

li = [0 for _ in range(10**5+1)]
ans = 0
for i in a:
    li[i]+=1
for ind,x in enumerate(li[:-2]):
    ans = max(ans,x+li[ind+1]+li[ind+2])
print(ans)


Measured memory_bytes: 13964
readlines.map(&:to_f).each{|q|
  break if q == -1
  x = q / 2.0
  loop do
    break if (x * x * x - q).abs < 0.00001 * q
    x -=  (x * x * x - q)/(3.0*x * x)
  end
  puts "%.8f" % x
}

Measured memory_bytes: 8628
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAX_N=1E2,MAX_K=5*1E3;
const int INF=2*1E8;

int n,k;

int G[MAX_N][MAX_N];
int d[MAX_N];

bool used[MAX_N];

int dijkstra(int s,int g){
	fill(used,used+n,false);
	fill(d,d+n,INF);
	d[s]=0;
	while (1){
		int v=-1;
		for (int i=0;i<n;i++){
			if (!used[i] && (v==-1 || d[i]<d[v])){
				v=i;
			}
		}
		if (v==g) break;
		used[v]=true;
		for (int i=0;i<n;i++){
			d[i]=min(d[i],d[v]+G[v][i]);
		}
	}
	return d[g];
}

int main(){
	do{
		scanf("%d %d",&n,&k);
		if (n || k){
			for (int i=0;i<n;i++){
				for (int j=0;j<n;j++){
					G[i][j]=INF;
				}
			}
			for (int i=0;i<k;i++){
				int t;
				scanf("%d",&t);
				if (t==0){
					int a,b;
					scanf("%d %d",&a,&b);
					int dist=dijkstra(a-1,b-1);
					printf("%d\n",dist==INF ? -1 : dist);
				}
				else{
					int c,d,e;
					scanf("%d %d %d",&c,&d,&e);
					c--;
					d--;
					G[c][d]=min(G[c][d],e);
					G[d][c]=min(G[d][c],e);
				}
			}
		}
	}while (n || k);
	return 0;
}

Measured memory_bytes: 1068
var
 x,y,z,i,j,k,p,sum:longint;
begin
 readln(x);
 readln(y);
 readln(z);
 readln(p);
  for i:=0 to x do
   for j:=0 to y do
    for k:=0 to z do
     if i*500+j*100+k*50=p then inc(sum);
     writeln(sum);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n; cin>>n;
  vector<int> a(n);
  rep(i, n) cin>>a[i];

  long long cur = 1000;
  rep(i, n-1) {
    if (a[i] < a[i+1]) {
      long long stock = cur / a[i];
      cur -= (a[i] * stock);
      cur += (a[i+1] * stock);
    }
  }
  print(cur);

  return 0;
}

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

#define int long long

#define rep(i,s,n) for(int i = (s);i<(n);i++)
#define repe(i,s,n) for(int i = (s);i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;

int n,m,cnt=0;
char c;

signed main(){
    cin>>n>>m;
    rep(i,0,n*m){
        cin>>c;
        if(c=='#')cnt++;
    }
    
    
    
    (cnt==n+m-1)?puts("Possible"):puts("Impossible");
    return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> c(h, vector<char>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> c.at(i).at(j);
        }
    }

    vector<vector<char>> c2;
    c2.assign(h*2, vector<char>(w));
    for(int i=0; i<h*2; i++){
        for(int j=0; j<w; j++){
            c2.at(i).at(j) = c.at(i/2).at(j); 
        }
    }

    for(int i=0; i<h*2; i++){
        for(int j=0; j<w; j++){
            cout << c2.at(i).at(j); 
        }
        cout << endl;
    }
    return 0;
}


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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vp;

int vec[100100];
ll dp[200][100100];

int main(){
	int n, k;
	sii(n, k);

	vec[0] = 0;
	for(int i = 1; i <= n; i++)
		si(vec[i]);

	dp[0][0] = 1;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= 100000; j++){
			if(i == 0 && j == 0)
				continue;
			if(j-1 >= 0){
				dp[i][j] += dp[i][j-1];
				dp[i][j] %= M;
			}
			if(i-1 >= 0){
				dp[i][j] += dp[i-1][j];
				dp[i][j] %= M;
				if(j-vec[i]-1 >= 0){
					dp[i][j] -= dp[i-1][j-vec[i]-1];
					dp[i][j] = (dp[i][j]%M+M)%M;
				}
			}
		}
	}
	ll ans = dp[n][k] - dp[n][k-1];
	ans = (ans%M + M)%M;
	printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 82776
import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    char val = sc.nextLine().charAt(0);
	    if(Character.isUpperCase(val)){
	        System.out.println('A');
	    }else{
	        System.out.println('a');
	    }
	}
}

Measured memory_bytes: 35704
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int H1,M1,H2,M2,K;
	cin>>H1>>M1>>H2>>M2>>K;
	int ans = H2*60+M2-(H1*60+M1)-K;
	cout<<ans;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
string S;
int ans;
string now;

bool check() {
    int index = 0;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == now[index]) index++;
        if(index == 3) return true;
    }
    return false;
}

void dfs() {
    if(now.size() == 3) {
        if(check()) ans++;
        return;
    }
    for(char a = '0'; a <= '9'; a++) {
        now.push_back(a);
        dfs();
        now.pop_back();
    }
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> S;
    dfs();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion
n, q = map(int, input().split())

tree_index = [[] for _ in range(n)]
for i in range(n-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  tree_index[a].append(b)
  tree_index[b].append(a)

ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x

def dfs(cur, par):
  for child in tree_index[cur]:
    if child == par:
      continue
    ans[child] += ans[cur]
    dfs(child, cur)
dfs(0, -1)
print(*ans)

Measured memory_bytes: 230928
my $s=<>;chomp $s;
if ($s eq "SSS"){print "0";}
elsif($s eq "RRR"){print"3";}
elsif($s eq "SRR"||$s eq "RRS"){print"2";}
elsif($s eq "SSR"||$s eq "SRS"||$s eq "RSS"||$s eq "RSR"){print"1";}


Measured memory_bytes: 4652
import sys

S = list(input())
T = list(input())

length = len(T)
position = len(S) - length

while position >= 0:
    text = S[position:position+length]
    for i in range(length):
        if text[i] == "?":
            text[i] = T[i]
    if text != T:
        position -= 1
    else:
        S[position:position+length] = T
        position = -10

if position != -10:
    print("UNRESTORABLE")
    sys.exit()

for i in range(len(S)):
    if S[i] == "?":
        S[i] = "a"

print("".join(S))





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

import heapq
a.sort(reverse=True)
q = []
ans = 0
heapq.heappush(q, -a[0])
for i in range(1, n):
    tmp = heapq.heappop(q)
    tmp *= -1
    ans += tmp
    heapq.heappush(q, -a[i])
    heapq.heappush(q, -a[i])
print(ans)

Measured memory_bytes: 31400
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for(int i=a;i<b;i++)
#define repds(i,a,b) for(int i=a+1;i<=b;i++)
#define rep(i,N) repd(i,0,N)
#define reps(i,N) repds(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){rep(i,N+1){rep(j,M+1){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
typedef pair<int,int> P;
const int INF=100000000;
const int dx[4]={ 0, 1, 0,-1};
const int dy[4]={ 1, 0,-1, 0};
//--------------------------------------//
int n;
int s[500];
int main(){
	cin>>n;
	bool m=n>0;
	n=abs(n);
	int c=0;
	if(n==0){
		cout<<"0"<<endl;
		return 0;
	}
	while(n>0){
		bool a=n&1==1;
		if(m&&a){
			if(c%2==0)
				s[c]+=1;
			else{
				s[c+1]+=1;
				s[c]+=1;
			}
		}
		else if(!m&&a){
			if(c%2==1)
				s[c]+=1;
			else{
				s[c+1]+=1;
				s[c]+=1;
			}
		}
		n>>=1;
		//cout<<a;
		c++;
	}
	//cout<<endl;
	rep(i,500){
		if(s[i]==2){
			s[i]=0;
			if(++s[i+1]==2) {s[i+2]--; s[i+1]=0;}
			s[i+2]++;
		}
	}
	bool b=false;
	rep(i,500){
		if(!b&&s[499-i]==0);
		else{
			b=true;
			cout<<s[499-i];
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N,M;
int A[100009], B[100009];
int inNum[100009];
vector<int> G[100009], rG[100009];
int par[100009];

void dfs(V vec){
    V nxt;
    for(auto u:vec){
        for(auto v:G[u]){
            inNum[v]--;
            if(inNum[v]==0){
                par[v]=u;
                nxt.push_back(v);
            }
        }
    }
    if(nxt.size()){
        dfs(nxt);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>M;
    rep(i,N+M-1){
        cin>>A[i]>>B[i];
        G[A[i]].push_back(B[i]);
        inNum[B[i]]++;
    }
    
    rep1(i,N){
        if(inNum[i]==0){
            dfs({i});
        }
    }
    
    rep1(i,N){
        cout1(par[i])
    }
}

Measured memory_bytes: 27392
#include <vector>
#include <iostream>

using namespace std;

//dp[i][j]=(頂点iを(j = 1黒く: j = 0白く)塗ったとき、iを親とする部分木の塗り方の場合の数)
long long dp[100100][2];
//long long dp[100][2];

vector<vector<int>> g;
const int MOD = 1e9 + 7;

void dfs(int v, int p){
    dp[v][0] = 1;
    dp[v][1] = 1;

    for(auto next_n : g[v]){
        if(next_n == p) continue;
        dfs(next_n, v);
        //自分が白なら白黒どっちでもok
        dp[v][0] = dp[v][0] * (dp[next_n][0] + dp[next_n][1]);
        dp[v][0] %= MOD;
        //黒ならその前は絶対に白
        dp[v][1] = dp[v][1] * dp[next_n][0];
        dp[v][1] %= MOD;
    }
}

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

    g.resize(N);

    for(int i=0; i<N-1; ++i){
        int x, y;
        cin >>x >> y;
        --x; --y;

        g[x].push_back(y);
        g[y].push_back(x);
    }

    dfs(0, -1);
    cout << (dp[0][0] + dp[0][1])%MOD << endl;
}

Measured memory_bytes: 17168
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

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

    string s;

    cin >> s;

    for (int i = 0; i < s.size(); i++) {

        if (i%2 && s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {

            cout << "No";
            return 0;
        }

        if (i%2 == 0 && s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {

            cout << "No";
            return 0;
        }
    }

    cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int V=100000;
const int E=200000;
const int INF=0x3f3f3f3f;
int n,k,v[V+10],l[V+10],r[V+10];
int fir[V+10],nxt[E+10],to[E+10],tote;
void adde(int u,int v){to[++tote]=v;nxt[tote]=fir[u];fir[u]=tote;}
bool build(int u,int fa)
{
	if(~v[u])l[u]=r[u]=v[u];
	else{l[u]=-INF;r[u]=INF;}
	bool flag=true;
	for(int i=fir[u],v;i;i=nxt[i])
	{
		if((v=to[i])==fa)continue;
		flag&=build(v,u);
		l[u]=max(l[u],l[v]-1);
		r[u]=min(r[u],r[v]+1);
	}
	return flag&&l[u]<=r[u];
}
void solve(int u,int fa)
{
	if(u==1)v[u]=l[u];
	else if(l[u]<=v[fa]-1&&v[fa]-1<=r[u])v[u]=v[fa]-1;
	else if(l[u]<=v[fa]+1&&v[fa]+1<=r[u])v[u]=v[fa]+1;
	for(int i=fir[u],v;i;i=nxt[i])if((v=to[i])!=fa)solve(v,u);
}
bool check(int u,int fa)
{
	bool flag=((u==1)||(abs(v[u]-v[fa])==1));
	for(int i=fir[u],v;i;i=nxt[i])if((v=to[i])!=fa)flag&=check(v,u);
	return flag;
}
int main()
{
	scanf("%d",&n);
	for(int i=1,a,b;i<n;++i)
	{
		scanf("%d%d",&a,&b);
		adde(a,b);adde(b,a);
	}
	memset(v,-1,sizeof v);
	scanf("%d",&k);
	for(int i=1,a,b;i<=k;++i)
	{
		scanf("%d%d",&a,&b);
		v[a]=b;
	}
	if(build(1,0)&&(solve(1,0),check(1,0)))
	{
		puts("Yes");
		for(int i=1;i<=n;++i)printf("%d\n",v[i]);
	}
	else puts("No");
	return 0;
}

Measured memory_bytes: 10240
#include <cstdio>
#include <algorithm>
#include <vector>
#include <numeric>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back

int main() {
	while(1) {
		int n, m; scanf("%d %d", &n, &m);
		if(n == 0 && m == 0) break;
		vector<int> p;
		rep(i,n) {
			int t; scanf("%d", &t);
			p.pb(t);
		}
		sort(p.begin(), p.end(), greater<int>());
		int sum = 0;
		rep(i,n/m) {
			p[(i + 1) * m - 1] = 0;
		}
		printf("%d\n", accumulate(p.begin(), p.end(), 0));
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.length() <= k)
        cout << s;
    else
    {
        for(int i=0;i<k;i++)
            cout << s[i];
        cout << "...";
    }
    
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(void){

	int n,x;
	int i,j,k;
	int sum;

	while(scanf("%d %d",&n,&x)!=EOF){

		if(n==0 && x==0)
			break;

		sum = 0;

		for(i=1;i<=n;i++){
			for(j=i;j<=n;j++){
				for(k=j;k<=n;k++){
					if(i+j+k == x && i!=j && i!=k && j!=k)
						sum++;
				}
			}
		}

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

	}

	return 0;

}
	

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

int main() {
    int N, M, K; cin >> N >> M >> K;
    vector<int> A(N), B(M);
    ll A_sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A_sum += A[i];
    }
    for (int i = 0; i < M; i++) cin >> B[i];

    int num = 0, su = 0; ll B_sum = 0;
    for (int i = N; i >= 0; i--) {
        for (int j = num; j <= M; j++) {
            num = j;
            if (A_sum + B_sum > K) break;
            su = max(su, i + j);
            if (j == M) break;
            B_sum += B[j];
        }
        if (i == 0) break;
        A_sum -= A[i-1];
    }
    cout << su << endl;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h> 
using namespace std; 
#include <stack>
#define ll long long 
const ll INF=1000000007;
#define vecpair vector<pair <ll,ll> >
#define pb push_back
#define mp make_pair
#define vel vector<ll>
bool prime[100001];
void SieveOfEratosthenes() 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true.  
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=100000; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=100000; i += p) 
                prime[i] = false; 
        } 
    } 
  
    
} 
ll bs(vel a,ll s,ll e,ll x){
	int l=s;
	int h=e;
	int m;
	while(l<=h){
		m=(l+h)/2;
		if(a[m]>x) h=m-1;
		else if(a[m]<x) l=m+1;
		else return m;
		}
		return -1;
	}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
SieveOfEratosthenes();
ll test;
test=1;
while(test--){
int x;
cin>>x;
if(x>=30) cout<<"Yes";
else cout<<"No";
}
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
/////////////////////////////////
template<class T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

const ll INF = 1LL << 60;
ll dp[1000010];
int main(){
    rep(i, 1000010) dp[i] = INF;
    int n,k;
    cin >> n>>k;
    ll h[n];
    rep(i, n) cin >> h[i];
    dp[0] = 0;
    for (int i = 0; i < n;++i){
        for (int j = 1; j < k + 1 && i+j<=n;++j){
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 12228
#include<cstdio>
#include<iostream>
#include<cstdlib>
using namespace std;
typedef long long ll;
int n,m,c[15][15],a[202][202];
ll ans;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<=9;i++)
	{
		for(int j=0;j<=9;j++)
		{
			scanf("%d",&c[i][j]);
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(int k=0;k<=9;k++)
	{
		for(int i=0;i<=9;i++)
		{
			for(int j=0;j<=9;j++)
			{
				if(c[i][j]>c[i][k]+c[k][j])
				{
					c[i][j]=c[i][k]+c[k][j];
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]==-1)continue;
			else
			{
				ans+=c[a[i][j]][1];
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())

keta = int(math.log10(n)) + 1

memo = [ [None] * 10 for _ in range(10)]

ans = 0
for a in range(1, n+1):
    x = int(str(a)[0])
    y = a % 10

    if x == 0 or y == 0:
        continue

    if memo[x][y] is not None:
        ans += memo[x][y]
        # print(a, ans)
        continue
    
    patterns = 0
    for b in range(x, n+1, 10):
        x2 = int(str(b)[0])
        y2 = b % 10
        if x == y2 and y == x2:
            patterns += 1
    memo[x][y] = patterns
    ans += patterns
    # print(a, ans)

    # patterns = 0
    # # 1桁
    # if x == y and n <= x:
    #     patterns += 1
    
    # for k in range(keta-1):

print(ans)

Measured memory_bytes: 41436
/* 
 * File:   main.cpp
 * Author: Sebastian Hall
 * Created on August 21, 2020, 4:50 PM
 * Purpose: https://atcoder.jp/contests/dp/tasks/dp_e
 */

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

typedef long long ll;
typedef long double triple;

int main() {
    ios::sync_with_stdio(false);
    //Declare variables
    ll n = 0LL,  w = 0LL, total = 0LL;
    
    cin>>n>>w;
    
    //Read in values and weights, sum values
    vector<ll> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        cin>>weight[i]>>value[i];
        total += value[i];
    }
    
    vector<ll> dp(total + 1, 1e18 + 5);
    dp[0] = 0;
    
    //Iterate over each item
    for(int i = 0; i < n; ++i) {
        for(int j = total - value[i]; j >= 0; --j) {
            dp[j + value[i]] = min(dp[j + value[i]], dp[j] + weight[i]);
        }
    }
    
    //Get highest value with weight in range
    int ind = 0;
    for(int i = 0; i <= total; ++i) {
        if(dp[i] <= w) {
            ind = i;
        }
    }

    cout<<ind<<endl;
    //A Sebastian Production
    return 0;
}

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

const int MAX = 2000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    long long X, Y; cin >> X >> Y;
    long long res = 0;
    for(int i=0; i<=X; ++i) {
        if((X - i) & 1) continue;
        long long j = (X - i) / 2;
        if(2 * i + j != Y) continue;
        res = (res + COM(i + j, i)) % MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 47104
#include <stdio.h>
#include <stdbool.h>

int main(){
  int A[3][3];
  for(int i=0; i<3; i++){
    scanf("%d %d %d", &A[i][0], &A[i][1],&A[i][2]);
  }
  int N;
  bool B[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0 ,0}};
  int input;
  bool bingo = false;
  scanf("%d", &N);
  for(int k=0; k<N ; k++){
    scanf("%d", &input);
    for(int i=0; i<3; i++){
      for(int j=0; j<3; j++){
        if(A[i][j] == input){
          B[i][j] = 1;
        }
      }
    }
  }
  int add = 0;
  //horiziantal check
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      add+=B[i][j];
    }
    if(add == 3){
      bingo = true;
      break;
    }
    add = 0;
  }
  //vertical check
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      add+=B[j][i];
    }
    if(add == 3){
      bingo = true;
      break;
    }
    add = 0;
  }
  //diagonal check
  if(B[0][0]==1&&B[1][1]==1&&B[2][2]==1)
    bingo = true;
  if(B[0][2]==1&&B[1][1]==1&&B[2][0]==1)
    bingo = true;
  
  if(bingo==true){
    puts("Yes");
  }else{
    puts("No");
  }
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define F first
#define S second
#define MP make_pair
#define PB push_back
 
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)
int main(){
	string str;
	cin>>str;
	stack<char> st;
	fr(i,0,str.size()){
		if(str[i]=='0'||str[i]=='1')
			st.push(str[i]);
		else{
			if(!st.empty())
				st.pop();
		}
	}
	string ans="";
	while(!st.empty()){
		ans=st.top()+ans;
		st.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    string S;
    cin >> S;

    if(S.substr(S.size()-1,1)=="s"){
        cout << S << "es" << endl;
    }else{
        cout << S << "s" << endl;

    }

    

}

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

int n, m, Q, L[200009], R[200009], X[509][509], C[509][509];

int main() {
	cin >> n >> m >> Q;
	for (int i = 1; i <= m; i++) {
		cin >> L[i] >> R[i]; 
        X[L[i]][R[i]]++;
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
            C[i][j] = C[i][j-1] + X[i][j];
        }
	}
	for (int i = 1; i <= Q; i++) {
		int p, q; cin >> p >> q;
		int sum = 0;

		for (int j = p; j <= q; j++) { 
            sum += C[j][q] - C[j][p-1];
        }

		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 4480