akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 4) --> {1,2,3,4}
// rep(i, 4, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a[3][3];
    bool v[3][3] = {false};
    rep(i, 0, 3)
        rep(j, 0, 3)
            cin >> a[i][j];
    int n;
    cin >> n;
    while(n--)
    {
        int b; cin >> b;
        rep(i, 0, 3)
            rep(j, 0, 3)
                if (b == a[i][j])
                    v[i][j] = true;
    }
    bool res = false;
    rep(i, 0, 3)
    {
        if (v[i][0]==v[i][1] && v[i][1]==v[i][2] && v[i][2]==true)
            res = true;
        if (v[0][i]==v[1][i] && v[1][i]==v[2][i] && v[2][i]==true)
            res = true;
    }
    if (v[0][0]==v[1][1] && v[1][1]==v[2][2] && v[2][2]==true)
        res = true;
    if (v[0][2]==v[1][1] && v[1][1]==v[2][0] && v[2][0]==true)
        res = true;
    cout << (res?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vll vector<ll>
#define pb push_back
#define x first
#define y second

vector<ll> w,v;
ll dp[109][100009];

ll maxi(ll n, ll W)
{
	if(n<0 || W<=0)
		return 0;		
	if(dp[n][W]!=-1)
		return dp[n][W];
	if(w[n]>W)
		dp[n][W]=maxi(n-1,W);
	else
		dp[n][W] = max(maxi(n-1,W),maxi(n-1,W-w[n])+v[n]);
	return dp[n][W];
}

int main()
{
	ll N,W,a,b,i,j;
	cin>>N>>W;
	for(i=0;i<N;i++)
	{
		cin>>a>>b;
		w.pb(a);
		v.pb(b);
	}
	for(i=0;i<N;i++)
		for(j=0;j<=W;j++)
		{
			dp[i][j]=-1;
		}
	maxi(N-1,W);
	/*for(i=0;i<N;i++)
		for(j=0;j<=W;j++)
		{
			cout<<dp[i][j]<<' ';
		}*/
	cout<<dp[N-1][W];
}

Measured memory_bytes: 80128
A, B, M = map(int, input().split())

As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Ms = [list(map(int, input().split())) for _ in range(M)]

ans = min(As) + min(Bs)
for a, b, c in Ms:
    p = As[a-1] + Bs[b-1] - c
    ans = ans if ans < p else p
print(ans)

Measured memory_bytes: 38488
#include <stdio.h>
int main(void){
    char s[256];
    int i,count,max;
    count = max = i = 0;
    scanf("%s",s);
    while(1){
        if (s[i] == '\0'){
            break;
        }
        if (s[i] == 'A'){
            count++;
        }else if (s[i] == 'T'){
            count++;
        }else if (s[i] == 'C'){
            count++;
        }else if (s[i] == 'G'){
            count++;
        }else {
            count = 0;
        }
        if (max < count){
            max = count;
        } 
        i++;
    }
    printf("%d",max);
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String length = sc.nextLine();
		List<String> getNumsStr = Arrays.asList(sc.nextLine().split(" "));
		List<Integer> getNumsInt = new ArrayList<Integer>();

		for(String num: getNumsStr) {
			getNumsInt.add(Integer.parseInt(num));
		}

		int resultCount = 0;

		for(int i = 0; i < getNumsInt.size(); i++) {
            if(((i+1) % 2 == 1) && (getNumsInt.get(i) % 2 == 1)) {
            	resultCount++;
            }
		}
		System.out.println(resultCount);
	}
}

Measured memory_bytes: 35580
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> A(n);
    vector<int> B(n);

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

    int mx = 0;
    for (auto x : B) {
        mx = max(mx, x);
    }

    auto count = [&](int x) {
        int cnt = 0;
        for (int i = 0; i < n; ++i) {
            if (A[i] <= x) {
                ++cnt;
            }
        }
        return cnt;
    };

    auto count2 = [&](int x) {
        int cnt = 0;
        for (int i = 0; i < n; ++i) {
            if (B[i] < x) {
                ++cnt;
            }
        }
        return cnt;
    };

    auto lower = [&](int k) {
        int l = 1, r = mx;

        while (l < r) {
            auto m = (l + r) / 2;

            if (count(m) >= k) {
                r = m;
            } else {
                l = m + 1;
            }
        }
        return l;
    };

    auto upper = [&](int k) {
        int l = 1, r = mx;
        while (l < r) {
            auto m = (l + r + 1) / 2;
            if (count2(m) >= k) {
                r = m - 1;
            } else {
                l = m;
            }
        }
        return l;
    };

    long long res = 0;
    if (n & 1) {
        int l = lower((n + 1) / 2);
        int r = upper((n + 1) / 2);
        // cout << (n + 1) / 2 << " " << l << " " << r << endl;
        res = r - l + 1;
        res = max(0LL, res);
    } else {
        long long l = lower((n + 1) / 2);
        long long r = upper((n + 1) / 2);
        long long ll = lower((n + 2) / 2);
        long long rr = upper((n + 2) / 2);

        res = rr + r - (ll + l) + 1;
        res = max(0LL, res);
    }

    cout << res << '\n';


    return 0;
}

