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

class Program
{
    static void Main(string[] args)
    {
        Dice dice = new Dice(Console.ReadLine());

        string operation = Console.ReadLine();

        foreach (char ch in operation.ToCharArray())
            dice.OperationMove(ch);

        Console.WriteLine(dice.GetTopNum());
    }
}

/// <summary>
/// ??????????????????
/// </summary>
public class Dice
{
    /// <summary>
    /// ????????????????????????
    /// </summary>
    private int _top;
    /// <summary>
    /// ????????????????????????
    /// </summary>
    private int _under;
    /// <summary>
    /// ????????????????????????
    /// </summary>
    private int _left;
    /// <summary>
    /// ????????????????????????
    /// </summary>
    private int _right;
    /// <summary>
    /// ????????????????????????
    /// </summary>
    private int _front;
    /// <summary>
    /// ????????????????????????
    /// </summary>
    private int _back;

    /// <summary>
    /// ????????????????????? int??????
    /// </summary>
    public Dice(int[] ary)
    {
        SetDice(ary);
    }

    /// <summary>
    /// ????????????????????????string
    /// </summary>
    /// <param name="str"></param>
    public Dice(string str)
    {
        int[] ary = str.Split(' ').Select(s => int.Parse(s)).ToArray();
        
        SetDice(ary);
    }

    /// <summary>
    /// ???????????????????????????
    /// </summary>
    /// <param name="ary"></param>
    private void SetDice(int[] ary)
    {
        _top = ary[0];
        _front = ary[1];
        _right = ary[2];
        _left = ary[3];
        _back = ary[4];
        _under = ary[5];
    }

    /// <summary>
    /// ?§??????????
    /// </summary>
    public void OperationMove(char direction)
    {
        switch (direction)
        {
            case 'E': MoveE(); break;
            case 'N': MoveN(); break;
            case 'S': MoveS(); break;
            case 'W': MoveW(); break;
        }
    }

    /// <summary>
    /// E??????????§????
    /// </summary>
    public void MoveE()
    {
        int tmp = _top;
        _top = _left;
        _left = _under;
        _under = _right;
        _right = tmp;
    }
    /// <summary>
    /// N??????????§????
    /// </summary>
    public void MoveN()
    {
        int tmp = _top;
        _top = _front;
        _front = _under;
        _under = _back;
        _back = tmp;
    }
    /// <summary>
    /// S??????????§????
    /// </summary>
    public void MoveS()
    {
        int tmp = _top;
        _top = _back;
        _back = _under;
        _under = _front;
        _front = tmp;
    }
    /// <summary>
    /// W???????§????
    /// </summary>
    public void MoveW()
    {
        int tmp = _top;
        _top = _right;
        _right = _under;
        _under = _left;
        _left = tmp;
    }
    
    /// <summary>
    /// ??????????????????????????????????????????
    /// </summary>
    /// <returns></returns>
    public int GetTopNum()
    {
        return _top;
    }
}

Measured memory_bytes: 9524
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    static int h, w;
    static int[] dx, dy;
    static int[,] map;
    public static void Main()
    {
        dx = new int[] { 0, 1, 1, 1, 0, -1, -1, -1 };
        dy = new int[] { 1, 1, 0, -1, -1, -1, 0, 1 };
        string[] line = Console.ReadLine().Trim().Split(' ');
        h = int.Parse(line[0]);
        w = int.Parse(line[1]);
        map = new int[h, w];
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < w; j++)
                if (s[j] != '.') map[i, j] = int.Parse(s[j].ToString());
        }
        var ans = getAns();
        Console.WriteLine(ans);
    }
    static int getAns()
    {
        var a = getA();
        if (a.Count() == 0) return 0;
        var b = new List<int>();
        var count = 1;
        changeSand(a);
        while (true)
        {
            AtoB(a, b);
            if (b.Count() == 0) return count;
            b = b.Distinct().ToList();
            changeSand(b);
            count++;
            AtoB(b, a);
            if (a.Count() == 0) return count;
            a = a.Distinct().ToList();
            changeSand(a);
            count++;
        }
    }
    static void AtoB(List<int> a, List<int> b)
    {
        b.Clear();
        foreach (var x in a)
        {
            for (int i = 0; i < 8; i++)
            {
                var nx = x / w + dx[i];
                var ny = x % w + dy[i];
                var nmp = map[nx, ny];
                if (nmp >= 1 && nmp <= 8)
                {
                    var count = 0;
                    for (int j = 0; j < 8; j++)
                    {
                        var nnx = nx + dx[j];
                        var nny = ny + dy[j];
                        if (nnx >= 0 && nnx < h && nny >= 0 && nny < w &&
                            map[nnx, nny] == 0)
                        {
                            count++;
                            if (count >= nmp) { b.Add(nx * w + ny); break; }
                        }
                    }
                }
            }
        }
    }
    static void changeSand(List<int> a)
    {
        foreach (var x in a)
            map[x / w, x % w] = 0;
    }
    static List<int> getA()
    {
        var a = new List<int>();
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
            {
                var mp = map[i, j];
                if (mp >= 1 && mp <= 8)
                {
                    var count = 0;
                    for (int k = 0; k < 8; k++)
                    {
                        var nx = i + dx[k];
                        var ny = j + dy[k];
                        if (map[nx, ny] == 0)
                        {
                            count++;
                            if (count >= mp) { a.Add(i * w + j); break; }
                        }
                    }
                }
            }
        return a;
    }
}


