akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> 
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define F(x) for(auto it:x)
#define in insert
#define pb push_back
#define pi pair<int,int>
#define si second
#define fi first
#define show_(x) cerr<<"-> "<<#x<<endl;F(x){cerr<<it<<" ";}cout<<endl;
#define show(x) cerr<<#x<<"-> "<<x<<endl;
//#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
//#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define FILEIO freopen("F:\\inout\\input.txt", "r", stdin); freopen("F:\\inout\\output.txt", "w", stdout);
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rb;
void print(int a[],int n){f(n){cout<<a[i]<<" ";}cout<<endl;}
int m(int x){return x%1000000007;} 
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int p(int a,int b){if(b==0)return 1;int t=p(a,b/2); if(b%2==0)return t*t; else return a*t*t; } 
//---------------------------------------------------------------------------------------------------------------------------------------------


signed main(){
	//FILEIO
	//cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	//----sure_am-----
	

	char c;
	cin>>c;
	c=c+1;
	cout<<c<<endl;	
	






	return 0;
}





Measured memory_bytes: 256
#include "bits/stdc++.h"
    using namespace std;
    int main()
    {
        double l;
        cin>>l;
        double n=(l)/3;
        printf("%0.12lf\n",n*n*n);
        // cout<<n*n*n<<endl;
        // int t;
        // cin>>t;
        // while(t--)
        // {

        // }
    }

Measured memory_bytes: 256
/*
 *  author: kiran bhanushali
 *  handle: kinibha
 *  time:
 *  email:kiranbhanushali143.kb143@gmail.com
 */


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

#define int  long long 
  

int32_t main(){
    
    int n , m , c;
    cin>>n>>m>>c;
    vector<int> b(m);
    for(int i = 0; i<m;i++){
        cin>>b[i];
    }
    int ans = 0 ; 
    for(int i =0 ;i<n;i++){
        int sum = 0;
        for(int j = 0 ; j<m;j++){
            int a; 
            cin>>a;
            sum+= a*b[j];
        }
        sum+= c;
        if(sum>0) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
S = str(input())
N = len(S)
L = []
for i in range(int((N-1)/2)):
    if S[i] == S[int((N-3)/2)-i] and S[int((N+1)/2)+i] == S[N-i-1]:
        L.append('Yes')
    else:
        L.append('No')
for i in range(N):
    if S[i] == S[N-1-i]:
        L.append('Yes')
    else:
        L.append('No')
if all(x=='Yes' for x in L):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
using ll = long long;
using namespace std;
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;
}

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

    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    S = "#" + S + "#";

    auto can_reach = [&](int start, int end) {
        FOR(i, start, end - 1) {
            if (S[i] == '#' && S[i + 1] == '#')
                return false;
        }
        return true;
    };

    if (!can_reach(A, C) || !can_reach(B, D)) {
        std::cout << "No" << '\n';
        return 0;
    }

    if (D < C) {
        bool f = false;
        FOR(i, B, D + 1) {
            if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
                f = true;
            }
        }
        if (!f) {
            std::cout << "No" << '\n';
            return 0;
        }
    }

    std::cout << "Yes" << '\n';

    return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>
#define int unsigned long long
using namespace std;

main()
{
    int x,y;
    cin>>x>>y;
    bitset<32> a(x),b(y);
    cout<<(a&b)<<"\n";
    cout<<(a|b)<<"\n";
    cout<<(a^b)<<"\n";
}





Measured memory_bytes: 3136
#include <algorithm>
#include <string>
#include <vector>
#include "math.h"
#include <iostream>

using namespace std;

