akhauriyash/Code-Regression huggingface dataset:
#include <sstream>
#include <fstream>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <cstdio>


#include <stdlib.h>
#include <iostream>
#include <chrono> //clock
#include <vector>
#include <string>
#include <iomanip>  //setprecision function
#include <cmath>	//math
#include <cstdio>
#include <vector>	//vector array
#include <algorithm>	//STL algorithm
#include <set> //STL library set
#include <sstream> // for stringstream


using namespace std;
using namespace std::chrono; 


int main() {
	stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(16);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP
	 // DP MA STATE PTA KRO AUR PHIR FUNCTION GENERATE KRO
	 // OBJECT KO CHOOSE KIA YA NAE KIA AGAR KIA TO KYA HOGA AUR NAE KIA TO KYA HOGA


	int n,k;
	cin>>n>>k;
	int vec[n][2];
	for(int i=0;i<n;i++){
		cin>>vec[i][0];
		cin>>vec[i][1];
	}
	
	vector<vector<long long>> dp(n+1,vector<long long>(k+1,0));

	
	//int dp[n][k];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			if(j-vec[i-1][0]>-1){
				dp[i][j]=max(vec[i-1][1]+dp[i-1][j-vec[i-1][0]],dp[i][j-1]);
				dp[i][j]=max(dp[i][j],dp[i-1][j]);
			}else dp[i][j]=dp[i-1][j];
		}
	}
	
	cout<<dp[n][k]<<endl;
	
	return 0;
}





























Measured memory_bytes: 80256
s = input()
q = int(input())
for i in range(q):
    row = list(input().split())
    a = int(row[1])
    b = int(row[2])
    command = row[0]
    if command == "replace":
        p = row[3]
        s = s[:a] + p + s[b+1:]
    elif command == "reverse":
        s = s[:a] + s[a:b+1][::-1] + s[b+1:]
    elif command == "print":
        print(s[a:b+1])



Measured memory_bytes: 5612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			const int d = 2019;

			var vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int L = vs[0];
			int R = vs[1];
			int ans = ((L % d) * (R % d)) % d;
			for (int i = L; i < R; i++) {
				for (int j = R; j > i; j--) {
					ans = Math.Min(ans, ((i % d) * (j % d)) % d);
					if (ans == 0) {
						break;
					}
				}
				if (ans == 0) {
					break;
				}
			}
			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 13396
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N;
    vector<int> a(100010);
    ll x = 0;
    cin >> N;
    for (int i=0;i<N;i++) cin >> a[i];
    bool flag = false;
    vector<int> b(a);
    sort(b.begin(), b.begin()+N);
    auto itr = unique(b.begin(),b.begin()+N);
    b.erase(itr,b.end());
    if (b.size() > 3) flag = true;
    else if (b.size() == 3) {
        if (N%3 != 0) flag = true;
        else if (b[0] != (b[1]^b[2]) || b[1] != (b[0]^b[2]) || b[2] != (b[0]^b[1])) flag = true;
        else if (count(a.begin(), a.begin()+N, b[0]) != N/3) flag = true;
        else if (count(a.begin(), a.begin()+N, b[1]) != N/3) flag = true;
        else if (count(a.begin(), a.begin()+N, b[2]) != N/3) flag = true;
    } else if (b.size() == 2) {
        if (N%3 != 0) flag = true;
        else if (b[0] != 0) flag = true;
        else if (count(a.begin(), a.begin()+N, b[1]) != 2*N/3) flag = true;
    } else {
        if (b[0] != 0) flag = true;
    }

    if (flag) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

int main() {
	int x, y; cin >> x >> y;

	if (x % y == 0) {
		cout << -1 << endl;
	}
	else {
		cout << x << endl;
	}


}



Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		String last = "";
		String start = "";

		Set<String> set = new HashSet<String>();

		for (int i = 0; i < n; i++) {
			String str = sc.next();

			start = str.substring(0, 1);

			if(i!=0) {
				if (!last.equals(start)) {
					break;
				}
			}

			last = str.substring(str.length() - 1);
			set.add(str);
		}

		if (set.size() != n) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}

	}

}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll V;
constexpr ll MAX_V = 200;
vector<vector<ll>> G;
ll match[MAX_V];
bool used[MAX_V];

