akhauriyash/Code-Regression huggingface dataset:
# coding=utf-8

###
### for atcorder program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

# リスト内包表記 ifあり
# [x-k if x != 0 else x for x in C]

# ソート
# N = N.sort()

# 10000個の素数リスト
# P = mymath.pnum_eratosthenes(105000)

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            #N.append(int(input()))
            #N.append(float(input()))
        except EOFError:
            break
    return N

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def dist(A, B):
    d = 0
    for i in range(len(A)):
        d += (A[i]-B[i])**2            
    d = d**(1/2)
    return d


N = int(input())
A = [int(x) for x in input().split()]

#print(list(range(N-1, 0, -1)))

count = 0
for i in range(N-1):
    for j in range(N-1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            count += 1

for i, n in enumerate(A):
    print(n, end='')
    if i != N-1:
        print(' ', end='')
print()

print(count)



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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    string a,s,c;
    cin >> a >> s >> c;
    cout << 'A' << s[0] << 'C' << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int year, month, day;
  int count,counter=0, sum=0;

  scanf("%d", &count);

  while(counter<count){
    int difference_year=0; //1,1,1~(year-1),10,20?????§?????\??°
    int multiple_three=0; //3????????°?????´????????°
    int even_month=0; //??¶??°??????????????°
    int odd_month=0; //?\???°??????????????°

    scanf("%d %d %d", &year, &month, &day);

    multiple_three=(year-1)/3;
    difference_year=multiple_three*200+((year-1)-multiple_three)*195;

    if(year%3==0){ //3????????°?????´??????
      sum=difference_year+(month-1)*20+day;
    }else{
      even_month=(month-1)/2;
      odd_month=month-even_month-1;
      sum=difference_year+even_month*19+odd_month*20+day;
    }

    printf("%d\n", 196471-sum);
    counter++;
  }

  return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int a,b;
    cin >> a >> b;
    if (b % a == 0) {
        cout << a+b << endl;
    } else {
        cout << b-a << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b;
int main(){
    scanf("%lld%lld%lld",&n,&a,&b);
    ll x=abs(b-a);
    if(x%2==0)printf("%lld\n",x/2);
    else{
        if(a>b)swap(a,b);
        printf("%lld\n",min(a-1,n-b)+1+(x-1)/2);
    }
    return 0;
}

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

int n,x[100100],cnt_1,cnt_2,cnt_4;

int main(){
    cin >> n;
    for(int i = 1;i <= n;++i){
        scanf("%d",&x[i]);
        if(x[i] % 2 == 1)
            cnt_1++;
        else{
            if(x[i] % 4 == 0)
                cnt_4++;
            else
                cnt_2++;
        }
    }
    if(cnt_4 >= cnt_1){
        cout << "Yes" << endl;
        return 0;
    }
    if(cnt_4 == cnt_1 - 1 && cnt_2 == 0){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 640
using System;
using System.Linq;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			var a = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList();
			Console.WriteLine("a {0} b",a[0]<a[1]?"<":a[0]>a[1]?">":"==");
		}
	}
}

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

using namespace std;

int main(int argc, char *argv[]) {
  std::ios_base::sync_with_stdio(false);
  int n, X;
  cin >> n >> X;
  vector<int> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i + 1 < a.size(); i++) {
    if (X >= a[i]) {
      X -= a[i];
      ans++;
    }
  }
  ans += X == a.back();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
mod = 10**9+7
dp = [[0]*13 for _ in range(len(s))]
t = [1]
for i in range(len(s)-1):
    t.append(t[-1]*10%13)
t.reverse()
#print(t)
if (s[0]=="?"):
    for i in range(10):
        dp[0][t[0]*i%13] = +1
else:
    dp[0][t[0]*int(s[0])%13] += 1
for i in range(1,len(s)):
    if (s[i]=="?"):
        for j in range(13):
            for k in range(10):
                dp[i][(j + t[i]*k)%13] += dp[i-1][j]
                dp[i][(j + t[i]*k)%13] %= mod
    else:
        for j in range(13):
            #print(i,j,(j + t[i]*int(s[i]))%13)
            dp[i][(j + t[i]*int(s[i]))%13] += dp[i-1][j]
            dp[i][(j + t[i]*int(s[i]))%13] %= mod             
#print(dp)
print(dp[len(s)-1][5])

Measured memory_bytes: 93928
import java.util.Scanner;

public class Main {
	 public static void main(String args[]){
		 Scanner std = new Scanner(System.in);
		 int n = std.nextInt();
		 int x = std.nextInt();
		 int[] l = new int[n];
		 for(int i=0;i<n;i++) {
			 l[i] = std.nextInt();
		 }
		 int d=0;
		 int a=0;
		 for(int i=0;i<n;i++) {
			 d+=l[i];
			 if(d>x) {
				 System.out.println(i+1);
				 a = 1;
				 break;
			 }
		 }
		 if (a==0) {
			 System.out.println(n+1);
		 }
	 }
}


Measured memory_bytes: 22868
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    ll sum = 0;
    rep(i, S.length()) {
        int c = S[i] - '0';
        sum += c;
    }
    if(sum % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;


const int mod = 100000007;
const int inf = 100000005;
const int N = 3e5, M = N;
ll i,j,n,m;


void solve() {
    ll n;
    cin>>n;

    string ans = "";
    while(n) {
        n--;
        ans+=(char)(n%26 + 'a');
        n/=26;
        
    }
    
    reverse(all(ans));
    cout<<ans<<"\n";
}


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

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

    return 0;
}




Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N + 1, 0);
    for(int i = 0; i < N; i++){
        int n;
        cin >> n;
        A[n]++;
    }
    
    vector<int> cnt;
    for(int i = 1; i <= N; i++){
        if(A[i] > 0){
            cnt.push_back(A[i]);
        }
    }
    
    if(cnt.size() <= K){
        cout << 0 << endl;
        return 0;
    }
    
    sort(cnt.begin(), cnt.end(), greater<int>());
    
    int temp = 0;
    for(int i = 0; i < K; i++){
        temp += cnt[i];
    }
    
    cout << N - temp << endl;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define P pair
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define endl '\n'