int main()
{
	int digit[8], n, a, b;
	char c;
	
	cin >> n;
	for (int i=0; i<n; i++) {
		for (int i=0; i<8; i++) {
			cin >> c;
			digit[i] = c-'0';
		}
		sort(digit, digit+8);
		a=0; b=0;
		for (int i=0; i<8; i++) {
			b+=digit[i]*pow(10, i);
			a+=digit[7-i]*pow(10, i);
		}
		cout << b-a << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long n, k, d;
	cin >> n >> k >> d;
	n = abs(n);
	long long m = 1000000000000000;
	if (m / k >= d) {
		if (n >= k * d) {
			cout << n - k * d << endl;
			return 0;
		}
	}
	if (1) {
		k = k - n / d;
		n %= d;
		if (k % 2 == 0) {
			cout << min(abs(n), abs(n - d * 2)) << endl;
		}
		else {
			cout << min(abs(n - d), abs(n + d)) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
using ll = long long;

int main() {
	ll A, B, K;
	cin >> A >> B >> K;

	if (K <= A) {
		cout << A - K << " " << B << endl;
	}
	else if (K <= A + B) {
		cout << 0 << " " << B - (K - A) << endl;
	}
	else {
		cout << 0 << " " << 0 << endl;
	}
}

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

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

            // 解析
            decimal iOut = lstT[0];
            for (int i = 1; i < lstT.Count; i++)
            {
                iOut = Lcm(iOut, lstT[i]);
            }

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

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

        // 最小公倍数取得
        private static decimal Lcm(decimal a, decimal b)
        {
            return a * (b / Gcd(a, b));                         // 特殊 本当は a * b / Gcd(a, b);
        }

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


Measured memory_bytes: 13268
p[1000055],s,r;main(i,j){for(;++i<9999;)for(j=i*2;j<1e6;j+=i)p[j]=1;for(;scanf("%d",&i),i;printf("%d\n",r))for(s=2,r=0;i;i-=!p[s++])r+=p[s]?0:s;exit(0);}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a=200000,b=0,c;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='A'){
      a=min(i,a);
    }else if(s.at(i)=='Z'){
      b=max(i,b);
    }
  }
  cout<<b-a+1<<endl;
}


Measured memory_bytes: 640
import numpy as np
from numba import njit

N, K = list(map(int, input().strip().split()))
A = np.array(input().strip().split(), dtype=np.int64)

@njit(cache=True)
def calc(a, step):
    b = np.array([0]*N)
    for i in range(N):
        left = int(max(0, i-a[i]))
        right = int(min(N-1, i+a[i]))
        b[left] += 1
        if right + 1 < N:
            b[right+1] -= 1
    b = np.cumsum(b)
    
    if np.all(a==b) or step>=K:
        return b
    else:
        step += 1
        return calc(b, step)

ans = calc(A, 1)
ans = [str(x) for x in ans]
print(" ".join(ans))

Measured memory_bytes: 197964
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())


class PotentialUnionFind:
    def __init__(self,N): # 頂点数 N
        self.table = [i for i in range(N)]    # 親 table[x] == x で根
        self.rank  = [1 for i in range(N)]    # 木の長さ
        self.size  = [1 for i in range(N)]    # 集合のサイズ
        self.diffweight = [0 for i in range(N)]

    def Find(self,x):    #xの根を返す
        if self.table[x] == x:
            return x
        else:
            root = self.Find(self.table[x]) #親の更新
            self.size[x] = self.size[self.table[x]]
            self.diffweight[x] += self.diffweight[self.table[x]]
            self.table[x] = root
            return self.table[x]

    def Unite(self,x,y,w): #xとyをDiff(x,y)=W で繋げる
        w = w - self.Weight(y) + self.Weight(x)
        x,y = self.Find(x), self.Find(y)
        sx,sy = self.Size(x), self.Size(y)
        if x == y: return
        if self.rank[x] > self.rank[y]:
            self.table[y] = x
            self.size[x] = sx + sy
            self.diffweight[y] = w
        else:
            self.table[x] = y
            self.size[y] = sx + sy
            self.diffweight[x] = -w
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def Check(self,x,y):
        return self.Find(x) == self.Find(y)

    def Size(self,x):
        return self.size[self.Find(x)]

    def Weight(self,x): # 重さ(根からの距離)
        self.Find(x)
        return self.diffweight[x]

    def Diff(self,x,y): # 繋がってる二点間距離
        return self.Weight(y) - self.Weight(x)


