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

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n];
        for(int i=0;i<n;i++) a[i]=sc.nextInt();
        for(int i=n-1;i>=0;i--){
            System.out.print(a[i]);
            if(i!=0) System.out.print(" ");
        }
        System.out.printf("\n");
    }
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<long long Mod = mod>
constexpr long long MOD(long long in) {
    return in % Mod;
}
template<class T>
constexpr T UP(T left, T div) {
    return (left + div - 1) / div;
}

int n, m;
int num[100005];
int main()
{
    std::cin >> n >> m;

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

        ++num[a], ++num[b];
    }

    bool ok = true;
    for (int i = 0; i < n; ++i)
        if (num[i] % 2 != 0) {
            ok = false;
            break;
        }

    if (ok)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
    return 0;
}


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

using namespace std;
const int maxn = 1e5 +10;
typedef long long ll;
int n;
ll t;
ll ans[maxn] , a[maxn] , ok[maxn];
ll sum[maxn];
int main()
{
    cin >> n >> t;
    for(int i = 1; i <= n ; i ++){
        scanf("%lld" , &a[i]);
        sum[i] = sum[i-1] + a[i-1];
    }
    memset(ok , 0 , sizeof(ok));
    ll num = t / a[1] + 1;
    ll cha = 0;
    ans[1] = num;
    //ll lastT = (num-1)*a[1];

    for(int i = 2 ; i <= n ; i ++){
        cha = cha + a[i-1] - a[i];
        cha = max(0ll , cha);
        ans[i] = (t - sum[i]) / (a[i] + cha) + 1;
        if((t - sum[i]) % (a[i] + cha) >= a[i])ans[i] ++;
    }
    for(int i = 1 ; i <= n ; i++){
        if(ans[i] <= 0)ans[i] = 1;
        printf("%lld\n" , ans[i]);
    }
    return 0;
}



Measured memory_bytes: 6336
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
 
// ------------------------------------------------------------------------------------------------

ll n, i, pos, l, r;
vll ans;
string s;

void get_rl() {
    for (r = 0; i < n && s[i] == 'R'; i++, r++);
    pos = i;
    for (l = 0; i < n && s[i] == 'L'; i++, l++);
}

int main() {
    fast_io; cout_precision;
    cin >> s;
    n = s.length();
    i = 0;
    ans.assign(n, 0);
    while (1) {
        get_rl();
        if (r == 0) {
            ans[0] += l;
        } else if (l == 0) {
            ans[n - 1] += r;
        } else {
            ans[pos - 1] += l / 2 + (r + 1) / 2;
            ans[pos] += (l + 1) / 2 + r / 2;
        }
        if (i >= n) {
            break;
        }
    }
    copy(ans.begin(), ans.end(), ostream_iterator<ll>(cout, " "));
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    sort(L.begin(), L.end(), greater<int>());
    int m = 0;
    for (int i = 1; i < L.size(); i++)
        m += L[i];
    if (L[0] < m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
    
long long F_0_N(long long n)
{
     long long  pair_num;
     
     if (n <= 0) return 0;             
     pair_num =  (n + 1) >> 1;
     return  ((n & 0x01) ? (pair_num & 0x01) : (pair_num & 0x01) ^ n);       
 }
     
long long F_A_B(long long a, long long b)
{
    if (a == b) return a;
    return (F_0_N(a - 1) ^ F_0_N(b));
}
     
//A ～　B までの論理和を求める
int main(int argc, char *argv[])
{
    long long A, B;
    long long xor_v;
  
    scanf("%lld %lld", &A, &B);
    xor_v =  F_A_B(A, B);
  
    printf("%lld\n", xor_v);
     
    return 0;
}

Measured memory_bytes: 128
h,w,x=map(int,input().split())
c=[input() for _ in [0]*h]
print(sum(x==sum(i>>k&1 and j>>l&1 and c[k][l]=='#' for k in range(h) for l in range(w)) for i in range(2**h) for j in range(2**w))
)

Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while (true)
    {
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }

        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            return 0;
        }


        /* code */
    }
    

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int a,b;
    cin >> a >> b;
    pr((a*b)%2?"Odd":"Even");
}

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

//グラフを隣接行列で管理する
bool G[10][10];

