akhauriyash/Code-Regression huggingface dataset:
import collections,math
s = input()
t = input()
#tを構成文字で、sにない文字があったらダメ。
#構成できるなら最大でもlen(t)個しかないから、10^100の連結は必要ない

#最も不足する文字を探す
ls = collections.Counter(s)
lt = collections.Counter(t)

time_dict ={}
tmp=0
max_time=0#一番少ないやつ
for t_key,t_val in lt.items():
    if t_key not in ls:#sの中にtの文字がない
        print(-1)
        exit()

#多分TLEするかも。。
cnt = 0
tt = list(t[::-1])
idx=0
ss = s
while tt!=[]:
    next_t = tt.pop()
    idx=ss.find(next_t)
    if idx == -1:
        cnt += len(ss)
        idx = s.find(next_t)
        ss = s[idx+1:]
        cnt += idx+1
    else:
        cnt += idx+1
        ss = ss[idx+1:]
print(cnt)


Measured memory_bytes: 10364
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func strToInt(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	s := strings.Repeat(a, strToInt(b))
	t := strings.Repeat(b, strToInt(a))

	if s < t {
		fmt.Println(s)
	} else {
		fmt.Println(t)
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF 1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    string str;
    cin >> str;
    int len = (int)str.length();
    string ans = "";
    for (int i = 0; i < len; i++) {
        if (i % 2 == 0) {
            ans += str[i];
        }
    }
    cout << ans << endl;

    return 0;
}



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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    ll m;
    cin >> m;
    ll digit = 0;
    ll sum = 0;
    ll d, c;
    for (int i = 0; i < m; ++i) {
        cin >> d >> c;
        digit += c;
        sum += d*c;
    }
    cout << (digit - 1) + ((sum - 1) / 9) << endl;
}

Measured memory_bytes: 256
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 16;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
string s;
ll dp[N][10][2][2];
ll solve1(ll id,ll pre,ll free,ll first)
{
     if(id==s.size())   return 1;
     ll ans = dp[id][pre][free][first];
     if(ans!=-1)   return ans;
     ans = 0;
     if(first==0)
     {
          if(free)
          {
               ans += solve1(id+1,0,0,0);
               for(ll i=1;i<s[id]-'0';i++)
               {
                    ans += solve1(id+1,i,0,1);
               }
               ans += solve1(id+1,s[id]-'0',1,1);
          }
          else
          {
               ans += solve1(id+1,0,0,0);
               for(ll i=1;i<=9;i++)
               {
                    ans += solve1(id+1,i,0,1);
               }
          }
     }
     else
     {
          if(free)
          {
               for(ll i=0;i<s[id]-'0';i++)
               {
                    if(abs(pre-i)<=1)
                    {
                         ans += solve1(id+1,i,0,1);
                    }
               }    
               if(abs(s[id]-'0'-pre)<=1)   ans += solve1(id+1,s[id]-'0',1,1);
          }
          else
          {
               for(ll i=0;i<=9;i++)
               {
                    if(abs(pre-i)<=1)
                    {
                         ans += solve1(id+1,i,0,1);
                    }
               }
          }
     }
     return dp[id][pre][free][first] = ans;
}
void solve()
{
     ll k;
     cin >> k;
     k++;
     ll low = 1,high = 1e14,ans;
     while(low<=high)
     {
          ll mid = (low + high)/2;
          s = to_string(mid);
          memset(dp,-1,sizeof(dp));  
          ll cnt = solve1(0,0,1,0);
          if(cnt<k)
          {
               low = mid + 1;
          }
          else
          {
               high = mid - 1;
               ans = mid;
          }
     }
     cout<<ans;
}

int main()
{
     FAST;
     ll t = 1;
    // cin >> t;
     while(t--)
     {
         
          solve();
     }
}

Measured memory_bytes: 256
#include <stdio.h>
#define abs(x) ((x) > 0 ? (x) : -(x))
#define neg(x) (((x) == 1) ? 1 : -1)

int main() {
	long long k, x, y;
	scanf("%lld\n%lld %lld", &k, &x, &y);
	if (!(k & 1) && (x + y & 1))
		return puts("-1") & 0;
	static int sz = 0;
	static long long ansx[239017];
	static long long ansy[239017];
	long long px = 0, py = 0;
	while (abs(px - x) + abs(py - y) > k * 2) {
		if (abs(px - x) > k) px += (px > x) ? -k : k;
		else py += (py > y) ? -k : k;
		ansx[++ sz] = px, ansy[sz] = py;
	}
	if (abs(px - x) + abs(py - y) != k) {
		if ((k & 1) && (x - px + y - py & 1)) {
			if (abs(py - y) <= k) {
				px += (k - abs(py - y)) * neg(px < x);
				py = y;
			}
			else {
				py += (k - abs(px - x)) * neg(py < y);
				px = x;
			}
			ansx[++ sz] = px, ansy[sz] = py;
		}
		long long t = k * 2 - abs(px - x) - abs(py - y) >> 1;
		if (abs(px - x) < abs(py - y))
			if (px <= x) {
				ansx[++ sz] = x + t;
				ansy[sz] = py + (k - (x + t - px)) * neg(py < y);
			}
			else {
				ansx[++ sz] = x - t;
				ansy[sz] = py + (k - (px + t - x)) * neg(py < y); 
			}
		else
			if (py <= y) {
				ansy[++ sz] = y + t;
				ansx[sz] = px + (k - (y + t - py)) * neg(px < x);
			}
			else {
				ansy[++ sz] = y - t;
				ansx[sz] = px + (k - (py + t - y)) * neg(px < x);
			}
	}
	ansx[++ sz] = x, ansy[sz] = y;
	printf("%d\n", sz);
	for (int i = 1; i <= sz; ++i)
		printf("%lld %lld\n", ansx[i], ansy[i]); 
	return 0;
}


