akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long X = GetLong();
		long Y = GetLong();
		long Z = GetLong();
		long K = GetLong();
		var A = GetLongs(X);
		var B = GetLongs(Y);
		var C = GetLongs(Z);

		var AB = new List<long>();
		for(long i = 0; i < X; i++)
		{
			for(long j = 0; j < Y; j++)
				AB.Add(A[i] + B[j]);
		}
		AB.Sort((x, y) => y.CompareTo(x));

		var ABC = new List<long>();
		for(long i = 0, E = Min(K, AB.Count); i < E; i++)
		{
			for(long j = 0; j < Z; j++)
				ABC.Add(AB[(int)i] + C[(int)j]);
		}
		ABC.Sort((x, y) => y.CompareTo(x));
		WriteLine(string.Join("\n", ABC.Take((int)K)));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 69400
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// get a integer
		int N = sc.nextInt();
		int L = sc.nextInt();
		
		List<String> inputs = new ArrayList<String>();
		
		for (int i = 0; i < N; i++) {
			//get strings
			inputs.add(sc.next());
		}
		
		Collections.sort(inputs);
		
		String output = String.join("", inputs);
		// output
		System.out.println(output);
	}
}

Measured memory_bytes: 24020
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		int Q = Integer.parseInt(in.readLine());
		for (int i = 0; i < Q; ++i) {
			String[] tokens = in.readLine().split(" ");
			int S = Integer.parseInt(tokens[0]);
			int T = Integer.parseInt(tokens[1]);
			int times = ins.getTimes(S - 1, T - 1);
			if (times > ins.N) {
				System.out.println("-1");
			} else {
				System.out.println((times - 1));

			}
		}
	}

	int N, M;
	long L;
	long[][] connMatrix;
	int[][] distMatrix;

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		M = Integer.parseInt(tokens[1]);
		L = Long.parseLong(tokens[2]);
		connMatrix = new long[N][N];
		for (int i = 0; i < N; ++i) {
			Arrays.fill(connMatrix[i], Long.MAX_VALUE / 2);
		}
		for (int i = 0; i < M; ++i) {
			tokens = in.readLine().split(" ");
			int A = Integer.parseInt(tokens[0]);
			int B = Integer.parseInt(tokens[1]);
			long C = Long.parseLong(tokens[2]);
			if (C <= L) {
				// 燃料タンクより長い道は使えない
				connMatrix[A - 1][B - 1] = C;
				connMatrix[B - 1][A - 1] = C;
			}
		}
		for (int i = 0; i < N; ++i) {
			connMatrix[i][i] = 0;
		}

		calcDistMatrix();

		this.distMatrix = new int[N][N];
		for (int i = 0; i < N; ++i) {
			for (int j = i + 1; j < N; ++j) {
				if (connMatrix[i][j] <= L) {
					distMatrix[i][j] = 1;
					distMatrix[j][i] = 1;
				} else {
					distMatrix[i][j] = Integer.MAX_VALUE / 2;
					distMatrix[j][i] = Integer.MAX_VALUE / 2;
				}
			}
		}
		for (int i = 0; i < N; ++i) {
			distMatrix[i][i] = 0;
		}
		calcDistMatrix2();
	}

	int getTimes(int src, int dst) {
		return distMatrix[src][dst];
	}

	void calcDistMatrix() {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				for (int k = j + 1; k < N; ++k) {
					this.connMatrix[j][k] = Math.min(connMatrix[j][k], connMatrix[j][i] + connMatrix[i][k]);
					this.connMatrix[k][j] = connMatrix[j][k];
				}
			}
		}
	}

	void calcDistMatrix2() {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				for (int k = j + 1; k < N; ++k) {
					this.distMatrix[j][k] = Math.min(distMatrix[j][k], distMatrix[j][i] + distMatrix[i][k]);
					this.distMatrix[k][j] = distMatrix[j][k];
				}
			}
		}
	}

}


Measured memory_bytes: 48784
#include <stdio.h>

int main(void)
{
	int a, b;
	char op=0;


	while (!(op == '?')) {
		scanf("%d %c %d", &a, &op, &b);
		if (op == '+') {
			printf("%d\n", a + b);
		}
		else if (op == '-') {
			printf("%d\n", a - b);
		}
		else if (op == '*') {
			printf("%d\n", a*b);
		}
		else if (op == '/') {
			printf("%d\n", a / b);
		}
	}
	return 0;
}


