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

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

  template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >> n){
    if(n == 0) break;
    vector<int> a(n+1,0),b(n+1,0);
    int ans =-inf,sum=0;
    rep(i,n){
      cin >> a[i];
      sum += a[i];
      b[i+1] = sum;
    }
    rep(i,n+1){
      REP(j,i+1,n+1){
        ans = max(ans,b[j] - b[i]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3112
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N =  1e5;
const int M = 18;
int sparse[M + 2][N + 5];
int arr[N + 5];

void hora(int tc) {
	int n, l;
	cin>>n;
	for(int i = 1;i <= n;i++) cin>>arr[i];
	cin>>l;
	arr[n + 1] = 1e9;
	int j = 1;
	for(int i = 1;i <= n;i++) {
		while(j != n + 1 && arr[j] - arr[i] <= l) j++;
		j--;
		sparse[0][i] = j;
	}
	for(int i = 1;i <= M;i++) for(int j = 1;j <= n;j++) sparse[i][j] = sparse[i-1][sparse[i-1][j]];
	int q;
	cin>>q;
	while(q--) {
		int l,r;
		cin>>l>>r;
		if(l > r) swap(l,r);
		int tot = 0;
		for(int i = M;i >= 0;i--) {
			if(sparse[i][l] < r) {
				l = sparse[i][l];
				tot += (1<<i);
			}
		}
		tot++;
		cout<<tot<<endl;
	}
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
#include <set>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.length(); i++){
		if (s[i] != t[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin>>n>>k;
  vector<ll>h(n+1,0);
  rep(i,n)cin>>h[i+1];
  vector<vector<ll>>dp(k+1,vector<ll>(n+1,1e18));
  dp[0][0]=0;
  repi(i,1,n+1){
    vector<vector<ll>>tdp(k+1,vector<ll>(n+1,1e18));

    //除く時
    rep(j,k){
      rep(l,n+1){
        tdp[j+1][l]=dp[j][l];
        //cout<<j<<" "<<l<<" "<<tdp[j+1][l]<<endl;
      }
    }
    //
    rep(j,k+1){
      rep(l,n+1){
        chmin(tdp[j][i],min((ll)1e18,dp[j][l]+max(0LL,h[i]-h[l])));
      }
    }
    swap(dp,tdp);

  }
  ll res=1e18;
  rep(i,k+1)rep(j,n+1){
    chmin(res,dp[i][j]);
    //cout<<dp[i][j]<<endl;
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 1760
import java.util.*;

class Question {
	int num;
	//AC=0,WA=1
	ArrayList<Integer> ansstack = new ArrayList<Integer>();
	public Question(int n) {
		num=n;
	}
	
	public void addAC() {
		ansstack.add(0);
	}
	
	public void addWA() {
		ansstack.add(1);
	}
	
	public void printStack() {
		for(int i=0;i<ansstack.size();i++) {
			System.out.print(ansstack.get(i));
		}
		System.out.println();
	}
	
	public int checkWA() {
		int tmp=0;
		for(int i=0;i<ansstack.size();i++) {
			if(ansstack.get(i)==1) tmp+=1;
			else if(ansstack.get(i)==0) return tmp;
		}
		return 0;
	}
	public int checkAC() {
		int tmp=0;
		for(int i=0;i<ansstack.size();i++) {
			if(ansstack.get(i)==0) return 1;
		}
		return 0;
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] p=new int[m];
		String[] s=new String[m];
		
		long ans_num=0;
		long pena_num=0;
		
		Question[] toi=new Question[n];
		
		for(int i=0;i<n;i++) {
			toi[i]=new Question(i);
		}
		
		for(int i=0;i<m;i++) {
			p[i] = sc.nextInt();
			s[i] = sc.next();
		}	
		
		for(int i=0;i<m;i++) {
			if(s[i].equals("AC")) {
				toi[p[i]-1].addAC();
			}
			else if(s[i].equals("WA")) {
				toi[p[i]-1].addWA();
			}
		}
		
		for(int i=0;i<n;i++) {
			ans_num+=toi[i].checkAC();
			pena_num+=toi[i].checkWA();
		}
		
		System.out.println(ans_num+" "+pena_num);
	}
}

Measured memory_bytes: 73756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,k,n) for(ll i=k;i<n;i++)
#define all(x) x.begin(),x.end()
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define xx first
#define yy second
#define MOD 1000000007
#define pb push_back
typedef long long ll;
template <typename T>
void dbg(T t){cerr<<t<<endl ;}
template<typename T, typename... Args>
void dbg(T t, Args... args) {cerr << t <<" ";dbg(args...) ;}


string t[1000];
int w,h;
int dp[1000][1000];
int X[]={0,1,1,-1};
int Y[]={1,0,-1,0};
int calc(int i,int j){
	if(min(i,j) < 0 || i >= h || j >= w || t[i][j] == '#') return 0;
	if(i == h - 1 && j == w - 1) return 1;
	int & ret = dp[i][j];
	if(ret != -1) return ret;
	ret = 0;
	rep(k,2){
		ret = (ret + calc(i+X[k],j+Y[k])) % MOD;
	}
	return ret;
}

int main(){
	FAST
	int n,m,a,b;
	cin >> h >> w;
	rep(i,h){
		cin >> t[i];
	}
	memset(dp,-1,sizeof(dp));
	cout << calc(0,0) << endl;
	return 0;
}


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

public class Main {
	public static void main(String[] args) {
		int N = 3;
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		for(int i=0;i<N;i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);
		if((list.get(0) == 5)&&(list.get(1) == 5)&&(list.get(2) == 7)) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 35692
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  string s = to_string(n);
  ll x = 0;
  rep(i, s.size()) x += (s[i] - '0');
  if (n % x == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>
ll m;
ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y%2) res=(x*res);
    x=(x*x);
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

bool issafe(int x,int y,int n,int m){
  return (x>=0 && y>=0 && x<n && y<m);
}
int ans;



void solve(){
  int test;
  //cin>>test;
  test=1;
  
  while(test--){
       int n,m;
       cin>>n>>m;
       
       if(n==m)
       cout<<"Yes";
       else
       cout<<"No";
  }    
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}


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

using namespace std;

int main(){
    int L, R, d;
    cin >> L >> R >> d;
    int count = 0;
    for (int i = L; i <= R; i++)
    {
        if(i%d==0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3620
// https://atcoder.jp/contests/agc005/tasks/agc005_a
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    string X;
    cin >> X;
    int N = X.size();

    stack<char> st;
    for (int i = 0; i < N; ++i)
    {
        // 見ている文字とスタックの先頭に着目する
        if ('S' == X[i])
        {
            st.push('S');
        }
        else // 'T' == X[i]
        {
            if (st.empty())
            {
                st.push('T');
                continue;
            }
            
            char c = st.top();
            if (c == 'T')
            {
                st.push('T');
            }
            else // c == 'S'
            {
                st.pop();
            }
        }
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 3780
n,k=map(int,input().split())
ar=list(map(int,input().split()))
def cnt(x):
	s=0
	for i in ar:
		if i>x:
			s+=(i-1)//x
	return s
l=0
r=10**9
while l<r-1:
	m=(l+r)//2
	c=cnt(m)
	if c>k:
		l=m
	else:
		r=m
print(r)

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

#define ll long long

int main() {
  int N;
  cin >> N;
  
  vector<pair<ll, ll>> work;
  for (int i = 0; i < N; i++) {
    ll A, B;
    cin >> A >> B;
    work.push_back({B,A});
  }
  
  sort(work.begin(), work.end());
  
  bool cond = true;
  
  ll time = 0;
  for (int i = 0; i < N; i++) {
    time += work[i].second;
    
    if (time > work[i].first) {
      cond = false;
      break;
    }
  }
  
  
  if (cond) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 7396
W,H = map(int, input().split())
P = [0] * W
Q = [0] * H
for i in range(W):
  P[i] = int(input())
for i in range(H):
  Q[i] = int(input())
  
P.sort()
Q.sort()
cumP = [0] * (W+1)
cumQ = [0] * (H+1)
for i in range(W):
  cumP[i+1] = cumP[i] + P[i]
for i in range(H):
  cumQ[i+1] = cumQ[i] + Q[i]
  
#print(cumP)
#print(cumQ)
y,x = 0,0
cost = 0
while y <= H and x <= W:
  #print(x,y)
  # 右か下にコストが安いほうにいけばよい。イコールなら任意でよい。
  if x == W and y == H:
    break
  elif x == W:
    cost += Q[y]
    y += 1
    cost += cumP[x]    
  elif y == H:
    cost += P[x]
    x += 1
    cost += cumQ[y]
  elif P[x] <= Q[y]:
    cost += P[x]
    x += 1
    cost += cumQ[y]
  else:
    cost += Q[y]
    y += 1
    cost += cumP[x]
    
print(cost)

Measured memory_bytes: 80684
package main

import (
	"fmt"
	"strings"
)

func main() {
	var wk string
	fmt.Scan(&wk)
	var res = abc049c(wk)
	fmt.Println(res)

}

func abc049c(wk string) string {
	var res = ""

	wk = Reverse(wk)
	wk = strings.Replace(wk, "resare", "", -1)
	wk = strings.Replace(wk, "esare", "", -1)
	wk = strings.Replace(wk, "remaerd", "", -1)
	wk = strings.Replace(wk, "maerd", "", -1)

	if len(wk) == 0 {
		res = "YES"
	} else {
		res = "NO"
	}
	return res
}

//Reverse stringreverse
func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)

}


Measured memory_bytes: 2176
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(d => if (d.size == 1) '0' + d else d)).toSeq
    println(in.flatMap(_.tail.grouped(2).map(_.mkString(":"))).sorted.distinct.map(s =>
        if (s(0) == '0' && s(2) == ':') s.tail else s
    ).mkString(" "))
}

Measured memory_bytes: 44812
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    ab = LIR(n)
    d = defaultdict(int)
    d2 = defaultdict(int)
    d3 = defaultdict(int)
    aa = 0
    for a, b in ab:
        if a == b == 0:
            aa += 1
            continue
        if a == 0:
            d[0] += 1
            d3[0] = 1
        elif b == 0:
            d2[0] += 1
            d3[0] = 1
        else:
            if a * b > 0:
                x = math.gcd(a, b)
                a //= x
                b //= x
                d[(abs(a) , abs(b))] += 1
                d3[(abs(a) , abs(b))] = 1
            else:
                x = math.gcd(a, b)
                a //= x
                b //= x
                d2[(abs(b), abs(a))] += 1
                d3[(abs(b), abs(a))] = 1
    ans = 1
    for k in d3.keys():
        ans *= (2 ** d[k] + 2 ** d2[k] - 1)
        ans %= mod
    ans -= 1
    ans += aa
    print(ans % mod)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 202648
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;

    class Program
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            var a = System.Console.ReadLine().Split(' ').Select((x) => long.Parse(x)).ToArray();
            var hyoutenList = new long[n];

            for (int i = k; i < n; i++)
            {
                //long hyouten = 1;
                //for (int j = i; j < i + k; j++)
                //{
                //    hyouten = hyouten + a[j];
                //}
                //hyoutenList[i] = hyouten;

                //if (i + 1 == n) return;

                var ans = "No";
                if (a[i - k] < a[i])
                {
                    ans = "Yes";
                }
                Output(ans.ToString());
            }
        }
        private static void Output(string str)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            Console.WriteLine(str);

            Console.Out.Flush();
        }

    }


Measured memory_bytes: 64100
//      https://youtu.be/X_hMZYDMps4

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;    // 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nl                  "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define pf                  push_front
#define all(x)              x.begin(),x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"

int main()
{
    fast;
    ll t,i,j,k,l,m,n,o,p,q,temp,ans=0,flag=0,mod=1000000007,odd=0,even=0,a,b;
    cin>>n>>a>>b;
    if(n==2) cout<<"Borys";
    else if(abs(a-b)%2) cout<<"Borys";
    else cout<<"Alice";
}


Measured memory_bytes: 3652
n,m,c = map(int, input().split())
b = list(map(int, input().split()))
cnt = 0
for _ in range(n):
  a = list(map(int, input().split()))
  s = c
  for i in range(m):
    s += a[i]*b[i]
  if s > 0:
    cnt += 1
print(cnt)

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

const int MAX=10;
int N;
vector<int> S[MAX],state(MAX,0),point(MAX,0);
stack<int> T;

void DFS(){
    int cnt=0,c=9;
    T.push(0);
    state[0]=1;
    while(T.size()){
        int a=T.top();
        bool check=true;
        for(int i=point[a];i<S[a].size();i++){
            int b=S[a][i];
            if(state[b]==0){
                T.push(b);
                state[b]=1;
                point[a]=i+1;
                check=false;
                break;
            }
        }
        if(T.size()==N&&!check){
            cnt++;
        }
        point[c]=0;
        c=9;
        if(check){
            state[a]=0;
            c=a;
            T.pop();
        }
    }
    cout<<cnt<<endl;
}

int main(){
    
    int M;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        S[a].push_back(b);
        S[b].push_back(a);
    }
    for(int i=0;i<N;i++){
        sort(S[i].begin(),S[i].end());
    }
    DFS();
}


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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n,m;
    cin >> n >> m;

    vector<int> city(n+1);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;

        city[a]++;
        city[b]++;
    }

    for(int i=1;i<n+1;i++){
        cout << city[i] << endl;
    }

    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll w,a,b;
  cin >> w >> a >> b;
  if(abs(a-b) <= w) cout << 0 << endl;
  else
    cout << min(abs(b-a-w),abs(a-b-w)) << endl;
  return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  cout << (((!(a-b) && !(b-c)) || ((a != b) && (b != c) && (c != a))) ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    long A,B;
    string op;
    cin>>A>>op>>B;
    if(op=="+"){
        cout << A+B <<endl;
        return 0;
    }else{
        cout << A-B<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c \""
"s,t=[0]*26,[0]*26\n"
"for a,b in zip(input(),input()):\n"
"  s[ord(a)-ord('a')]+=1\n"
"  t[ord(b)-ord('a')]+=1\n"
"u,v=[],[]\n"
"for a,b in zip(s,t):\n"
"  if a!=b:\n"
"    u.append(a)\n"
"    v.append(b)\n"
"print('YNeos'[sorted(u)!=sorted(v)::2])\n"
"\"";
  system(s);
  return 0;
}

Measured memory_bytes: 8260
// author-Shivam gupta

#include <bits/stdc++.h>


using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))

#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 FOR(i,a) for(int i=0;i<a;i++)

#define FOR1(i,j,a) for(int i=j;i<a;i++)

#define EB emplace_back

#define INF (int)1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define read(type) readInt<type>()
#define max1 100001
#define out(x) cout<<x<<'\n'
#define out1(x) cout<<x<<" "
#define END cout<<'\n'
#define int long long
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}


signed main(){

int n;
cin>>n;
if(n%2==0){out(-1);return 0;}
int x=0;
int p=n;
int cnt=0;
while(p>0){
    x*=10;
    x+=7;
    p=p/10;
    cnt++;
}
if(x<n){
    x*=10;
    x+=7;
    cnt++;
}
int a=x%n;
if(a==0){out(cnt);return 0;}
p=a;
while(p<n){
    p*=10;
    p+=7;
    cnt++;
}
int w=1000000;
while(w--){
    a=p%n;
    if(a==0){out(cnt);return 0;}

p=a;
while(p<n){
    p*=10;
    p+=7;
    cnt++;
}
}
 out(-1);

}


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

int main() {
    string S;
    cin >> S; //S is a string of length 6 consisting of lowercase English letters
    if (S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
    else cout << "No"<< endl;
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<iomanip>
using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point{
	public:
		double x, y;

		Point(double x = 0, double y = 0): x(x), y(y) {}

		Point operator + (Point p){ return Point(x + p.x, y + p.y);}
		Point operator - (Point p){ return Point(x - p.x, y - p.y);}
		Point operator * (double a){ return Point(a * x, a * y);}
		Point operator / (double a){ return Point(x / a, y / a);}

		double abs(){ return sqrt(norm());}
		double norm(){ return x * x + y * y;}

		bool operator < (const Point &p) const{
			return x != p.x ? x < p.x : y < p.y;
		}

		bool operator == (const Point &p) const{
			return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
		}
};

class Circle{
	public:
		Point c;
		double r;
		Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

double getDistance(Point a, Point b){
	return (a - b).abs();
}

int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		Circle a, b;
		cin >> a.c.x >> a.c.y >> a.r >> b.c.x >> b.c.y >> b.r;
		if(a.r > (b.r + getDistance(a.c, b.c))) cout << 2 << endl;
		else if(b.r > (a.r + getDistance(a.c, b.c))) cout << -2 << endl;
		else if(a.r + b.r < getDistance(a.c, b.c)) cout << 0 << endl;
		else cout << 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <set>
#define MAXN 300000
int n, m, k, x[MAXN], id[MAXN], ans[MAXN], sum[MAXN];
int main() {
	scanf("%d", &n);
	m = n * n;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &x[i]);
		id[i] = ans[x[i]] = i;
	}
	std::sort(id + 1, id + n + 1, [](int a, int b) { return x[a] < x[b]; });
	for (int i = 1, cur = 1; i <= n; i++) {
		for (int j = 1; j < id[i]; j++) {
			while (ans[cur]) cur++;
			ans[cur] = id[i];
		}
		if (cur > x[id[i]]) return puts("No"), 0;
	}
	for (int i = n, cur = m; i >= 1; i--) {
		for (int j = id[i] + 1; j <= n; j++) {
			while (ans[cur]) cur--;
			ans[cur] = id[i];
		}
		if (cur < x[id[i]]) return puts("No"), 0;
	}
	puts("Yes");
	for (int i = 1; i <= m; i++) printf("%d%c", ans[i], " \n"[i == m]);
	return 0;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

int N,M;
int root;
int num_visited;
int vertex[SIZE];
int sdom[SIZE],idom[SIZE];
int parent[SIZE],work[SIZE],uf_parent[SIZE];
vector<int> G[SIZE],rev_G[SIZE],bucket[SIZE];

int find(int node_id){
	if(node_id == uf_parent[node_id]){

		return node_id;

	}else{

		int ret = find(uf_parent[node_id]);

		if(sdom[work[node_id]] > sdom[work[uf_parent[node_id]]]){

			work[node_id] = work[uf_parent[node_id]];
		}

		return uf_parent[node_id] = ret;
	}
}

void LINK(int child,int arg_parent){

	uf_parent[child] = arg_parent;
}

void dfs(int node_id,int pre){

	parent[node_id] = pre;
	vertex[num_visited] = node_id;
	sdom[node_id] = num_visited++;

	for(int i = 0; i < G[node_id].size(); i++){

		int next = G[node_id][i];
		if(sdom[next] != -1)continue;

		dfs(next,node_id);
	}
}

int EVAL(int node_id){

	find(node_id);
	return work[node_id];
}


int main(){

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

	int from,to;
	for(int loop = 0; loop < M; loop++){

		scanf("%d %d",&from,&to);
		from--;
		to--;
		G[from].push_back(to);
		rev_G[to].push_back(from);
	}

	root = 0;
	num_visited = 0;

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

		sdom[i] = -1;
		uf_parent[i] = i;
		work[i] = i;
	}

	dfs(root,-1);

	for(int i = N-1; i >= 1; i--){

		int node_id = vertex[i];

		for(int k = 0; k < rev_G[node_id].size(); k++){

			int pre_node = rev_G[node_id][k];
			int u = EVAL(pre_node); //分岐の始点を求める
			sdom[node_id] = min(sdom[node_id],sdom[u]);
		}
		bucket[vertex[sdom[node_id]]].push_back(node_id);

		for(int k = 0; k < bucket[parent[node_id]].size(); k++){

			int v = bucket[parent[node_id]][k];
			int u = EVAL(v);

			if(sdom[u] < sdom[v]){

				idom[v] = u;
			}else{

				idom[v] = parent[node_id];
			}
		}
		bucket[parent[node_id]].clear();
		LINK(node_id,parent[node_id]);
	}

	for(int i = 1; i < N; i++){

		int w = vertex[i];

		if(idom[w] != vertex[sdom[w]]){

			idom[w] = idom[idom[w]];
		}
	}
	idom[root] = -1;

	int num_query;
	scanf("%d",&num_query);

	int tmp;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d",&tmp);
		tmp--;

		if(idom[tmp] == root){

			printf("%d\n",tmp+1);
		}else{

			printf("%d\n",idom[tmp]+1);
		}
	}

	return 0;
}



Measured memory_bytes: 22480
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int d[100010];
int pre[100010];

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    string s;
    cin >> n >> m >> s;
    reverse(s.begin(), s.end());
    priority_queue<int> q;
    q.push(0);
    rep(i, 0, n + 1) d[i] = INF;
    d[0] = 0;
    pre[0] = -1;
    int ans = -1;
    while(q.size()){
        int p = q.top(); q.pop();
        for(int i = min(m, n - p); i >= 1; i--){
            if(s[p + i] == '1') continue;
            if(d[p + i] != INF) continue;
            d[p + i] = d[p] + 1;
            pre[p + i] = p;
            q.push(p + i);
            if(p + i == n){
                ans = d[p + i];
            }
            break;
        }
        if(ans != -1) break;
    }
    if(ans == -1){
        cout << -1 << endl;
        return 0;
    }
    vector<int> dice;
    int now = n;
    while(1){
        int nxt = pre[now];
        if(nxt == -1) break;
        dice.push_back(abs(now - nxt));
        now = nxt;
    }
    for(int ii = 0; ii < dice.size(); ii++){
        if(ii) cout << ' ';
        cout << dice[ii];
    }
    cout << endl;
}   

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

const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<char> c(n);
    rep(i, 0, s.size()) c[i] = s[i];
    int flag = 0;
    bool check = false;
    if(c[0] == 'R') check = true;
    rep(i, 1, n){
        if(c[i] != c[i-1]) flag++;
    }
    if(flag == 0){
        cout << 0 << endl;
        return 0;
    }
    if(check == true && flag <= 1){
        cout << 0 << endl;
        return 0;
    }
    int cnt_w = 0;
    int cnt_r = 0;
    rep(i, 0, n){
        if(c[i] == 'W') cnt_w++;
        else cnt_r++;
    }
    if(flag == 1){
        cout << min(cnt_w, cnt_r) << endl;
        return 0;
    }
    int cnt_W, cnt_R;
    cnt_W = cnt_R = 0;
    rep(i, 0, cnt_r){
        if(c[i] == 'W') cnt_W++;
    }
    for(int i = n-1; i >= 0; i--){
        if(c[i] == 'R') cnt_R++;
    }
    cout << min(cnt_R, cnt_W) << endl;
    return 0;
}