Measured memory_bytes: 5248
#include "iostream"
using namespace std;


int prime(int n) {
	int m = 3;
	while (n%m != 0) {
		if (m*m > n)return true;
		m += 2;
	}
	return false;
}


int main()
{
	int n,a=11;
	cin >> n;
	for (int i = 0; i < n; i++) {
		while (prime(a) != true) {
			a += 10;
		}
		cout << a << ' ';
		a += 10;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,a,b;
	char n[101];
	while(1){
		a=0; b=0;
		scanf("%s",&n);
		if(n[0]=='0') break;
		for(i=1;i<strlen(n);i++){
			if(n[i]=='A') a++;
			else b++;
		}
		if(a<b) b++;
		else a++;
		printf("%d %d\n",a,b);
	}
	return 0;
}	

Measured memory_bytes: 2700
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N;
	ll K; cin >> N >> K;
	vector<P> ab(N);
	rep (i, N){
		int a, b; cin >> a >> b;
		ab[i].first = a;
		ab[i].second = b;
	} // end rep

	sort(ALL(ab));

	int res = 0;
	ll sum = 0LL;
	rep (i, N){
		if (sum + (ll)ab[i].second >= K){
			res = ab[i].first;
			break;
		} // end if
		sum += (ll)ab[i].second;
	} // end rep

	cout << (res == 0 ? ab[N-1].first : res) << endl;

	return 0;
}

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

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

    int n;
    cin >> n;
    int ans;
    if (n == 1)
    {
        ans = 1;
    }
    else if (n <= 3)
    {
        ans = 2;
    }
    else if (n <= 7)
    {
        ans = 4;
    }
    else if (n <= 15)
    {
        ans = 8;
    }
    else if (n <= 31)
    {
        ans = 16;
    }
    else if (n <= 63)
    {
        ans = 32;
    }
    else if (n <= 100)
    {
        ans = 64;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import bisect
N = int(input())
top = list(map(int,input().split()))
middle = list(map(int,input().split()))	
bottom = list(map(int,input().split()))	

top.sort()
middle.sort()
bottom.sort()

ans = 0
for i in middle:
  can_put_upstair = bisect.bisect_left(top,i)
  can_put_downstair = N - bisect.bisect_right(bottom,i)
  #print(can_put_upstair,can_put_downstair)
  ans += can_put_upstair*can_put_downstair

print(ans)
  

Measured memory_bytes: 29548
w = input()
w = list(w)
w.sort()

w_dict = {}
for i in range(len(w)):
    if w[i] not in w_dict:
        w_dict[w[i]] = True

isBeautiful = True

for k,v in w_dict.items():
    idx = w.index(k)
    if idx % 2 != 0:
        isBeautiful = False

if len(w_dict.items()) == 1:
    if len(w) % 2 != 0:
        isBeautiful = False

if isBeautiful:
    print("Yes")
else:
    print("No")







Measured memory_bytes: 3064
s = input()
a = 0
s_list = list(s)
s_set_list = list(set(s_list))
if len(s_set_list) == 2:
  a += 1
s_list.sort()
if (s_list[0] == s_list[1]) and (s_list[2] == s_list[3]):
  a += 1
if a == 2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<iostream>
#include <cmath>
using namespace std;
int main(){
  int N,i,count;
  cin >> N;
  int A[N];
  for(int i = 0;i<N;i++)cin>>A[i];
  for(i = 0;i<N;i++){
    while((A[i]%2) == 0){
      count++;
      A[i] = A[i]/2;
    }
  }
  cout << count << "\n";
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

dp =[[float("inf") for _ in range(2 ** N)] for _ in range(M + 1)]
dp[0][0] = 0

for i in range(M):
    A, B = map(int, input().split())
    C = list(map(int, input().split()))
    tmp = [0 for _ in range(N)]
    for c in C:
        tmp[c - 1] = 1
    x = int("".join(map(str, tmp)), 2)
    for j in range(2 ** N):
        dp[i + 1][x|j] = min(dp[i][x|j], dp[i][j] + A, dp[i + 1][x|j])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

ans = dp[M][2 ** N - 1]
if ans != float("inf"):
    print(ans)
else:
    print(-1)

Measured memory_bytes: 138120
import sys
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

from collections import defaultdict 
import math 

n = int(input())
s = input()
w_cnt = 0
r_cnt = 0

for i in s:
	if i=='W':
		w_cnt+=1
	else:
		r_cnt+=1

if w_cnt ==0 or r_cnt == 0:
	print(0)
else:
	ans = 0
	for i in range(r_cnt):
		if s[i]=='W':
			ans+=1
	print(ans)


Measured memory_bytes: 9748
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
score = 0

def rsp(hand: str) -> int:
  if hand == 'r':
    return p
  elif hand == 's':
    return r
  else:
    return s

for i in range(k):
  score += rsp(t[i])
  twice = True
  for j in range(i+k, n, k):
    if t[j] == t[j-k]:
      if twice:
        twice = False
      else:
        twice = True
        score += rsp(t[j])
    else:
      twice = True
      score += rsp(t[j])
      
print(score)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int MOD=1e9+7;

int32_t main(){
    FAST
    int n,k;cin>>n>>k;
    vector<int> p,ne;
    priority_queue<int> positive;
    priority_queue<int,vector<int>,greater<int>> negative;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        if(x>0){
            positive.push(x);
            p.push_back(x);
        }
        else{
            negative.push(x);
            ne.push_back(x);
        }
    }
    int ans=1;

    if(n==k){
        for(int i=0;i<p.size();i++){
                ans*=p[i];
                ans%=MOD;
        }
        for(int i=0;i<ne.size();i++){
                ans*=ne[i];
                ans%=MOD;
                ans=(ans+MOD)%MOD;
        }
        cout<<ans<<"\n";
        return 0;
    }

    if(positive.size()==0){
        if(k&1){
            sort(ne.begin(),ne.end(),greater<int>());
            for(int i=0;i<k;i++){
                ans*=ne[i];
                ans%=MOD;
                ans=(ans+MOD)%MOD;
            }
            cout<<ans<<endl;
            return 0;
        }
        else{
            sort(ne.begin(),ne.end());
            for(int i=0;i<k;i++){
                ans*=ne[i];
                ans%=MOD;
                ans=(ans+MOD)%MOD;
            }
            cout<<ans<<endl;
            return 0;
        }
    }

    if(k&1){
        ans*=positive.top();positive.pop();
        k--;
    }
    

    while(k>0&&(positive.size()>=2)&&(negative.size()>=2)){
        
        int xp=positive.top();positive.pop();
        int yp=positive.top();positive.pop();

        int xn=negative.top();negative.pop();
        int yn=negative.top();negative.pop();

        if(xp*yp>xn*yn){
            int to_multiply=xp*yp;to_multiply%=MOD;
            ans=(ans*to_multiply)%MOD;
            negative.push(xn);
            negative.push(yn);
            k-=2;
        }
        else{
            int to_multiply=xn*yn;to_multiply%=MOD;
            ans=(ans*to_multiply)%MOD;
            positive.push(xp);
            positive.push(yp);
            k-=2;
        }

    }

    if(k==0){
        cout<<ans<<endl;
        return 0;
    }

    while(k>0&&positive.size()>=2){
        ans=(ans*positive.top())%MOD;positive.pop();
        ans=(ans*positive.top())%MOD;positive.pop();
        k-=2;
    }

    while(k>0&&negative.size()>=2){
        ans=(ans*negative.top())%MOD;negative.pop();
        ans=(ans*negative.top())%MOD;negative.pop();
        k-=2;
    }

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

Measured memory_bytes: 6724
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, m;
    cin >> n >> m;
    int mn = n + 1, mx = 0;
    while(m--){
        int l, r;
        cin >> l >> r;
        mx = max(mx, l);
        mn = min(mn, r);
    }
    if(mx <= mn){
        cout << mn - mx + 1;
    }else{
        cout << 0;
    }
    return 0;
}


Measured memory_bytes: 256
<?php
$arr = explode(' ', fgets(STDIN));

$age = (int) $arr[0];
$price = (int) $arr[1];

if ($age <= 5) {
    echo 0 . PHP_EOL;
    exit;
} elseif (6 <= $age && $age <= 12) {
    echo ($price / 2) . PHP_EOL;
    exit;
} else {
    echo $price . PHP_EOL;
    exit;
}

Measured memory_bytes: 4856
local DBG = false
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

-- returns (b^n) % m
local function modpow(b, n, m)
    if n == 0 then
        return 1
    elseif n % 2 == 0 then
        return modpow(b * b % m, n//2, m) % m
    else
        return b * modpow(b, n - 1, m) % m
    end
end

---
local MOD = 998244353
local AMAX = 300
local N = io.read("n")
local a = {}
local S = 0
for i=1,N do
    a[i] = io.read("n")
    S = S + a[i]
end

local function fill90000(t, v)
    for i=1,900000 do
        t[i] = v
    end
end

local function default0(t)
    local mt = {
        __index = function(t,k)
            return 0
        end
    }
    setmetatable(t, mt)
end

-- ∑A = S/2 and ∑B = S/2 and ∑C = 0
local function getY()
    if S % 2 == 1 then
        return 0
    end
    local cache = {}
    default0(cache)
    --fill90000(cache, 0)
    cache[0] = 1
    local curmax = 0
    for i=1,N do
        local cur = a[i]
        curmax = curmax + cur
        for s=curmax,cur,-1 do
            cache[s] = (cache[s] + cache[s-cur]) % MOD
        end
    end
    return cache[S//2]
end

-- ∑A >= S/2
local function getX()
    local cache = {}
    --fill90000(cache, 0)
    default0(cache)
    cache[0] = 1
    local curmax = 0
    for i=1,N do
        local cur = a[i]
        curmax = curmax + cur
        for s=curmax,cur,-1 do
            cache[s] = (2 * cache[s] + cache[s-cur]) % MOD
        end
        for s=cur-1,0,-1 do
            cache[s] = 2 * cache[s] % MOD
        end
    end
    local sum = 0
    for s = math.ceil(S/2), curmax, 1 do
        sum = sum + cache[s]
    end
    return sum
end

local X, Y = getX(), getY()
local Total = modpow(3, N, MOD)
--dbgpr(Total, X, Y)
local ans = (Total - (3 * X) + (3 * Y)) % MOD
print(ans)


Measured memory_bytes: 2520
n = int(input())
a = list(map(int,input().split()))
b = [0]*n

for i in range(n)[::-1]:
    cnt = sum(b[i::i+1])
    if (cnt %2) != a[i]:
        b[i] = 1
    

print(sum(b))

for i, j in enumerate(b):
    if j == 1:
        print(i+1)

Measured memory_bytes: 8384
X, Y = map(int, input().split())

ans = 0
if X == 1:
    ans += 300000
elif X == 2:
    ans += 200000
elif X == 3:
    ans += 100000

if Y == 1:
    ans += 300000
elif Y == 2:
    ans += 200000
elif Y == 3:
    ans += 100000

if X == 1 and Y == 1:
    ans += 400000

print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextLong();
		int l = 0, r = 0;
		long ans = 0, sum = 0;
		while(l < n) {
			while(r < n && sum + a[r] == (sum^a[r])) {
				sum += a[r];
				r++;
			}
			ans += r - l;
			sum -= a[l];
			l++;
			if(l > r) r = l;
		}
		System.out.println(ans);
		sc.close();
	}

}

Measured memory_bytes: 85700
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int n;
	vector<int>list(105, 0);
	int sum = 0;

	cin >> n;

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

	int minn = 99999999;
	int sum2 = 0;
	for (int i = 0; i < n; i++) {
		sum -= list[i];
		sum2 += list[i];
		minn = min(minn, abs(sum - sum2));
	}


	cout << minn << endl;




	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

int main(){
    string s1, s2;
    cin >> s1 >> s2;
    bool icchi = true;
    for(int i = 0; i < 3; i++){
        if(s1[i] != s2[2 - i]){
            icchi = false;
            break;
        }
    }
    string ans = (icchi)? "YES" : "NO";
    cout << ans << endl;
    return 0;
}

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

int main(){
    int h,w;cin>>h>>w;
    vector<string> grids;
    for (int i=0;i<h;i++){
        string row;
        cin>>row;
        grids.push_back(row);
    }

    vector<int> x{0, 1, 0, -1};
    vector<int> y{1, 0, -1, 0};
    bool judge = true;
    for (int i=0;i<h;i++){
        for (int j=0;j<w;j++){
            if (grids[i][j] == '#'){
                bool temp_judge = false;
                for (int k=0;k<4;k++){
                    int target_x = j + x[k];
                    int target_y = i + y[k];
                    if (0 <= target_x && target_x < w && 0 <= target_y && target_y < h){
                        if (grids[target_y][target_x] == '#'){
                            temp_judge = true;
                            break;
                        }
                    }
                }
                if (temp_judge == false){
                    judge = false;
                }
            }
        }
    }
    if (judge){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  int l = 0, r = 0;
  ll ans = 1000;
  while(l < n-1) {
    while(r < n-1 && A[r] <= A[r+1]) r++;
    ll cur = ans / A[l];
    ans -= cur * A[l];
    ans += cur * A[r];
    while(r < n-1 && A[r] > A[r+1]) r++;
    l = r;
  }
  cout << ans << "\n";
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 1000005;
bool vis[N + 5];
vector<ll>primes;
int sz;
void seive(){
  vis[0] = vis[1] = true;
  for (int i = 4; i <= N; i += 2){
    vis[i] = true;
  }
  
  for (int i = 3; i * i <= N; i++){
    if (vis[i] == false){
      for (int j = i * i; j <= N; j += (i + i)){
        vis[j] = true;
      }
    }
  }                  
  
  primes.push_back(2LL);
  for (int i = 3; i <= N; i += 2){
    if (vis[i] == false){
      primes.push_back(i);
    }
  }
  sz = primes.size();
}
ll fac[N + 5];
int main(){
  FASTER;
  seive(); 
  //return 0;
  int n;
  cin >> n;
  vector<ll>ar(n);
  for (int i = 0; i < n; i++){
    cin >> ar[i];
  }
  for (int i = 0; i < n; i++){
    ll x = ar[i];
    for (int j = 0; j < sz && primes[j] * primes[j] <= x; j++){
      ll cnt = 0;
      while (x % primes[j] == 0){
        cnt++;
        x /= primes[j];
      }
      fac[primes[j]] = max(fac[primes[j]], cnt);
    }
    if (x > 1){
      fac[x] = max(fac[x], 1LL);
    }
  }
  ll lcm = 1LL;
  for (int i = 2; i < N; i++){
    if (vis[i] == false){
      ll t = bigMod((ll)i, (ll)fac[i]);
      lcm = ((lcm % MOD) * (t % MOD)) % MOD;
    }
  }
  assert(lcm >= 0);        
  ll ans = 0;
  for (int i = 0; i < n; i++){
    ll inv = invMod((ll) ar[i]);
    ll tmp = ((inv % MOD) * (lcm % MOD)) % MOD;
    ans += tmp;
    ans %= MOD;
  }
  assert(ans >= 0);
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 9588
s = input()
q = int(input())
Q = [list(map(str, input().split())) for _ in range(q)]

t = ''
for qi in Q:
  if int(qi[0]) == 1:
    s, t = t, s
  else:
    if int(qi[1])  == 1:
      t += qi[2]
    else:
      s += qi[2]
      
t = t[::-1]
t += s
print(t)


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

#define ALL(a)  (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define REP(i,n) for(int i=0;i<(int)n;++i)

#define CLEAR(a) memset((a), 0, sizeof(a))

inline int toInt(string s) { int x; istringstream iss(s); iss >> x; return x; }
template<class T> inline string toString(T x) { ostringstream oss; oss <<x ; return oss.str(); }
template<class T> inline T sqr(T x) { return x * x; }

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

static const auto io_sync_off = []() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    return nullptr;
}();


int main(int argc, char *argv[]) {
    vector<int> abc {111,222,333,444,555,666,777,888,999};
    int n;
    cin >> n;

    for (auto x : abc) {
        if (n <= x) {
            cout << x << endl;
            break;
        }
    }


    return 0;
}



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

using namespace std;

int main() {
    int n;
    cin >> n;
    
    string s = "";
    if (n == 0) {
    	s = "0";
	} else {
		while (n != 0) {
	        int q = n % 2;
	        if (q < 0) {
	            q += 2;
	        }
	        
			s = (char) (q + '0') + s;
	        n = (n - q) / (-2);
    	}
	}

	cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int h; //?????¢?????????
	while (1){
		cin >> h;
		if (h == 0){
			return 0;
		}
		//?????¢??????
		int board[10][5] = { -1 };
		for (int i = 0; i < h; i++){
			for (int j = 0; j < 5; j++){
				cin >> board[i][j];
			}
		}

		bool flg = 1; //??°???????????????
		int points = 0; //????¨????
		while (flg){
			flg = 0;

			//????????????????¶????&?¶??????????????????°?¨????
			for (int i = 0; i < h; i++){
				int start = -1; //??£?¶?????????????????§???????
				int end = -1; //??£?¶?????????????????????????

				for (int j = 1; j < 4; j++){
					//??°??????0??\??????3?????\?????£?¶????????????????????????¢???
					if (board[i][j] > 0){
						if (board[i][j - 1] == board[i][j] && board[i][j] == board[i][j + 1]){
							if (start < 0){
								start = j - 1;
							}
							end = j + 1;
							flg = 1;
						}
					}
				}
				
				if (flg){
					//?????°?¨????
					if (start >= 0 && end >= 0){
						points += (end - start + 1) * board[i][start];
						//????????????????????????????¶????(0?????????)
						for (int j = start; j <= end; j++){
							board[i][j] = 0;
						}
					}
				}
			}
			//?????????????????°??????
			if (flg){
				for (int i = 0; i < h - 1;i++){
					for (int j = 0; j < 5; j++){
						if (board[i+1][j] == 0){
							for (int x = i; x >= 0; x--){
								if (board[x][j] != 0){
									board[x + 1][j] = board[x][j];
									board[x][j] = 0;
								}
							}
						}
					}
				}
			}
		}
		cout << points << endl;
	}
	return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	double t,x;
	cin >> t >> x;
	cout << t/x << endl;
}

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

for y in range(1, h + 1):
    for x in range(1, w + 1):
        if s[y][x] == '#' and all(s[y + dy][x + dx] == '.' for dy, dx in [(1, 0), (0, 1), (-1, 0), (0, -1)]):
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
int main() {
  int N, M;  cin >> N >> M;
  Graph E(N);
  int a, b;
  for (int i=0; i < M; i++) {
    cin >> a >> b; a--; b--;
    E.at(a).push_back(b);
  }
  vector<double> p(N, 0); p.at(0) = 1;
  for (int i=0; i < N; i++) {
    for (int x : E.at(i)) {
      p.at(x) += 1.0 * p.at(i) / E.at(i).size();
    }
  }
  vector<double> ex(N, 0); double ans = 0;
  for (int i=N-2; i >= 0; i--) {
    double ex2 = 0, tmp = 0;
    for (int x : E.at(i)) {
      tmp += ex.at(x);
    }
    ex.at(i) = tmp / E.at(i).size() + 1;
    if (E.at(i).size() > 1) {
      for (int x : E.at(i)) {
        ex2 = max(ex2, ex.at(x));
      }
      ex2 = ( tmp - ex2 ) / ( E.at(i).size() - 1) + 1;
      ans = max(ans, p.at(i) * (ex.at(i) - ex2));
    }
  }
  printf("%.8lf\n", ex.at(0) - ans);
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

string S[310];
vector<int> G[310];
int str[310];
int main()
{
	int H, W, K;
	cin >> H >> W >> K;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#') {
				str[i]++;
			}
		}
	}
	int cnt = 1;
	for (int i = 0; i < H; i++) {
		if (str[i] == 0) {

		}
		else {
			for (int j = 0; j < W; j++) {
				G[i].push_back(cnt);
				if (S[i][j] == '#') {
					str[i]--;
					if (str[i] != 0) {
						cnt++;
					}
				}
			}
			cnt++;
		}
	}
	for (int i = 0; i < H; i++) {
		if (G[i].empty()) {
			if (i == 0) {
				for (int j = i; j < H; j++) {
					if (!G[j].empty()) {
						for (int k = 0; k < W; k++) {
							G[i].push_back(G[j][k]);
							cout << G[i][k] << " ";
						}
						break;
					}
				}
			}
			else {
				for (int j = 0; j < W; j++) {
					G[i].push_back(G[i - 1][j]);
					cout << G[i][j] << " ";
				}
			}
		}
		else {
			for (int j = 0; j < W; j++) {
				cout << G[i][j] << " ";
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1536
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = vec![];

    for i in 0..n {
        a.push(read::<i64>() - i as i64 - 1);
    }

    a.sort();

    let t = a[n / 2];
    let mut ans = 0;

    for i in 0..n {
        ans += (a[i] - t).abs();
    }

    println!("{}", ans);
}


Measured memory_bytes: 6396
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
#define __int64 long long
int ta[100001];
__int64 n,k;
__int64 ok(__int64 x){
	__int64 cnt=1,now=0;
	int i=0;
	while(i<n){
	if(now+ta[i]<=x)now+=ta[i],i++;
	else now=0,cnt++;//オーバー
	if(cnt>k)return i;
	}
	if(cnt<=k)return n;
	else return 0;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)scanf("%d",&ta[i]);
	__int64 a=0,b=20000000000000000,mid=0;
	for(int i=0;i<3000;i++){
	//cout<<a<<" "<<b<<" "<<mid<<endl;
	mid=(a+b)/2;
	int bi=ok(mid);
	if(bi<n)a=mid;//鋼板
	else if(bi>=n)b=mid;//前半
	}
	cout<<b<<endl;
	return 0;
}

Measured memory_bytes: 1628
list=map(int,raw_input().split())
W=list[0]
H=list[1]
x=list[2]
y=list[3]
r=list[4]

if x-r < 0:
    print('No')
elif x + r >W:
    print('No')
elif y-r < 0:
    print('No')
elif y+r>H:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 4640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();

            TreeMap<Integer, Integer> widths = new TreeMap<>();

            for (int i = 0; i < N; i++) {
                widths.compute(in.nextInt(), (k, v) -> v == null ? 1 : v + 1);
            }

            int diameter = widths.lastKey();
            boolean possible = true;
            for (int i = 0; i < diameter + 1; i++) {
                int width = Math.max(diameter - i, i);
                int remains = widths.compute(width, (k, v) -> v == null ? -1 : v - 1);
                if (remains < 0) {
                    possible = false;
                }
            }

            for (int w : widths.keySet()) {
                if (widths.get(w) != 0 && w <= (diameter + 1) / 2) {
                    possible = false;
                }
            }

            out.println(possible ? "Possible" : "Impossible");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}


Measured memory_bytes: 14400
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    REP(i, n){
        cin >> x[i] >> y[i];
    }
    int path = 0;
    for(int i = 0; i < n; i++){
        path+=i;
    }
    double count = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            count += sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
        }
    }
    double ans = count * (n-1) / path;
 
    printf("%.10f", ans);
}