void addEdge(ll u, ll v)
{
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(ll v)
{
	used[v] = true;

	for (auto &nv : G[v])
	{
		ll w = match[nv];
		if (w < 0 || (!used[w] && dfs(w)))
		{
			match[v] = nv;
			match[nv] = v;
			return true;
		}
	}
	return false;
}

ll bipartiteMatching()
{
	ll res{0};
	memset(match, -1, sizeof match);
	REP(v, V)
	{
		if (match[v] < 0)
		{
			memset(used, 0, sizeof used);
			if (dfs(v)) ++res;
		}
	}
	return res;
}

int main(int argc, char **argv)
{
	ll N; cin >> N;
	V = 2*N;
	vector<ll> a(N), b(N);
	REP(i, N) cin >> a[i] >> b[i];
	G.resize(N*2);
	
	REP(i, N)
	{
		ll x, y; cin >> x >> y;
		REP(j, N)
		{
			if (a[j] < x && b[j] < y)
				addEdge(j, i+N);
		}
	}

	std::cout << bipartiteMatching() << std::endl;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Arrays;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
            int n;
            n=sc.nextInt();
            int a[]=new int[n];
            for(int i=0;i<n;i++){
                a[i]=sc.nextInt();
            }
            for(int i=0;i<n;i++){
                if(i!=(n-1))System.out.print(a[n-i-1]+" ");
                else System.out.println(a[n-i-1]);
            }
        
}
}



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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    ll K,A,B;
    Scll3(K,A,B);

    ll ans0 = K+1;
    ll ans1 = 0;
    ll k = K-A+1;
    ans1 = (B-A)*(k/2)+A;
    ans1 += k%2;

    printf ("%lld\n", max( ans0, ans1 ) );

    return 0;
}





Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d', $num);
$angle = array_fill(0, 1000000, 0);
$now = $angle[0];
$ans = 0;
while (!($now > 0 && $now % 360 == 0)) {
    $angle[$now]++;
    $now+=$num;
    $ans++;
}
echo $ans;

Measured memory_bytes: 47140
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
    n = int(input())
    a = np.array(read().split(), np.int32)
    mina = np.minimum.accumulate(a)
    r = np.count_nonzero(mina >= a)
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 48008
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

ll sum[100010], sum2[100010];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, m; cin >> n >> m;
	vi a(n); rep(i, n) cin >> a[i], a[i]--;
	
	rep(i, n - 1){
		int l = a[i], r = a[i + 1];
		if(l < r){
			/*
			rep(j, m){
				if(l < j && j <= r) cnt[j] += r - j + 1;
				else cnt[j] += r - l;
			}
			*/
			sum[0] += r - l;
			sum[l + 1] -= r - l;
			sum[r + 1] += r - l;
			
			sum[l + 1] += r + 1;
			sum[r + 1] -= r + 1;
			sum2[l + 1]--;
			sum2[r + 1]++;
		}
		else{
			/*
			rep(j, m){
				if(j <= r) cnt[j] += r - j + 1;
				else if(j > l) cnt[j] += r + m - j + 1;
				else cnt[j] += r + m - l;
			}
			*/
			sum[0] += r + 1;
			sum[r + 1] -= r + 1;
			sum2[0]--;
			sum2[r + 1]++;
			
			sum[l + 1] += r + m + 1;
			sum2[l + 1]--;
			
			sum[r + 1] += r + m - l;
			sum[l + 1] -= r + m - l;
		}
	}
	//rep(i, m) dbg(i, cnt[i]);
	
	rep(i, m){
		sum[i + 1] += sum[i];
		sum2[i + 1] += sum2[i];
		sum[i] += sum2[i] * i;
		//dbg(i, sum[i]);
	}
	cout << *min_element(sum, sum + m) << endl;
	
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
int N,M,Q;



