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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

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

  int n, d;
  cin >> n >> d;
  V<int> x(n), y(n);
  REP(i, n) cin >> x[i] >> y[i];

  V<PII> v1;
  int n2 = n/2;
  int m = pow(3, n2);
  REP(i, m) {
    int a = 0, b = 0;
    int bit = i;
    REP(j, n2) {
      if(bit%3==0) a += x[j], b += y[j];
      else if(bit%3==1) a -= x[j], b -= y[j];
      bit /= 3;
    }
    v1.PB({a, b});
  }

  // cout << "a" << endl;

  V<PII> v2;
  m = pow(3, n-n2);
  REP(i, m) {
    int a = 0, b = 0;
    int bit = i;
    REP(j, n-n2) {
      if(bit%3==0) a += x[n2+j], b += y[n2+j];
      else if(bit%3==1) a -= x[n2+j], b -= y[n2+j];
      bit /= 3;
    }
    v2.PB({a, b});
  }

  sort(ALL(v1));
  reverse(ALL(v1));
  sort(ALL(v2));

  // cout << v1 << endl << v2 << endl;

  // cout << "b" << endl;

  // [itr1, itr2) になるように　
  int itr1 = 0, itr2 = 0;
  deque<int> deq;
  int ret = -INF;
  for(auto i: v1) {
    // cout << i << " " << itr1 << " " << itr2 << endl;
    // [-i.first-d, -i.first+d] の区間
    while(itr2 < v2.size() && v2[itr2].first <= -i.first+d) {
      // cout << "itr2=" << itr2 << " " << v2[itr2].first << " " << -i.first+d << endl;
      // dequeにitr2を追加
      while(deq.size() && v2[deq.back()].second <= v2[itr2].second) deq.pop_back();
      deq.push_back(itr2);
      itr2++;
    }
    while(itr1 < v2.size() && v2[itr1].first < -i.first-d) {
      // dequeからitr1を削除
      if(deq.size() && deq.front()==itr1) {
        deq.pop_front();
      }
      itr1++;
    }

    if(deq.size()) chmax(ret, i.second + v2[deq.front()].second);
  }
  cout << ret << endl;

  return 0;
}



Measured memory_bytes: 489440
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        for (int i = 1; i <= 100; i++) {
            if (a * i % b == c) {
                System.out.println("YES");
                System.exit(0);
            }
        }
        System.out.println("NO");
    }
}


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

int main() {
  int N,M,check = 0;
  cin >> N >> M;
  vector<vector<int>> V(M,vector<int>(2,0));
  for (int i = 0; i < M; i++) 
    cin >> V.at(i).at(0) >> V.at(i).at(1);
  
  for (int j = 0; j < 1000; j++) {
    int count = 0;
    int flag = 0;
    if ((j/100 > 0 && N == 3) || (j/100 == 0 && j/10 > 0 && N == 2) || (j/10 == 0 && N == 1)) {
      for (int k = 0; k < M; k++) {
        if (V.at(k).at(0) == N) {
          if (j%10 != V.at(k).at(1))
            count++;
        }
        if (V.at(k).at(0) == N - 1) {
          if (j%100/10 != V.at(k).at(1))
            count++;
        }
        if (V.at(k).at(0) == N - 2) {
          if (j/100 != V.at(k).at(1))
            count++;
        }
      }
      if (count == 0) {
        cout << j << endl;
        flag++;
        check++;
      }
    }
    if (flag == 1) 
      break;
  }
  if (check == 0)
    cout << -1 << endl;
  
}


Measured memory_bytes: 256
Option Strict On

Module Module1

    Function ChrToStr(ByVal c As Char) As String
        Return c & ""
    End Function

    Sub Main()
        'var'
        Dim S() As Char = Console.ReadLine().ToCharArray()
        Dim ans As String = "No"

        Array.Sort(S)
        If Join(Array.ConvertAll(Of Char, String)(S, AddressOf ChrToStr), "") = "abc" Then
            ans = "Yes"
        End If

        Console.WriteLine(ans)

    End Sub

End Module

Measured memory_bytes: 19920
ab = gets.chomp
rainCnt = 0
rainmax = 0
if ab[0] == "R" then
  rainCnt += 1
end
 
  rainmax = rainCnt
if ab[1] == "R" then

  rainCnt += 1
  rainmax = rainCnt
else
  rainCnt = 0
end
if ab[2] == "R" then

  rainCnt += 1
    rainmax = rainCnt
else
  rainCnt = 0
end
puts rainmax


Measured memory_bytes: 14368
#include <stdio.h>
#include <cassert>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
#include <iomanip>
 
#ifdef LOCAL_CODE
	#define DEBUG(x) cerr << "[" << #x << '=' << x << "]" << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int i = (N)-1; i >= 0; i--)