Measured memory_bytes: 256
S = input()
lng = len(S) - 1
#print(lng)
cnt = 0

for i in range(2**lng):
    A = format(i, '09b')
    A = A[-lng:]
    #print(A)
    slc = 0
    for j in range(lng):
        #print(j)
        #print(int(A[j]))
        if int(A[j]):
            #print(int(S[slc:j+1]))
            cnt += int(S[slc:j+1])
            #cnt += int(S[slc:j+1])
            slc = j +1
    #print(int(S[slc:]))
    cnt += int(S[slc:])
print(cnt)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 0;
		double[] A = new double[N];
		for(int i = 0; i < N; i++)
			A[i] = sc.nextInt();
		Arrays.sort(A);
		int[] B = new int[N];
		for(int i = 0; i < N; i++)
			B[i] = sc.nextInt();
		Arrays.sort(B);
		double[] C = new double[N];
		for(int i = 0; i < N; i++)
			C[i] = sc.nextInt();
		Arrays.sort(C);
		for(int i = 0; i < N; i++) {
			long AB = 0, BC = 0;
			AB = - 1 - Arrays.binarySearch(A, B[i]-0.1);
			BC = N + 1 + Arrays.binarySearch(C, B[i]+0.1);
			ans += AB * BC;
		}
		System.out.println(ans);
	}
 
}

