akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int n,a;
    cin >> n;
    set<int> d;
    rep(i,n){
        cin >> a;
        d.insert(a);
    }
    PRINT(d.size());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
int main() {
int a,b;
scanf("%d%d",&a,&b);
if(a,b>=1&&a,b<=13){
    if(a>1&&b>1){
        if(a>b){
            printf("Alice");
        } else if(a<b){
            printf("Bob");
        }else{
            printf("Draw");
        }
    }
    if(a==1&&b>1)
        printf("Alice");
    else if (a>1&&b==1)
        printf("Bob");
    else if(a==1&&b==1)
        printf("Draw");
}
   return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

void solve(long long N, long long R)
{
    int diff = 0;
    if (N < 10)
    {
        diff = 100 * (10 - N);
    }
    cout << R + diff << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long R;
    scanf("%lld", &R);
    solve(N, R);
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int h,w;
  cin >> h >> w;
  string s;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s;
      if(s=="snuke"){
        cout << (char)(j+'A') << i+1 << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.text.*;
import java.io.*;
 
public class Main{
  public static void main(String[] args) throws ParseException,IOException {
    SimpleDateFormat f = new SimpleDateFormat("yyyy/MM/dd");
    Date heisei = f.parse("2019/04/30");
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    Date d = f.parse(in.readLine());
    if(d.after(heisei)) {
      System.out.println("TBD");
    }
    else {
      System.out.println("Heisei");
    }
  }
}

Measured memory_bytes: 21840
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> R[i];
  }
  int maxv = -2000000000;
  int minv = R[0];
  for (int i = 1; i < n; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
  cout << maxv << endl;
  return 0;
}



Measured memory_bytes: 3872
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

struct aa {
	vector<int>stays;
	int change_num;
	int cost;
	aa() :stays(), change_num(0), cost(1e9) {

	}
	aa(const vector<int>&_stays, const int _change_num, const int _cost) :stays(_stays), change_num(_change_num), cost(_cost) {

	}
	
};
bool operator<(const aa&l, const aa&r) {
	if (l.cost == r.cost) {
		if (l.change_num == r.change_num) {
			for (int s = 0; s < l.stays.size(); ++s) {
				if (l.stays[s] == r.stays[s])continue;
				else return l.stays[s] < r.stays[s];
			}
		}
		else {
			return l.change_num < r.change_num;
		}
	}
	else {
		return l.cost < r.cost;
	}
	return true;
}
int main() {
	int N, D; cin >> N >> D;
	vector<vector<int>>costs(D, vector<int>(N));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < D; ++j) {
			cin >> costs[j][i];
		}
	}
	vector<vector<aa>>dp(D + 1, vector<aa>(N+1));
	dp[0][N] = aa(vector<int>(), 0, 0);
	

	for (int d = 0; d < D; ++d) {
		for (int h = 0; h <= N; ++h) {
			if (d&&h == N)continue;
			for (int next = 0; next < N; ++next) {
				vector<int>nextstays(dp[d][h].stays);
				nextstays.emplace_back(next);
				const int nextcost = dp[d][h].cost + costs[d][next];
				const int nextchange_num = dp[d][h].change_num + (h != next);
				dp[d + 1][next] = min(dp[d + 1][next], aa(nextstays, nextchange_num, nextcost));
			}
		}
	}
	aa ans = dp[D][0];
	for (int i = 0; i < N; ++i) {
		if (dp[D][i] < ans)ans = dp[D][i];
	}
	cout << ans.cost << " " << ans.change_num-1 << endl;
	for (int i = 0; i < D; ++i) {
		cout << ans.stays[i] + 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3292
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define INFLL 1000000000000000000LL
#define MOD 1000000007
#define PI acos(-1)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>

using namespace std;

// clang-format on

int sgn(int x) { return (0 < x) - (x < 0); }

main {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  auto f = [&](bool p) -> int {
    int c = 0, s = a[0];
    if (p) {
      if (s <= 0) {
        c += abs(s) + 1;
        s = 1;
      }
    } else {
      if (s >= 0) {
        c += abs(s) + 1;
        s = -1;
      }
    }
    loop(i, 1, n) {
      if (s + a[i] == 0) {
        c++;
        s = -sgn(s);
        continue;
      }
      if (sgn(s) == sgn(s + a[i])) {
        s += a[i];
        c += abs(s) + 1;
        s = -sgn(s);
        continue;
      }
      s += a[i];
    }
    return c;
  };
  cout << min(f(false), f(true)) << endl;
  bye;
}


Measured memory_bytes: 1024
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 
#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl
 
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 200005;

V adj[N];
ll fact[N], subtree[N], ans[N], down[N];

ll power(ll a,ll n,ll m=M){
    ll ans=1;
    while(n){
        if(n&1) ans=ans*a;
        a=a*a;
        n=n>>1;
        ans=ans%m;
        a=a%m;
    }
    return ans;
}

void dfs1(ll n, ll p){
	for(auto i:adj[n])
		if(i!=p)
			dfs1(i,n);
	down[n] = 1;
	subtree[n] = 1;
	ll cnt = 1;
	for(auto i:adj[n])
		if(i!=p){
			subtree[n] += subtree[i];
			cnt = (cnt * power(fact[subtree[i]], M-2)) % M; 
			cnt = (cnt * down[i]) % M;
		}
	cnt = (cnt * (fact[subtree[n]-1])) % M;
	down[n] = cnt;
}

void dfs2(ll n, ll p, ll a, ll b, ll m){
	ll cur = 1;
	cur = (power(fact[b], M-2) * a)%M;
	for(auto i:adj[n])
		if(i!=p){
			cur = (cur * power(fact[subtree[i]], M-2)) % M; 
			cur = (cur * down[i]) % M;
		}
	ll cnt = cur;
	cnt = (cnt * fact[m-1]) % M;
	ans[n] = cnt;
	for(auto i:adj[n])
		if(i!=p){
			ll a = (((cur * fact[subtree[i]])%M * fact[m-subtree[i]-1])%M * power(down[i], M-2))%M;
			dfs2(i, n, a, m-subtree[i],m);
		}
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	fact[0] = 1;
	rep(i,1,n+1)	fact[i] = (fact[i-1]*i)%M;
	rep(i,0,n-1){
		ll u,v;
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs1(1,0);
	dfs2(1,0,1,0,n);
	rep(i,1,n+1)	cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 20976
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main(int argc,char** argv) {
	int n,i;
	cin >> n >> i;
	cout << n - i + 1;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
s = input()
t = input()

def gcd(a, b):
    if b > a:
        a,b = b,a
    a,b = b,a % b
    if b == 0:
        return a
    else:
        return gcd(a,b)
def lcm(a, b):
	return a * b // gcd (a, b)

if s[0] != t[0]:
    print(-1)
    exit()
if gcd(n,m) == 1:
    print(lcm(n,m))
    exit()

ans = lcm(n,m)
nn = ans//n
mm = ans//m
e = lcm(nn,mm)
for i in range(1,ans,e):
    # print(i // (ans//n),i // (ans//m))
    # print(s[i // (ans//n)],t[i // (ans//m)])
    if s[i // (ans//n)] != t[i // (ans//m)]:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define N 205
using namespace std;
int main(){
	long long n,m,r,dist[N][N],i,j,k,a,b,c,d,ans=1e9,res;
	vector<long long> vp,s;
	cin>>n>>m>>r;
	for(i=0;i<N;i++)
	{
		for(j=0;j<N;j++)
		{
			dist[i][j]=1e8;
			if(i==j)
			{
				dist[i][j]=0;
			}
		}
	}
	for(i=0;i<r;i++)
	{
		cin>>d;
		vp.push_back(d);
	}
	for(i=0;i<m;i++)
	{
		cin>>a>>b>>c;
		dist[a][b]=c;
		dist[b][a]=c;
	}
	for(k=1;k<=n;k++)
	{
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	s=vp;
	do
	{
		res=0;
		for(i=1;i<vp.size();i++)
		{
			res+=dist[vp[i-1]][vp[i]];
		}
		ans=min(ans,res);
		next_permutation(vp.begin(),vp.end());
	}while(vp!=s);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
s1 = str(input())
s = s1.split(' ')
k = int(s[0])
n = int(s[1])
l=[]

ls = str(input())
l = ls.split(' ')
l1 = [int(x) for x in l]

def dist(a,b,k):
    if(b>a):
        return (k-b)+a
    else:
        return a-b

l4=[]
for i in range(len(l1)):
    l4.append(k - dist(l1[i],l1[i-1],k))
        
    
print(min(l4))

Measured memory_bytes: 34380
#include <iostream>
     
    int main(){
    int n;
    std :: cin >> n;
     
    bool flag = false;

    if(n == 1)
    flag = true;
     
    for(int i = 2 ; i < 10 ; i++)
    if(n / i < 10 && n % i == 0)
    flag = true;
     
    std :: cout << (flag == true ? "Yes\n" : "No\n");
    }

Measured memory_bytes: 256
list = list(input())
n = len(list) - 1

for i in range(1 << n):
    aa = ["-"] * n
    for j in range(n):
        if (i >> j) % 2 == 1:
            aa[n - 1 -j] = "+"
    sum = 0
    for index, x in enumerate(list):
        if index == 0:
            sum = int(x)
        else:
            if aa[index-1] == "+":
                sum = sum + int(x)
            elif aa[index-1] == "-":
                sum = sum - int(x)

    if sum == 7:
        print("{0}{1}{2}{3}{4}{5}{6}=7".format(list[0], aa[0], list[1],
                                               aa[1], list[2], aa[2],
                                               list[3]))
        exit()


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

#define M1 1000000007
#define M2 1000000009
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define f0(i, n) for (int i = 0; i < (int)(n); ++i)
#define f1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fc0(i,l,r) for(int i = (int)(l); i<(int)(r); ++i)
#define fc1(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define fr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
 
void init()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
      freopen("error.txt", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
}

signed main()
{
    init();

    int n,c=0;
    cin>>n;
    string s;
    cin>>s;
    if(n%2!=0)
    {
      cout<<"No"<<endl;
    }
    else
    {
      f0(i,n/2){if(s[i]==s[i+n/2]){c++;}}
      if(c==n/2){cout<<"Yes"<<endl;}
      else
        cout<<"No"<<endl;
    }

    cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}

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

class Program{
    static long n;
    static long[] s;
    static long q;
    static long[] t;
    static void Main(){
        n = long.Parse(Console.ReadLine());
        s = Console.ReadLine().Split().Select(long.Parse).ToArray();
        q = long.Parse(Console.ReadLine());
        t = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long count = 0;
        for(int i=0; i<q; i++){
            if(Check(t[i]))count++;
        }
        Console.WriteLine(count);
    }
    
    static bool Check(long l){
        //???????????????s????????????????????¢?´¢???????????????
        //????????¨?????????????°??????¨?????§???????????£???mid?????¨??£????????????
        long lb = 0, ub = n;
        while(lb<ub){
            var mid = (lb+ub)/2;
            if(s[mid]==l) return true;
            else if(l<s[mid]) ub = mid;
            else lb = mid+1;
        }
        return false;
    }
}

Measured memory_bytes: 22608
(defn create-data [s]
  (map #(Long/parseLong %) (.split s " ")))

(defn chooseIntegers [[a b c]]
  (if (empty? (for [i (range 0 a)
                  :when (zero? (mod (+ (* i b) c) a))]
              "YES")
            )
         "NO"
         "YES"
    )
  )


(println (chooseIntegers (create-data (read-line))))


Measured memory_bytes: 69776
import sys
input = sys.stdin.readline
A, B, N = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ps = make_divisors(B - 1)
res = (A * N) // B - A * (N // B)
for i in ps:
  if N < i: continue
  for j in range(1, 10 ** 4 + 1):
    x = i * j
    if N < x: continue
    res = max(res, (A * x) // B - A * (x // B))
for x in range(1, min(N, 10 ** 4)):
  res = max(res, (A * x) // B - A * (x // B))
print(res)


Measured memory_bytes: 68636
#include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  ll ans=0;
  if(a+b<2*c) {
    ans=a*x+b*y;
    COUT(a*x+b*y);
  }
  else{
    if(x>y){
      x-=y;
      ans+=y*2*c+x*a;
      ans=min(ans,(x+y)*c*2);
      COUT(ans);
    }
    else{
      y-=x;
      ans+=x*2*c+y*b;
      ans=min(ans,(x+y)*c*2);
      COUT(ans);
    }
  }
}


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

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n;
	cin >> n;
	Array a(n, 0);
	REP(i, n) cin >> a[i];

	Array sum(n + 1, 0);
	REP(i, n) sum[i + 1] = sum[i] + a[i];

	Array con(n + 1, 0);
	REP(i, n) {
		con[i + 1] = con[i];
		if (a[i] >= 2) con[i + 1]++;
	}

	ll max = INF;
	REP(i, n) {
		ll sum_r= sum[n] - sum[i];
		ll sum_l = sum[i] - sum[0];
		chmin(max, abs(sum_r - sum_l));
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include<cstring>

using namespace std;

string in;
vector<int> P,A;

int main(){
  getline(cin,in);
  P.push_back(0);
  A.push_back(0);
  while(1){
    int n = in.find("apple",A.back()+5);
    if(n != -1) A.push_back(n);
    else break;
  }

  while(1){
    int n = in.find("peach",P.back()+5);
    if(n != -1) P.push_back(n);
    else break;
  }

  for(int i = 1; i < P.size(); i++)
    in.replace(P[i],5,"apple");
  for(int i = 1; i < A.size(); i++)
    in.replace(A[i],5,"peach");

  cout << in << endl;
  return 0;
}

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

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

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

using namespace std;

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

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> va(a);
    vector<int> vb(b);
    vector<int> vc(c);
    for (int i = 0; i < a; i++) {
        cin >> va[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> vb[i];
    }
    for (int i = 0; i < c; i++) {
        cin >> vc[i];
    }
    sort(va.begin(), va.end());
    reverse(va.begin(), va.end());
    sort(vb.begin(), vb.end());
    reverse(vb.begin(), vb.end());
    sort(vc.begin(), vc.end());
    reverse(vc.begin(), vc.end());

    int qa = x-1;
    int qb = y-1;
    int qc = 0;
    while (true) {
        if (qc == c) {
            qc--;
            break;
        }
        long long ca = qa == -1 ? 1e10 : va[qa];
        long long cb = qb == -1 ? 1e10 : vb[qb];
        long long cc = vc[qc];
        if (cc > ca || cc > cb) {
            if (ca <= cb) {
                qa--;
            } else {
                qb--;
            }
            qc++;
        } else {
            qc--;
            break;
        }
    }

    long long ans = 0;
    for (int i = 0; i <= qa; i++) {
        ans += va[i];
    }
    for (int i = 0; i <= qb; i++) {
        ans += vb[i];
    }
    for (int i = 0; i <= qc; i++) {
        ans += vc[i];
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
	string str[3];

	for (int i = 0; i < 3; i++)
		cin >> str[i];

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

	return 0;
}


Measured memory_bytes: 256
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const [N] = r.nn()

    const memo: { [i: number]: number } = {}
    const len = String(N).length
    const ni = Number(String(N)[0])
    const nj = Number(String(N)[len - 1])
    const nc = Number(String(N).substr(1, len - 2))

    for (let i = 1; i <= 9; i++) {
      for (let j = 1; j <= 9; j++) {
        const id = i * 10 + j

        memo[id] = 0

        for (let k = 0; k < len - 2; k++) {
          memo[id] += 10 ** k
        } // TODO Number('1'.repeat(k))
        if (i === j && i <= N) {
          memo[id] += 1
        }
        if (len === 1) {
          continue
        }
        // k === len - 2 の処理
        if (i > ni) {
          continue
        }
        if (i < ni) {
          memo[id] += 10 ** (len - 2)
          continue
        }
        memo[id] += nc + 1
        if (j > nj) {
          memo[id] -= 1
        }
      }
    }

    let sum = 0

    for (let i = 1; i <= 9; i++) {
      for (let j = 1; j <= 9; j++) {
        if (i === j) {
          sum += memo[i * 10 + j] ** 2
        } else {
          sum += memo[i * 10 + j] * memo[j * 10 + i]
        }
      }
    }

    return sum
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string s,t;
  cin >> s >> t;
  ll ns=s.size();
  ll nt=t.size();
  ll ans=nt;
  for(ll i=0;i<ns-nt+1;i++) {
    ll cnt=0;
    for(ll j=0;j<nt;j++) {
      if(s[i+j]!=t[j]) cnt++;
    }
    ans=min(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3560
import java.io.*;
import  java.util.*;

import static java.lang.System.in;

class Main{
    static long[] X,sum;
    static Edge[] edges;
    static int[] id,unconnected;
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        sum = new long[n+1];
        edges = new Edge[m];
        id = new int[n+1];
        unconnected = new int[n+1];

        for(int i=1;i<=n;i++) {
            sum[i] = sc.nextLong();
            id[i] = i;
        }
        for(int i=0;i<m;i++){
            int a = sc.nextInt(), b = sc.nextInt();
            long y = sc.nextLong();
            edges[i] = new Edge(a,b,y);
        }
        Arrays.sort(edges);
        for(int i=0;i<m;i++){
            Edge e = edges[i];
            union(e.left,e.right,e.weight);
        }
        int ans = unconnected[find(1)];
        System.out.println(ans);
    }
    static int find(int p){
        while(p!=id[p]){
            id[p] = id[id[p]];
            p = id[p];
        }
        return p;
    }
    static void union(int p, int q, long Y){
        int i = find(p), j = find(q);
        if(i==j){
            if(Y>sum[i]) unconnected[i]++;
        } else{
            if(Y<=sum[i]+sum[j]) unconnected[i]=0;
            else unconnected[i]+=1+unconnected[j];
            sum[i] += sum[j];
            id[j] = i;
        }
    }
    static class Edge implements Comparable<Edge>{
        int left, right;
        long weight;
        public Edge(int l, int r, long w){
            this.left = l; this.right = r;
            this.weight = w;
        }
        public int compareTo(Edge e){
            return Long.compare(this.weight,e.weight);
        }
    }
}


Measured memory_bytes: 110344
#include <iostream>

using namespace std;

template<class T>
class Math {
    public:
        T extgcd(T a, T b, T &x, T &y){
            if(b==0){
                x = 1; y = 0;
                return a;
            }
            T d = extgcd(b, a%b, y, x);
            y -= a/b * x;
            return d;
        }
};


int main(){
    int a,b;
    cin >> a >> b;
    Math<long long> m;
    long long x,y;
    m.extgcd(a,b,x,y);
    cout << x << ' ' << y << '\n';
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main(void){
    while (true){
        int m, e, r;
        cin >> m >> e >> r;
        if(m==-1&&e==-1&&r==-1) break;
        else if(m==-1||e==-1||m+e<30) cout << 'F' << endl;
        else if((m+e>=30&&m+e<50&&r>=50)||(m+e>=50&&m+e<65)) cout << 'C' << endl;
        else if(m+e>=65&&m+e<80) cout << 'B' << endl;
        else if(m+e>=80) cout << 'A' << endl;
        else if(m+e>=30&&m+e<50&&r<50) cout << 'D' << endl;
    }
    
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
    char a[15];
    int i,n,j,max=0,m;
    gets(a);
    n=strlen(a);
    for(i=0;i<n;i++)
    {
        if(a[i]=='A'||a[i]=='C'||a[i]=='G'||a[i]=='T')
        {
            m=1;
            for(j=i+1;j<n;j++)
            {
                if(a[j]!='A'&&a[j]!='C'&&a[j]!='G'&&a[j]!='T')
                    break;
                else
                    m++;
            }
            if(max<m)
                max=m;
            i=j;
        }
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int main(){
  REP(i,4000){
    int x,y; cin>>x>>y;
    if(x==0 && y==0){
      break;
    }else{
      if(x>y){ swap(x,y);}
      printf("%d %d\n",x,y);
    }
  }
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
 
using namespace std;
 
long long MAX = 1e18 + 9 ;
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vso(x) sort( x.begin() , x.end() )
#define aso(x) sort( x , x + x.size() )
#define print(x) cout << x << endl 
#define no cout << "NO\n" 
#define yes cout << "YES\n"
typedef long long ll ; 
typedef unsigned long long ull ;
typedef long double ld ;
typedef pair<ll, ll> pairs ;

ll a[500] , prefix[500] , x[500][500] ;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("problem_name.out", "w", stdout) ;
    //freopen("problem_name.in", "r", stdin) ;
    //ull h ; cin >> h ; srand(h) ;
    //int t ; cin >> t ; while(t--){}
    ll n ; cin >> n ;
    ll sum = 0 ;
    for ( ll i = 1 ; i <= n ; i++ )
    {
        cin >> a[i] ;
        sum += a[i] ;
        prefix[i] = sum ;
    }

    for ( ll i = 1 ; i <= n ; i++ )
    {
        for ( ll j = 1 ; (j+i) <= n ; j++  )
        {
            ll mini = MAX ;
            for ( ll k = j  ; k < (i+j) ; k++ )
            {
                mini = min( mini , x[j][k] + x[k+1][(i+j)] ) ;
            }
            x[j][(i+j)] = mini + ( prefix[(i+j)] - prefix[j-1] ) ;
            //cout <<  i << "  " << j << "  " << x[j][(i+j)] << "\n" ;
        }
    }
    print(x[1][n]) ;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define dl double long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

int main()
{
  ll N, M;
  cin >> N >> M;
  rep(i, M) {ll hw; cin >> hw; N -= hw;}
  cout << max((ll)-1, N) << "\n";
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int64_t n, x, m, a, count_a = 0, ans = 0, temp, time;

	cin >> n >> x >> m;
	map<int64_t, pair<int64_t, int64_t>> loop;
	a = x;
	for (int64_t i = 0; i < n; i++)
	{
		count_a++;
		loop[a] = make_pair(ans, count_a - 1);
		ans += a;
		a = (a * a) % m;
		if (loop.count(a))
			break;
	}
	temp = ans - loop[a].first;
	time = (n - count_a) / (count_a - loop[a].second);
	temp = temp * time;
	ans += (temp < 0 ? 0 : temp);
	time = (n - count_a) % (count_a - loop[a].second);
	for (int64_t i = 0; i < time; i++)
	{
		ans += a;
		a = (a * a) % m;
	}
	cout << ans << endl;
}


Measured memory_bytes: 6696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n, W;    cin >> n >> W;
    vector<ll> v(n), w(n);
    REP(i, n)   cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n+1, vector<ll>(W+1, 0));

    REP(i, n){
        for(ll j=0; j<=W; j++){
            dp[i+1][j] = dp[i][j];
            if(w[i]<=j)
                dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i+1][j]);
        }

    }

    cout << dp[n][W] << endl;
}


Measured memory_bytes: 83176
import math
from math import sqrt
import sys
from collections import deque, defaultdict
from heapq import heappop,heappush
from copy import deepcopy

INF=10**18
MOD=10**9+7
MAX=10**5+7



def main():
  N=int(input())
  dp=[[0]*3 for i in range(MAX)]
  
  for i in range(N):
    a,b,c=map(int, input().split())
    dp[i+1][0]=max(dp[i][1]+a, dp[i][2]+a)
    dp[i+1][1]=max(dp[i][2]+b, dp[i][0]+b)
    dp[i+1][2]=max(dp[i][0]+c, dp[i][1]+c)
  print(max(dp[N]))

if __name__=='__main__':
  main()





Measured memory_bytes: 59628
import java.util.Scanner;


public class Main {

    public static String Y = "Yes";
    public static String N = "No";
    public static String I = "IMPOSSIBLE";
    public static String B = "Bad";
    public static String G = "Good";
    public static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int n = ni();
        String s = n();

        char[] cArr = s.toCharArray();

        long rcont = 0;
        long gcont = 0;
        long bcont = 0;
        long cont = 0;

        for (char c : cArr) {
            if (c == 'R') {
                rcont++;
            } else if (c == 'G') {
                gcont++;
            } else {
                bcont++;
            }
        }
        cont = rcont * gcont * bcont;

        long minus = 0;

        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; 2 * j - i < n; j++) {
                if (cArr[2 * j - i] != cArr[i] && cArr[j] != cArr[i] && cArr[2 * j - i] != cArr[j]) {
                    minus++;
                }

            }
        }

        out(cont - minus);
    }

    /*
     * 以下メソッド集
     */
    static int ni() {

        return sc.nextInt();
    }

    static long nl() {

        return sc.nextLong();
    }

    static String n() {

        return sc.next();
    }

    static char[] nc() {

        return sc.next().toCharArray();
    }

    static int kaijo(int n) {

        if (n == 0 || n == 1) {
            return 1;
        } else {
            return n * kaijo(n - 1);
        }
    }

    static int fib(int n) {

        return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
    }

    static long lcm(long m, long n) {

        return m * n / gcd(m, n);
    }

    static int lcm(int m, int n) {

        return m * n / gcd(m, n);
    }

    static long gcd(long a, long b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static int gcd(int a, int b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static void out(String info) {

        System.out.println(info);
    }

    static void out(int info) {

        System.out.println(info);
    }

    static void out(double info) {

        System.out.println(info);
    }

    static void out(long info) {

        System.out.println(info);
    }

    static void out(char info) {

        System.out.println(info);
    }

    static void outn(String info) {

        System.out.print(info);
    }

    static void outn(int info) {

        System.out.print(info);
    }

    static void outn(double info) {

        System.out.print(info);
    }

    static void outn(long info) {

        System.out.print(info);
    }

    static void outn(char info) {

        System.out.print(info);
    }

    static int max(int a, int b) {

        return Math.max(a, b);
    }

    static long max(long a, long b) {

        return Math.max(a, b);
    }

    static int min(int a, int b) {

        return Math.min(a, b);
    }

    static long min(long a, long b) {

        return Math.min(a, b);
    }
}

Measured memory_bytes: 27456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e15)+1;
const ll mod = ll(1e9)+7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}
int main(){
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2])pf("No");
    else pf("Yes");
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int h,w;
  char a[200][200];
  cin >> h >> w;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++)
      cin >> a[i][j];
  }
  int num_h[200],m = 0;
  for(int i = 0; i < h; i++) {
    bool flag = 0;
    for(int j = 0; j < w; j++) {
      if(a[i][j] == '.') flag = 1;
      else {
        flag = 0; break;
      }
    }
    if(flag) {
      num_h[m] = i; m++;
    }
  }
  int num_w[200],n = 0;
  for(int j = 0; j < w; j++) {
    bool flag = 0;
    for(int i = 0; i < h; i++) {
      if(a[i][j] == '.') flag = 1;
      else {
        flag = 0; break;
      }
    }
    if(flag) {
      num_w[n] = j; n++;
    }
  }

  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      for(int x = 0; x < m; x++) {
        if(i == num_h[x]) goto Exit1;
      }
      for(int y = 0; y < n; y++) {
        if(j == num_w[y]) goto Exit2;
      }
      cout << a[i][j];
      Exit2: ;
    }
    cout << endl;
    Exit1: ;
  }
}

Measured memory_bytes: 3656
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    boolean flg = true;
    for (int i=0; i<n; i++){
      a[i]=sc.nextInt();
      if (a[i] % 2 == 0) {
        if (a[i] % 3 == 0 || a[i] % 5 == 0) {

        } else {
          flg = false;
          break;
        }
      }
    }
    
      if (flg) {
        System.out.println("APPROVED");        
      } else {
        System.out.println("DENIED");                
      }
  }
}




Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <iomanip>

long long euclidean_gcd(long long a, long long b) {
	while(a > 0 && b > 0) {
		if(a > b) a %= b;
		else b %= a;
	}
	long long ret = (a == 0 ? b : a);
	return ret;
}

int main(void) {
	// in
	long long a, b, c, d;
	std::cin >> a >> b >> c >> d;

	// divide by c
	long long n_div_c = (b - a + ((a-1) % c) - (b % c) + 1) / c;
	//std::cout << n_div_c << std::endl;
	
	// divide by d
	long long n_div_d = (b - a + ((a-1) % d) - (b % d) + 1) / d;
	//std::cout << n_div_d << std::endl;
	
	// divide by ...
	long long e = c * d / euclidean_gcd(c, d);
	long long n_div_e = (b - a + ((a-1) % e) - (b % e) + 1) / e;
	//std::cout << n_div_e << std::endl;
	
	std::cout << (b - a + 1) - (n_div_c + n_div_d - n_div_e) << std::endl;

	return 0;
}


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

using namespace std;

void
Main() {
	int	N;
	cin >> N;
	string S;
	cin >> S;
	int	w;
	vector< int > wL( N );
	w = 0;
	for ( int i = 0; i < N; i++ ) {
		if ( S[ i ] == 'W' ) w++;
		wL[ i ] = w;
	}
	vector< int > wR( N );
	w = 0;
	for ( int i = N - 1; i >= 0; i-- ) {
		if ( S[ i ] == 'E' ) w++;
		wR[ i ] = w;
	}
	int	v = N;
	for ( int i = 0; i < N; i++ ) {
		auto l = ( i == 0 ) ? 0 : wL[ i - 1 ];
		auto r = ( i == N - 1 ) ? 0 : wR[ i + 1 ];
		if ( l + r < v ) v = l + r;
	}
	cout << v << endl;
}

int
main() {
	Main();
	return 0;
}



Measured memory_bytes: 3076
n,m = map(int,input().split())
lis = [[] for i in range(n)]
exist = [0 for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    lis[a-1].append(b-1)
    lis[b-1].append(a-1)
ans = 0
for i in range(n):
    if exist[i] == 0:
        ans += 1
        now = [i]
        while now:

            num = now.pop(0)
            exist[num] = 1
            for nu in lis[num]:
                if exist[nu] == 0:
                    now.append(nu)
                    exist[nu] = 1
print(ans-1)

Measured memory_bytes: 26280
n = int(input())
count = 0
for i in range(16):
  if count:
    break
  if n - i * 7 == 0:
    print('Yes')
    count = 1
    break
  for j in range(26):
    if n - i * 7 - j * 4 == 0:
      print('Yes')
      count = 1
      break
if not(count):
  print('No')

Measured memory_bytes: 9076
//Topological Sort
#include <iostream>
#include <vector>
#include <queue>
#include <list>

using namespace std;

static const int MAX = 100000;

vector<int> G[MAX];
queue<int> Q;
list<int> out;
bool V[MAX] = {};
int indeg[MAX] = {};
int N;

void bfs(int u) {
    while(!Q.empty()) Q.pop();
    int v;
    Q.push(u);
    V[u] = true;
    while(!Q.empty()) {
        v = Q.front();
        Q.pop();
        out.push_back(v);
        for(auto i : G[v]) {
            indeg[i]--;
            if(indeg[i] == 0) {
                Q.push(i);
                V[i] = true;
            }
        }
    }
}

void topologivalSort() {
    for(int i = 0; i < N; i++) {
        if(indeg[i] == 0 && !V[i]) bfs(i);
    }
}

int main() {
    int M, s, t;
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        indeg[t]++;
    }

    topologivalSort();

    for(auto itr = out.begin(); itr != out.end(); itr++) cout << *itr << endl;
}


Measured memory_bytes: 6112
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, L;
    cin >> N >> L;
    int sum = 0;
    rep(i, 0, N)
    {
        const int taste = L + i;
        sum += taste;
    }
    int ans = 0;
    int minAbs = 1 << 30;
    rep(i, 0, N)
    {
        const int taste = L + i;
        const int tmp = sum - taste;
        if (chmin(minAbs, abs(sum - tmp)))
        {
            ans = tmp;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
	#include<string.h>
	int main(){
		
		int a,b,c,e,d,f;
		
		scanf("%d %d %d", &a,&b,&c);
		
		e=a+b;
		d=a+c;
		f=b+c;
		if(e<d&&e<f){
			printf("%d", e);
		}
		else if(d<e&&d<f){
			printf("%d", d);
		}
		else printf("%d\n", f);
		return 0;
	}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			long[] tmp = new long[n];

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

			Arrays.sort(tmp);

			long result = 1;
			for (int i = 0; i < n; i++) {
				if (result % tmp[n - 1 - i] != 0) {
					result = lcm(result, tmp[n - 1 - i]);
				}
			}

			System.out.println(Long.toString(result));
		}
	}
	private static long lcm(long m, long n) {
	    return (m / gcd(m, n)) * n ;
	}
	private static long gcd(long m, long n) {
		return n == 0 ? m : gcd(n, m % n);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int N;
  cin >> N ;
  bool A = false ;
  for(int a=0;a<= N/4;a++){
    if((N-4*a)%7 == 0){
        A = true ;
        break;
    }
  }
  if(A)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

const int maxn = 1 << 19;
int mx[maxn << 1], siz;

inline int Max(int a, int b) {return a < b ? b : a;}

void init(int n) {
	for (siz = 1; siz < n; siz <<= 1) ;
	memset(mx, 0, sizeof(mx));
}

void upd(int i, int a, int b, int x, int v) {
	if (a + 1 == b) {mx[i] = v; return ;}
	int m = (a + b) >> 1;
	if (x < m) upd(i << 1, a, m, x, v);
	else upd(i << 1 | 1, m, b, x, v);
	mx[i] = Max(mx[i << 1], mx[i << 1 | 1]);
}

int qry(int i, int a, int b, int v, vector <int> &vec) {
	if (a + 1 == b) {vec.pb(a); return mx[i];}
	int m = (a + b) >> 1;
	if (v < mx[i << 1]) v = qry(i << 1, a, m, v, vec);
	if (v < mx[i << 1 | 1]) v = qry(i << 1 | 1, m, b, v, vec);
	return v;
}

struct T {
	int val, fix;
	T *ls, *rs;
	T(int v) {val = v; fix = rand(); ls = rs = NULL;}
};

void split(T *x, int v, T *&a, T *&b) {
	if (!x) {a = b = NULL; return ;}
	if (x->val <= v) a = x, split(x->rs, v, a->rs, b);
	else b = x, split(x->ls, v, a, b->ls);
}

T *merge(T *a, T *b) {
	if (!a || !b) return a ? a : b;
	if (a->fix < b->fix) {a->rs = merge(a->rs, b); return a;}
	else {b->ls = merge(a, b->ls); return b;}
}

int mxv(T *x) {if (x) while (x->rs) x = x->rs; return x ? x->val : 0;}
void prt(T *x) {if (x) prt(x->ls), printf("%d ", x->val), prt(x->rs);}

int n, a[maxn];
T *rt[maxn];
int lst[maxn];

int main() {
//	freopen("in", "r", stdin);
	srand(200);
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i) scanf("%d", &a[i]);
//	n = 2e5;
//	for (int i = 0; i < n; ++ i) a[i] = n - i;
	int m = 0;
	for (int i = 0; i < n; ++ i) {
		if (a[i] < a[i - 1]) m ++;
		rt[m] = merge(rt[m], new T(a[i])); lst[m] = a[i];
	}
	int n2 = n + m; init(n2);
	for (int i = 0; i <= m; ++ i) upd(1, 0, n2, i, lst[i]);
	int nw = n;
	for (int i = 0; i <= n; ++ i) {
		vector <int> vec;
		qry(1, 0, n2, 0, vec);
		++ m;
		int v = 0;
		for (int j = 0; j < vec.size(); ++ j) {
			T *a, *b;
			split(rt[vec[j]], v, a, b);
			rt[vec[j]] = a;
			upd(1, 0, n2, vec[j], mxv(a));
			v = mxv(b);
			rt[m] = merge(rt[m], b);
		}
		while (nw && mxv(rt[m]) == nw) {
			T *d; split(rt[m], nw - 1, rt[m], d); -- nw;
		}
		if (!nw) {printf("%d\n", i); break;}
		if (rt[m]) upd(1, 0, n2, m, mxv(rt[m]));
		else -- m;
//		for (int j = 0; j <= m; ++ j)
//			prt(rt[j]); puts("");
	}
//	printf("%.3f\n", clock() * 1.0 / CLOCKS_PER_SEC);
	return 0;
}


Measured memory_bytes: 17152
#include <stdio.h>
#include <string.h>
#include <ctype.h>
 
void b_rot(char s[]){
    int i;
    char buf=s[0];
    size_t last = strlen(s)-1;
    for(i=0;i<last;i++){
        s[i] = s[i+1];
    }
    s[i] = buf;
}
 
int main(){
    char s[200];
    char s_cp[200];
    int i,j,num,block[100];
    while(1){
        scanf("%s",s);
        if(!strcmp(s,"-"))break;
        scanf("%d",&num);
        for(i=0;i<num;i++){
            scanf("%d",&(block[i]));
        }
        for(i=0;i<num;i++){
            for(j=0;j<block[i];j++){
                b_rot(s);
            }
        }
        printf("%s\n",s);
    }
    return 0;
}



Measured memory_bytes: 2100