Measured memory_bytes: 4780
<?php

fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%s", $S);
fscanf(STDIN, "%d", $Q);

$new_text = [];
foreach(str_split($S) as $value){
    $new_text[] = 1 << (ord($value )- 97);
}

$ST = new SegmentTree($new_text);

while($Q--){

    fscanf(STDIN, "%d%d%s",$type, $from, $to);
    if($type === 1){

        $ST->update($from-1, (1 << (ord($to)-97)));

    }else{
        echo bitnum($ST->query($from-1, $to-1, 0, 0, $ST->size-1)).PHP_EOL;

    }

}



class SegmentTree{

    /**
     * @var array
     */
    private $tree = [];
    public $size = 0;
    private $default = 0;

    function __construct($array, $default=0){
        $count = count($array);
        $pow = floor(log($count, 2));
        $pow = (int)pow(2,$pow);
        while($count>$pow){
            $pow*=2;
        }
        $this->size = $pow;
        $this->tree = array_merge(array_fill(0,$pow-1,$default), $array, array_fill(0, $pow-$count, $default));
        $this->default = $default;
//        for($i=$this->size - intdiv($this->size,2)-1; $i < $this->size-1;$i++){
//            $this->updateUP($i);
//        }
        $this->updateAll();
    }

    function update($target, $value){
        $target = $target + $this->size -1;
        $this->tree[$target] = $value;
        $this->updateUP(intdiv($target-1, 2));

    }

    function updateUP($target){

//        while($target >=0){
//            $this->tree[$target] = $this->ev($this->tree[($target << 1) + 1], $this->tree[($target <<1) + 2]);
//            $target-=1;
//            $target>>=1;
//        }
        $this->tree[$target] = $this->ev($this->tree[($target << 1) + 1], $this->tree[($target <<1) + 2]);
        if($target != 0){
            $this->updateUP(($target-1)>>1);
        }
    }

    function updateAll(){
        for($i = $this->size-2;$i>=0;$i--){
            $this->tree[$i] = $this->ev($this->tree[$i * 2 + 1], $this->tree[$i * 2 + 2]);
        }
    }

    function query($from, $to, $node, $node_from, $node_to){

        if($node_from > $to || $node_to < $from){
            return $this->default;
        }
        if($node_to <= $to && $node_from >= $from){
            return $this->tree[$node];
        }else{
            $left = $this->query($from, $to, 2*$node + 1, $node_from, intdiv($node_from + $node_to, 2));
            $right = $this->query($from, $to, 2*$node + 2, intdiv($node_from + $node_to, 2)+1, $node_to);
            return $this->ev($left,$right);
        }


    }

    function ev($new, $comp){
        return $new | $comp;
    }

}
function bitnum($bits){
    $bits = ($bits & 0x55555555) + ($bits >> 1 & 0x55555555);
    $bits = ($bits & 0x33333333) + ($bits >> 2 & 0x33333333);
    $bits = ($bits & 0x0f0f0f0f) + ($bits >> 4 & 0x0f0f0f0f);
    $bits = ($bits & 0x00ff00ff) + ($bits >> 8 & 0x00ff00ff);
    return ($bits & 0x0000ffff) + ($bits >>16 & 0x0000ffff);
}


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

typedef long long ll;

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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N) cin >> d[i];
    ll ans = 0;
    rep(i, N) {
        for (int j = i + 1; j < N; j++) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Map.Entry;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int K = sc.nextInt();

		HashMap<Integer, Integer> counter = new HashMap<>();

		for (int i = 0; i < N; i++) {
			int ai = sc.nextInt();
			int count = counter.getOrDefault(ai, 0) + 1;
			counter.put(ai, count);
		}

		ArrayList<Integer> vals = new ArrayList<>(counter.values());
		Collections.sort(vals);

		int upto = counter.size() - K;
		int cnt = 0;
		for (int i = 0; i < upto; i++) {
			cnt += vals.get(i);
		}
		System.out.println(cnt);
		sc.close();
	}

}

Measured memory_bytes: 100328
#include<stdio.h>

