akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a;
  cin>>a;
  ll c=0;
  ll d=0;
  for(ll i=0;i<a;i++){
    ll b;
    cin>>b;
    if(b%4==0){
      c+=1;
    }
    else if(b%2==0){
      d+=1;
    }
  }
  ll e=1;
  d=max(d,e);
  if(a<=2*c+d){
    cout<<"Yes"<<endl;
  }
  
  else{
    cout<<"No"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
const int N=2e3+20;
int main()
{
	string s;
	while(cin>>s)
	{
		for(int i=0;i<s.length();i++)
		{
			if(s[i]==',')
			s[i]=' ';
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
'use strict'

function Main(input) {
  const D = Number(input.split(' ')[0]);
  let N = Number(input.split(' ')[1]);

  if(N === 100) {
    N++;
  }

  console.log(Math.pow(100,D) * N);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

int main()
{
    int n,m;
    cin >> n >> m;
    int all = 0;
    vector<int> a(n);
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        all += a[i];
    }
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        if(4*m * a[i] >= all)ans++;
    }
    cout << ((ans >= m) ? "Yes" : "No");
    return 0;
}


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

namespace _1192
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x.Max() == 0) break;
                int ret = 0;
                for (int i = 1; i <= x[2]; i++)
                {
                    for (int j = 1; j <= x[2]; j++)
                    {
                        if (i * (100 + x[0]) / 100 + j * (100 + x[0]) / 100 == x[2])
                        {
                            ret = Math.Max(ret,i * (100 + x[1]) / 100 + j * (100 + x[1]) / 100);
                        }
                    }
                }
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 9704
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
using namespace std;
int main(){
	string s = "";
	string u;
	cin >> u;
	int len = u.length();
	for (int i =0 ; i < len; i++) {
		int l = s.length();
		if (u[i] == '0') {
			s += "0";
		}
		else if (u[i] == '1') {
			s += "1";
		}
		else {
			if (l > 0) {
				s.erase(s.begin() + l - 1);
			}
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    bool able=true;
    string S,T; cin>>S>>T;
    if(T.size()!=S.size()+1) able=false;
    rep(i,S.size()){
        if(T[i]!=S[i]) able=false;
    }
    if(able) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

ll mod;

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

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

ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

/*

// a bit of NT

const int _N = 1234567;

ll F[_N];
ll IF[_N];

void init() {
	F[0] = 1;
	for(int i=1; i<_N; i++) F[i] = mul(F[i-1], i);
	IF[_N-1] = power(F[_N-1], mod-2);
	for(int i=_N-2; i>=0; i--) IF[i] = mul(IF[i+1], i+1);
}

ll ncr(ll x, ll y) {
	if(y > x || y < 0) return 0;
	return mul(F[x], mul(IF[x-y], IF[y]));
}

ll euler(ll m) {
	ll res = 1;
	for(ll i = 2; i*i <= m; i++) {
		if(m%i == 0) {
			m /= i;
			res *= (i - 1);
			while(m % i == 0) {
				m /= i;
				res *= i;
			}
		}
	}
	if(m > 1) res *= (m-1);
	return res;
}

/**/

int main() {
	// ll start = clock();
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	int cnt[2][123456];
	memset(cnt, 0, sizeof cnt);
	pair <int, int> p[2][123456];
	for(int j=0; j<2; j++) {
		for(int i=j; i<n; i+=2) cnt[j][a[i]]++;
		for(int i=0; i<123456; i++) p[j][i] = {cnt[j][i], i};
		sort(p[j], p[j]+123456);
		reverse(p[j], p[j]+123456);
	}
	if(p[0][0].se != p[1][0].se) cout << n - p[0][0].fr - p[1][0].fr << endl;
	else cout << min(n - p[0][1].fr - p[1][0].fr, n - p[0][0].fr - p[1][1].fr) << endl;
	// cerr << (clock() - start) / (CLOCKS_PER_SEC*1.0) << endl;
	return 0;
}

Measured memory_bytes: 3584
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (s.nextInt() >=k)
                ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 47792
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int i = 0, x;
		Scanner scan = new Scanner(System.in);
		while(true) {
			x = scan.nextInt();
			if (x==0) break;
			i++;
			System.out.println("Case " + i + ": " + x);
		}
	}
}



Measured memory_bytes: 40780
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef unsigned int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    ll n;
    cin>>n;
    ll MOD = 1000000007;
    vector<ll> v;

    rep(i,n){
        ll a;
        cin>>a;
        v.push_back(a);
    }
    if(v[0]!=0){cout<<0<<endl;return 0;}
    ll co[3]={1,0,0};
    ll ans=1ll;
    for(int i=1;i<n;i++){
        ll k=v[i];
        ll c=0;

        rep(j,3){
            if(k==co[j]){
               c++;
            }
        }
        if(c==0){
            cout<<0<<endl;
            return 0;
        }

        ans = ((ans%MOD)*(c%MOD))%MOD;
        rep(j,3){
            if(k==co[j]){
                co[j]++;
                break;
            }
        }
    }


    ans=ans*3ll;
    ans%=MOD;


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


Measured memory_bytes: 1528
import itertools


def main():
    N = [i for i in range(1, int(input()) + 1)]
    P = tuple(map(int, input().split(' ')))
    Q = tuple(map(int, input().split(' ')))
    x, y = 0, 0
    for enum, n in enumerate(itertools.permutations(N)):
        if n == P:
            x = enum + 1
        if n == Q:
            y = enum + 1
        if x > 0 and y > 0:
            break
    print(abs(x - y))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

X, Y = input_int()

flg=True
for i in range(X+1):
    if 2*i + (X-i)*4 == Y:
        print("Yes")
        flg=False
if flg:
    print("No")

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,i,j,n;
 string s;
  cin >> n >> s >>k;
  for(i=0;i<n;i++)
  {
    if(s.at(i)!=s.at(k-1))
    {
       s.at(i)='*';
    }
  }
  cout << s << endl;
  
}


Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = []
sortlist = []
if n == 0:
    print(x)
else:
    p.sort()
    p1 = p[0]
    pn = p[n-1]
    new = [i for i in range(0, 102)]
    nolist = set(new) ^ set(p)
    nolist = list(nolist)

    for i in range(0, len(nolist)):
        d = abs(nolist[i] - x)
        sortlist.append(d)

        k = sortlist.index(min(sortlist))
    print(nolist[k])

Measured memory_bytes: 62976
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        char[] n = sc.next().toCharArray();
        int len = n.length;
        long[][] dp = new long[len+1][2];
        dp[0][1] = 1;
        for(int i = 0; i < len; i++){
            int now = n[i] - '0';
            dp[i+1][0] = Math.min(dp[i][1] + (10-now), dp[i][0] + now);
            dp[i+1][1] = Math.min(dp[i][1] + (10-now-1), dp[i][0] + now+1);
        }
        pw.println(dp[len][0]);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
    
    private static long rep2(long b, long n, long mod){
        if(n == 0) return 1;
        long bn = rep2(b,n/2,mod);
        if(n % 2 == 0){
            return (bn*bn)%mod;
        }else{
            return (bn*bn)%mod*b%mod;
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 84184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,a,b,c,x;
  cin >> n >> a >> b;
  c = n * a;
  if (c > b) {
    x = b;
    cout << x << endl;
  }
  else if (b > c) {
    x = c;
    cout << x << endl;
  }
  else {
    x = c;
    cout << x << endl;
  }
}

Measured memory_bytes: 256
inp=input().split(" ")
H=int(inp[0])
W=int(inp[1])
N=int(inp[2])
plot=[]
times=[0 for i in range(10)]
times[0]=(H-2)*(W-2)
from collections import defaultdict
count=defaultdict(lambda:0)
def check(a,b,count):
    for i in range(3):
        for j in range(3):
            if a-i>=0 and b-j>=0 and a+2-i<=H-1 and b+2-j<=W-1:
                count[str([a-i,b-j])]+=1
for i in range(N):
    plot.append(list(map(int,input().split(" "))))
    check(plot[i][0]-1,plot[i][1]-1,count)
for i in count.values():
    times[i]+=1
    times[0]-=1
for i in range(len(times)):
    print(times[i])

Measured memory_bytes: 156256
h,w = gets.split.map(&:to_i)
lim1 = gets.split.map(&:to_i)
lim2 = gets.split.map(&:to_i)
lim1.sort!
lim1.reverse!
lim2.sort!
lim2.reverse!
ans = 1
sum = h*w
num = Array.new(h*w, 0)
if lim1[0] != lim2[0] && lim1[0] != h*w
  puts 0
  exit
end
num[-1] = 3
for i in 0..h-2
  if lim1[i] == lim1[i+1]
    puts 0
    exit
  else
    num[lim1[i+1]-1] += 1
  end
end
for i in 0..w-2
  if lim2[i] == lim2[i+1]
    puts 0
    exit
  else
    num[lim2[i+1]-1] += 2
  end
end

count1 = 0
count2 = 0
while sum > 0
  if num[sum-1] == 3
    count1 += 1
    count2 += 1
  elsif num[sum-1] == 2
    ans *= count1
    count2 += 1
  elsif num[sum-1] == 1
    ans *= count2
    count1 += 1
  else
    ans *= (count1*count2)-(h*w-sum)
  end
  if ans <= 0
    puts 0
    exit
  end
  ans %= (10**9)+7
  sum -= 1
end

p ans


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

using namespace std;

int n, a, b;
long long ans;

int s (int a)
{
    int sum = 0;
    while (a > 0)
    {
        sum+=a%10;
        a/=10;
    }
    return sum;
}

int main()
{
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++)
    {
        if (s(i)>= a && s(i)<=b) ans+=i;
    }
    cout << ans;
}


Measured memory_bytes: 256
import math

def isPrime(x):
    if x==2:
        return True
    
    if x<2 or x%2==0: #偶数もNG
        return False
    
    i=3
    while  i<=math.sqrt(x):
        if x%i==0:
            return False
        i+=2
    return True
    
n=int(input())#1度目の入力
count=0
for i in range(n):
    a=int(input())
    if isPrime(a):
        count+=1
print(count)


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin>>n&&n){
    vary(ll,v,n,inf);
    rep(i,n){
      cin>>v[i];
    }
    sort(all(v));
    ll sum = 0,ans=0;
    REP(i,1,n){
      sum = v[i-1] + sum;
      ans += sum;
    }
    cout << ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>

int min(int a,int b){return a > b ? b : a;}
int max(int a,int b){return a < b ? b : a;}

int main()
{
    int n,a,color[9] = {0};

    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&a);
        if(a <= 3199)
        {
            color[a / 400] = 1;
        }
        else
        {
            color[8]++;
        }
        
    }

    int count = 0;

    for (int i = 0; i < 8; i++)
    {
        if(color[i] == 1)count++;
    }
    
    printf("%d %d\n",max(1,count),count + color[8]);
}