Measured memory_bytes: 95992
while true
n, x = gets.split.map(&:to_i)
break if n == 0 && x == 0

range = 1..n
box = Array.new
range.each{|number|
box << number
}

cnt = 0
box.combination(3) {|a, b, c|
cnt += 1 if x-a-b-c == 0
}

puts cnt
end

Measured memory_bytes: 6104
A,B =gets.split.map(&:to_i)
S=[]
A.times do (S<<STDIN.getc)end
flag=0
temp = STDIN.getc
flag = -1 if !(temp  == "-")
B.times do(S<<STDIN.getc) end
S.each do |s|
 flag = -1 unless s>="0" && s<="9"
end
if flag ==-1 then
  print "No"
else
  print "Yes"
end

Measured memory_bytes: 1788
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

int MOD = 998244353;
// int MOD = 1000000007;

int N = 1000000;
int arr[1000001] = {0};
//----------------------------------------------------------------
signed main(){

	ll a,b;
	cin >> a >> b;

	
    for(int i = 0; i < N; i++) arr[i] = 1;
    for(int i = 2; i < sqrt(N); i++){
        if(arr[i]){
            for(int j = 0; i * (j + 2) < N; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }
    arr[0] = 0;
    arr[1] = 0;
	ll ans = 1;
    vector<int> pri;
    for(int i = 2; i < N; i++){
        if(arr[i]){
            // cout << i;
            pri.pb(i);
			if(a%i == 0 && b%i == 0)ans++;
			while(a%i==0)a /= i;
			while(b%i==0)b /= i;
        }
    }
	if(a == b && a >= N)ans++;
	
	cout << ans << endl;
	

	return 0;
}

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

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://abc142.contest.atcoder.jp/tasks/abc142_b

Measured memory_bytes: 9208
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: r,g,b

    read*, r,g,b
    if (mod(g*10+b,4) == 0) then
        print'(a)', 'YES'
    else
        print'(a)', 'NO'
    end if
    
end program main

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N+2,0),L(N+2,0),R(N+2,0);
    for(int i=1;i<=N;i++) cin >> A[i];
    for(int i=1;i<=N;i++) L[i] = max(A[i],L[i-1]);
    for(int i=N;i>=1;i--) R[i] = max(A[i],R[i+1]);
    for(int i=1;i<=N;i++) cout << max(L[i-1],R[i+1]) << endl;
}

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