int main(){
    int n,m; cin >> n >> m;
    for(int i=0; i<m; i++){
        int a,b; cin >> a >> b; a--; b--;
        G[a][b] = G[b][a] = true;
    }

    //順列
    vector<int> ord(n);
    for(int i=0; i<n; i++) ord[i] = i;
    //n=5ならord={0,1,2,3,4} 

    //順列を全部試す
    //next_permutation
    int ans = 0;
    do{
        //スタート地点が0ではない場合break
        if(ord[0] != 0) break;

        //全列挙した並び順に道があるか確認
        bool ok = true;
        //最後の要素は確認しなくていいから、i<n-1
        for(int i=0; i<n-1; i++){
            int from = ord[i];
            int to = ord[i+1];
            if(!G[from][to]) ok = false;
        }
        if(ok) ans++;
    }while(next_permutation(ord.begin(),ord.end()));
        
    cout << ans << endl;
}

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

using namespace std;

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

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 12345678901234567

const int maxn = 1e5 + 10;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	
	ll n,m; cin >> n>>m;

	ll ans;
	if (n * 2 > m) ans = m / 2;
	else
	{
		ll nokori = m - n * 2;
		ans = n + (nokori / 4);
	}

	Print(ans);
	// your code finished
	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int n, x;
    int i, j, k, count=0;
    while (1) {
        scanf("%d %d", &n, &x);
        if (n==0 && x==0) {
            break;
        }
        for (i=1; i+2<=n; i++) {
            for (j=i+1; j+1<=n; j++) {
                for (k=j+1; k<=n; k++) {
                    if (i+j+k==x) {
                        count++;
                    }
                }
            }
    }
    
        printf("%d\n", count);
        count=0;
    }
    return 0;
}



Measured memory_bytes: 2040
N = int(input())

reslis = []
for i in range(N + 1):
    count = 0
    temp = i
    while True:
        count += temp % 9
        if temp//9 == 0:
            break
        else:
            temp = temp//9
    temp = N - i
    while True:
        count += temp % 6
        if temp//6 == 0:
            break
        else:
            temp = temp//6
    reslis.append(count)


reslis.sort()
print(reslis[0])

Measured memory_bytes: 4308
#include <iostream>
using namespace std;
int main(){
    int n,b,f,r,v;
    const int B = 4, F = 3, R = 10;
    int inf[B][F][R] = {0};
    
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        inf[b-1][f-1][r-1] += v;
    }
    
    for(int i=0;i<B-1;i++){
        for(int j=0;j<F;j++){
            for(int k=0;k<R;k++){
                cout << " " << inf[i][j][k];
            }
            cout <<endl;
        }
        cout << "####################" <<endl;
    }
    
    for(int i=B-1;i<B;i++){
        for(int j=0;j<F;j++){
            for(int k=0;k<R;k++){
                cout << " " << inf[i][j][k];
            }
            cout <<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Long K = in.nextLong();
        Long A = in.nextLong();
        Long B = in.nextLong();

        if (A >= K) {
            System.out.println(1);
        } else if (A <= B) {
            System.out.println(-1);
        } else if ((K - A) % (A - B) == 0) {
            System.out.println(((K - A) / (A - B)) * 2 + 1);
        } else {
            System.out.println(((K - A) / (A - B)) * 2 + 3);
        }
    }
}

Measured memory_bytes: 23764
/*
 * Author: Anmol Choudhary
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<"["<<#x<<"="<<x<<"] , ["<<#y<<"="<<y<<"]"<<"\n"
const ll mod = 1000000007;
const ll maxn = 1000005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int an=0;
    rep0(i,n-2){
        string ss=s.substr(i,3);
        if(ss=="ABC") an++;
    }
    pr(an);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
constexpr auto INF = 1000000007;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt = 1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
/*Library End!*/