Measured memory_bytes: 2684
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    X,K,D = isRaw()
    X = abs(X)
    W =  X//D
   
    if W > K:
        print(X-D*K)
        return
    if (K-W)%2==0:
        print(X%D)
        return
    else:
        print(D-X%D)
         
main()


Measured memory_bytes: 67600
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;
import std.range;

void main() {
	auto ip = readln.split.to!(int[]), A = ip[0], B = ip[1];
	/*uint r = A / 1000;
	uint p = A.to!string[2].to!uint - '0';
	uint s = r*1000 + p*100 + r;
	uint count;
	while(s <= B) {
		count++;
		if(p == 9) {
			p = 0;
			r++;
		}
		else p++;


		s = r*1000 + p*100 + r;
	}
	count.writeln;
	*/
	uint count;
	uint p = 100;
	uint i;
	uint j;
	uint k;
	string a;
	while(p < 1000) {
		a = p.to!string;
		i = 10000*(a[0].to!uint - '0') + 1000*(a[1].to!uint - '0');
		j = 10*(a[1].to!uint - '0') + (a[0].to!uint - '0');
		k = i + j + 100*(a[2].to!uint - '0');

		if(k >= A && k <= B) count++;
		p++;
	}
	count.writeln;
}


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;
	vector<int> x(n), y(n);
	rep(i,n) cin >> x[i] >> y[i];
	vector<int> prm(n);
	rep(i,n) prm[i] = i;
	double ans = 0;
	int cnt = 0;
	do{
		rep(i,n-1){
			double dx = x[prm[i]] - x[prm[i+1]];
			double dy = y[prm[i]] - y[prm[i+1]];
			ans += sqrt(dx*dx+dy*dy);
		}
		cnt++;
	}while(next_permutation(prm.begin(), prm.end()));
	ans /= cnt;
	printf("%.10f", ans);
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_end().to_owned()
    };

    let a2 = s.chars().nth(2).unwrap() == s.chars().nth(3).unwrap();
    let a3 = s.chars().nth(4).unwrap() == s.chars().nth(5).unwrap();
    let result = if a2 && a3 {
        "Yes"
    } else {
        "No"
    };
    println!("{}", result)
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intinf 1000000000
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

#include <bits/stdc++.h>
#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int n, a[300][300];
bool b;
ll ans = 0;