Measured memory_bytes: 26208
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
mod = 10**9+7
dp = [1]*(n+1)
for i in a:
    dp[i] = 0
for i in range(2, n+1):
    if dp[i] > 0:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[n])

Measured memory_bytes: 50008
n=gets.chomp.to_i

ans = 0
2.upto(n) do |m|
    next if m%2==0
    pf = Hash.new(0)
    i=2
    mm=m
    while m>=i**2
        if mm%i==0
            pf[i]+=1
            mm/=i
        else
            i+=1
        end
    end
    c=1
    pf.each do |k,v|
        c*=(v+1)
    end
    if c == 8
        ans +=1
    end
end

puts ans

Measured memory_bytes: 1788
w,h,n=map(int,input().split())
lx=0
rx=w
sy=h
iy=0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        lx=max(lx,x)
    elif a==2:
        rx=min(rx,x)
    elif a==3:
        iy=max(iy,y)
    else:
        sy=min(sy,y)
x=rx-lx
y=sy-iy
if x<0 or y<0:
    print(0)
    exit()
print(x*y)

Measured memory_bytes: 61644
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <tuple>

using namespace std;

using int64 = long long;

const int64 INF = (1LL<<60);

int N;

void back(int at, int x, string S) {
    if (at == N) {
        cout << S << "\n";
        return;
    }

    for (int i = 0; i <= x + 1; i++) {
        back(at + 1, (i == x + 1 ? x + 1 : x), S + string(1, 'a' + i));
    }
}

int main() {
    cin >> N;

    back(0, -1, "");

    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#define MAX 2000
#define max 20
#define false 0
#define true 1

int solve(int, int);
int n,A[MAX];


int main(){

	int i,q,x;

	scanf("%d",&n);
	for(i = 0; i < n; i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i = 0; i < q; i++){
		scanf("%d",&x);
		if(solve(0,x) == false) printf("no\n");
		else printf("yes\n");
	}
	return 0;
}

   int solve(int i, int m){

   	int res;

   if(m == 0) return true;
   if(i >= n) return false;
   res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;

}

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

int main() {
	ios :: sync_with_stdio(false);
	for(int n; cin >> n; ) {
		for(int i = 0; i < 10; i ++) if((n >> i) & 1) {
			n -= (1 << i);
			cout << (1 << i) << (n ? ' ' : '\n');
		}
	}
	return 0;
}

Measured memory_bytes: 3164
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#include <cstdint>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long solve(long n, long m, std::vector<long> p, std::vector<long> c){
    std::vector<bool> used(n, false);
    std::vector<std::vector<long> > arrays;
    for(int i = 0; i < n; i++){
        if(used[i]){
            continue;
        }
        arrays.push_back(std::vector<long>());
        long vis = i;
        do{
            arrays[arrays.size()-1].push_back(vis);
            used[vis] = true;
            vis = p[vis];
        }while(vis != i);
    }
    /*
    for(int i = 0; i < arrays.size(); i++){
        for(int j = 0; j < arrays[i].size(); j++){
            printf("%ld ", arrays[i][j]);
        }
        printf("\n");
    }
    //*/
    long ans = -LINF;
    for(int i = 0; i < arrays.size(); i++){
        //printf("loop #%d\n", i);
        long loopsize = arrays[i].size();
        std::vector<long> accum_sum(loopsize+1, 0);
        for(int j = 0; j < loopsize; j++){
            accum_sum[j+1] = accum_sum[j] + c[arrays[i][j]];
        }
        //printf("  %ld\n", accum_sum[loopsize]);
        for(int j = 0; j < loopsize; j++){//num to add
            if(j == 0 && accum_sum[loopsize] < 0){
                continue;
            }
            for(int k = 0; k < arrays[i].size(); k++){//starting point
                long sum;
                if(k + j <= loopsize){
                    sum = accum_sum[k+j] - accum_sum[k];
                }else{
                    sum = accum_sum[(k+j) % loopsize] - accum_sum[k] + accum_sum[loopsize];
                }
                long res;
                if(m % loopsize >= j){
                    res = std::max(0l, accum_sum[loopsize]*(m/loopsize)) + sum;
                }else if(m / loopsize > 0){
                    res = std::max(0l, accum_sum[loopsize]*(m/loopsize - 1)) + sum;
                }
                /*
                if(res > ans){
                    printf("%ld %ld, %ld %ld\n", k, j, sum, res);
                }
                //*/
                ans = std::max(ans, res);
            }
        }
    }
    return ans;
}

int main(){
    long n, k;
    scanf("%ld%ld", &n, &k);
    std::vector<long> p(n);
    std::vector<long> c(n);
    for(int i = 0; i < n; i++){
        std::cin >> p[i];
        p[i]--;
    }
    for(int i = 0; i < n; i++){
        std::cin >> c[i];
    }
    printf("%ld\n", solve(n, k, p, c));
}