Measured memory_bytes: 3920
def get_par(tree: list, root: int) -> list:
    """根付き木の頂点それぞれの親を求める"""
    n = len(tree)
    visited = [False] * n
    visited[root] = True
    par = [-1] * n
    stack = [root]
    while stack:
        v = stack.pop()
        for nxt_v in tree[v]:
            if visited[nxt_v]:
                continue
            visited[nxt_v] = True
            stack.append(nxt_v)
            par[nxt_v] = v
    return par


def topological_sort(tree: list, root) -> list:
    """根付き木をトポロジカルソートする"""
    n = len(tree)
    visited = [False] * n
    visited[root] = True
    tp_sorted = [root]
    stack = [root]
    while stack:
        v = stack.pop()
        for nxt_v in tree[v]:
            if visited[nxt_v]:
                continue
            visited[nxt_v] = True
            stack.append(nxt_v)
            tp_sorted.append(nxt_v)
    return tp_sorted


n = int(input())
a = list(map(int, input().split()))
edges = [list(map(int, input().split())) for i in range(n - 1)]


tree = [[] for i in range(n)]
for u, v in edges:
    u -= 1
    v -= 1
    tree[u].append(v)
    tree[v].append(u)

# rootには葉以外を選ぶ
root = -1
for v in range(n):
    if len(tree[v]) != 1:
        root = v
        break
        
