akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    long long sum = 0;
    int pre = 0, next = 0;
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
        sum += std::abs(a[i] - pre);
        pre = a[i];
    }
    // 最後自宅に戻るぶん
    sum += std::abs(pre - next);

    for(int i = 0; i < n; i++){
        if(i == 0){
            pre = 0;
            next = a[i + 1];
        }else if(i == n - 1){
            pre = a[i - 1];
            next = 0;
        }else{
            pre = a[i - 1];
            next = a[i + 1];
        }
        long long tmp = sum;
        tmp -= std::abs(pre - a[i]) + std::abs(a[i] - next);
        tmp += std::abs(pre - next);
        std::cout << tmp << std::endl;
    }
    
    return 0;
}


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

int main() {
  int N, M; cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  
  double sum = 0;
  for (int i = 0; i < N; i++) sum += A[i];
  
  double is_popular = sum / (4.0 * M);
  
  int num = 0;
  for (int i = 0; i < N; i++) {
    if (is_popular <= A[i]) num++;
  }
  
  if (M <= num) cout << "Yes" << endl;
  else cout << "No" << endl;  
}

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

int main(){
  int N; cin>>N;
  if(N%2==1){
    cout<<(N-1)*(N-1)/2<<endl;
    for(int i=1;i<N;i++){
      for(int j=i+1;j<=N;j++){
        if(i+j!=N){
          cout<<i<<" "<<j<<endl;
        }
      }
    }
  }else{
    cout<<N*(N-2)/2<<endl;
    for(int i=1;i<=N;i++){
      for(int j=i+1;j<=N;j++){
        if(i+j!=N+1){
          cout<<i<<" "<<j<<endl;
        }
      }
    }
  }
}

Measured memory_bytes: 256
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);
            var c = int.Parse(_[2]);
            var d = int.Parse(_[3]);

            var left = a + b;
            var right = c + d;

            if(left > right){
                Console.WriteLine("Left");
            }else if(left < right){
                Console.WriteLine("Right");
            }else{
                Console.WriteLine("Balanced");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
long long n, i = 0,  a = 10, b = 9, c = 8, mod = 1000000007;
int main() { cin >> n;
    for(; i < n - 1; i++) {
        a *= 10; a %= mod;
        b *= 9;  b %= mod;
        c *= 8;  c %= mod;
    }
    a += c; a %= mod;
  cout << (a - (2 * b) % mod + mod) % mod << endl;
}

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

#define x first
#define y second

#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cerr << #x << ": " << x << endl;
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

vi al[200000];
int n;
bool act[200000],vis[200000];
int mex[200000];
vi cyc;

vi seen;

int mx(int i,int o=-1) {
	if (mex[i]!=-1) return mex[i];
	seen.clear();
	for (int j:al[i]) if (j!=o) seen.push_back(mex[j]);
	sort(seen.begin(),seen.end());
	seen.resize(unique(seen.begin(),seen.end())-seen.begin());
	for (int c=0;c<seen.size();c++) if (seen[c]!=c) {
		return mex[i]=c;
	}
	return mex[i]=seen.size();
}

bool tmx(int i) {
	int v=mex[i];
	mex[i]=-1;
	bool res=mx(i)==v;
	mex[i]=v;
	return res;
}

bool consist() {
	for (int i:cyc) if (!tmx(i)) return 0;
	return 1;
}


bool dfs(int i) {
	if (vis[i]) return 0;
	if (act[i]) return 1;
	act[i]=1;
	bool incyc=0;
	for (int j:al[i]) {
		incyc=dfs(j)||incyc;
	}
	vis[i]=1;
	if (incyc) {
		cyc.push_back(i);
		return 1;
	}

	mx(i);
	return 0;
}

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

	cin >> n;
	for (int i=0;i<n;i++) {
		int u;cin >> u;u--;
		al[u].push_back(i);
	}

	fill(mex,mex+n,-1);

	for (int i=0;i<n;i++) if (!vis[i]) {
		dfs(i);
		if (cyc.size()) {
			//if (cyc.size()%2) cout << "IMPOSSIBLE\n";
			//else cout << "POSSIBLE\n";
			//return 0;
			mex[cyc[0]]=-1;
			int mx0=mx(cyc[0],cyc.back());
			for (int j=1;j<cyc.size();j++) mex[cyc[j]]=-1,mx(cyc[j]);
			if (!consist()) {
				mex[cyc.back()]=mx0;
				for (int j=0;j+1<cyc.size();j++) {
					mex[cyc[j]]=-1;
					mx(cyc[j]);
				}
				if (!consist()) {
					cout << "IMPOSSIBLE\n";
					return 0;
				}
			}
			cyc.clear();
		}
	}

	cout << "POSSIBLE\n";

}