int main() {
	cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	rep(i, A.size()-1) {
		cout << A[i] << " ";
	}
	cout << A[A.size()-1] << endl;
	return 0;
}





Measured memory_bytes: 3156
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

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

// const int kMaxN;

int A, B, C, K;
int ans = 0;

signed main() {
  cin >> A >> B >> C;
  cin >> K;

  int m = MAX(A, MAX(B, C));
  int n = 1;
  REP(i, K) { n *= 2; }
  ans = A+B+C - m + m*n;

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


Measured memory_bytes: 256
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit
    
N, = getIntList()
#print(N)
za = getIntList()

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

for i in range(1,N):
    dp[i] = dp[i-1] + abs( za[i] - za[i-1])
    if i>1:
        c = dp[i-2] + abs( za[i] - za[i-2])
        dp[i] = min(dp[i],c)

print(dp[N-1])






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


/*
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <ctype.h>
*/
typedef struct  llnode
{
	int x;
	struct llnode *next;
}
slnode;


using namespace std;

typedef pair<int , int > pii;
typedef pair<long , long> pll;
typedef pair<pii , int > piii;
typedef pair<pll , long > plll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector <pii> vii;
typedef vector<pll> vll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef unsigned long long int ulli;
typedef long long int lli;
typedef double d;
typedef float f;
typedef string s;
typedef char ch;
typedef pair<int,ll> pill;

#define loop(n) for(int i = 0; i < (n); i++)
#define lp(x , s , e) for(int x = (s); x < (e); x++)
#define lpe(x , s , e) for(int x = (s); x <= (e); x++)
#define readline(s) getline(cin,s)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;
#define MP make_pair
#define PB push_back
#define all(a) a.begin(),a.end()
#define clr(x , val) memset((x) , (val) , sizeof(x))
#define endl '\n'

ll power(ll a, ll b)
{
    ll res = 1;
    for(int i = 0; i<b; i++)
       res *= a;

    return res;
}
int findSingle(int ar[], int ar_size)
    {
        int res = ar[0];
        for (int i = 1; i < ar_size; i++)
            res = res ^ ar[i];
        return res;
    }
const int con = 2e5;
int freq[con + 9];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    while(n > 0)
    {
    	if (n % 10 == 7)
    	{
    		cout << "Yes";
    		return 0;
    	}
    	n /= 10;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] abs = new int[3];
        int ans = 0;
        for(int i = 0; i < n; i++){
            String tmp = sc.next();
            int index = 0;
            while(index < tmp.length()){
                int now = tmp.indexOf("AB", index);
                if(now != -1){
                    index = now+1;
                    ans++;
                }else{
                    break;
                }
            }
            boolean topB = tmp.charAt(0) == 'B' ? true : false;
            boolean lastA = tmp.charAt(tmp.length()-1) == 'A' ? true : false;
            if(topB && lastA){
                abs[0]++;
            }else if(topB){
                abs[1]++;
            }else if(lastA){
                abs[2]++;
            }
        }
        if(abs[1]+abs[2] == 0){
            System.out.println(ans + Math.max(0,abs[0]-1));
        }else if(abs[0]+abs[1] <= abs[2]){
            System.out.println(ans + abs[0]+abs[1]);
        }else if(abs[0]+abs[2] <= abs[1]){
            System.out.println(ans + abs[0]+abs[2]);
        }else{
            abs[0] -= Math.abs(abs[1]-abs[2]);
            System.out.println(ans + abs[0]+Math.max(abs[1],abs[2]));
        }
    }
}

Measured memory_bytes: 29928
import collections
import itertools

n = int(input())
ls = [input().rstrip() for _ in range(n)]
counter = collections.Counter()
for x in ls:
    x = x[0]
    if x in 'MARCH':
        counter[x] += 1

res = 0
for a, b, c in itertools.combinations('MARCH', 3):
    res += counter[a] * counter[b] * counter[c]