int main(){

	int number,i,min=9,sum=0,x=0,temp;

	for(i=0;i<5;i++){
		scanf("%d",&number);

		if(min>((number-1)%10)){

			min=number%10;
			temp=number;
			number=x;
			x=temp;

		}


		number=(number/10+(number%10!=0?1:0))*10;

		sum+=number;

	//	printf("%d\n",sum);

	}

	sum+=x;

	printf("%d\n",sum);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;

int main(){
  int i,j,k,cnt=0;
  int n;
  string s;
  cin>>n;
  cin>>s;
  int flg=0;
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      for(k=0;k<10;k++){
        flg=0;
        for(int p=0;p<n;p++){
          if(s[p]=='0'+i && flg==0){
            flg=1;
            continue;
          }
          if(s[p]=='0'+j && flg==1){
            flg=2;
            continue;
          }
          if(s[p]=='0'+k && flg==2){
            cnt++;
            break;
          }
        }
      }
    }
  }
  cout<<cnt;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int m, k;
  cin >> m >> k;

  int max_a = pow(2, m);
  if (max_a <= k) {
    cout << -1 << '\n';
    return 0;
  }

  if (m == 0) {
    if (k == 0) {
      cout << "0 0" << '\n';
    } else {
      cout << -1 << '\n';
    }

    return 0;
  }

  if (m == 1) {
    if (k == 0) {
      cout << "0 0 1 1" << '\n';
    } else {
      cout << -1 << '\n';
    }

    return 0;
  }

  for (int i = 0; i < max_a; ++i) {
    if (i == k) {
      continue;
    }

    cout << i << ' ';
  }

  cout << k << ' ';

  for (int i = max_a - 1; i >= 0; --i) {
    if (i == k) {
      continue;
    }

    cout << i << ' ';
  }

  cout << k << '\n';
}

