akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <utility>
#include <vector>
#include <queue>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	vector<queue<int>> v(in());
	for (int q = in(); q; q--) {
		int o = in();
		auto &t = v[in()];
		switch(o) {
		case 0:
			t.push(in());
			break;
		case 1:
			if (!t.empty())
				outl(t.front());
			break;
		default:
			if (!t.empty())
				t.pop();
		}
	}
}


Measured memory_bytes: 3752
//A-One_Card_Poker
#include <bits/stdc++.h>
using namespace std;

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

  if(a!=1&&b!=1){
    if(a>b) cout<<"Alice"<<endl;
    else if(a<b) cout<<"Bob"<<endl;
    else cout<<"Draw"<<endl;
  }
  else{
    if(a==b) cout<<"Draw"<<endl;
    else if(a==1) cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;

  }
  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	double x1, y1, x2, y2, xq, yq, xr, yr;

	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq) != EOF){

		xr = (pow(x1-x2,2)*xq + 2*(x1-x2)*(y1-y2)*(yq-y1) + pow(y1-y2,2)*(2*x1-xq)) / (pow(x1-x2,2) + pow(y1-y2,2));
		yr = (pow(x1-x2,2)*(2*y1-yq) + 2*(x1-x2)*(y1-y2)*(xq-x1) + pow(y1-y2,2)*yq) / (pow(x1-x2,2) + pow(y1-y2,2));

		printf("%f %f\n", xr, yr);

	}
	return 0;
}

Measured memory_bytes: 652
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var strs = str.Split(' ');
            var n = int.Parse(strs[0]);
            var limitT = int.Parse(strs[1]);

            int minCost = int.MaxValue;
            for (int i = 0; i < n; i++)
            {
                str = Console.ReadLine();
                strs = str.Split(' ');

                var c = int.Parse(strs[0]);
                var t = int.Parse(strs[1]);

                if (t > limitT)
                {
                    continue;
                }

                if (c < minCost)
                {
                    minCost = c;
                }
            }

            Console.WriteLine(minCost == int.MaxValue ? "TLE" : minCost.ToString());
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;

    int temp;
    list<int> a;
    for(int i=0; i<n; i++){
        cin >> temp;
        if(i%2 == 0){
            a.push_back(temp);
        }
        else{
            a.push_front(temp);
        }
    }

    if(n%2 == 1){
        a.reverse();
    }

    for(auto x : a){
        cout << x << " ";
    }



    return 0;
}

Measured memory_bytes: 8448
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
  int i, N;
  double x, T=0;
  char s[10];
  scanf("%d", &N);
  for (i=0;i<N;i++){
    scanf("%lf %s", &x, s);
    if (strcmp(s, "BTC") == 0){
      T += 380000 * x;
    } else {
      T += x;
    }
  }
  printf("%lf\n", T);
  return 0;
}




Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int a, b, c;

	cin >> a >> b >> c;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

int main(void)
{
    string s;
    cin >> s;
    string ans = "keyence";
    int p = 0;
    int skip = 0;

    rep(i, s.length())
    {
        rep(j, s.length() - i + 1)
        {
            string ss = s.substr(0, i) + s.substr(i+j, s.length()-i-j);
            //cout << ss << endl;

            if(ss == ans)
            {
                cout << "YES" << endl;
                return 0;        
            }
        }        
    }
    cout << "NO" << endl;

    return 0;
}


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

const int maxn=200010;
int n;
int a[maxn], dp[maxn];

void chkmax(int& x,int y){ if(x<y) x=y; }

int main(){

	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]);
	int ans=0;
	for(int i=1;i<=n;i++){
		dp[ a[i] ]=dp[ a[i]-1 ]+1;
		chkmax(ans, dp[ a[i] ]);
	}
	printf("%d\n", n-ans);
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		Map<Long , Long> tm = new TreeMap<Long , Long>();
		int n = Integer.parseInt(sc.next());
		long m = Long.parseLong(sc.next());
		long a = 0;
		long b = 0;
		for(int i = 0 ; i < n ; i++){
			a = Long.parseLong(sc.next());
			b = Long.parseLong(sc.next());
			if(tm.containsKey(a)){
				tm.put(a , b + tm.get(a));
			}else{
				tm.put(a , b);
			}
		}
		sc.close();
		long yono = 0;
		for(long i : tm.keySet()){
			yono += i * tm.get(i);
			m -= tm.get(i);
			if(m <= 0){
				yono += i * (long)m;
				break;
			}
		}
		ou.print(yono + "\n");
		ou.flush();
    }
}

