akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define UP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define UU(a,b,c) for(ll (a)=(b);(a)<=(c);(a)++)
#define DN(a,b,c) for(ll (a)=(b);(a)>(c);(a)--)
#define DU(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

int r, c, m, x, y, row[300005] = {0}, col[300006] = {0};
map<pair<int,int>,bool>M;

void reset()
{
}

void input()
{
	cin>>r>>c>>m;
	UU(i,1,m)
	{
		cin>>y>>x;
		M[{y,x}] = 1;
		row[y]++;
		col[x]++;
	}
}

ll solve(int type)
{
	if(type == 0)
	{
		ll best = 0, ans = 0, idx = 0;
		
		UU(i,1,r)
		{
			if(best < row[i])
			{
				best = row[i], y = i;
			}
		}
		ans = best;
		best =0;
		UU(i,1,c)
		{
			int flag =0 ;
			if(M.count({y,i}))
			{
				flag = 1;
			}
			if(best < col[i] - flag)
			{
				best = col[i] - flag, x = i;
			}
		}
		ans += best;
		return ans;
	}
	else
	{
		ll best = 0, ans = 0, idx = 0;
		
		UU(i,1,c)
		{
			if(best < col[i])
			{
				best = col[i], x = i;
			}
		}
		ans = best;
		best =0;
		UU(i,1,r)
		{
			int flag =0 ;
			if(M.count({i,x}))
			{
				flag = 1;
			}
			if(best < row[i] - flag)
			{
				best = row[i] - flag, y = i;
			}
		}
		ans += best;
		return ans;
	}
}

void LetsRock()
{
	cout<<max(solve(0), solve(1))<<endl;
}

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

		input();
		reset();
		LetsRock();
	
	return 0;
}


Measured memory_bytes: 24732
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define cint(d) scanf("%d", &d)
#define cint2(a, b) scanf("%d %d", &a, &b)
#define cint3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define cint4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)

#define clong(d) scanf("%lld", &d)
#define clong2(a, b) scanf("%lld %lld", &a, &b)
#define clong3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define clong4(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)

#define foreach(v, c) for(__typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define revforeach(v, c) for(__typeof( (c).rbegin()) v = (c).rbegin();  v != (c).rend(); ++v)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

typedef long long int slong;
typedef pair<int, int> pii;
typedef pair<slong, slong> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

#ifdef VSP4 
    #include "debug.h"    
#else
    #define debug(args...)                  // Just strip off all debug tokens
#endif

const int MOD = 1000000007;
#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define MODADDSET(d) if ((d) >= MOD) d -= MOD;
#define MODADDWHILESET(d) while ((d) >= MOD) d -= MOD;

const int MAXN = 50;
const int SQRTN = 550;
const int LOGN = 60;
const int INT_INFINITY = 1001001001;
const int LIMIT = 40000;

const slong LONG_INFINITY = 1001001001001001001ll;
const slong LONG_LIMIT = 200100100100101ll;

slong k;
const slong MAXLIM = 5ll*1000*1000*1000*1000*100000;
const slong MAXVAL = 1ll*1000*1000*1000*1000*10000 + 1000;

int arr[MAXN+5];

