akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int      long long int
#define MOD      1000000007
#define pb       push_back
#define mp       make_pair
#define vi       vector<int>
#define mi  	 map<int,int>
#define umi		 unordered_map<int,int>
#define pii      pair<int,int>
#define ff 		 first
#define ss 		 second
#define inf		 1e18
#define case	int t;cin>>t;while(t--)
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void pre()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main()
{	//pre();
	//case
	{	string a, b;
		cin >> a >> b;
		int sa = a.length(), sb = b.length();
		int dp[sa + 2][sb + 2];
		for (int i = 0; i <= sa; i++)
		{	for (int j = 0; j <= sb; j++)
			{	if (i == 0 || j == 0)
					dp[i][j] = 0;
				else if (a[i - 1] == b[j - 1])
					dp[i][j] = dp[i - 1][j - 1] + 1;
				else
					dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
				//cout << dp[i][j] << " ";
			}
			//cout << endl;
		}
		int i = sa, j = sb;
		string s = "";
		//cout << dp[i][j] << endl;
		while (1)
		{	if (i == 0 || j == 0)
				break;
			if (a[i - 1] == b[j - 1])
			{	s += a[i - 1];
				i--;
				j--;
			}
			else if (dp[i - 1][j] >= dp[i][j])
				i--;
			else
				j--;

		}
		reverse(s.begin(), s.end());
		cout << s;
	}
	return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
int n,m;
vector<int> v[max_n];
struct Seg//min 
{
    #define lson l,mid,rt<<1
    #define rson mid+1,r,rt<<1|1
    int d[1<<20],lazy[1<<20];
    void pushup(int rt)
    {
        d[rt]=min(d[rt<<1],d[rt<<1|1]);
    }
    void pushdown(int rt,int ln=1,int rn=1)
    {
        if(lazy[rt])
        {
            d[rt<<1]+=lazy[rt]*ln;
            d[rt<<1|1]+=lazy[rt]*rn;
            lazy[rt<<1]+=lazy[rt];
            lazy[rt<<1|1]+=lazy[rt];
            lazy[rt]=0;
        }
    }
    void init(int l,int r,int rt)
    {
        d[rt]=INT_MAX,lazy[rt]=0;
        if(l==r)return;
        int mid=l+r>>1;
        init(lson),init(rson);
    }
    void ins(int x,int c,int l,int r,int rt)
    {
        if(l==r)
        {
            d[rt]=c;
            return;
        }
        int mid=l+r>>1;
        pushdown(rt);
        if(x<=mid)ins(x,c,lson);
        else ins(x,c,rson);
        pushup(rt);
    }
    void update(int L,int R,int C,int l,int r,int rt)
    {
        if(L>R)return;
        if(l>=L&&r<=R)
        {
            d[rt]+=C;
            lazy[rt]+=C;
            return;
        }
        int mid=l+r>>1;
        pushdown(rt);
        if(mid>=L)update(L,R,C,lson);
        if(mid<R)update(L,R,C,rson);
        pushup(rt);
    }
    int query(int L,int R,int l,int r,int rt)
    {
        if(L>R||L>r||R<l)return INT_MAX;
        if(l>=L&&r<=R)return d[rt];
        int mid=l+r>>1;
        pushdown(rt);
        return min(query(L,R,lson),query(L,R,rson));
    }
}Tree;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        int l,r;scanf("%d%d",&l,&r);
        v[l].push_back(r);
    }
    Tree.init(1,m+1,1);
    for(int i=1;i<=m+1;i++)Tree.ins(i,-i,1,m+1,1);
    int ans=n-m;
    for(int i=0;i<=m;i++){
        for(auto x:v[i])Tree.update(1,x,-1,1,m+1,1);
        int res=-Tree.query(1,m+1,1,m+1,1);
        ans=max(ans,res-i-m-1);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 16768
class Node():
    def __init__(self):
        self.lt = None
        self.rt = None
        self.dep = None

class Trie():
    def __init__(self):
        self.root = Node()
        self.root.dep = 0

    def add(self, string):
        node = self.root
        for s in string:
            if s == '0':
                if node.lt is None:
                    node.lt = Node()
                    node.lt.dep = node.dep + 1
                node = node.lt
            else:
                if node.rt is None:
                    node.rt = Node()
                    node.rt.dep = node.dep + 1
                node = node.rt

N, L = map(int, input().split())

trie = Trie()

for _ in range(N):
    s = input()
    trie.add(s)

subgame = []
stack = [trie.root]

while stack:
    node = stack.pop()
    if node.lt is None and node.rt is None:
        continue
    elif node.rt is None:
        stack.append(node.lt)
        subgame.append(L - node.dep)
    elif node.lt is None:
        stack.append(node.rt)
        subgame.append(L - node.dep)
    else:
        stack.append(node.lt)
        stack.append(node.rt)

def grundy(n):
    if n == 0: return 0
    if n % 2 == 1: return 1
    if n == 2**(n.bit_length() - 1):
        return n
    return grundy(n - 2**(n.bit_length() - 1))

g = 0

for l in subgame:
    g ^= grundy(l)

print('Alice' if g != 0 else 'Bob')

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

like=[set() for i in range(N)]
cnt=0
for i in range(N):
    if i+1<A[i]:
        like[A[i]-1].add(i+1)
    else:
        if A[i] in like[i]:
            cnt+=1
print(cnt)


Measured memory_bytes: 32192
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int x[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>x[i][j];
        }
    }
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            bool b=true;
            int h;
            for(int k=0;k<n;k++){
                if(x[k][2]){
                    h=abs(x[k][0]-i)+abs(x[k][1]-j)+x[k][2];
                    break;
                }
            }
            for(int k=0;k<n;k++){
                 if(max(0,h-abs(x[k][0]-i)-abs(x[k][1]-j))!=x[k][2])b=false;
            }
            if(b){
                cout<<i<<" "<<j<<" "<<h<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> v(n,k);
    rep(i,q)
    {
        int a;
        cin>>a;
        v[a-1]++;
    }
    rep(i,v.size())
    {
        if(v[i]-q>0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}


const int mod = 1000000007;
// const int mod = 998244353;

struct mint {
  long long x;
  mint(long long 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 -= a.x) < 0) x += mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint operator++() const { return mint(*this) += mint(1);}
  mint operator--() const { return mint(*this) -= mint(1);}
  mint pow(long long 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 { return mint(*this) /= 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;cin >> n;
  vi a(n,0);
  mint sum = mint(0);
  rep(i,n) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  mint ans = mint(0);
  rep(i,n) ans += (sum - a.at(i)) * a.at(i);
  ans /= 2;

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3972
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int x = Integer.parseInt(sc.next());
		boolean a = true;
		int aa = x;
		int i = 0;
		while(a){
			i++;
			if(x % 360 == 0){
				a = false;
				ou.println(i);
			}
			x += aa;
		}
		ou.flush();
	}
}

Measured memory_bytes: 35744
#include <bits/stdc++.h>
using namespace std;
 
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define mod 1000000007
#define qmod 998244353
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll LINF = LLONG_MAX;
int main(){
	string s;
	cin>>s;
	int count=0,mx=INT_MIN;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A' ||s[i]=='C' ||s[i]=='G' ||s[i]=='T'){
			count++;
		}
		else{
			count =0;			
		}
		mx = max(mx,count);

	}
	cout<<mx;
}

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