print(res)

Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  long long vec[100];
  for (int i = 0; i <= a; i++) {
    if (i == 0) vec[0] = 2;
    else if (i == 1) vec[1] = 1;
    else vec[i] = vec[i - 1] + vec[i - 2];
  }
  cout << vec[a] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = h1 * 60 + m1, t2 = h2 * 60 + m2;
    cout << (t2 - t1 - k) << endl;

}



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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.pb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  vector<vector<char>> s_(h+2,vector<char>(w+2,'.'));
  rep(i,h) cin>>s[i];
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#') s_[i+1][j+1]='#';
    }
  }
  vi dx={-1,0,1},dy={-1,0,1};
  REP(i,1,h+1){
    REP(j,1,w+1){
      if(s_[i][j]=='#') cout<<'#';
      else {
        int k=0;
        rep(a,3){
          rep(b,3){
            if(s_[i+dx[a]][j+dy[b]]=='#') k++;
          }
        }
        cout<<k;
      }
    }
    cout<<endl;
  }
}

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
int main()
{
	int n;
	bool f1=0,f2=0,f3=0,f4=0;
	for (int i = 0; i < 4; i++) {
		cin >> n;
		if (!f1&&n == 1)
			f1 = 1;
		else if (!f2&&n == 9)
			f2 = 1;
		else if (!f3&&n == 7)
			f3 = 1;
		else if (!f4&&n == 4)
			f4 = 1;
	}
	cout << (f1&&f2&&f3&&f4 ? "YES" : "NO") << endl;

	return 0;
}

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

