akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int N=scan.nextInt();
        int[] a=new int[N];
        int[] judge=new int[N];
        int i;
        int flag=0;
        int count=0;
        for(i=0;i<N;i++){
            a[i]=scan.nextInt();
            judge[i]=0;
            if(a[i]==2){
                flag++;
            }
        }
        if(flag==0){
            System.out.println("-1");
            return;
        }
        else{
            int j=0,light=1;
            while(light!=2){
                judge[j]++;
                if(judge[j]>1){
                    System.out.println("-1");
                    return;
                }
                count++;
                light=a[j];
                j=light-1;
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 64616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s1, s2, s3;
  int S;
  cin >> S;
  s1 = S / 100;
  s2 = (S - s1 * 100) / 10;
  s3 = (S - s1 * 100) - s2 * 10;
  cout << s1 + s2 +s3 << endl;
}

Measured memory_bytes: 256
import sys

DBG_FLAG = 0

def p_dbg(str):
    if(DBG_FLAG == 1):
        sys.stdout.flush()
        print str

# TIME OVER
# def lucas_num(num):
#     if num == 0:
#         luca = 2
#     elif num == 1:
#         luca = 1
#     else:
#         luca = lucas_num(num-1)+lucas_num(num-2)

#     return luca

def lucas_num(num):
    array = []
    array.append(2) # i=0
    array.append(1) # i=1
    p_dbg('array' + str(array))
    count = 2
    while count <= num:
        l1 = array[count -1]
        l2 = array[count -2]
        array.append(l1 + l2)
        count = count + 1

    p_dbg('array' + str(array))
    return array[num]

# get num
num = int(raw_input())
p_dbg('num : ' + str(num))

print lucas_num(num)


Measured memory_bytes: 2568
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let (N,M) = readInts() |> pair
let A=readInts()

let s=A |> Array.sum

A
|> Array.sortDescending
|> Array.take M
|> Array.forall (fun a -> (a*4*M)>=s)
|> function
  | true -> "Yes"
  | false -> "No"
|> printfn "%s"

Measured memory_bytes: 14044
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#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 LLINF = (1LL<<60);
const int INF = (1LL<<30);
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;
  cin >> n;
  VI a(n), b(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];

  set<int> st;
  REP(i, n) st.insert(a[i]);
  REP(i, n) {
    if(st.find(b[i]) != st.end()) {
      st.erase(b[i]);
    }
  }

  if(st.size() == 0) {
    cout << "Yes" << endl;
    return 0;
  }

  // stに残っているところを not equal にする
  VI c(n), d(n);
  REP(i, n) {
    if(st.find(a[i]) == st.end()) {
      c[i] = a[i], d[i] = a[i];
    } else {
      c[i] = a[0], d[i] = a[1];
    }
  }

  cout << "No" << endl;
  REP(i, n) cout << c[i] << (i==n-1?"\n":" ");
  REP(i, n) cout << d[i] << (i==n-1?"\n":" ");

  return 0;
}



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