N,M = inpl()
PUF = PotentialUnionFind(N)

for _ in range(M):
    l,r,d = inpl()
    l,r = l-1,r-1
    if PUF.Check(l,r):
        if PUF.Diff(l,r) == d:
            continue
        else:
            print('No')
            exit()
    else:
        PUF.Unite(l,r,d)

print('Yes')


Measured memory_bytes: 11740
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val n = input.split(LINE_SEPARATOR).head.toInt
    val x = input.split(LINE_SEPARATOR).tail.map(_.split(" ").head.toDouble)
    val y = input.split(LINE_SEPARATOR).tail.map(_.split(" ").tail.head.toDouble)

    val d = (0 until n).combinations(2).map{comb =>
      val i = comb(0)
      val j = comb(1)
      (comb(0) -> comb(1)) -> sqrt((x(i)-x(j))*(x(i)-x(j)) + (y(i) - y(j))*(y(i) - y(j)))
    }.toMap
    val result = (0 until n).permutations.map{perm =>
      perm.sliding(2).map{pair =>
        d((min(pair(0), pair(1)), max(pair(0), pair(1))))
      }.sum
    }.sum / (0 until n).permutations.size
    result.toString
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """3
      |0 0
      |1 0
      |0 1""".stripMargin -> """2.2761423749
                                   |""".stripMargin,
    """2
      |-879 981
      |-866 890""".stripMargin -> """91.9238815543
                                        |""".stripMargin,
    """8
      |-406 10
      |512 859
      |494 362
      |-955 -475
      |128 553
      |-986 -885
      |763 77
      |449 310""".stripMargin -> """7641.9817824387"""
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 107168
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
P p[200000];
int a,b,c,sum=0,ans=0;
vector<P> v;
signed main(){
	cin>>a>>b>>c;
	f(i,a)cin>>p[i].F>>p[i].S;
	sort(p,p+a);
	v.push_back({-1,0});
	f(i,a){
		int z=lower_bound(all(v),P(p[i].F,(int)0))-v.begin();
		if(z==v.size()||sum-v[z-1].S<p[i].S){
			int x=(p[i].S+v[z-1].S-1-sum)/c+1;
			ans+=x;
			v.push_back({p[i].F+b+b,c*x+v[v.size()-1].S});
			sum+=c*x;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 9072
#include<stdio.h>

int str_lenth(char str[]);
int judge(char s[], char p[], int lenth_s, int lenth_p, int k);

int main(void)
{
		char s[100];
		char p[100];
		int k;

		scanf("%s", s);
		scanf("%s", p);

		int lenth_s, lenth_p;
		lenth_s = str_lenth(s);
		lenth_p = str_lenth(p);
		//printf("lenth_s: %d\nlenth_p: %d\n", lenth_s, lenth_p);
		for(k=0; k<lenth_s; k++)
		{
				if(judge(s, p, lenth_s, lenth_p, k) == 1)
				{
						printf("Yes\n");
						break;
				}
		}

		if(k==lenth_s)
		{
				printf("No\n");
		}

		return 0;
}



int str_lenth(char str[])
{
		int cnt;
		for(cnt=0; str[cnt]!='\0'; cnt++);
		return cnt;
}


int judge(char s[], char p[], int lenth_s, int lenth_p, int k)
{
		int i;
		int flag = 1;
		for(i=0; i<lenth_p; i++)
		{
				if(s[k] != p[i])
				{
						flag = 0;
						break;
				}

				if(++k > lenth_s-1)
				{
						k=0;
				}
		}
		//printf("s[%d] p[%d] flag = %d\n", i, k, flag);
		return flag;
}

Measured memory_bytes: 524
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
#https://atcoder.jp/contests/arc084/tasks/arc084_a
#C - Snuke Festival
"""
need to consider the case that ticket is not enough to lower everything
"""


def bt():
    global prefix, ans
    prefix *= 10

    for i in range(3):
        prefix += ds[i]
        cnt[i] += 1

        if prefix <= N:
            if all(cnt):
                ans += 1
            bt()
        cnt[i] -= 1
        prefix -= ds[i]
    prefix /= 10


N = gi()
prefix = 0
ds = [3, 5, 7]
cnt = [0] * 3
ans = 0

bt()
print(ans)


Measured memory_bytes: 14700
S = list(map(int, list(input())))
S.reverse()
a = [0]*len(S)
y = 2019
x = 1
t = 0
cnt = [0]*y
res = 0
for i in range(len(S)):
    cnt[t] += 1
    t += S[i]*x
    t %= y
    res += cnt[t]
    x = x*10%y
print(res)

Measured memory_bytes: 11968
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
struct Edge {
	int from, to;
	long long int cost;
	Edge(const int f, const int t, const int c) :from{ f }, to{ t }, cost{ c }{};
};
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<Edge> edges; 
	std::vector<std::vector<int>> in_edges(n);
	for (auto i = 0; i < m; ++i) {
		int a, b, c; std::cin >> a >> b >> c;
		edges.emplace_back(a - 1, b - 1, c);
		in_edges[b - 1].push_back(a - 1);
	}
	std::vector<bool> can_reach_goal(n, false); can_reach_goal[n - 1] = true;
	std::queue<int> queue; queue.push(n - 1);
	while (!queue.empty()) {
		auto top = queue.front(); queue.pop();
		for (const auto next : in_edges[top]) if (!can_reach_goal[next]) {
			can_reach_goal[next] = true;
			queue.push(next);
		}
	}
	std::vector<long long int> max_cost(n, LLONG_MIN);
	max_cost[0] = 0;
	for (auto i = 0; i < n; ++i) {
		for (const auto& e : edges) if (can_reach_goal[e.from] && can_reach_goal[e.to]){
			if (max_cost[e.from] != LLONG_MIN && max_cost[e.to] < max_cost[e.from] + e.cost) {
				max_cost[e.to] = max_cost[e.from] + e.cost;
			}
		}
	}
	if (std::any_of(edges.begin(), edges.end(), [&can_reach_goal, &max_cost](const Edge& e) {
		return can_reach_goal[e.from] && can_reach_goal[e.to] && (max_cost[e.from] != LLONG_MIN && max_cost[e.to] < max_cost[e.from] + e.cost); })) {
		std::cout << "inf" << std::endl;
	}
	else {
		std::cout << max_cost[n - 1] << std::endl;
	}
}


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

using namespace std;

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

    int n;
    cin >> n;
    int a[n + 2];
    a[0] = 0;
    a[n + 1] = 0;
    for(int i = 1; i <= n; i++)
        cin >> a[i];

    int sum = 0;
    for(int i = 0; i <= n; i++)
        sum += abs(a[i] - a[i + 1]);
    for(int i = 1; i <= n; i++)
        cout << sum + abs(a[i - 1] - a[i + 1]) - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])) << "\n";

    return 0;
}


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