int main() {
  int x, y; cin >> x >> y;
  vector<int> v;
  v = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  if (v.at(x) == v.at(y)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int n;
string colors;
vector<vector<int>> g;

int numAll = 0;
int numWhite = 0;
bool _allBlack;
int _maxWhiteDown;
int maxWhitePath;

void dfs(int x, int p) {
    bool allBlack = colors[x] == 'B';
    int maxWhiteDown = 0;
    int max1 = 0;
    int max2 = 0;
    int deg = (p >= 0);
    for (int y : g[x]) {
        if (y == p) continue;
        dfs(y, x);
        if (!_allBlack) {
            deg++;
            allBlack = false;
        }
        maxWhiteDown = std::max(maxWhiteDown, _maxWhiteDown);
        if (_maxWhiteDown > max1) {
            max2 = max1;
            max1 = _maxWhiteDown;
        } else if (_maxWhiteDown > max2) {
            max2 = _maxWhiteDown;
        }
    }
    if (allBlack) {
        _allBlack = true;
        _maxWhiteDown = 0;
    } else {
        _allBlack = false;
        numAll++;
        int isWhite = ((colors[x] == 'W') + deg) & 1;
        if (isWhite) numWhite++;
        _maxWhiteDown = maxWhiteDown + isWhite;
        maxWhitePath = std::max(maxWhitePath, max1 + max2 + isWhite);
    }
//    cout << x << " " << _allBlack << " " << _maxWhiteDown << " " << maxWhitePath << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);

    cin >> n;
    g.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    cin >> colors;

    for (int i = 0; i < n; i++) {
        if (colors[i] == 'W') {
            dfs(i, -1);
//            cout << "!" << numAll << " " << numWhite << " " << maxWhitePath << "\n";
            if (numAll == 1) {
                cout << 1 << "\n";
            } else {
                cout << 2 * (numAll - 1) + numWhite - 2 * maxWhitePath << "\n";
            }
            return 0;
        }
    }
    cout << 0;

    return 0;
}

Measured memory_bytes: 15312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,m,k,ans=0;
    cin>>n>>m>>k;
    ll a[n+1]={0},b[m+1]={0};
    for(ll i=1;i<=n;i++) cin>>a[i],a[i]+=a[i-1];
    for(ll i=1;i<=m;i++) cin>>b[i],b[i]+=b[i-1];
    for(ll i=0;i<=n;i++) if(k>=a[i]) ans=max(ans,upper_bound(b+1,b+1+m,k-a[i])-b-1+i);
    cout<<ans;
}


Measured memory_bytes: 6764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)
#define M 1000000007


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>s;
    for0(s.size())
    {
        c+=(s[i]-'0');
    }
    cout<<(c%9?"No":"Yes")<<endl;
}



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