int main() {
    long long A;
    long long B;
    cin >> A >> B;
    long long difference = A - (B * 2);
    if ((B * 2) >= A) {
        cout << "0" << endl;
    }
    else {
        cout << difference << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
int n;

int main(){
	IOS
	cin >> n;
	vector<int>a(n+5), b(n+5), c(n+5);
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	for(int i=1;i<=n;i++){
		cin >> b[i];
	}
	for(int i=1;i<n;i++){
		cin >> c[i];
	}
	ll sums=0;
	for(int i=1;i<=n;i++){
		sums+=b[a[i]];
		if(i!=1&&a[i]==a[i-1]+1){
			sums+=c[a[i-1]];
		}
	}
	cout << sums << '\n';
}


Measured memory_bytes: 3664
#include<iostream>
using namespace std;
int main()
{
	int N , M;
	const int n = 100000;
	int A[n];

	cin >> N >> M;

	for (int i = 0; i < M; i++)
	{
		cin >> A[i];
	}

	int count = 0;
	for (int i = 0; i < M; i++)
	{
		count += A[i];
	}
	int asobu = 0;

	if (N >= count)
	{
		asobu = N - count;
		cout << asobu;
	}
	else
	{
		cout << "-1";
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    long long n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    long long m = min({a,b,c,d,e});
    cout << (n+m-1)/m + 4 << endl;
    return 0;
}

Measured memory_bytes: 3588
use std::io::{stdin, Read};
use std::iter::FromIterator;

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, s: [String; n]);
    let c: std::collections::HashSet<String> = std::collections::HashSet::from_iter(s.into_iter());
    println!("{}", c.len());
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 21380
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            sS = System.Console.ReadLine().Trim().Split(' ');
            List<int> lstM = new List<int>();
            for (int i = 0; i < sS.Length; i++)
            {
                lstM.Add(int.Parse(sS[i]));
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstM.Sort();
            int iGcd = lstM[0];
            for (int i = 1; i < lstM.Count; i++)
            {
                iGcd = Gcd(iGcd, lstM[i]);
            }

            // 出力
            System.Console.WriteLine("{0}", iGcd.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        // 最小公倍数取得
        private static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        // 最大公約数取得
        private static int Gcd(int a, int b)
        {
            if (a < b) { return Gcd(b, a); }
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

}


Measured memory_bytes: 19296
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79032
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
#define MP make_pair
#define	pb push_back
#define x first
#define y second
#define next fake_next

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define count jaskdasbj
const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const int INF = 1e9;
const int MAX = 1 << 17;
const int mod = 1000 * 1000 * 1000 + 7;
int a[200000];
ll pref[100000];
int main()
{
	//freopen("input.txt" , "r" , stdin);
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a , a + n);
	ll curAns = 0;
	if(n % 2)
	{
		for(int i = 0; i < n; i++)
		{
			curAns += abs(a[i] - a[n / 2]);
		}
		cout << curAns;
		return 0;
	}
	else
	{
		int med1 = n / 2;
		int med2 = med1 - 1;
		ll curAns1 = 0 , curAns2 = 0;
		for(int i = 0; i < n; i++)
		{
			curAns1 += abs(a[i] - a[med1]);
		}
		for(int i = 0; i < n; i++)
		{
			curAns2 += abs(a[i] - a[med2]);
		}
		cout << min(curAns1 , curAns2);
	}


	return 0;
}



Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static int mod =1000000007;
	public static void main(String[] args) {
		int A=sc.nextInt();
		int B=sc.nextInt();
		int M=sc.nextInt();
		int a[]=new int[A];
		int b[]=new int[B];
		int minA=0,minB=0,minABC=0;
		for(int i=0;i<A;i++) {
			a[i]=sc.nextInt();
			if(i==0)minA=a[i];
			else minA=Math.min(minA, a[i]);
		}
		for(int i=0;i<B;i++) {
			b[i]=sc.nextInt();
			if(i==0)minB=b[i];
			else minB=Math.min(minB, b[i]);
		}
		int x,y,c;
		for(int i=0;i<M;i++) {
			x=sc.nextInt()-1;
			y=sc.nextInt()-1;
			c=sc.nextInt();
			if(i==0)minABC=a[x]+b[y]-c;
			else minABC=Math.min(minABC, a[x]+b[y]-c);
		}
		p(Math.min(minABC, minA+minB));
		//System.out.println(me);
		
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
}
	


Measured memory_bytes: 151940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iK = int.Parse(sS[0]);
            int iX = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            if (iK * 500 >= iX) { sOut = "Yes"; }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 11220
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] d = new int[n];
    for(int i = 0;i < n;i++)d[i]=sc.nextInt();
    int m = sc.nextInt();
    int[] t = new int[m];
    for(int i = 0;i < m;i++)t[i]=sc.nextInt();
    Arrays.sort(d);
    Arrays.sort(t);
    int cnt = 1;
    Map<Integer,Integer> map = new HashMap<>();
    for(int i = 0;i < n-1;i++){
      if(d[i]==d[i+1])cnt++;
      else{
        map.put(d[i],cnt);
        cnt=1;
      }
    }
    map.put(d[n-1],cnt);
    boolean ans = true;
    cnt=1;
    for(int i = 0;i < m-1;i++){
      if(t[i]==t[i+1])cnt++;
      else{
        if(map.get(t[i])==null)ans=false;
        else if(map.get(t[i])<cnt)ans=false;
        cnt=1;
      }
    }
    if(map.get(t[m-1])==null)ans=false;
    else if(map.get(t[m-1])<cnt)ans=false;
    System.out.println((ans)?"YES":"NO");
  }
}


Measured memory_bytes: 96228
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define inf 2e9
#define f first
#define s second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

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