int main() {
  double w,h,x,y; cin>>w>>h>>x>>y;
  cout<<w*h/2<<" ";
  if(w/2==x && h/2==y){cout<<1<<endl;}
  else{cout<<0<<endl;}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int m, min, max, i, p[10000], diff[10000], gap, nmax;
  while(1){

    scanf("%d%d%d", &m, &min, &max);

    if(m==0 && min==0 && max==0)break;
    
    for(i=0; i<m; i++){
      scanf("%d", &p[i]);
      if(i!=0){
	diff[i]=p[i-1]-p[i];
      }
    }
    gap=0;
    nmax=min;
    for(i=min; i<max+1; i++){
      if(diff[i]>=gap){
	nmax=i;
	gap=diff[i];
      }
    }
    printf("%d\n", nmax);
  }
  return 0;
}

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

#define A

#ifdef A
int main(void) {


	string str;

	getline(cin, str);
	for (size_t i = 0; i < str.size(); i++)
	{
		if (str[i] > 0x40 && str[i] < 0x5b)
		{
			cout << static_cast<char>(str[i] + 0x20);
		}
		else if (str[i] > 0x60 && str[i] < 0x7b)
		{
			cout << static_cast<char>(str[i] - 0x20);

		}
		else 
			cout << str[i];
	}
	cout << endl;
	return 0;
}
#endif // A