int main(){
  ll N; cin>>N;
  map<ll, ll> mpa;
  for(ll i=0; i<N; i++){
    ll D; cin>>D;
    if(mpa.count(D)) mpa[D]++;
    else mpa[D]=1;
  }
  ll M; cin>>M;
  map<ll, ll> mpb;
  for(ll i=0; i<M; i++){
    ll T; cin>>T;
    if(mpb.count(T)) mpb[T]++;
    else mpb[T]=1;
  }
  bool dame=0;
  for(auto p : mpb){
    auto k=p.first;
    auto v=p.second;
    if(mpb[k]>mpa[k]) dame=1;
  }
  if(dame) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}

Measured memory_bytes: 25216
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int N;

	cin >> N;

	long long ans =0;
	for(int i = 0; i < N; i++){
		long long x;
		cin >> x;
		ans += (x -1);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
L, R = list(map(int,input().split()))

mod_min = 2019

LRrange = min(2019, R-L+1)

for i in range(LRrange):
    for j in range(LRrange):
        if L+i+j+1>R:
            break
        else:
            mod_min = min(mod_min,(L+i)*(L+i+j+1) % 2019)

print(mod_min)


Measured memory_bytes: 40940
#include<iostream>
#include<cstdio>
using namespace std;

int h,m,s;

int main(){
    while(1){
        cin>>h>>m>>s;
        if(h==-1&&m==-1&&s==-1) break;
        int sec = h*3600 + m*60 + s;
        int ans1 = 3600*2 - sec;
        int ans2 = ans1*3;
        printf("%02d:%02d:%02d\n",
               ans1/3600, ans1%3600/60, ans1%60 );
        printf("%02d:%02d:%02d\n",
               ans2/3600, ans2%3600/60, ans2%60);
    }

    return 0;
}

Measured memory_bytes: 1140
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String p = sc.nextLine();
    int si;
    for(si = 0;si < s.length();si++){
      if(s.charAt(si) == p.charAt(0)){
        int pi;
        for(pi = 1;pi < p.length();pi++){
          if(s.charAt((si + pi) % s.length()) != p.charAt(pi))break;
        }
        if(pi == p.length()){
          System.out.println("Yes");
          break;
        }
      }
    }
    if(si == s.length())System.out.println("No");
    sc.close();
  }
}