Measured memory_bytes: 68660
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int W[N];
    for(int i=0;i<N;i++){
        cin>>W[i];
    }
    int sum1=0;
    int sum2=0;
    int min=100000;
    for(int t=0;t<100;t++){
        for(int i=0;i<N;i++){
            if(i>t){
                sum1+=W[i];
            }
            else{
                sum2+=W[i];
            }
        }
        if(min>abs(sum1-sum2)){
            min=abs(sum1-sum2);
        }
        sum1=0;
        sum2=0;
    }
    cout<<min<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

struct teaminfo {
  int id;
  int ac;
  int time;
  int wan[ 11 ];
  bool operator<( const teaminfo &t ) const;
  bool operator==( const teaminfo &t ) const;
};

bool teaminfo::operator<( const teaminfo &t ) const {
  if( this->ac == t.ac ) {
    if( this->time == t.time ) {
      return this->id < t.id;
    }
    return this->time > t.time;
  }
  return this->ac < t.ac;
}

bool teaminfo::operator==( const teaminfo &t ) const {
  return this->time == t.time && this->ac == t.ac;
}


int main() {
  while( 1 ) {
    int m, t, p, r;
    teaminfo ti[ 51 ];
    cin >> m >> t >> p >> r;
    if( !m && !t && !p && !r ) { break; }
    for( int i = 1; i <= t; i++ ) {
      ti[ i ].id = i;
      ti[ i ].ac = 0;
      ti[ i ].time = 0;
      for( int j = 1; j <= p; j++ ) {
        ti[ i ].wan[ j ] = 0;
      }
    }
    for( int i = 0; i < r; i++ ) {
      int mk, tk, pk, jk;
      cin >> mk >> tk >> pk >> jk;
      if( jk == 0 ) { // ac
        ti[ tk ].ac++;
        ti[ tk ].time += ( mk + ti[ tk ].wan[ pk ] * 20 );
      } else { // wa
        ti[ tk ].wan[ pk ]++;
      }

    }
    sort( ti + 1, ti + t + 1 );
    for( int i = t; i > 0; i-- ) {
      cout << ti[ i ].id << flush;
      if( i != 1 ) {
        if( ti[ i - 1 ] == ti[ i ] ) {
          cout << "=" << flush;
        } else {
          cout << "," << flush;
        }
      }
    }
    cout << endl;
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1184
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

// ===============================================================

int main() {
	ll n, k; cin >> n >> k;
	vl a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll ans = 1000000000000000;
	for (int i = 0; i < n - k + 1; i++) {
		ans = min(ans, a[i + k - 1] - a[i]);
	}
	cout << ans << endl;
}

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n,a[101];
string s[101],sam;

void nhap()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
    {
        cin>>s[i]>>a[i];
    }
    cin>>sam;
}

void process()
{
    int kq=0;
    bool f=0;
    for (int i=1;i<=n;++i)
    {
        if (f) kq+=a[i];
        if (sam==s[i])
            f=1;
    }
    cout<<kq;
}

int main()
{
    nhap();
    process();
    return 0;
}


Measured memory_bytes: 256
from itertools import groupby
n, k = map(int, input().split())
S = input().strip()
L = [len(list(g)) for v, g in groupby(S)]
if S[0] == '0':
    L = [0] + L
if S[-1] == '0':
    L = L + [0]

A = [sum(L[:2*k+1])]
for i in range(0, len(L)-2*k-1, 2):
    A += A[-1]-L[i]-L[i+1]+L[i+2*k+1]+L[i+2*k+2],
print(max(A))

Measured memory_bytes: 5524
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.FormatFlagsConversionMismatchException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
import java.util.StringTokenizer;

import javax.naming.spi.DirStateFactory.Result;
import javax.swing.text.AbstractDocument.BranchElement;

import org.w3c.dom.css.Counter;
 
public class Main {

	
	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int first = fs.nextInt();
		int sec = fs.nextInt();
		int third = fs.nextInt();

		if(first%sec==0) {
			System.out.println((first/sec)*third);
		}
		else {
			System.out.println(((first/sec)+1)*third);
		}
	}
	
 
	static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
 
	
}

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