Measured memory_bytes: 3192
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////
 
int N,Q;
string S;
vector<char> t,d;

bool leftfall (int x) {
    if (x < 1) return true;
    if (x > N) return false;
    rep(i,Q) {
        if (S[x-1] == t[i]) {
            if (d[i] == 'L') x--;
            else x++;
        }
        if (x < 1) return true;
        if (x > N) return false;
    }
    return false;
}

bool rightfall (int x) {
    if (x < 1) return false;
    if (x > N) return true;
    rep(i,Q) {
        if (S[x-1] == t[i]) {
            if (d[i] == 'L') x--;
            else x++;
        }
        if (x > N) return true;
        if (x < 1) return false;
    }
    return false;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N >> Q >> S;
    t.resize(Q); d.resize(Q);
    rep(i,Q) cin >> t[i] >> d[i];

    int left = 0;
    int right = N+1;
    while(right - left > 1) {
        int mid = (right + left) / 2;
        if (leftfall(mid)) left = mid;
        else right = mid;
    }
    int ansl = left;

    left = 0;
    right = N+1;
    while(right - left > 1) {
        int mid = (right + left) / 2;
        if (rightfall(mid)) right = mid;
        else left = mid;
    }
    int ansr = left;

    cout << max(0,ansr - ansl) << endl;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cout << fixed << setprecision(12);
	cin >> a >> b;
	if((a-b)&1) print1("IMPOSSIBLE");
	else print1(a+b>>1);
	return 0;
}

Measured memory_bytes: 256
import math
a, b, H, M = [int(i) for i in input().split()]
angle1 = (2 * math.pi / 12) * (H + M / 60)
angle2 = (2 * math.pi / 60) * M
res = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(angle2 - angle1))
print(res)

Measured memory_bytes: 62348
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 10005
 
#define PI   3.14159265358979323846264338327950

#define PB push_back 
#define F first
#define S second
 
#define ll 	 long long int

#define mod  1000000007

vector<ll> v;
bool p[MAXX];
int main()
{
	FAST;
	ll n;
	cin >> n;
	ll a[n+ 6];
	bool flag = false;
	for(ll i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] % 2){
			flag = true;
		}
	}
	if(flag){
		cout << "first";
		return 0;
	}
	cout << "second";
	return 0;
}

Measured memory_bytes: 4452
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	fastio();
	int n;
	cin >> n;
	map<string, int> m;
	vector<string >a(n);
	vin(a);
	m[a[0]] = 1;
	for (int i = 1; i < a.size(); ++i)
	{
		if (a[i][0] != a[i - 1].back())
		{
			cout << "No";
			return 0;
		}
		if (m[a[i]])
		{
			cout << "No";
			return 0;
		}
		m[a[i]] = 1;
	}
	cout << "Yes";
	system("pause");
}

Measured memory_bytes: 504
package main

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

var (
	MaxBuffLen  = 100000 + 1024
	InitBuffLen = 1024
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 1024), MaxBuffLen)
	scanner.Scan()
	buff := scanner.Bytes()

	r := 0
	for _, b := range buff {
		if b == '0' {
			r++
		}
	}
	fmt.Println(2 * min(r, len(buff)-r))
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n, k, d, a; set <int> s;