# 頂点2つのときはrootを葉として選べない
if root == -1:
    if a[0] == a[1]:
        print("YES")
    else:
        print("NO")
    exit()
    
par = get_par(tree, root)
tp_sorted = topological_sort(tree, root)

stn_cnt = [[] for _ in range(n)]

# 葉から探索
is_YES = True
for v in tp_sorted[::-1]:
    if not stn_cnt[v]:
        par_v = par[v]
        stn_cnt[par_v].append(a[v])
        continue
    sum_cnt = sum(stn_cnt[v])
    max_cnt = max(stn_cnt[v])
    if sum_cnt < a[v]:
        is_YES = False
        break
    cnt1 = 2 * a[v] - sum_cnt
    cnt2 = sum_cnt - a[v]
    if v == root and cnt1 != 0:
        is_YES = False
        break
    if cnt1 < 0:
        is_YES = False
        break
    if cnt2 < 0 or min(sum_cnt - max_cnt, sum_cnt // 2) < cnt2:
        is_YES = False
        break
    par_v = par[v]
    stn_cnt[par_v].append(cnt1)

if is_YES:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 120060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
const int maxn=100+10;
int n;
int g[maxn][maxn];
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    int no,cnt,dd;
    memset(g,0,sizeof(g));
   for(int i=0;i<n;i++)
    {
        scanf("%d%d",&no,&cnt);
        for(int j=0;j<cnt;j++)
        {
            scanf("%d",&dd);
            g[no-1][dd-1]=1;
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(j) printf(" ");
            printf("%d",g[i][j]);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 3260
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-06 20:28:58
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-08 19:09:22
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef pair<int,int> pii;

namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}

using namespace IO;

typedef pair<ll,ll> frac;

ll N,S=0;
vector<frac> T;
bool mp(frac A,frac B)
{
    return (A.first*B.second<A.second*B.first);
}
ll gcd(ll x,ll y) { return (!y)?x:gcd(y,x%y); }
signed main()
{

    read(N);
    for(int i=1;i<=N;i++)
    {   
        ll x,y;
        read(x),read(y);
        S+=x;
        T.push_back(make_pair(std::max(x,y),y));
    }
    sort(T.begin(),T.end(),greater<frac>());
    ll pos=0;
    ll point=0;
    int ca=0;
    for(auto it=T.begin();it!=T.end();it++)
    {
        if((pos+it->first) >S) break;
        pos+=it->first;
        point=it-T.begin();
        ca++;
    }
    if(ca==N){cout<<"0 1"<<endl;return 0;}
    frac ans(0,1);
    for(int i=0;i<T.size();++i)
    {
        if(i+1>ca)
        {
            if(pos+T[i].second>=S) 
            {
                frac res(pos+T[i].second-S,T[i].second);
                ans=(mp(ans,res))?res:ans;
            }
        }
        else
        {
            if(pos-T[i].first+T[point+1].first+T[i].second>=S)
            {
                frac res(pos-T[i].first+T[point+1].first+T[i].second-S,T[i].second);
                ans=(mp(ans,res))?res:ans;
            }
        } 
    }
    ans.first+=ans.second*(N-ca-1);ans.second*=N;
    ll _f=gcd(ans.first,ans.second);
    cout<<ans.first/_f<<" "<<ans.second/_f<<endl;
    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
const int mod = 1e9+7;
const int mx = INT_MAX;
const long double pi = 4*atan((long double)1);
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define file "orz"
const int mxN=1e5+5;
int n, arr[mxN], cnt[mxN], occ[mxN];
signed main()
{
    //freopen(file".inp","r",stdin);
    //freopen(file".out","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n;
    priority_queue<pii> pq;
    for(int i=1;i<=n;i++)
    {
    	cnt[i]=1;
    	cin>>arr[i];
    	pq.push(mp(arr[i],i));
	}
	while(pq.size()>=2)
	{
		auto temp=pq.top();
		pq.pop();
		auto temp2=pq.top();
		pq.pop();
		occ[temp.se] += cnt[temp.se]*(temp.fi-temp2.fi);
		cnt[min(temp.se,temp2.se)]+=cnt[max(temp.se,temp2.se)];
		pq.push(mp(temp2.fi,min(temp.se,temp2.se)));
	}
	cout<<occ[1]+n*pq.top().fi<<"\n";
	for(int i=2;i<=n;i++)
		cout<<occ[i]<<"\n";
}


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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line


// now += mint(2).pow(s) - 1; こんな感じで、2のs乗を求められrう
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main()
{
	int n, s;
	cin >> n >> s;
	vector<int> a(n);
	rep(i, n)cin>>a[i];
	vector<mint> dp(s+1);
	dp[0] = 1;
	rep(i,n) {
		vector<mint> p(s+1);
		swap(dp,p);
		rep(j,s+1){
			dp[j] += p[j] * 2;
			if( j + a[i] <= s) dp[j+a[i]] += p[j];
		}
	}
	cout << dp[s] << endl;
}


Measured memory_bytes: 3628
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

array = [a,b,c,d,e]
flag = True

for i in range(0, 4):
    for j in range(i+1, 5):
        if abs(array[i] - array[j] )> k:
            flag = False
            break
            
if flag:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    vector<string> aaa;
    string a = "", b = "";
    for(int i = 1; i <= n; i++) a += (m + '0');
    for(int i = 1; i <= m; i++) b += (n + '0');
    aaa.push_back(a);
    aaa.push_back(b);
    sort(aaa.begin(), aaa.end());
    cout << aaa[0] << endl;
    return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    bool is_575 = false;
    if (a == 7 && b == 5 && c == 5) {
        is_575 = true;
    }
    else if (a == 5 && b == 7 && c == 5) {
        is_575 = true;
    }
    else if (a == 5 && b == 5 && c == 7) {
        is_575 = true;
    }

    if (is_575 == true) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

    return 0;
}


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

ll A,B;

// 下位1ビット変わるだけの数字のxorは1 && xorは可換 -> xまでの数字全てのxorは4の倍数で場合分けできる。
ll check(ll x){
	if(x % 4 == 0){
		return x;
	} else if(x % 4 == 1){
		return 1;
	} else if (x % 4 == 2){
		return x ^= 1;
	}
	return 0;
}

int main()
{
	cin >> A >> B;
	// n xor n = 0
	ll ans = check(B) ^ check(A-1);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)
const int N = 3000, M = 7 + 1e9;
int n, a[N];
ll dp[N][N][2];
int main()
{
	cin >> n;
	f(i, 0, n)
		cin >> a[i];
	f(i, 0, n)
		dp[i][i][0] = -a[i]; // of length 1
	f(i, 0, n)
		dp[i][i][1] = a[i];
	
	f(i, 2, n+1){//all continous with len i
		f(j, 0, n-i+1){
			int r = j, l = j+i-1;
			dp[r][l][0] = min(dp[r+1][l][1]-a[r], dp[r][l-1][1]-a[l]);
			dp[r][l][1] = max(dp[r+1][l][0]+a[r], dp[r][l-1][0]+a[l]);
		}
	}
	cout << dp[0][n-1][1];
 
}

Measured memory_bytes: 139776
#include <cstdio>
#include <iostream>

bool is_prime(int number)
{
    if(number < 2) {
        return false;
    }

    for(int i = 2; i * i <= number; i++) {
        if(number % i == 0) {
            return false;
        }
    }
    return true;
}

int main()
{
    int input_size;
    int counter = 0;
    std::cin >> input_size;
    for(int i = 0; i < input_size; i++) {
        int number;
        std::cin >> number;
        if(is_prime(number)) {
            counter++;
        }
    }
    printf("%d\n", counter);
    return 0;
}

Measured memory_bytes: 3156
// https://atcoder.jp/contests/abc084/tasks/abc084_d
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    ll Q;
    cin >> Q;
    vector<ll> l(Q), r(Q);
    REP(i, Q) cin >> l[i] >> r[i];
    vector<ll> isprime(100011, 0);
    size_t N = isprime.size();
    for (size_t n = 2; n < N; ++n)
    {
        if (isprime[n] == -1)
            continue;
        
        isprime[n] = 1;
        for (size_t k = n + n; k < N; k += n)
        {
            isprime[k] = -1;
        }
    }

    vector<ll> cnt(N, 0);
    for (size_t n = 3; n < N; n += 2)
    {
        if (isprime[n] == 1 && isprime[(n + 1) / 2] == 1)
        {
            cnt[n] = cnt[n - 2] + 1;
            cnt[n - 1] = cnt[n - 2];
        }
        else
        {
            cnt[n] = cnt[n - 2];
            cnt[n - 1] = cnt[n - 2];
        }
        
    }

    vector<ll> res(Q, 0);
    REP(i, Q)
    {
        res[i] = cnt[r[i]] - cnt[l[i] - 1];
    }

    REP(i, Q)
    {
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 7220
K = int(input())

lunlun = [i for i in range(1, 10)]

p = 0


def genelate_lunlun(p):
    last = p % 10
    if last > 0:
        yield p * 10 + last - 1
    yield p * 10 + last
    if last + 1 < 10:
        yield p * 10 + last + 1


while len(lunlun) <= K:
    for new in genelate_lunlun(lunlun[p]):
        lunlun.append(new)
    p += 1

# print(lunlun)
print(lunlun[K - 1])


Measured memory_bytes: 7144
N = int(input())
ABC = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * 3 for _ in range(N+1)]
for i in range(N):
    dp[i+1][0] = max(dp[i][1]+ABC[i][0], dp[i][2]+ABC[i][0])
    dp[i+1][1] = max(dp[i][0]+ABC[i][1], dp[i][2]+ABC[i][1])
    dp[i+1][2] = max(dp[i][0]+ABC[i][2], dp[i][1]+ABC[i][2])

print(max(dp[-1]))
    


Measured memory_bytes: 74712
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author CodeMonk
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int arr[] = new int[10000];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                long s = Math.min(arr[i], k - arr[i]);
                ans += s;
            }
            out.println(ans * 2);
        }

    }
}


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

