akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int caseCnt = 1;

            while (true)
            {
                int W = int.Parse(Console.ReadLine());

                if (W == 0) break;

                Nullable<int>[] dp = new Nullable<int>[W + 1];
                dp[0] = 0;

                int N = int.Parse(Console.ReadLine());
                int maxV = 0;

                for (int i = 0; i < N; i++)
                {
                    string[] input = Console.ReadLine().Split(',');
                    int v = int.Parse(input[0]);
                    int w = int.Parse(input[1]);

                    for (int j = W; j >= 0; j--)
                    {
                        if (dp[j] == null) continue;

                        int sumW = w + j;
                        if (sumW > W) continue;

                        int sumV = dp[j].Value + v;

                        if (dp[sumW] == null || dp[sumW] < sumV)
                        {
                            dp[sumW] = sumV;
                            maxV = Math.Max(maxV, dp[sumW].Value);
                        }
                    }
                }
                int resW = Array.IndexOf(dp, maxV);

                sb.AppendLine("Case " + caseCnt + ":");
                sb.AppendLine(maxV.ToString());
                sb.AppendLine(resW.ToString());
                caseCnt++;
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9508
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] a = in.nextIntArray(n);
			Arrays.sort(a);
			int[] b = in.nextIntArray(n);
			int[] c = in.nextIntArray(n);
			Arrays.sort(c);

			long count = 0L;
			for (int i = 0; i < n; i++) {
				long ubc = ArrayUtils.lowerBinarySearch(a, b[i]);
				long obc = n - (ArrayUtils.upperBinarySearch(c, b[i]));
				count += (ubc * obc);
			}
			out.println(count);

		}

	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
		/**
		 * 指定された要素以上の値が現れる最初の位置のイテレータを取得する
		 * */
		public static int lowerBinarySearch(int[] a, int obj) {
			int l = 0,r = a.length - 1;
			while (r - l >= 0) {
				int c = (l + r) / 2;
				if (obj <= a[c]) {
					r = c - 1;
				} else {
					l = c + 1;
				}
			}
			return l;
		}

		/**
		 * 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
		 * */
		public static int upperBinarySearch(int[] a, int obj) {
			int l = 0,r = a.length - 1;
			while (r - l >= 0) {
				int c = (l + r) / 2;
				if (a[c] <= obj) {
					l = c + 1;
				} else {
					r = c - 1;
				}
			}
			return l;
		}

	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 50536
/**
 * Boris Sokolov
 * Software Engineer at Ring Labs
 * Kiev, Ukraine | Los Angeles, CA
 */

#pragma comment(linker, "/STACK:500000000")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <exception>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;
const double PI = acos(-1.0);
const double EPS = 1e-9;
const ll INF = static_cast<ll>(1e18);
const int MOD = static_cast<int>(1e9) + 7;

vector<int> a[(int)1e5 + 9];
bool is_in_path[(int)1e5 + 9];
bool stop = false;
int n;
int color[(int)1e5 + 9];
int cnt[2];

void dfs(int node, int prev) {
    if (stop) {
        return;
    }
    is_in_path[node] = true;
    if (node == n - 1) {
        stop = true;
        return;
    }
    for (int i = 0; i < a[node].size(); ++i) {
        int child = a[node][i];
        if (child != prev) {
            dfs(child, node);
        }
    }
    if (stop) {
        return;
    }
    is_in_path[node] = false;
}

void dfs2(int node, int player_color) {
    color[node] = player_color;
    for (int i = 0; i < a[node].size(); ++i) {
        int child = a[node][i];
        if (color[child] == -1) {
            dfs2(child, player_color);
        }
    }
}