signed main() {
	int n;
	cin >> n;
	if (n == 3 || n == 5 || n == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
	endre;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int i,a[200005];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int mi=a[0],ans=1;
    for(int i=1;i<n;i++)
    {
        if(a[i]<=mi)
        {
            ans++;
            mi=a[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

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

while True:
    n, y, x = map(int, raw_input().split())
    if n == 0:
        break
    ys = [y]
    for i in range(1, n)[::-1]:
        if y <= 2 ** i:
            y = 2 ** i - y + 1
        else:
            y -= 2 ** i
        ys = [y] + ys
    ans = ""
    y = 1
    for i in range(n):
        sz = 2 ** (n - i)
        c = "R" if (x > sz / 2) ^ (y + 2 ** i == ys[i]) else "L"
        if c == "L" and x <= sz / 2:
            x = sz / 2 - x + 1
        elif c == "L":
            x -= sz / 2
        elif c == "R" and x > sz / 2:
            x = sz - x + 1
        ans += c
        y = ys[i]
    print ans


Measured memory_bytes: 5028
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    string s;
    cin>>s;

    for(auto c:s)
    {
        if(c=='?')
            cout<<'D';
        else
            cout<<c;
    }
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
  int n,h;
  cin >> n >> h;
  int a[n],b[n];
  int amax = 0;
  int ans = 0;
  FOR(i,0,n-1) {
      cin >> a[i] >> b[i];
      chmax(amax,a[i]);
  }

  sort(b,b+n,greater<int>());

  int ref = 0;
  while(b[ref]>amax){
      if(h<=0) break;
      h -= b[ref];
      ++ans;
      ++ref;
      if(ref==n) break;
  }

  if(h>0) ans += (h+(amax-1))/amax;

  cout << ans << endl;



}



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

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

  int n;
  cin >> n;

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end(), greater<int>());

  int alice = 0;
  int bob = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      alice += a.at(i);
    } else {
      bob += a.at(i);
    }
  }

  cout << alice - bob << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;
struct UF
{
  vector<ll> par;
  vector<ll> sz;
  vector<ll> rank;
  UF(ll n):par(n),sz(n),rank(n){
    for(ll i = 0; i < n; i++){
      par[i] = i;sz[i] = 1;rank[i] = 0;
    }
  }
  ll find(ll x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  void merge(ll x, ll y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if(rank[x] < rank[y]){
      par[x] = y;
      sz[y] += sz[x];
    }
    else{
      par[y] = x;
      sz[x] += sz[y];
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(ll x, ll y) { return find(x) == find(y); }
  ll size(ll n){return sz[find(n)];}
};

string m[1111];
ll h,w;
bool check(ll x,ll y){
  return x>=0&&x<h&&y>=0&&y<w;
}
ll vx[4] = {1,0,-1,0};
ll vy[4] = {0,1,0,-1};
vvi E(1111111);
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>h>>w;
  ll sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  sx--;sy--;tx--;ty--;
  UF uni(1111111);
  for(int i=0;i<h;i++){
    cin>>m[i];
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(m[i][j]=='.'){
	for(int k=0;k<4;k++){
	  ll x = i-vx[k],y = j-vy[k];
	  if(check(x,y) && m[x][y] == '.'){
	    uni.merge(i*1000+j,x*1000+y);
	  }
	}
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=i-2;k<=i+2;k++){
	for(int l=j-2;l<=j+2;l++){
	  if(m[i][j] == '.' && check(k,l) && m[k][l] == '.' && !uni.same(i*1000+j,k*1000+l)){
	    
	    E[uni.find(i*1000+j)].pb(uni.find(k*1000+l));
	    E[uni.find(k*1000+l)].pb(uni.find(i*1000+j));
	  }
	}
      }
    }
  }
  ll s = uni.find(sx*1000+sy);
  ll t = uni.find(tx*1000+ty);
  queue<pair<ll,ll>>que;
  vi dist(1111111,llINF);
  dist[s] = 0;
  que.push(mp(s,0));
  while(!que.empty()){
    ll now = que.front().F;
    ll cost = que.front().S;
    que.pop();
    for(auto e:E[now]){
      if(dist[e] > dist[now]+1){
	dist[e] = dist[now]+1;
	que.push(mp(e,cost+1));
      }
    }
  }
  if(dist[t] == llINF)cout<<-1<<endl;
  else
    cout<<dist[t]<<endl;
  return 0;
}


Measured memory_bytes: 107968
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <vector>

using namespace std;
using ll = long long;

const ll e = 1e9 + 7;

int s[10000];

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

  for(int i=2; i<=n; i++){
    int c = i;
    for(int j=2; j<=i; j++){
      while(c%j == 0){
	s[j]++;
	c /= j;
      }
    }
  }

  //for(int i=0; i<n; i++) cout << s[i] << endl;

  ll sum = 1;
  for(int i=2; i<=n; i++) {
    sum = (sum * (s[i] + 1LL)) % e;
  }
  
  cout << sum << endl;
  
  
  return 0;
}



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

int main(){
    int n,m;
    cin>>n>>m;
    map<int,int> e;
    if (m==0) {
        if(n==1) cout<<0<<endl;
        if(n==2) cout<<10<<endl;
        if(n==3) cout<<100<<endl;
        return 0;
    }
    vector<vector<int>> s(m,vector<int>(2));
    for(auto &p:s){
        for(auto &t:p){
            cin>>t;
        }
    }//pもeも1からにする

    for(auto &p:s){
        if(!e.count(p.at(0))){
            e[p.at(0)]=p.at(1);
        }else if(p.at(1)!=e.at(p.at(0))){
            cout<<-1<<endl;
            return 0;
        }
    }
    if(e.count(1)){
        if(e.at(1)==0){
            if(n==1){
             cout<<0;
             return 0;
            }else{
                cout<<-1;
                return 0;
            }
        }
    }
    for(int i=1;i<n+1;i++){
        if(e.count(i)){
            cout<<e.at(i);
        }else if(i==1){
            if(n==1) cout<<0;
            else cout<<1;
        }else cout<<0;
    }
}

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

int main()
{
    ios_base::sync_with_stdio(0);

    ll N;
    cin >> N;

    ll ans = 1e18;
    for (ll i = 1; i <= 1e6; i++)
    {
        if (N % i == 0)
        {
            ans = min (ans, i + N / i);
        }
    }
    cout << ans - 2 << "\n";
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

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

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

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

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

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

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

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


int main()
{
	int n, k;
	cin >> n;
	int ans = 1 << 31 - 1;
	for (size_t i = 1; i < n; i++)
	{
		string a = to_string(i);
		string b = to_string(n - i);
		int suma = 0, sumb = 0;
		REP(j, a.length()) suma += a[j] - '0';
		REP(j, b.length()) sumb += b[j] - '0';

		ans = min(ans, suma + sumb);
	}
	cout << ans << endl;
 	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
int _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }

int rec(int l,int r,vv<int> &dp,v<int> &s){
  if(dp[l][r]!=-1) return dp[l][r];
  if(abs(l-r)<=1) return 0;
  int res=INF;
  for(int mid=l+1;mid<=r-1;mid++){
    chmin(res,rec(l,mid,dp,s)+rec(mid,r,dp,s)+s[r]-s[l]);
  }
  return dp[l][r]=res;
}

int _main(){
  int N; cin >> N;
  v<int> w(N);
  rep(i,0,N) cin >> w[i];

  // 累積和
  vector<int> s(N+1, 0); // s[0] = 0 になる
  for (int i = 0; i < N; ++i) s[i+1] = s[i] + w[i];

  vv<int> dp(410,v<int>(410,-1));
  cout << rec(0,N,dp,s) << endl;
  return 0;
}


Measured memory_bytes: 1664
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let a: i32 = lines.next().unwrap().unwrap().parse().unwrap();

    let mut ans = "No";
    for i in 1..10 {
        for j in 1..10 {
            if i * j == a {
                ans = "Yes";
                break;
            }
        }
    }

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"10", br"Yes
",
        ),
        (
            br"50", br"No
",
        ),
        (
            br"81", br"Yes
",
        ),
    ];

    #[test]
    fn test_b() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


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

