akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    input = sys.stdin.readline

    INF = 10 ** 18

    N, M = map(int, input().split())

    G = [[] for _ in range(N + 1)]
    for _ in range(M):
        L, R, C = map(int, input().split())
        G[L].append([C, R])
        G[R].append([C, L])

    for i in range(1, N):
        G[i + 1].append([0, i])

    d = [INF] * (N + 1)

    def dijkstra(s):
        from heapq import heappop, heappush
        d[s] = 0
        pque = []
        heappush(pque, [0, s])
        
        while pque:
            p = heappop(pque)
            v = p[1]
            if d[v] < p[0]:
                continue
            for i in range(len(G[v])):
                e = G[v][i]
                if d[e[1]] > d[v] + e[0]:
                    d[e[1]] = d[v] + e[0]
                    heappush(pque, [d[e[1]], e[1]])

    dijkstra(1)

    print (-1 if d[-1] == INF else d[-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 97148
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int a = 0;
        int b = 0;
        int c = 0;
        for (int i = 0; i < 101; i++) {
            a = i;
            for (int j = 0; j < 101; j++) {
                b=j;
                if (a+b == X && 2*a+4*b == Y) {
                    c = c + 1;
                } else {
                    c = c;
                }
            }
        }
        if ( c >= 1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35772
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()

	fmt.Fprintln(wr, n*(n-1)/2+m*(m-1)/2)
}


Measured memory_bytes: 640
# Wrote in Mar 4, 2020 18:51 by reetok
require 'time'
require 'prime'
require 'bigdecimal'
def inp(type=:to_i,spst=" ")
  return eval("gets.chomp.split(#{spst}).map(&:#{type})")
end
def inpf() return self.inp(:to_f," ") end
def inps() return self.inp(:to_s," ") end
def r_up(a, b) (a/b).ceil end
def r_down(a, b) (a/b).floor end
def sum(a) a.inject(:+) end
def big(a,b) return (a>b)? a:b end
def small(a,b) return (a<b)? a:b end
def minp(n,datatype=:to_i)
  t = []
  n.times do
    t.push(eval("gets.chomp.#{datatype.to_s}"))
  end
end
def yes() puts "Yes" end
def no() puts "No" end
def ynju(bool,yes="Yes",no="No") puts (bool ? yes : no) end
class Integer
  def divisor_list
    devisors = [1]
    2.upto(self/2) do |i|
      devisors << i if self%i == 0
    end
    devisors << self
    return devisors.uniq.sort
  end
end
class Array
  def upper(a) #aより上
    self.sort.select{|n|n>=a}
  end
  def downer(a) #aより下
    self.sort.select{|n|n<=a}
  end
end

#---------------

pi = Math::PI

r = gets.to_f

puts [r**2*pi,2*pi*r].join(" ")


Measured memory_bytes: 7240
import sys
x,n=map(int,input().split())
if n==0:
  print(x)
  sys.exit()
p=list(map(int,input().split()))
jud=[0 for i in range(102)]
for i in p:
  jud[i]=1
if jud[x]==0:
  print(x)
  sys.exit()
diff=1
while 1:
  if x >= diff and jud[x-diff]==0:
    print(x-diff)
    break
  if x + diff < 102 and jud[x+diff]==0:
    print(x+diff)
    break
  diff+=1


Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define int long long
#define M 1000000007
signed main()
{
    rootdada;
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    int n;
    cin >> n;
    int s = 0;
    rep(i, 1, n + 1)
    {
        rep(j, 1, n + 1)
        {
            rep(k, 1, n + 1)
            {
                s += __gcd(i, __gcd(j, k));
            }
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int N;
const int fish=998244353;
string s;
int main(){
	scanf("%d",&N);
	int ans=1;
	cin>>s;
	for (int i=1;i<=N;i++)
		ans=1ll*ans*i%fish;
	int r=0,g=0,b=0,rg=0,rb=0,gb=0;
	for (int i=0;i<3*N;i++){
		if (s[i]=='R'){
			if (gb) {
				ans=1ll*ans*gb%fish;
				gb--;
			}
			else if (g){
				ans=1ll*ans*g%fish;
				g--;rg++;
			}
			else if (b) {
				ans=1ll*ans*b%fish;
				b--,rb++;
			}else r++;
		}
		if (s[i]=='B'){
			if (rg){
				ans=1ll*ans*rg%fish;
				rg--;
			}
			else if (g){
				ans=1ll*ans*g%fish;
				g--;gb++;
			}
			else if (r){
				ans=1ll*ans*r%fish;
				r--;rb++;
			}
			else b++;
		}
		else if (s[i]=='G'){
			if (rb){
				ans=1ll*ans*rb%fish;
				rb--;
			}
			else if (b){
				ans=1ll*ans*b%fish;
				b--;
				gb++;
			}
			else if (r){
				ans=1ll*ans*r%fish;
				r--;rg++;
			}
			else g++;
		}
	}
	cout<<ans%fish;
	return 0;
}

Measured memory_bytes: 900
#include<iostream>

int main()
{
    int S;
    int h,m,s;
    int h_buf,m_buf;

    std::cin>>S;

    h_buf=S%3600;
    h=(S-h_buf)/3600;

    m_buf=h_buf%60;
    m=(h_buf-m_buf)/60;

    s=m_buf;

    std::cout<<h<<":"<<m<<":"<<s<<std::endl;
    return 0;
}


Measured memory_bytes: 3112
using System;

namespace A___1222
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = Console.ReadLine ();
            var count = 0;
            foreach (var p in n)
            {
                if (p == '2')
                    count++;
            }
            Console.WriteLine (count);
        }
    }
}

Measured memory_bytes: 11092
n = gets.to_i
ary = gets.split.map(&:to_i)
gu = [0] * 100001
ki = [0] * 100001
n.times do |i|
  if i % 2 == 0
    gu[ary[i]]  += 1
  else
    ki[ary[i]]  += 1
  end
end
gu_index = gu.index(gu.max)
ki_index = ki.index(ki.max)
gusu = gu.max
kisu = ki.max

if gu_index == ki_index
  gu[gu_index] = 0
  ki[ki_index] = 0
  if gu.max + kisu > ki.max + gusu
    gusu = gu.max
  else
    kisu = ki.max
  end
end

puts n - gusu - kisu

Measured memory_bytes: 11660
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        while(true){
            int n=sc.nextInt();
            if(n==0){
                break;
            }
            int a[]=new int[n];
            int cnt=0;
	    int cnt2=0;
            for(int i=0;i<n;i++){
                a[i]=sc.nextInt();
                if(a[i]>=2){
                    cnt++;
                }
		if(a[i]>0){
		    cnt2++;
		}
            }
            if(cnt==0){
                System.out.println("NA");
            }else{
                System.out.println(cnt2+1);
            }
        }
    }
}