void solve()
{
    cin >> n >> k;
    for (int i=0; i<k; i++) {
        cin >> d;
        while (d--) {
            cin >> a; s.insert(a);
        }
    }
    nout(n-s.size());
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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

int A1, A2, A3;

int main() {
  cin >> A1 >> A2 >> A3;
  if (A1 + A2 + A3 >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  char a,b,c;
  cin >>a>>b>>c;
  int d=(int)a-'0';
  int e=(int)b-'0';
  int f=(int)c-'0';
  cout<< d+e+f<<endl;

}


Measured memory_bytes: 256
// 2020-09-25 22:49:28
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
using edge = pair<int, ll>;  // b, c
const int MX = 100010;
ll d[MX];
vector<edge> G[MX];
void dfs(int u) {
  for (auto [v, c] : G[u])
    if (d[v] == -1) {
      d[v] = d[u] + c;
      dfs(v);
    }
}
void answer() {
  int n;
  cin >> n;
  rep(i, n - 1) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].emplace_back(edge(b, c));
    G[b].emplace_back(edge(a, c));
  }
  int q, k;
  cin >> q >> k;
  k--;
  memset(d, -1, sizeof d);
  d[k] = 0;
  dfs(k);
  rep(qi, q) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    cout << d[x] + d[y] << '\n';
  }
}

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

Measured memory_bytes: 16000
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	t := nextInt()

	min := 2000
	for i := 0; i < n; i++ {
		c := nextInt()
		ti := nextInt()
		if ti <= t && c < min {
			min = c
		}
	}
	if min == 2000 {
		fmt.Println("TLE")
	} else {
		fmt.Println(min)
	}
}


Measured memory_bytes: 640
import java.util.*;
import java.util.function.BinaryOperator;
import java.util.function.UnaryOperator;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        SegmentTree<Integer> seg = new SegmentTree<>(n, Integer::max, Integer.MIN_VALUE);
        
        // 初期の配列を取得
        for (int i = 0; i < n; i++) {
            seg.update(i, sc.nextInt());
        }
        
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
        for (int i = 0; i < n; i++) {
            int now = seg.query(i, i+1);
            int max = seg.query(i+1, n);
            
            if (now < max) {
                int key = max - now;
                int val = map.getOrDefault(key, 0);
                map.put(key, ++val);
            }
        }
        
        int last_val = map.get(map.lastKey());
        System.out.println(last_val);
    }
}

class SegmentTree<T> {
    // dat: 0-indexed
    // 00000000
    // 11112222
    // 33445566
    // 789ABCDE ... a[0]-a[n]
    
    final T[] dat;              // データを格納する配列
    final int n;                // datの一番下のレベルの要素数
    final BinaryOperator<T> f;  // 二項演算子
    final T e;                  // 単位元

    // 単位元で埋めて新規作成
    public SegmentTree(int len, BinaryOperator<T> f, T e) {
        int n = 1;
        while (n < len) n <<= 1;
        this.n = n;
        this.f = f;
        this.e = e;
        this.dat = (T[]) new Object[n << 1];
        Arrays.fill(dat, e);
    }
    
    // 一点更新(a[i] = x) O(logN)
    public void update(int i, T x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;  // i: parent of vl/vr
            T vl = dat[i * 2 + 1];
            T vr = dat[i * 2 + 2];
            dat[i] = f.apply(vl, vr);
        }
    }
    
    // 区間取得[a, b) O(logN)
    public T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    public T query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {             // outside completely
            return e;
        } else if (a <= l && r <= b) {      // inside completely
            return dat[k];
        } else {
            T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return f.apply(vl, vr);
        }
    }
    
    // 使用例
    // Range Sum Query
    // SegmentTree<Integer> seg = new SegmentTree<>(n, Integer::sum, 0);
    // SegmentTree<Long> seg = new SegmentTree<>(n, Long::sum, 0L);
    
    // Range Minimum Query
    // SegmentTree<Integer> seg = new SegmentTree<>(n, Integer::min, Integer.MAX_VALUE);
    
    // Range Maximum Query
    // SegmentTree<Long> seg = new SegmentTree<>(n, Long::max, Long.MIN_VALUE);
}