int main() {
	cin >> n;
	rep(n) {
		REP(n, j) {
			cin >> a[i][j];
		}
	}
	rep(n) {
		REP(n, j) {
			b = true;
			REP(n, k) {
				if (k != i&&k != j) {
					if (a[i][j] > a[i][k] + a[k][j]) {
						cout << -1 << endl;
						return 0;
					}
					if (a[i][j] == a[i][k] + a[k][j])
						b = false;
				}
			}
			if (b)
				ans += a[i][j];
		}
	}
	cout << ans / 2 << endl;
	return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 1; i <= n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

int euclid(ll a, ll b) {
  int temp;

  if (a < b) {
    temp = a;
    a = b;
    b = temp;
  }
  if (b < 1) return -1;

  if (a % b == 0) return b;
  return euclid(b, a % b);
}

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

  ll n;
  cin >> n;

  ll ans = 0;
  REP(i, n) {
    REP(j, n) {
      REP(k, n) { ans += euclid(euclid(i, j), k); }
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 3660
import sys


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    a, v = _ia()
    b, w = _ia()
    t = _i()
    if a > b:
        ans = "YES" if a - (v-w) * t <= b else "NO"
    else:
        ans = "YES" if a + (v-w) * t >= b else "NO"

    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 61680
#include <iostream>
using namespace std;
void printArr(int *a,int n)
{
	for(int i=0;i<n;i++)
	{
		if(i>0) cout << " ";
		cout << a[i];
	}
	cout << "\n";
}
int bubbleSort(int *a,int n)
{
	int exchangeCount=0;
	int j,temp;
	int flag = 1;
	while(flag==1)
	{
		flag=0;
		for(j=n-1;j>=1;j--)
		{
			if(a[j]<a[j-1])
			{
				exchangeCount++;
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;
				flag=1;
			}
		}
	}
	return exchangeCount;
}
int main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	int count=bubbleSort(a,n);
	printArr(a,n);
	cout << count << endl;
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  long long N; cin >> N;
  vector<long long> a(400000);
  vector<long long> s(400000), t(400000);
  long long cnt, cnt2;
  priority_queue<long long, vector<long long>, greater<long long>>L;
  priority_queue<long long, vector<long long>, less<long long>>R;
  for(int i = 0; i < 3*N; ++i) {
    cin >> a[i];
  }
  for(int i = 0; i < N; ++i) {
    L.emplace(a[i]);
    cnt += a[i];
  }
  s[N] = cnt;
  for(int i = N; i < 3*N; ++i) {
    L.emplace(a[i]);
    cnt += a[i];
    cnt2 += a[i];
    cnt -= L.top(); L.pop();
    s[i+1] = cnt;
  }
  cnt = 0, cnt2 = 0;
  for(int i = 2 * N; i < 3 * N; ++i) {
    R.emplace(a[i]);
    cnt += a[i];
    cnt2 += a[i];
  }
  t[2*N] = cnt;
  for(int i = 2 * N - 1; i >= 0; --i) {
    R.emplace(a[i]);
    cnt += a[i];
    cnt -= R.top(); R.pop();
    t[i] = cnt;
  }
  long long maxn = (-1LL << 60);
  for(int i = N; i <= 2*N; ++i) {
    maxn = max(maxn, s[i] - t[i]);
  }
  cout << maxn << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int i = 0;
	while(a > 0 && c > 0){
		if(i%2 == 0) c-= b;
		else a -= d;
		++i;
	}
	
	cout << (a>0?"Yes":"No");

}


Measured memory_bytes: 3632
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  string s,k("keyence");

  cin >> s;

  bool ans = false;
  if(s == k)
  {
    ans = true;
  }  
  else
  {
    for(ll i = 0; i < sz(s) ; ++i)
    {
      for(ll j = i; j < sz(s); ++j)
      {
        string buf = s.substr(0,i) + s.substr(j+1);
        if(buf == k)
        {
          ans = true;
          break;
        }
      }
      if(ans) break;
    }
  }

  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;  
  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

vector<vector<int>> graph;

void solution(){

	int n, k; cin >> n >> k;
	vector<int> h(n); for(auto& x : h) cin >> x;

	vector<int> dp(n);
	vector<int> m;

	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);

	for(int i = 2; i < n; i++){
		dp[i] = INT_MAX;
		for(int j = i-1; j >= 0 && j >= i-k; j--){
			dp[i] = min(dp[i], abs(h[i] - h[j]) + dp[j]);
		}

	}

	cout << dp[n-1] << endl;



	
}	

int main(){ 

	fio; // fast input output
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// GOOGLE //
		// cout << "Case #" << i << ": ";

		solution();
	} 
	return 0;
}

Measured memory_bytes: 3936
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <map>
#include <vector> 
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <cmath>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <iostream>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rall(x) x.rbegin(),x.rend()
#define mu(x) x.resize(unique(all(x))-x.begin());
#define srt(x) sort(all(x));
#define rev(x) reverse(all(x));
#define each(x,a) for(auto& x:a)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define PER(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cerr<<#x<<" "<<x<<"\n";
#define debug_v(x) { cerr<<#x<<"\n";  each(y,x) cerr<<y<<" "; cerr<<'\n';}
#define debug_vp(x) { cerr<<#x<<"\n";  each(y,x) cerr<<y.ff<<" "<<y.ss<<'\n'; cerr<<'\n';}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<bool> vb;

const ll mod=1000000000+7;

ll d[100100];

ll sum(ll a, ll b) {
 	return (a+b)%mod;
}

ll sub(ll a, ll b) {
 	return (a-b+mod*mod)%mod;
}


ll mul(ll a, ll b) {
 	return (a * b) % mod;
}

ll bin_pow(ll a, ll p) {
 	if(p==0)return 1;
 	ll t=bin_pow(a,p/2);
 	if(p&1)return t*t%mod*a%mod;
 	else return t*t%mod;
}