Measured memory_bytes: 4032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] h = new int[n];
		for(int i=0;i<n;i++) h[i] = in.nextInt();
		boolean ans = true;
		for(int i=1;i<n;i++) {
			if(-h[i]+h[i-1]>=2) {
				ans = false;
				break;
			}else if(-h[i]+h[i-1]==1) {
				h[i]++;
			}
		}
		System.out.println(ans?"Yes":"No");
		in.close();

	}

}


Measured memory_bytes: 48728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <stdlib.h>
#include <math.h>
using namespace std;

int func(vector<int> y, vector<int> z)
{
	int result = 0;
	for (int i = 0; i < y.size(); i++)
	{
		result += pow(y[i] - z[i], 2);
	}

	double ans = sqrt(result);
	int ians = ans;

	if (ans - ians == 0)
	{
		return 1;
	}

	return 0;
}

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

	vector<vector<int>> x(N);

	for (int i = 0; i < N; i++)
	{
		vector<int> n(D);
		for (int j = 0; j < D; j++)
		{
			cin >> n[j];
		}
		x[i] = n;
	}

	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (j == i)
			{
				continue;
			}

			cnt += func(x[i], x[j]);
		}

	}

	cout << cnt / 2 << endl;
	
	return 0;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		// 返済期間
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int week = Integer.parseInt(br.readLine());
		// 負債額
		int debt = 100000;
		// 利率
		double rate = 1.05;
		// 切り上げ単位
		int roundUp = 1000;

		// 負債額を切り上げ単位で割った値で計算する。（ 1,000 円未満切り上げのため）
		int debt_k = debt / roundUp;

		for (int i = 0; i < week; i++) {
			debt_k = (int) (Math.ceil(debt_k * rate));
		}

		// 出力
		// 切り上げ単位で割っていた値を元に戻す。
		System.out.println(debt_k * roundUp);
	}
}

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

int main() {
  int n, m;
  cin >> n >> m;
  string ans = "Yes";
  if (n != m) ans = "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        long res = 360 / gcd(360, x);
        System.out.println(res);

    }

    static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

}

Measured memory_bytes: 35748
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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 int INF = 1e18;