#define REP(i, N) for(int i = 0; i < (int)(N); i++)
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.first >> p.second; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.first << ' ' << p.second; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

unsigned long long n,m,k;//A,B,C,D;
void solve(istream& cin, ostream& cout) {
	int a,b;
	scanf("%llu %d.%d", &n, &a,&b);
	ll C = a*100+b;
	ll res = (n*C)/100;
	cout <<res<<endl;
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007
 
const int mxN = 1e5 + 1;
ll a[mxN];
ll w[mxN];
vt<ll> dp(mxN, 0);
ll n, W;
 
 
int main()
{
FIO
 
    cin >> n >> W;
    FOR(n) cin >> w[i] >> a[i];
    FOR(n)
    {
        for(int j = W; j >= 1; j--)
        {
            if(w[i] <= j)
            {
                dp[j] = max(dp[j], dp[j-w[i]] + a[i]);
            }
        }
    }
    cout << dp[W] << endl;
}


Measured memory_bytes: 3824
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	vll cnt(1000000,0) ;
	ll n ; cin >> n ;
//	cout << n << endl ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		cnt.at(a)++ ;
		if(a!=0) cnt.at(a-1)++ ;
		cnt.at(a+1)++ ;
	}
	ll ans = 0 ;
	for(int i=0;i<cnt.size();i++){
		if(cnt.at(i)>ans) ans = cnt.at(i) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 8064
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

class UnionFind
{
public:
    vector<int> p;

    UnionFind() {}
    UnionFind(int size)
    : p(vector<int>(size, -1))
    {}

    void clear()
    {
        rep (i, p.size())
        {
            p[i] = -1;
        }
    }

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

    void unite(int x, int y)
    {
        x = findSet(x); y = findSet(y);
        if (x == y) return;

        if (p[x] > p[y]) swap(x, y);
        p[x] += p[y];
        p[y] = x;
    }

    int findSet(int x)
    {
        if (p[x] < 0) return x;
        else p[x] = findSet(p[x]);
        return p[x];
    }
};

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

    int N, M;
    cin >> N >> M;
    vector< pair<int, int> > e(M);
    int u, v;
    rep (i, M)
    {
        cin >> u >> v;
        --u; --v;
        e[i] = make_pair(u, v);
    }

    UnionFind uf(N);
    int ans = 0;
    rep (i, M)
    {
        uf.clear();
        bool flag = true;
        rep (j, M)
        {
            if (i == j) continue;
            uf.unite(e[j].first, e[j].second);
        }

        rep (j, N)
        {
            if (uf.findSet(0) != uf.findSet(j))
            {
                flag = false;
            }
        }
        if (!flag) ++ans;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
   ll n;
   cin >> n;
   map <ll,ll> mapp;
   ll ans = 0;
   for (int z=0;z<n;z++){
      ll temp;
      cin >> temp;
      ans += temp;
      mapp[temp]++;
   }
   ll q;
   cin >> q;
   for (int z=0;z<q;z++){
      ll b,c;
      cin >> b >> c;
      ans += c*mapp[b];
      ans -= b*mapp[b];
      mapp[c] += mapp[b];
      mapp.erase(b);
      cout << ans << endl;
   }
} 

Measured memory_bytes: 7568
N=int(input())
H=list(map(int,input().split()))
dplist=[0 for i in range(N)]
dplist[0]=0
dplist[1]=abs(H[1]-H[0])
for i in range(2,N):
  dplist[i]=min(dplist[i-1]+abs(H[i]-H[i-1]),dplist[i-2]+abs(H[i-2]-H[i]))
print(dplist[N-1])

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> jobs(m);
  rep(i,n){
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    jobs[m-a].push_back(b);
  }
  priority_queue<int> q;
  ll ans =0;
  for(int i = m-1;i >=0; i--) {
    for(auto k : jobs[i]){
      q.push(k);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5504
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int N,C[4]={0};
	cin >> N;
	for(int i=0;i<N;i++){
		string s;
		cin >> s;
		if(s=="AC")
			C[0]++;
		else if(s=="WA")
			C[1]++;
		else if(s=="TLE")
			C[2]++;
		else if(s=="RE")
			C[3]++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",C[0],C[1],C[2],C[3]);
}

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

using namespace std;

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG(x) cout << "> " << #x << ": " << x << endl;

typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
const int inf = 1e9+7;
const ll longinf = 1LL<<60;

// Start Coding...

void solve() {
    int N;
    string S;
    cin >> N >> S;
    if (N == 0 || N == 26) cout << S << endl;
    else {
        for (int i = 0; i < S.size(); i++) {
            S[i] = (S[i] - 'A' + N) >= 26 ? S[i] + N - 26 : S[i] + N;
        }
        cout << S << endl;
    }
    return;
}

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

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

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

        String S = sc.next();
        sc.close();

        int N = S.length();
        char[] s = new char[N];
        s = S.toCharArray();
        long[] num = new long[N];
        for (int i = 0; i < N; i++) {
            num[i] = 1;
        }

        long[] list = new long[N];
        long[] sum = new long[2];
        int rStart = 0;
        int rEnd = 0;
        int lStart = 0;
        for (int i = 0; i < N; i++) {
            sum[(i - rStart) % 2] += num[i];
            if (s[i] == 'L') {
                if (i > 0 && s[i-1] == 'R') {
                    rEnd = i - 1;
                    lStart = i;
                }
                if (i + 1 == N || s[i+1] == 'R') {
                    if ((rEnd - rStart) % 2 == 0) {
                        list[rEnd] = sum[0];
                        list[lStart] = sum[1];
                    } else {
                        list[rEnd] = sum[1];
                        list[lStart] = sum[0];
                    }
                    sum[0] = 0;
                    sum[1] = 0;
                    rStart = i + 1;
                }
            }
        }

        for (int i = 0; i < N; i++) {
            if (i != 0) {
                out.printf(" ");
            }
            out.printf("%d", list[i]);
        }
        out.printf("\n");
        out.flush();
    }
}


Measured memory_bytes: 78720
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    if (a >= 13) {
      System.out.println(b + "\n");
    } else if (a < 13 && a >= 6) {
      System.out.println((b / 2) + "\n");
    } else {
      System.out.println("0\n");
    }
  }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