int main (){
    int a,p;
    cin >> a >> p;
    cout << (a*3+p)/2 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset; // order_of_key, find_by_order

int main() {
	 ios::sync_with_stdio(0);
	 cin.tie(0);
	 cout.tie(0);
	 ll a, b, c;
	 cin >> a >> b >> c;
	 cout << b+min(c,a+b+1);
}


Measured memory_bytes: 380
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n;
vi g[N];

bool check(vi&f,int B,int skip) {
  for(int i=0,j=sz(f)-1;i<j;++i,--j) {
    if(i == skip) ++i;
    if(j == skip) --j;
    if(i < j && f[i] + f[j] > B)
      return false;
  }
  return true;
}

int dfs(int c,int fa,int B) {
  vi f;
  for(auto t : g[c]) if(t != fa) {
    f.pb(dfs(t , c , B));
  }
  if(~sz(f) & 1) f.pb(0);
  sort(all(f));
  if(!check(f , B , sz(f) - 1))
    throw 1;
  int l = -1 , r = sz(f) - 1;
  while(l + 1 < r) {
    int mid = (l + r) >> 1;
    (check(f , B , mid) ? r : l) = mid;
  }
  return f[r] + 1;
}

bool check(int B,int rt) {
  try {
    int d = dfs(rt , 0 , B);
    if(d > B + 1)
      return false;
    return true;
  } catch(...) {
    return false;
  }
}

int main(){
  scanf("%d",&n);
  rep(i,1,n) {
    int x,y;
    scanf("%d%d",&x,&y);
    g[x].pb(y);
    g[y].pb(x);
  }
  int A = 0;
  rep(i,1,n+1) A += sz(g[i]) & 1;
  int rt = 1;
  while(~sz(g[rt]) & 1) rt++;
  A >>= 1;
  int l = 0 , r = n;
  while(l + 1 < r) {
    int mid = (l + r) >> 1;
    (check(mid , rt) ? r : l) = mid;
  }
  printf("%d %d\n",A,r);
  return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

class dice
{
	int ue,mae,migi,hidari,sita,usiro;
	public:
	dice(int a,int b,int c,int d,int e,int f)
	{
		ue = a;
		mae = b;
		migi = c;
		hidari = d;
		sita = f;
		usiro = e;
	}
	void N()
	{
		swap(ue,mae);
		swap(mae,sita);
		swap(sita,usiro);
	}
	void S()
	{
		swap(ue,usiro);
		swap(usiro,sita);
		swap(sita,mae);
	}
	void E()
	{
		swap(ue,hidari);
		swap(hidari,sita);
		swap(sita,migi);
	}
	void W()
	{
		swap(ue,migi);
		swap(migi,sita);
		swap(sita,hidari);
	}
	int top()
	{
		return ue;
	}
	int right()
	{
		return migi;
	}
	int front()
	{
		return mae;
	}
	void turn_right()
	{
		swap(mae,migi);
		swap(migi,usiro);
		swap(usiro,hidari);
	}
	bool serch_turn(dice E)
	{
		for(int i = 0;i<4;i++)
		{
			turn_right();
			if(same(E))
			{
				return true;
			}
		}
		return false;
	}
	bool same(dice E)
	{
		if(mae==E.mae
		&&ue==E.ue
		&&sita==E.sita
		&&migi==E.migi
		&&hidari==E.hidari
		&&usiro==E.usiro)
		{
			return true;
		}
		return false;
	}
};



int main()
{
	int a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >>f;
	dice Di(a,b,c,d,e,f);
	int A,B,C,D,E,F;
	cin >> A >> B >> C >> D >> E >> F;
	dice Ei(A,B,C,D,E,F);
	for(int i = 0;i<1;i++)
	{
		
		//cout<<' '<<D.top()<<' '<<D.front()<<endl;
		if(Di.top()==Ei.top())
		{
			if(Di.serch_turn(Ei)){cout<<"Yes"<<endl;
			return 0;}
		}
		Di.N();
		if(Di.top()==Ei.top())
		{
			if(Di.serch_turn(Ei)){cout<<"Yes"<<endl;
			return 0;}
		}
		Di.N();
		if(Di.top()==Ei.top())
		{
			if(Di.serch_turn(Ei)){cout<<"Yes"<<endl;
			return 0;}
		}
		Di.N();
		if(Di.top()==Ei.top())
		{
			if(Di.serch_turn(Ei)){cout<<"Yes"<<endl;
			return 0;}
		}
		Di.N();
		Di.E();
		if(Di.top()==Ei.top())
		{
			if(Di.serch_turn(Ei)){cout<<"Yes"<<endl;
			return 0;}
		}
		Di.W();
		Di.W();
		if(Di.top()==Ei.top())
		{
			if(Di.serch_turn(Ei)){cout<<"Yes"<<endl;
			return 0;}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3112
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)
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]

K = ni()
print(A[K-1])



Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func sliceAtof64(sa []string) ([]float64, error) {
	si := make([]float64, 0, len(sa))
	for _, a := range sa {
		i, err := strconv.ParseFloat(a, 64)
		if err != nil {
			return si, err
		}
		si = append(si, i)
	}
	return si, nil
}

func answer(ans bool) {
	if ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func isRightTriangle(ary []float64) (ans bool) {
	sort.Sort(sort.Reverse(sort.Float64Slice(ary)))
	ans = math.Pow(ary[1], 2.0)+math.Pow(ary[2], 2.0) == math.Pow(ary[0], 2.0)

	return
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	lineCount, _ := strconv.Atoi(scanner.Text())
	lines := make([]string, lineCount)

	for i := 0; i < lineCount; i++ {
		scanner.Scan()
		lines[i] = scanner.Text()
	}

	for _, v := range lines {
		ary, _ := sliceAtof64(strings.Split(v, " "))
		answer(isRightTriangle(ary))
	}
}



Measured memory_bytes: 1216
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int m, n;
	int[][] a;

	void run(){
		for(;;){
			m=sc.nextInt();
			n=sc.nextInt();
			if((m|n)==0){
				break;
			}
			int k=sc.nextInt();
			a=new int[n][m];
			for(int i=0; i<k; i++){
				int x=sc.nextInt()-1;
				int y=sc.nextInt()-1;
				a[y][x]=1;
			}
			solve();
		}
	}

	void solve(){
		int[][] dp=new int[n][m];
		dp[0][0]=1;
		for(int j=0; j<n; j++){
			for(int i=0; i<m; i++){
				if(a[j][i]==0){
					if(j>0){
						dp[j][i]+=dp[j-1][i];
					}
					if(i>0){
						dp[j][i]+=dp[j][i-1];
					}
				}
			}
		}
		println(dp[n-1][m-1]+"");
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
//name wzq
//内容
//文件名
#include<iostream>
using namespace std;
int main()
{
	int k,a,b;
	cin>>k>>a>>b;
	int i;
	for(i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
}

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

int main(){
  int N; cin >> N;
  if(N==1){
    cout << 1 << endl;
    return 0;
  }
  //a:cin b:1つ前 count:部分列 updown: 未定(0),減少(1),増加(2) 
  int a, b, count=1, updown=0;
  bool conti=false;
  cin >> b;
  for(int i=0; i<N; i++){
    cin >> a;
    if(updown==0){
      if(a>b){
        updown=1;
      }else if(a<b){
        updown=2;
      }
    }else if(updown==1){
      if(a<b){
        updown=0;
        count++;
      }
    }else if(updown==2){
      if(a>b){
        updown=0;
        count++;
      }
    }
    b=a;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin>>s;
  sort(s.begin(),s.end());
  cout<<(s == "abc"? "Yes":"No")<<endl;
  pr("test");
  return 0;
}


Measured memory_bytes: 256
#1-nの全組み合わせをリストに登録
max = int(input())
a = ''.join(input().split())
b = ''.join(input().split())
petternArr = []

def makeArray(n,s):

  if n >= max:
    petternArr.append(s)
    return
  
  for i in range(max):
    if s.find(str(i+1)) == -1:
      tmp = s + str(i+1)
      makeArray(n+1,tmp)

makeArray(0,'')

petternArr.sort()

idxA = petternArr.index(a)
idxB = petternArr.index(b)

print(abs(idxA-idxB))

Measured memory_bytes: 47196
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
string s, t, B = "~";
bool isOK(string ss,string t)
{//sをi文字目からtと同じ文字数で切り取ったものがssとして届く
 //cout << ss<<":"<<t<<endl;
 rep(i,ss.size())
 { 
   if(ss[i]!='?'&&ss[i]!=t[i])
   {return false;}
 }
 //cout<<"true!"<<endl;
 return true;

}
int main() {
	cin >> s >> t;
	for (int i = 0; i <= (int)s.size() - (int)t.size(); i++) {
		string U = s.substr(i, t.size());
		if (isOK(U, t) == true) {
			string v = s;
			for (int j = i; j < i + t.size(); j++)v[j] = t[j - i];
			for (int j = 0; j < i; j++) { if (v[j] == '?')v[j] = 'a'; }
			for (int j = i + t.size(); j < v.size(); j++) { if (v[j] == '?')v[j] = 'a'; }
			B = min(B, v);
		}
	}
	if (B == "~")cout << "UNRESTORABLE" << endl;
	else cout << B << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_A&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    a, b = map(int, input().split())
    d = a // b
    r = a % b
    f = float(a) / float(b)

    print('{} {} {:.5f}'.format(d, r, f))



if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long S = sc.nextLong();
		long ans = Math.abs(753 - S % 1000);
		while(S >= 100) {
			S = S / 10;
			ans = Math.min(ans, Math.abs(753 - S % 1000));
		}
		System.out.println(ans);

	}

}


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

int main(){
    char s[1000],t[1000];
    int min=1001;
    cin>>s>>t;
    // scanf("%s %s", s, t);
    for(size_t i=0; i<=(strlen(s)-strlen(t)); i++){
        int count = 0;
        for(size_t j=0; j<strlen(t);j++){
            if(s[i+j] != t[j]){
                count++;
                if(count>min){
                    break;
                }
            }
            
        }
        if(min > count){
            min = count;
        }
    }
    printf("%i", min);
    return 0;
}

// cabacc
// abc

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

void solve() {
  int n; cin >> n;
  vector<string> s(n);
  vector<int> c(26, 100), count(26);
  for(int i=0; i<n; ++i) {
    cin >> s.at(i);
    vector<int> count(26);
    for(int j=0; j<s.at(i).size(); ++j) {
      count.at(s.at(i).at(j)-'a')++;
    }
    for(int j=0; j<26; ++j) {
      if(c.at(j) > count.at(j)) {
        c.at(j) = count.at(j);
      }
    }
  }
  for(int i=0; i<26; ++i) {
    char ans = i+'a';
    if(c.at(i)) {
      for(int j=0; j<c.at(i); ++j) {
        cout << ans;
      }
    }
  }
  cout << '\n';

  return;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


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


int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, X;
  cin >> N >> X;
  ll x[N];
  ll diff[N];
  for(int i = 0; i < N; i++){
    cin >> x[i];
    if(x[i] > X){
      diff[i] = x[i] - X;
    }else{
      diff[i] = X - x[i];
    }
  }

  ll ans;
  if(N == 1){
    ans = diff[0];
  }else{
    ans = diff[0];
    for(int i = 1; i < N; i++){
      ans = gcd(ans, diff[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <set>
#define setIt set <int> :: iterator
#define fi first
#define se second
using namespace std;
const int maxn = 1000006;
int p[maxn], s[maxn];
pair <int, int> seg[maxn], _seg[maxn];
set <int> mn, mx;
int main(){
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++ i)
		scanf("%d", &p[i]);
	int tp = 0;
	for (int i = 1; i <= n; ++ i){
		while (tp && p[s[tp]] > p[i])
			mn.insert(s[tp --]);
		if (i >= k){
			setIt it = mn.lower_bound(i - k + 1);
			if (it != mn.end())
				seg[i - k + 1].fi = *it;
			else
				seg[i - k + 1].fi = n + 1;
		}
		s[++ tp] = i;
	}
	tp = 0;
	for (int i = n; i; -- i){
		while (tp && p[s[tp]] < p[i])
			mx.insert(s[tp --]);
		if (i <= n - k + 1){
			setIt it = mx.upper_bound(i + k - 1);
			if (it == mx.begin())
				seg[i].se = 0;
			else
				seg[i].se = *(-- it);
		}
		s[++ tp] = i;
	}
	bool flag = false;
	int m = 0;
	for (int i = 1; i <= n - k + 1; ++ i)
		if (seg[i].fi <= seg[i].se)
			_seg[++ m] = seg[i];
		else
			flag = true;
	sort(_seg + 1, _seg + 1 + m);
	cout << unique(_seg + 1, _seg + 1 + m) - _seg - 1 + flag << endl;
}

Measured memory_bytes: 28800