int main()
{
	#ifdef VSP4
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	cout.tie(0);
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	int t, i, j, u, v;
	
	/*
	int n;
	cint(n);
	
	for (i = 1; i <= n; i++)
	{
		cint(arr[i]);
	}
	
	slong count = 0;
	
	while (true)
	{
		pii maxval = mp(-1, -1);
		
		for (i = 1; i <= n; i++)
		{
			maxval = max(maxval, mp(arr[i], i));
		}
		
		if (maxval.fi >= n)
		{
			count++;
			
			for (i = 1; i <= n; i++)
			{
				if (i == maxval.se)
				{
					arr[i] -= n;
				}
				else
				{
					arr[i]++;
				}
			}
		}
		else
		{
			break;
		}
	}
	
	cout << count;
	return 0;
	*/
	
	clong(k);
	
	for (int n = 2; n <= 50; n++)
	{
		slong first = (k - (n-1) + n)/(n+1);
		slong last = (MAXVAL + k - (n-1))/(n+1);
		
		if (first <= last)
		{
			slong done = n*first;
			slong perleft = (last-first);
			
			if (done <= k && (done + perleft*n) >= k)
			{
				//ans possible
				cout << n << "\n";
				slong left = k - done;				
				
				for (i = 1; i <= n; i++)
				{
					slong val = min(left, perleft);
					left -= val;
					
					val += first;
					
					slong a1 = val*(n+1) - k + (n-1);
					
					cout << a1 << " ";
				}
				
				return 0;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

Measured memory_bytes: 20480
#include <stdio.h>

#define true 1
#define false 0

#define MAX 3
#define INF 100000000

int limit;
int shortest = INF;
int count;
int puzzle[MAX * MAX];
int road[30][MAX * MAX];

void swap(int *x, int *y) {
    int tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
}

int history(int depth) {
    int i, j, cnt;
    if (depth < 2) return -1;

    cnt = (MAX * MAX) - 1;
    for (j = depth - 2; j != 0; j--) {
        for (i = 1; i < (MAX * MAX); i++) {
            if (puzzle[i - 1] == road[depth - 2][i - 1]) {
                cnt--;
            }
        }
        if (cnt == 0) return cnt;
    }
    return cnt;
}

int check() {
    int i, cnt;

    cnt = (MAX * MAX) - 1;
    for (i = 1; i < (MAX * MAX); i++) {
        if (puzzle[i - 1] == i) {
            cnt--;
        }
    }
    return cnt;
}

int up(int i, int *dir) {
    *dir = i - MAX;
    if (*dir >= 0) { return true; }
    else return false;
}

int down(int i, int *dir) {
    *dir = i + MAX;
    if (*dir < (MAX * MAX)) { return true; }
    else return false;
}

int left(int i, int *dir) {
    *dir = i - 1;
    if ((i % MAX != 0)) { return true; }
    else return false;
}

int right(int i, int *dir) {
    *dir = i + 1;
    if ((i + 1) % MAX != 0) { return true; }
    else return false;
}

void disp(int depth) {
    int i;
    if (depth < 0) return;

    for (i = 0; i < (MAX * MAX); i++) {
        if ((i % MAX) == 0) printf("\n");
        printf("%d ", road[depth][i]);
    }
    printf("\n");
    disp(depth - 1);
}

void cp(int depth) {
    int i;
    for (i = 0; i < (MAX * MAX); i++) {
        road[depth][i] = puzzle[i];
    }
}

void dfs(int depth, int pos) {
    int dir;
    int h = check();
    cp(depth);
    count++;

    if (depth + h > limit || history(depth) == 0) {
        return;
    }
    if (h == 0) {
        if (shortest > depth) {
            shortest = depth;
            limit = depth;
        }
        //disp(depth);
        return;
    }

    if (up(pos, &dir)) {
        swap(&puzzle[pos], &puzzle[dir]);
        dfs(depth+1, dir);
        swap(&puzzle[pos], &puzzle[dir]);
    }
    if (down(pos, &dir)) {
        swap(&puzzle[pos], &puzzle[dir]);
        dfs(depth+1, dir);
        swap(&puzzle[pos], &puzzle[dir]);
    }
    if (right(pos, &dir)) {
        swap(&puzzle[pos], &puzzle[dir]);
        dfs(depth+1, dir);
        swap(&puzzle[pos], &puzzle[dir]);
    }
    if (left(pos, &dir)) {
        swap(&puzzle[pos], &puzzle[dir]);
        dfs(depth+1, dir);
        swap(&puzzle[pos], &puzzle[dir]);
    }
}

int  main() {
    int i, pos;

    for (i = 0; i < (MAX * MAX); i++) {
        scanf("%d", &puzzle[i]);
        if (puzzle[i] == 0) {
            pos = i;
        }
    }
    limit = (check() + 1) * 4;

    dfs(0, pos);

    if (shortest != INF) {
        printf("%d\n", shortest);
        //printf("count >> %d\n", count);
    } else {
        printf(">> not Solve limit-> %d, %d\n", limit, count);
        disp(limit);
    }

    return 0;
}


Measured memory_bytes: 2148
import sys
# input = sys.stdin.readline
inf = 10 ** 18

S = input()

aa = int(S[:2])
bb = int(S[2:])

flag = 0b00
if 1 <= aa <= 12:
    flag += 0b01
if 1 <= bb <= 12:
    flag += 0b10

if flag == 0b00:
    print('NA')
elif flag == 0b01:
    print('MMYY')
elif flag == 0b10:
    print('YYMM')
else:
    print('AMBIGUOUS')

Measured memory_bytes: 3064
tex=input()
n=int(input())
for i in range(n):
    order=list(input().split())
    a=int(order[1])
    b=int(order[2])
    if order[0]=="print":
        print(tex[a:b+1])
    elif order[0]=="reverse":
        if a==0:
            tex=tex[b::-1]+tex[b+1:]
        else:
            tex=tex[:a]+tex[b:a-1:-1]+tex[b+1:]  
    else:
        tex=tex[:a]+order[3]+tex[b+1:]


Measured memory_bytes: 5616
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cassert>

#include <unordered_set>
#include <unordered_map>
#include <random>
#include <thread>
#include <chrono>

using namespace std;

#define val const auto
#define var auto

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x) 
#endif

typedef complex<double> point;

template<typename T,std::size_t N>
struct _v_traits {using type = std::vector<typename _v_traits<T,N-1>::type>;};
template<typename T>
struct _v_traits<T,1> {using type = std::vector<T>;};
template<typename T,std::size_t N=1>
using vec = typename _v_traits<T,N>::type;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it){
        if(it != v.begin()){
            os << ",";
        }
        os << *it;
    }
    return os << "}";
}

template <typename T>
T read_next(){
    T ret; cin >> ret;
    return ret;
}


template<typename T>
void isort(std::vector<T>& v, std::function<bool(T,T)> comp=less<T>()){
    sort(v.begin(), v.end(), comp);
}
template<typename T>
std::vector<T> sort(std::vector<T> v, std::function<bool(T,T)> comp=less<T>()){
    isort(v);
    return v;
}
template<typename T1, typename T2>
std::vector<T2> rmap(const std::vector<T1>& v, std::function<T2(T1)> f){
    std::vector<T2> t; t.reserve(v.size());
    for(const auto& i: v) t.push_back(f(i));
    return t;
}
std::vector<std::string> split(std::string str, char delim){
    std::vector<std::string> res;
    size_t current = 0, found;
    while((found = str.find_first_of(delim, current)) != std::string::npos){
        res.push_back(std::string(str, current, found - current));
        current = found + 1;
    }
    res.push_back(std::string(str, current, str.size() - current));
    return res;
}
string join(const std::vector<string>& v, string delim){
    string ret = "";
    for(auto it = v.begin(); it != v.end(); ++it){
        if(it != v.begin()){
            ret += delim;
        }
        ret += *it;
    }
    return ret;
}


using i64 = int64_t;
using i32 = int32_t;

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

    i64 a, b, c, k;
    cin >> a >> b >> c >> k;
    i64 m = max(a, max(b, c));

    i64 p = m;
    for (int i = 0; i < k; i++) {
        p = p * 2;
    }
    cout << a + b + c - m + p << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
letter='ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
a=[0]*len(s)
for i in range(len(s)):
  
  u=letter.index(s[i])
  a[i]=letter[int(u)+n]
  
print(''.join(a))




Measured memory_bytes: 3060
#include <bits/stdc++.h>
    #define int long long
    #define endl '\n'
    #define modulo 1000000007
    using namespace std;
    int power(int x,int y,int m)
        {
        int temp;
        if(y == 0)
        return 1;
        temp = (power(x, y/2,m))%m;
        if (y%2 == 0)
        return ((temp%m)*temp);
        else
        return ((x*temp%m)*temp%m)%m;
        }
        int visited[100001];
        int grouped[100001];
        vector<vector<pair<int,int>>>lolz(100001);
        void DFS(int n,int total){
        if(visited[n])
        return;
        if(total%2==0)
        grouped[n]=1;
        visited[n]=1;
        for(int i=0;i<lolz[n].size();i++){
        DFS(lolz[n][i].first,total+lolz[n][i].second);
        }
        }
    int32_t main()
    {
    iostream::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    lolz[a-1].push_back({b-1,c});
    lolz[b-1].push_back({a-1,c});
    }
    DFS(0,0);
    for(int i=0;i<n;i++){
    cout<<grouped[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 10112
a,b,c,k = map(int,input().split())


def function(a,b,c,k):
    count =0
    if a>=k:
        return k
    else:
        count =a
        k =k-a
        a=0
        if b>=k:
            return count
        else:
            k-=b
            b=0
            count-=k

        return count
print(function(a,b,c,k))


Measured memory_bytes: 9072
inf = float('inf')

def accmulate(array):
    global cs
    cs = [0]*(len(array)+1)
    for i in range(len(array)):
        cs[i+1] = cs[i] + array[i]

def query(l,r):
    return cs[r+1] - cs[l]

N = int(input())
A = list(map(int,input().split()))

accmulate(A)

dp = [[inf]*(N+1) for _ in range(N+1)]

for i in range(N):
    dp[i][i+1] = 0

for i in range(N-1):
    dp[i][i+2] = A[i] + A[i+1]

for b in range(3,N+1):
    for i in range(N-b+1):
        j = i + b
        for k in range(i+1,j):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + query(i,j-1))

ans = dp[0][N]
print(ans)

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

N, H = map(int, input().split())
max_a = 0
b = [0] * N
for i in range(N):
    a, b[i] = map(int, input().split())
    max_a = max(max_a, a)
b.sort(reverse=True)

cnt = 0
for bi in b:
    if bi < max_a:
        break
    H -= bi
    cnt += 1
    if H <= 0:
        break

if H > 0:
    cnt += H // max_a
    if H % max_a != 0:
        cnt += 1
print(cnt)


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

int main(){
    int K, S;
    cin >> K >> S;
    int ans = 0;
    for (int X = 0; X <= K; X++) {
        for (int Y = 0; Y <= K; Y++) {
            int Z = S-X-Y;
            if (Z >= 0 && Z <= K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()
{
	int n;
	vector <int > v;
	
	cin >> n;
	int x;
	int c = 0;
	
	
	for (int i =0; i<n; i++)
	{
		cin >> x;
		v.push_back(x);
		
	}
	
	for (int i = 1; i<n-1; i++)
	{
		if ((v[i-1] < v[i] && v[i+1] > v[i]) || (v[i+1] < v[i] && v[i-1] > v[i])){
			c++;
		}
	}
	
	
	cout << c <<endl;

	
	
	
	
	
	
	return 0;
}



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

int main() {
  int N, Ai, Counter=30 ;
 cin >>N;
   for (int i = 0; i<N ; i++) {
   cin >>Ai;
     for (int j = 0; j<30 ; j++) {
     if (Ai % 2 == 1 && j < Counter) {Counter = j; break; }
     Ai /= 2;}
   }
   cout << Counter <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
using namespace std;
#define REP(i,n); for(int i = 0;i < (int)(n);i++)

int main() {
	int h, n, input, sum=0;
	//vector<int> a;
	
	cin >> h >> n;
	
	REP(i,n){
		cin >> input;
		//a.push_back(input);
		sum += input;
		
	}
	//sort(a.begin(), a.end(), greater<int>());
	if(sum >= h) cout<<"Yes";
	else cout << "No";
	
	return(0);
}

Measured memory_bytes: 256
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
vi vertices[sze];
vi visit(sze, 0);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int A, B;
int cnt = 0;

int down[sze], up[sze];

int dfs1(int v, int par = -1)
{
	down[v] = 1;
	for (auto to : vertices[v])
	{
		if (to == par)continue;
		down[v] = down[v] * (dfs1(to, v) + 1) % m;
	}
	return down[v];
}

void dfs2(int v, int calc = 0, int par = -1)
{
	up[v] = 1;
	if (par != -1)
	{
		up[v] = (calc + up[v]) % m;
	}

	int k = SZ(vertices[v]);
	if (k)
	{
		vi pref(k), suf(k);

		pref[0] = vertices[v][0] == par ? 1 : (down[vertices[v][0]] + 1) % m;
		for (int i = 1; i < k; i++)
		{
			if (vertices[v][i] == par)
			{
				pref[i] = pref[i - 1];
			}
			else
			{
				pref[i] = pref[i - 1] * (down[vertices[v][i]] + 1) % m;
			}
		}

		suf[k - 1] = vertices[v][k - 1] == par ? 1 : (down[vertices[v][k - 1]] + 1) % m;
		for (int i = k - 2; i >= 0; i--)
		{
			if (vertices[v][i] == par)
			{
				suf[i] = suf[i + 1];
			}
			else
			{
				suf[i] = suf[i + 1] * (down[vertices[v][i]] + 1) % m;
			}
		}

		for (int i = 0; i < k; i++)
		{
			if (vertices[v][i] == par) continue;

			int calc = up[v];
			if (i - 1 >= 0)
			{
				calc = calc * pref[i - 1] % m;
			}
			if (i + 1 < k)
			{
				calc = calc * suf[i + 1] % m;
			}

			dfs2(vertices[v][i], calc, v);
		}
	}
}

signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("stars.in", "r", stdin);
	freopen("stars.out", "w", stdout);*/

	cin >> n >> m;
	for (int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		vertices[u].pb(v);
		vertices[v].pb(u);
	}

	dfs1(1);
	dfs2(1);

	for (int i = 1; i <= n; i++)
	{
		cout << down[i] * up[i] % m << endl;
	}
	
	return 0;
}

Measured memory_bytes: 33280
import numpy as np

N = int(input())
A = list(map(int, input().split()))

counter = np.bincount(A)

total = (counter * (counter - 1)).sum() // 2
diff = (counter * (counter-1)//2 - (counter-1) * (counter-2)//2)
ans = total - diff[A]

print(*ans, sep="\n")

Measured memory_bytes: 36140
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 
void solve()
{
    int sum=0;
    int m,d;cin>>m>>d;
    REP(i,m)REP(j,d)
    {
        int j1=(j+1)/10;int j2=(j+1)%10;
        if(j1*j2==i+1&&j1!=1&&j2!=1)sum++;
    }
    cout<<sum<<endl;
}

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	bool f[100][100];
	for (int i = 0; i < 100; i++)for (int j = 0; j < 100; j++)f[i][j] = false;
	int n, u, k, v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			f[u - 1][v - 1] = true;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j)cout << " ";
			cout << f[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

int main(void) {
    int a, b;
    cin >> a >> b;
    int n;
    if (a < 6) {
        n = 0;
    } else if (a < 13) {
        n = b / 2;
    } else {
        n = b;
    }
    cout << n << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  string str;cin>>str;
  int ans = 0;
  int best = 0;
  for(int i=0;i<str.size();i++){
    if(str[i] == 'S')
      best = 0;
    else
      best++;
    max_self(ans,best);
  }
  cout<<ans<<endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    vector<bool> dir(4); string d = "NSWE";
    rep (i, s.size()) rep (j, 4) if (d[j] == s[i]) dir[j] = true;
    // eprintf("%d %d %d %d\n",dir[0]*1,d[1]*1,d[2]*1,d[3]*1);
    if (!(dir[0] ^ dir[1]) && !(dir[2] ^ dir[3])) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::string s;std::cin>>s;
    std::string t=std::string(s.rbegin(),s.rend());
    lint n=(s.length()-1)/2;
    std::cout<<(s==t&&s.substr(0,n)==t.substr(n+1,n)?"Yes":"No")<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll; 
const int N = 2e5+5;

ll a[N];

int main()
{	
	int n;
	ll res = 0;
	scanf("%d",&n);
	for(int i = 1;i <= n;++i) scanf("%lld",&a[i]),res ^= a[i];
	for(int i = 1;i <= n;++i) printf("%lld%c",res^a[i],i == n ?'\n' :' ');
	return 0;
} 

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


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int               long long
#define endl              '\n'
#define ff                first
#define ss                second
#define mp                make_pair
#define pb                push_back
#define vii               vector<int> 
#define mii                          map< int, int >
#define msi                          map< string, int > 
#define mib                          map< int, bool > 
#define pii               pair<int,int>
#define vpii              vector< pii >
#define all(v)            v.begin(),v.end()
#define loop(i,s,e)       for(int i=s;i<e;i++)
#define rloop(i,e,s)      for(int i=e;i>=s;i--)
#define mset(a,f)              memset(a,f,sizeof(a))
#define M                 1000000007
#define ld long double
#define fastio            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define prvec(v)          loop(i_u_j,0,v.size())cout << v[i_u_j] <<" "; cout << endl;
#define prarr(arr,n)      loop(i_u_j,0,n)cout << arr[i_u_j] << " "; cout << endl;
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)


template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //
const int N = 3e5 + 7;
int n;
ld arr[3000];


void solve()
{
      cin >> n;
      loop(i,1,n+1) cin >> arr[i];
      ld dp[n+1][n+1];

      ld head[n+1], tail[n+1];
      head[0] = 1;
      tail[0] = 1;

      loop(i,1,n+1) head[i] = arr[i]*head[i-1];
      loop(i,1,n+1) tail[i] = (1.0 - arr[i])*tail[i-1];
      dp[0][0] = 1;

      loop(i,0,n+1) dp[i][0] = tail[i];
      loop(i,0,n+1) dp[i][i] = head[i];

      loop(i,1,n+1)
      {
            loop(j,1,n+1)
            {
                  if( j < i ) dp[i][j] = dp[i-1][j]*(1.0-arr[i]) + dp[i-1][j-1]*(arr[i]);
            }
      }

      double ans = 0;
      loop(i,n/2+1,n+1) ans += dp[n][i];
      

      cout << setprecision(10) << ans ;

}

int32_t main() {
    fastio;

  int t = 1; 
  //cin>>t;
  
  while(t--) solve();
  
  


}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //















Measured memory_bytes: 141056
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vvi a(h, vi(w));
    rep(i, h) rep(j, w) {
        cin >> a[i][j];
    }
    rep(i, h) rep(j, w) {
        int b;
        cin >> b;
        a[i][j] -= b;
    }

    vector<vector<vector<bool> > > check(h, vector<vector<bool> >(w, vector<bool>(160*(h+w)+1)));
    check[0][0][80*(h+w)] = true;
    rep(i, h) rep(j, w) {
        rep(k, 160*(h+w)+1) if(check[i][j][k]) {
            if(i != h-1) {
                check[i+1][j][k+a[i][j]] = true;
                check[i+1][j][k-a[i][j]] = true;
            }
            if(j != w-1) {
                check[i][j+1][k+a[i][j]] = true;
                check[i][j+1][k-a[i][j]] = true;
            }
        }
    }


    int ans = 0;
    while(true) {
        if(-a[h-1][w-1]+80*(h+w)+ans <= 160*(h+w) and check[h-1][w-1][-a[h-1][w-1]+80*(h+w)+ans]) break;
        if(-a[h-1][w-1]+80*(h+w)-ans >= 0 and check[h-1][w-1][-a[h-1][w-1]+80*(h+w)-ans]) break;
        if(a[h-1][w-1]+80*(h+w)+ans <= 160*(h+w) and check[h-1][w-1][a[h-1][w-1]+80*(h+w)+ans]) break;
        if(a[h-1][w-1]+80*(h+w)-ans >= 0 and check[h-1][w-1][a[h-1][w-1]+80*(h+w)-ans]) break;
        ans++;
    }

    cout << ans << endl;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  if (a + b >= k) {
    cout << min(a, k) << endl;
  } else {
    k -= a + b;
    cout << a - k << endl;
  }

  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length = 2*(a+b);
        System.out.println(area +" "+ length);
        sc.close();
    }
}


Measured memory_bytes: 26140
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    int n = int.Parse(Console.ReadLine());
    int[] a = new int[n];
    for(int i=0; i<n; i++){
      a[i] = int.Parse(Console.ReadLine());
    }
    int cnt = 0;
    var b = Enumerable.Repeat(false,n).ToArray();
    
    var prg = new Program();
    int ans = prg.button(a,b,cnt,0);
    Console.WriteLine(ans);
  }
  
  public int button(int[] a,bool[] b,int cnt,int index){
    
    if(b[index] == true) return -1;
    if(index == 1) return cnt;
    
    b[index] = true;
    cnt++;
    return button(a,b,cnt,a[index]-1);
  }
}

Measured memory_bytes: 18400
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

int main(){
	int N;
	cin >> N;
	vector<ll> S(N);
	for(int i=0; i<N; i++) cin >> S[i];

	ll ans = 0;
	for(int d=1; d<=(N-1)/2; d++){
		ll sum = 0;
		set<int> used;
		for(int k=1; d*(k+1)<N-1; k++){
			if(d*k==N-1-d*k||used.count(d*k)>0||used.count(N-1-d*k)>0) break;
			sum += S[d*k] + S[N-1-d*k];
			used.insert(d*k);
			used.insert(N-1-d*k);
			ans = max(ans, sum);
			debug(any{d, k, d*k, N-1-d*k, sum});
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 7808
Scanf.scanf "%d %d %d" (fun rr cc k ->
    let mat = Array.make_matrix rr cc 0 in
    for i = 1 to k do
        Scanf.scanf " %d %d %d" (fun rr cc v ->
            mat.(rr - 1).(cc - 1) <- v
        )
    done;

    let prev = Array.make cc 0 in
    for y = 0 to rr - 1 do
        let m = mat.(y) in
        let rec loop x work0 work1 work2 work3 =
            if x < cc then (
                let work0 = max work0 prev.(x) in
                let v = m.(x) in
                let work3 = max work3 (work2 + v) in
                let work2 = max work2 (work1 + v) in
                let work1 = max work1 (work0 + v) in
                prev.(x) <- max (max work3 work2) (max work1 work0);
                loop (x + 1) work0 work1 work2 work3
            )
        in
        loop 0 0 0 0 0
    done;
    Printf.printf "%d\n" (prev.(cc - 1))
)

Measured memory_bytes: 77096
s = input()
ls = list(s)
ls1 = ls[:int((len(ls)-1)/2)]
ls2 = ls[int((len(ls)+3)/2) - 1:]
def kt(l):
    lr = list(reversed(l))
    if l == lr:
        return 1
    else:
        return 0
a = kt(ls)
b = kt(ls1)
c = kt(ls2)


d = a + b + c

if d >= 3:
    print('Yes')
else:
    print('No')


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

#define MAX 100000
typedef long long ll;

int n, k;
ll T[MAX];

int check(ll P){
    int i = 0;
    for(int j = 0; j < k; j++){
        ll s = 0;
        while(s + T[i] <= P){
            s += T[i];
            i++;
            if(i == n) return n;
        }
    }
    return i;
}

int solve(){
    ll left = 0;
    ll right = 100000 * 10000;
    ll mid;
    while(right - left > 1){
        mid = (right + left) / 2;
        int v = check(mid);
        if(v >= n) right = mid;
        else left = mid;
    }
    return right;
}

int main(){
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> T[i];
    ll ans = solve();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3884
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <cmath>
#include <limits.h>
#include <ios>
#include <iomanip>
#include <map> // pair
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b){return b? gcd(b, a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<pair<ll, ll> > pairs(N);
  for(int i = 0; i < N; i++){
    ll a, b;
    cin >> a >> b;
    pairs[i] = make_pair(a, b);
  }
  sort(pairs.begin(), pairs.end());
  ll total = 0;
  for(int i =0; i < N; i++){
    if(pairs[i].second >= M){
      total += M*pairs[i].first;
      M = 0;
      break;
    }else{
      total += pairs[i].second * pairs[i].first;
      M -= pairs[i].second;
    }
  }
  cout << total << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    int N=in();
    // string S=in<string>()
    int M=in();
    int d=0;
    REP(i,M){
        int D;
        cin>>D;
        d+=D;
    }
    if(d>N){
        cout<<-1<<endl;
    }else{
        cout<<N-d<<endl;
    }
    return 0;

}


Measured memory_bytes: 3660
function bigAdd(x,y){
   var a=(x+"").split("").reverse().map(Number);
   var b=(y+"").split("").reverse().map(Number);
   var c=[];
   var max=Math.max(a.length,b.length);
   for(var i=0;i<max+1;i++)c[i]=0;
   for(var i=0;i<max;i++){
      var sum=0;
      if(a.length>i)sum+=a[i];
      if(b.length>i)sum+=b[i];
      c[i]+=sum;
   }
   for(var i=0;i<max;i++){
      if(c[i]>=10){
         c[i]-=10;
         c[i+1]++;
      }
   }
   if(c[c.length-1]==0)c.pop();
   var str=c.reverse().join("");
   return str;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
arr.shift();
var a=arr.shift().split(" ").map(Number);
a.sort(function(a,b){return a-b;});
arr.shift();
var b=arr.shift().split(" ").map(Number);
var c=arr.shift().split(" ");
var ary=[];
for(var i=0;i<=1000000;i++)ary[i]=false;
ary[0]=0;
var sum=0;
a.forEach(function(v){
   sum=bigAdd(sum,v);
   ary[v]=sum;
});
b.forEach(function(v,i){
   while(true){
      if(ary[v]!==false)break;
      v--;
   }
   var ans="No";
   if(c[i]==ary[v]){ans="Yes";}  
   else if(c[i].length<ary[v].length){ans="Yes";}
   else if(c[i].length==ary[v].length){
      for(var j=0;j<c[i].length;j++){
         if(c[i][j]-0===ary[v][j]-0){continue;}
         else if(c[i][j]-0>ary[v][j]-0){ans="No";break;}
         else if(c[i][j]-0<ary[v][j]-0){ans="Yes";break;}
      }
   }
   console.log(ans);
});

Measured memory_bytes: 112504
#include<cstdio>
using namespace std;
int main(){
    int n,k;
    char s[11];
    scanf("%d",&n);
    scanf("%s",s);
    scanf("%d",&k);
    for(int i=0;i<n;i++){
        if(s[i]!=s[k-1]){
            s[i]='*';
        }
    }
    printf("%s\n",s);
}

Measured memory_bytes: 128
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    vector<int> dp(K+1, 0);
    dp[0] = -1;
    for (int i = 1; i <= K; i++) {
        bool win = false;
        for (int j = 0; j < N; j++) {
            if (i - A[j] < 0) continue;
            if (dp[i - A[j]] == -1) {
                win = true;
                break;
            }
        }

        if (win) dp[i] = 1;
        else dp[i] = -1;
    }

    cout << (dp[K] == 1 ? "First" : "Second") << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const double EPS = 1e-3;
const double PI = 3.1415926535897932384626433832795028841971;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
vector<int> visitlog;
bool hasloop = false;
int lastpos;

void dfs(vector<vector<int>> &g, int cur, vector<bool> &started,
         vector<bool> &finished) {
  started[cur] = true;
  visitlog.push_back(cur);

  for (auto &&next : g[cur]) {
    if (finished[next]) continue;
    if (started[next] && !finished[next]) {
      lastpos = next;
      hasloop = true;
      return;
    }
    dfs(g, next, started, finished);
    if (hasloop) return;
  }
  visitlog.pop_back();
  finished[cur] = true;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
  }
  rep(i, n) {
    vector<bool> started(n, false);
    vector<bool> finished(n, false);
    dfs(g, i, started, finished);
    if (hasloop) break;
    assert(visitlog.empty());
  }
  if (hasloop == false) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> loop;
  reverse(ALL(visitlog));

  rep(i, visitlog.size()) {
    loop.push_back(visitlog[i]);
    if (visitlog[i] == lastpos) {
      break;
    }
  }
  reverse(ALL(loop));

  while (true) {
    int startpos = -1, endpos = -1;
    vector<int> order(n, -1);
    rep(i, loop.size()) order[loop[i]] = i;
    rep(i, loop.size()) {
      for (auto &&next : g[loop[i]]) {
        if (order[next] != -1 && next != loop[(i + 1) % loop.size()]) {
          startpos = i;
          endpos = order[next];
        }
      }
    }

    if (startpos == -1) break;
    vector<int> nloop;
    nloop.push_back(loop[startpos]);
    while (startpos != endpos) {
      nloop.push_back(loop[endpos]);
      endpos = (endpos + 1) % loop.size();
    }
    loop = nloop;
  }
  cout << loop.size() << endl;
  for (auto &&x : loop) {
    cout << x + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3780
///PROBLEM CODE - SEGDIR (CodeChef)
///SOLUTION FOR 3rd problem of ICPC Online round 2k19!!

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define pb push_back


///Input/Output macros!
#define gi(x) scanf("%d", &x)
#define gi2(x, y) scanf("%d%d", &x, &y)
#define gi3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define gill(x) scanf("%lld", &x)
#define gill2(x, y) scanf("%lld%lld", &x, &y)
#define gill3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define pi(x) printf("%d\n", x)
#define pill(x) printf("%lld\n", x)


///Basic Debugging macros!
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(ll __i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(ll __i__=0;__i__<r;__i__++){for(ll __j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}

using namespace std;

///Power of 2 till 2^31!
ll pow2[32] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648};

///Power function!
ll power(ll x,ll y)
{
        ll res = 1;
        while(y>0){
            if(y&1)
                res *= x;
            y>>=1;
            x*=x;
        }
        return res;
}

///Basic Sieve of Eratosthenes!
void Sieve(ll n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (ll p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}

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

bool isPerfectSquare(ll x){ ll s = sqrt(x); return (s*s == x);}

bool isFibonacci(int n){return isPerfectSquare(5*n*n + 4) || isPerfectSquare(5*n*n - 4);}

bool isPrime(int n){if (n <= 1)return false;if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0)return false;
    return true;
}

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;


const int MOD = 1000000007;
const long double PI = 4*atan((long double)1);
const ll INF = 1e18;

int main()
{
    int a,b;
    cin>>a>>b;
    cout<<max(0,a-(2*b))<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
  int n,a,b;cin>>n>>a>>b;
  printf("%d %d\n",min(a,b),max(0,a+b-n));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  if(N%2==1)cout<<"No"<<endl;
  else{
    string S;cin>>S;
    int i;
    for(i=0;i<N/2;i++){
      if(S.at(i)!=S.at(i+N/2))break;
    }
    if(i==N/2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
vector<ll> A;

int main(){
  cin>>N;
  A.resize(N);
  rep(i,N) cin>>A[i];

  vector<pair<ll,int>> v;
  for(int i=0;i<N;i++) v.push_back(mkp(A[i],i));
  v.push_back(mkp(0,MOD));
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());

  vector<ll> ans(N,0);
  int mi=v[0].second;
  ll pre=v[0].first;
  for(int i=1;i<v.size();i++){
      if(v[i].first!=pre){
          ans[mi]+=i*(pre-v[i].first);
          pre=v[i].first;
      }
      mi=min(mi,v[i].second);
  }

  for(int i=0;i<N;i++) cout<<ans[i]<<endl;

  return 0;
}


Measured memory_bytes: 4208
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define	abs(a) ((a)<0?-(a):(a))



int main(void){
	/* === input paramater === */
	int n;
	int *a;

	/* === operate paramater === */
	int i;
	int ans;

	/* === input === */
	scanf("%d",&n);
	a = calloc(sizeof(int),n+1);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	/* === operate === */
	ans = 0;
	for(i=1;i<=n;i++){
		if(a[a[i]] == i) ans++;
	}
	/* === output === */
	printf("%d\n", ans/2);


	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long a,b,c;
		cin>>a>>b>>c;
	long long dp[n][3];
	dp[0][0]=a;
	dp[0][1]=b;
	dp[0][2]=c;
	for(long long i=1;i<n;i++){
		cin>>a>>b>>c;
		dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
		//cout<<dp[i-1][0]<<" "<<dp[i-1][1]<<" "<<dp[i-1][2]<<endl;
		dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
		//cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
	}
	long long temp1=max(dp[n-1][0],dp[n-1][1]);
	long long temp2=max(dp[n-1][1],dp[n-1][2]);
//	cout<<temp1<<" "<<temp2<<endl;
	cout<<max(temp1,temp2)<<endl;
	return 0;
	
}

Measured memory_bytes: 2688