using namespace std;

typedef long long ll;
typedef P<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int32_t main()
{
	IO_OP;
	
	string s, t = "LR";
	cin >> s;
	bool ok = true;
	for(int i=0;i<s.size();i++)
		if(s[i] == t[i&1])
			ok = false;
	cout << (ok ? "Yes" : "No") << endl;
}





Measured memory_bytes: 256
import scala.io.StdIn._
import scala.math._

object Main extends App with StdInHelper {
  val n = readInt
  val as = readInts

  val maxA = as.max
  val dp = scala.collection.mutable.Map[Int, Int]().withDefaultValue(0)

  for (a <- as) {
    for (i <- a to maxA by a) {
      dp(i) += 1
    }
  }

  var res = 0

  for (a <- as) {
    if (dp(a) == 1) res += 1
  }

  println(res)
}

trait StdInHelper {
  def readStrings = {
    val l = readLine
    if (l == "") Array.empty[String]
    else l.split(" ")
  }
  def readInts = readStrings.map(_.toInt)
  def readLongs = readStrings.map(_.toLong)
  def readDoubles = readStrings.map(_.toDouble)
  def readBigInts = readStrings.map(BigInt.apply(_))
  def readBigDecimals = readStrings.map(BigDecimal.apply(_))
}


Measured memory_bytes: 142748
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  ll march[5];
  for(int i=0; i<5; i++)
    march[i] = 0;
  for(int i=0; i<N; i++){
    string in;
    cin >> in;
    if(in[0] == 'M') march[0]++;
    else if(in[0] == 'A') march[1]++;
    else if(in[0] == 'R') march[2]++;
    else if(in[0] == 'C') march[3]++;
    else if(in[0] == 'H') march[4]++;
  }
  ll ret = 0;
  for(int i=0; i<5; i++)
    for(int j=i+1; j<5; j++)
      for(int k=j+1; k<5; k++)
        ret += march[i] * march[j] * march[k];
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, k;
  cin >> n >> k;
  cout << n % k << endl;
}