signed main(){
    int n, k; cin >> n >> k;
    vector<int> a(n), f(n);
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> f[i];
    sort(all(a));
    sort(rall(f));
    int ok = INF, ng = -1;
    while(ok-ng > 1){
        int mid = (ok+ng)/2;
        int count = 0;
        REP(i,n){
            if(a[i]*f[i] > mid) count += a[i]- mid/f[i];
        }
        if(count > k) ng = mid;
        else ok = mid;
    }
    cout << ok << endl;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x, y;
  x = a + b;
  y = c + d;
  if (x == y) {
    cout << "Balanced" << endl;
  } else if (x > y) {
    cout << "Left" << endl;
  } else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
struct city{
    int x,y,id;
}c[100005];
struct E{
    int u,v,next,w;
}edge[100005 * 4];
int head[100005];
int cnte;
bool vst[100005];
int n,m;
int fa[100005];
const int INF = 1e9+7;
bool cmp1(city c1, city c2) {
    return c1.x < c2.x;
}
bool cmp2(city c1, city c2) {
    return c1.y < c2.y;
}
inline int findfa(int x) {return fa[x] == x ? fa[x] : fa[x] = findfa(fa[x]);}
void addedge(int u,int v,int w) {
    edge[cnte].u = u;edge[cnte].v = v;
    edge[cnte].w = w;edge[cnte].next = head[u];
    head[u] = cnte++;
}
bool cmp3(E e1, E e2) {
    return e1.w < e2.w;
}
int dis(int x,int y) {
    return min(abs(c[x].x - c[y].x), abs(c[x].y - c[y].y));
}
int main() {
    while(cin >> n) {
        for(int i = 1;i <= n;i++) {
            cin >> c[i].x >> c[i].y;c[i].id = i;
            head[i] = -1;fa[i] = i;
        }
        cnte = 0;
        sort(c+1,c+1+n,cmp1);
        for(int i = 1;i < n;i++) {
            addedge(c[i].id,c[i+1].id,dis(i,i+1));
        }
        sort(c+1,c+1+n,cmp2);
        for(int i = 1;i < n;i++) {
            addedge(c[i].id,c[i+1].id,dis(i,i+1));
        }
        sort(edge,edge+cnte,cmp3);
        for(int i = 1;i <= n;i++) {
            vst[i] = false;
        }
        int tnc = 0;
        LL ans = 0;
        for(int i = 0;i < cnte;i++) {
            //printf("%d %d %d\n",edge[i].u,edge[i].v,edge[i].w);
            int x = edge[i].u, y = edge[i].v;
            int fx = findfa(x), fy = findfa(y);
            if(fx == fy) continue;
            fa[fx] = fy;tnc++;
            ans += edge[i].w;
            if(tnc == n-1) break;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 6528
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////

void solve() {
	int X, Y;
	cin >> X >> Y;
	cout << X + Y / 2 << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    
    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        var input = Reads();
        var a = input[0];
        var b = input[1];
        var k = input[2];
        if (k <= a)
            Console.WriteLine("{0} {1}", a - k, b);
        else if (k <= a + b)
            Console.WriteLine("0 {0}", a + b - k);
        else
            Console.WriteLine("0 0");

        Console.Out.Flush();
    }
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



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

	int n, k;
	cin >>n >>k;
	VI x(n), y(n), c(n);
	
	vector<VI> d(2*k, VI(2*k, 0));
	rep(i,n){
		int xx,yy, zx,zy; char cc;
		cin >>xx >>yy >>cc;
		if(cc=='W')  zx= (xx+k)%(2*k);
		else zx = xx%(2*k);
		zy = yy%(2*k);
		d[zy][zx]++;
	}
	vector<VI> sk(2*k+5, VI(2*k+5, 0));
  rep(i,2*k) rep(j,2*k){
		sk[i+1][j+1] = sk[i][j+1] + sk[i+1][j] - sk[i][j] + d[i][j];
	}
	
	ll ans =0;
	rep(i, k) rep(j, k){
		int by[]={0,i,i+k,2*k}, bx[]={0,j,j+k,2*k};
		ll w=0;
		rep(p1, 3) rep(p2, 3) if((p1+p2)%2){
			w += sk[by[p1+1]][bx[p2+1]] - sk[by[p1+1]][bx[p2]] 
			     - sk[by[p1]][bx[p2+1]]  + sk[by[p1]][bx[p2]];
		}
		ans = max(ans, w);
		ans = max(ans, n-w);
	}
	cout << ans <<"\n";
	
	return 0;
	
}


Measured memory_bytes: 32896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	string s, p;
	cin >> s >> p;

	s += s;
	for (int i = 0; i < s.size() - p.size() + 1; i++) {
		string tmp = "";
		for (int j = 0; j < p.size(); j++) {
			tmp += s[i + j];
		}
		if (tmp == p) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std;

int main(void) {
	int a, b;
	while (cin >> a) {
		cin >> b;
		int sum = a + b;
		int count = 1;
		while (sum / 10 > 0) {
			count++;
			sum /= 10;
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
typedef long long int ll;
using namespace std;

ll dp[1000005];

void add(vector<int>g[],int u,int v)
{
	g[u].push_back(v);
}

ll go(vector<int>g[],ll n)
{
	if (g[n].size()==0)
	return 0;
	else if (dp[n]!=-1)
	return dp[n];
	else
	{
		ll x=0;
		ll m=0;
		for (int i=0;i<g[n].size();i++)
		{
		m=max(m,go(g,g[n][i]));
		}
		x=m+1;
		dp[n]=x;
		return x;
	}
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vector<int> g[n+5];
    ll a[m+5][5];
    for (int i=1;i<=m;i++)
    {
    	cin>>a[i][0]>>a[i][1];
	}
	
	
	for (int i=1;i<=m;i++)
	{
		add(g,a[i][0],a[i][1]);
	}
	memset(dp,-1,sizeof(dp));
	
	ll k=0;
	for (int i=1;i<=n;i++)
	k=max(k,go(g,i));
	cout<<k<<endl;
	
	

}


Measured memory_bytes: 19456
package main

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

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	var ans int
	n := atoi(nextSlice())
	for _, a := range n {
		ans += a
	}
	if ans == 1 {
		ans *= 10
	}
	fmt.Println(ans)
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), "")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

// ---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

// ---------------------------------------------------

func yesOrNo(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

func yesorNO(b bool) {
	if b {
		reply = "YES"
		fmt.Println(reply)
		return
	}
	reply = "NO"
	fmt.Println(reply)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define LONG LLONG_MAX/3;
#define INT INT_MAX/3;
#define mod 1000000007
#define S second
#define F first
#define int long long
using namespace std;
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
signed main(){
	int a,b;
	cin>>a>>b;
	if(b%2){
		int c=a/b;
		cout<<c*c*c<<endl;
	}
	else{
		int c=(a+b/2)/b,d=a/b;
		cout<<c*c*c+d*d*d<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
struct rollinghash{
  string S;
  ull B;
  vector<ull> hash,p;
  int len;
  rollinghash(){}
  rollinghash(string S,ull B):S(S),B(B){init();};
  void init(){
    len=S.length();
    hash.resize(len+1);
    p.resize(len+1);
    hash[0]=0;p[0]=1;
    for(int i=0;i<len;i++){
      hash[i+1]=hash[i]*B+S[i];
      p[i+1]=p[i]*B;
    }
  }
  ull find(int l,int r){
    return hash[r]-hash[l]*p[r-l];
  }
};
typedef pair<ull,ull> P;
int main(){
  string s,t;
  cin>>s>>t;
  ull B=1000000007LL,C=1777771LL;
  int sl=s.length(),tl=t.length();
  rollinghash r1(s,B),r2(s,C);
  vector<P> v(sl-tl+1);
  for(int i=0;i<=sl-tl;i++) v[i]=P(r1.find(i,i+tl),r2.find(i,i+tl));
  sort(v.begin(),v.end());
  //for(int i=0;i<=sl-tl;i++) cout<<v[i].first<<" "<<v[i].second<<endl;
  //cout<<endl;
  ull h1=0,p1=1,h2=0,p2=1,ans=0;
  for(int i=0;i<tl;i++) h1=h1*B+t[i],h2=h2*C+t[i];
  for(int i=tl-1;i>=0;i--){
    h1-=p1*t[i];
    h2-=p2*t[i];
    for(int j='a';j<='z';j++){
      if(j==t[i]) continue;
      h1+=p1*j;
      h2+=p2*j;
      //cout<<h1<<endl;
      ans+=upper_bound(v.begin(),v.end(),P(h1,h2))
	-lower_bound(v.begin(),v.end(),P(h1,h2));
      h1-=p1*j;
      h2-=p2*j;
    }
    for(int j='A';j<='Z';j++){
      if(j==t[i]) continue;
      h1+=p1*j;
      h2+=p2*j;
      //cout<<h1<<endl;
      ans+=upper_bound(v.begin(),v.end(),P(h1,h2))
	-lower_bound(v.begin(),v.end(),P(h1,h2));
      h1-=p1*j;
      h2-=p2*j;
    }
    h1+=p1*t[i];
    h2+=p2*t[i];
    p1*=B;
    p2*=C;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 17964
main = do
 [h,w] <- map read . words <$> getLine
 print (min (cb h w) (cb w h))

cb :: Integer -> Integer -> Integer
cb x y = min (maximum [s1,s2,s3] - minimum [s1,s2,s3]) (maximum [s1,s2',s3'] - minimum [s1,s2',s3'])
 where
  x1 = round ((fromIntegral x) / 3)
  x2 = x - x1
  y1 = div y 2
  y2 = y - y1
  x1' = div x2 2
  x2' = x2 - x1'
  s1 = x1 * y
  s2 = x2 * y1
  s3 = x2 * y2
  s2' = x1' * y
  s3' = x2' * y

Measured memory_bytes: 508
/*
 * itikara.cpp
 *
 *  Created on: 2018/05/30
 *      Author: J01003
 */
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int n,x,c;
	while(1){
		c=0;
	cin>>n>>x;
	if(n==0&&x==0){
			return 0;;
			}
	for(int k=1;k<=n;k++){
	for(int b=1;b<=n;b++){
	for(int s=1;s<=n;s++){
	if(k!=b&&b!=s&&s!=k&&k+b+s==x){
			c++;
			}
	}}}
	c=c/6;
	cout<<c<<endl;
}
	return 0;
}




Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define hell 1000000007
#define hell1 1000000006
#define pb push_back
#define x first
#define y second
#define MAXL 100005
#define pll pair<ll,ll>
using namespace std;
//vector<ll>prime(15000002,0);
ll mM(ll a,ll b,ll mod){ll res = 0;a %= mod;while(b){if (b & 1)res = (res + a) % mod;a = (2 * a) % mod;b >>= 1;}return res;}
ll fpow(ll x,ll y,ll p){x=x%p;ll res=1;while(y){if(y&1)res=(res*x)%p;res%=p;if(res<0)res=(res+p)%p;y=y>>1;x=(x*x)%p;if(x<0)x=(x+p)%p;x%=p;}return res;}
ll inv(ll n,ll p){return fpow(n,p-2,p);}
ll modmul(ll x,ll y){return (x*y)%hell;}
ll modadd(ll x,ll y){if(x>=hell)x-=hell;if(y>=hell)y-=hell;ll temp=x+y;if(temp>=hell)temp-=hell;if(temp<0)temp = temp+hell;return temp;}
/*void sieve(){
	prime[1] = 1;
	for(ll i=2;i<=15000000;i++)
		if(!prime[i])
			for(ll j=i;j<=15000000;j+=i)
				if(!prime[j])
					prime[j] = i;
}*/
vector<ll>adj[100005],visited(100005,0),dp(100005,0);
void dfs(ll src)
{
	//cout << src << " ";
	if(!visited[src])
	{
		visited[src]++;
		ll mx = 0;
		for(auto e:adj[src])
			if(!visited[e])
			{
				dfs(e);
				mx = max(mx,dp[e]);
			}
			else
				mx = max(mx,dp[e]);
		if(adj[src].size())
			dp[src] = mx + 1;
		else
			dp[src] = 0;
	}
}
int main(){
	ios
	ll t = 1;
	//cin >> t;
	//sieve();
	while(t--)
	{
		ll n,m;
		cin >> n >> m;
		for(int i=0;i<m;i++)
		{
			ll u,v;
			cin >> u >> v;
			adj[u].pb(v);
		}
		ll ans = 0;
		for(int i=1;i<=n;i++)
			if(!visited[i])
				dfs(i);
		for(int i=1;i<=n;i++)
			ans = max(ans,dp[i]);
		cout << ans << "\n";
	}
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;

ll n, a[105], kol;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (ll i = 1; i <= n; ++i)
        cin >> a[i];
    for (ll i = 1; i <= n; ++i)
        for (ll j = i + 1; j <= n; ++j)
            for (ll k = j + 1; k <= n; ++k)
                if (a[i] != a[j] && a[j] != a[k] && a[k] != a[i] && a[i] + a[k] > a[j] && a[i] + a[j] > a[k] && a[k] + a[j] > a[i])
                    ++kol;
    cout << kol;
    return 0;
}


Measured memory_bytes: 3644
// input has entire input data
function Main(input) {
    // first line is in input[0], second line is in input[1], ..
    input = input.split("\n");
    // write solution here
    // 'let' was not available..
    var n = (input[0]);
    var ans = '';
    for (var i = 0; i < n.length; i++) {
        if (n[i] === '1') {
            ans += '9';
        } else {
            ans += '1';
        }
    }
    // console.log will write a line to standard output (with line break at end)
    console.log(ans);
}

// do not edit lines below (reads entire standard input to call Main)
// this did not read input from VS Code integrated terminal, nor terminal
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
long long int le,sum=0,a[1000000];
cin>>le;
for(int i=0;i<le;i++){
cin>>a[i];
sum+=a[i];
}
cout<<*min_element(a,a+le)<<" "<<*max_element(a,a+le)<<" "<<sum<<endl;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  std::vector<int> w(N);
  for(int i=0;i<N;i++)w[i]=v[i];
  sort(v.begin(),v.end());
  for(int i=0;i<N;i++){
    if(w[i]==v[N-1])cout<<v[N-2]<<endl;
    else cout<<v[N-1]<<endl;
  }
}


Measured memory_bytes: 4736
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(a,b,c) for (int a=b;a<=c;a++)
using namespace std;
const int N=305;
void chkmin(int &x,int y){
	x=min(x,y);
}
void chkmax(int &x,int y){
	x=max(x,y);
}
void add(int &x,int y){
	x=(x+y)%1000000007;
}
int n,m,ans,lmn[4][N],lmx[4][N],f[N][N][N];
int main(){
	scanf("%d%d",&n,&m);
	memset(lmn,127,sizeof(lmn));
	memset(lmx,128,sizeof(lmx));
	rep(i,1,m){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		chkmin(lmn[z][y],x);
		chkmax(lmx[z][y],x);
	}
	f[1][0][0]=f[0][1][0]=f[0][0][1]=1;
	rep(i,1,n) rep(j,0,i-1) rep(k,0,i-1){
		int fi=i,se=max(j,k),th=min(j,k);
		if ((j==k&&j!=0)||
			se>=lmn[1][i]||
			se< lmx[2][i]||
			th>=lmn[2][i]||
			th< lmx[3][i]){
				f[i][j][k]=
				f[k][i][j]=
				f[j][k][i]=0;
				continue;
			}
		if (i==n){
			add(ans,f[n][j][k]);
			add(ans,f[k][n][j]);
			add(ans,f[j][k][n]);
		}
		for (int l=1;l<=3;l++,swap(i,j),swap(i,k)){
			add(f[fi+1][j][k],f[i][j][k]);
			add(f[i][fi+1][k],f[i][j][k]);
			add(f[i][j][fi+1],f[i][j][k]);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 110720
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>

using namespace std;

int gcd(int a, int b){
    while( b ){
        int m = a % b;
        a = b;
        b = m;
    }
    return a;
}

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

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

long long mod_pow(long long x, long long n, long long mod){
    //x???n???????¨????????????????n??????2?????¨?¨???????????¨????
    //x^22 = x^16 + x^4 + x^2
    long long ret=1;
    while(n>0){
        if(n%2==1){
            ret=(ret*x)%mod;//???????????????
        }
        x=(x*x)%mod;//2???
        n=n/2;
    }
    return ret;
}

struct VV{
    int x;
    int y;
    int w;
    int e;
    int ind;
};

class LessInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        if(riLeft.x == riRight.x){
            return riLeft.y > riRight.y;
        }
        return riLeft.x > riRight.x;
        
    }
};

class indInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        return riLeft.ind < riRight.ind;
        
    }
};



int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //????????????
    
    int L,N;
    
    cin >> L >> N;
    int LL[62];
    
    for(int i=0;i<62;i++){
        LL[i]=0;
    }
    
    int sum=0;
    
    for(int i=0;i<N;i++){
        int tmp,tmp2;
        cin >> tmp;
        cin >> tmp2;
        LL[tmp+L]=LL[tmp+L]+tmp2;
        sum=sum+tmp*tmp2;
    }
    vector<int> ansl;
    vector<int> answ;
    ansl.clear();
    answ.clear();
    for(int i=0;i<L;i++){
        if(LL[i]!=LL[2*L-i]){
            if(LL[i]-LL[2*L-i]<0){
                answ.push_back(abs(LL[i]-LL[2*L-i]));
                ansl.push_back(i-L);
            }else{
                answ.push_back(abs(LL[i]-LL[2*L-i]));
                ansl.push_back((2*L-i)-L);
            }
        }
    }
    
    if(sum==0){
        cout << 0 << endl;
        return 0;
    }
    
    cout << ansl.size() << endl;
    for(int i=0;i<ansl.size();i++){
        cout << ansl[i] << " " << answ[i] << endl;
    }
    
    //???????????§
    //cout << "ans" << endl;????????????
    //printf("%.0f\n",ans);//?°???°?????\?????¨?????????
    //printf("%.7f",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}

Measured memory_bytes: 1220
import java.util.Scanner;

public class Main
{

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

        int t[] = new int[5];
        for (int i = 0; i < 5; i++) {
            t[i] = scan.nextInt();
        }
        for (int j = 0; j < 4; j++) {
            for (int a = 0; a < 4 - j; a++) {
                if (t[a] < t[a + 1]) {
                    int b = t[a];
                    t[a] = t[a + 1];
                    t[a + 1] = b;
                }
            }

        }
        for (int i = 0; i < 5; i++) {
            if (i < 4) {
                System.out.print(t[i] + " ");
            } else {
                System.out.println(t[i]);
            }
        }

    }
}




Measured memory_bytes: 26148
def solve():
    n = int(input())
    a = list(map(int, input().split()))
    ave = sum(a) / n
    a2 = [(abs(a[i] - ave), i) for i in range(n)]
    a2 = sorted(a2)
    print(a2[0][1])


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

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

	int N, M; cin >> N >> M;
	vector<int> v(N);
	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b;
		v[a - 1]++;
		v[b - 1]++;
	}

	bool f = true;
	for (int i = 0; i < N; i++) {
		if (v[i] % 2 == 1) { f = false; }
	}

	if (f) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
char dc[5] = "RDLU";

bool dfs(int y, int x, int l, string &ans, vector<vector<char> > &field){
    if(l==0){
        ans[l] = field[y][x];
        return true;
    }

    char dir = field[y][x];
    for(int i=0; i<4; i++){
        if(field[y][x] == dc[(i+2)%4]) continue;
        int ny=y, nx=x;
        while(field[ny][nx] != 'x'){
            if(field[ny][nx]=='o'){
                field[y][x] = '.';
                field[ny][nx] = dc[i];
                if(dfs(ny, nx, l-1, ans, field)){
                    ans[l] = dir;
                    return true;
                }
                field[ny][nx] = 'o';
                field[y][x] = dir;
                break;
            }
            ny += dy[i];
            nx += dx[i];
        }
    }
    return false;
}

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char> > field(h+2, vector<char>(w+2, 'x'));
    int sx,sy, leaf=0;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> field[i][j];
            if(field[i][j] == 'o'){
                leaf++;
            }else if(field[i][j] != '.'){
                sy = i;
                sx = j;
            }
        }
    }
    string ans(leaf, '.');
    dfs(sy, sx, leaf, ans, field);
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3216
module.exports=function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){i(1)(i(3).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(t,e,i){var n=i(2);t.exports=function(t){for(var e=t[0].split(" "),i=Number(e[0]),r=Number(e[1]),s=[],o=0,u=new n(10),d=0;d<i;d++){for(var f=t[d+1].split(""),l=0;l<r;l++)"#"==f[l]?u.enq({x:l,y:d,dist:0}):o+=1;s.push(f)}for(;u.size>0;){var c=u.deq();if("."==s[c.y][c.x]||0==c.dist){if("."==s[c.y][c.x]&&(s[c.y][c.x]="#",o-=1),o<=0)return void console.log(c.dist);c.x+1<r&&"#"!=s[c.y][c.x+1]&&u.enq({x:c.x+1,y:c.y,dist:c.dist+1}),c.x-1>=0&&"#"!=s[c.y][c.x-1]&&u.enq({x:c.x-1,y:c.y,dist:c.dist+1}),c.y+1<i&&"#"!=s[c.y+1][c.x]&&u.enq({x:c.x,y:c.y+1,dist:c.dist+1}),c.y-1>=0&&"#"!=s[c.y-1][c.x]&&u.enq({x:c.x,y:c.y-1,dist:c.dist+1})}}}},function(t,e,i){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;this.size=0,this.items=[],this.ind=0,this.maxGap=t}enq(t){this.size+=1,this.items.push(t),this.items.size-this.ind>this.maxGap&&(this.items=this.items.slice(this.ind))}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}}},function(t,e){t.exports=require("fs")}]);