int main()
{
    int A,B,C,D; cin >> A >> B >> C >>D;
    int n,m;
    if (C%B==0) n=C/B;
    else n=C/B+1;
    if (A%D==0) m=A/D;
    else m=A/D+1;
    if (n<=m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    ll sum = 0;
    int a_p = min(a,k);
    k-=a_p;
    sum+=a_p;
    int b_p = min(b,k);
    k-=b_p;
    int c_p = min(k,c);
    sum-=c_p;

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3636
def main():
    N = int(input())
    dp = [float('inf') for _ in range(N+1)]
    dp[0] = 0
    cand = [1]
    p = 6
    while p <= N:
        cand.append(p)
        p *= 6
    p = 9
    while p <= N:
        cand.append(p)
        p *= 9

    for i in range(1, N+1):
        for j in cand:
            if i-j >= 0:
                dp[i] = min(dp[i], dp[i-j]+1)
    return dp[N]


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 6296
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>

int main(void){
  int n,k,d,at;
  std::vector<int> a;
  std::cin >> n >> k;
  for(int c=0;c<k;c++){
    std::cin >> d;
    for(int i=0;i<d;i++){
      std::cin >> at;
      auto itr = std::find(a.begin(), a.end(), at); 
      if(itr == a.end()){
        a.push_back(at);
      }
    }
  }
  int c=0;
  for(int i=1;i<=n;i++){
    auto itr = std::find(a.begin(), a.end(), i); 
    if(itr == a.end()){
      c++;
    }
  }
  std::cout << c;
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

vector<int> to[2505];
vector<int> rto[2505];
bool reachablefrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachablefrom1[v]) return;
  reachablefrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  string s; cin >> s;
  int prev = (int)(s[0] - 'a');
  //cout << prev << endl;
  int cnt = 0;
  for (int i = 1; i < s.size(); i++) {
    int curr = (int)(s[i] - 'a');
    if (prev == curr) {
      i++;
      cnt++;
      prev = 26;
    } else {
      prev = curr;
    }
  }
  cout << s.size() - cnt << endl;
  return 0;
}


Measured memory_bytes: 768
import itertools

N, X, Y = map(int, input().split())

n_iter = itertools.combinations(list(range(1,N+1)), 2)

count_list = [0]*(N-1)

for i, j in n_iter:
  #1. abs(X - i) + abs(Y - j) + 1
  #2. abs(Y - i) + abs(X - j) + 1
  #3. abs(j - i)
  x = min(
    abs(X - i) + abs(Y - j) + 1,
    abs(Y - i) + abs(X - j) + 1,
    abs(j - i)
  )
  count_list[x-1] += 1

for i in count_list:
  print(i)

Measured memory_bytes: 3572
#include <stdio.h>

int main(void)
{
  int a, b, ans;

  scanf("%d%d",&a,&b);

  if(a>=b){
    ans = a;
    a = a - 1;
  }
  else{
    ans = b;
    b = b - 1;
  }
  if(a>=b){
    ans = ans + a;
  }
  else{
    ans = ans + b;
  }

  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 128
M = 10**9 + 7
N, A, AB, ABC = 1, 0, 0, 0
idx = {'A': 1, 'B': 2, 'C': 3}
for c in input():
    if c == '?':
        N, A, AB, ABC = (N * 3) % M, (A * 3 + N) % M, (AB * 3 + A) % M, (ABC * 3 + AB) % M
    elif c == 'A':
        A += N
    elif c == 'B':
        AB += A
    else:
        ABC += AB
print(ABC % M)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int w, h;
	cin >> w >> h;
	char matrix[w][h];
	int del[w+1];
	int ppp[w+1][h+1], next[w+1][h+1];
	for (int i=0; i <= w; i++){
		for (int j=0; j <= h; j++){
			ppp[i][j] = -1;
			next[i][j] = -1;
		}
	}
    for (int i=0; i < w; i++){
		for (int j=0; j < h; j++){
			cin >> matrix[i][j];
		}
    }
    for (int i=1; i < w; i++){
        for (int j=1; j < h; j++){
			int summ = 0;
			if (matrix[i-1][j-1] == '#') summ++;
			if (matrix[i-1][j] == '#') summ++;
			if (matrix[i][j-1] == '#') summ++;
			if (matrix[i][j] == '#') summ++;
			if (summ % 2 != 0){
                ppp[i][j] = 1;
			}
        }
    }
    int ans = 0;
    for (int i=0; i <= w; i++){
		next[i][h] = -1;
		for (int j=h-1;j >= 0; j--){
			if (ppp[i][j] != -1) next[i][j] = j;
			else next[i][j] = next[i][j+1];
		}
    }
    for (int start = 0; start < h; start++){
		for (int j=0; j <= w; j++){
			del[j] = 0;
		}
        vector<pair<int, int> > np;
        for (int j=0; j <= w; j++){
			if (next[j][start+1] == -1) continue;
			np.push_back(make_pair(next[j][start+1], j));
        }
        sort(np.begin(), np.end());
        set<int> pp;
        pp.insert(0);
        pp.insert(w);
        priority_queue<int> dist;
        dist.push(w);
        int u = 0;
        for (int next=start+1; next <= h; next++){
            while (u < np.size() && np[u].first < next){
                int str = np[u].second;
                u++;
                set<int>::iterator ii = pp.upper_bound(str);
                set<int>::iterator i1 = ii;
                i1--;
                int v1 = *i1;
                int v2 = *ii;
                del[v2-v1]++;
                int n1 = str - v1;
                int n2 = v2 - str;
                dist.push(n1);
                dist.push(n2);
                pp.insert(str);
            }
            int aa;
            while (true){
				int el = dist.top();
				if (del[el] > 0){
					del[el]--;
					dist.pop();
				}
				else{
                    aa = el;
                    break;
				}
            }
            ans = max(ans, aa * (next - start));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35584
package main

import (
	"fmt"
)

func main() {
	var word string
	fmt.Scan(&word)
	palindromeHugger(word)
}

func palindromeHugger(word string) {
	var incidences int
	wordLenght := len(word) - 1

	for i, letter := range word {
		if letter != rune(word[wordLenght-i]) {
			incidences++
		}
	}

	fmt.Println(incidences / 2)
}


Measured memory_bytes: 1776
// Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;

int main()
{
    //freopen("a.txt","r",stdin);
    int n,ar[10001],x=0,i,j,m,sum;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>ar[i];
        x+=ar[i];
    }
    sum=n-x;
    if(sum>=0)cout<<sum<<endl;
    else cout<<"-1\n";

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v[200001];
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
    ll ans=1;
    for(int i=1; i<=n; i++)
        ans*=a;
    return ans;
}

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

    ll n,m,ans=0;
    cin>>n>>m;
    for(int i=0; i<n; i++)
    {
        cin>>A[i];
    }
    for(int i=1; i<=m; i++)
    {
        ll a,b;
        cin>>a>>b;
        if(A[a-1]>A[b-1])
        {
            v[b].push_back(a);
        }
        else if(A[a-1]<A[b-1])
        {
            v[a].push_back(b);
        }
        else
        {
            v[a].push_back(b);
            v[b].push_back(a);
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(v[i].size()==0)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}



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

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W, N;
  cin >> H >> W >> N;
  set<tuple<int, int>> black;
  REP(i, N) {
    int r, c;
    cin >> r >> c;
    black.insert({r, c});
  }
  map<tuple<int, int>, int> gsum;
  for (auto [r, c] : black) {
    for (int i = -2; i <= 0; ++i) {
      for (int j = -2; j <= 0; ++j) {
        int rx = r + i;
        int cx = c + j;
        if (rx <= 0 || rx > H - 2 || cx <= 0 || cx > W - 2) continue;
        // DEBUG(r, c, rx, cx);
        gsum[{rx, cx}]++;
      }
    }
  }
  vector<i64> ans(10);
  u64 total = (u64)(H - 2) * (W - 2);
  for (auto it = gsum.begin(); it != gsum.end(); ++it) {
    DEBUG(get<0>(it->first), get<1>(it->first), it->second);
    assert(it->second <= 9);
    ans[it->second]++;
    --total;
  }
  ans[0] = total;

  REP(i, 10) { cout << ans[i] << '\n'; }
}

Measured memory_bytes: 64516
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
int main() {
  string S, T;
  cin >> S >> T;
  ll ans = 1e8;
  REP(i, S.size() - T.size() + 1) {
    ll tmp = 0;
    char c = S[i];
    REP(j, T.size()) {
      if (S[i + j] != T[j]) tmp++;
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

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

  double sum = 0;
  for (int i = 0; i < N; ++i)
  {
    double x;
    string u;
    cin >> x >> u;

    if (u == "JPY") sum += x;
    else sum += x * 380000;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define INF 1e+9
using namespace std;


int main(){
	int n,m;
	int gaku[20];
	int dp[21][50001];
	cin >> n >> m;
	for(int i = m - 1;i >= 0;i--) cin >> gaku[i];
	for(int i = 0;i <= 50000;i++){
		for(int j = 0;j <= 20;j++) dp[j][i] = INF;
	}
	dp[0][0] = 0;
	for(int i = 1;i <= m;i++){
		for(int j = 0;j <= n;j++){
			if(j - gaku[i - 1] < 0) dp[i][j] = dp[i - 1][j];
			else dp[i][j] = min(dp[i - 1][j],dp[i][j - gaku[i - 1]] + 1);
		}
	}
	cout << dp[m][n] << endl;
	return 0;
}

Measured memory_bytes: 7188
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repc(i, t, n) for(int i = t; i < (n); ++i)
 
using namespace std;
using ll = long long;
 
int main(){
 
	int N; cin >> N;
	
	int first = N, tenth = N, third = N;
 
 
	first /= 1; first %= 10;
	tenth /= 10; tenth %= 10;
	third /= 100; third %= 10;
 
	if(first == 7 || tenth == 7 || third == 7){
		cout << "Yes" << endl;
	} else{
		cout << "No" << endl;
	}
 
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


bool dp[20000];
bool check(vector<int> a, int x) {
  int M = accumulate(ALL(a), 0);
  if (M < abs(x)) return false;
  if ((x+M) % 2 == 1) return false;
  CLR(dp, 0);
  dp[0] = 1;
  for (int ai : a) {
    for (int j = 2*M; j - ai >= 0; j--) {
      if (dp[j-ai]) dp[j] = 1;
    }
  }
  return dp[ (x+M)/2 ];
}


int main2() {
  string s; cin >> s;
  int x, y; cin >> x >> y;

  int i = 0;
  while (i < (int)s.size() && s[i] == 'F') {
    i++;
    x--;
  }

  int dir = 0;
  vector<int> a, b;
  int len = 0;
  for ( ; i < (int)s.size(); i++) {
    if (s[i] == 'T') {
      if (len > 0) { (dir == 0 ? a : b).push_back(len); len = 0; }
      dir = 1 - dir;
    }
    else {
      len++;
    }
  }
  if (len > 0) { (dir == 0 ? a : b).push_back(len); len = 0; }
  
  // cout << s << endl;
  // cout << "a:"; pv(ALL(a));
  // cout << "b:"; pv(ALL(b));

  cout << (check(a, x) && check(b, y) ? "Yes":"No")  << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()){
			char[] line = stdIn.nextLine().toCharArray();
			int joi = 0, ioi = 0;
			for(int i=2;i<line.length;i++){
				if(line[i]=='I'&&line[i-1]=='O'){
					if(line[i-2]=='J'){
						joi++;
					}
					else if(line[i-2]=='I'){
						ioi++;
					}
				}
			}
			System.out.println(joi);
			System.out.println(ioi);
		}
	}
}

Measured memory_bytes: 12000
// https://atcoder.jp/contests/abc107/tasks/arc101_a

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
    int n, k;
    vector<int> x, y;
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;
    x.resize(n);

    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    sort(ALL(x));

    // k本のロウソクに火をつける時間を計算
    for (int i = 0; i <= n - k; i++) {
        // 比較対象の符号が逆の場合
        int a = x[i], b = x[i + k - 1];
        if (signbit(a) != 0 && signbit(b) == 0 ||
            signbit(a) == 0 && signbit(b) != 0) {
            if (abs(x[i]) < abs(x[i + k - 1])) {
                y.push_back(2 * abs(x[i]) + abs(x[i + k - 1]));
            } else {
                y.push_back(abs(x[i]) + 2 * abs(x[i + k - 1]));
            }
        } else {
            y.push_back(max(abs(x[i]), abs(x[i + k - 1])));
        }
    }
    sort(ALL(y));
    cout << y[0] << endl;

    return 0;
}


Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc096/tasks/abc096_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int a, b, r;

  cin >> a >> b;

  r = a <= b ? a : a - 1;

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int count =0;
    if (K % 2 ==0) {
      System.out.print((long)Math.pow((N / (K/2) - N/K),3) + (long)Math.pow(N / K,3));
      } else {
      System.out.print((long)Math.pow(N / K ,3));
    }
  }
}

Measured memory_bytes: 35652
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main()
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll q = x/d;

    if(k>q){
        k=k-q;
        x = x-(q*d);
        ll x1 = abs(x-d);
        // cout<<x<<" "<<x1<<": "<<k<<endl;
        if(k%2==0){
            cout<<x;
        }
        else{
            cout<<x1;
        }
    }
    else{
        x = x-(k*d);
        k=0;
        cout<<x;     
    }

    return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,m; cin>>n>>m;
  if(n==m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
def d_even_relation_bfs(N, Nodes):  # BFSによる
    from collections import deque
    graph = [[] for _ in range(N)]
    for u, v, w in Nodes:  # 0-basedとする
        graph[u - 1].append((v - 1, w))
        graph[v - 1].append((u - 1, w))
    distance_from_root = [0] * N  # 根(頂点0)から各頂点への距離

    queue = deque([(-1, 0, 0)])  # 親と現在の頂点番号、根から親までの距離
    while queue:
        parent, current, distance = queue.pop()
        distance_from_root[current] = distance
        for next_edge, dist in graph[current]:
            if parent != next_edge:  # 木を「逆戻り」しない頂点だけ調べる
                queue.appendleft((current, next_edge, distance + dist))
    ans = (1 if d % 2 == 0 else 0 for d in distance_from_root)
    return ' '.join(map(str, ans))

N = int(input())
Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]
print(d_even_relation_bfs(N, Nodes))

Measured memory_bytes: 67072
import math

def isPrime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    else:
        return True

def solve():
    X = int(input())
    while 1:
        if isPrime(X):
            return X
        X += 1

print(solve())

Measured memory_bytes: 3060
n=int(input())
z=0
N=[0]*10000
ans=0
ko=0
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ko=x**2+y**2+z**2+x*y+y*z+z*x
            if ko<=n:
                N[ko-1]+=1
            else:
                break
for i in range(n):
    print(N[i])

Measured memory_bytes: 9192
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define sz(x) ((long long)x.size())
#define all(x) (x).begin(), (x).end()
#define popcount(x) __builtin_popcountll(x)
const int MOD =1e9+7;

mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> istream& operator >> (istream &in,vector<T> &A){ for(auto &x:A) in>>x; return in; };
template<typename T> ostream& operator << (ostream &out,vector<T> &A){ for(auto &x:A) out<<x<<" "; return out; };
template<typename T,typename W> istream& operator >> (istream &in,pair<T,W> &A){ in>>A.fi>>A.se; return in; };
const int N = 2*1e5+3;

void solve()
{
	int k;
	cin>>k;
	if(k%2==0)
	{
		cout<<"-1";
		return;
	}
	int ans= 0;
	int  p =1;
	for(int i=1;i<=1e8;i++)
	{
		ans=7*(p)+ans;
		ans%=k;
		if(ans==0)
		{
			cout<<i;
			return;
		}
		p*=10;
		p%=k;
	}
	cout<<"-1\n";
}
// 7, 7*11, 7*3*37 , 7*11*101,
int32_t main(){
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	#endif

	int t=1;
	// cin>>t;
	for(int _t=1;_t<=t;_t++){
		// cout<<"Case #"<<_t<<": ";
		solve();
	}
} 


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

using P = pair<string, string>;

int n;
string s;
ll ans;
map<P, int> mp;

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

   rep (mask, (1<<n)) {
      string a, b;
      rep (i, n) {
         if (mask & (1<<i)) {
            a.push_back(s[i]);
         } else {
            b.push_back(s[i]);
         }
      }
      mp[{a, b}]++;
   }

   string t = s;
   reverse(all(t));
   rep (mask, (1<<n)) {
      string a, b;
      rep (i, n) {
         if (mask & (1<<i)) {
            a.push_back(t[i]);
         } else {
            b.push_back(t[i]);
         }
      }
      ans += mp[{a, b}];
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 91904
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin>>n;
#define in2(n, k) cin>>n>>k;
#define in3(n, k, s) cin>>n>>k>>s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)\
        cin>>a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    int n, k;
    in2(n,k)
    int ar[n] = {0};
    while(k--)
    {
        int d;
        cin>>d;
        while(d--)
        {
            int i;
            cin>>i;
            ar[i-1] = ar[i-1]+1;
        }
    }
    int ans = 0;
    rep(i, n)
        if(ar[i] == 0)
            ans++;
    cout<<ans;
    return 0;
}

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

n, x = map(int, input().split())
children = list(map(int, input().split()))

children.sort()

count = 0
index = 0

for c in children:
    # print("{}, {}".format(x, c))
    is_last_child = index + 1 == len(children)
    if is_last_child:
        if x == c:
            x -= c
            count += 1
    elif x >= c:
        x -= c
        count += 1
    index += 1

print(count)

Measured memory_bytes: 3060
import bisect
from operator import itemgetter

d, g = map(int, input().split())
g //= 100
problem_quantities = []
complete_scores = []
for i in range(1, d + 1):
    p, c = map(int, input().split())
    c //= 100
    problem_quantities.append(p)
    complete_scores.append(i * p + c)

curr_idx = d
curr_bit = 0
curr_cmp, curr_qtt = 0, 0
complete_combinations = [None] * (1 << d)
complete_combinations[0] = (0, 0, 0)
for use in range(1, 1 << d):
    if use & curr_bit == 0:
        curr_idx -= 1
        curr_bit = use
        curr_cmp = complete_scores[curr_idx]
        curr_qtt = problem_quantities[curr_idx]
    ps, pq, _ = complete_combinations[use ^ curr_bit]
    complete_combinations[use] = (ps + curr_cmp, pq + curr_qtt, use)

complete_combinations.sort()

bi = bisect.bisect(complete_combinations, (g,))

ans = float('inf')
for s, p, use in complete_combinations[:bi]:
    i = d
    while use & 1:
        i -= 1
        use >>= 1
    cmp = complete_scores[i - 1]
    remain = g - s
    if remain >= cmp:
        continue
    q = min(problem_quantities[i - 1], (remain - 1) // i + 1)
    ans = min(ans, p + q)

ans = min(ans, min(map(itemgetter(1), complete_combinations[bi:])))
print(ans)


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

typedef long long ll;
typedef long double ld;

typedef pair<int, int> p;

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

    int x;
    cin >> x;

    if(x < 1200) {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

int F(int x) {
  if (x == 1) return 300000;
  if (x == 2) return 200000;
  if (x == 3) return 100000;
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  int ans = F(x) + F(y);
  if (x == 1 && y ==1) ans += 400000;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
//#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pai acos(-1)
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x,s) for(i=x;i>=s;i--)
#define fit(itr,s) for(itr=s.begin();itr!=s.end();itr++)
#define W while
#define pp pair<ll,ll>
#define ppi pair<int,int>
#define vl vector<ll>
#define vll vector<pp >
#define vi vector<int>
#define vii vector<ppi>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define debug(x) cerr<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define boost  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const ll MAX=1e7;
const ll MM=2e6;
const ll mod=998244353;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

ll expo(ll x,ll n,ll M=mod)
{
    ll ans=1;
    while(n>0)
    {
        if(n&1){ans=(ans*x)%M;}
                x=(x*x)%M;
                n>>=1;
    }
    return ans;
}
bool pri[MAX];
void sieve()
{
    ll i,j;
    fn(i,MAX)pri[i]=1;
    pri[1]=0;
    for(i=2;i*i<MAX;i++)
    {
        if(pri[i])
        {
            for(j=i*i;j<MAX;j+=i)
            {
                pri[j]=0;
            }
        }
    }
}
ll dp[4001][4001];
void solve()
{
  ll n,s,i,j;
  cin>>n>>s;
  vl a(n);
  fn(i,n)cin>>a[i];
  sort(all(a));
  dp[0][0]=1;
  fn(i,n)
  {
      fn(j,s+1)
      {
          dp[i+1][j]+=2*dp[i][j];
          dp[i+1][j]%=mod;
          if((j+a[i])<=s)
            {dp[i+1][j+a[i]]+=dp[i][j];
            dp[i+1][j+a[i]]%=mod;}
      }
  }
  cout<<dp[n][s]<<endl;

}


int main()
{
  boost;
  ll t=1;
  //cin>>t;
  sieve();
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 95720
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007

    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}

   
     int solve()
     {
        int n;
        cin>>n;
        mii m;
        rep0(n){
            int a,b;
            cin>>a>>b;
            if(b<a) return cout<<"No",0;
            m[b]+=a;
        }
        int cur=0;
        FORE(it,m){
            int deadline=it->ff;
            int totaltime=it->ss;
            if(deadline-cur<totaltime) return cout<<"No",0;
            cur+=totaltime;
        }

        cout<<"Yes";
     }
    signed main()
    {   
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

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



Measured memory_bytes: 2044
#include <cstdio>
#include <vector>
using namespace std;

typedef vector<vector<int> > vvint;

void mul(vvint &x, const vvint &y, int m){
	int n = x.size();
	vvint z(n, vector<int>(n));
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < n; ++j)
			for(int k = 0; k < n; ++k)
				z[i][j] = (z[i][j] + x[i][k] * y[k][j]) % m;
	x.swap(z);
}

int main(){
	int n, m, a, b, c, t;
	while(scanf("%d%d%d%d%d%d", &n, &m, &a, &b, &c, &t), n){
		vvint x(n, vector<int>(n)), y = x;
		for(int i = 0; i < n; ++i){
			if(i != 0) x[i][i-1] = a;
			x[i][i] = b;
			if(i != n - 1) x[i][i+1] = c;

			y[i][i] = 1;
		}

		while(t){
			if(t & 1) mul(y, x, m);
			mul(x, x, m);
			t >>= 1;
		}

		vector<int> s(n);
		for(int i = 0; i < n; ++i){
			scanf("%d", &s[i]);
		}

		for(int i = 0; i < n; ++i){
			int p = 0;
			for(int j = 0; j < n; ++j){
				p = (p + y[i][j] * s[j]) % m;
			}
			printf("%d%c", p, i == n - 1 ? '\n' : ' ');
		}
	}
}

Measured memory_bytes: 1100
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
const int  M = 201;
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    string s;
    int n;
    cin >> n >> s;
    int ans = 0;
    stack<char> st;
    fore(i, 0, n){
        if(s[i] == '('){
            st.push(')');
            continue;
        }
        if(!st.empty()){
            if(s[i] == st.top())
                st.pop();
            else
                ans++;
        }else
            ans++;
    }
    fore(i, 0, ans)
        cout << '(';
    cout << s;
    fore(i, 0, sz(st))
        cout << ')';
    return 0;
}   

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> pii;

int main() {
	int c[5];
	char k;
	while(cin >> c[0] >> k >> c[1] >> k >> c[2] >> k >> c[3] >> k >> c[4]) {
		int cnt[13] = {};
		int twoes = 0;
		rep(i,5) {
			cnt[c[i]-1]++;
		}
		rep(i,13) {
			if(cnt[i] == 4) {
				cout << "four card" << endl;
				goto END;
			}
		}
		rep(i,13) {
			rep(j,13) {
				if(cnt[i]==3 && cnt[j]==2) {
					cout << "full house" << endl;
					goto END;
				}
			}
		}
		rep(i,10) {
			bool ok = true;
			rep(j,5) {
				int n = (i+j)%13;
				if(cnt[n] != 1) {
					ok = false;
					break;
				}
			}
			if(ok) {
				cout << "straight" << endl;
				goto END;
			}
		}
		rep(i,13) {
			if(cnt[i] == 3) {
				cout << "three card" << endl;
				goto END;
			}
		}
		rep(i,13) {
			if(cnt[i] == 2) twoes++;
		}
		if(twoes==2) {
			cout << "two pair" << endl;
		} else if(twoes==1) {
			cout << "one pair" << endl;
		}else {
			cout << "null" << endl;
		}
END:;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3588