Measured memory_bytes: 3984
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	string s; cin >> s;
	vector<string>v = { "maerd", "remaerd" ,"esare", "resare" };
	reverse(s.begin(), s.end());

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'm') {
			if (s.substr(i, v[0].size()) == v[0])i += v[0].size() - 1;
			else { cout << "NO" << endl; return 0; }
		}
		else if (s[i] == 'r') {
			if (s.substr(i, v[1].size()) == v[1])i += v[1].size() - 1;
			else if (s.substr(i, v[3].size()) == v[3])i += v[3].size() - 1;
			else { cout << "NO" << endl; return 0; }
		}
		else if (s[i] == 'e') {
			if (s.substr(i, v[2].size()) == v[2])i += v[2].size() - 1;
			else { cout << "NO" << endl; return 0; }
		}
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  ll n, k, q;
  cin >> n >> k >> q;
  vector<ll> a(q);
  rep(i, q) {
    cin >> a[i];
    a[i]--;

  }
  vector<ll> ans(n, k-q);
  rep(i, q) ans[a[i]]++;
  rep(i, n) {
    if (ans[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 2176
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    N,H = i_map()
    l = []
    for _ in range(N):
        a,b = i_map()
        l.append([a,b])
    t = [list(i) for i in zip(*l)]
    ans = 0

    M = max(t[0])
    throw = 0
    for i in sorted(t[1], reverse=True):
        if i > M:
            throw += i
            H -= i
            ans += 1
            if H <= 0:
                print(ans)
                exit()
    i = t[0].index(M)
    # H += t[1][i]
    if H%M == 0:
        ans += H//M
    else:
        ans += H//M+1
    print(ans)


if __name__=="__main__":
    main()


Measured memory_bytes: 33316
n,m = map(int, input().split())

a = [int(i) for i in input().split()]

l = [0,2,5,5,4,5,6,3,7,6]
inf = float("INF")
dp = [-inf] * (n+10)
d = [-inf] * (n+10)
dp[0] = 0
d[0] = 0
for i in range(n):
  if dp[i] == -inf: continue
  tmp = dp[i]
  k = d[i]
  for ai in a:
    dp[l[ai] + i] = max(dp[l[ai] + i], dp[i] + k * ai, dp[i] * 10 + ai)
    d[i + l[ai]] = max(d[i + l[ai]], k + 1)
print(dp[n])


Measured memory_bytes: 52828
// Problem : F - LCS
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	string s,t;
	cin >> s >> t;
	int n=s.size(),m=t.size();
	int dp[n+1][m+1];
	memset(dp,0,sizeof(dp));
	rep(i,1,n+1)
		rep(j,1,m+1)
		{
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			if(s[i-1] == t[j-1])
				dp[i][j]=max(dp[i][j],1+dp[i-1][j-1]);
		}		
	string ans;
	// int i=n,j=m;
	// while(i>0 and j>0)
	// {
		// if(dp[i][j]==1+dp[i-1][])
		// {
// 
			// ans+=s[i-1];
			// i--,j--;
		// }
		// else if(dp[i][j] == dp[i-1][j])
		// i--;
		// else j--;
	// }
	int i=n;int j=m;
	while(i>0 && j>0){
		if(s[i-1]==t[j-1])
	    {
	        ans+=s[i-1];
	    	i--;
	        j--;
	    }
	    else
	    {
	    if(dp[i-1][j]>dp[i][j-1])
	    	i--;
	    else 
	        j--;
	    }
	}
	reverse(all(ans));
	cout <<ans ;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 73976
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;
typedef vector<ll>		VLL;
typedef vector<VLL>		VVLL;
typedef vector<VVLL>	VVVLL;

// 枝定義
struct Edge
{
	int	from;
	int	to;
	Edge(){}
	Edge(int a, int b): from(a), to(b){}
};

// dfs
vector<vector<int>>	G;
vector<int>			memo;
int dfs(int to)
{
	if (memo[to] != -1) {
		return memo[to];
	}

	int ret = 0;
	for (auto nextTo : G[to]) {
		int oneRes = dfs(nextTo) + 1;
		ret = max(ret, oneRes);
	}

	memo[to] = ret;
	return ret;
}

// メイン
int main()
{
	int N, M;
	cin >> N >> M;
	vector<Edge>	edgeList;
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		edgeList.emplace_back(a, b);
	}

	// グラフ作成
	G.clear();
	G.resize(N);
	for (int j = 0; j < M; j++) {
		const auto &edgeOne = edgeList[j];
		G[edgeOne.from].emplace_back(edgeOne.to);
	}
		
	int ans = 0;
	int startPos = 0;
	memo.clear();
	memo.resize(N, -1);
	for (int j = 0; j < N; j++) {
		int ret = dfs(j);
		ans = max(ans, ret);
	}

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


Measured memory_bytes: 8948
/* D - Div Game */

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

int main(){
  vector<int> x(5);
  for(int i = 0; i < 5; i++){
    cin >> x.at(i);
    if(x.at(i) == 0){
      cout << i + 1 << endl;
    }
  }
}


Measured memory_bytes: 3568
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define Rep(i,a,b) for (int i=(a);i<(b);i++)
using namespace std;
char s[30];
int c[30];
char ans;
bool check(){
	Rep(i,0,26)if (c[i]==0){
		ans=i+'a';
		return true;
		}
	return false;
}
int main(){
	cin >> s;
	int l=strlen(s);
	Rep(i,0,l)c[s[i]-'a']++;
	if (check()){
		printf("%s",s);
		putchar(ans);
		puts("");
		return 0;
	}
	else{
		int lst=l-1;
		while (true){
			c[s[lst]-'a']--;
			s[lst]++;while(s[lst]>'z'){lst--;if (lst<0){
				puts("-1");
				return 0;
			}
		c[s[lst]-'a']--;
		s[lst]++;
		}
			c[s[lst]-'a']++;
			if (c[s[lst]-'a']==1){
				rep(i,0,lst)putchar(s[i]);
				puts("");
				return 0;
			}
		}
	}
	puts("-1");
	return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

// void func(int N, int Q, string S, vector<int> l, vector<int> r) {}

int main() {
    int N;
    cin >> N;
    int Q;
    cin >> Q;
    string S;
    cin >> S;

    vi l(Q);
    vi r(Q);
    rep(i, Q) {
        cin >> l[i];
        cin >> r[i];
    }

    vi sum(N);
    rep(i, N - 1) {
        if (S[i] == 'A' && S[i + 1] == 'C') {
            sum[i + 1] = sum[i] + 1;
        } else {
            sum[i + 1] = sum[i];
        }
    }
    rep(i, Q) { cout << sum[r[i] - 1] - sum[l[i] - 1] << endl; }

    return 0;
}


Measured memory_bytes: 2176
package main

import (
	"fmt"
)

type point struct {
	v int
	c int
}

func main() {
	var n int
	fmt.Scan(&n)
	gm := map[int]int{}
	km := map[int]int{}
	for i := 0; i < n; i += 2 {
		var a, b int
		fmt.Scan(&a, &b)
		gm[a]++
		km[b]++
	}
	gt := point{}
	gs := point{}
	kt := point{}
	ks := point{}
	for k, v := range gm {
		if gt.c < v {
			gs = gt
			gt = point{v: k, c: v}
		} else if gs.c < v {
			gs = point{v: k, c: v}
		}
	}
	for k, v := range km {
		if kt.c < v {
			ks = kt
			kt = point{v: k, c: v}
		} else if ks.c < v {
			ks = point{v: k, c: v}
		}
	}
	m := f(gt, kt, n)
	if ks.c > 0 {
		k := f(gt, ks, n)
		m = min(m, k)
	}
	if gs.c > 0 {
		k := f(gs, kt, n)
		m = min(m, k)
		if ks.c > 0 {
			k := f(gs, ks, n)
			m = min(m, k)
		}
	}
	fmt.Println(m)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func f(p1, p2 point, n int) int {
	if p1.v == p2.v {
		return n/2 - p1.c + n/2
	}
	return n/2 - p1.c + n/2 - p2.c
}


Measured memory_bytes: 7808
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;


int main(void)
{
	string s; cin >> s;
	map<char, bool> alphabets;
	rep(i, 0, 26)alphabets['a' + i] = false;
	rep(i, 0, s.length())alphabets[s[i]] = true;
	bool none = true;
	rep(i, 0, 26) {
		if (!alphabets['a' + i]) {
			cout << (char)('a' + i) << endl;
			none = false;
			break;
		}
	}
	if (none)cout << "None" << endl;
	
	return 0;
}

Measured memory_bytes: 512
from operator import itemgetter
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=itemgetter(1), reverse=True)
CD = [tuple(map(int, input().split())) for _ in range(N)]
CD.sort(key=itemgetter(0))
use = [False] * N
for a, b in AB:
    for i, (c, d) in enumerate(CD):
        if a < c and b < d and not use[i]:
            use[i] = True
            break
print(sum(use))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;
int digit(long long n){
  int d = 0;
  while(n > 0){n /= 10; ++d;}
  return max(1, d);
}
int main(){
  long long n; int a = 1e9; cin >> n;
  rep(i, sqrt(n)) if(n % (i+1) == 0) a = min(a, digit(n/(i+1)));
  cout << a << "\n";
  return 0;
}

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

using namespace std;

#define f(i,n) for(int i=0; i < (n); i++)
#define fi(n) for(int i=0; i < (n); i++)
int main()
{
  int n;
  cin >> n;
  fi(n) {
    int t;
    cin >> t;
    if(t % 2 != 0)
      continue;
    if(t % 5 != 0 && t % 3 != 0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}

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

using namespace std;

int main(){

    int fatores[40];

    long long int n;
    cin >> n;

    if (n==1) {
        cout << 0 << endl;
        return 0;
    }

    int cont =0;
    while (n%2==0){
        fatores[cont] = 2;
        cont++;
        n/=2;
    }

    for (int i=3; i<=sqrt(n) + 1; i+=2){
        while (n%i == 0){
            fatores[cont] = i;
            cont++;
            n/=i;
        }
        if (n==1) break;
    }

    if (n>2) {
        fatores[cont] = n; cont++;
    }

    int e = 0;
    int d = 1;
    int resp = 0;

//    for (int i = 0; i < cont; i++) cout << fatores[i] << " ";

    for (int i=0; i<cont-1; i++){
        if (fatores[i] == fatores[i+1])e++;
        else {
            e++;
            while(e>=d){
                e-=d;
                d++;
            }
            d--;
            resp += d;

            d=1;
            e=0;
        }
    }

    if (fatores[cont-2] != fatores[cont-1]) resp++;
    else e++;

    while(e>=d){
        e-=d;
        d++;
    }
    d--;
    resp += d;

    cout << resp << endl;
    return 0;
}


Measured memory_bytes: 3676
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(final String[] args){
 
        final Scanner sc = new Scanner(System.in);
        long A =sc.nextInt();
        long V =sc.nextInt();
        long B =sc.nextInt();
        long W =sc.nextInt();
        long T =sc.nextInt();
        long div = Math.abs(A-B);
        long run = V-W;
        long ans =div -(run*T);
        if(ans>0){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }

        
        /* 
        long N = sc.nextLong();
        int ans=0;
        long q =2;
 
        //1だった時はさっさと終わらす
        if(N==1){
            System.out.println(0);
            return;
        }
 
        //本編
        while(q*q<=N){
            //qを決定する
            if(N%q ==0){
                //qの累積を全部発見する
                for(int i = 1; N>=Math.pow(q,i);i++){
                    if(N%Math.pow(q, i)==0){
                        //発見するたびにカウントアップ
                        ans++;
                        //発見するたびに除算
                        N = (long) (N / Math.pow(q, i));
                    }
                }
                //qの累積は見つけ尽くしたので、Nからqを完全に取り除く
                while(N%q ==0){
                    N = N/q;
                }
            }   
            q++;
        }

        //1以外の数が搾りカスとして出たら足してあげる
        if(N != 1){ans++;}
            System.out.println(ans);*/
    }
} 

Measured memory_bytes: 35532
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))
"""
A,B = nums()
P,Q,R = nums()

first_distance = P * B
pre_runned = (B - A) * Q
time = B + (first_distance - pre_runned) / (R + Q)
print(time)
"""
"""
N = num()
randoms = nums()
ans = 0
for i in range(N):
    today = randoms[i]
    if i == 0:
        continue
    if today > randoms[i-1]:
        ans += 1
print(ans)
"""
"""
N = num()
members = []
for i in range(N):
    members.append(input())

ans = members.count("E869120")
print(ans)
"""
"""
N = num()
V = nums()
V.sort(reverse=True)
ans = 0
for i in range(N):
    Vi = V[i]
    ans += (Vi - i -1)
print(ans)
"""

N = num()
A = nums()
ans_max = N
ans_min = 0
old_i = 0
for i in A:
    if not i > old_i:
        ans_min += 1
    old_i = i
ans_min += 1
print(ans_min)
print(ans_max)


Measured memory_bytes: 16660
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  cout << (n-2)*180 << endl;
  return 0;
}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 998244353
typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll n,p;	cin>>n>>p;
	
	if(n==1){
		cout<<p<<'\n';
		return 0;
	}
	ll ans=1;
	for(ll i=2;i<=1e6;i++){
		ll cnt=0;
		while(p%i==0){
			p/=i;
			cnt++;
		}
		cnt/=n;
		while(cnt){
			ans*=i;
			cnt--;
		}
	}
	cout<<ans<<'\n';
	
	return 0;
}


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

int main() {
    int n; cin >> n;
    int max = -1001001001;
    int min = 1001001001;

    rep(i, n){
        int x; cin >> x;

        if (i != 0 && x - min > max) max = x - min;

        if (x < min) min = x;
    }

    cout << max << endl;
}


Measured memory_bytes: 3120
#include<iostream>
#define N 50
using namespace std;
/*
Hanafuda Shuffle
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1129&lang=jp

*/
int array[N];
void makearray(int n){
    for(int i=0;i<N;i++){
	array[i]=n;
	if(n>0)n-=1;
    }
}
void shuffle(int p, int c){
    int sarray[N];
    //copy unshuffled deck
    for(int i=p-1+c;i<N;i++){
	sarray[i]=array[i];
    }
    //copy the c part
    int j=0;
    for(int i=p-1;i<p-1+c;i++){
	sarray[j]=array[i];
	j++;
    }
    // copy the p part
    j=c;
    for(int i=0;i<p-1;i++){
	sarray[j]=array[i];
	j++;
    }
    for(int i=0;i<N;i++){
	array[i]=sarray[i];
    }
}
    
    
    
int main(){
    int n,r, p, c;
    while(1){
	cin >>n>>r;
	makearray(n);
	if(n==0 && r==0)break;
	for(int i=0;i<r;i++){
	    cin >> p>>c;
	    shuffle(p,c);
	}
	cout << array[0] << endl;
    }
    
}

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

using namespace std;



void solver() {
    int n; cin >> n;
    
    vector<int> a(n), pref(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        pref[i] = a[i];
        if (i) pref[i] ^= pref[i - 1];
    }
    vector<int> suff(n);
    for(int i = n - 1; i >= 0; --i) {
        suff[i] = a[i];
        if (i + 1 < n) suff[i] ^= suff[i + 1];
    }

    for(int i = 0; i < n; ++i) {
        int L = (i ? pref[i - 1] : 0);
        int R = (i + 1 < n ? suff[i + 1] : 0);
        cout << (L ^ R) << " \n"[i == n - 1];
    }

}

int main() {

    ios_base :: sync_with_stdio(0); cin.tie(NULL);

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

    return 0;
}

Measured memory_bytes: 5392
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

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

    for(int i=1; i<=n; i++){
        if(i%3==0){
            cout<<" "<<i;
            continue;
        }
        
        string s=to_string(i);
        REP(j,s.size()){
            if(s[j]=='3'){
                cout<<" "<<i;
                break;
            }
        }
        
    }

    cout<<endl;
}


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