Measured memory_bytes: 200640
import java.util.*;

public class Main {
	
	static int change = 0;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		StringBuilder sb = new StringBuilder();
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(A <= 9 && B <= 9) {
			System.out.println(A*B);
		} else {
			System.out.println(-1);
		}
		
	}

}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<pairl>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    
    ll A, B;
    cin >> A >> B;
    vector<pair<ll, ll> > apf = prime_factorize(A);
    vector<pair<ll, ll> > bpf = prime_factorize(B);
    int ai = 0, bi = 0;
    ll ans = 1;
    while(1){
        if(ai == apf.size() || bi == bpf.size())break;
        int ap = apf[ai].first;
        int bp = bpf[bi].first;

        if(ap == bp){
            ans++;
            ai++;
            bi++;
        }
        else if(ap > bp){
            bi++;
        }
        else {
            ai++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int N, K, r, s, p;
    cin >> N >> K >> r >> s >> p;
    string T; cin >> T;
    int tsize = T.size();
    vector<char> ans(tsize,' ');
    long a = 0;
    for (int i = 0; i < tsize; i++){
        if(i > K-1){
            if(T[i] == 'r' && ans[i-K] != 'p')
                ans[i] = 'p';
            if (T[i] == 's' && ans[i - K] != 'r')
                ans[i] = 'r';
            if (T[i] == 'p' && ans[i - K] != 's')
                ans[i] = 's';
        }else{
            if(T[i] == 'r')
                ans[i] = 'p';
            if (T[i] == 's')
                ans[i] = 'r';
            if (T[i] == 'p')
                ans[i] = 's';
        }
    }
    for (int i = 0; i < tsize;i++){
        if(ans[i] == 'r')
            a += r;
        if(ans[i] == 's')
            a += s;
        if(ans[i] == 'p')
            a += p;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
char a[3][3];
char b[4][4];

string c[5];
int main(){
	a[0][0] = 'a'; a[0][1] = 'a'; a[0][2] = 'c';
	a[1][0] = 'b'; a[1][1] = '.'; a[1][2] = 'c';
	a[2][0] = 'b'; a[2][1] = 'd'; a[2][2] = 'd';


	b[0][0] = 'a'; b[0][1] = 'a'; b[0][2] = 'c'; b[0][3] = 'd';
	b[1][0] = 'b'; b[1][1] = 'b'; b[1][2] = 'c'; b[1][3] = 'd';
	b[2][0] = 'c'; b[2][1] = 'd'; b[2][2] = 'a'; b[2][3] = 'a';
	b[3][0] = 'c'; b[3][1] = 'd'; b[3][2] = 'b'; b[3][3] = 'b';


	c[0] = "a.eef";
	c[1] = "ab..f";
	c[2] = ".bggi";
	c[3] = "cch.i";
	c[4] = "ddhjj";

	int n;
	cin >> n;
	if(n<=2) puts("-1");
	else if(n == 7){
		cout <<
		"aa...bc" << endl <<
		"....dbc" << endl <<
		"eeffd.." << endl <<
		".abbcc." << endl <<
		".a..edd" << endl <<
		"g...e.f" << endl <<
		"g.hh..f" << endl;
	}
	else if(n == 11){
		cout <<
		"aa.......bc" << endl <<
		"........dbc" << endl <<
		"aabb....d.." << endl <<
		"c...ddee..." << endl <<
		"c......aabb" << endl <<
		".cde......." << endl <<
		".cde......." << endl <<
		"....abc...." << endl <<
		"....abc...." << endl <<
		"..dd..ee..c" << endl <<
		"....aa..bbc" << endl;

	}
	else if(n%3 == 0){
			string ans[1005];
			rep(i,n) rep(j,n) ans[i].pb('.');
			rep(i,n/3){
				int x = i*3, y = i*3;
				rep(aa,3)rep(b,3){
					ans[x+aa][y+b] = a[aa][b];
				}
			}
			rep(i,n) cout << ans[i] << endl;
		
	}
	else{
			string ans[1005];
			rep(i,n) rep(j,n) ans[i].pb('.');
			rep(aaa,n) rep(bbb,n){
				if(4*aaa+5*bbb == n){
					int cur = 0;
					rep(i,aaa){
						rep(aa,4)rep(bb,4) ans[cur+aa][cur+bb] = b[aa][bb];
						cur += 4;
					}
					rep(i,bbb){
						rep(aa,5)rep(bb,5) ans[cur+aa][cur+bb] = c[aa][bb];
						cur += 5;
					}
					rep(i,n) cout << ans[i] << endl;return 0;
				}
			}
		
	}
}

Measured memory_bytes: 2304
S = input()
MOD = 10**9 + 7

M = 13
dp = [0] * M
dp[0] = 1

for s in S:
    newDp = [0] * M
    if s == '?':
        for m in range(M):
            for s in range(10):
                newDp[(m * 10 + s) % M] += dp[m]
    else:
        s = int(s)
        for m in range(M):
            newDp[(m * 10 + s) % M] += dp[m]
    dp = newDp
    for m in range(M):
        dp[m] %= MOD

print(newDp[5] % MOD)

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

using namespace std;

bool check(vector<int>& A, vector<int>& B, int C, int M){
    int sum = C;
    for(int i = 0; i < M; i++){
	sum += A.at(i) * B.at(i);
    }
    return (sum > 0);
}

int main(){

    int N, M, C;

    cin >> N >> M >> C;

    vector<int> B(M);
    vector<vector<int>> A(N, vector<int>(M));

    for(int i = 0; i < M; i++){
	cin >> B.at(i);
    }
    for(int i = 0; i < N; i++){
	for(int j = 0; j < M; j++){
	    cin >> A.at(i).at(j);
	}
    }

    int sum = 0;
    for(int i = 0; i < N; i++){
	if(check(A.at(i), B, C, M)) sum++;
    }

    cout << sum << endl;

}


Measured memory_bytes: 256