bool kai(string s) {
	rep(i, s.size()) {
		if(s[i] != s[s.size() - 1 - i]) return 0;
	}
	return 1;
}

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

	string s;
	cin >> s;
	int n = s.size();
	if(kai(s) && kai(s.substr(0, n / 2)) && kai(s.substr(n / 2 + 1, n / 2))) {
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

#define forw(i, a, b) for (int i = a; i <= b; ++i)
#define iter(i, n) forw(i, 1, n)

#define NR 2010

const int mod = 1e9 + 7;

int n, m, f[2 * NR][NR], fac[NR * NR], inv[NR * NR];

int pr(int a, int z) {
	int s = 1;
	while (z > 0) {
		if (z % 2 == 1) s = 1ll * s * a % mod;
		a = 1ll * a * a % mod;
		z /= 2;
	}
	return s;
}

int binom(int n, int k) { return 1ll * fac[n] * inv[k] % mod * inv[n - k] % mod; }

int main() {
	scanf("%d%d", &n, &m);
	if (m == 1) {
		puts("1");
		return 0;
	}

	fac[0] = inv[0] = 1;
	iter(i, n * m) {
		fac[i] = 1ll * fac[i - 1] * i % mod;
		inv[i] = pr(fac[i], mod - 2);
	}

	f[0][0] = 1;
	iter(i, 2 * n) {
		forw(j, 0, n) if (j <= i - j && i - j <= n) {
			f[i][j] = i != 2 * n ? f[i - 1][j] : 0;
			if (2 * j <= i && j) f[i][j] = (f[i][j] + 1ll * f[i - 1][j - 1] * binom((n - j + 1) * (m - 1) + n - (i - j) - 1, m - 2)) % mod;
			//printf("f[%d][%d]=%d\n", i, j, f[i][j]);
		}
	}
	printf("%d\n", 1ll * f[2 * n][n] * fac[n] % mod);
	return 0;
}


Measured memory_bytes: 62464
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int s;
int dp[700][2005];

int solve(int pos, int sum)
{
    if(sum == s)
        return 1;

    if(dp[pos][sum] != -1)
        return dp[pos][sum];

    int ret = 0;
    for(int i = 3; i <= s; i++) {
        if(sum + i <= s) {
            ret += solve(pos + 1, sum + i) % MOD;
            ret %= MOD;
        }
    }

    return dp[pos][sum] = ret;
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin>>s;

    mem(dp, -1);
    int res = solve(0, 0);

    cout<<res<<endl;

    return 0;
}



Measured memory_bytes: 9148
n, m = gets.chomp.split.map(&:to_i)
dir = Array.new(n) { [] }
prev = Array.new(n, -1)
visited = Array.new(n, false)
m.times do |_|
  a, b = gets.chomp.split.map(&:to_i)
  dir[a - 1] << b - 1
  dir[b - 1] << a - 1
end

q = [0]
while !q.empty?
  cur = q.shift
  next if visited[cur]

  visited[cur] = true
  dir[cur].each do |v|
    if v != 0 && prev[v] == -1
      prev[v] = cur
      q << v
    end
  end
end

if prev[1...n].count(-1) <= 1
  puts "Yes"
  puts prev[1...n].map {|i| i + 1 }
else
  puts "No"
end

Measured memory_bytes: 34572
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n<10){
    cout << n << endl;
  }
  else if(n<100){
    cout << 9 << endl;
  }
  else if(n<1000){
    cout << 9+n-99 << endl;
  }
  else if(n<10000){
    cout << 909 << endl;
  }
  else if(n==100000){
    cout << 90909 << endl;
  }
  else{
    cout << n-9090 << endl;
  }
}