Measured memory_bytes: 154036
N, K = [int(a) for a in input().split()]

h = []

for _ in range(N):
    h.append(int(input()))

sortedh = sorted(h)

min_ = 1e9

for i in range(N-K+1):
    diff = sortedh[i+K-1] - sortedh[i]
    min_ = min(min_, diff)

print(min_)


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

int main(){
    int n, m;
    cin >> n;
    string s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    cin >> m;
    string t[m];
    for(int i = 0; i < m; i++){
        cin >> t[i];
    }
    int keeper, ans = 0;
    for(int i = 0; i < n; i++){
        keeper = 0;
        for(int j = 0; j < n; j++){
            if(s[i] == s[j]){
                keeper++;
            }
        }
        for(int j = 0; j < m; j++){
            if(s[i] == t[j]){
                keeper--;
            }
        }
        ans = max(ans, keeper);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
info = []

N = int(input())
for _ in range(N):
    info.append(tuple(map(int, input().split())))

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

highDiff = info[0][0] - 1
lowDiff = info[len(info) - 1][1]
middleDiff = info[len(info) - 1][0] - info[0][0] + 1

print(highDiff + lowDiff + middleDiff)


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

int main() {
    int a;
    cin >> a;
    int h=a/3600;
    a-=h*3600;
    int m=a/60;
    a-=m*60;
    int s=a;

    cout << h << ":" << m << ":" << s << endl;
  return 0;
}



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

int main(){
    std::vector<int> in_train;
    std::vector<int> out_train;
    
    int a; //for input

    while(std::cin >> a){
        if(a == -1){
	    break;
	}else if(a > 0){
	    in_train.push_back(a);
	}else if(a == 0){
	    int e = in_train.back();
	    //std::cout << e << std::endl;
	    out_train.push_back(e);
	    in_train.pop_back();
	}
    }
    
    
    while(out_train.empty() != true){
        int e = out_train.front();
        std::cout << e << std::endl;
        out_train.erase(out_train.begin());
    }
    
    return 0;
}

Measured memory_bytes: 3124
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<deque>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
template<typename T>
constexpr auto ALL(T v) { return v.begin(), v.end(); }
typedef long long ll;

using namespace std;

void Main() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
}

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

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

double a[100];
signed main(){
  int n;cin >> n;
  double ans;
  rep(i,n){
    double tmp;
    string str;
    cin >> tmp >> str;
    if(str == "JPY")ans += tmp;
    else ans += 380000.0 * tmp;
  }
  printf("%.7lf", ans);
  return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int sum = 0;
    for (int i = 0; i < n;i++){
        int h;
        cin >> h;
        if(h>=k)
            sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;
int n,m,k;
int mat[3001][3001];
int dp[3001][3001][4];
int dfs(int i,int j,int cur){
    if(i == n or j == m or cur == 3){
        return 0;
    }
    if(dp[i][j][cur] != -1){
        return dp[i][j][cur];
    }
    int &ans = dp[i][j][cur];
    ans = 0;
    if(mat[i][j] == 0){
        ans = max({ans,dfs(i+1,j,0),dfs(i,j+1,cur)});
    }
    else{
        ans = max({ans,mat[i][j] + dfs(i+1,j,0),mat[i][j] + dfs(i,j+1,cur+1),dfs(i,j+1,cur),dfs(i+1,j,0)});
    }
    return ans;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> k;
    memset(dp,-1,sizeof(dp));
    f(i,0,k){
        int x,y,val;
        cin >> x >> y >> val;
        x--;
        y--;
        mat[x][y] = val;
    }
    cout << dfs(0,0,0);
    return 0;
}
 

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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n;
long long x[max_n], y[max_n], r[max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    for (int i = 0; i <= n; ++i) {
        cin >> y[i];
    }
    if (n == 0) {
        if (y[0] == 1) {
            cout << 1 << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }
    if (y[0]) {
        cout << -1 << endl;
        return 0;
    }
    x[0] = 1;
    r[n] = 0;
    for (int i = n - 1; i >= 0; --i) {
        r[i] = r[i + 1] + y[i + 1];
    }
    for (int i = 1; i <= n; ++i) {
        x[i] = min(r[i], 2 * x[i - 1] - y[i]);
        if (x[i] < 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    long long tot = 1;
    for (int i = 1; i <= n; ++i) {
        long long val = x[i] + y[i];
        if (!(x[i - 1] <= val && val <= 2 * x[i - 1])) {
            cout << -1 << endl;
            return 0;
        }
        tot += val;
    }
    cout << tot << endl;
    return 0;
}


Measured memory_bytes: 5892
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val x = sc.nextInt


  val res = (x to x + 1000).find(isPrime).get

  println(res)

  def isPrime(num: Int): Boolean = {
    num match {
      case 1 => false
      case 2 => true
      case x => (2 to Math.sqrt(x).toInt).forall(num % _ != 0 )
    }
  }
}

Measured memory_bytes: 27208
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
x1,y1,x2,y2  = parseMap(split(readline()))
l_x = x2 - x1
l_y = y2 - y1

x3,y3 = x2 - l_y, y2 + l_x
x4,y4 = x1 - l_y, y1 + l_x

println("$x3 $y3 $x4 $y4")

Measured memory_bytes: 110344
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int solve(){
    int ans = 0;

    bool V[MAX];
    for(int i = 0; i < n; i++){
        B[i] = A[i];
        V[i] = false;
    }

    sort(B, B + n);
    for(int i = 0; i < n; i++) T[B[i]] = i;
    for(int i = 0; i < n; i++){
        if(V[i]) continue;
        int cur = i;
        int S = 0;
        int m = VMAX;
        int an = 0;
        while(1){
            V[cur] = true;
            an++;
            int v = A[cur];
            m = min(m, v);
            S += v;
            cur = T[v];
            if(V[cur]) break;
        }
        ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
    }

    return ans;
}

int main(){
    cin >> n;
    s = VMAX;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        s = min(s, A[i]);
    }
    int ans = solve();
    cout << ans << endl;

    return 0;
}


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

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))

#define isBitSet(S, i) ((S >> i) & 1)


/*
    WEWEWEEE W WWE
lw  011223333444
re  655443211110
4

    WWWWWEEE
lw  01234555
#rw

#le
re  333333210
3

*/
int solve(string& s) {
    if (s.size()==0){
        return 0;
    }
    if (s.size()<=2){
        return s.size()-1;
    }
    vector<int> lw, re;
    auto v = 0;
    lw.push_back(0);
    re.push_back(0);
    for (int i = 1; i<s.size(); i++)
    {
        auto val = lw.back();
        if (s[i-1]=='W'){
            val++;
        }
        lw.push_back(val);
    }
    for (int i = s.size()-2; i>=0; i--)
    {
        auto val = re.back();
        if (s[i+1]=='E'){
            val++;
        }
        re.push_back(val);
    }
    reverse(re.begin(), re.end());
    int minSol = s.size()-1;
    for (int i = 0 ; i < s.size(); i++)
    {
        minSol = min(minSol, lw[i]+re[i]);
    }
    return minSol;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int N; 
    cin >> N;
    string s;
    cin >> s;
    cout << solve(s) << endl; 
}

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

int main() {
        string a, b, c;
        cin >> a >> b >> c;
        if (a[a.size()-1] == b[0] &&
        b[b.size()-1] == c[0]) {
                cout << "YES" << endl;
        } else {
                cout << "NO" << endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    string b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();++i){
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 16565457023
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define vci vector<char>
#define all(n) (n.begin(),n.end())
#define forn(i,a,n) for(ll i=a;i<n;i++)


 const ll N = 2e5 + 2;
ll vis[N] = {}, ans = 0, c = 0;


void dfs(vli v[], ll x){
    if(!vis[x]){
        c++;
        // cout<<x<<" "<<c<<endl;
        ans = max(ans, c);
        vis[x] = 1;
        forn(i, 0, v[x].size()){
            dfs(v, v[x][i]);
        }
    }
    
}

int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll n, m;
    cin>>n>>m;
    vli v[n+1];
    ll x, y;
    forn(i, 0, m){
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    
    forn(i, 1, n+1){
        if(!vis[i]){
            // cout<<i<<":--"<<endl;
            c = 0;
            dfs(v, i);
            
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 22308
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 max = Math.max(a,b);
		int min = Math.min(a,b);
		for(int i =0;i<max;i++) {
			System.out.print(min);
		}
	}

}

Measured memory_bytes: 25684
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	set<int> a,b,c;
	a={1,3,5,7,8,10,12};
	b={4,6,9,11};
	c={2};
	int x,y;
	cin>>x>>y;
	if((a.count(x)&&a.count(y))||(b.count(x)&&b.count(y))||(c.count(x)&&c.count(y)))cout<<"Yes";
	else cout<<"No";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

int main() {

	int n;
	string s;
	cin >> n;
	cin >> s;

	int r = 0, g = 0, b = 0;	

	for(int i = 0; i < n; i++) {
		if(s[i] == 'R') r++;
		else if(s[i] == 'G') g++;
		else if(s[i] == 'B') b++;
	}

	ll ans = (ll)r * (ll)g * (ll)b;

	for(int sz = 1; sz < n; sz++) {
		for(int st = 0; st < n; st++) {
			int a = st, b = a + sz, c = a + sz + sz;
			if(c >= n) continue;
			if(s[a] != s[b] && s[a] != s[c] && s[c] != s[b]) ans--;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; i++)
#define FOR2(i, z, n) for(int i=z; i<n; i++)

struct item {
  int value, weight;
  item() {

  }
  item(int val, int we) {
    value = val;
    weight = we;
  }
};

int main() {
  int nbr_items, max_weight;
  cin >> nbr_items >> max_weight;
  vector<pair<item, vector<int> > > matrix(nbr_items + 1);

  FOR(i, nbr_items) {
    int we, val;
    cin >> val >> we;
    vector<int> vec(max_weight + 1, 0);
    item it(val, we);
    matrix[i] = make_pair(it, vec);
  }

  FOR(i, nbr_items) {
    FOR2(j, 1, max_weight + 1) {
      int max_value = matrix[i].second[j - 1];
      if (i > 0 && matrix[i - 1].second[j] > max_value) {
        max_value = matrix[i - 1].second[j];
      }
      if (i > 0 && j >= matrix[i].first.weight && max_value < matrix[i].first.value + matrix[i - 1].second[j - matrix[i].first.weight]) {
        max_value = matrix[i].first.value + matrix[i - 1].second[j - matrix[i].first.weight];
      }
      if (max_value < matrix[i].first.value && j == matrix[i].first.weight) {
        max_value = matrix[i].first.value;
      }
      matrix[i].second[j] = max_value;
    }
  }
  cout << matrix[nbr_items - 1].second[max_weight] << endl;
}


Measured memory_bytes: 6824
#include<stdio.h>
int main()
{

int dx,dy,x1,x2,x3,x4,y1,y2,y3,y4;
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
dx=x2-x1;
dy=y2-y1;
x3=x2-dy;
y3=y2+dx;
x4=x1-dy;
y4=y1+dx;
printf("%d %d %d %d\n",x3,y3,x4,y4);
return 0;



}






Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin>>a;
  int sum=0;
  for(int i=0;i<a.size();i++){
	if(a[i]=='2'){
      sum++;
    }
	else{
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

constexpr unsigned int max_buf = 1e5 + 1;

int count_cluster(std::vector<int> &cluster, const std::vector<std::vector<int>> &F, int i, int count)
{
	if (cluster[i] < 0)
	{
		cluster[i] = count;
		int sum = 1;
		for (int j : F[i])
		{
			sum += count_cluster(cluster, F, j, count);
		}
		return sum;
	}
	else
	{
		return 0;
	}
}

int main()
{
	int N, M, K;
	std::cin >> N >> M >> K;

	std::vector<std::vector<int>> F(N);
	std::vector<std::vector<int>> B(N);

	for (int i = 0; i < M; i++)
	{
		int a, b;
		std::cin >> a >> b;

		F[a-1].push_back(b-1);
		F[b-1].push_back(a-1);
	}

	for (int i = 0; i < K; i++)
	{
		int a, b;
		std::cin >> a >> b;

		B[a-1].push_back(b-1);
		B[b-1].push_back(a-1);
	}

	std::vector<int> cluster(N, -1);
	std::vector<int> cluster_ninzu(N);
	int cluster_count = 0;
	for (int i = 0; i < N; i++)
	{
		cluster_ninzu[i] = count_cluster(cluster, F, i, cluster_count++);
	}

	for (int i = 0; i < N; i++)
	{
		int ninzu = cluster_ninzu[cluster[i]] - F[i].size() - 1;
		for (int b : B[i])
		{
			if (cluster[b] == cluster[i])
			{
				ninzu--;
			}
		}
		std::cout << ninzu << " ";
	}
}

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

int main()
{
	int a, b;
	std::cin >> a >> b;
	int ans = 0;

	for (int i = 1; i <= b - a; i++)
	{
		ans += i;
	}

	std::cout << ans - b << std::endl;
	return 0;
}

Measured memory_bytes: 256
import math

def f(a,b,x,y):
    ans=math.sqrt( (a-x)*(a-x) + (b-y)*(b-y) )
    return ans

def circumcenter(ax,ay,bx,by,cx,cy):
    d = 2 * (ax * (by - cy) + bx * (cy - ay) + cx * (ay - by))
    if d==0:
        return (-1,-1)
    ux = ((ax * ax + ay * ay) * (by - cy) + (bx * bx + by * by) * (cy - ay) + (cx * cx + cy * cy) * (ay - by)) / d
    uy = ((ax * ax + ay * ay) * (cx - bx) + (bx * bx + by * by) * (ax - cx) + (cx * cx + cy * cy) * (bx - ax)) / d
    return (ux, uy)

n=int(input())
x=[]
y=[]
for i in range(n):
    u,v=map(int,input().split())
    x.append(u)
    y.append(v)
if n==2:
    ans=f(x[0],y[0],x[1],y[1])/2
    print("%0.12f"%ans)
else:
    radius=20000
    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):

                a,b=circumcenter(x[i],y[i],x[j],y[j],x[k],y[k])
                if a==-1 and b==-1:
                    continue
                r=f(a,b,x[i],y[i])

                ff=1
                for l in range(n):
                    if f(a,b,x[l],y[l])>r:
                        ff=0
                        break
                if ff:
                    radius=min(radius,r)
    for i in range(n):
        for j in range(i+1,n):
            a=(x[i]+x[j])/2
            b=(y[i]+y[j])/2
            r=f(x[i],y[i],x[j],y[j])/2
            ff=1
            for k in range(n):
                if f(a,b,x[k],y[k])>r:
                    ff=0
                    break
            if ff:
                radius=min(r,radius)
    print("%0.12f"%radius)

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

int main() {
    /*変数定義，入力*/
    int N;
    cin >> N;
    
    //ll A, B;cin >> A >> B;
    //vector<ll> a(N);  rep(i, N) cin >> a[i];
    
    /*演算*/
    int a = N/100;
    int b = (N - a * 100)/10;
    int c = N - a * 100 - b * 10;
    if(a == 7 || b == 7 || c == 7){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    /*出力*/

    /*終了*/
    return 0;
}

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

int main(){
	string A, B;
	cin >> A >> B;
	int x=A.size(), y=B.size(), c=0;
	if(x>y) cout << "GREATER", c++;
	if(x<y) cout << "LESS", c++;
	if(x==y){
		for(int i=0;i<x;i++){
			if(A[i]>B[i]){
				c++;
				cout << "GREATER";
				break;
			} else if(A[i]<B[i]){
				c++;
				cout << "LESS";
				break;
			}
		}
	}
	if(c==0) cout << "EQUAL" ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> W(N);
  int W_sum = 0;
  for (int i=0; i<N; i++){
    cin >> W.at(i);
    W_sum += W.at(i);
  }
  vector<int> ans(N-1);
  int s1 = 0;
  for (int i=0; i<N-1; i++){
    s1 += W.at(i);
    ans.at(i) = abs(2*s1 - W_sum);
  }
  sort(ans.begin(), ans.end());
  cout << ans.at(0) << endl;
}

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

namespace Volume20_2012
{
    class Program
    {
        static void Main(string[] args)
        {
            Calclation calclation = new Calclation();
            int enagy;
            while ((enagy = int.Parse(Console.ReadLine())) != 0)
            {
                Console.WriteLine(calclation.GetAppearPoint(enagy).Min());
            }
        }
    }
    class Calclation
    {
        internal IEnumerable<int> GetAppearPoint(int enagy)
        {
            for (int z = 0; Math.Pow(z, 3) <= enagy; ++z)
            {
                int y = (int)Math.Sqrt(enagy - (int)Math.Pow(z, 3));
                int x = enagy - (int)Math.Pow(z, 3) - (int)Math.Pow(y, 2);
                yield return x + y + z;
            }
        }
    }
}



Measured memory_bytes: 16192
# -*- coding: utf-8 -*-
"""
Created on Fri Jan  4 20:10:14 2019

@author: Yamazaki Kenichi
"""
import bisect

N, M= map(int,input().split())
C = [list(map(int,input().split())) for i in range(M)]

a = [[] for i in range(N)]
for j in range(M):
    a[C[j][0]-1].append(C[j][1])

for i in range(N):
    a[i].sort()

ans = []
for j in range(M):
    l = '0'*(6-len(str(C[j][0])))+str(C[j][0])
    r1 = bisect.bisect_left(a[C[j][0]-1],(C[j][1]))+1
    r = '0'*(6-len(str(r1)))+str(str(r1))
    ans = l + r 
    print(ans)


Measured memory_bytes: 36760
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
int n,k;
int a[51];
int ans;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=k;i++)ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
def resolve():
	n = int(input())
	dp = [[0]*3 for _ in range(n+1) ]
	for i in range(1, n+1):
		r = list(map(int, input().split()))
		for j in range(3):
			for k in range(3):
				if j == k:
					continue
				dp[i][j] = max(dp[i][j], dp[i-1][k] + r[j])
	print(max(dp[-1]))
resolve()

Measured memory_bytes: 22824
#include<stdio.h>
int main(){
    int N,L;
    int result=0;

    scanf("%d %d",&N,&L);

    if(L>=0){
        for(int i=L+1; i<L+N; i++)result+=i;
    }else{
        if(N+L>0){
            for(int i=L; i<0; i++)result+=i;
            for(int i=1; i<L+N; i++)result+=i;
        }else{
        	for(int i=L; i<L+N-1; i++)result+=i;
        }
    }

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

    return 0;
}


Measured memory_bytes: 128
//Sasayego! Sasayego! Shinzou wo Sasageyo!

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bitset>
#include <ctime>
#define debug(x)  cerr << #x << " = " << x << endl
#define lid (id << 1)
#define rid (lid ^ 1)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int arumin[maxN];
vector <int> G[maxN];

int LEVI(int v, int p = -1){
	int cnt[3] = {0, 0, 0};
	for (int u : G[v]){
		if (u == p)
			continue;
		cnt[LEVI(u, v)]++;
	}
	if (cnt[0] > 0 || cnt[2] > 1)
		return arumin[v] = 0;
	return arumin[v] = 2 - cnt[2];
}

int main(){
	time_t START = clock();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; scanf("%d", &n);
	for (int i = 1; i < n; i++){
		int u, v; scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	printf(LEVI(1) & 1 ? "Second\n" : "First\n");
	time_t FINISH = clock();
	cerr << "Execution time: " << (ld)(FINISH - START) / CLOCKS_PER_SEC * 1000.0 << " milliseconds.\n";
	return 0;
}
 


Measured memory_bytes: 9824
#include <bits/stdc++.h>
using namespace std;
#define int                 long long   
#define double              long double
#define endl                "\n"
#define pb                  push_back
#define PI                  3.1415926535897932384626433832795l
#define F                   first
#define S                   second
#define mp                  make_pair
#define f(i,n)              for(int i=0;i<n;++i)
#define loop(i,a,b)         for (int i=a ; i<b ;++i)
#define fastio              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define gcd(a,b)            __gcd((a),(b))
#define fill(a,value)       memset(a,value,sizeof(a));
#define minn(v)             *min_element(v.begin(), v.end());
#define maxx(v)             *max_element(v.begin(), v.end());
#define print(x)            cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
signed main() 
{
    fastio;
    string s;
    cin>>s;
    int c=0;
    for(auto p:s)
    {
        c+=(p=='x');
    }
    if(c<=7)print("YES")
    else print("NO")
    
    
    
    return 0;
    
    
}

Measured memory_bytes: 3636
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
xyc=[list(map(int,input().split())) for _ in range(m)]
ans=min(al)+min(bl)
for x,y,c in xyc:
    ans=min(ans,al[x-1]+bl[y-1]-c)
print(ans)

Measured memory_bytes: 38560
n,q = map(int, input().split())  
a = input() 
l = [0]*n; 

for i in range(2,n+1):
    x = a[(i-2):i]
    l[i-1] = l[i-2]
    if x=='AC':
        l[i-1] += 1

for i in range(q):
  le,ri = map(int, input().split())  
  print(l[ri-1]-l[le-1]) 



Measured memory_bytes: 6132
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
S = LS2()

a,b = 0,0
left = []
for i in range(N):
    if S[i] == '(':
        a += 1
    else:
        b += 1
    if a < b:
        a,b = 0,0
        left.append('(')

ANS = left + S + [')']*(a-b)

print(''.join(ANS))

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

using namespace std;

typedef long long int ll;

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

typedef pair<int,int> pair;

int main(){
    int n[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;

    cout << n[k-1] << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE NumDecimals #-}
module Main (main) where
import Control.Applicative
import Control.Monad
import Data.Maybe
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO ()
main = do
  n:w:_ <- getInts
  xs <- U.replicateM n $ do
    v:w:_ <- getInts
    return (v,w)
  print $ solve1 w xs

solve1 :: Int -> U.Vector (Int,Int) -> Int
solve1 w xs = U.maximum . U.foldl' step (U.replicate (w+1) 0) $
  xs
  where
    step maxs (val,weight) = U.generate (w+1) $
      \maxWeight -> (maxs U.! maxWeight)
                    `max` (val + (fromMaybe (-1e10) $ maxs U.!? (maxWeight - weight)))

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

using namespace std;

using int64 = long long;

void fail() {
  cout << "No\n";
  exit(0);
}

int main() {
  int N;
  cin >> N;
  map< string, priority_queue< int, vector< int >, greater< int > > > C;
  for(int i = 0; i < N; i++) {
    string x;
    int y;
    cin >> x >> y;
    C[x].push(y);
  }
  int M;
  cin >> M;
  int last = -1;
  while(M--) {
    string O;
    cin >> O;
    if(!C.count(O)) fail();
    auto &p = C[O];
    while(C[O].size() && C[O].top() <= last) C[O].pop();
    if(C[O].empty()) fail();
    last = C[O].top();
  }
  cout << "Yes\n";

}



Measured memory_bytes: 21908
n = int(input())
li = list(map(int,input().split()))

li.reverse()

ope=0
flg=0

for i in range(1,n):
    chk = li[i]-li[i-1]
    if chk>1:
        print('No')
        flg = 1
        break
    elif chk==1:
        li[i]-=1
    else:
        continue

if flg==0:
    print('Yes')

Measured memory_bytes: 20784
(defun main ()
  (let ((n (read))
        (ans 1)
        (a nil))
    ; read
    (loop :for _ :from 1 :to n
          :do (push (read) a))
    (setf a (sort a #'<))
    ;
    (loop :for ai :in a
          :do (progn 
                (setf ans (* ans ai))
                (when (> ans 1000000000000000000)
                  (format t "-1~%")
                  (return-from main))))
    (format t "~A~%" ans)))
(main)


Measured memory_bytes: 78428
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, M, A, B, C;
    string s, s2;
    cin >> s;
    int ans = 0;
    int tmp = 0;
    rep(i, s.size()){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') tmp++;
        else tmp = 0;
        ans = max(ans, tmp);        
    }
    cout << ans << endl;
}

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

int query(int x)
{
	cout << x - 1 << endl;
	string s;
	cin >> s;
	if (s == "Male")
		return 0;
	if (s == "Female")
		return 1;
	exit(0);
}

bool has_vacent(int l, int r, int sl, int sr)
{
	return sl ^ sr ^ ((r - l) & 1);
}
vector<int> a;
int main()
{
	int n;
	cin >> n;
	a.resize(n + 2);
	a[1] = query(1);
	int k1 = (n + 1) / 2;
	int k2 = k1 + 1;
	a[k1] = query(k1);
	a[k2] = query(k2);
	a[n + 1] = a[1];
	int l = 0, r = 0;
	if (has_vacent(1, k1, a[1], a[k1]))
	{
		l = 1;
		r = k1;
	}
	else if (has_vacent(k2, n + 1, a[k2], a[1]))
	{
		l = k2;
		r = n + 1;
	}
	else
	{
		assert(false);
	}
	while(true)
	{
		int mid = (l + r) / 2;
		a[mid] = query(mid);
		if (has_vacent(l, mid, a[l], a[mid]))
		{
			r = mid;
		}
		else if (has_vacent(mid, r ,a[mid], a[r]))
		{
			l = mid;
		}
	}
}


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

#define i_64 long long
const i_64 mod = (i_64)1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    i_64 n, m;
    cin >> n >> m;
    string s[n];
    for (string &i: s) cin >> i;
    i_64 dp[n + 1][m + 1];
    memset(dp, 0, sizeof dp);
    dp[1][1] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (i == 1 and j == 1) continue;
            if (s[i - 1][j - 1] == '#') continue;
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }
    cout << dp[n][m] << "\n";
    return 0;
}

Measured memory_bytes: 9088
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
t = input()

# ord('a') == 97 
abc = [[] for i in range(26)]
for i,j in enumerate(s):
    tmp = ord(j) - 97
    abc[tmp].append(i)
ln = [0] * 26
for i,j in enumerate(abc):
    ln[i] = len(j)
    # print(abc[i],ln[i])
count = 0
p = -1
for i,j in enumerate(t):
    tmp = ord(j) - 97
    if not abc[tmp]:
        print(-1)
        break
    c = bisect.bisect_left(abc[tmp],p+1)
    # print(c)
    if c == ln[tmp]:
        count += 1
        p = abc[tmp][0]
    else:
        p = abc[tmp][c]
else:
    print(count * len(s) + p + 1)

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

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

    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 3644
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

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

typedef long long int         lli;
typedef long long             ll;
typedef unsigned long long    ull;
typedef long double           ldb;
const   ll   N = 2e5+5;

#define         rep(i,n)       for ( i=0 ; i<n ; i++ )
#define         rep1(i,n)      for ( i=1 ; i<=n ; i++ )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rsajo(str)     reverse(str.begin(),str.end())
#define         pi             3.14159265359
#define         nel            printf("\n");
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"Yes"<<"\n";
#define         no             cout<<"No"<<"\n";
#define         pb             push_back
#define         pii            pair< ll , ll >
#define         ppi            pair< pii , ll >
#define         ff             first
#define         ss             second
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int fact(int n)
{
   if(n==0)
      return(1);
   return(n*fact(n-1));
}
int prm(ll n)
{
    ll j=0;
    while (n % 2 == 0){
        j++;
        n = n/2;}
    for (ll i = 3; i*i <= n ; i = i + 2){
        while (n % i == 0){
           j++;
        n = n/i;}
    }
    if (n > 2)
        j++;
    return j;
}

int main(){Faysal

    ll ans,cnt,sum,mx,mn,chk;

    ll n,q,a,b,x,y,i,j,k;

    cin>>n>>k;
    vector<ll>v(n);
    rep(i,n) cin>>v[i];
    sajo(v);
    cnt=0;
    for(i=0;i<n-k;i++)
    {
        x=v[i];
        cnt+=x;
    }
    cout<<cnt<<endl;

    return 0;

}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
int n,m;
vector <int> rel[100000];
int id[100001];
int visit[100001] = {0};
int s,t;


void check(int x, int u) { 
 visit[x] = 1;
  id[x] = u;

  int v ;
  for(int i=0;i<rel[x].size();i++) {
    v = rel[x][i];
    if(visit[v] == 0) {
      check(v,u);
    }
  }
}
    
  

int main() {

 

  cin >> n >> m;

 
  int a,b;


  for(int i=0;i<m;i++) {


    cin >> a >> b;

    rel[a].push_back(b);
    rel[b].push_back(a);

  }
  
  for(int i =0;i<n;i++) {
    if(visit[i] == 0) {
      check(i,i);
    }
  }
  

  int q;
  cin >> q;
  
  
  
  for(int i=0;i<q;i++) {
    cin >> s >> t;
    
    
    if(id[s] == id[t]) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;

}

Measured memory_bytes: 10572
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b, x;
    cin >> a >> b >> x;
    if (x >= a && x <= a + b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,k;
    cin >>a>>b>>k;
    if(b-a+1>=2*k){
        for(int i=a;i<a+k;i++) cout <<i<<endl;
        for(int i=b-k+1;i<=b;i++) cout <<i<<endl;
    }
    else{
        for(int i=a;i<=b;i++) cout <<i<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

A, B, K = MAP()

if K <= A:
    A -= K
    print(A, B)
elif K <= A + B:
    K -= A
    B -= K
    print(0, B)
else:
    print(0, 0)


Measured memory_bytes: 3064
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)7           __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

     ll a,b,c,k;
     cin>>a>>b>>c>>k;
     ll ans=0;
     if(a<=k)
        ans=ans+(a);
	 else
	 {
	 	ans=ans+k;
	 }
     k=k-a;
     if(k>0)
	 {
	 	k=k-b;
	 	if(k>0)
		{
			ans=ans-k;
		}
	 }

	 cout << ans ;


}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
    //cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main ()
{
	long long int x,min,max,sum,N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>x;
		if(i==0)max=min=sum=x;
		else {
			if(x<min)min=x;
			if(x>max)max=x;
			sum+=x;
		}
	}
	cout<<min<<" "<<max<<" "<<sum<<endl;
}

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

int main() {
  string S;
  cin >>S;
  int counter=0;
  if(S[0] == 'o') ++counter;
  if(S[1] == 'o') ++counter;
  if(S[2] == 'o') ++counter;
 
  cout << 700 + (counter*100) << endl;
}


Measured memory_bytes: 3600