int main() {
    //freopen("in.txt", "rt", stdin);
    //freopen("out.txt", "wt", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        scanf("%d %d", &u, &v);
        --u;
        --v;
        a[u].push_back(v);
        a[v].push_back(u);
    }
    
    color[0] = 1;
    for (int node = 1; node < n - 1; ++node) {
        color[node] = -1;
    }
    color[n - 1] = 0;
    dfs(0, -1);
    
    int x = 0;
    int y = n - 1;
    while (true) {
        int z = -1;
        for (int i = 0; i < a[x].size(); ++i) {
            int node = a[x][i];
            if (color[node] == -1 && is_in_path[node]) {
                z = node;
                break;
            }
        }
        if (z == -1) {
            break;
        }
        x = z;
        color[x] = 1;

        z = -1;
        for (int i = 0; i < a[y].size(); ++i) {
            int node = a[y][i];
            if (color[node] == -1 && is_in_path[node]) {
                z = node;
                break;
            }
        }
        if (z == -1) {
            break;
        }
        y = z;
        color[y] = 0;
    }
    for (int i = 0; i < n; ++i) {
        if (color[i] != -1) {
            dfs2(i, color[i]);
        }
    }
    for (int i = 0; i < n; ++i) {
        ++cnt[color[i]];
    }
    printf((cnt[1] > cnt[0]) ? "Fennec\n" : "Snuke\n");
    return 0;
}


Measured memory_bytes: 12416
def convert(S,N):
    i = ord(S)
    if (i + N > 90):
        c_i = i + N - 26
    else:
        c_i = i + N 
    return c_i

def main():
    N = int(input())
    S = input()
    s = ' '
    for i in range(len(S)):
        s += chr(convert(S[i],N))
    print(s[1:])
    return 0
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        final int[] array = new int[100];
        for (int i = 1; i <= n; i++) {
            if (i % 10 == 0) {
                continue;
            }

            final String s = Integer.toString(i);
            array[(s.charAt(0) - '0') * 10 + s.charAt(s.length() - 1) - '0']++;
        }

        int count = 0;
        for (int i = 11; i <= 99; i++) {
            final int reverseNum = i % 10 * 10 + i / 10;
            count += array[i] * array[reverseNum];
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 32596
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

#include <stack>
#include <queue>
// #include <deque>
#include <set>
#include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;
typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/

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

    int x,y,z; cin>>x>>y>>z; cin.ignore();

    swap(x,y); swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<el;
}

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

const long long maxn = 2e5 + 10;

long long n, m;
long long a[maxn];
long long cnt[maxn];
long long ans[maxn];

void in();
void solve();
void out();

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

void in(){
    cin >> n;
    for(long long i = 0; i < n; i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
}

void solve(){
    long long kol = 0;
    for(long long i = 0; i <= n; i++)
        kol += cnt[i] * (cnt[i] - 1) / 2;
    for(long long i = 0; i < n; i++){
        ans[i] = kol - cnt[a[i]] + 1;
    }
}
void out(){
    for(long long i = 0; i < n; i++)
        cout << ans[i] << '\n';
}


Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

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

const ll mod = static_cast<ll>(1e9) + 7;

const ll MAXM = 200000;

ll M;
ll D[MAXM], C[MAXM];

int main()
{
    cin >> M;
    rep (i, M) { cin >> D[i] >> C[i]; }

    ll ans = 0;
    ll tmp = 0;

    rep (i, M)
    {
        tmp += D[i] * C[i];

        while (tmp >= 10)
        {
            const ll c1 = tmp / 10;
            const ll c2 = tmp % 10;

            ans += c1;
            tmp = c1 + c2;
        }

        ans += C[i];
    }

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

    return 0;
}


Measured memory_bytes: 3328
a,b,c,d = gets.chomp.split("").map &:to_i
op_1 = op_2 = op_3 = 0
2.times do |i|
  2.times do |j|
    2.times do |k|
      i = -1 if i == 0
      j = -1 if j == 0
      k = -1 if k == 0
      if a + i * b + j * c + k * d == 7
        op_1 = i == -1 ? "-" : "+"
        op_2 = j == -1 ? "-" : "+"
        op_3 = k == -1 ? "-" : "+"
      end
    end
  end
end
puts "#{a}#{op_1}#{b}#{op_2}#{c}#{op_3}#{d}=7"

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	if (N % 10 == 7 || (N % 100) / 10 == 7 || N / 100 == 7) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, S);
  cout << S[0] << S.length() - 2 << S[S.length() - 1] << endl;
}


Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cctype>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  int X, t;
  cin >> X >> t;
  if(X > t) cout << X-t << endl;
  else cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#CODEFESTIVAL2016 qualB D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [I() for _ in range(n)]