Measured memory_bytes: 3572
// Created by abhay
#include <bits/stdc++.h>
#define sz(a) int((a).size())
#define pb push_back
#define allc c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(allc,x) != c.end())
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
const double pi=3.14;
using namespace std;

int main()

{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll r;
	cin>>r;
	cout<<setprecision(6)<<(2*pi*r);
}


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

int main()
{
     int h,w;
  cin >> h >> w;
  while(h!=0 && w!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	  if(i%2==0)
	  {
	      if(j%2==0) cout<<"#";
	      else cout<<".";
	  }
	  if(i%2!=0)
	  {
	      if(j%2==0) cout<<".";
	      else cout<<"#";
	  }
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main() {
    ll N;
    cin >> N;

    vector<ll> a(N);
    ll total = 0;
    for (ll i = 0; i < N; i++) {
        cin >> a[i];       
        a[i] -= (i+1);
        total += a[i];
    }

    sort(a.begin(), a.end());
    //cout << "total=" << total << endl;
    vector<ll> b(3);
    b[1] = a[N/2];
    if (N / 2 - 1 >= 0)
        b[0] = a[N / 2 - 1];
    if (N / 2 + 1 <= N - 1)
        b[2] = a[N / 2 + 1];

    ll ans = LLONG_MAX; 
    for (int i = 0; i < 3; i++) {
        ll temp = 0;
        for (int j = 0; j < N; j++) {
            temp += abs(a[j] - b[i]);
        }
        ans = min(ans, temp);
    }

    cout << ans << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;

int main(){
    int n;
    double res;
    cin >> n;
    vector<int> v(n);
    for(int i = 0;i < n;i++){
        cin >> v.at(i);
        res += 1.0/v.at(i);
    }
    res = 1.0/res;
    cout << setprecision(16) << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s,t,v;
    cin>>s>>t>>v;
    double ans=s*1.0/v;
    if(ans<=t)
    {
        cout<<"Yes"<<endl;

    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


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

int player[100005];
int counter[100005];

#undef int
int main()
{
#define int long long
    int n, k, q, x;
    cin >> n >> k >> q;

    memset(player, 0, sizeof(player));
    memset(counter, 0, sizeof(counter));

    for (int i = 0; i < q; i++)
    {
        cin >> x;
        counter[x]++;
    }
    for (int i = 1; i <= n; i++)
    {
        player[i] += (k - q) + counter[i];
    }
    for (int i = 1; i <= n; i++)
    {
        if (player[i] <= 0)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
const constexpr int INF = 1e9;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
struct Less{
   bool operator()(const pair<string, int>&a, const pair<string, int>&b){
        if(a.first==b.first){
            return a.second < b.second;
        }
       return a.first < b.first;
    }
};
const constexpr ll MOD = 1e9;


ll extGCD(ll a, ll b, ll& x, ll& y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}
ll GCD(ll a, ll b){
    if(a<b) swap(a, b);
    if(b==0) return a;
    return GCD(b, a%b);
}
int p[100010];

int par[100010], rr[100010];
void init(){
    for(int i=0; i<100010; ++i){
        par[i]=i;
        rr[i]=0;
    }
}
int root(int x){
    return par[x] == x ? x:par[x] = root(par[x]);
}
bool same(int x, int y){
    return root(x)==root(y);
}
void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x==y) return ;
    
    if(rr[x]<rr[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(rr[x]==rr[y]) rr[x]++;
    }
}

int main() {
    REP(i, 100010) p[i] = -1; 
    init();
    int N, M; cin >> N >> M;
    REP(i, N){ 
        cin >> p[i];
        p[i]--;
    }
    REP(i, M){
        int x, y; cin >> x >> y;
        x--; y--;
        unite(x, y);
    }
    int cnt=0;
    REP(i, N){
        if(same(i,p[i]))cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class2
    {
        static void Main()
        {
            long H = long.Parse(Console.ReadLine());
            long count = 0;
            
            long ans = 1;
            while (H > 0)
            {
                H /= 2;
                count++;
            }
            for(int i = 0; i < count; i++)
            {
                ans *= 2;
            }
            ans = ans == 1 ? 1 : ans - 1;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    vector<int> p(N);
    rep(i, N) cin >> p[i];

    LL ans = 0;
    for (int i = 1; i+1 < N; ++i) {
        if ((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    long n;
    int k, cnt = 1, amari;
    scanf("%d %d", &n, &k);
    while(1){
        if(n < k){
            printf("%d\n", cnt);
            return 0;
        }
        amari = n % k;
        n = (n - amari) / k;
        cnt++;
    }
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n;
int h[100007];
int k;
int f[100007];
int main()
{
    cin>>n>>k;
    int i;
    for(i=1;i<=n;i++)
        cin>>h[i];
    f[1]=0;
    int j;
    f[2]=abs(h[2]-h[1]);
    for(i=3;i<=n;i++)
    {
      j=1;
      f[i]=f[i-j]+abs(h[i]-h[i-j]);
      for(j=2;j<=k;j++)
        if(i-j>0)
          f[i]=min(f[i-j]+abs(h[i]-h[i-j]),f[i]);
        else break;
    }
     cout<<f[n];
    return 0;
}


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


using namespace std;


#ifdef zxc

#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-8;
const ll MOD = 1e9 + 7;
const ld PI = 3.141592653589793;
const int maxn = 2001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}


ll a[maxn];
ll dp[maxn];

signed main() {
#ifdef zxc
    mt19937 mt(228);
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_input.txt", "w", stdout);
#else
    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
//            freopen("", "r", stdin);
//        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(10);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    int n;
    cin >> n;
    ll x;
    cin >> x;
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        ans += a[i];
        dp[i] = a[i];
    }


    for (int cnt = 1; cnt <= n; ++cnt) {
        ll cur = 0;
        for (int i = 1; i <= n; ++i) {
            int prev = (i - cnt);
            if (prev <= 0) {
                prev += n;
            }
            dp[i] = min(dp[i], a[prev]);
            cur += dp[i];
        }
        ans = min(ans, cur + cnt * x);
    }
    cout << ans;
    auto end = chrono::steady_clock::now();
    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}

int main()
{

	char x;
	cin>>x;
	x++;
	cout<<x;
}



Measured memory_bytes: 256
N = int(input())
red = {}
for i in range(N):
    tmp = input()
    if tmp in red:
        red[tmp] += 1
    else:
        red[tmp] = 1

M = int(input())
for i in range(M):
    tmp = input()
    if tmp in red:
        red[tmp] -= 1

print(max(0,max(red.values())))

Measured memory_bytes: 3064
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int n, a[26];
vector<string> vec;
string ans;
void func(int m) {
	if (m == n) {
		vec.push_back(ans);
		return;
	}
	ans += 'a';
	a[0]++;
	func(m + 1);
	ans.pop_back();
	a[0]--;
	REP(i, 25) {
		if (a[i]) {
			ans += 'a' + i;
			a[i]++;
			func(m + 1);
			ans.pop_back();
			a[i]--;
		}
		else if (i) {
			if (a[i - 1]) {
				ans += 'a' + i;
				a[i]++;
				func(m + 1);
				ans.pop_back();
				a[i]--;
			}
		}
	}
}
signed main() {
	cin >> n;
	func(0);
	for (string s : vec)cout << s << endl;
	return 0;
}

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

int main(){
  int n; cin >> n;
  ll l[n];
  int ans = 0;
  rep(i, n) cin >> l[i];
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      for(int k = j + 1; k < n; k++){
        ll a = l[i], b = l[j], c = l[k];
        if(a != b && b != c && c != a && a + b > c && b + c > a && c + a > b) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <algorithm>
#define R register
using namespace std;
const int MAXN=100100;
char s1[MAXN],s2[MAXN];
int pr1[MAXN][2],pr2[MAXN][2];

template<class T>void read(T &x)
{
	x=0;int ff=0;char ch=getchar();
	while(ch<'0'||ch>'9'){ff|=(ch=='-');ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	x=ff?-x:x;
}

int reads(char *st)
{
	int len=0;char ch=getchar();
	while(ch<'A'||ch>'B')ch=getchar();
	while(ch>='A'&&ch<='B')st[++len]=ch,ch=getchar();
	return len;
}

int main()
{
	int n1,n2;
	n1=reads(s1),n2=reads(s2);
	for(R int i=1;i<=n1;++i)
	{
		pr1[i][0]=pr1[i-1][0];
		pr1[i][1]=pr1[i-1][1];
		if(s1[i]=='A')++pr1[i][0];
		else ++pr1[i][1];
	}
	for(R int i=1;i<=n2;++i)
	{
		pr2[i][0]=pr2[i-1][0];
		pr2[i][1]=pr2[i-1][1];
		if(s2[i]=='A')++pr2[i][0];
		else ++pr2[i][1];
	}
	int m;
	read(m);
	int t1,t2,t3,t4;
	for(R int i=1;i<=m;++i)
	{
		read(t1),read(t2),read(t3),read(t4);
		int d1=(pr1[t2][0]-pr1[t1-1][0])-(pr1[t2][1]-pr1[t1-1][1]);
		int d2=(pr2[t4][0]-pr2[t3-1][0])-(pr2[t4][1]-pr2[t3-1][1]);
		int d=d1-d2;
		if(d<0)d=-d;
		if(d%3==0)puts("YES");
		else puts("NO");
	}
	return 0;
}

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

char prv(char c) {
    if (c == '?') return '?';
    return c == 'A' ? 'Z' : c - 1;
}
char nxt(char c) {
    if (c == '?') return '?';
    return c == 'Z' ? 'A' : c + 1;
}
string exp1(string& s, int& i);
string exp2(string& s, int& i);
char exp3(string& s, int& i);
string exp1(string& s, int& i) {
    string acc = exp2(s, i);
    while (i < s.size() && s[i] != ']') {
        acc += exp2(s, i);
    }
    return acc;
}
string exp2(string& s, int& i) {
    if (s[i] == '[') {
        string ret = exp1(s, ++i);
        assert(s[i] == ']');
        i++;
        reverse(ret.begin(), ret.end());
        return ret;
    }
    return ""s + exp3(s, i);
}
char exp3(string& s, int& i) {
    if (s[i] == '+') return nxt(exp3(s, ++i));
    if (s[i] == '-') return prv(exp3(s, ++i));
    return s[i++];
}
void solve() {
    string s; cin >> s;
    if (s == ".") exit(0);
    int i = 0;
    string t = exp1(s, i);
    for (auto& c : t) {
        if (c == '?') c = 'A';
    }
    cout << t << endl;
}
signed main() {
    while (1) solve();
}



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

class Program {

    static void Main (string[] args) {
        int K = int.Parse (Console.ReadLine ());
        string S = Console.ReadLine ();
        if (S.Length <= K) {
            Console.WriteLine (S);
        } else {
            S = S.Substring (0, K);
            Console.WriteLine (S + "...");
        }
        //% 998244353
    }
}
//dotnet run --project test

Measured memory_bytes: 27332
n,m = map(int,input().split())

C={}
S1=[]
for i in range(n):
    a,b = map(int,input().split())
    S1.append(a)
    if a in C:
        C[a]+=b
    else:
        C[a]=b
S=list(set(S1))
S.sort()

ans=0
for s in S:
    # print(S,C,ans)
    if m<C[s] :
        ans+=m*s
        break
    else:
        ans+=C[s]*s
        m-=C[s]

print(ans)




Measured memory_bytes: 27880
#include <iostream>
#include <set>

using namespace std;

typedef multiset<int> si;

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

    int n, m;
    cin >> n >> m;
    si s;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s.insert(a);
    }

    for (int i = 0; i < m; i++) {
        s.insert(*s.rbegin() / 2);
        s.erase(prev(s.end()));
    }

    long long ans = 0;
    for (int a : s) {
        ans += a;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n,m;
	cin >> n >> m;
	int ans;
	ans = (n * (n-1)) /2;
	if (m>=2) {
		ans = ans + (m * (m -1) /2);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////
map<int,int> mp;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    int n;
    cin>>n;
    int x;
    REP(i,n)
    {
        cin>>x;
        mp[x]++;
    }
    ll ans=0;
    for(auto i:mp)
    {
        if(i.second<i.first)
        ans+=i.second;
        else ans+=abs(i.first - i.second);
    }
    cout<<ans;
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

Measured memory_bytes: 8160
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll dp[200001][3] = {};
ll dp2[200001][3][3] = {};
int main() {
	string s; cin >> s;
	int len = s.length();
	if (len <= 4) {
		int out = 1;
		queue<string> q;
		map<string, int> mp;
		mp[s] = 1;
		q.push(s);
		while (!q.empty()) {
			string x = q.front(); q.pop();
			rep(i, len - 1) {
				string y = x;
				if (x[i] != x[i + 1]) {
					char u = ('d' - x[i]) + 'a' - x[i + 1] + 'a';
					y[i] = y[i + 1] = u;
					if (!mp[y]) {
						mp[y] = 1; q.push(y); out++;
					}
				}
			}
		}
		cout << out << endl;
	}
	else {
		bool f = true; int chk = 0;
		bool g = true;
		rep(i, len - 1) {
			if (s[i] != s[i + 1])f = false;
			if (s[i] == s[i + 1])g = false;
			chk = (chk + (int)(s[i] - 'a')) % 3;
		}
		chk = (chk + (int)(s[len - 1] - 'a')) % 3;
		if (f) {
			cout << 1 << endl;
		}
		else {
			dp[0][0] = 1;
			dp2[0][0][0] = 1;
			dp2[1][0][0] = 1;
			rep(i, len) {
				rep(j, 3) {
					rep(k, 3) {
						dp[i + 1][(k + j) % 3] = (dp[i + 1][(k + j) % 3] + dp[i][j]) % MOD;
						if (j != k) {
							rep(l, 3) {
								dp2[i + 1][k][(k + l) % 3] = (dp2[i + 1][k][(k + l) % 3] + dp2[i][j][l]) % MOD;
							}
						}
					}
				}
			}
			ll sum = 0;
			rep(i, 3) {
				sum += dp2[len][i][chk];
			}
			sum %= MOD;
			ll res = dp[len][chk] - sum;
			if (g)res++;
			res = (res + 2 * MOD) % MOD;
			cout << res << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 19460
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;

int main(){

	vector<string> t;
	string s;
	int k;
	cin >> s >> k;
	for(int i=0; i<s.size(); i++){
		for(int j=1; j<=5; j++){
			t.push_back(s.substr(i, j));
		}
	}
	sort(t.begin(), t.end());
	unique(t.begin(), t.end());
	cout << t[k-1] << endl;

	return 0;
}


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

class Program {
    static void Main (string[] args) {
        string[] input1 = Console.ReadLine ().Split (' ');
        string[] input2 = Console.ReadLine ().Split (' ');
        long N = long.Parse (input1[0]);
        int M = int.Parse (input1[1]);
        long total = 0;
        for (int i = 0; i < M; i++) {
            total += long.Parse (input2[i]);
        }
        if (total > N) {
            Console.WriteLine (-1);
        } else {
            Console.WriteLine (N - total);
        }
    }
}

Measured memory_bytes: 28300
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int main(){
    string in = "ACGT";
    string s;
    cin >> s;
    int cur = 0;
    int ans = 0;
    rep(i, s.size()){
        if(find(all(in), s[i]) != in.end()){
            cur++;
            if(i == s.size() -1) chmax(ans, cur);
        }else{
           chmax(ans, cur);
           cur = 0;
        }
    }

    cout << ans <<endl;
}



Measured memory_bytes: 256
/* AOJ 0084
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0084
 *
 */

#include <stdio.h>




int head[1024];
int len[1024];
int wc;


int is_sep(char c){
    return c == ' ' || c == '.' || c == ',';
}

void chop(char* buf){
    int h, l, pos;

    h = 0;
    l = 0;
    pos = 0;
    while(*buf){
        if(is_sep(*buf)){
            if(l){
                head[wc] = h;
                len[wc] = l;
                wc++;
            }
            l = 0;
        }else{
            if(l==0){
                h = pos;
            }
            l++;
        }
        buf++; pos++;
    }

}



int main(){
    char buf[1026];
    int i, j;
    int isfirst;

    while(fgets(buf, 1024, stdin)){
        wc = 0;
        isfirst = 1;
        chop(buf);
        for(i=0;i<wc; i++){
            if(len[i]>2 && len[i] < 7){
                if(isfirst){
                    isfirst = 0;
                }else{
                    printf(" ");
                }
                for(j=0;j<len[i];j++){
                    printf("%c", *(buf+head[i]+j));
                }
            }
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    private static final String KEYENCE = "keyence";

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

        if (str.contains(KEYENCE)) {
            System.out.println("YES");
            return;
        }
        // 分割して存在している場合、文字列の最初と最後でマッチしている必要がある
        for (int i = 1; i < KEYENCE.length(); i++) {
            String s1 = KEYENCE.substring(0, i);
            String s2 = KEYENCE.substring(i);
            if (str.startsWith(s1) && str.endsWith(s2)) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }

}


Measured memory_bytes: 22864
#include "bits/stdc++.h"

using namespace std;

int main()
{
    int n,d;
    cin >> n >> d;
    int x[n][d];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
        cin >> x[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
        int ni=0;
            for(int k=0;k<d;k++){
                int tmp=abs(x[i][k]-x[j][k]);
                ni+=tmp*tmp;
            }

        int f=0;
        for(int j=0;j<=ni;j++){
            if(ni==j*j)f=1;
        }
        if(f)ans++;
        }
    }
    cout << ans<< endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  long long int ans=0,b;
  cin>>s;
  for(int i=0;i<s.size();i++){
    b=i;
    if(s[i]=='B'){
      break;
    }
  }
  for(int j=b;j<s.size();j++){
    if(s[j]=='W'){
      ans+=j-b;
      b++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int front(int x) {
  while(x > 9) x /= 10;
  return x;
}

int back(int x) {
  return x % 10;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  int a, b, ans = 0;
  for(int i = 1; i <= n; i++){
    a = front(i);
    b = back(i);
    if(b == 0) continue;
    
    if(a == b) ans++;
    
    if(10 * b + a <= n) ans++;
    
    for(int i = 0; i <= 9; i++){
      if(100 * b + 10 * i + a <= n) ans++;
      else break;
    }
    
    for(int i = 0; i <= 99; i++){
      if(1000 * b + 10 * i + a <= n) ans++;
      else break;
    }
    
    for(int i = 0; i <= 999; i++){
      if(10000 * b + 10 * i + a <= n) ans++;
      else break;
    }
    
    for(int i = 0; i <= 9999; i++){
      if(100000 * b + 10 * i + a <= n) ans++;
      else break;
    }
  }
  
  cout << ans << '\n';
}

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

Measured memory_bytes: 3100
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <algorithm>
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
int main() {
	char t[2][2];
	t[0][0] = 'R', t[0][1] = 'Y';
	t[1][0] = 'G', t[1][1] = 'B';
	int h, w, d; read(h), read(w), read(d);
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			int x = (i + j) / d, y = (i - j + w) / d;
			int tx = x & 1, ty = y & 1;
			putchar(t[tx][ty]);
		}
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 3084
N, K = [int(i) for i in input().split()]
X = sorted([int(i) for i in input().split()])

minv = 10**18
for i in range(N-K+1):
    l, r = X[i], X[i+K-1]

    minv = min(minv, r-l+abs(l))
    minv = min(minv, r-l+abs(r))

print(minv)

Measured memory_bytes: 14252
import math

N,K=map(int, input().split())

ans = float(0)

Kd = float(0)
Nd =int(0)
i = int(1)


if N>=K:
    Nd = K-1
    ans += N-K+1

else:
    Nd = N

while Nd>=1 :
    Kd = K/(2**i)
    if Kd<=Nd:
        ans += (Nd - math.ceil(Kd) +1) / (2 ** i)

        if math.ceil(Kd)-math.floor(Kd)==0.0:
            Nd = math.ceil(Kd)-1
        else: Nd = math.floor(Kd)

    i +=1


ans = ans/N

print(ans)

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

stack<int> st;
int calc(string com){
    int a = st.top(); st.pop();
    int b = st.top(); st.pop();
    if(com == "+")return a+b;
    else if(com == "-")return b-a;
    else if(com == "*")return a*b;
}
int main(){
    string str;
    while(cin >> str){
        if(str == "+" || str == "-" || str == "*"){
            st.push(calc(str));
            //cout << st.top() << endl;
        }
        else st.push(atoi(str.c_str()));
        if(getchar() == '\n')break;
    }
    cout << st.top() << endl;
    return 0;
}


Measured memory_bytes: 3200
n=int(input())
p=list(map(int, input().split()))
q=list(map(int, input().split()))
ans = sum(p)+q[n-1]
tmp = ans
for i in range(n-1):
  tmp = tmp + q[n-i-2] - p[n-i-1]
  ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 81568
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << ' ';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  //string S{}; std::cin >> S;
  //ui  N{}; std::cin >> N;

  ull W{}, H{}, x{}, y{};
  std::cin >> W >> H >> x >> y;

  std::cout << ((long double)W * (long double)H) / 2
            << ' '
            << ((2 * x == W && 2 * y == H) ? 1 : 0)
            << '\n';

  return;
}

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

  solve();

  return 0;
}


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

int main(){
    int H,W,N;
    cin >> H >> W >> N;

    int a[10000];
    for(int i=0;i<N;i++){
        int b;
        cin >> b;
        a[i]=(i==0?b:a[i-1]+b);
    }
    int c[100][100];
    int ai=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int x=i*W+j;
            if(x==a[ai]) ai++;
            c[i][(i%2==0)?j:W-1-j]=ai+1;
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W-1;j++){
            cout << c[i][j] << " ";
        }
        cout << c[i][W-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000005
#define MAX 100004
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int a[MAX], b[MAX], f[MAX];
int main(){
	int n, m, p = 1;
	scanf("%d%d", &n, &m);
	for(int i = 1;i < n;i++)scanf("%d", &a[i]);
	for(int i = 1;i <= m;i++)scanf("%d", &b[i]);
	for(int i = 1;i <= m;i++){
		if(b[i] > 0){
			f[p]++;
			f[p+b[i]]--;
			p += b[i];
		}else{
			f[p+b[i]]++;
			f[p]--;
			p += b[i];
		}
	}
	int ans = 0;
	for(int i = 1;i < n;i++){
		f[i] += f[i-1];
		ans += (f[i]*a[i]);
		ans %= 100000;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
vector<double> p;
vector<vector<double> > m;
double call(int i,int t){
	if(i==p.size()-1){
		m[i][t]=0.0;
		if(t>=(p.size()/2)){
		   m[i][t]+=p[i];
		   if(t>(p.size()/2)){
		   	m[i][t]+=(1-p[i]);
		   }
		   return m[i][t];	
		}
		else{
			return 0.0;
		}
	}
	if(m[i][t]!=-1.0){
		return m[i][t];
	}
	m[i][t]=call(i+1,t+1)*p[i]+call(i+1,t)*(1-p[i]);
    return m[i][t];	
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	p.resize(n);
	m.resize(n,vector<double>(n));
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			m[i][j]=-1.0;
		}
	}
	cout<<setprecision(16)<<call(0,0);
}


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

typedef long long ll;

int main(){
  ll L, R;
  cin >> L >> R;
  R = min(R, L+2019);
  ll ans = 100000000;
  for (ll i=L;i<=R-1;i++){
    for (ll j=i+1;j<=R;j++){
      ans = min(ans, i*j % 2019);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256