Measured memory_bytes: 68876
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979

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




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}


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

  if(S == "ABC"){
    ans = "ARC";
  }else{
    ans = "ABC";
  }

  cout << ans<< endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
string s;
vector<int> vec[30];
vector<P> ve;
int x[200010];
int BIT[200010];
int ans;

void add(int k) {
	while (k <= n) {
		BIT[k]++;
		k += k & -k;
	}
}

int sum(int k) {
	int res = 0;
	while (0 < k) {
		res += BIT[k];
		k -= k & -k;
	}
	return res;
}

signed main() {
	cin >> s;
	n = (int)s.size();
	for (int i = 0; i < n; i++)vec[s[i] - 'a'].push_back(i);
	int k = 0;
	for (int i = 0; i < 26; i++)if ((int)vec[i].size() % 2)k++;
	if (2 <= k) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i < 26; i++) {
		int p = (int)vec[i].size();
		if (p % 2)x[n / 2] = vec[i][p / 2];
		for (int j = 0; j < p / 2; j++)ve.push_back(make_pair(vec[i][j], j));
	}
	sort(all(ve));
	for (int i = 0; i < (int)ve.size(); i++) {
		x[i] = ve[i].first;
		int p = s[ve[i].first] - 'a';
		int q = (int)vec[p].size();
		x[n - 1 - i] = vec[p][q - 1 - ve[i].second];
	}
	for (int i = 0; i < n; i++) {
		ans += i - sum(x[i] + 1);
		add(x[i] + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8692
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int gx = sc.nextInt();
        int gy = sc.nextInt();
        int dx = gx - sx;
        int dy = gy - sy;
        for (int i = 0; i < dx; i++) {
            System.out.print("R");
        }
        for (int i = 0; i < dy; i++) {
            System.out.print("U");
        }
        for (int i = 0; i < dx; i++) {
            System.out.print("L");
        }
        for (int i = 0; i < dy; i++) {
            System.out.print("D");
        }
        System.out.print("D");
        for (int i = 0; i < dx; i++) {
            System.out.print("R");
        }
        System.out.print("R");
        for (int i = 0; i < dy; i++) {
            System.out.print("U");
        }
        System.out.print("U");
        System.out.print("L");
        System.out.print("U");
        for (int i = 0; i < dx; i++) {
            System.out.print("L");
        }
        System.out.print("L");
        for (int i = 0; i < dy; i++) {
            System.out.print("D");
        }
        System.out.print("D");
        System.out.print("R");
        System.out.println();
    }
}


Measured memory_bytes: 23252
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    private static double EPSILON = 1e-9;

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int x = scanner.nextInt();
        int full = a * a * b;
        double half = full / 2.0;
        double ans;
        if (x >= half) {
            double l = 0;
            double r = b;
            while (l < r - EPSILON) {
                double mid = (l + r) / 2;
                if ((b + mid) * a * a / 2 < x)
                    l = mid;
                else
                    r = mid;
            }
            ans = Math.toDegrees(Math.atan((b - l) / a));
        } else {
            double l = 0;
            double r = a;
            while (l < r - EPSILON) {
                double mid = (l + r) / 2;
                if ((b * mid) * a / 2 < x)
                    l = mid;
                else
                    r = mid;
            }
            ans = Math.toDegrees(Math.atan(b / l));
        }

        writer.println(ans);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        private void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        private char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        private String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

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

int dp[100002], c, yukseklik[100002];

int mutlak(int e, int r){
	if(e>r)return e-r;
	else return r-e;
}

int recursive(int n){
	if(dp[n])return dp[n];
	if(n==c)return 0;
	if(n>c)return 9999;
	int a=recursive(n+1)+mutlak(yukseklik[n],yukseklik[n+1]);
	int b=recursive(n+2)+mutlak(yukseklik[n],yukseklik[n+2]);
	if(a<b){
		dp[n]=a;
		return dp[n];
	}else{
		dp[n]=b;
		return dp[n];
	}
}