Measured memory_bytes: 26248
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.ascii, std.regex, std.conv, std.stdio, std.typecons;

void main()
{
  for (;;) {
    auto x = readln.chomp;
    if (x == "0") break;
    writeln(x.map!(to!string).map!(to!int).sum);
  }
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	string S;
    int Q;
    cin >> S >> Q;
    string T;

    rep(i, Q){
        int t;
        cin >> t;
        if(t == 1)
            swap(S, T);
        else{
            int f;
            string c;
            cin >> f >> c;
            if(f == 1)
                T += c;
            else
                S += c;
        }
    }

    reverse(T.begin(), T.end());

    cout << T + S << endl;
	
	return 0;
}

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

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

  int T = -1;
  for (int t = 0; t < 60; t++) {
    if ((60 * t + c) % (a + b) <= a) {
      T = 60 * t + c;
      break;
    }
  }

  cout << T << endl;

  return 0;
}

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

int digit_sum(int n) {
    int a = n / 10000;
    n %= 10000;
    int b = n / 1000;
    n %= 1000;
    int c = n / 100;
    n %= 100;
    int d = n / 10;
    n %= 10;
    return a+b+c+d+n;
}

int main() {
    int n;
    scanf("%d",&n);
    int h = n / 2;
    int ans = 1000;
    for(int i = 1; i <= h; i++) {
        int x = i;
        int y = n - x;
        int counter = digit_sum(x) + digit_sum(y);
        ans = min(ans,counter);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <list>
#include <string>
#include <map>
#include <numeric>
#include<unordered_map>
#include<queue>
#include <set>
#include<unordered_set>
#include <bitset>
#include <cmath>
#include <functional>
using namespace std;
int main()
{
	ifstream fin("input.txt");
	long long N, i = 0, p, cnt = 0;
	cin >> N;
	vector<long long>vec(N);
	while (i < N)
	{
		cin >> p;
		vec[i] = p;
		i++;
	}
	for (long long i = 1; i <= N; i++)
	{
		if (vec[i - 1] == i)
		{
			if (i == N)
			{
				swap(vec[i - 1], vec[i - 2]);
				cnt++;
				continue;
			}
			swap(vec[i], vec[i - 1]);
			cnt++;
		}

	}
	cout << cnt << endl;
} 


Measured memory_bytes: 1024
/**
 *    author:  FromDihPout
 *    created: 2020-08-02
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long k;
    cin >> k;
    
    long long cycle = k / 50, rem = k % 50;
    
    cout << 50 << '\n';
    if (cycle == 0) {
        for (int i = 0; i < 50; i++) {
            if (i < 50 - rem) {
                cout << 0 << ' ';
            }
            else {
                cout << 50 << ' ';
            }
        }
    }
    else {
        for (int i = 0; i < 50; i++) {
            if (i < 50 - rem) {
                cout << cycle + i << ' ';
            }
            else {
                cout << cycle + i + 1 << ' ';
            }
        }
    }
    cout << '\n';
    return 0;
}

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

int N;
int A[100010];
int F[100010], B[100010];

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

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

    F[0] = A[0];
    for(int i = 1; i < N; i++)F[i] = gcd(F[i - 1], A[i]);

    B[N - 1] = A[N - 1];
    for(int i = N - 2; i >= 0; i--)B[i] = gcd(B[i + 1], A[i]);

    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        if(i == 0)ans = max(ans, B[1]);
        else if(i == N - 1)ans = max(ans, F[N - 2]);
        else ans = max(ans, gcd(F[i - 1], B[i + 1]));
    }

    cout << ans << endl;
}


Measured memory_bytes: 1408
#include <cstdio>
using namespace std;

long long n, a, b, c, d, st, dis, tst, tdis;
bool found;
int main(void) {
	scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
	if (a > b) dis = a - b;
	else dis = b - a;
	st = n - 2;
	if (d + st * d < dis)
		printf("NO");
	else {
		if (c + st * c <= dis)
			printf("YES");
		else {
			tst = st; tdis = dis;
			found = false;
			while (!(c + st * c <= dis && d + st * d >= dis) && st >= 0) {
				st--;
				dis += d;
				if (c + st * c <= dis && d + st * d >= dis)
					found = true;
			}
			st = tst; dis = tdis;
			while (!(c + st * c <= dis && d + st * d >= dis) && st >= 0) {
				st--;
				dis += c;
				if (c + st * c <= dis && d + st * d >= dis)
					found = true;
			}
			if (found)
				printf("YES");
			else
				printf("NO");
		}
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < (int)s.size(); i++) if (s[i] == '1') cnt++;
  dump(cnt);
  return 0;
}


Measured memory_bytes: 256