Measured memory_bytes: 256
import sys
import math
a,b,h,m = map(int, sys.stdin.readline().rstrip("\n").split())
l_d = 6*m
s_d = 30*h + 0.5*m
d = abs(l_d-s_d)
cosC = round(math.cos(math.radians(d)), 13)
c_2 = a**2 + b**2 -2*a*b*cosC
c = round(c_2**0.5, 13)
print(c)

Measured memory_bytes: 9508
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main (void){
    int N,x,i,temp,a[100],count=0;

    scanf("%d %d",&N,&x);
    
    for(i=0; i<N; i++){
          scanf("%d", &a[i]);
    }
    for(i=0; i<N; i++){
        for(int s =N-1; s>i; --s){
           if(a[s] < a[s-1]){
               temp =a[s-1];
               a[s-1] = a[s];
               a[s] = temp;
           } 
        }        
    }
    for(i=0; i<N; i++){
        x = x -a[i];
        if(x <0){
            break;
        }
        count++;
    }
   if (x >=0){
       if( x != 0){
           count--;
       }
   }
    

    
    
    printf("%d",count);
    
    
    
        return 0;
}
 //chcp 65001 cd contest

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

int main(){
  int S, s1, s2, s3;
  int count = 0;
  cin >> S;
  s1 = S / 100;
  s2 = (S - s1 * 100) / 10;
  s3 = S % 10;
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 3668
n=input()
r=input()
r=r.split(" ")
r=sorted(r)
a=list(map(int,r))

d=dict()

ans=0
count=0

from collections import defaultdict
d = defaultdict(lambda: 0, d)

for i in a:
    d[i]=d.get(i,0)+1

p=0
while(p<100010):
    count=d[p-1]+d[p]+d[p+1]
    p=p+1
    if(count>ans):
        ans=count
print(ans)

Measured memory_bytes: 31708
k, n = map(int,input().split())
A = list(map(int, input().split()))

ans = float("inf")
for i in range(1, n):
    ans = min(ans, A[i-1]+k-A[i])
ans = min(ans, A[n-1])
for i in range(n-1):
    ans = min(ans, A[i]+k-A[i+1])
ans = min(ans, A[n-1]-A[0])
print(ans)

Measured memory_bytes: 26444
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
////////////////////////////////

int const N = 141;

int mini[27], cur[27];
int n;
void solve(){
	vector<string> vs;
	cin >> n;
	fi(0, 27) mini[i] = N;
	fi(0, n){
		string s;
		cin >> s;
		fj(0, 27) cur[j] = 0;
		fj(0, sz(s)) ++cur[s[j]-'a'];
		fj(0, 27) mini[j] = min(mini[j], cur[j]);
	}
	string ret = "";
	fi(0, 27){
		if(mini[i] == N) continue;
		fj(0, mini[i]){
			ret += (char)(i + 'a');
		}
	}
	cout << ret << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();



	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

import sys
input = sys.stdin.readline

# N = int(input())
# L = [int(x) for x in input().split()]
A, B = map(int, input().split())
# S = input()

if A >= 13:
    print(B)
elif 6 <= A and A <= 12:
    print(B // 2)
else:
    print(0)


Measured memory_bytes: 2940
/*
I_Love_Trueno 
Author- darklight13
Smoke_Weed_Everyday
*/
#define _CRT_SECURE_NO_DEPRECATE
#define V__0_0__V
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double   ld;
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define view(x)     cout << (#x) << " is " << (x) << endl
#define view2(x,y)     cout << (#x) <<" "<<(#y)<< " are " << (x) <<" "<<(y)<< endl
#define  pb push_back
#define  F  first
#define  S  second
#define  mp make_pair
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
#define all(v) (v).begin(),(v).end()
#define sz(a) (ll)((a).size())
#define sq(x) ((x)*(x))
#define pii pair<ll,ll>
#define endl '\n'
#define pow (ll)pow
ll Max_val(ll a[],ll b[],ll n,ll cnt,ll w,ll curr)
{
    if(curr>=n||cnt>=w)
        return 0;
    else
    {
        if(cnt+a[curr]<=w)
        {
            return max(Max_val(a,b,n,cnt+a[curr],w,curr+1)+b[curr],Max_val(a,b,n,cnt,w,curr+1));
        }else
        {
            return Max_val(a,b,n,cnt,w,curr+1);
        }
    }
}
int32_t main()
{
  // FRE
    SYNC
    ll n,w;cin>>n>>w;
    ll a[n+1],b[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
    }
    ll dp[n+1][w+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
            dp[i][j]=0;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(j-a[i]>=0)
            {
                dp[i][j]= max(dp[i-1][j-a[i]]+b[i],dp[i-1][j]);
            }else
            {
                dp[i][j]=dp[i-1][j];
            }
           // cout<<dp[i][j]<<" ";
        }
    }    
    cout<<dp[n][w];
    return 0;
}

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

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

  vector<tuple<string, int, int>> tuple(N);
  for (int i = 0; i < N; i++) {
    string S;
    int P;
    cin >> S >> P;
    tuple.at(i) = make_tuple(S, 100 - P, i + 1);
  }
  
  sort(tuple.begin(), tuple.end());
  
  for (int i = 0; i < N; i++) {
    cout << get<2>(tuple.at(i)) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


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

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

int n,t[60];string s[60];
signed main(){
  cin>>n;
  rep(i,n)cin>>s[i]>>t[i];
  string ss;cin>>ss;
  int ans = 0;bool b = false;
  rep(i,n){
    if(b)ans += t[i];
    if(s[i] == ss)b = true;
  }
  cout << ans << endl;
}



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

int getGroup(int x) {
	int a[] = {1, 3, 5, 7, 8, 10, 12};
	int b[] = {4, 6, 9, 11};
	
	if (x == 2) return 2;
	for (int i = 0; i < 4; i++) if (x == b[i]) return 1;
	
	return 0;
}

int main() {
	
	int x, y;
	scanf("%d %d", &x, &y);
	
	printf("%s", getGroup(x) == getGroup(y) ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 256
import numpy as np
n,MOD=map(int,input().split())
n3=n*3+1
dp=np.zeros((n3,n*5),np.int64)
dp[0][0]=dp[1][1]=dp[2][2]=dp[2][-1]=1
for i in range(3,n3):
  dp[i]=(dp[i-3]*(i-2)*(i-1)+np.roll(dp[i-2],-1)*(i-1)+np.roll(dp[i-1],1))%MOD
print(dp[-1][:n3].sum()%MOD)


Measured memory_bytes: 481484
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int a[5010],b[5010];

signed main(){
	int n,m;
	cin>>n>>m;
	rep(i,0,n){
		cin>>a[i];
	}
	rep(i,0,m){
		cin>>b[i];
	}
	int MAX=0,ind;
	rep(i,0,m){
		ind=i;
		rep(j,0,n){
			if(a[j]==b[ind]){
				ind++;
			}
		}
		MAX=max(MAX,ind-i);
	}
	cout<<MAX<<endl;
}

Measured memory_bytes: 1236
#![allow(unused)]

#[allow(unused_imports)]
use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::*;
use collections::{HashMap, HashSet};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($arg: tt)*) => { eprintln!($fmt, $($arg)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($arg: tt)*) => {};
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let n = parse_line::<usize>();
    let spot_pos = {
        let mut v = Vec::with_capacity(n + 2);
        v.push(0);
        v.append(&mut parse_vec::<i32>());
        v.push(0);
        v
    };

    let sum = spot_pos
        .windows(2)
        .map(|path| (path[0] - path[1]).abs())
        .sum::<i32>();

    for path in spot_pos.windows(3) {
        if range_contains(path[0], path[2], path[1]) {
            println!("{}", sum);
        } else {
            let new_sum = sum - 2 * cmp::min((path[0] - path[1]).abs(), (path[1] - path[2]).abs());
            println!("{}", new_sum);
        }
    }
}

fn range_contains(from: i32, to: i32, target: i32) -> bool {
    (from <= target && target <= to) || (to <= target && target <= from)
}

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

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 7292
#include<bits/stdc++.h>
#define fo(i, n) for(int i = 1; i <= (n); i ++)
#define out(x) cerr << #x << " = " << x << "\n"
using namespace std;
//by piano
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
const int N = 233;
char str[N];
int n, ans = 1e9, vis[N];
main(void) {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  for(int i = 1; i <= n; i ++)
    vis[str[i]] = 1; 
  for(int re = 'a'; re <= 'z'; re ++) if(vis[re]) {
    int res = 0;
    for(int i = 1; i <= n; i ++) {
      int ok = 0;
      for(int k = i; k <= n; k ++) {
        if(str[k] == re) {
          res = max(res, k - i);
          ok = i;
          break;
        }
      }
      if(!ok) {
        for(int k = i; k >= 1; k --)
          if(str[k] == re) {
            res = max(res, n - k);
            break;
          }
      }
    }
    ans = min(ans, res);
  }
  cout << ans << "\n";
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n,ans=0;
    cin>>n;
    Vi a(3*n);
    REP(i,0,3*n) cin>>a[i];
    
    SORTG(a);
    REP(i,0,n){
        ans += a[2*i+1];
    }
    cout<<ans<<endl;
    return 0;
}


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

#define MOD 1000000007

// 素因数分解
map<long long, int> prime_factor(long long n) {
  map<long long, int> ret;
  for(long long i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

// 二項係数
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int n, m;
int main(void) {
	cin >> n >> m;
  COMinit();
  map<long long, int> factors = prime_factor(m);
  long long result = 1;
  for (auto it = factors.begin(); it != factors.end(); it++) {
    long long r = it->second;
    result = (result * COM(r + n - 1, r)) % MOD;
  }
  cout << result << endl;
}


Measured memory_bytes: 12160
# C - H and V
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    H, W, K = map(int, readline().split())
    C = [line.decode() for line in read().split()]
    res = 0
    for bit_row in range(1 << H):
        for bit_col in range(1 << W):
            cnt_black = 0
            for i in range(H):
                for j in range(W):
                    if (
                        not ((bit_row >> i) & 1)
                        and not ((bit_col >> j) & 1)
                        and C[i][j] == "#"
                    ):
                        cnt_black += 1
            if cnt_black == K:
                res += 1
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9264
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>
#include<stdio.h>

using namespace std;

using ll = long long;

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

const ll INF = 1LL << 60;

typedef pair<ll, double> P;

bool pairCompare(const P& firstElof, const P& secondElof)
{
	return firstElof.second < secondElof.second;
}

bool IsPrime(ll num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

signed main() {
	ll ans = 0;

	ll n, r;

	cin >> n >> r;

	if (n < 10) {
		ans = r + (100 * (10 - n));
	}
	else {
		ans = r;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
#define N 2000
int n, z, w;
int a[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> z >> w;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if(n == 1) {
        cout << abs(a[n-1] - w) << endl;
    } else {
        cout << max(abs(a[n-1] - w), abs(a[n-2] - a[n-1])) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;


public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        char[] s = sc.next().toCharArray();
        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < s.length; i++) {
            if (s[i] != 'B') {
                stack.push(s[i]);
            } else {
                if (stack.size() > 0) {
                    stack.pop();
                }
            }
        }
        String ans = "";
        for (int i = 0; i < stack.size(); i++) {
            ans += stack.get(i);
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 23124
def getval():
    n,m = map(int,input().split())
    g = [[] for i in range(n)]
    for i in range(m):
        x,y = map(int,input().split())
        g[x-1].append(y-1)
    return n,m,g

def main(n,m,g):
    d = [-1 for i in range(n)]
    visited = [False for i in range(n)]
    temp = [[] for i in range(n)]
    ans = 0
    #print(g)
    #print(visited)
    for i in range(n):
        if d[i] != -1:
            continue
        q = [[i,-1]]
        prev = [-1]
        while q:
            idx = q.pop(-1)
            #print(i,idx,q,d)
            if not visited[idx[0]]:
                visited[idx[0]] = True
                if g[idx[0]]:
                    prev.append(idx[0])
                    for j in g[idx[0]]:
                        q.append([j,idx[0]])
                else:
                    d[idx[0]] = 0
                    temp[idx[1]].append(0)
                    if idx[1]==-1:
                        break
                    if prev[-1]!=-1 and q:
                        #print(q)
                        if q[-1][1]==idx[1]:
                            continue
                    bef = prev.pop(-1)
                    q.append([bef,prev[-1]])
            else:
                if d[idx[0]] == -1:
                    d[idx[0]] = 1 + max(temp[idx[0]])
                    if idx[1]!=-1:
                        temp[idx[1]].append(d[idx[0]])
                else:
                    if idx[1]!=-1:
                        temp[idx[1]].append(d[idx[0]])
                if prev[-1]!=-1 and q:
                    #print(q)
                    if q[-1][1]==idx[1]:
                        continue
                if idx[1]==-1:
                    break
                bef = prev.pop(-1)
                q.append([bef,prev[-1]])   
    print(max(max(d),0))
    #print(d)
                

if __name__=="__main__":
    n,m,g = getval()
    main(n,m,g)

Measured memory_bytes: 107636
#include<bits/stdc++.h>
using namespace std;
int main () {
  vector<bool>sosu(100003, true);
  sosu[0] = sosu[1] = false;
  for (int i = 0; i <= 100000; i ++) {
    if (sosu[i]) {
      for (int j = 2; j <= 100000 / i; j ++) {
        sosu[i * j] = false;
      }
    }
  }
  vector<int>ans(100003);
  ans[0] = ans[1] = ans[2] = 0;
  for (int i = 2; i <= 100000; i ++) {
    ans[i] = ans[i - 1];
    if (sosu[i] && sosu[(i + 1) / 2]) {
      ans[i] ++;
    }
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i ++) {
    int l, r;
    cin >> l >> r;
    cout << ans[r] - ans[l - 1] << endl;
  }
}

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

int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++) cin>>A[i];
  int B[N];
  for(int i=0;i<N;i++) B[i]=A[i];
  sort(A.begin(),A.end());
  int ans=A[N-1];
  int sub=A[N-2];
  for(int i=0;i<N;i++){
    if(B[i]==ans) cout<<sub<<endl;
    else cout<<ans<<endl;
  }
}

Measured memory_bytes: 3200
s,l,o,t=4.times.map{gets.to_i};c=->n,r,y{r.map{|r|(0..(n<r/y ?n:r/y)).map{|i|r-y*i}}.flatten}
p c[l,c[s,[t],500],100].select{|x|x<=50*o}.size


Measured memory_bytes: 1788
N,W = map(int, input().split())
w,v = [0]*N, [0]*N
for i in range(N):
    w[i],v[i] = map(int, input().split())
MAX_NV = 100*1000 # N*v
inf = float('inf')
# dp tabel -> dp list
dp = [inf]*(MAX_NV+1) 
dp[0]  = 0
for i in range(N):
    for j in reversed(range(MAX_NV+1)):
        if j-v[i]<0:
            dp[j] = dp[j]
        else:
            dp[j] = min(dp[j],
                        dp[j-v[i]] + w[i])
    # print(dp[:100])

ans = 0
for value,dpi in enumerate(dp):
    if dpi<=W:
        ans = max(ans, value)
print(ans)

Measured memory_bytes: 117836
from collections import Counter
s = input()
n = len(s)
# 累積和の準備
sum_list = [0]*(n+1)  # s[0]は０であってほしいから配列数ひとつおおい
_10 = 1
for i in range(1, n + 1):
    sum_list[i] += (sum_list[i-1] + int(s[n-i])*_10 % 2019) % 2019  # ここでmodしておく
    _10 = _10*10 %2019
"""
(s[j]-s[i]/10**i)が区間の整数
区間の整数が2019で割り切れればよい
つまり、(s[j]-s[i]/10**i)≡0 (mod=2019)
ここで10**iと2019(素数)は互いに素なので、
10**iをかけて上の式はs[j]-s[i]≡0 (mod=2019)と同値
s[j]≡s[i] (mod=2019)となる。
"""
c = Counter(sum_list)
ans = 0

for key in c.keys():
    ans += c[key]*(c[key]-1)//2
print(ans)


Measured memory_bytes: 70840
#include<stdio.h>
int main(void){
	
	int N,X,m[100];
	scanf("%d%d",&N,&X);
	
	int i;
	for(i=0;i<N;i++){
		scanf("%d",&m[i]);
	}
	
	int min = m[0],least = 0;;
	for(i = 0;i < N;i ++){
		
		if(m[i] <= min){
			min = m[i];
		}
		least = least + m[i];
		
	}
	
	printf("%d",N + (X - least)/min);

}
	

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

def main():
    a = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
    s = input().strip()
    for i, t in enumerate(a):
        if s == t:
            print(7-i)
            return

if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include <stdio.h>

int min(int a, int b, int c)
{
  int min=a;
  if(min>b) min=b;
  if(min>c) min=c;
  return min;
}

int main(void)
{
  char masu[1000][1000];
  int space[1000][1000];
  int n;
  int max;
  int i, j;

  while(1){
    scanf("%d", &n);
    if(n==0) break;
    for(i=0; i<n; i++) scanf("%s", masu[i]);

    for(i=0; i<n; i++){
      if(masu[i][0]=='*') space[i][0]=0;
      else space[i][0]=1;
      if(masu[0][i]=='*') space[0][i]=0;
      else space[0][i]=1;
    }

    max=0;
    for(i=1; i<n; i++){
      for(j=1; j<n; j++){
	if(masu[i][j]=='*') space[i][j]=0;
	else space[i][j]=min(space[i-1][j-1], space[i-1][j], space[i][j-1])+1;
	if(max<space[i][j]) max=space[i][j];
      }
    }
    printf("%d\n", max);
  }
  return 0;
}

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

int main()
{
	int sai[3],		/*[0]¨ã [1]¨èO(South) [2]¨E¤(East)*/
	/*âµÄàââ±µ¢ÌÅ3ÂB©¦È¢ÊÍ7©çø¢ÄßéÆ·éB*/
		i,
		n = 0,		/*w¦ñ*/
		count;
	char muki[6];
	
	while(scanf("%d",&n),n != 0){
		count = 1;
		for(i=0; i<3; i++) sai[i] = i+1;
		for(i=0; i<n; i++){
			scanf("%s",muki);
		
			if( !strcmp(muki,"North") ){			/*E¤¶¤ÍÏíç¸*/
				int buf = sai[0];
				sai[0] = sai[1];
				sai[1] = 7 - buf;
			}else if( !strcmp(muki,"South") ){
				int buf = sai[1];
				sai[1] = sai[0];
				sai[0] = 7 - buf;
			}else if( !strcmp(muki,"East") ){		/*èOÆ¤ÍÏíç¸*/
				int buf = sai[2];
				sai[2] = sai[0];
				sai[0] = 7 - buf;
			}else if( !strcmp(muki,"West") ){
				int buf = sai[0];
				sai[0] = sai[2];
				sai[2] = 7 - buf;
			}else if( !strcmp(muki,"Right") ){		/*ãÆºÍÏíç¸*/
				int buf = sai[1];
				sai[1] = sai[2];
				sai[2] = 7 - buf;
			}else if( !strcmp(muki,"Left") ){
				int buf = sai[2];
				sai[2] = sai[1];
				sai[1] = 7 - buf;
			}
		
			count += sai[0];
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

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

dp = None

def main():
    a, b = [int(_) for _ in input().split()]
    print(max(a+b, a-b, a*b))

main()


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

int main(){
  int N, K;
  cin>>N>>K;
  vector<bool> have(N, false);

  for(int i=0;i<K;i++){
    int su=0;
    cin>>su;
    for(int s=0;s<su;s++){
      int tmp;
      cin>>tmp;
      have.at(tmp-1)=true;
    }
  }
  cout<<count(have.begin(), have.end(), false)<<endl;
}

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

using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  
  int c = 0;
  for (int i = a; i <= b; ++i) {
    string s = to_string(i);
    if(s[0] == s[4] && s[1] == s[3]) {
      ++c;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N=1e5+10;
char s[N];
int main()
{
    scanf("%s",s);
    int len=strlen(s);
    string tmp;
    int flag=0;
    for(int i=0;i<len;i++)
    {
        tmp="";
        for(int j=i;j<=i+4;j++)
        {
            tmp+=s[j];
        }
 //       cout<<tmp<<endl;
        if(tmp=="erase")
        {
            i+=4;
            if(s[i+1]=='r') i+=1;
        }
        else if(tmp=="dream")
        {
            i+=4;
            if(s[i+1]=='e'&&s[i+2]=='r'&&s[i+3]!='a') i+=2;
        }
        else flag=1;
    }
    if(flag) puts("NO");
    else puts("YES");
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
	int n;
	double av=0;
	cin >> n;
	for(int i=0; i<n; i++){
		int m;
		cin >> m;
		av += (double)m/n;
	}
	cout << (int)av << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vint c(n-1), s(n-1), f(n-1);
    rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
    rep(i,n) {
        int t = 0;
        for (int j = i; j < n-1; j++) {
            t = max(t,s[j]);
            if ((t-s[j])%f[j] != 0) {
                t += f[j]-(t-s[j])%f[j];
            }
            t += c[j];
        }
        cout << t << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
int a, b, w;
while(scanf("%d",&a), scanf("%d",&b), a != 0 || b != 0 ) {
if( a > b ){
printf( "%d %d\n", b, a );
}else {
printf( "%d %d\n", a, b );
}

}

return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<S.size();++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
inline int read()
{
	char c=getchar(); int ret=0;
	while(c<48||c>57)c=getchar();
	while(c>=48&&c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}

#define N 130022
#define MO 1000000007
char s[N],p[N];
int f[N][18],n;

int main()
{
	scanf("%s",p+1);
	n=strlen(p+1);
	for(int i=1;i<=n;++i)s[i]=p[n-i+1];
	f[n+1][0]=1;
	for(int i=n;i;--i){
		if(s[i]!='?'){
			for(int j=0;j<13;++j)f[i][(j*10+s[i]-48)%13]+=f[i+1][j],f[i][(j*10+s[i]-48)%13]%=MO;
			continue;  //// +=  =
		}
		for(int k=0;k<=9;++k){
			for(int j=0;j<13;++j)f[i][(j*10+k)%13]+=f[i+1][j],f[i][(j*10+k)%13]%=MO;
		}
	}
	cout<<f[1][5];
}

Measured memory_bytes: 8576