int main(void){
	cin>>c;
	for(int i=1;i<=c;i++)cin>>yukseklik[i];
	memset(dp, 0, sizeof(int)*(c+1));
	dp[c]=0;
	//recursive(1);
	dp[c-1]=mutlak(yukseklik[c],yukseklik[c-1]);
	for(int i=c-2;i>0;i--)dp[i]=min(mutlak(yukseklik[i], yukseklik[i+1])+dp[i+1],mutlak(yukseklik[i], yukseklik[i+2])+dp[i+2]);
	cout<<dp[1];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int mini;
	cin>>mini;
	int ans=INT_MIN;
	for(int i=1; i<n; i++){
		int m;
		cin>>m;
		int tmp=m-mini;
		ans=max(tmp,ans);
		mini=min(m,mini);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main()
{
	int n,k;
	cin >> n;
	for(int f=0;;f++){
		for(int s=0;;s++){
			k=f*4+s*7;
			if(k>=n){
				if(k==n)
					cout << "Yes" << endl;
				break;
			}
		}
		if(k==n)break;
		if(f*4>n){
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}

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

int a[5];

int main(){
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	int res = 0;
	for (int i = 0; i < 2; i++)
	{
		res += abs(a[i+1] - a[i]);
	}

	cout << res << endl;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b;cin>>a>>b;
  if(a%3==0 || b%3==0 || (a+b)%3==0){
    cout<<"Possible"<<endl;
  }else {
    cout<<"Impossible"<<endl;

  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int K, N, ans, dis;
  cin >> K >> N;
  
  vector<int> house(N);
  for(int i = 0;i < N;i++){
  cin >> house.at(i);
  }
  
  ans = K + house.at(0) - house.at(N - 1);
  
  for(int i = 0;i < N - 1;i++){
  dis = house.at(i + 1) - house.at(i);  
    if(ans < dis){
    ans = dis;
    }
  }
  cout << K - ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
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;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int x;
  cin >> x;
  if (x >= 30) cout << "Yes" << '\n';
  else cout << "No" << '\n';
  return (0);
}


Measured memory_bytes: 3604
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>
#define MOD 1000000007

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

vector<ll> inv,fact,invfact;
void setupCombination(ll n_max,ll mod){
    fact.resize(n_max+1);
    inv.resize(n_max+1);
    invfact.resize(n_max+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    for(ll i=0;i<n_max;i++){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll getCombinationMOD(ll n,ll k,ll mod){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll getHomogeneousProductMOD(ll n,ll r,ll mod){
    return getCombinationMOD(n +r-1,r,mod);
}

ll ans=0;
int main(){

    
    cin >> N;
    cin >> K;
    setupCombination(base10_6,MOD);

    ll repeat = N;
    if(N>K) repeat = K;


    for( int ni = 0 ; ni <=repeat ; ni++ ){
        ll leftK = K-ni;
        ll leftRoom = N - ni;
        ll leftPerson = ni;
        ans = ans + getCombinationMOD(N,ni,MOD) * getHomogeneousProductMOD(leftRoom,leftPerson,MOD);
        ans = ans + MOD;
        ans = ans % MOD;
    }
    ans = ans + MOD;
    ans = ans % MOD;
    cout << ans << endl;

        
    

}

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

typedef long long int ll;
ll a[200000];
ll pre[400001];

void pa(ll* arr, ll a, ll b){
    for(int i=a; i < b; i++) cout << arr[i] << " ";
    cout << endl;
}

int main(){
    int a; int b;
  	cin >> a >> b;
  cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 3596
cs=$<.read.split.map(&:to_i)
cs=cs.each_slice(3).to_a

i = 0
while i < 3
    cs[i] = cs[i].map {|c| c-cs[i].min}
    i += 1
end
cs = cs.transpose
i = 0
while i < 3
    cs[i] = cs[i].map {|c| c-cs[i].min}
    i += 1
end

b = cs.flatten.inject(&:+) == 0
puts(b ? 'Yes' : 'No')


Measured memory_bytes: 1788