Measured memory_bytes: 22996
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	int x , a , b;
    cin >> x >> a >> b;
    if (a >= b) cout << "delicious";
    else if (a + x >= b) cout << "safe";
    else cout << "dangerous";
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

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

typedef long long ll;


int main()
{
    int n, m, sum = 0, current;
    cin >> n >> m;

    for (int i=0; i<m; i++) {
        cin >> current;
        sum += current;
    }

    if (sum > n) {
        cout << -1 << endl;
    } else {
        cout << n-sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
def rotate(str)
	strs = str.chars
	[strs.pop, strs].join("")
end

attrs = Array.new
while line = $stdin.gets
	attrs << line.chomp.split[0]
	if attrs.length >= 2
		break
	end
end

str = attrs[0]
str.length.times do
	str = rotate(str)
	if str == attrs[1]
		puts 'Yes'
		exit
	end
end

puts 'No'


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

void solve(void) {
  int N;
  string str;
  cin >> N >> str;
  int ans = 0;
  for (int si = 0; si < N-2; ++si) {
    if (str.substr(si, 3) == "ABC") ++ans;
  }
  cout << ans << endl;
}
int main(void) {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

int main(){
    long long K,N,total = 0;
    long long ans = 0;
    
    cin >> N >> K;
    vector<int> H(N,0);

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

    sort(H.begin(),H.end());

    while(0 < K){
        N--;
        K--;
    }

    for(int i = 0;i < N;i++){
        ans += H[i];
    }

    cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++) {
				int cnt = 0;
				for (int now = 0; now < n; now++) {
					if ((int)(s[now] - '0') == i && cnt == 0) cnt++;
					else if ((int)(s[now] - '0') == j && cnt == 1) cnt++;
					else if ((int)(s[now] - '0') == k && cnt == 2) cnt++;
				}
				if (cnt == 3)ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3700
# 2019/01/13
# KEYENCE Programming Contest 2019 - C

# Input
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list()

# Init
sum = 0
minuscnt = 0
summinus = 0

for idx in range(n):
    yoyu = a[idx] - b[idx]
    c.append(yoyu)
    sum += yoyu
    if yoyu < 0:
        minuscnt += 1
        summinus += yoyu

c.sort(reverse=True)

if sum < 0:
    ans = -1
else:
    pluscnt = 0
    while summinus < 0:
        summinus += c[pluscnt]
        pluscnt += 1
    ans = minuscnt + pluscnt

# Output
print(ans)

Measured memory_bytes: 18292
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll x,a,b;
    cin >>x>>a>>b;
    
    cout << (x-a)%b <<endl;
    
    return 0;
}



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

int main()
{
  int64_t N, ans = 1;
  cin >> N;
  vector<int64_t> A(N), S(N + 1, 0);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++)
  {
    S[i + 1] = S[i] + A[i];
  }
  for (int i = N - 1; i >= 1; i--)
  {
    if (S[i] * 2 >= A.at(i))
      ans++;
    else
      break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1920
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
a.reverse()
s = sum(a)
flag = True

for i,j in enumerate(a):
    if i+1 > m:
        break
    if j < s/(4*m):
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void y(bool c) { if (c)print("Yes"); else print("No"); };

int A, B, C, D, E, X, Y, Z, N, M;
string S, T;
void solve() {
	cin >> A >> B >> C;
	cout << C << " " << A << " " << B;
}

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




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  s+=s[0];
  s+=s[1];
  bool flag=false;
  vector<int> v(n+2);
  rep(i,2){
    rep(j,2){
      v.clear();
      v.resize(n+2);
      v[0]=i;
      v[1]=j;
      for(int k=2;k<n+2;k++){
        // 0:羊,1:狼
        if(s[k-1]=='o' && v[k-2]==0 && v[k-1]==0){
          v[k]=0;
        }
        if(s[k-1]=='o' && v[k-2]==0 && v[k-1]==1){
          v[k]=1;
        }
        if(s[k-1]=='o' && v[k-2]==1 && v[k-1]==0){
          v[k]=1;
        }
        if(s[k-1]=='o' && v[k-2]==1 && v[k-1]==1){
          v[k]=0;
        }
        if(s[k-1]=='x' && v[k-2]==0 && v[k-1]==0){
          v[k]=1;
        }
        if(s[k-1]=='x' && v[k-2]==0 && v[k-1]==1){
          v[k]=0;
        }
        if(s[k-1]=='x' && v[k-2]==1 && v[k-1]==0){
          v[k]=0;
        }
        if(s[k-1]=='x' && v[k-2]==1 && v[k-1]==1){
          v[k]=1;
        }
      }
      if(v[0]==v[n] && v[1]==v[n+1]){
        rep(i,n){
          if(v[i]==0)cout << 'S';
          else cout << 'W';
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int row,column;
    cin >> row >> column;
    
    vector<vector<int> > mat(row+1, vector<int>(column+1,0));

    for(int i=0;i<row;i++){
        for(int j=0;j<column;j++){
            cin >> mat[i][j];
            mat[i][column]+=mat[i][j];
            mat[row][j]+=mat[i][j];
        }
    }
    
    for(int j=0;j<column;j++){
        mat[row][column]+=mat[row][j];
    }
    
    for(int i=0;i<=row;i++){
        for(int j=0;j<=column;j++){
            if(j!=column){
                cout << mat[i][j]<<' ' ;
            }else{
                cout << mat[i][j] ;
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int N = 500010;
    vector<char> a(N);
    {
        string s;
        cin >> s;
        for (int i = 0; i < s.size(); i++) {
            a[s.size() - 1 - i] = s[i] - '0';
        }
    }
    {
        int x = 0;
        for (int i = 0; i < N; i++) {
            a[i] = a[i] * 9 + x;
            x = a[i] / 10;
            a[i] = a[i] % 10;
        }
    }

    int s = 0;
    for (int x : a) s += x;
    int res = 0;
    while (s > res * 9) {
        res++;
        a[0] += 9;
        s += 9;
        for (int i = 0; i < N; i++) {
            if (a[i] < 10) break;
            s -= 9;
            a[i] -= 10;
            a[i + 1]++;
        }
//        cout << res << " " << s << "\n";
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 1684
from collections import deque

s=deque(list(input()))
q=int(input())


rev=0
for i in range(q):
  l=list(input().split())
  if len(l)==1:
#    s.reverse()
    rev+=1
  else:
    t,f,c=l[0],l[1],l[2]

    if rev%2==0:
      if f=='1':
        s.appendleft(c)
      else:
        s.append(c)
    else:
      if f=='1':
        s.append(c)
      else:
        s.appendleft(c)

s=list(s)
if rev%2==1:
  s.reverse()
print(''.join(s))

Measured memory_bytes: 8420
package main

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

const (
	maxBufsize = 1000000
)

func inputs(lines int) []string {
	var strSlice []string

	rdr := bufio.NewReaderSize(os.Stdin, maxBufsize)

	for i := 0; i < lines; i++ {

		line := ReadLine(rdr)
		strSlice = append(strSlice, line)

	}

	return strSlice
}

// ReadLine is to read long line
func ReadLine(rdr *bufio.Reader) string {
	buf := make([]byte, 0, maxBufsize)
	for {
		l, p, e := rdr.ReadLine()

		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}

	return string(buf)
}

func account(a int, interest float64) int {
	all := float64(a) * interest

	return int(math.Trunc(all))
}

func main() {
	lines := inputs(1)

	X, _ := strconv.Atoi(lines[0])

	interest := 1.01
	acc := 100
	year := 0
	for {
		year++
		acc = account(acc, interest)

		if acc >= X {
			break
		}

	}

	fmt.Println(year)

}


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

string a,b="CF"; //打表
int al,bl;

int main(){
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl]){ /*fwgdfhgfgvdrgfgd*/
            bl++;
            if(bl==2)   //ghtrf退出
                break;
        }
    if(bl==2) cout<<"Yes"; //判断gr出
    else cout<<"No";
    cout<<endl;//最后不要egbrdthdfdt
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.immutable._
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}

object Main {
  val m = (1 << 9) - 1

  def solve(sc: => Scanner): Unit = {
    println(getPrimeList.filter(_ % 5 == 1).take(sc.nextInt).force.mkString(" "))
  }

  def recursive(now: Int, A: Array[List[Int]]): Int = {
    if (A(now).size == 0) (now) else {
      val next = A(now).head
      A(now) = A(now).filter(_ != next)
      A(next) = A(next).filter(_ != now)
      recursive(next, A)
    }
  }

  def getPermutation(now: Long = 0): Stream[Long] = {
    Stream.cons(now, getPermutation(now + 1))
  }

  def getPrimeList(): Stream[Long] = {
    getPrimeListRecursive(getPermutation(2))
  }

  def getPrimeListRecursive(A: Stream[Long]): Stream[Long] = {
    Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))
  }

  def check(A: Array[List[Int]]): Boolean = {
    A.map(_.size == 0).fold(true)((a, b) => a & b)
  }

  def shift(n: Long): Long = {
    if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)
  }

  def unShift(n: Long): Long = {
    if (n == 0) (0) else (unShift(n >> 1) + 1)
  }

  def calc(v: Long): Long = (v + 1) * v / 2

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 31692
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 2010

int a, b, c;

int main() {
	cin >> a >> b >> c;
	if (a <= c&&c <= b)cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		if(a+b < c) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
int main(){
	int A,B;
	cin>>A>>B;
	cout<<A-(A>B?1:0)<<endl;
  return 0;
}


Measured memory_bytes: 256
s = list(input())
n = len(s)
zero = 0
one = 0
for i in range(n):
    if i%2==0:
        if int(s[i])!=0:
            zero+=1
        else:
            one+=1
    elif i%2==1:
        if int(s[i])==0:
            zero+=1
        else:
            one+=1
print(min(zero,one))

Measured memory_bytes: 3956
using System;

class Program {
    static void Main() {
        double min = double.MaxValue, max = 0;

        string line;
        while ((line = Console.ReadLine()) != null) {
            var n = double.Parse(line);
            if (n < min) min = n;
            if (n > max) max = n;
        }

        Console.WriteLine(max - min);
    }
}

Measured memory_bytes: 9160
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {

	int A, B,C;
	cin >> A >> B>>C;
	string s = "No";
	if (A<=C&&C<=B) {
		s="Yes";
	}
	
		cout << s << endl;
	
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <map>
#include <string>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for(char c:s)pcu(c);}
_vo(string s){for(char c:s)pcu(c);}
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
//_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	map<string, int> m;
	string k;
	for (int i = in(); i; i--) {
		int o = in();
		scan(k);
		switch(o) {
		case 0:
			m[k] = in();
			break;
		case 1:
			{ auto r = m.find(k); outl(r != m.end() ? r->second : 0); }
			break;
		case 2:
			m.erase(k);
			break;
		case 3:
			string s;
			scan(s);
			for (auto i = m.lower_bound(k), e = m.upper_bound(s); i != e; i++)
				outl(i->first, ' ', i->second);
		}
	}
}


Measured memory_bytes: 27460
#include<stdio.h>

int main(){
  int a, b;
  int temp;
  int i;

  for(i = 0; i < 10000; i++){
    scanf("%d %d", &a, &b);

    if(a == 0 && b == 0) break;

    if(a > b){
      temp = a;
      a = b;
      b = temp;
    }

    printf("%d %d\n", a , b);
  }

  return 0;
}


Measured memory_bytes: 2036
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;


int main(){
	long long N,ans=100000000000,x=0,y=0; cin >> N;
	long long a[N];
	for(int i=0; i<N; i++){
		cin >> a[i];
		x+=a[i];
	}for(int i=0; i<N-1; i++){
		y+=a[i];
		ans=min(ans,abs(x-2*y));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


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

  std::cout << std::fixed << std::setprecision(6);

  int n, m;

  std::cin >> n >> m;

  long long x[111111], y[111111];

  for (int i = 0; i < n; i ++)
    std::cin >> x[i];

  for (int i = 0; i < m; i ++)
    std::cin >> y[i];

  long long a = 0, A = 0;

  for (int i = 0; i < n - 1; i ++)
    (a += (x[i + 1] - x[i]) * (i + 1) % MOD * (n - (i + 1)) % MOD) %= MOD;

  for (int i = 0; i < m - 1; i ++)
    (A += a * (y[i + 1] - y[i]) % MOD * (i + 1) % MOD * (m - (i + 1)) % MOD) %= MOD;

  std::cout << A << std::endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <atcoder/all>
#define F first
#define S second
using namespace std;
using namespace atcoder;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
ll Mod = 1000000007;
int main() {
  int N,Q;
  cin >> N >> Q;
  fenwick_tree<ll> fw(N);
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    fw.add(i,a);
  }
  for (int i = 0; i < Q; i++) {
    int mode;
    cin >> mode;
    if (mode == 0) {
      int p; ll x;
      cin >> p >> x;
      fw.add(p,x);
    } else {
      int l,r;
      cin >> l >> r;
      ll ans = fw.sum(l,r);
      cout << ans << endl;
    }
  }
  return 0;
}

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

namespace ABC159
{
    class C
    {
        static void Main(string[] args)
        {
            double L = double.Parse(Console.ReadLine());
            //double res = 0;
            /*
            for (double i = 0; i < 1000; i++)
            {
                for (double j = 1; j < 1000; j++)
                {
                    double k = L - i - j;

                    if (i + j < L)
                    {
                        res = Math.Max(i * j * (L - i - j), res);
                    }
                }
            }
            */
            Console.WriteLine(Math.Pow(L / 3.0, 3));
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
#define pb(x) push_back(x);
typedef long long  int ll;
ll mod = 998244353;
ll hmaxii=0;
vector<ll>values[2*100000+1];
ll MAXN = 2*100000+1;
ll spf[2*100000+1];
//vector<ll>values[];
ll diff,x,y,z;
ll flag=1;ll price[1001][1001];

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }


void solution(){
    ll n,w;
    cin>>n>>w;
    ll arr[n+1][w+1];
    ll weight[n+1],value[n+1];
    for(ll i=1;i<=n;i++){
        cin>>weight[i]>>value[i];
    }
    for(ll i=0;i<=n;i++){
        arr[i][0]=0;
    }
    for(ll i=0;i<=w;i++){
        arr[0][i]=0;
    }
    //cout<<"ggfgf"<<endl;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=w;j++){
            if(weight[i]>j){
                arr[i][j]=arr[i-1][j];
            }
            else{
                arr[i][j] = max(arr[i-1][j],arr[i-1][j-weight[i]]+value[i]);
            }
        }
    }
    cout<<arr[n][w]<<endl;
}


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //sieve();
    /*ll powe[64];
    powe[0]=1;
    ll i=1;
    while(i<64){
        powe[i] = powe[i-1]*2;
        i++;
    }*/
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solution();
    }
    return 0;
}

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

int main(){
    int n,k,resp=0,x;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>x;
        resp+=x;
    }

    if(resp>=n)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
d=Counter(a)
b=[]
for i in d:
  if d[i]>1:b.append(i)
  if d[i]>3:b.append(i)
if len(b)<2:exit(print(0))
b.sort()
print(b[-1]*b[-2])

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

signed main(){
  string S;
  cin>>S;
  S[3]='8';
  cout<<S<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int cnt,dx[4]={0,-1,0,1},dy[4]={-1,0,1,0},max,x,y,m,n,i,j,a[90][90];
void func(int y,int x){
	int i,xx,yy;
	for(i=0;i<4;i++){
		xx=x+dx[i]; yy=y+dy[i];
		if(xx<m&&xx>=0&&yy<n&&yy>=0&&a[yy][xx]==1){
			cnt++;
			a[yy][xx]=0;
			if(max<cnt) max=cnt;
			func(yy,xx);
			a[yy][xx]=1; cnt--;
		}
	}
}
int main(void){
	int i,j;
	while(1){
		scanf("%d %d",&m,&n);
		if(m==0&&n==0) break;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++) scanf("%d",&a[i][j]);
		}
		max=0;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				cnt=0;
				func(i,j);
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 2616
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    long[][] ab = new long[n][2];
    for (int i = 0; i < n; i++) {
      ab[i][0] = sc.nextLong();
      ab[i][1] = sc.nextLong();
    }
    Arrays.sort(ab, (x,y) -> Long.compare(x[0], y[0]));
    long ans = 0;
    for (int i = 0; i < n; i++) {
      long a = ab[i][0];
      long b = ab[i][1];
      if (m >= b) {
        ans += a * b;
        m -= b;
      } else {
        ans += a * m;
        break;  
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 92420
n = gets.to_i
plans = []
n.times do
  plans << gets.chomp.split(" ").map(&:to_i)
end

# ある秒のときの地点から+n秒でイケる地点を列挙？
# その座標の|x|+|y|以上の時刻でn%(|x|+|y|) == 0 なら行ける？

now = [0,0]
t = 0
plans.each do |plan|
  dt = plan[0] - t
  dx = plan[1] - now[0]
  dy = plan[2] - now[1]

  if dt % (dx.abs + dy.abs) != 0
    puts "No"
    exit
  end

  t = plan[0]
  now = [plan[1],plan[2]]
end

puts "Yes"

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

int main()
{
	char c[3];
	scanf("%s", c);
	int ans = 0, tmp = 0;
	for(int i = 0; i <= 2; i++)
		if(c[i] == 'R') {
			if(++tmp > ans) ans = tmp;
		} else tmp = 0;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3800
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, count = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	int x;
	while (1) {
		x = 0;
		for (int j = 0; j < n; j++) {
			if (a.at(j) % 2 == 0) {
				x++;
			}
		}
		if (x == n) {
			for (int j = 0; j < n; j++) {
				a.at(j) /= 2;
			}
			count++;
			continue;
		}
		else {
			break;
		}
	}
	cout << count << endl;
}

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

int main(){
  int n,count=0;cin>>n;
  vector<int> a(n+1,0),x(n+1,0),ans(n+1,0);
  REP(i,n) cin>>a.at(i);

  for(int i=n;i>=1;i--){
    ans.at(i)=x.at(i)^a.at(i);
    if(ans.at(i)) count++;
    for(int j=1;j*j<=i;j++){
      if(!(i%j)){
        x.at(j)^=ans.at(i);
        if((j!=1)&&(j!=i/j)) x.at(i/j)^=ans.at(i);
      }
    }
  }

  cout<<count<<endl;
  REP(i,n) if(ans.at(i)) cout<<i<<" ";
}

Measured memory_bytes: 3200
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

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

const int MAXN = 5e6+3; //AREGLAAAAAAAAR!!!!
ll as[8],as2[5];
int main(){
	ll a,b,c,d,n;
	lrii(a,b);
	lrii(c,d);
	lri(n);
	as[0]=a*4;
	as[1]=b*2;
	as[2]=c;
	as2[0]=a*8;
	as2[1]=b*4;
	as2[2]=c*2;
	as2[3]=d;
	if(n==1){
		sort(as,as+3);
		printf("%lld",as[0]);
	}
	else if(n%2){
		sort(as,as+3);
		sort(as2,as2+4);
		ll cant=n/2;
		printf("%lld",cant*as2[0]+as[0]);
	}else{
		sort(as2,as2+4);
		ll cant=n/2;
		printf("%lld",cant*as2[0]);
	}

}


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

using namespace std;

int main(void){
    
    string S;
    cin >> S;
    reverse(S.begin(),S.end());
    int T[2019] = {};    

    int ans(0);
    int tmp(0);
    int i(1);
    
    T[0] = 1;
    for(auto c : S){
        tmp += (static_cast<int>(c-48)) * i;
        tmp %= 2019;
        i *= 10;
        i %= 2019;
        ++T[tmp];
        ans += (T[tmp]-1);
    }

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


Measured memory_bytes: 3668
#include <iostream>
#include <string.h>
#include<algorithm>
using namespace std;

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


Measured memory_bytes: 256
h,w = map(int,input().split())
s = [input() for _ in range(h)]

#union-find

n = h*w

par = [0] * n
rank = [0] * n

#初期化
for i in range(n):
    par[i] = i
    rank[i] = 0

#判定(一番上野根を求める)
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
    
#結合
def unite(x , y):
    rx = find(x)
    ry = find(y)
    
    if rx == ry:
        return
    
    if rank[rx] < rank[ry]:
        par[rx] = ry
    elif rank[rx] > rank[ry]:
        par[ry] = rx
    else:
        par[ry] = x
        rank[rx] += 1

for i in range(h):
    for j in range(w-1):
        if s[i][j] != s[i][j+1]:
            unite(i*w+j , i*w +j+1)
            
for i in range(h-1):
    for j in range(w):
        if s[i][j] != s[i+1][j]:
            unite(i*w+j , (i+1)*w +j)
            
uni = [[0]*2 for _ in range(n)]

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            k = 0
        else:
            k = 1
        uni[find(i*w+j)][k] += 1
        
ans = 0
for i in uni:
    ans += i[0] * i[1]
    
print(ans)

Measured memory_bytes: 100584
#include <iostream>
#include <string>
#include <list>

using namespace std;

int main() {
  int n; cin >> n;
  list<int> l;
  
  int flg = 0;
  for (int i = 0; i < n; i++, flg ^= 1) {
    int tmp; cin >> tmp;
    if (flg == 0) {
      l.push_back(tmp);
    } else {
      l.push_front(tmp);
    }
  }

  if (n % 2 == 0) {
    for (std::list<int>::iterator it = l.begin(); it != l.end(); ++it) {
      if (it != l.begin()) { cout << ' '; }
      cout << *it;
    }
    cout << endl;
  } else {
    for (std::list<int>::reverse_iterator it = l.rbegin(); it != l.rend(); ++it) {
      if (it != l.rbegin()) { cout << ' '; }
      cout << *it;
    }
    cout << endl;
  }


  return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define lop(i, n) for(i=0; i<n; i++)

int gcd( int a, int b )
{
    int temp;

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

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

int main()
{
	int k, a, b, c;
	long int sum=0;
	scanf("%d", &k);
	
	for(a=1; a<=k; a++){
		for(b=1; b<=k; b++){
			for(c=1; c<=k; c++) sum+= gcd(gcd(a,b), c);
		}
	}
	
	printf("%ld", sum);
	
	
return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <vector>

using namespace std;

constexpr int LEN = 1000005;

typedef struct pp{
  string name;
  int t;
}P;

vector<P> Q(LEN+1);
int head, tail, n;

void enqueue(P &x){
  tail = (tail + 1) % LEN;
  Q[tail].name = x.name;
  Q[tail].t = x.t;
}

P dequeue(){
  int h = head;
  head = (head + 1) % LEN;
  return Q[h];
}

int main(){
  ios::sync_with_stdio(false);
  int elaps = 0;
  int q;
  P u;
  cin >> n; cin >> q;
  for (int i = 0; i < n; i++){
    cin >> Q[i].name;
    cin >> Q[i].t;
  }
  head = 0; tail = n-1;
  for(;;)
  {
    P p = dequeue();
    if(p.t <= q){
      elaps += p.t;
      cout << p.name << " " << elaps << endl;
      if(head == (tail + 1) % LEN){
        break;
      }
    } else{
      elaps += q;
      p.t -= q;
      enqueue(p);
    }
  }
  return 0;
}

Measured memory_bytes: 19072
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(3);
    for (int &ai: a) cin >> ai;
    vector<vector<int>> g(n);
    while (m--) {
        int u, v; cin >> u >> v; u--, v--;
        g[u].emplace_back(v);
    }
    // nxt[s][i] := s から a[i] で到達できる頂点
    vector<vector<vector<int>>> nxt(n, vector<vector<int>>(3));
    const int MAX = 100;
    for (int s = 0; s < n; s++) {
        vector<vector<int>> visited(n, vector<int>(MAX + 1));
        visited[s][0] = true;
        for (int cnt = 0; cnt < MAX; cnt++) {
            for (int u = 0; u < n; u++) if (visited[u][cnt]) {
                for (int v: g[u]) visited[v][cnt + 1] = true;
            }
        }
        for (int i = 0; i < 3; i++) {
            for (int u = 0; u < n; u++) if (visited[u][a[i]]) {
                nxt[s][i].emplace_back(u);
            }
        }
    }
    vector<int> d(n, INF);
    d.back() = 0;
    bool update = true;
    while (update) {
        update = false;
        for (int u = 0; u < n; u++) {
            vector<int> mi(3, INF);
            for (int i = 0; i < 3; i++) {
                for (int v: nxt[u][i]) chmin(mi[i], d[v]);
            }
            int ma = *max_element(mi.begin(), mi.end()) + 1;
            if (chmin(d[u], ma)) update = true;
        }
    }
    if (d[0] == INF) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << d[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;

ll dp[2001][2001];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    vector<pair<ll, ll> > in(n);
    int i;
    rep(i, n) {
        cin >> in[i].first;
        in[i].second = i;
    }
    sort(in.begin(), in.end());
    ll ans(0);
    ll cnt(0);
    memset(dp, 0, sizeof(dp));
    for (int i = n - 1; i >= 0; i--) {
        ll val = in[i].first;
        ll pos = in[i].second;
        cnt++;
        ll cc = n - cnt;
        for (ll j = 0; j < cnt + 1; j++) {
            ll left = j;
            ll right = j + cc;
            // cout << left << ' ' << right << endl;
            ll t = 0;
            if (left > 0) {
                t = max(t, dp[left-1][right] + val * abs(left - 1 - pos));
            }
            if (right < n) {
                t = max(t, dp[left][right+1] + val * abs(right - pos));
            }
            // cout << dp[left][right] << endl;
            dp[left][right] = t;
        }
    }
    rep(i, n) {
        ans = max(ans, dp[i][i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 34928
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <set>

using namespace std;

int main() {
	int a, b, k;
	cin >> a >> b >> k;

	set<int> nums;
	for (int i = 0; i < k; i++) {
		int x = a+i;
		int y = b-i;

		if (a <= x && x <= b) { nums.insert(x); }
		if (a <= y && y <= b) { nums.insert(y); }
	}

	for (auto x: nums) {
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<list>
using namespace std;

int main() {
	int A, B, N;
	cin >> A >> B >> N;
	if (A + B >= N)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

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

int main() {
    string N;
    cin >> N;
    
    if(N[0] == N[1] && N[1] == N[2] || N[1] == N[2] && N[2] == N[3]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();

        double num = Math.abs(30 * h - 5.5 * m);

        double cos = Math.cos(Math.toRadians(num));

        double ans = b * b + a * a - 2 * a * b * cos;

        System.out.println(Math.sqrt(ans));

        sc.close();
    }

}


Measured memory_bytes: 36024
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#define abs(x) ((x) < 0 ? (-x) : (x))
using namespace std;
int main() {
  int n, l;
  cin >> n >> l;
  
  int total = 0, min = 999999;
  for (int i = 1; i <= n; i++) {
    int t = l + i - 1;
    total += t;
    if (abs(min) > abs(t))
      min = t;
  }
  cout << total - min << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
     
    int main(void) {
        int n, count = 0;
        scanf("%d", &n);
        for(int i = 1; i <= n; i++) {
            int j = i, keta = 0;
            while (j != 0) {
                j /= 10;
                keta++;
            }
            if(keta % 2 == 1) {
                count++;
            }
        }
        printf("%d\n", count);
        return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pll;
const lli inf = 1e18;

int main(){
	int n,k;
	string s;
	cin >> n >> k >> s;
	s[k-1] = tolower(s[k-1]);
	cout << s << endl;
    return 0;
}

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

int main(void)
{
	int s[5], c[5], N, M, i;
	int num = 0, ret=0, temp;
	int flg[3] = {0};
	cin >> N >> M;
	
	for(i = 0;i < M;i++)
	{
		cin >> s[i] >> c[i];
		if(s[i] == 1 && c[i] == 0 && N != 1){
			num = -1;
			break;
		}
		
		if(flg[s[i]-1] == 0){
			flg[s[i]-1] = 1;
			num += pow(10,N-s[i]) * c[i];
		}else{
			temp = (int)pow(10,N-s[i]+1);
			if((int)(num/pow(10,N-s[i]))%temp == c[i]){
				/* 何もしない */
			}else{
				num = -1;
				break;
			}
		}
	}
	
	if(num == -1){
		cout << num;
	}else{
		for(i = 1;i < N;i++){
			if(flg[i-1] == 0){
				if(i-1==0){
					num += pow(10,N-1);
				}
			}
		}
		cout << num;
	}
}


Measured memory_bytes: 256
def main():
        K = int(input())
        S = str(input())

        S_list = list(S)
        l = len(S_list)

        ans = []

        if l <= K:
                for i in range(l):
                        ans.append(S_list[i])
        else:
                for i in range(K):
                        ans.append(S_list[i])
                ans.append("...")

        ans = "".join(map(str,ans))
        print("{}".format(ans))

if __name__=="__main__":
        main()


Measured memory_bytes: 9128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

L,R = map(int,read().split())

if R-L > 1000:
    print(0)
    exit()
x = np.arange(L,R+1)
x = x[:,None] * x[None,:] % 2019
np.fill_diagonal(x,2019)
answer = x.min()
print(answer)

Measured memory_bytes: 15828
using System;
using System.Collections;
using System.Collections.Generic;

public class AOJ11
{
    public static void Main()
    {
        int W, H;
        string[] field = new string[20];
        int[] dx = { -1, 0, 1, 0 };
        int[] dy = { 0, -1, 0, 1 };
        Queue q = new Queue();
        while (true)
        {
            string[] v = Console.ReadLine().Split(' ');
            W = Int32.Parse(v[0]); H = Int32.Parse(v[1]);
            if (W == 0 && H == 0) break;
            for (int i = 0; i < H; i++) field[i] = Console.ReadLine();
            bool[,] flag=new bool[ H, W];
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (field[i][j] == '@')
                    {
                        q.Enqueue(new KeyValuePair<int, int>(i, j));
                        flag[i, j] = true;
                        break;
                    }
                }
                if (q.Count != 0) break;
            }
            while (q.Count > 0)
            {
                KeyValuePair<int, int> T = (KeyValuePair<int,int>)q.Peek();
                int y = T.Key; int x = T.Value;
                q.Dequeue();
                for (int i = 0; i < 4; i++)
                {
                    if (x + dx[i] < 0 || W <= x + dx[i] || y + dy[i] < 0 || H <= y + dy[i]) continue;
                    if (field[y + dy[i]][x + dx[i]] == '#' || flag[y + dy[i], x + dx[i]] == true) continue;
                    flag[y + dy[i], x + dx[i]] = true;
                    q.Enqueue(new KeyValuePair<int, int>(y+dy[i],x+dx[i]));
                }
            }
            int cnt = 0;
            for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) if (flag[i, j] == true) cnt++;
            Console.WriteLine(cnt);
        }
    }
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int d;
    for (int i = 0; i < N; i++) {
      int x; cin >> x;
      if ( x <= K/2 ) {
        d += 2*x;
      }      
      else {
        d += 2*(K-x);
      }
  }
  cout << d << endl;
}

Measured memory_bytes: 256