#define forn(l, r) for(int i = l; i < (r); ++i)
#define forj(l, r) for(int j = l; j < (r); ++j)
#define TAM 1000100
#define SYNC ios::sync_with_stdio(0);
#define $ << ' ' <<
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
const ll mod = 1000000007;




int main() {
    //SYNC
    ll ans;
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    ans = min(n, k)*x;
    ans += max(0, n-k)*y;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
public class Main {
	int N,X;
	int[] a;
	boolean[] isPrime,dp;

	public void setPrime(){
		isPrime[0] = isPrime[1] = false;
		for(int i = 2;i <= X;i++){
			if(!isPrime[i])continue;
			isPrime[i] = true;
			for(int j = 2;j * i <= X;j++){
				isPrime[j * i] = false;
			}
		}
	}

	public void solve() {
		while(true){
			N = nextInt();
			X = nextInt();

			if(N + X == 0)break;
			a = new int[N];
			for(int i = 0;i < N;i++){
				a[i] = nextInt();
			}

			isPrime = new boolean[X + 1];
			Arrays.fill(isPrime, true);
			setPrime();
			dp = new boolean[X + 1];
			dp[0] = true;
			for(int i = 0;i < N;i++){
				for(int j = 0;j <= X;j++){
					if(dp[j] && j + a[i] <= X){
						dp[j + a[i]] = true;
					}
				}
			}

			boolean find = false;
			for(int i = X;i >= 0;i--){
				if(dp[i] && isPrime[i]){
					out.println(i);
					find = true;
					break;
				}
			}
			if(!find)out.println("NA");
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 60832
#include <bits/stdc++.h>
#define ll long long
#define all(x) begin(x), end(x)
#define range(x) begin(x), begin(x)
#define what(x) cout << #x << ": " << x << '\n'
#define print(x) for (auto &el: x) cout << el << ' '; cout << '\n'
using namespace std;
 
template<typename S, typename T>
ostream& operator <<(ostream &os, pair<S, T> &m) { 
	os << '[' << m.first << " " << m.second << ']'; 
	return os; 
}

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

	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for (auto &el: v) cin >> el;
	sort(all(v));
	cout << accumulate(range(v) + k, 0) << endl;
	

	return 0;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int[] ans = new int[n];
    for(int i = 1; i < n; i++) {
      for(int j = i + 1; j <= n; j++) {
        int t = j - i;
        t = Math.min(t, Math.abs(i - x) + 1 + Math.abs(y - j));
        t = Math.min(t, Math.abs(i - y) + 1 + Math.abs(x - j));
        ans[t]++;
      }
    }

    for(int i = 1; i < n; i++) {
      System.out.println(ans[i]);
    }
  }
}

Measured memory_bytes: 36636
#include <iostream>

using namespace std;

int main(void) {
  int n, y;
  cin >> n >> y;
  y /= 1000;
  for(int i = 0; i * 10 <= y; i++) {
    for(int j = 0; i * 10 + j * 5 <= y; j++) {
      if(i * 10 + j * 5 + (n - i - j) == y) {
        cout << i << " " << j << " " << (n - i - j);
        return 0;
      }
    }
  }
  cout << "-1 -1 -1";
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    println(
        when (s) {
            "SUN" -> 7
            "MON" -> 6
            "TUE" -> 5
            "WED" -> 4
            "THU" -> 3
            "FRI" -> 2
            "SAT" -> 1
            else -> 0
        }
    )

}

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

int main(){
    string s;
    cin >> s;
    int ans = 700;
    rep(i,3) if(s[i] == 'o') ans += 100;
    cout << ans << endl;
}

Measured memory_bytes: 3560
using System;
using System.Linq;
 
class program
{
    static void Main()
    {
        var xkd = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        long x = xkd[0], k = xkd[1], d = xkd[2];
        long move = x / d;
        long ans = 0;
        if (Math.Abs(move) > k)
        { 
          if(Math.Abs(x - k * d) < Math.Abs(x + k * d)) ans = Math.Abs(x - k * d);
          else ans = Math.Abs(x + k * d);
        }
        else
        {
            if ((k - move) % 2 == 1)
            {
                if (Math.Abs(x - (move + 1) * d) < Math.Abs(x - (move - 1) * d))
                    ans = Math.Abs(x - (move + 1) * d);
                else
                    ans = Math.Abs(x - (move - 1) * d);
            }
            else ans = Math.Abs(x - move * d);
        }
        Console.Write(ans);
 
    }
}

Measured memory_bytes: 28136
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,x;
	cin>>n>>x;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	sort(ALL(a));
	ll ans=0;
	REP(i,n) {
		if(a[i]>x) break;
		else {
			ans++;
			x-=a[i];
		}
	}
	if(ans==n&&x>0) cout<<ans-1<<endl;
	else cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.par = [-1 for i in range(n)]

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x]) # contraction
            return self.par[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.par[x] > self.par[y]: # merge technique
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

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

    def size(self, x):
        return -self.par[self.root(x)]

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

ans = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i == j:
            continue
        uf.unite(edges[j][0], edges[j][1])

    is_bridge = False
    for j in range(1, n):
        if not uf.same(j-1, j):
            is_bridge = True
            break

    if is_bridge:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,k,n74=0,n24=0,n14=0,n4=0,n2=0,ans=0;
  cin>>n;
  vector<int> p;
  p.push_back(2);
  for(i=3;i<100;i++){
    for(j=0;j<p.size();j++) if(i%p.at(j)==0) break;
    if(j==p.size()) p.push_back(i);
  }
  vector<int> c(p.size());
  for(i=2;i<=n;i++){
    k=i;
    for(j=0;j<p.size();j++){
      while(k%p.at(j)==0){
        c.at(j)++;
        k/=p.at(j);
      }
      if(k==1) break;
    }
  }
  for(i=0;i<c.size();i++){
    if(c.at(i)>=2){
      n2++;
      if(c.at(i)>=4){
        n4++;
        if(c.at(i)>=14){
          n14++;
          if(c.at(i)>=24){
            n24++;
            if(c.at(i)>=74) n74++;
          }
        }
      }
    }
  }
  ans+=n74;
  if(n2>=1) ans+=n24*(n2-1);
  if(n4>=1){
    ans+=n14*(n4-1);
    if(n2>=2) ans+=n4*(n4-1)/2*(n2-2);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_N 200000

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, a[MAX_N + 1];
int ball[MAX_N + 1];
int main(int argc, char **argv) {
    cin >> N;
    for(int i = 1; i <= N; ++i)
        cin >> a[i];

    for(int i = 1; i <= N; ++i)
        ball[i] = -1;

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

        bool cur = a[i];
        for(int j = N / i; j >= 1; --j) {
            if(j > 1) {
                if(ball[i * j] == 1)
                    cur = !cur;
            } else {
                ball[i] = cur;
            }
        }

    }

    vector<int> res;
    for(int i = 1; i <= N; ++i)
        if(ball[i] == 1)
            res.push_back(i);
        else if(ball[i] == -1)
            cout << "???: " << i << endl;
    
    cout << res.size() << endl;
    if(res.size()) {
        for(int i = 0; i < res.size(); ++i) {
            if(i != 0)
                cout << " ";
            cout << res[i];
        }
        cout << endl;
    }
    
}

Measured memory_bytes: 3064
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int x, a, b;
  cin >> x >> a >> b;
  if (a >= b) cout << "delicious" << endl;
  else if (b - a <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
#include<math.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。


int main(){
	int n;
	cin>>n;
	int h[n];
	rep0(i,n) cin>>h[i];
	int M=-inf;
	int ans=0;
	rep0(i,n){
		if(h[i]>=M){
			ans++;
			M=h[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
	int a,b,e=0;
	cin>>a>>b;
	string c,d;
	for(int i=a;i<=b;i++){
		c=to_string(i);
		d=c;
		rev(d);
		e+=(c==d);
	}
	cout<<e<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>

#define INF 100100100
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

 
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22){
        cout << "bust"<< endl;
        return 0;
    }
    cout << "win"<< endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

high = h[0]
now = 0
max = 0

for r_h in h[1:]:
    if(r_h <= high):
        now += 1
    elif( now > max):
        max = now*1
        now = 0
    else:
        now = 0
    high = r_h*1

if(now > max):
    max = now*1

print(max)


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

using namespace std;

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

const int MOD = 10007;

int dp[1001][8];

int main() {
	int n;
	string s;
	cin >> n >> s;
	rep (i, n + 1) rep (j, 8) dp[i][j] = 0;
	dp[0][1] = 1;
	rep (i, n) {
		int a;
		if (s[i] == 'J') a = 0;
		else if (s[i] == 'O') a = 1;
		else a = 2;
		rep (j, 8) rep (k, 8) {
			if (!(j & 1 << a)) continue;
			if (!(j & k)) continue;
			dp[i + 1][j] += dp[i][k];
			dp[i + 1][j] %= MOD;
		}
	}
	int res = 0;
	rep (i, 8) {
		res += dp[n][i];
		res %= MOD;
	}
	cout << res << endl;
}

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

string to_string(string s) {
    return '"' + s + '"';
}
string to_string(char ch) {
    string s(1, ch);
    return '\'' + s + '\'';
}
string to_string(const char *s) {
    return to_string((string)s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
 
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long int ll;
#define int ll
#define pb          push_back
#define pll         pair<int,int>
#define mll	        map<int,int>
#define F           first
#define S           second
#define lbnd(v,val) lower_bound(v.begin(),v.end(),val)
#define ubnd(v,val) upper_bound(v.begin(),v.end(),val)
#define bs(v,val)   binary_search(v.begin(),v.end(),val)
#define mp          make_pair
#define f(i,x,n)    for(int i=x;i<n;i++)
#define isup		isupper
#define islow 		islower
#define max3(a,b,c)	max(a,max(b,c))
#define endl        "\n"
#define countbits(n)	 __builtin_popcountll(n)
#define all(ar) ar.begin(), ar.end()
#define rall(ar) (ar).rbegin(), (ar).rend()
const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 2e5 + 10;

typedef vector<vector<ll>> matrix;
typedef vector<ll> vll;


void solve(){
	int n,w;
	cin>>n>>w;
	vector<pll> v(n);
	f(i,0,n){
		cin>>v[i].F>>v[i].S;
	}
	int dp[n+1][w+1];
	for(int i=0;i<=n;i++){
		for(int weight=0;weight<=w;weight++){
			if(i==0 || weight==0){
				dp[i][weight]=0;
			}
			else if(v[i-1].F<=weight){
				dp[i][weight] = max((int)v[i-1].S+dp[i-1][weight-v[i-1].F], dp[i-1][weight]);
			}else{
				dp[i][weight] = dp[i-1][weight];
			}
		}
	}
	// f(i,0,n+1){
	// 	f(j,0,w+1){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	cout<<dp[n][w]<<endl;
}

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

    int t=1;
    // cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}


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

int main(void)
{
	char a[15],b[15],c[15];
	int lena,lenb,lenc;
	scanf("%s %s %s",a,b,c);
	
	lena=strlen(a);
	lenb=strlen(b);
	lenc=strlen(c);
	
	if(a[lena-1]==b[0] && b[lenb-1]==c[0]){
		printf("YES\n");
	} else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
komoji = [chr(i) for i in range(97, 97+26)]

ans = ""
# print(N)
while True:
    q, mod = divmod(N, 26)
    ans = komoji[mod-1] + ans
    # print("q: {} mod: {} ans: {}".format(q, mod, ans))
    if mod == 0:
        q = q - 1
    N = q
    if q == 0:
        break
print(ans)

Measured memory_bytes: 9200
#!/usr/bin/env python3
import sys
from collections import Counter

def solve(N: int, S: "List[str]"):
    c = Counter(S)
    for w in ["AC", "WA", "TLE", "RE" ]:
        print(f"{w} x {c[w]}")
    return



# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


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



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

    int b[n+5];
    int a[n+5]={};

    for(int i=0;i<n-1;i++){
        cin >> b[i];
    }
    a[0]=b[0];

    for(int i=1;i<n-1;i++){
        a[i]=min(b[i],b[i-1]);
    }
    int sum=0;
    a[n-1]=b[n-2];
    for(int i=0;i<n;i++){
       sum+=a[i];
   }

   cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
  
$input = fgets(STDIN);
 
$T_LP = (int)explode(' ', $input)[0];
$T_AT = (int)explode(' ', $input)[1];
$A_LP = (int)explode(' ', $input)[2];
$A_AT = (int)explode(' ', $input)[3];

while($T_LP > 0 && $A_LP > 0){
  $A_LP -= $T_AT;
  if($A_LP <= 0){
    echo 'Yes';  
    break;
  }
  
  $T_LP -= $A_AT;
  if($T_LP <= 0){
    echo 'No';  
    break;
  }
}


Measured memory_bytes: 16184
#include <bits/stdc++.h>
#define int long long
using namespace std;

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  VI Nums;
  int now=1; //今見ている数
  int cnt=0;
  REP(i, N){
    if(S[i]==(char)('0'+now)){
      cnt++;
    }else{
      Nums.pb(cnt);
      now = 1 - now;
      cnt = 1;
    }
  }
  if(cnt!=0) Nums.pb(cnt);
  if(now==0) Nums.pb(0); //最後は1についてのcnt

  int ans=0;
  int Add=2*K+1;

  int right=0;
  int left=0; //[left, right)
  int tmp=0;
  
  for(int i=0; i < Nums.size(); i+=2){

    int Nextright=min(i+Add, (int)Nums.size());
    int Nextleft=i;

    while(Nextleft > left){
      tmp-=Nums.at(left);
      left++;
    }

    while(Nextright > right){
      tmp+=Nums.at(right);
      right++;
    }

    ans=max(ans, tmp);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1528
#include <iostream>

using namespace std;

int take;

int gcd(int n, int m)
{
    take++;
    if (m == 0)
        return n;
    return gcd(m, n % m);
}

int main()
{
    int n, m, ans;

    while (cin >> n >> m, n || m) {
        take = 0;
        ans = (n >= m) ? gcd(n, m) : gcd(m, n);

        cout << ans << " " << take - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int main()
{
    int n;
	string s;
 	cin>>s;
  	n=s.size();
  	if(s[n-1]=='s')
      cout<<s<<"es"<<endl;
  	else
      cout<<s<<"s"<<endl;

    return 0;
}


Measured memory_bytes: 3620
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A&lang=jp*/
#include<iostream>

using namespace std;

void println(int *a,int n){
    for(int i=0;i<n;i++){
        cout<<a[i];
        if(i<n-1){
            cout<<" ";
        }
    }
    cout<<endl;
}

int main()
{
    int n;
    int a[100];
    int count=0;
    bool flag = true;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i = 0;flag == true; i++){
        flag = false;
        for(int j = n-1; i < j; j--){
            if(a[j]<a[j - 1]){
                swap(a[j],a[j-1]);
                flag=true;
                count++;
            }
        }
    }
    println(a,n);
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int n, a[200010], l[200010], r[200010];
    long long sum[200010], ans=999999999999999999, t[4];
    cin>>n;
    sum[0]=0;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    l[2]=1;
    int right=1;
    for (int i=3; i<=n-2; i++)
    {
        while (right+1<i && abs(sum[right]-(sum[i]-sum[right]))>abs(sum[right+1]-(sum[i]-sum[right+1]))) right++;
        l[i]=right;
    }
    right=n-1;
    r[n-2]=n-1;
    for (int i=n-3; i>=2; i--)
    {
        while (right-1>i && abs((sum[right]-sum[i])-(sum[n]-sum[right]))>abs((sum[right-1]-sum[i])-(sum[n]-sum[right-1]))) right--;
        r[i]=right;
    }
    for (int i=2; i<=n-2; i++)
    {
        t[0]=sum[l[i]];
        t[1]=sum[i]-sum[l[i]];
        t[2]=sum[r[i]]-sum[i];
        t[3]=sum[n]-sum[r[i]];
        sort(t, t+4);
        ans=min(ans, t[3]-t[0]);
    }
    cout<<ans<<'\n';
	return 0;
}



Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    int N;
    cin>>N;
    int P=N;
    int S;
    bool a=true;
    while(a==true){
        if(N==0){
            a=false;
        }
        else{
            S+=N%10;
            N-=N%10;
            N/=10;
        }
    }
    if(P%S==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int n,y,ans,ic,uc,hc;
int main(){
    cin>>n>>y;


    for(int i=0;i<n+1;i++){
        if(1000*i>y||i>n)break;
        for(int u=0;u<n+1;u++){
            if(1000*i+5000*u>y||i+u>n)break;
            for(int h=0;h<n+1;h++){
                if(1000*i+5000*u+10000*h>y||i+u+h>n)break;
                if(1000*i+5000*u+10000*h==y&&i+u+h==n){
                    ic=h;
                    uc=u;
                    hc=i;
                    ans=1;
                    break;
                }
            }if(ans)break;
        }if(ans)break;
    }

    for(int i=0;i<1000000000*6;i++){
        int aho;
    }








    if(ans==1){
        cout<<ic<<" "<<uc<<" "<<hc<<endl;
    }else{
        cout<<"-1 -1 -1"<<endl;
    }
}


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

int main() {
  std::string S;

  std::cin >> S;

  int f = std::stoi(S.substr(0,2));
  int b = std::stoi(S.substr(2,2));

  if (1 <= f && f <= 12) {
    if (1 <= b && b <= 12) {
      std::cout << "AMBIGUOUS" << std::endl;
    } else {
      std::cout << "MMYY" << std::endl;
    }
  } else {
    if (1 <= b && b <= 12) {
      std::cout << "YYMM" << std::endl;
    } else {
      std::cout << "NA" << std::endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc146/tasks/abc146_b

#include "algorithm"
#include "cmath"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;
  string S;
  cin >> S;

  string res = S;

  rep(i, S.size()) {
    res[i] = S[i] + N;
    if (res[i] > 'Z') {
      res[i] -= 'Z' - 'A' + 1;
    }
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt(); int n = sc.nextInt();
		int[] price = new int[t];
		while (t-- > 0) {
			price[t] = sc.nextInt(); //receives input in reverse
		}

		Arrays.sort(price);
		int sum = 0;
		for (int i = 0; i<n; i++) {
			sum+=price[i];
		}

		System.out.println(sum);
	}
}


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

#define N 1007

char X[N],Y[N];
int c[N][N];

int L[N];

int m,n;

int LCSlength(char *,char *);

int  main(){
  int i,j,num;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    scanf("%s",X+1);
    scanf("%s",Y+1);

    L[i] =  LCSlength(X,Y);

  }

  for(i=0;i<num;i++){
    
    printf("%d\n",L[i]);

  }


  return 0;


}



int LCSlength(char *X,char *Y){
  int m,n;
  int i,j;
  int max=0;

  m = strlen(X+1);
  n = strlen(Y+1);
  
  for(i=0;i<=m;i++) c[i][0] = 0;
  for(j=0;j<=n;j++) c[0][j] = 0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      
      if(X[i] == Y[j]){
	c[i][j] = c[i-1][j-1] + 1;
      }

      else if(c[i-1][j] >= c[i][j-1]){
	c[i][j] = c[i-1][j];
      }

      else c[i][j] = c[i][j-1];
      if(max < c[i][j]) max = c[i][j];      
    }
  }

  return max;

}
  
  




Measured memory_bytes: 5712
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		char[][] s = new char[n][];
		for (int i = 0; i < n; i++) {
			s[i] = new StringBuilder(br.readLine()).reverse().toString().toCharArray();
		}
		br.close();

		int[][] num = new int[n][];
		List<Node> trie = new ArrayList<>();
		trie.add(new Node(' '));
		for (int i = 0; i < n; i++) {
			num[i] = new int[s[i].length];
			int idx = 0;
			for (int j = 0; j < s[i].length; j++) {
				num[i][j] = idx;
				char c = s[i][j];
				Node o = trie.get(idx);
				idx = o.next.getOrDefault(c, 0);
				if (idx == 0) {
					idx = trie.size();
					o.next.put(c, idx);
					trie.add(new Node(c));
				}
			}
			trie.get(idx).end = true;
		}

		int ans = 0;
		for (int i = 0; i < n; i++) {
			Set<Character> set = new HashSet<>();
			for (int j = s[i].length - 1; j >= 0; j--) {
				set.add(s[i][j]);
				Map<Character, Integer> map = trie.get(num[i][j]).next;
				for (char c : set) {
					int idx = map.getOrDefault(c, 0);
					if (trie.get(idx).end) {
						ans++;
					}
				}
			}
		}
		System.out.println(ans - n);
	}

	static class Node {
		char c;
		Map<Character, Integer> next = new HashMap<>();
		boolean end;

		public Node(char c) {
			this.c = c;
		}
	}
}


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

using namespace std;

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void sb()
{	
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<vector<ll>> dp;
vector<ll> v;
ll solve(int i,int j){
	if(i>j)
		return 0ll;
	if(dp[i][j]!=-1)
		return dp[i][j];
	if(i==j)
		return dp[i][j] = v[i];

	dp[i][j] = max(v[i]-solve(i+1,j),v[j]-solve(i,j-1));

	return dp[i][j];

}
int main()
{
	
	ll n;
	cin>>n;
	 v =  vector<ll>(n);
	dp = vector<vector<ll>>(n+1,vector<ll>(n+1,-1));
	for(int i=0;i<n;i++)
		cin>>v[i];

	cout<<solve(0,n-1)<<endl;
	
}

Measured memory_bytes: 74012
X = int(input())

mina = 0
maxa = 1000000000
mid = int((mina+maxa)/2)
for i in range(100):
    if mid*(mid+1)/2 < X:
        mina = mid
    else:
        maxa = mid
    mid = int((mina+maxa)/2)

print(mid+1)


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

void Main()
{
    int x, n;
    cin >> x >> n;
    vector<int> p(101);
    for (int i = 0; i < n; i++)
    {
        int in;
        cin >> in;
        p[in] = 1;
    }
    int min_d = abs(-1 - x);
    int min_i = -1;
    for (int i = 0; i <= 101; i++)
    {
        int d = abs(i - x);
        if(p[i] == 0 && min_d > d){
            min_d = d;
            min_i = i;
        }
    }
    
    cout << min_i << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 3636
<?php
$p=[0,0];
$L=trim(fgets(STDIN));
for($i=0;$i<$L;$i++){
  $C=explode(' ',trim(fgets(STDIN)));
  $c=strcmp($C[0],$C[1]);
  if($c<0) $p[1]+=3;
  elseif($c>0) $p[0]+=3;
  else{++$p[0];++$p[1];}
}
echo $p[0],' ',$p[1];
?>

Measured memory_bytes: 15288