public class Program {
    static void Main(string[] args) {
        var arr = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        var xNow = arr[0];
        var yNow = arr[1];

        var routeHistory = new List<int>();
        var subX = arr[2] - arr[0];
        var subY = arr[3] - arr[1];

        var route =
            new string(Enumerable.Repeat('R', subX).ToArray()) +
            new string(Enumerable.Repeat('U', subY).ToArray()) +
            new string(Enumerable.Repeat('L', subX).ToArray()) +
            new string(Enumerable.Repeat('D', subY).ToArray()) +
            "L" +
            new string(Enumerable.Repeat('U', subY + 1).ToArray()) +
            new string(Enumerable.Repeat('R', subX + 1).ToArray()) +
            "D" +
            "R" +
            new string(Enumerable.Repeat('D', subY + 1).ToArray()) +
            new string(Enumerable.Repeat('L', subX + 1).ToArray()) +
            "U";


        Console.WriteLine(route);

    }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  for (int i = k + 1; i <= n; i++) {
    ll a1 = a[i - k - 1];
    ll a2 = a[i - 1];
    if (a2 > a1) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 4856
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;

static class MainClass
{
    public static void Main(string[] args)
    {
        try{
        while (true)
        {
            var str = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (str.Length <= 0)
                return;
            var num = new List<int>();
            foreach (var item in str)
            {
                num.Add(int.Parse(item));
            }

            Console.WriteLine(Gcd(num[0], num[1]));
        }}catch{}
    }


    public static int Gcd(int a, int b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }


}


Measured memory_bytes: 13992
#include<stdio.h>
#include<string.h>
int main(void){
  int ans=0,i,n;
  char a[100];
  scanf("%s",a);
  n=strlen(a);
  for(i=0;i<n/2;i++){
    if(a[i]!=a[n-i-1]) ans++;
  }
   printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize "O3"
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define REP_FROM(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define REP_REV(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define REP_FROMREV(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#ifndef LOCAL
#define cerr if (false) cerr
#endif
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <class T> T sq(T x) { return x * x; }
template <class T> T clamp(T a, T l, T r) { return min(max(a, l), r); } // [l, r]
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int getDigit(int num) {
	int cnt = 0;
	while(num > 0) {
		num /= 10;
		cnt++;
	}
	return cnt;
}

int main(int argc, char *argv[]) {
	// Something to do
	int a, b;

	while(scanf("%d %d", &a, &b) != EOF)
		cout << getDigit(a+b) << endl;

	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
#include <cmath>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
#define UB 1000 * 1000 * 1000
typedef long long int lli;

vector<lli> get_divisors(lli num){
    vector<lli> res;
    for(lli i = 1; i * i <= num; ++i){
        if(i * i == num){
            res.push_back(i);
        }else if(num % i == 0){
            res.push_back(i);
            res.push_back(num / i);
        }
    }

    sort(res.begin(), res.end());
    // for(size_t k = 0; k < res.size(); ++k){
    //     cout << "div[" << k << "] = " << res[k] << endl;
    // }
    return res;
}

int main(){
    lli s;
    cin >> s;
    double root_s = sqrt(s);
    // cout << root_s << endl;
    lli rs = (lli)root_s;
    // cout << setprecision(20) << rs << endl;
    vector<pair<lli, lli>> three_points(1, make_pair(0, 0));

    if(rs * rs == s){
        three_points.emplace_back(make_pair(rs, 0));
        three_points.emplace_back(make_pair(0, rs));
    }else{
        lli px = rs;
        lli qy = rs;
        // cout << "px = " << px << endl;
        // cout << "qy = " << qy << endl;
        while (px * qy < s){
            px++;
            qy++;
            // cout << "px = " << px << endl;
            // cout << "qy = " << qy << endl;
        }
        
        lli area = px * qy;
        // cout << "area = " << area << endl;
        lli sub = area - s;
        // cout << "sub = " << sub << endl;
        vector<lli> sub_divisors = get_divisors(sub);
        lli py = 0, qx = 0;
        for(size_t i = 0; i < sub_divisors.size(); ++i){
            if(sub_divisors[i] <= UB && sub / sub_divisors[i] <= UB){
                py = sub_divisors[i];
                qx = sub / sub_divisors[i];
                break;
            }
        }
        three_points.emplace_back(make_pair(px, py));
        three_points.emplace_back(make_pair(qx, qy));
    }
    
    for(size_t k = 0; k < three_points.size(); ++k){
        char c = (k == three_points.size() - 1)? '\n' : ' ';
        cout << three_points[k].first << " " << three_points[k].second << c;
    }

    // lli actual_area = abs(three_points[1].first * three_points[2].second - three_points[1].second * three_points[2].first);
    // cout << "actual_area = " << actual_area << endl;

    // if(s == actual_area) puts("equal");
    // else puts("NOT EQUAL");
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl

#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define gap cout<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
const int N=1000005;
ll powers[N];
ll primes[N];
const int MOD=1000000007;

ll Power(ll base , ll e)
{
    if(e == 0) return 1;
    ll ans = base; e--;
    while(e)
    {
        if(e & 1) ans = (ans * base) %MOD;
        base = (base * base) %MOD;
        e >>= 1;
    }
    return (ans+MOD)%MOD;
}

void sieve()
{
  
  
  for(ll i=2;i<=N;i++)
  {
    if(primes[i]==-1)
    {
        for(ll j=i;j<=N;j+=i) primes[j]=i;
        
     }
   }

}

int main(){
    ll n;
    cin>>n;
    fo(i,N){
        primes[i]=-1;
        powers[i]=0;
    }
    ll a[10005];
    fo(i,n) cin>>a[i];
    ll tmp=1;
    sieve();
    fo(i,n){
        ll tmp=a[i];
        while(tmp>1){
            ll y=primes[tmp];
            ll count=0;
            while(tmp%y==0){
                tmp=tmp/y;
                count++;
            }
            powers[y]=max(powers[y],count); 
        }
    }
    //dbg("fgrgrgeerssewer");
    ll ans=1;
    FOR(i,2,N){
        if(primes[i]==i){
            ans=(ans%MOD*Power(i,powers[i])%MOD)%MOD;
            ans=(ans+MOD)%MOD;
        }

    }
    ll final=0;
    fo(i,n){
        ll inv=(Power(a[i],MOD-2)+MOD)%MOD;
        final=(final+(inv%MOD*ans%MOD)%MOD+MOD)%MOD;

    }
    final=(final)%MOD;
    //dbg(ans);
    cout<<final<<endl;

}

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

int main()
{	
	int a;
	cin >> a;
	int b = a/3600;
	int c = (a%3600)/60;
	int d = a-3600*b-c*60;
	cout << b << ":" << c << ":" << d << endl; 
	return 0;
}

Measured memory_bytes: 3112
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, m = map(int, input().split())
list_AB = [ list(map(int,input().split(" "))) for i in range(m)]
uf = UnionFind(n)
ans = [cmb(n, 2)]
cnt = cmb(n, 2)
for i in range(m-1, -1, -1):
    a, b = list_AB[i]
    p, q = uf.size(a-1), uf.size(b-1)
    uf.union(a-1, b-1)
    r = uf.size(a-1)
    if p != r:
        if p == 1:
            x = 0
        else:
            x = cmb(p, 2)

        if q == 1:
            y = 0
        else:
            y = cmb(q, 2)

        cnt -= cmb(r, 2) - x - y
    ans.append(cnt)

ans.reverse()
for i in range(1, m+1):
    print(ans[i])




Measured memory_bytes: 35208
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        201005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}  
void solve(){
    int x,n;
    cin >> x >> n;
    vector<int>v(n+5),is(10000);
    FOR(i,1,n+1)cin >> v[i],is[v[i]] = 1;
    int ans = inf,tot = -1;
    FOR(i,0,1000){
        if(abs(i-x) < ans && !is[i]){
            ans = abs(i-x);
            tot = i;
        }
    }
    cout << tot;

}

signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){   
        solve();
        cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...
 

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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1e9 + 7;
const int N = 55;

typedef long long ll;

ll n, s, ans = 1e18, sq;

ll f(ll x, ll a)
{
      ll res = 0;
      while(x)
      {
            res += x % a;
            x /= a;
      }
      return res;
}

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

      sq = sqrt(100000000000);

      for(int i = 2; i <= sq; i ++)
      {
            if(f(n, i) == s)
            {
                  cout << i << endl;
                  return 0;
            }
      }

      if(n < s)
      {
            cout << -1 << endl;
            return 0;
      }

      ll d = n - s;
      sq = sqrt(d);

      for(ll i = sq; i >= 1; i --)
      {
            if(d % i == 0)
            {
                  ll a = d / i, b = i;
                  if(a < b) swap(a, b);
                  if(f(n, a + 1) == s)
                  {
                        cout << a + 1 << endl;
                        return 0;
                  }
            }
      }
      
      if(n == s)
      {
            cout << n + 1 << endl;
      }
      else 
      cout << -1 << endl;
}


Measured memory_bytes: 384
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int n, k; cin >> n >> k;
  string s; cin >> s;
  s[k - 1] = tolower(s[k - 1]);

  print(s);

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 55;
char grid[maxn][maxn];
int M(){
    string s;
    if(!(cin >> s)) return 0;
    if(s.find("AC") != -1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 1;
}
int main(){
    while(M());
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;


int main() {
 int H,W;
 cin>>H>>W;
 char a[110][110];
 for(int i=0;i<H;i++){
     for(int j=0;j<W;j++){
         cin>>a[i][j];
     }
 }
 vector<bool>h(H,false);
 vector<bool>w(W,false);

 for(int i=0;i<H;i++){
     for(int j=0;j<W;j++){
         if(a[i][j]=='#'){h[i]=true;w[j]=true;}
     }
 }
 for(int i=0;i<H;i++){
     for(int j=0;j<W;j++){
         if(h[i]&&w[j]){cout<<a[i][j];}
     }if(h[i])cout<<endl;
 }
 
 return 0;
}

Measured memory_bytes: 256
import numpy

n, l = map(int, input().split())

apps = [(l + i -1) for i in range(1, n + 1)]
# print(apps)
# print(sum(apps))
apps_abs = list(numpy.abs(apps))
# print(apps_abs)
# print(apps_abs.index(min(apps_abs)))
apps.pop(apps_abs.index(min(apps_abs)))
# print(apps)
print(sum(apps))

Measured memory_bytes: 12448
#include <bits/stdc++.h>
using namespace std;
#define NIL -1

// 頂点の個数
int n;
// 隣接リスト
vector<vector<int> > G(100000, vector<int>(0));
// 頂点のグループidを格納する配列
vector<int> color(100000, NIL);

// 深さ優先探索でuを含む連結成分をグループ(id)分け(uはグループ分けされていないと仮定)
void dfs(int u, int id)
{
  stack<int> S;
  S.push(u);
  color.at(u) = id;
  while (!S.empty())
  {
    int v = S.top();
    S.pop();
    for (int i = 0; i < G.at(v).size(); i++)
    {
      if (color.at(G.at(v).at(i)) == NIL)
      {
        // vの隣接頂点で未発見(idがない)のものをスタックに積んでidをつける
        S.push(G.at(v).at(i));
        color.at(G.at(v).at(i)) = id;
      }
    }
  }
}

void assignIds()
{
  int id = 1;
  for (int i = 0; i < n; i++)
  {
    if (color.at(i) == NIL)
    {
      dfs(i, id);
      id++;
    }
  }
}

int main()
{
  int m;
  cin >> n >> m;
  for (int i = 0; i < m; i++)
  {
    int u, v;
    cin >> u >> v;
    G.at(u).push_back(v);
    G.at(v).push_back(u);
  }

  assignIds();

  int q;
  cin >> q;
  vector<bool> ans(q);
  for (int i = 0; i < q; i++)
  {
    int u, v;
    cin >> u >> v;
    ans.at(i) = (color.at(u) == color.at(v));
  }

  for (int i = 0; i < q; i++)
  {
    if (ans.at(i))
    {
      cout << "yes" << endl;
    }
    else
    {
      cout << "no" << endl;
    }
  }
}


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

typedef long long ll;
typedef long long int lli;
const int MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < (n); i++)

using namespace std;

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

	ll L, R; cin >> L >> R;

	if (R - L > 2019) { cout << 0 << endl; }
	else {
		ll res = 2018;
		for (ll x = L; x < R; ++x)
			for (ll y = x + 1; y <= R; ++y) {
				res = min(res, (x * y) % 2019);
			}
		cout << res << endl;
	}
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int A[] = new int[200001];

		for (int i = 0; i < N; i++) {
			A[sc.nextInt()]++;
		}
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i <= 200000; i++) {
			if (A[i] > 0) {
				list.add(A[i]);
			}
		}
		Collections.sort(list);
		int erase = list.size() - K;
		if (erase > 0) {
			System.out.println(list.subList(0, erase).stream().mapToInt(a -> a).sum());
		} else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 89904
N,M=map(int,input().split())
dp=[1]*(N+1)
for _ in range(M):
  i=int(input())
  dp[i]=0
for i in range(2,N+1):
  if dp[i]!=0:
      dp[i]=dp[i-1]+dp[i-2]
  dp[i]%=1000000007
print(dp[N])




Measured memory_bytes: 6900
#!/usr/bin/env python3

def main():
    W, H, N = map(int, input().split())
    xya = [list(map(int, input().split())) for i in range(N)]
    a, b = 0, 0
    for i in range(N):
        if xya[i][2] == 1:
            a = max(a, xya[i][0])
        elif xya[i][2] == 2:
            W = min(W, xya[i][0])
        elif xya[i][2] == 3:
            b = max(b, xya[i][1])
        elif xya[i][2] == 4:
            H = min(H, xya[i][1])
    print(max(0, W - a) * max(0, H - b))


if __name__ == "__main__":
    main()


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

int main(){
    int n;
    cin>>n;
    ll ans=0;
    ll mi=10000000000;
    int cnt=0;
    for(int i=0;i<n;i++){
        ll b;
        cin>>b;
        if(b<0) cnt++;
        ans+=abs(b);
        mi=min(mi,abs(b));
    }
    if(cnt%2==0) cout<<ans<<endl;
    else cout<<ans-2*mi<<endl;
   
}

Measured memory_bytes: 256