int main () {
  string S;
  cin >> S;
  
  int ans = 0;
  for (int i = 0; i < 4; i++) {
    if (S.at(i) == '+') {
      ans ++;
    }
    else {
      ans --;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <math.h>

using namespace std;
int main(void)
{
	int a, b, c, k;

	cin >> a >> b >> c >> k;

	int ans = 0;

	if (k <= a)
	{
		cout << k << endl;
		return 0;
	}

	ans += a;
	k -= a;

	if (k <= b)
	{
		cout << ans << endl;
		return 0;
	}

	k -= b;

	c -= k;

	cout << (ans - k) << endl;

	return 0;
}

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

using namespace std;

int main()
{
  	int n;
  cin>>n;
  
  int a[n][3];
  
  for(int i=0;i<n;i++)
  {
    	cin>>a[i][0]>>a[i][1]>>a[i][2];
  }
  
  for(int i=1;i<n;i++)
  {
    	a[i][0] +=   max(a[i-1][1],a[i-1][2]);
    	a[i][1] +=  max(a[i-1][0],a[i-1][2]);
    	a[i][2] += max(a[i-1][1],a[i-1][0]);
    
  }
  
  int result = max(a[n-1][0],max(a[n-1][1],a[n-1][2]));
  
  cout<<result<<endl;
}

Measured memory_bytes: 1408