int main() {
    int A, B; cin >> A >> B;
    for (int i = 0; i< 100000; i++)
    {
        int x = i*0.08;
        int y = i*0.1;
        if(x==A && y==B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

}

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

int main(){
  int N , l , r;
  cin >> N;
  int sum = 0;
  
  for(int i = 0; i < N; i ++){
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
 
using namespace std;

double solve(double n){

	double cont=0;

	for(int i=1;i<=n;i++){
			cont+=i;
	}

	return 1.0*cont/n;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	
	vector<double>v;
	v.push_back(0);

	int n,m;
	double aux,resp=0*1.0;

	cin >> n >> m;

	for(int i=0;i<n;i++){
		cin >> aux;
		v.push_back(v[i] + solve(aux));
	}

	for(int i=m;i<=n;i++){
			resp = max(resp, v[i]-v[i-m]);
	}

		cout << setprecision(9) << resp << "\n";
	return 0;
}

Measured memory_bytes: 2420
h, w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(h)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for i in range(h):
    for j in range(w):
        if A[i][j] != -1 and A[i][j] != 1:
            ans += c[A[i][j]][1]

print(ans)


Measured memory_bytes: 3444
import sys, math

def GCD(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b

def solve():
    A, B = map(int, input().split())
    is_prime = dict()
    is_prime[1] = True
    primes = {1}
    gcd = GCD(A, B)
    lim = int(math.sqrt(gcd))
    count = 1
    for i in range(2, lim + 1):
        if i not in is_prime:
            primes |= {i}
            is_prime[i] = True
            k = i * 2
            while k <= lim:
                is_prime[k] = False
                k += i

            if gcd % i == 0:
                count += 1
                while gcd % i == 0:
                    gcd //= i
    
    if gcd > 1: count += 1
    print(count)

            
        
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 115704
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
 
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
 
        int cnt = 0;
        boolean next = true;
        while (next) {
            for (int i = 0; i < N; i++) {
                if (a[i] % 2 != 0) {
                    next = false;
                    break;
                } else {
                    a[i] = a[i] / 2;
                }
            }
            if (next) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23892
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
class Solution {
public:
	Solution() {
		rank = vector <int>(MAX_N);
		rank[0] = 1;
		for (int i = 1; i < MAX_N; i++) rank[i] = 1LL * rank[i - 1] * i % MOD;
	}

	int solve() {
		scanf("%d %d", &N, &K);
		G = vector <vector <int>>(N + 1, vector <int>());
		for (int i = 0; i < N - 1; i++) {
			int a, b;
			scanf("%d %d", &a, &b);
			G[a].push_back(b);
			G[b].push_back(a);
		}
		child_counts = vector <int>(N + 1, 0);
		DFS(1, 1);
		int res = 1LL * K * P(K - 1, child_counts[1]) % MOD;
		for (int v = 2; v <= N; v++) res = 1LL * res * P(K - 2, child_counts[v]) % MOD;
		return res;
	}
protected:
	void DFS(int u, int father) {
		for (int v : G[u]) if (v != father) {
			child_counts[u]++;
			DFS(v, u);
		}
	}

	int fast_pow(int a, int n) {
		int res = 1;
		while (n > 0) {
			if (n & 1) res = 1LL * res *  a % MOD;
			a = 1LL * a * a % MOD;
			n >>= 1;
		}
		return res;
	}

	int P(int n, int m) {
		if (m > n) return 0;
		return 1LL * rank[n] * fast_pow(rank[n - m], MOD - 2) % MOD;
	}
private:
	int N, K;
	vector <vector <int>> G;
	vector <int> child_counts;
	vector <int> rank;
};
/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	// WF("output.txt");
	DF("err.txt");

	printf("%d\n", Solution().solve());
	return 0;
}

Measured memory_bytes: 8832
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 998244353;

int main(){
    ll a; ll b; ll c; ll d; 
    cin >> a >> b >> c >> d;
    vvll dp(3001, vll(3001, 0));
    dp[a][b] = 1;
    rep(i, a, c+1){
        rep(j, b, d+1){
            if(i == a&&j == b){
                continue;
            }
            if(i > a&&j > b){
                dp[i][j] = j*dp[i-1][j] + i*dp[i][j-1];
                ll g = dp[i-1][j-1];
                g *= (i-1); g %= M;
                g *= (j-1); g %= M;
                dp[i][j] -= g;
            }else if(i == a){
                dp[i][j] = i*dp[i][j-1];
            }else{
                dp[i][j] = j*dp[i-1][j];
            }
            dp[i][j] %= M;
        }
    }
    rep(i, 0, c+1){
        rep(j, 0, d+1){
            //prt(dp[i][j]); prt(" ");
        }
        //prt(endl);
    }
    prt(dp[c][d]);
}




Measured memory_bytes: 73676
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
		int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
		int l;


	cin >> l;
	cout << a[--l] << endl;


	
	return 0;
}



Measured memory_bytes: 764
n,m=map(int,input().split())
stu=[list(map(int, input().split())) for _ in range(n)]
che=[list(map(int, input().split())) for _ in range(m)]
for i in range(n):
    a=stu[i][0]
    b=stu[i][1]
    minche=50
    minlen=10**10
    for j in range(m):
        x=che[j][0]
        y=che[j][1]
        kyori=abs(a-x)+abs(b-y)
        if kyori<minlen:
            minlen=kyori
            minche=j+1
    print(minche)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,j,n) for (int i = j; n<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  int N,M,n_ac=0,n_wa=0;cin>>N>>M;
  int a;string b;
  vector<int> v_wa(N+1);
  vector<bool> v_ac(N+1);
  REP(i,0,N){
    v_wa[i]=0;
    v_ac[i]=false;
  }
  while(M--){
    cin>>a>>b;
    if(v_ac[a-1])continue;
    if(b=="AC"){
      n_ac++;
      v_ac[a-1]=true;
      n_wa+=v_wa[a-1];

    }
    else if(b=="WA") v_wa[a-1]++;
  }
  cout<< n_ac  << " ";
  cout<< n_wa << "\n";
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t H, W;
    cin >> H >> W;

    auto mat = make_v(' ', H + 1, W + 1);
    for (size_t i = 1; i <= H; ++i) {
        for (size_t j = 1; j <= W; ++j) {
            cin >> mat[i][j];
        }
    }

    const int MOD = int(1e9) + 7;
    auto dp = make_v(0LL, H + 1, W + 1);
    dp[1][1] = 1;
    for (size_t i = 1; i <= H; ++i) {
        for (size_t j = 1; j <= W; ++j) {
            if (mat[i][j] == '.') {
                (dp[i][j] += dp[i - 1][j]) %= MOD;
                (dp[i][j] += dp[i][j - 1]) %= MOD;
            }
        }
    }

    cout << dp[H][W] << "\n";

    return 0;
}


Measured memory_bytes: 9216
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int s[5];
int len;
char st[100005];
bool check(int x,int y)
{
	int g[5];
	g[1]=s[1];g[2]=s[2];g[3]=s[3];
    if (g[x]<=0||g[y]<=0) return 0;
    g[x]--,g[y]--;
    for (int i=2;i<len;i++)
    {
    	int z=6-x-y;
    	if (g[z]<=0) return 0;
    	g[z]--;
		x=y; y=z; 
	}
	return 1;
}
int main()
{
	scanf("%s",st);
	len=strlen(st);
	for (int i=0;i<len;i++) s[st[i]-96]++;
	if (len<2||check(1,2)||check(1,3)||check(2,3)||check(2,1)||check(3,1)||check(3,2)) printf("YES"); 
	else printf("NO");
	return 0;
}

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

int main() {
    int n; cin >> n;
    int F[50];
    F[0] = F[1] = 1;
    for (int i = 2; i <= n; i++) F[i] = F[i-1] + F[i-2];

    cout << F[n] << endl;

    return 0;
}


Measured memory_bytes: 3100
#pragma GCC optimize ("Ofast")

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING

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


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);

	int n;
	cin >> n;

	int ac=0, wa=0, tle=0, re=0;
	string s;
	while (n--) {
		cin >> s;
		if (s == "AC") ++ac;
		else if (s == "WA") ++wa;
		else if (s == "TLE") ++tle;
		else ++re;
	}

	cout << "AC x " << ac << '\n'
		<< "WA x " << wa << '\n'
		<< "TLE x " << tle << '\n'
		<< "RE x " << re << '\n';

	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




string SS, T;
//---------------------------------------------------------------------------------------------------
string solve() {
    int N = SS.length();
    int M = T.length();

    set<string> ans;
    rrep(R, N, M) {
        int L = R - M;

        int ok = 1;
        rep(i, 0, M) if (SS[L + i] != '?' and SS[L + i] != T[i]) ok = 0;
        if (ok) {
            string S;
            rep(i, 0, N) S += SS[i];
            rep(i, 0, M) S[L + i] = T[i];
            rep(i, 0, N) if (S[i] == '?') S[i] = 'a';
            ans.insert(S);
        }
    }

    if(ans.size() == 0) return "UNRESTORABLE";
    return *(ans.begin());
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> SS >> T;
    cout << solve() << endl;
}

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

typedef long long int ll;

int main()
{
    ll n,w;
    ll a[1000],b[10000];

    cin >> n >> w;

    ll dp[100001];
    for(int i=0;i<n;i++)
    {
        cin >> a[i] >> b[i];
    }

    for(int i=0;i<=100000;i++)
    {
        dp[i] = 100000000000000000; 
    }

    dp[0] = 0;
    ll ans = 0;
    for(ll j=0;j<n;j++)
    {
        for(ll i=100000;i>=b[j];i--)
        {
            dp[i]=min(dp[i],dp[i-b[j]]+a[j]);
            if(dp[i]<=w)
            {
                ans = max(ans,i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
  string S;
  cin >> S;
  int ans = 0, tmp = 0;
  for (int i = 0; i < (int)S.size(); i++){
    if (S[i] == 'A' || S[i] == 'G' || S[i] == 'C' || S[i] == 'T'){
      tmp++;
    }else{
      if (ans < tmp){
        ans = tmp;
      }
      tmp = 0;
    }
  }
  if (ans < tmp){
    ans = tmp;
  }
  printf("%d\n", ans);
  
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    int f = 0;
    rep(i, n / 4 + 1)
    {
        rep(j, n / 7 + 1)
        {
            if (i * 4 + 7 * j == n) f = 1;
        }
    }
    if (f) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;

void ABC051C()
{
	int x0, y0, x1, y1;
	cin >> x0 >> y0 >> x1 >> y1;
	int dx = x1 - x0;
	int dy = y1 - y0;

	cout << string(dx, 'R') << string(dy, 'U') << string(dx, 'L') << string(dy,'D');
	cout << 'D' << string(dx + 1, 'R') << string(dy + 1, 'U') << "LU" << string(dx + 1, 'L') << string(dy + 1, 'D') << 'R';
	cout << endl;
}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;

public class Main {
	static ContestScanner in;
	static Writer out;
	public static void main(String[] args) {
		Main main = new Main();
		try {
			in = new ContestScanner();
			out = new Writer();
			main.solve();
			out.close();
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	void solve() throws IOException {
		int H = in.nextInt();
		int W = in.nextInt();
		int h = in.nextInt();
		int w = in.nextInt();
		int[][] map = new int[H][W];
		long cnt = 0;
		final int base = 1000;
		final int min = - (h * w) * base - 1;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				map[i][j] = base;
				if((i + 1) % h == 0 && (j + 1) % w == 0) map[i][j] += min;
				cnt += map[i][j];
			}
		}
		if(cnt <= 0) {
			System.out.println("No");
		} else {
			out.println("Yes");
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					if(j > 0) out.print(" ");
					out.print(map[i][j]);
				}out.println();
			}
		}
	}
}

class Writer extends PrintWriter{
	public Writer(String filename)throws IOException
	{super(new BufferedWriter(new FileWriter(filename)));}
	public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
	private BufferedReader in;private int c=-2;
	public ContestScanner()throws IOException 
	{in=new BufferedReader(new InputStreamReader(System.in));}
	public ContestScanner(String filename)throws IOException
	{in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
	public String nextToken()throws IOException {
		StringBuilder sb=new StringBuilder();
		while((c=in.read())!=-1&&Character.isWhitespace(c));
		while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public String readLine()throws IOException{
		StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
		while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public long nextLong()throws IOException,NumberFormatException
	{return Long.parseLong(nextToken());}
	public int nextInt()throws NumberFormatException,IOException
	{return(int)nextLong();}
	public double nextDouble()throws NumberFormatException,IOException 
	{return Double.parseDouble(nextToken());}
	public void close() throws IOException {in.close();}
}

Measured memory_bytes: 37936
A, B, K = map(int,input().split())

if A <= K:
    K = K - A
    A = 0
else:
    A = A - K
    K = 0
if B <= K:
    K = K - B
    B = 0
else:
    B = B - K
    K = 0

print(A, B)

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

//解説等確認済み
//参考: https://atcoder.jp/contests/abc141/submissions/7550214

int main() {
  ll N, M, temp;
  priority_queue<ll, vector<ll>, less<ll>> q;
  cin >> N >> M;
  for (ll i = 0; i < N; i++) {
    cin >> temp;
    q.push(temp);
  }
  for (ll i = 0; i < M; i++) {
    temp = q.top();
    temp /= 2;
    q.push(temp);
    q.pop();
  }
  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    ans += q.top();
    q.pop();
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1400
<?php

$input = trim(fgets(STDIN));
$strs = str_split($input);
$result = array_count_values($strs);
$out = 'No';
if(count($result) == 2){
    $c = array_pop($result);
    if($c == 2){
        $out = 'Yes';
    }
}

echo $out;

?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define U 1000000007
#define N 100005
#define ins insert
using namespace std;
int n,m,dis[N];
vector<int>v[N],ts;
bool b[N];
void dfs(int s){
    b[s]=true;
    rep(i,0,sz(v[s])){
        if(b[v[s][i]]==false) dfs(v[s][i]);
        dis[s]=max(dis[s],1+dis[v[s][i]]);
    }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin>>n>>m;
    rep(i,0,m){
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
        
    }
    rep(i,1,n+1) if(b[i]==false) dfs(i);
    int ans=0;
    rep(i,1,n+1) ans=max(ans,dis[i]);
    cout<<ans<<endl;




}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i <= (int)(n); i++)
#define Graph vector<vector<int>>
#define MOD 1000000007 
#define PMAX 1000000 

typedef pair<int, int> PII;
typedef long long ll;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

  int C[10][10];
  Fill(C,0);

  rep2(i,1,N){
    int tmpN = i;
    int digit_Max = 0;

    while(tmpN > 9){
      tmpN /= 10;
    }
    digit_Max = tmpN;

    int digit1 = i % 10;
    C[digit_Max][digit1]++;
  }
  
  
  ll ans = 0;
  rep(i,10){
    rep(j,10){
      ans += C[i][j] * C[j][i];
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 2e5+5;

int f(int x, int n){
	int f = x, res = 0;
	do{
		if(x%2==0) x+=1<<n;
		x>>=1;
		++res;
	}while(x!=f);
	return res;
}

int g(int x, int n){
	string s;
	for(int i=0;i<n;++i,x/=2) s+=char(x%2+'0');
	
	for(int k=2;k<=n;k+=2) if(n%(k/2)==0){
		string t = s.substr(k);
		for(int i=0;i<k;++i) t+=s[i]^1;
		if(t==s){
			//assert(k%2==0);
			//assert(n%(k/2) == 0);
			assert(n/(k/2)%2==1);
			return k;
		}
	}
	return n*2;
}

int g2(int x, int n){
	string s;
	for(int i=0;i<n;++i,x/=2) s+=char(x%2+'0');
	
	for(int k=1;k<=n;k++) if(n%k==0 && n/k%2){
		bool ok = true;
		for(int i=0;i<n;++i) ok&=s[i] == (s[i%k]^(i/k%2));
		if(ok) return k*2;
	}
	return -1;
}

vector<int> divs[N];

const int mod = 998244353;

ll solve(string X){
	int n = X.size();
	
	for(int i=1;i<=n;++i) divs[i].clear();
	for(int i=1;i<=n;++i) for(int j=i;j<=n;j+=i) if((j/i)%2==1 && n%j==0) divs[j].push_back(i);
	
	vector<int> p2(n+1);
	for(int i=p2[0]=1; i<=n; ++i) p2[i]=p2[i-1]*2 %mod;
	
	vector<int> F(n+1);
	
	ll ans = 0;
	
	vector<int> h(n+1);
	for(int k : divs[n]){
		bool ok = true;
		for(int i=0;i<n;++i){
			ok&= X[i] == (X[i%k]^(i/k%2));
			if(!ok){
				h[k] = i;
				break;
			}
		}
		if(ok) h[k] = n;
	}
	
	for(int pref=0;pref<=n;++pref){
		if(pref<n && X[pref]=='0') continue;
		
		int len = (pref==n ? n : pref + 1);
		for(int k : divs[n]){
			if(len <= k){
				F[k] = p2[k-len];
				
			}else{
				bool ok = h[k]>len-2;
				char c = pref<n ? '0' : X.back();
				ok&= c==(X[(len-1)%k]^((len-1)/k%2));
				F[k] = ok;
			}
			for(int k2 : divs[k]) if(k2<k){
				F[k]-=F[k2];
				if(F[k]<0) F[k]+=mod;
			}
			ans+= 2LL*k*F[k];
			ans%=mod;
			//cerr<<"?"<<pref<<": "<<k<<": "<<F[k]<<endl;
		}
	}
	
	return ans;
}

bool doit(){
	int n;
	string x;
	if(cin>>n>>x){
		cout<<solve(x)<<endl;
		return 1;
	}else return 0;
}

int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	
	
	for(;doit(););
	return 0;
	
	/*int n = 2e5;
	
	for(int n=1;n<=21;++n){
		ll sum = 0;
		for(int i=0;i<(1<<n);++i){
			int ans = f(i,n);
			int res = g(i,n);
			assert(res == ans);
			sum+=res;
			
			ans = g2(i,n);
			if(ans!=res){
				cerr<<n<<' '<<i<<' '<<ans<<' '<<res<<endl;
			}
			assert(ans == res);
		}
		cout<<n<<": "<<sum<<endl;
	}*/
	
	
	
	return 0;
}


Measured memory_bytes: 7828
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef long long LL;
typedef pair<int,int> P;

void visit(int n, vector<P> g, bool b[], vector<int>& res ){
  if( ! b[n] ){
    b[n] = true;
    for(vector<P>::iterator it=g.begin(); it!=g.end(); ++it){
      if( (*it).first == n )
	visit( (*it).second, g, b, res );
    }
    res.PB(n);
  }
}


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  int m,n;
  cin >> m >> n;

  vector<P> graph;
  set<int> node;

  REP(_t,n){
    int x,y;
    cin >> x >> y;
    graph.PB( MP(x,y) );
    node.insert(x);
    node.insert(y);
  }

  bool isVisited[m+1];
  memset(isVisited, 0, sizeof(isVisited));

  vector<int> res;

  for(set<int>::iterator it=node.begin(); it!=node.end(); ++it){
    visit((*it), graph, isVisited, res);
  }
  reverse( ALL(res) );
  IREP(it,res){
    cout << *it << endl;
  }

  return 0;
}

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

int main() {
    int K, S;
    cin >> K >> S;
    int ans = 0;
    rep(x, K + 1) {
        rep(y, K + 1) {
            int z = S - x - y;
            if (0 <= z && z <= K) {
                ans += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $sunukeCnt, $treatCnt);
$treatHasMap = array_fill(0, $sunukeCnt, 0);

for ($i=0; $i < $treatCnt; $i++) { 
    fscanf(STDIN, '%d', $treatNo);
    $treatHas = array_map('intval', explode(' ', trim(fgets(STDIN))));
    foreach ($treatHas as $hasSunuke) {
        $treatHasMap[$hasSunuke-1] = $treatNo;
    }
}

$ans = count(array_filter($treatHasMap, 'isZero'));
echo $ans;

function isZero($num) {
    return $num == 0;
}

Measured memory_bytes: 16148
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

void dfs(ll n,ll x,ll a,ll b,ll c,int &count)
{
    if(x > n) return;
    if(a&&b&&c) count++;
    dfs(n,10*x+7,1,b,c,count);
    dfs(n,10*x+5,a,1,c,count);
    dfs(n,10*x+3,a,b,1,count);
}


int main()
{
    fast

    ll n;
    cin>>n;

    int count = 0;
    dfs(n,0,0,0,0,count);
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
T=input()
S=input()
m = 10**10
lt=len(T)
ls=len(S)
for i in range(0,lt-ls+1):
  tmp=T[i:ls+i]
  mm=0
  for j in range(ls):
    if tmp[j]!=S[j]:
      mm+=1
  m = min(m, mm)
print(m)

Measured memory_bytes: 9112
n, x = map(int, input().split())

def make_burger(i, x):
    if i == 0:
        return 1 if x >= 1 else 0
    center_num = (a[i] + 1) // 2
    if center_num > x:
        return make_burger(i - 1, x - 1)
    elif center_num == x:
        return p[i - 1] + 1
    else:
        return p[i - 1] + 1 + make_burger(i - 1, x - center_num)


a = [1]
p = [1]
for i in range(1, n + 1):
    a.append(2 * a[-1] + 3)
    p.append(2 * p[-1] + 1)

print(make_burger(n, x))

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h, w, k := scanInt(), scanInt(), scanInt()
	c := make([][]rune, h)
	for i := 0; i < h; i++ {
		c[i] = scanRunes()
	}

	ans := 0
	bitExhaustiveSearch(h, func(a []bool) {
		tmp := make([][]rune, h)
		for i := 0; i < h; i++ {
			tmp[i] = make([]rune, w)
			if a[i] {
				for j := 0; j < w; j++ {
					tmp[i][j] = 'x'
				}
			} else {
				copy(tmp[i], c[i])
			}
		}

		bitExhaustiveSearch(w, func(b []bool) {
			cnt := 0
			for i := 0; i < w; i++ {
				if !b[i] {
					for j := 0; j < h; j++ {
						if tmp[j][i] == '#' {
							cnt++
						}
					}
				}
			}

			if cnt == k {
				ans++
			}
		})
	})

	fmt.Fprintln(wr, ans)
}

func bitExhaustiveSearch(n int, fn func(a []bool)) {
	all := 1 << uint(n)
	a := make([]bool, n)
	for i := 0; i < all; i++ {
		for j := 0; j < n; j++ {
			if i>>uint(j)&1 == 1 {
				a[j] = true
			} else {
				a[j] = false
			}
		}
		fn(a)
	}
}


Measured memory_bytes: 1808
//Binary_search:二分探索法に依る検索
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vecll = vector<long long>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); n++)

int main()
{
    ll n, q, k;
    vecll A;

    cin >> n;
    A.resize(n);
    for(auto &x : A)
        cin >> x;

    cin >> q;
    while (cin >> k)
        cout << (binary_search(A.begin(), A.end(), k) ? "1" : "0") << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#define intmax 2147483647
using namespace std;
int main() {
    int n,k;
    cin>>n>>k;
    int h[n],dp[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
        dp[i]=intmax;
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i+j<n){
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
                }
        }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
using ll = long long;
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;
}
int main() {
    ll n;
    cin>>n;
    vector<ll> v(n), c(n);
    for (ll i = 0; i < n;i++)cin>>v[i];
    for (ll i = 0; i < n;i++)cin>>c[i];
    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        ans += max(v[i] - c[i], 0LL);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
main(){
int i,j,n;
scanf("%d",&n);
int a[n][10],b,c;
for(i=0;i<n;i++)
for(j=0;j<10;j++)
scanf("%d",&a[i][j]);
for(i=0;i<n;i++){
b=0;
c=0;
for(j=0;j<10;j++)
if(a[i][j]>b)
b=a[i][j];
else if(a[i][j]>c)
c=a[i][j];
else
break;
if(j==10)
puts("YES");
else
puts("NO");
}
return 0;
}

Measured memory_bytes: 1008