tmp = 1
ans = a[0] - 1
for i in range(1,n):
    if a[i] == tmp + 1:
        tmp += 1
    elif a[i] == tmp:
        continue
    else:
        ans += math.ceil(a[i]/(tmp+1)) - 1
print(ans)


Measured memory_bytes: 45816
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int A[101],B[101][101],C[101];
int N,M;
int D[201];
int main() {
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>A[i];
	}
	for(int i=0;i<M;i++){
		for(int j=0;j<N;j++){
			cin>>B[i][j];
		}
	}
	int S;
	for(int i=0;i<M;i++){
		S=0;
		for(int j=0;j<N;j++){
			if(B[i][j]==A[i]){
				C[j]+=1;
			}else{
				S+=1;
			}
		}
		C[A[i]-1]+=S;
	}



	for(int i=0;i<N;i++){
		cout<<C[i]<<endl;
	}




	return 0;
}

Measured memory_bytes: 3116
A,B,K = map(int, input().split())
A_div = []
B_div = []
C     = set()

def divisor(a,b):

    for i in range(1, int(a**0.5)+1, 1):
        if a%i==0:
            A_div.append(i)
            A_div.append(a//i)
        
    for i in range(1, int(b**0.5)+1, 1):
        if b%i==0:
            B_div.append(i)
            B_div.append(b//i)

def f():
    for a in A_div:
        for b in B_div:
            if a==b:
                C.add(a)

divisor(A,B)
f()

C = list(C)
C.sort(reverse=True)
print(C[K-1])
    

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

int main()
{
  string S, T;
  cin >> S >> T;
  // もし最初から合っていればYes出して終了
  if (S == T)
  {
    cout << "Yes" << endl;
    return 0;
  }
  // 左に一個ずらしてる
  for (int i = 0; i < S.length(); ++i)
  {
    char A = S[0];
    // ポンポン右の数字を自分に置いてく
    for (int j = 0; j < S.length()-1; ++j)
    {
      S[j] = S[j+1];
    }
    // 最後は最初のものを持って来て完成！！
    S[S.length()-1] = A;

    if (S == T)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  // 最後まで当たらなかったらNoをだす
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N;
	cin>>N;
	vector<int>a(N);
	REP(i,N) cin>>a[i];
	cout<<a[N-1];
	for(int i=N-3;i>=0;i-=2)
		cout<<" "<<a[i];
	if(N%2==0){
	for(int i=0;i<N;i+=2)
		cout<<" "<<a[i];
	cout<<endl;
	}
	else{
	for(int i=1;i<N;i+=2)
		cout<<" "<<a[i];
	cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int ta[100010],to[100010],co[100010],nt[100010],it[100010],l[100010];
void mklsb(int v,int e,int *a,int *b,int *c){
  int i;
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    co[ta[a[i]]=i  ]=c[i];      
    co[ta[b[i]]=i+e]=0;
  }
}
int MF(int e,int s,int t,int min){
  if(s==t)return min;
  int i,r;
  for(;it[s]+1;it[s]=nt[it[s]]){
    if(co[it[s]]==0||l[s]>=l[to[it[s]]])continue;
    r=MF(e,to[it[s]],t,MIN(min,co[it[s]]));
    co[it[s]]-=r;
    co[(it[s]+e)%(2*e)]+=r;
    if(r)return r;
  }
  return 0;
}
int maxf(int v,int e,int s,int g){
  int i,a=0,q[100010],t,r,c=3;
  while(1){
    for(i=t=0;i<v;i++)l[i]=-1;
    l[q[0]=s]=0;
    for(r=1;r-t;t++){
      for(i=ta[q[t]];i+1;i=nt[i]){
	if(co[i]==0||l[to[i]]+1)continue;
	l[to[i]]=l[q[t]]+1;
	q[r++]=to[i];
      }
    }
    if(l[g]<0)return a;
    for(i=0;i<v;i++)it[i]=ta[i];
    while(r=MF(e,s,g,1e9))a+=r;
  }
  return a;
}
int main(){
  int n,m,i,a[100010],b[100010],c[1000010],m1,m2;
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++)scanf("%d %d %d",&a[i],&b[i],&c[i]);
  mklsb(n,m,a,b,c);//prls(n);
  m1=maxf (n,m,0,n-1);
  printf("%d\n",m1);
  return 0;
}

Measured memory_bytes: 4736
import math

K = int(input())

A = input().split()

for i in range(K):
    A[i] = int(A[i])

maxlst = [0 for i in range(K)]
minlst = [0 for i in range(K)]

if A[K-1] != 2:
    print(-1)
    quit()

maxlst[K-1] = 3
minlst[K-1] = 2

for i in reversed(range(K-1)):
    if maxlst[i+1] < A[i] or (maxlst[i+1] % A[i] != 0 and minlst[i+1] % A[i] != 0 and int(maxlst[i+1]/A[i]) == int(minlst[i+1]/A[i])):
        print(-1)
        quit()
    maxlst[i] = int(A[i] - 1 + A[i] * math.floor(maxlst[i+1] / A[i]))
    minlst[i] = int(math.ceil(minlst[i+1] / A[i]) * A[i])

print(minlst[0], maxlst[0])


Measured memory_bytes: 15752
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#include <sstream>
#include <bitset> 
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define ld long double
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int INF=0x7ffffff;

int ans=INF;
int movee[5][3];
bool visited[848][848];
int r,c,k;
int sx,sy;
int a[848][848];
char s[1000];
queue<int> q;

void bfs(int x,int y,int step)
{
	q.push(x);q.push(y);q.push(0);
	int cur_ans,cx,cy,cd,xx,yy,dd;
	visited[x][y]=true;
	while (!q.empty())
	{
		cx=q.front();q.pop();
		cy=q.front();q.pop();
		cd=q.front();q.pop();
		//visited[cx][cy]=true;
		cur_ans=cx-1;
		cur_ans=min(cur_ans,cy-1);
		cur_ans=min(cur_ans,r-cx);
		cur_ans=min(cur_ans,c-cy);
		ans=min(ans,cur_ans);
		if (cd==k) continue;
		for (int i=1;i<=4;i++)
		{
			xx=cx+movee[i][1];yy=cy+movee[i][2];
			if (xx<1 || xx>r || yy<1 || yy>c) continue;
			if (a[xx][yy]==1 || visited[xx][yy]) continue;
			visited[xx][yy]=true;q.push(xx);q.push(yy);q.push(cd+1);
		}
	}
	/*int cur_ans=x-1;
	cur_ans=min(cur_ans,y-1);
	cur_ans=min(cur_ans,r-x);
	cur_ans=min(cur_ans,c-y);
	ans=min(ans,cur_ans);
	visited[x][y]=true;
	if (step==k) return;
	int xx,yy,i;
	for (i=1;i<=4;i++)
	{
		xx=x+movee[i][1];yy=y+movee[i][2];
		if (xx<1 || xx>r || yy<1 || yy>c) continue;
		if (a[xx][yy]==1 || visited[xx][yy]) continue;
		dfs(xx,yy,step+1);
	}*/
}

int main ()
{
	//ios::sync_with_stdio(false);
	int i,j;
	movee[1][1]=1;movee[1][2]=0;
	movee[2][1]=0;movee[2][2]=1;
	movee[3][1]=-1;movee[3][2]=0;
	movee[4][1]=0;movee[4][2]=-1;
	scanf("%d%d%d",&r,&c,&k);
	for (i=1;i<=r;i++)
	{
		scanf("%s",s);
		for (j=1;j<=c;j++)
		{
			if (s[j-1]=='#') a[i][j]=1;
			if (s[j-1]=='.') a[i][j]=2;
			if (s[j-1]=='S')
			{
				sx=i;sy=j;
				a[i][j]=2;
			}
		}
	}
	bfs(sx,sy,0);
	int fans=1+(ans+k-1)/k;
	printf("%d\n",fans);
	return 0;
}

/*
3 3 3
#.#
#S.
###

3 3 3
###
#S#
###

7 7 2
#######
#######
##...##
###S###
##.#.##
###.###
#######
*/

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

int main() {
	string str;
	cin >> str;
	int idx = 0;
	for (; idx < str.sz; idx++)
		if (str[idx] == 'C')
			break;
	for (; idx < str.sz; idx++)
		if (str[idx] == 'F')
			break;
	if (idx < str.sz)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

using namespace std;

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

  int L = 1;
  int R = N;

  for (int i = 0; i < M; i++) {
    int l, r;
    cin >> l;
    cin >> r;
    L = max(L, l);
    R = min(R, r);
  }

  int ans = max(0, R - L + 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30

int MOD = 1000000007;



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

    int n; cin >> n; int sum = 0;
    std::vector<int> l(n);

    REP(i,n){
        cin >> l[i];
        sum+= l[i];
    }

    int m = *std::max_element(l.begin(), l.end());
    sum-=m;
    if(m < sum) cout << "Yes" <<endl;
    else cout << "No" << endl;



    return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int t;
  cin >> t;
  while (t--) {
    int x, y, w, h;
    cin >> x >> y >> w >> h;
    int c = 0;
    int n;
    cin >> n;
    while (n--) {
      int p, q;
      cin >> p >> q;
      c += x <= p && p <= x + w && y <= q && q <= y + h;
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 3076
import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();


        int[] fr = new int[N];
        for (int i = 0; i < N; i++) {
            fr[i] = sc.nextInt();
        }

        Arrays.sort(fr);


        int ans = 0;

        for (int i = 0; i < K && i<fr.length ; i++) {
            ans += fr[i];
        }


        System.out.println(ans);


    }

}


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

int main() {
  int N;cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  int ans=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=j+1;k<N;k++){
        bool can=true;
        if(A.at(i)==A.at(j)) can=false;
        else if(A.at(j)==A.at(k)) can=false;
        else if(A.at(i)==A.at(k)) can=false;
        if(A.at(i)+A.at(j)<=A.at(k)) can=false;
        else if(A.at(j)+A.at(k)<=A.at(i)) can=false;
        else if(A.at(k)+A.at(i)<=A.at(j)) can=false;
        if(can) ans++;
      }
    }
  }
  cout<<ans<<endl;
}

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

int main(){
    ios_base::sync_with_stdio(0);
    long long n; cin >> n;
    int cnt = 0;
    for(long long i = 2; i * i <= n; ++i){
        if(n % i == 0){
            int t = 0;
            while(n % i == 0){
                t++;
                n /= i;
            }
            int i = 1;
            for(;t >= i;++i) t -= i, ++cnt;
        }
    }
    if( n > 1 ) cnt++;
    cout << cnt << '\n';
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const long long MOD = 1000000007;
const int MAX_N = 100001;
string s;
ll dp[MAX_N+1][2];


int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> s;

  // (0,0)
  dp[0][1] = 1;

  forn(i,s.size()) {
    if (s[i] == '0') {
      // i+1桁目を0にする
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = dp[i][1];
      // i+1桁目を1にする
      dp[i+1][0] = (dp[i+1][0] + dp[i][0] * 2) % MOD;
    } else {
      dp[i+1][0] = (dp[i][0] + dp[i][1]) % MOD;

      dp[i+1][0] = (dp[i+1][0] + dp[i][0] * 2) % MOD;
      dp[i+1][1] = dp[i][1] * 2 % MOD;
    }
  }

  cout << (dp[s.size()][0] + dp[s.size()][1]) % MOD << endl;

  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int main() {
  string S; cin >> S;
  int N = S.size();
  
  int n0 = count(all(S),'0');
  int n1 = count(all(S),'1');
  cout << min(n0,n1)*2 << endl;
}

Measured memory_bytes: 512
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005

int main()
{
    fastread;
    int n;
    cin>>n;
    vector<int> arr(n);
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    int minval = arr[0];
    int cnt = 1;
    for(int i=1;i<n;i++){
    	minval = min(minval,arr[i]);
    	if(minval == arr[i])
    		cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
string T;

int main() {
  cin >> T;
  for (int i = 0; i < T.size(); ++i) {
    if (T[i] == '?') {
      cout << 'D';
      continue;
    }
    cout << T[i];
  }
  cout << endl;
}


Measured memory_bytes: 3732
n = int(input())
WIN = 3
DROW = 1
tarou = 0
hanako = 0
for i in range(n):
    t, h = input().split()
    if t == h:
        tarou += DROW
        hanako += DROW
    if t > h:
        tarou += WIN
    if t < h:
        hanako += WIN
print(tarou, hanako)



Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector< bool > seen;
int N;


int dfs( const vector< vector<int> > G, int v )
{
    bool all_v = true;
    seen[v] = true;
    for( int i = 0; i < N; ++i )
    {
        if( seen[i] == false )
        {
            all_v = false;
        }
    }

    if( all_v == true )
    {
        return 1;
    }

    int ret = 0;
    for( int i = 0; i < G[v].size(); ++i )
    {
        int nv = G[v][i];
        if( seen[nv] == true )
        {
            continue;
        }
        ret = ret + dfs( G, nv );
        seen[nv] = false;
    }
    return ret;
}

int main()
{
    int n,m;
    cin >> n >> m;
    N = n;
    vector< vector<int> > g(n);
    for( int i = 0; i < m; ++i )
    {
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    seen.assign(n,false);
    int ans = dfs( g, 0 );
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
n, m, x = map(int, input().split())
books=[]
for i in range(n):
    books.append(list(map(int, input().split())))
#print(books)
perms=[]
for i in range(2**n):
    list2 = []
    for j in range(n):
        if (i >> j) &1 == 1:
            list2.append(1)
        else:
            list2.append(0)
    perms.append(list2)
#print(perms)
oks=[]
for i in perms:
    cost = 0
    xs = [0]*m
    for idx,j in enumerate(i):
        if j==1:
            cost+=books[idx][0]
            for k in range(m):
                xs[k]+=books[idx][k+1]
    if min(xs)>=x:
        oks.append(cost)
#print(oks)
if oks:
    print(min(oks))
else:
    print(-1)

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

#define BR "\n"
#define SP " "
#define fcout cout << fixed << setprecision(18)

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

  ll ans = N * N;

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
    int money;
    int coin5;
    int coin500;

    scanf("%d", &money);

    coin500 = money / 500;
    coin5 = (money-500*coin500)/5;

    printf("%d\n", coin500*1000 + coin5*5);

    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;




int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n, k;
	cin >> n >> k;
	vi a(n);
	for (auto& x : a)
		cin >> x;
	sort(all(a));
	reverse(all(a));
	ll res = 0;
	for (int i = k; i < n; i++)
	{
		res += a[i];
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  if (S.size()==2) {
    cout << S <<endl;
  }
  else {
    cout << char(S.at(2)) << char(S.at(1)) << char(S.at(0)) << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

int main()
{
	bool dup = false;
	int n;
	set<int> list;

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		set<int>::iterator ret;

		int input;

		scanf("%d", &input);

		ret = list.find(input);

		if (ret == list.end())
		{
			list.insert(input);
		}

		else
		{
			dup = true;
		}
	}

	if (dup)
	{
		printf("NO\n");
	}

	else
	{
		printf("YES\n");
	}

	return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 100000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)

int operate(int bit, int dig, int n1, int n2){
    if(bit & (1<< dig)) return n1+n2;
    else return n1-n2;    
}

char operate_c(int bit, int dig){
    if(bit & (1<< dig)) return '+';
    else return '-';    
}

int main(){
    int N,A,B,C,D,sum;
    cin >> N;
    A = N /1000;
    B = (N-A*1000)/100;
    C = (N-A*1000-B*100)/10;
    D = N%10;
    for(int bit = 0;bit <(1<<3);bit++){
        sum = A;
        sum = operate(bit,0,sum,B);
        sum = operate(bit,1,sum,C);
        sum = operate(bit,2,sum,D);      
        if(sum==7){
            cout << A << operate_c(bit,0) << B << operate_c(bit,1) << C <<operate_c(bit,2) << D <<"=7" << endl;
            break;
        }
    }
}

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

#define lli unsigned long long int
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

void swap(lli *a,lli *b){
	lli tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){

	lli q;
	cin>>q;
	REP(i,q){
		lli a,b;
		cin>>a>>b;
		lli target = a*b;
		lli num = sqrt(target);
		lli flagA=0,flagB=0;
		if(a>b){
			swap(&a,&b);
		}
		if( a==b || a+1 ==b){
			cout<<2*a-2<<endl;
			continue;
		}
		lli ans = num*2;
		if(num*num == target){
			ans--;
		}
		if((num+1)*num<target){
			cout<<ans-1<<endl;
		}
		else{
			cout<<ans-2<<endl;
		}
	}

	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

struct UnionFind
{
	vector<int> parent;
	vector<int> rank;

	UnionFind(int N) :parent(N, 0), rank(N, 0)
	{
		rep(i, 0, N)parent[i] = i;
	}

	int find(int x)
	{
		if (parent[x] == x)return x;
		else return parent[x] = find(parent[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (x == y)return;

		if (rank[x] < rank[y])parent[x] = y;
		else {
			parent[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}

	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, Q;
	cin >> N >> Q;

	UnionFind uf(N + 1);
	int t, u, v;
	rep(i, 0, Q)
	{
		cin >> t >> u >> v;
		if (t == 0)
		{
			uf.unite(u, v);
		}
		else
		{
			cout << (uf.same(u, v) ? 1 : 0) << endl;
		}
	}

	return 0;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
 int N, K, S;
 cin >> N >> K >> S;
if (S == 1e9)
   {
      REP(i, N)
      {
         if (i >= K)
         {
            cout << 1 << ' ';
         }
         else
         {
            cout << S << ' ';
         }
      }
   }
   else
   {
      REP(i, N)
      {
         if (i >= K)
         {
            cout << S + 1 << ' ';
         }
         else
         {
            cout << S << ' ';
         }
      }
   }
cout << endl;
}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_155
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var dict = new Dictionary<string, int>();
            int cnt = 0;
            for(int i = 0; i < n; i++)
            {
                string s = Read();
                if (dict.ContainsKey(s))
                {
                    dict[s]++;
                }
                else
                {
                    dict.Add(s, 1);
                }
                cnt = Max(cnt, dict[s]);
            }
            List<string> res = new List<string>();
            foreach(string key in dict.Keys)
            {
                if (dict[key] == cnt)
                {
                    res.Add(key);
                }
            }
            res.Sort(StringComparer.OrdinalIgnoreCase);
            for(int i = 0; i < res.Count; i++)
            {
                WriteLine(res[i]);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 39772
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        StringTokenizer st;
        try {
            String line;
            int n = Integer.parseInt(br.readLine());
            System.out.println(factrial(n));

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public static long factrial(int n) {
        long m;
        if (n == 0) {
            return 1;
        }
        m = factrial(n - 1);
        return n * m;
    }

}

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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

void solve() {
    rd2(ll, a, l);
    if((l- 2 * a) >= 0 and (l- 2 * a) % 2 == 0 and (4 * a - l) >= 0 and (4 * a - l) % 2 == 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }
	
}

int main() {
	
	fastio;

//  	rd1(ll, t);
	ll t = 1;

    while(t--) {
        solve();
    }
    
	return 0;
}

Measured memory_bytes: 3652
def main():
    n, m = map(int, input().split())
    ac = [0] * n
    wanum = [0] * n
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if ac[p]:
            continue
        else:
            if s == 'AC':
                ac[p] = 1
                wanum[p] *= -1
            else:
                wanum[p] -= 1
    wanum2 = [i for i in wanum if i > 0]
    print(sum(ac), sum(wanum2))

if __name__ == '__main__':
    main()

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  string S = readString();
  vi cnt(S.size());
  string prev = "", tmp;
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    tmp += S[i];
    if (prev != tmp) {
      prev = tmp;
      tmp = "";
      ans++;
    }
  }
  print(ans);
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define all(x) begin(x),end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << " " <<
using namespace std;

int n,k,a[105];
int dp[100005][2];

int main(){
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;++i)scanf("%d",a+i);
  for(int i=1;i<=k;++i){
    for(int j=0;j<n;++j){
      if(a[j]>i)continue;
      dp[i][0]|=!dp[i-a[j]][1];
      dp[i][1]|=!dp[i-a[j]][0];
    }
  }
  puts(dp[k][0]?"First":"Second");
}


Measured memory_bytes: 1024