int main()
{
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
    string c[3];

    REP(i, 3)
    {
            cin >> c[i];
    }

    cout << c[0].at(0) << c[1].at(1) << c[2].at(2) << endl;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// 期待値・累積和
// https://drken1215.hatenablog.com/entry/2020/02/10/235800
// https://qiita.com/drken/items/56a6b68edef8fc605821

func main() {
	N := nextInt()
	K := nextInt()
	Pn := make([]int, N)
	Csum := make([]int, N+1)
	var ans int
	// (p+1)/2 がサイコロの期待値。2で割るのは最後にして、まずはpi+1を配列に入れる
	for i := range Pn {
		Pn[i] = nextInt()
		Pn[i]++
	}
	// 累積和
	for i, Pi := range Pn {
		Csum[i+1] = Csum[i] + Pi
	}

	for i := 0; i+K <= N; i++ {
		sum := Csum[i+K] - Csum[i]
		if ans < sum {
			ans = sum
		}
	}
	// fmt.Printf("%.7f\n", float64(sans)/2)
	fmt.Println(float64(ans) / 2)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


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


int main() {
  int H,W,A,B;
  cin >> H >> W >> A >> B;
  
  for(int i=0; i<H; i++){
    if(i<B){
      for(int j=0; j<W; j++){ if(j<A){ cout << 1; } else { cout << 0; } } 
    }else {
      for(int j=0; j<W; j++){ if(j<A){ cout << 0; } else { cout << 1; } } 
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n, k; cin >> n >> k;
	VI p(n); REP(i, n)cin >> p[i];
	double ans = 0;
	int sum = k;
	REP(i, k)
		sum += p[i];
	for(int i = 0;1;i++) {
		ans = max(ans, (double)sum / 2);
		if (i + k >= n)break;
		sum += p[i + k];
		sum -= p[i];
	}
	cout << setprecision(10) << ans;
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
using namespace std;
const double PI = acos(-1);

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

    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double th = double(h*60 + m) / 720 * 2*PI;
    double tm = double(m) / 60 * 2*PI;
    double xh = cos(th) * a;
    double yh = sin(th) * a;
    double xm = cos(tm) * b;
    double ym = sin(tm) * b;
    double dist = hypot(xh - xm, yh - ym);
    printf("%.9f\n", dist);
    return 0;
}


Measured memory_bytes: 4064
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long h, n, i, j, k, x, s;
	cin >> n >> k; 
	vector<long long> a(n);
	for (i = 0; i < n; i++) cin >> a[i];
	sort(a.rbegin(), a.rend());
	s = 0;
	for (i = k; i < n; i++) s += a[i];

	cout << s << "\n";

	return 0;
}


Measured memory_bytes: 2552
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
 
using namespace std;
    
int main()
{
    int sum=0;
    int c;
    while((c = getchar()) != EOF){
        if('0' <= c && c <= '9'){
            sum += c-'0';
        }
    }
    cout << (sum%9 ? "No" : "Yes") << endl;
    
    return 0;
}

Measured memory_bytes: 3040
//======================================
//author @Amit Singh : global_const
//======================================

#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
template <class Key, class T, class Compare, class Alloc>
  bool operator== ( const map<Key,T,Compare,Alloc>& lhs,const map<Key,T,Compare,Alloc>& rhs );
template <class Key, class T, class Compare, class Alloc>
  bool operator!= ( const map<Key,T,Compare,Alloc>& lhs,const map<Key,T,Compare,Alloc>& rhs );
template <class Key, class T, class Compare, class Alloc>
  bool operator<  ( const map<Key,T,Compare,Alloc>& lhs,const map<Key,T,Compare,Alloc>& rhs );	
template <class Key, class T, class Compare, class Alloc>
  bool operator<= ( const map<Key,T,Compare,Alloc>& lhs,const map<Key,T,Compare,Alloc>& rhs );
template <class Key, class T, class Compare, class Alloc>
  bool operator>  ( const map<Key,T,Compare,Alloc>& lhs,const map<Key,T,Compare,Alloc>& rhs );	
template <class Key, class T, class Compare, class Alloc>
  bool operator>= ( const map<Key,T,Compare,Alloc>& lhs,const map<Key,T,Compare,Alloc>& rhs );
#define yeah ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define vi vector<int>
#define pb push_back
#define loop(i,n) for(int i=0;i<n;++i)
#define pii pair<int,int>
#define mp make_pair
int main()
{ yeah;
  int a;
  int b;
  cin>>a>>b;
  cout<<a*b<<endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;

int n, r;

struct opt {
	int p, c;
};

vector<opt> V;

int main() {
	while(cin >> n >> r, n | r) {
		V.clear();

		rep(i, r) {
			opt o;
			cin >> o.p >> o.c;
			V.push_back(o);
		}

		int a = 1;
		repd(i,V.size()-1,0) {
			if(a <= V[i].c) {
				a += V[i].p-1;
			} else {
				if(a - V[i].c <= V[i].p - 1) {
					a = a - V[i].c;
				}
			}
		}
		printf("%d\n", n-a+1);
	}
}

Measured memory_bytes: 1188
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Point[] point = new Point[n];
        for (int i = 0; i < n; i++) {
            point[i] = new Point();
        }
        int[] index = new int[n - 1];
        
        // 自分に子を割り当てる
        for (int i = 0; i < n - 1; i++) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            index[i] = q;   // 出力順を記憶する
            
            point[p].children.add(q);
        }
        
        // 自分の子を若い色から塗る
        for (int i = 0; i < n; i++) {
            int nowColor = 1;
            int myColor = 0;
            if (i != 0) {
                myColor = point[i].color;
            }
            
            for (Integer child : point[i].children) {
                if (nowColor == myColor) {
                    nowColor++;
                }
                
                point[child].color = nowColor;
                nowColor++;
            }
        }
        
        // 必要な最小色数を出力
        int max = 0;
        for (Point p : point) {
            max = Math.max(max, p.color);
        }
        System.out.println(max);
        
        // 子の色を出力順に出力
        for (int i = 0; i < n - 1; i++) {
            System.out.println(point[index[i]].color);
        }
        
    }
    
    public static class Point {
        int color;
        List<Integer> children;
        
        Point() {
            this.children = new ArrayList<Integer>();
        }
    }
}


Measured memory_bytes: 97200
#include <stdio.h>
#define N 3000
#define S 3000
#define MOD 998244353
long long dp[N+1][S+1];
int a[N];

int main(){
  int n,s;
  int i,j;
  scanf("%d %d", &n, &s);
  for(i=0;i<n;i++)scanf("%d", &a[i]);

  dp[0][0]=1;

  for(i=0;i<n;i++){
    for(j=0;j<=S;j++){
      dp[i+1][j] += 2*dp[i][j];//tにi個選ぶ時それぞれのiについてuに選ぶ選ばないの2通りなのでこれで良い
      dp[i+1][j]%=MOD;
      if(j+a[i] <= S){
        dp[i+1][j+a[i]] += dp[i][j];
        dp[i+1][j+a[i]]%=MOD;
      }
    }
  }


    printf("%lld\n", dp[n][s]);

  return 0;
}


Measured memory_bytes: 72032
#!/usr/bin/env python3
import sys
import itertools

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


def main():
    N, M, X = lmi()
    CA = llmi(N)

    def get_cost(set_of_bought):
        ans = 0
        for s in set_of_bought:
            ans += CA[s][0]
        return ans

    def check(set_of_bought):
        XX = [0] * M
        for s in set_of_bought:
            for i in range(M):
                XX[i] += CA[s][i + 1]
        if all(v >= X for v in XX):
            return True
        return False
    ans = INF
    for i in range(1 << N):
        cur = set()
        for n in range(N):
            if i>>n & 1:
                cur.add(n)
        # print(cur)

        if check(cur):
            ans = min(ans,get_cost(cur))
    if ans == INF:
        print(-1)
    else:
        print(ans)



if __name__ == '__main__':
    main()


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

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

  int h, w;
  cin >> h >> w;
  vector<vector<char>> grid(h + 2, vector<char>(w + 2, '-'));
  for (int i = 1; i < h + 1; i++) {
    for (int j = 1; j < w + 1; j++) {
      cin >> grid[i][j];
    }
  }
  vector<vector<int>> res(h + 2, vector<int>(w + 2, 0));
  for (int i = 1; i < h + 1; i++) {
    for (int j = 1; j < w + 1; j++) {
      if (grid[i][j] == '.') continue;
      for (int di = -1; di <= 1; di++) {
        for (int dj = -1; dj <= 1; dj++) {
          if (di == 0 && dj == 0) continue;
          res[i+di][j+dj]++;
        }
      }
    }
  }
  for (int i = 1; i < h + 1; i++) {
    for (int j = 1; j < w + 1; j++) {
      if (grid[i][j] == '#') cout << '#';
      else cout << res[i][j];
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    if(a>=1 && a<=20 && b>=1 && b<=20)
    {
        if(a>=1 && a<=9 && b>=1 && b<=9)
        {
        int mul= a*b;
        cout << mul << endl;
        }
        else cout << -1 << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;
const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, l, ans = 0;
  ll n, k, syuuki;
  cin >> n >> k;
  vector<ll> a(n), when(n, -1);
  for (i = 0; i < n; i++)
  {
    cin >> a[i];
    a[i]--;
  }
  i = 0;
  ll num = 0;
  while (when[i] == -1)
  {
    if (num == k)
    {
      cout << i + 1;
      return 0;
    }
    //cout << num << " " << i << endl;
    when[i] = num;
    i = a[i];

    num++;
  }
  //cout << num << " " << i << endl;
  ll saisyo = when[i];
  syuuki = num - saisyo;
  //cout << endl;
  //cout << " saisyo " << saisyo << "  ato " << num << " syuuki " << syuuki;
  k -= (saisyo);
  k %= syuuki;
  //cout << " amari " << k << endl;
  for (i = 0; i < n; i++)
  {
    if (when[i] == saisyo + k)
    {
      cout << i + 1;
      return 0;
    }
  }
  // //cout << ans << endl;
}


Measured memory_bytes: 6404
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  vch A(7);
  st s="keyence";
  st t;
  ci(t);
  ll a=t.sz;
  bl b=false;
  
  if(t.substr(0,7)==s) b=true;
  else if(t.substr(a-7,7)==s) b=true;
  else{
    FOR(i,1,7){
      if(s.substr(0,i)==t.substr(0,i)&&s.substr(i,7-i)==t.substr(a-7+i,7-i)){
        b=true;
      }
    }
  }
    if(b){
      co("YES")
    }
    else{
      co("NO")
    }
  }

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

int main(){
	double d;
	cin>>d;
	  cout << fixed<< setprecision(10);
	if(d<1 ){
		cout<<d*sqrt(2)<<endl;
	}
	else cout<<max( (double)((int)(d+1) ),d*sqrt(2) ) <<endl;
	return 0;
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    double x, y;
    cin >> x >> y;
    cout << x / y << endl;
    return 0;
}


Measured memory_bytes: 256
N,W = map(int,input().split())
import copy
dp = [0]*(W+1)
for _ in range(N):
    dpc = copy.deepcopy(dp)
    w,v = map(int,input().split())
    if w > W:
        continue
    else:
        for j in range(w,W+1):
            if dpc[j] < dpc[j-w]+v:
                dp[j] = dpc[j-w]+v
print(dp[W])

Measured memory_bytes: 124016
fun main (args : Array<String>) {
	val (age1, money1) = readLine()!!.split(" ").map(String::toInt)
	var age2 : Int = age1.toInt()
	var money2 : Int = money1.toInt()
	return if (age2 >= 13) {
		println("${money2}")
	} else if ((age2 >= 6) && (age2 <= 12)) {
		println("${money2/2}")
	} else {
		println("0")
	}
}

Measured memory_bytes: 36080
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int n = 25 - a;
        String ans = "Christmas";
        for(int i = 0; i < n; i++) {
          ans += " Eve";
        }
    
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 22612