Measured memory_bytes: 128
import java.util.*;
import java.lang.*;


public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        String line = sc.next();

        int same=0, different=0;
        for(int n=0; n<N-1; n++){
            if(line.charAt(n)==line.charAt(n+1)) same++;
            else different++;
        }
        System.out.println(Math.min(N-1, same+2*K));
    }
}


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

namespace Main
{
    public static class Program
    {
        public static List<int> banboos = new List<int>();
        static void Main(string[] arg)
        {
            var answer = 0;
            int n = int.Parse(Console.ReadLine());
            int[] Line = GetIntList(Console.ReadLine());
            int aa = Line[0];
            for (int i = 0; i < n - 1; i++)
            {
                aa = Gcd(aa, Line[i + 1]);
            }
            answer = aa;
            Console.WriteLine(answer);
            Console.ReadLine();

        }
        private static int[] GetIntList(string line)
        {
            return line.Split(' ').Select(x => int.Parse(x)).ToArray();

        }
        private static int SearchNearest(this IEnumerable<int> self, int target)
        {
            var min = self.Min(c => Math.Abs(c - target));
            return self.First(c => Math.Abs(c - target) == min);
        }
        public static int Gcd(int a,int b)
        {
            if(a < b)
            {
                Gcd(b, a);
            }
            while (b != 0)
            {
                var rm = a % b;
                a = b;
                b = rm;
            }
            return a;
        }
    }
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

vi node;

int root(int x)
{
    if(node[x] == x) return x;
    return node[x] = root(node[x]);
}

void unite(int x, int y)
{
    int rx = root(x);
    int ry = root(y);
    node[rx] = ry;
}

bool same(int x, int y)
{
    return root(x) == root(y);
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, M; cin >> N >> M;
    node.resize(N);
    REP(i, N) node[i] = i;
    REP(i, M)
    {  
        int a, b; cin >> a >> b;
        a--; b--;
        unite(a, b);
    }


    vi count(N);
    REP(i, N) count[root(node[i])]++;

    cout << *max_element(ALL(count)) << endl;
}

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

int main() {
  int W, A, B, C, D;
  cin >> W >> A >> C;
  if (A > C) swap(A, C);
  B = A + W;
  D = C + W;
  if (A <= C && C <= B) return cout << 0 << "\n", 0;
  if (A <= D && D <= B) return cout << 0 << "\n", 0;
  cout << C - B << "\n";
}

Measured memory_bytes: 3624
n = int(input())
x = list(map(int, input().split()))
mod = 10**9 + 7
X = []
for i in range(n - 1):
    X.append(x[i + 1] - x[i])
l, left = 1, [1]
for i in range(1, n - 1):
    l *= i
    l %= mod
    left.append(l)
r, right = 1, [1]
for i in range(n - 1, 1, -1):
    r *= i
    r %= mod
    right.append(r)
right.reverse()
f, flst = 0, []

for i, j in zip(left, right):
    f += i * j % mod
    f %= mod
    flst.append(f)
s = 0
for i, j in zip(X, flst):
    s += i * j % mod
print(s % mod)


Measured memory_bytes: 23112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define Graph vector<vector<ll>>
#define INF (ll)(1ll<<60)
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

int main(){
	ll n;cin>>n;
	vector<ll> p(n),ins(n);
	ll num=0;
	rep(i,n){
		cin>>p[i];
		ins[i]=p[i];
	}
	sort(p.begin(),p.end());

	rep(i,n){
		if(ins[i]!=p[i]) num++;
	}

	if(num>2) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

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

int main(){
    int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
    int dx = tx-sx,dy = ty-sy;
    rep(i,dy) cout << 'U';
    rep(i,dx) cout << 'R';
    rep(i,dy) cout << 'D';
    rep(i,dx+1) cout << 'L';
    rep(i,dy+1) cout << 'U';
    rep(i,dx+1) cout << 'R';
    cout << "DR";
    rep(i,dy+1) cout << 'D';
    rep(i,dx+1) cout << 'L';
    cout << 'U' << endl;
}

Measured memory_bytes: 256
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


int main(){	
	fastio;
	int a,b,k;cin>>a>>b>>k;
	int lim=min(a,b);
	int c=0;
	IFR(i,lim,1)if(a%i==0&&b%i==0){
		c++;
		if(c==k){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.charAt(0) == s.charAt(1) && s.charAt(1)== s.charAt(2) || s.charAt(1) == s.charAt(2) && s.charAt(2)== s.charAt(3)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>

using namespace std;

int main() {

  int n;
  double long a;
  cin >> n;
  
  long double x = 0.0l;
  
  for (int i = 0; i < n; i++) {
    cin >> a;
    x += 1/a;
  }
  
  long double lx = (1.0l/x);
  cout << fixed << setprecision(6) << lx << endl;

  return 0;
}


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long N;
	scanf("%lld",&N);
	std::vector<long long> P(N);
	for(ll i = 0 ; i < N ; i++){
		scanf("%lld",&P[i]);
	}

	ll count = 0;
	ll smallest = N;
	for (ll i = 0; i < N; ++i)
	{
		if (P[i] <= smallest) {
			++count;
			smallest = P[i];
		}
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

int N, A, B, C;
vector<int> V;

int Match(int count, int a, int b, int c)
{
	int res = INF32;
	if (count == N)
	{

		if (a * b * c == 0)
		{
			return INF32;
		}
		res = 0;
		res += abs(a - A);
		res += abs(b - B);
		res += abs(c - C);
		return res - 30;
	}

	res = min(res, Match(count + 1, a, b, c));
	res = min(res, Match(count + 1, a + V[count], b, c) + 10);
	res = min(res, Match(count + 1, a, b + V[count], c) + 10);
	res = min(res, Match(count + 1, a, b, c + V[count]) + 10);
	return res;
}

void execute()
{

	cin >> N >> A >> B >> C;
	V.resize(N);

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

	cout << Match(0, 0, 0, 0) << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#pragma GCC optimize "trapv"
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  string s; cin >> s;
  if(s[s.size()-1]=='s') s+="es";
  else s+="s";
  
  cout << s << '\n';  
  return 0;
}

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

int main(){
	int n,k;
	cin>>n;
	int dp[n+1][3];
	memset(dp,0,sizeof(dp));
	int new_dp[3];
	new_dp[0]=0;
	new_dp[1]=0;
	new_dp[2]=0;
	for(int i=0;i<n;i++){
		for(int k=0;k<3;k++)
		cin>>dp[i][k];
			
		for(int h=0;h<3;h++){
			for(int j=0;j<3;j++){
				if(j!=h)
				dp[i+1][j]=max((new_dp[h]+dp[i][j]),dp[i+1][j]);
			}
		}
		new_dp[0]=dp[i+1][0];
		new_dp[1]=dp[i+1][1];
		new_dp[2]=dp[i+1][2];
		
		//for(int m=0;m<3;m++)
		//cout<<new_dp[m]<<" ";
		//cout<<endl;
	}
	int res=-1;
	for(int i=0;i<3;i++){
		if(dp[n][i]>res)
		res=dp[n][i];
	}
	cout<<res;
	return 0;
}

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

int main(void){
 string s;
 int n;
 cin>>n>>s;
 
 int ans=1;
 
 for(int i=0;i<n-1;i++){
	 if(s[i]!=s[i+1]){
	 	ans++;
	 }
 }
 
 cout<<ans;

return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
static const int MAX = 100;
int main()
{
    int M, N;
    string s[MAX], t[MAX];
    int score = 0;
    scanf("%d", &M);
    for (int i = 0; i < M; i++)
    {
        cin >> s[i];
    }
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        cin >> t[i];
    }

    for (int i = 0; i < M; i++)
    {
        int w = 1;
        for (int k = i + 1; k < M; k++)
        {
            if (s[i] == s[k])
            {
                w++;
            }
        }   
        for (int j = 0; j < N; j++)
        {
            if (s[i] == t[j])
            {
                w--;
            }
        }
        if (w > score)
        {
            score = w;
        }
    }
    cout << score << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    string o, e;
    cin >> o >> e;
    string ans = "";
    for(int i = 0; i < e.size(); i++){
        ans += o[i];
        ans += e[i];
    }
    if(o.size() != e.size()){
        ans += o[o.size() - 1];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

template<typename T, typename Compare = less<T> >
void chmin(T &t, T f, Compare comp = Compare()){if(!comp(t, f))t = f;}

int N;
vector<string> dp;

string merge(string s, string t){
    if(s.find(t) != string::npos)return s;
    for(int i=max(0, (int)(s.size() - t.size())); i<(int)s.size(); ++i){
        if(s.substr(i) == t.substr(0, (int)s.size() - i)){
            return s.substr(0, i) + t;
        }
    }
    return s + t;
}

string solve(){
    rep(S, 1<<N){
        if(__builtin_popcount(S) == 1)continue;
        for(int U=S-1&S; U>0; --U&=S){
            chmin(dp[S], merge(dp[U], dp[S^U]),
                  [](const string &s, const string &t){
                        return s.size() < t.size() || (s.size() == t.size() && s < t);
                  });
        }
    }
    return dp[(1<<N) - 1];
}

int main(){
    while(cin >> N, N){
        dp.assign(1<<N, string(100, 'z'));
        rep(i, N)cin >> dp[1<<i];
        cout << solve() << '\n';
    }
    return 0;
}

Measured memory_bytes: 1328
#include <iostream>
#include <map>
#include <cstdint>

using namespace std;

uint64_t num_patterns(uint32_t c)
{
    if (c <= 1) {
        return 0;
    }

    uint64_t n = static_cast<uint64_t>(c) - 1;

    return (n + 1) * n / 2;
}

int main()
{
    uint32_t s = 0;
    uint32_t n;
    uint32_t m;
    map<uint32_t, uint32_t> counts;

    cin >> n >> m;

    counts[0] = 1;

    for (uint32_t i = 0; i < n; i++) {
        uint32_t a;
        cin >> a;

        s = (s + a) % m;
        counts[s]++;
    }

    uint64_t c = 0;
    typedef map<uint32_t, uint32_t>::iterator iterator;
    for (iterator it = counts.begin(); it != counts.end(); ++it) {
        c += num_patterns(it->second);
    }

    cout << c << endl;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e17;
const int N=2e5+10;
int a[N];
ll f[N],c1[N],c2[N];
int n;
int main() {
	ll ans,cnt;
	int i;
	ans=-INF;
	scanf("%d",&n);
	for (i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		if (i==1) c2[i]=a[i];
		else if (i%2==0) c1[i]=c1[i-2]+a[i];
		else c2[i]=c2[i-2]+a[i];
	}
	for (i=2;i<=n;i++) {
		if (i%2==0) f[i]=max(f[i-2]+a[i],c2[i-1]);
		else f[i]=max(f[i-2]+a[i],f[i-1]);
//		cout<<i<<' '<<f[i]<<endl;
	}
	printf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 9292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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; }


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

    int R, G, B, N; cin >> R >> G >> B >> N;
    int ans = 0;
    rep(r, N + 1) {
        rep(g, N + 1) {
            int b = (N - (R*r + G*g)) / B;
            if(N - (R*r + G*g + b*B) == 0 && b >= 0) {
                ans++;
            }
        }
    }
    COUT(ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
int main()
{

    string a, b, c;
    while(cin >> a >> b >> c)
    {
        int lena = a.length();
        int lenb = b.length();
        if(a[lena-1] == b[0] && b[lenb-1] == c[0])
            printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <bitset>

using namespace std;
using ull = unsigned long long;
using ll = long long;

#define EPS (1e-7) 
#define ALL(x) begin(x), end(x)

int main() {
	ull N, K;
	cin >> N >> K;
	vector<ull> A(N);
	for (size_t i = 0; i < N; i++) {
		cin >> A[i];
	}

	// XORすべき最強の数字は、ビット0が多い箇所を反転させる数字である
	// K以下の整数でなければならないので何か技がいるはずだ
	// 低い数字から決めていき、K以内でなければ打ち切るで良さそう。 ⇒ダメでした。
	// bitがONかOFFかを調べるには、割り算してから半分以上で見る。　⇒bitsetが楽でした。
	// 2の10乗が1024なので、大体10の3乗。2の40乗くらいまで回せば10の12乗カバーできそうだ。　⇒あってた。
	constexpr ull JOU = 41;

	// 立っているビットを数えるもの
	vector<int> Bits(JOU, 0);
	for (size_t i = 0; i < N; i++) {
		const bitset<JOU> bitnum(A[i]);
		for (size_t j = 0; j < JOU; j++) {
			if (bitnum[j]) {
				Bits[j]++;
			}
		}
	}

	// 数え上げできたので、半数未満であればそこのビットは立てるのが望ましい
	bitset<JOU> needOn(0);
	for (size_t i = 0; i < JOU; i++) {
		const ull ones = Bits[i];
		const ull zeros = N - Bits[i];
		if (zeros > ones) {
			needOn[i] = 1;
		}
	}

	// どちらかというと大きいビットを立てたいので逆順に見るのが正解だ　⇒ダメでした。下記参照。
	// ・・・という簡単な理屈ではなく、敢えて低いビットを立てたくなることもある
	// 例：N=3, K=4, 4, 8, 24のとき
	// 4のビットを立てるよりも、2と1の二つを立てるほうが良い。
	// というわけで解説に書いてあるように、K+1のビットを基準にして探索するのが良い

	// iをずらして答えを計算してみる
	ull ans = 0;
	const bitset<JOU> K_Bit(K + 1); // K+1のビット
	for (size_t i = 0; i < JOU; i++) {
		if (!K_Bit[i]) {
			// K+1のビットが立っている箇所のみをiの候補とする
			continue;
		}

		bitset<JOU> x(0); // iビット目そのものは0とする。(ここの初期化で済ませる)
		// iよりも上位ビットはK+1に一致させる
		for (size_t j = i + 1; j < JOU; j++) {
			x[j] = K_Bit[j];
		}
		// iよりも下位ビットは数え上げした最適な値に一致させる
		for (size_t j = 0; j < i; j++) {
			x[j] = needOn[j];
		}

		ull tempans = 0;
		for (size_t j = 0; j < N; j++) {
			tempans += A[j] ^ x.to_ullong();
		}
		ans = max(ans, tempans);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
s=input()
lo=len(s)
p=[]
m=[]
c=0
q=(lo-1)//2
a=[]
b=[]
if(s.islower() and lo%2==1):
    l=[]
    l=list(s)
    ll=l[::-1]
    if(l==ll):
        c=c+1
    p=l[0:q]
    m=p[::-1]
    if(p==m):
        c=c+1
    a=l[(lo+3)//2-1:lo]
    
    b=a[::-1]
    if(a==b):
        c=c+1
if(c==3):
    print("Yes")
else:
    print("No")





Measured memory_bytes: 3064
N,M=map(int,input().split())
K=[]
for i in range(N):
    K+=[[]]
    K[i]+=[int(j) for j in input().split()]
    K[i].pop(0)

count=0
for i in range(M):
    count1=0
    for j in range(len(K)):
        if i+1 in K[j]:
            count1+=1
    if count1==len(K):
        count+=1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
        #define ff first
        #define ss second
        #define pb push_back
        #define mkp make_pair
        #define int long long
        #define fori(j,n) for(int i=j;i<n;i++)
        #define forb(n,j) for(int i=n-1;i>=0;i--)
        #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        #define endl "\n"
        #define PI 3.141592653589793
        #define M 1000000007
        using namespace std;
        int fast(int a,int b)
        {
            int ans=1;
            a=a%M;
            if(a==0)
                return 0;
            while(b>0)
            {
                if(b&1)
                {
                    ans=(ans*a)%M;
                }
                b>>=1;
                a=(a*a)%M;
            }
        }
        int N;
        int v[105];
        int w[105];
        int dp[110][100001];
        int cal(int i,int W)
        {
            if(W<0)
                return INT_MIN;
            if(i<0 || w==0)
                return 0;
            if(dp[i][W]!=-1)
                return dp[i][W];
            int notinclude=cal(i-1,W);
            int include=v[i]+cal(i-1,W-w[i]);
            return dp[i][W]=max(include,notinclude);
        }
        int32_t main()
        {
            IOS;
            int W;
            memset(dp,-1,sizeof(dp));
            cin>>N>>W;
            fori(0,N)
            {
                cin>>w[i]>>v[i];
            }
            cout<<cal(N-1,W);
            return 0;
        }


Measured memory_bytes: 86272
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define pb push_back
    #define ld long double
    typedef pair<ll,ll> P;
    #define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    int main()
    {
        string s1,s2;
        cin>>s1;
        cin>>s2;
        ll i,n=s1.size(),m=s2.size(),j;
        ll DP[n+1][m+1];
        memset(DP,0,sizeof(DP));
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=m;j++)
            {
                if(s1[i-1]==s2[j-1])
                {
                    DP[i][j]=DP[i-1][j-1]+1;
                }
                else
                DP[i][j]=max(DP[i-1][j],DP[i][j-1]);
            }
        }
        string s;
        i=n,j=m;
        while(i>0 && j>0)
        {
            if(s1[i-1]==s2[j-1])
            {s=s+s1[i-1];i--;j--;}
            else if(DP[i-1][j]>=DP[i][j-1])
            {i--;}
            else
            {j--;}
        }
        reverse(s.begin(),s.end());
        cout<<s<<endl;
    }


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	ll L, R;
	cin >> L >> R;

	if (R - L >= 2019) {
		ce(0)
	}
	else {
		L = L % 2019;
		R %= 2019;
		if (R <= L) {
			ce(0)
		}
		else {
			ll ans = INT_MAX;
			for (ll x = L; x < R;x++) {
				for (ll y = x + 1; y <= R;y++) {
					ans = min(ans, (x*y) % 2019);
				}
			}
			ce(ans)
		}
	}
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long i64;

const int MOD = 1000000007;

int N;
i64 dp[1010101];

void add(i64 &a, i64 b)
{
	a = (a + b) % MOD;
}

int main()
{
	scanf("%d", &N);
	dp[N - 1] = N;

	i64 acc = 0;
	for (int i = N - 2; i >= 0; --i) {
		dp[i] = dp[i + 1];
		add(dp[i], (i64)(N - 1) * (N - 1));

		add(acc, dp[i + 3]);
		add(dp[i], acc);
		add(dp[i], min(N - 1, i + 2));
	//	printf("%d: %lld\n", i, dp[i]);
	}
	printf("%lld\n", dp[0]);
	return 0;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define lld long long
#define N 200005
#define INF 1e18
#define INF2 1e16
#define mod 998244353
lld power(lld a,lld b,lld c){
  lld ans=1;
  while(b){
    if(b&1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    b=b/2;
  }
  return ans;
}
int main() {
	int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k; cin>>k;
	cout<<a[k-1];

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, T;
int main () {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> N >> T;
  if (N <= 1) {
    cout << N * T << endl;
    return 0;
  }

  ll ret = 0;
  ll p = 0;
  cin >> p;
  for(int i = 1; i < N; ++i) {
    ll cp;
    cin >> cp;
    if (cp - p < T) {
      ret += cp - p;
    } else {
      ret += T;
    }
    p = cp;
  }

  ret += T;
  cout << ret << endl;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int d = sc.nextInt();
      int e = sc.nextInt();
      if(a==0){
        System.out.println(1);
      }else if(b==0){
        System.out.println(2);
      }else if(c==0){
        System.out.println(3);
      }else if(d==0){
        System.out.println(4);
      }else if(e==0){
        System.out.println(5);
      }
    }
}
    

Measured memory_bytes: 35652
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize
    }
    let mut dp = vec![0u64;n+1];
    dp[0] = 2;
    dp[1] = 1;
    for i in 0..n-1 {
        dp[i+2] = dp[i] + dp[i+1];
    }
    println!("{}", dp[n]);
}


Measured memory_bytes: 4352
//https://atcoder.jp/contests/abc167/tasks/abc167_b
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a;
	cin>>a;
	ll b;
	cin>>b;
	ll c;
	cin>>c;
	ll k;
	cin>>k;
	ll d;
	if(a>=k)
	{
		cout<<k<<"\n";
	}
	else if((a<k)&&((a+b)>=k))
	{
		cout<<a<<"\n";
	}
	else
	{
		d=k-(a+b);
		cout<<a+(d*(-1))<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3620
import numba
import numpy as np
N = int(input())
P = np.array([int(c)-1 for c in input().split()])

#from random import shuffle
#N = 500
#P = list(range(N*N))
#shuffle(P)
#P = np.array(P)

@numba.njit("i8(i8,i8[:])")
def proc(N, P):
    ans = 0
    Removed = np.zeros((500, 500), dtype=np.int8)
    Mat = np.zeros((500, 500), dtype=np.int16)
    Dy, Dx = [1,0,-1,0], [0,1,0,-1]

    for y in range(N):
        for x in range(N):
            Mat[y, x] = min(y, N-1-y, x, N-1-x)
    #print(Mat)
    for i in range(N*N):
        p = P[i]
        y, x = divmod(p, N)
        ans += Mat[y,x]
        Removed[y,x] = 1
        st = [(y, x)]
        while st:
            vy, vx = st.pop()
            vr = Removed[vy,vx]
            val = Mat[vy,vx]
            #for dy, dx in zip(Dy, Dx):
            for j in range(4):
                uy, ux = vy + Dy[j], vx + Dx[j]
                if not (0<=uy<N and 0<=ux<N):
                    continue
                ur = Removed[uy,ux]
                if vr:
                    if Mat[uy,ux] >= val+1:
                        Mat[uy,ux] = val
                        st.append((uy, ux))
                else:
                    if Mat[uy,ux] >= val+2:
                        Mat[uy,ux] = val+1
                        st.append((uy, ux))
    # for m in Mat:
    #     print(m)
    return ans
print(proc(N, P))



Measured memory_bytes: 122220
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
signed main(){
    int n;
    cin>>n;
    int a[114514];
    for(int i=0;i<2*n;i++)cin>>a[i];
    sort(a,a+2*n);
    int ans=0;
    for(int i=0;i<2*n;i++){
        if(i%2==0)ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String age = br.readLine();
    
    if ("1".equals(age)) {
      System.out.println("Hello World");
    } else {
      int A = Integer.parseInt(br.readLine());
      int B = Integer.parseInt(br.readLine());
      System.out.println(A + B);
    }
  }
} 

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

using ll = long long;

ll l, r, ans, m = 10000;
int main() {
    std::cin >> l >> r;
    for (ll i = l; i <= l+2019 && i <= r; i++) {
        for (ll p = i; p <= r && p <= l+2019; p++) {
            if (i == p) {
                continue;
            }
            ans = (i * p) % 2019;
            if (ans < m) {
                m = ans;
            }

        }
    }
    std::cout << m << std::endl;
}


Measured memory_bytes: 256