int main() {
	fastio;
	int n,k;
	cin>>n>>k;      
	PER(i,k,1){
	 	d[i]=bin_pow(k/i,n);
	}
	PER(i,k,1){
	 	for(int j=2*i;j<=k;j+=i){
	 	 	d[i]=sub(d[i],d[j]);
	 	}
	}
    ll ans=0;
    PER(i,k,1){
		ans=sum(ans,mul(d[i],i)); 	
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4288
import java.util.*;
public class Main{
	public static void main(String[] args){
		double ans_1 = 0;
		int ans_2 = 0;
		Scanner sc = new Scanner(System.in);
		double w = sc.nextInt();
		double h = sc.nextInt();
		double x = sc.nextInt();
		double y = sc.nextInt();

		ans_1 = w * h / 2;
		if(w / 2 == x && h / 2 == y){
			ans_2 = 1;
		}else{
			ans_2 = 0;
		}
		
		System.out.print(ans_1);
		System.out.print(" ");
		System.out.println(ans_2);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
void PDF(int k,int a,int b)
{
    int i,u=0;
    for(i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            u++;
        }
    }
    if(u==0)
    {
        cout << "NG" <<endl;
    }
    else
    {
        cout << "OK" <<endl;
    }
}
int main()
{
    int k,a,b;
    cin >> k >> a >> b;
    PDF(k,a,b);
    return 0;
}


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

int N, K;
int R, S, P;
string T;

int main() {
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (i < K) {
      if (T[i] == 'r') ans += P;
      if (T[i] == 's') ans += R;
      if (T[i] == 'p') ans += S;
    }
    else {
      if (T[i] == T[i-K]) {
        T[i] = '#';
        continue;
      }
      if (T[i] == 'r') ans += P;
      if (T[i] == 's') ans += R;
      if (T[i] == 'p') ans += S;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
n,q= map(int,input().split())
s = input()
lr = [list(map(int, input().split())) for i in range(q)]
import numpy as np
sn = list(np.cumsum([0] + [s[i:i++2]=="AC" for i in range(n-1)]))

for i,j in lr:
  i -= 1
  j -= 1
  print(sn[j] - sn[i])

Measured memory_bytes: 38872
#include <bits/stdc++.h>
using namespace std;
#define MOD (1000000007)

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

	int N = S.size();
	int64_t dp[N+10][13];
	int64_t res;

	for (int i=0; i<N+10; i++)
		for (int j=0; j<13; j++)
			dp[i][j] = 0;

	dp[0][0] = 1;
	for (int i=1; i<=N; i++) {
		char now_c = S[i-1];
		if (now_c == '?') {
			for (int d=0; d<10; d++) {
				for (int j=0; j<13; j++) {
					(dp[i][(10*j + d) % 13] += dp[i-1][j]) %= MOD;
				}
			}
		}
		else {
			int d = now_c - '0';
			for (int j=0; j<13; j++) {
				(dp[i][(10*j + d) % 13] += dp[i-1][j]) %= MOD;
			}
		}
	}

	res = dp[N][5];
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 10752
#include <stdio.h>

int main() {
  long long int t, sum = 1;
  scanf("%lld", &t);

  long long int n[t];
  for(int i = 0; i < t; i++) {
    scanf("%lld", &n[i]);
  }

  for(int i = 0; i < t; i++) {
    if(n[i] == 0) {
      printf("0");
      return 0;
    }
  }

  for(int i = 0; i < t; i++) {
    if(n[i] <= 1000000000000000000 / sum) {
      sum *= n[i];
    }
    else {
      printf("-1");
      return 0;
    }
  }
  printf("%lld", sum);
  return 0;
}


Measured memory_bytes: 2512
K, S = map(int, input().split())

cnt = 0
for x in range(0,K+1):
	if S-x < 0:
		break
	for y in range(0, min(K,S-x)+1):
		z = S-x-y
		if z>-1:
			if z < K+1:
				cnt += 1
		else:
			break

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

bool solve() {
    ll e;
    cin >> e;
    if(e == 0) {
        return false;
    }
    ll ans = LLINF;
    for(ll z = 0; z * z * z <= e; z++) {
        for(ll y = 0; y * y <= e; y++) {
            ll x = e - y * y - z * z * z;
            if(0 <= x && x <= e) {
                chmin(ans, x + y + z);
            }
        }
    }
    cout << ans << endl;
    return true;
}

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


Measured memory_bytes: 3028
#include <iostream>
#include <vector>
#include <algorithm>
#include<array>
using namespace std;

using ll = long long;

int main() {
	ll n = 0;
	cin >> n;
	for (int h = 1; h <= 3500; h++)
	{
		for (int p = 1; p <= 3500; p++)
		{
			ll A = n*p*h;
			ll B = 4 * h*p - n*p - n*h;
			if (B == 0)continue;
			if (A%B != 0)continue;
			ll w = A / B;
			if (w < 0)continue;
			cout << h << " " << p << " " << w << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toLong() }.toTypedArray()

    a.sort()
    var ans = 0L

    for (i in 0 until n) {
        ans += a[3 * n - 2 * i - 2]
    }
    println(ans)
}


Measured memory_bytes: 87532
#include <stdio.h>

int main(void){
  long int N,K;
  scanf("%ld",&N);
  scanf("%ld",&K);
  long int p = 0;
  long int m = 0;
  p = N % K;
  m = (p - K) * -1;
  if(p < m){
    printf("%ld",p);
  }
  else{
    printf("%ld",m);
  }
  return 0;
}


Measured memory_bytes: 1728
#include<iostream>
using namespace std;
  
int main(){
    int a, b;
      
    cin>> a >> b;
      
    if ( a < b ) cout << "a < b" << endl;
    else if ( a > b ) cout << "a > b" << endl;
    else cout << "a == b" << endl;
  
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
// 素因数分解
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> mp;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
    return mp;
}

// 素数判定
bool is_prime(ll n) {
    for (int i = 2; i * i <= n; i++) if (n % i == 0) return false;
    return n != 1;
}

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return move(res);
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n, k;
        cin >> n >> k;
        vl a(n);
        rep(i, n) cin >> a[i];

        vl divs = divisor(accumulate(all(a), 0LL));

        ll ans = 0;
        each(e, divs) {
            vl mods(n);
            rep(i, n) mods[i] = a[i] % e;
            sort(all(mods));
            vl minuss(n + 1), pluss(n + 1);
            rep(i, n) {
                minuss[i + 1] = minuss[i] + mods[i];
                pluss[i + 1] = pluss[i] + (e - mods[i]);
            }

            for (ll i = 0; i <= n; ++i) {
                ll minus = minuss[i];
                ll plus = pluss[n] - pluss[i];

//                cout << "e: " << e << ", plus: " << plus << ", minus: " << minus << endl;
                if (max(plus, minus) <= k) {
                    ans = max(ans, e);
                }
            }
        }
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
from collections import deque

n, k = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
for t in range(k//2 + 1):
    hand = deque(V[:k-t])
    rest = deque(V[k-t:])
    cur_sum = sum(hand)

    for j in range(k-t+1):
        put_back = 0
        rev_hand = sorted(hand)

        for i in range(t):
            jewel = rev_hand[i]
            if jewel < 0:
                put_back -= jewel
            else:
                break

        candidate = cur_sum + put_back
        ans = max(candidate, ans)

        to_rest = hand.pop()
        rest.appendleft(to_rest)
        to_hand = rest.pop()
        hand.appendleft(to_hand)

        cur_sum += to_hand - to_rest

print(ans)

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

int main() {
	int n; cin >> n;
	int w[110],sum=0;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		sum += w[i];
	}
	int ans = sum, s1 = 0;
	for (int i = 0; i < n; i++) {
		s1 += w[i];
		if (s1 * 2 < sum) ans = min(ans, sum - s1 * 2);
		else ans = min(ans, 2 * s1 - sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
S=list(input())
n=len(S)
ans='No'
if S==list(reversed(S)):
    new=S[0:((n-1)//2)]
    if new==list(reversed(new)):
        new2=S[((n+3)//2)-1:]
        if new2==list(reversed(new2)):
            ans='Yes'
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long int mod = 1e9+7;

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

int main(){
  int k; cin >> k;
  deque< pair<int, int> > pq;
  vector<int> c(k+1, 1e9);
  pq.push_back({0, 1});
  while(!pq.empty()) {
    pair<int, int> p = pq.front();
    c[p.second] = min(c[p.second], p.first);
    pq.pop_front();
    if(c[(p.second+1)%k] == 1e9) pq.push_back({p.first+1, (p.second+1)%k});
    if(c[(p.second*10)%k] == 1e9) pq.push_front({p.first, (p.second*10)%k});
  }
  cout << c[0]+1 << endl;

  return 0;
}

// EOF


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

typedef long long ll;

int main()
{
    int n;
    string s, t;

    scanf("%d", &n );
    cin >> s >> t;

    for ( int i = 0; i <= n; ++i ) {
        if ( s.substr( i, n - i ) == t.substr( 0, n - i ) ) {
            printf("%d\n", n + i );
            break;
        }
    }

    return 0;

}



Measured memory_bytes: 256
#include<stdio.h>

int prime_elements[1000001]={0};

int main(void){
    int i,j,result,num_input;
    for(i=2;i<=1000000;i++){
        if(prime_elements[i]==0){
            for(j=2;i*j<=1000000;j++){
                prime_elements[i*j]=1;
            }
        }
    }
    while(scanf("%d",&num_input)!=EOF){
        result=0;
        for(i=2;i<=num_input;i++){
            if(prime_elements[i]==0){
               result++;
            }
        }
    printf("%d\n",result);
    }
    return 0;
}

Measured memory_bytes: 4500
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cfenv>
using ll = unsigned long long;
using namespace std;
int gcd(int x,int y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}
int lcm(int x,int y){
    return x/gcd(x,y)*y;
}
int main(){
    ll n;
    cin >> n;
  //  ll c=0;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    if(n==2){
        cout<<0<<endl;
        return 0;
    }
    if(n==3){
        cout<<2<<endl;
        return 0;
    }
    vector<ll> vec;
    for(int i=1;i<sqrt(n);i++){
        if(n%i==0){
           // c++;
            vec.push_back(i);
        }
    }
   // for(int i=0;i<c;i++)cout<<vec[i]<<endl;
   ll sum=0;
   for(int i=0;i<vec.size();i++){
       if(n%(n/vec[i]-1)==n/(n/vec[i]-1)){
            sum += (n/vec[i])-1;
       }
   }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(true){
    C -= B;
    if(C <= 0){
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if(A <= 0 && C > 0){
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3628
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn print_array<T: std::string::ToString>(array: &Vec<T>) {
    println!(
        "{}",
        array
            .iter()
            .map(|ref x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

fn main() {
    let v = read_vec::<usize>();
    let (m, k) = (v[0], v[1]);
    if k == 0 {
        let mut answers = vec![];
        for i in 0..1 << m {
            for _ in 0..2 {
                answers.push(i);
            }
        }
        print_array(&answers);
        return;
    }
    if k >= 1 << m || (m == 1 && k != 0) {
        println!("-1");
        return;
    }

    let nums = (0..1 << m).collect::<Vec<_>>();
    let mut used = HashSet::new();
    let mut pairs = Vec::new();
    let mut reversed_pairs = Vec::new();
    for &num in nums.iter() {
        if used.contains(&num) {
            continue;
        }
        let pair = (num, num ^ k);
        used.insert(num);
        used.insert(num ^ k);
        pairs.push(pair);
        let pair = (num ^ k, num);
        reversed_pairs.push(pair);
    }
    let mut answers = vec![];
    for i in 0..pairs.len() {
        let pair = pairs[i];
        answers.push(pair.0);
        answers.push(pair.1);
    }
    for i in (0..pairs.len() - 1).rev() {
        let pair = reversed_pairs[i];
        answers.push(pair.0);
        answers.push(pair.1);
    }
    let final_reversed = reversed_pairs[reversed_pairs.len() - 1];
    answers.push(final_reversed.0);
    answers.push(final_reversed.1);
    print_array(&answers);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define ll long long int
#define pll pair <ll , ll>
#define vpll vector < pll >
#define F first
#define S second

int main () {
	int x , y , a , b , c ;
	cin >> x >> y >> a >> b >> c ;
	priority_queue < pll , vpll > p ;
	for (int i = 0 ; i < a ; ++i) {
		ll k ;
		cin >> k ;
		p.push({k , 0}) ;
	}
	for (int i = 0 ; i < b ; ++i) {
		ll k ;
		cin >> k ;
		p.push({k , 1}) ;
	}
	for (int i = 0 ; i < c; ++i) {
		ll k ;
		cin >> k ;
		p.push({k , 2}) ;
	}
	ll ans = 0 ;
	int A[3] = {0} ;
	while (A[0] <= x && A[1] <= y && A[0] + A[1] + A[2] < x+y) {
		pll t ;
		t = p.top() ;
		p.pop() ;
		if (t.S == 0 && A[0] < x) {
			++A[0] ;
			ans += t.F ;
		}
		if (t.S == 1 && A[1] < y) {
			++A[1] ;
			ans += t.F ;
		}
		if (t.S == 2) {
			++A[2] ;
			ans += t.F ;
		}
	}
	cout << ans ;
	return 0 ;
}

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

const int N=1010;
int n,h[N],ty[N],ans=0;
bool rm[N];

void gao(int l,int r,int lsh)
{
	if(l>r) return;
	int mxh=0;
	for(int i=l;i<=r;i++)
		if(ty[i]) mxh=max(mxh,h[i]);
	vector<int> pos;
	pos.push_back(l-1);
	for(int i=l;i<=r;i++)
		if(ty[i]&&h[i]==mxh) pos.push_back(i);
	pos.push_back(r+1);
	if(pos.size()==2) goto calc;
	for(int i=1;i<pos.size();i++)
		gao(pos[i-1]+1,pos[i]-1,mxh);
	calc: int mnh=N+1;
	for(int i=l;i<=r;i++)
		if(!ty[i]&&!rm[i]) mnh=min(mnh,h[i]);
	if(mnh>lsh) return;
	for(int i=l;i<=r;i++) rm[i]=1;
	ans++;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		static char ts[5];
		scanf("%s%d",ts,h+i);
		if(*ts=='n') ty[i]=1;
	}
	gao(1,n,N);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3248
N,K=map(int,input().split())
 
a=list(map(int,input().split()))
 
ruisekia=[]
keta=[0]*30
for i in range(N):
  temp=0
  for j in range(i,N):
    temp+=a[j]
    ruisekia.append(temp)
ruisekia.sort(reverse=True)
 
#print(ruisekia)
answer=0
for i in range(40,-1,-1):
  count=0
  ruiseki=[]
  for j in ruisekia:
    if j&(1<<i)==1<<i:
      count+=1
      ruiseki.append(j)
  if count>=K:
    answer+=2**i
    ruisekia=ruiseki

print(answer)
'''
for i in range(len(ruisekia)):
  tempo=ruisekia[i]
  while(tempo!=0):
    x=1
    count=0
    while(tempo>=x*2):
      x*=2
      count+=1
    keta[count]+=1
    tempo-=x
print(keta)
'''

Measured memory_bytes: 28148
s=input()
n=len(s)
# 左から < かどうかを見る
cnt=0
r=[0]*(n+1)
tmp=s[0]
for i in range(n):
    if s[i]=='<':
        cnt+=1
    else:
        tmp=s[i]
        cnt=0
    r[i+1]=cnt

# 右から > かどうかを見る
cnt=0
tmp=s[n-1]
l=[0]*(n+1)
for i in range(n-1,-1,-1):
    if s[i]=='>':
        cnt+=1
    else:
        tmp=s[i]
        cnt=0
    l[i]=cnt

ans=0
for i in range(n+1):
    ans+=max(r[i],l[i])
print(ans)


Measured memory_bytes: 29224
#include <iostream>
using namespace std;
int main(){
    int x, h, m, s;
    cin >> x;
    h = x / 3600;
    x = x % 3600;
    m = x / 60;
    s = x % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>

int main(void)
{
    int n, x;
    int i, j, k;

    while (1) {
        int count = 0;
        scanf("%d %d", &n, &x);
        if (n == 0 && x == 0) {
            break;
        }
        for (i = 1; i <= n; i++) {
            for (j = i+1; j <= n; j++) {
                for (k = j+1; k <= n; k++) {
                    if (i + j + k == x) {
                        count++;
                    }
                }
            }
        }
        printf("%d\n", count);
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

int main() {
  string s;
  cin >> s;
  int red = 0, blue = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      red++;
    else
      blue++;
  }
  cout << min(red, blue) * 2 << endl;
}

Measured memory_bytes: 512
import java.util.*;


public class Main
{
	
	public static void main(String[] atgs) {
		Scanner s=new Scanner(System.in);
		String str=s.nextLine();
		str=str.replace("eraser","");
		str=str.replace("erase","");
		str=str.replace("dreamer","");
		str=str.replace("dream","");
		if(str.equals(""))
			System.out.println("YES");
		else System.out.println("NO");
	}
}



Measured memory_bytes: 40812
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Str s;
	AtCoder::input(&s);

	AtCoder::Ans* ans = new AtCoder::Ans();

	const int m = std::atoi(s[0].c_str());
	const int d = std::atoi(s[1].c_str());

	for (int i = 0; i < m; i++) {
		for (int j = 1; j < d + 1; j++) {
			std::string buf = std::to_string(j);
			AtCoder::exp(&buf, &s);
			const int d1 = 1 == s.size() ? 0 : std::atoi(s[0].c_str());
			const int d2 = 1 == s.size() ? 0 : std::atoi(s[1].c_str());
			if (i < d2) {
				continue;
			} else if (i < d1) {
				break;
			}
			if ((i + 1) == (d1 * d2)) {
				ans->increment();
			}
		}
	}

	ans->showResult();

	delete(ans);

	return 0;
}


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

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private long A, B, C, K;
        public void Solve()
        {
            var sc = new Scanner();
            A = sc.NextLong();
            B = sc.NextLong();
            C = sc.NextLong();
            K = sc.NextLong();
            Console.WriteLine((K % 2 == 0 ? 1 : -1) * (A - B));
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main(){
	int n,k;
	cin>>n;
	char p[100];
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	cin>>k;
	for(int i=0;i<n;i++){
		if(p[k-1]!=p[i]){
			cout<<"*";
		}else{
			cout<<p[i];
		}
	}
	return 0;
} 

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap<String, Integer> map = new HashMap<>();
		String s; int v;
		
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			s = sc.next();
			v = sc.nextInt();
			if (map.containsKey(s)) {
				map.put(s, map.get(s) + v);
			} else {
				map.put(s, v);
			}
		}
		
		Object[] keys = map.keySet().toArray();
		Arrays.sort(keys, new Comparator<Object>() {
			public int compare(Object k1, Object k2) {
				if (k1.toString().length() == k2.toString().length()) {
					return k1.toString().compareTo(k2.toString());
				} else {
					return (k1.toString().length() - k2.toString().length());
				}
			}
		});
		
		for(int i = 0; i < keys.length; i++) {
			System.out.println(keys[i].toString() + " " + map.get(keys[i].toString()));
		}
	}
}

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

const int N = 100 * 1000 + 10;

int n, ans;
pair <int, int> arr[N];

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> arr[i].first;
        arr[i].second = i;
    }
    return;
}

void solve() {
    sort(arr, arr + n) ;
    for (int i = 0; i < n; i++)
        if (arr[i].second % 2 != i % 2)
            ans++;
    return;
}

void output() {
    cout << ans / 2 << endl;
    return;
}

int main() {
    input() ;
    solve() ;
    output() ;
    return 0;
}


Measured memory_bytes: 1024
from collections import deque

def bfs(grid, sy, sx, target, wall):
    grid[sy][sx] = wall
    queue = deque([])
    queue.append([sy, sx, 0])
    dxy = [(1,0), (-1,0), (0,1), (0,-1)]
    while queue:
        y,x,cnt = queue.popleft()
        for dy, dx in dxy:
            y_,x_ = y+dy,x+dx
            if [y_, x_] == target:
                return cnt+1
            if grid[y_][x_] == wall:
                continue
            queue.append([y_,x_,cnt+1])
            grid[y_][x_] = wall
    return -1

H,W = map(int, input().split())

edges = ['#' for i in range(W+2) ]
grid = [edges]
white = 0
for i in range(H):
    s = input()
    grid.append(['#'])
    for j in range(W):
        grid[i+1].append(s[j])
        white += 1 if s[j] == '.' else 0
    grid[i+1].append('#')
grid.append(edges)

ans = bfs(grid, 1, 1, [H,W], '#')

if ans == -1:
    print(ans)
else:
    print(white - ans - 1)

Measured memory_bytes: 3444
#include<stdio.h>
int main(){
  int N;
  scanf("%d",&N);
  
  if (N%10==7)printf("Yes");
  else if ((N/10)%10==7)printf("Yes");
  else if((N/100)%10==7)printf("Yes");
  
  else printf("No");
  
  return;
 
}


Measured memory_bytes: 1732
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP){ 
    return firstP.second < secondP.second; 
}//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

vi v;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll xx;ll tmp = 10;
    rep(i,5){
        cin>>xx;
        if(xx%10 != 0){
            chmin(tmp,xx-10*(xx/10));
            xx = 10*(xx/10 + 1);
        }
        v.pb(xx);
    }
    ll ans=0;
    rep(i,5){
        ans += v[i];
    }
    cout<<ans-10+tmp<<endl;
    return 0;
}

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

using namespace std;

using point = pair<int, int>;

int main(int argc, char *argv[]) {
	long H, W, N;
	cin >> H >> W >> N;
	map<point, int> board;

	long ans[10] = {};
	ans[0] = (H - 2) * (W - 2);
	for (int i = 0; i < N; i++) {
		int px, py;
		cin >> py >> px;

		px--; py--;
		for (int x = px - 2; x <= px; x++) {
			if (x < 0 || x >= W - 2) continue;
			for (int y = py - 2; y <= py; y++) {
				if (y < 0 || y >= H - 2) continue;

				if (board[make_pair(x, y)] == 0) ans[0]--;
				board[make_pair(x, y)]++;
			}
		}
	}

	for (auto p : board) {
		ans[p.second]++;
	}

	for (int i = 0; i < 10; i++)
		cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 56448