akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define lld long double
using namespace std;
const int N = 101000;
char c[N];
int main(){
	sprintf(c,"p=int(1e9+7)\ndef calc(n,l,r):\n\tf=[0]* (n+1)\n\tf[0]=1\n\tsum=0\n\tfor i in range (1,n+1):\n\t\tif i>=l:\n\t\t\tsum+=f[i-l]\n\t\tf[i]=sum%%p\n\t\tif (i>=r):\n\t\t\tsum-=f[i-r]\n\tans=0\n\tfor i in range (l,r+1):\n\t\tans=(ans+f[n-i]*i)%%p\n\treturn ans\nn,m=input().split()\nn=int(n)\nm=int(m)\ns=input()\na=s.split(chr(ord('R')+ord('B')-ord(s[0])))\nif len(a)==1:\n\tprint((calc(n,2,n)+1)%%p)\nelif n%%2==1:\n\tprint(0)\nelse:\n\tr=len(a[0])+1-len(a[0])%%2\n\tfor i in range(1,len(a)-1):\n\t\tif len(a[i])%%2==1 :\n\t\t\tr=min(r,len(a[i]));\n\tn=n//2\n\tr=(r+1)//2\n\tprint(calc(n,1,r)*2%%p)\n");
	string out;
	out="python3 -c \"";
	int len=strlen(c);
	for(int i=0;i<len;i++)
		out+=c[i];
	out+="\"";
	system(out.data());
	return 0;
}



Measured memory_bytes: 11584
# from pprint import pprint
# import math
# import collections

# n = int(input())
x, k, d = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

# 開始位置の符号は正負どちらでも同じなので正にそろえる
x = abs(x)

# 開始距離 >= 総移動量の場合
if x >= k * d:
    ans = x - k * d
# 開始距離 < 総移動量の場合
else:
    # 距離 < 移動量 となるまで移動
    cnt = x // d
    _k = k - cnt

    _x = x - d * cnt

    # この時点の原点からの距離と残移動回数
    # 現在位置のほうが原点に近くかつ残移動回数が偶数であれば戻ってこれるので答えは現在位置
    if _k % 2 == 0:
        ans = _x
    else:
        ans = abs(_x - d)

print(ans)


Measured memory_bytes: 9184
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())

A_c = copy.deepcopy(A)
A_c.sort()
for i in range(N):
    if A_c[-1] == A[i]:
        print(A_c[-2])
    else:
        print(A_c[-1])


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

int main()
{
	for (int i = 1; i < 10; i++)
	{
		for (int j = 1; j < 10; j++)
		{
			cout << i << "x" << j << "=" << i * j;
			cout << endl;
		}
	}

    return 0;
}



Measured memory_bytes: 3076
N = gets.to_i

a = gets.split(" ").map(&:to_i)

allEven = true

i = -1
while allEven do
  i += 1
  a.map!{|e|
    if e.even? then
      e = e / 2
    else
      allEven = false
      break
    end
  }
end

puts i

Measured memory_bytes: 1788
f=lambda:map(int,input().split())
n,d,a=f()
lt=sorted(tuple(f()) for _ in range(n))
from collections import *
q=deque()
c=s=0
for x,h in lt:
  while q and q[0][0]<x: s+=q.popleft()[1]
  h-=s
  if h>0: t=-h//a; c-=t; s-=t*a; q.append((x+d*2,t*a))
print(c)

Measured memory_bytes: 44628
#include <iostream>
#include <vector>
#include <string>

using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  bool ok = true;
  for(int i = 0; i < s.length(); ++i)
  {
    if(i&1)
      ok = ok && s[i] != 'R';
    else
      ok = ok && s[i] != 'L';
  }
  if(ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String []args){
	Scanner sc =new Scanner (System.in);
	int n = sc.nextInt();
	int all = cal(1000,1,1);
	for(int i = 0 ; i < n ; i++ ){
	    int year = sc.nextInt();
	    int month = sc.nextInt();
	    int day = sc.nextInt();
	    System.out.println(all - cal(year,month,day));
	}

    }
    static int cal(int year,int month,int date){
	int y = 1;
	int m = 1;
	int d = 1;
	int sum = 0;
	int monthDay;
	while(!(y ==  year && m ==  month && d == date)){
	    sum++;
	    if(y % 3 == 0){
		monthDay = 20;
	    }else if(m % 2 == 0){
		monthDay = 19;
	    }else{
		monthDay = 20;
	    }
	    
	    if(monthDay >  d){
		d++;
	    }else{
		d = 1;
		if(m < 10){
		    m++;
		}else{
		    m = 1;
		    y++;
		}
	    }
	}
	return sum;
    }
    
}

Measured memory_bytes: 20568
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,x,t;
	cin>>n>>x>>t;
	if(n%x==0)
		cout<<n/x*t<<endl;
	else
		cout<<(n/x+1)*t<<endl;
	return 0;
}


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

using namespace std;

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

  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  int cnt = 0;
  for (auto &c : s) {
    if (c == '-') cnt++;
    if (!(c == '-' || (c >= '0' && c <= '9'))) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << (s[a] == '-' && cnt == 1 ? "Yes" : "No") << endl;

  return 0;
}



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

int n,a,b,dig,tmp;
long long x,y;
vector<long long> ans;
int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  vector<int> d(n,0);
  int dan=1;
  for(int i=0;i<n;i++)
    {
      cin >> d[i];
    }
  sort(d.begin(),d.end(),greater<int>());
  for(int i=0;i<n-1;i++)
    {
      if(d[i]>d[i+1]) dan++;
    }
  cout << dan << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n, c = map(int, input().split())
    xv = [list(map(int, input().split())) for _ in range(n)]
    v, left_max, right_max = 0, 0, 0
    gl = [None]*n
    gr = [None]*n
    _2oas = [None]*(n+1)
    _2obs = [None]*(n+1)
    _2oas[0], _2obs[0] = 0, 0
    ans = 0
    for i, (xi, vi) in enumerate(xv):
        v += vi
        left = v - xi
        if left_max < left:
            left_max = left
        gl[i] = left_max
        _2oas[i+1] = v - 2*xi
    v = 0
    for i, (xi, vi) in enumerate(xv[::-1]):
        v += vi
        right = v - c + xi
        if right_max < right:
            right_max = right
        gr[i] = right_max
        _2obs[i+1] = v - 2*(c - xi)
    for i in range(1, n+1):
        oa = gl[-i]
        _2ob = _2obs[i-1]
        ob = gr[-i]
        _2oa = _2oas[i-1]
        ans = max(ans, _2oa+ob, _2ob+oa)
    print(ans)
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 71768
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  int count = 0;
  for(int i=0; i<N; i++){
    v.at(i) = i+1;
  }
  vector<int> w(N);
  for(int i=0; i<N; i++){
    while(v.at(i)%2 == 0){
      count++;
      v.at(i) /= 2;
    }
    
    w.at(i) = count;
    count = 0;
  }
  int ans = 0;
  int a = 0;
  for(int i=0; i<N; i++){
    if(a < w.at(i)){
      ans = i+1;
      a++;
    }
  }
  if(N == 1){
    ans = 1;
  }
    
  cout << ans << endl;
    
	
}

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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(X) (X).begin(), (X).end()
#define sz(X) (int)X.size()

using ll = long long;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

class DSU
{
private:
    vector<int> p, rk, sz;
    int num_disjoint_sets;
public:
    DSU(int n) : num_disjoint_sets(n)
    {
        rk.assign(n, 0), p.assign(n, 0), sz.assign(n, 1);
        for (int i = 0; i < n; ++i) p[i] = i;
    }
    int find_set(int i)
    {
        while (p[i] != i) i = p[i];
        return i;
    }
    int set_size(int i) { return sz[find_set(i)]; }
    int num_sets() const { return num_disjoint_sets; }
    void union_set(int i, int j)
    {
        int x = find_set(i), y = find_set(j);
        if (rk[x] < rk[y]) swap(x, y);
        if (x != y)
        {
            --num_disjoint_sets;
            p[y] = x;
            rk[x] += (rk[x] == rk[y]);
            sz[x] += sz[y];
        }
    }
};

int main()
{ _
    int n, m; cin >> n >> m;
    DSU dsu(n);
    for (int j = 0; j < m; ++j)
    {
        int a, b; cin >> a >> b; --a, --b;
        dsu.union_set(a, b);
    }
    int ans = dsu.num_sets() - 1;
    cout << ans << endl;
    exit(0);
}



Measured memory_bytes: 4832
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def f(g,b):
        left = bisect.bisect_left(g,j)
        right = bisect.bisect_left(b,j)
        res = left*(len(b)-right)
        for i in range(left):
            k = bisect.bisect_left(b,j2-g[i])
            if k < len(b) and b[k]+g[i] == j2:
                res -= 1
        return res
    n = I()
    s = input()
    r = []
    g = []
    b = []
    for i in range(n):
        if s[i] == "R":
            r.append(i)
        elif s[i] == "G":
            g.append(i)
        else:
            b.append(i)
    ans = 0
    for j in range(1,n-1):
        sj = s[j]
        j2 = 2*j
        if sj == "R":
            ans += f(g,b)+f(b,g)
        elif sj == "G":
            ans += f(r,b)+f(b,r)
        else:
            ans += f(r,g)+f(g,r)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 78736
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>

int main()
{
	int n, *east_sum, *west_sum, east, min = 3000000;
	bool *is_east, *is_west;
	scanf("%d", &n);

	east_sum = new int[n];
	west_sum = new int[n];
	is_east = new bool[n];
	is_west = new bool[n];
	for (int i = 0; i < n; ++i)
	{
		char tmp;
		scanf("%c", &tmp);
		
		if (tmp == '\n')
		{
			i--;
			continue;
		}
		is_east[i] = (tmp == 'E');
		is_west[i] = !(is_east[i]);
	}
	east_sum[0] = west_sum[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		east_sum[i] = east_sum[i - 1] + is_east[i - 1];
		west_sum[i] = west_sum[i - 1] + is_west[i - 1];
	}
	east = east_sum[n - 1] + is_east[n - 1];
	for (int i = 0; i < n; ++i)
	{
		int tmp = west_sum[i] + (east - east_sum[i]) - is_east[i];
		if (tmp < min)
			min = tmp;
	}

	printf("%d\n", min);

	delete[] east_sum;
	delete[] west_sum;
	delete[] is_east;
	delete[] is_west;
	return 0;
}

Measured memory_bytes: 3200
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int s1,s2;
	s1=a*b;s2=c*d;
	if(s1>=s2)
		cout << s1;
	else
		cout << s2;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int a[10010];
int grid[110][110];

int main(void)
{
    int H, W, N;
    scanf("%d%d%d", &H, &W, &N);
    for (int i = 1; i <= N; i++)
        scanf("%d", &a[i]);
    int col = 1;
    for (int i = 0; i < H; i++) {
        if (i % 2) {
            for (int j = 0; j < W; j++) {
                if (a[col] == 0) col++;
                if (a[col]) {
                    grid[i][j] = col;
                    a[col]--;
                }
            }
        }
        else {
            for (int j = W - 1; j >= 0; j--) {
                if (a[col] == 0) col++;
                if (a[col]) {
                    grid[i][j] = col;
                    a[col]--;
                }
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            printf("%d", grid[i][j]);
            if (j == W - 1) putchar('\n');
            else putchar(' ');
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  int k;
  cin>>k;
  string s="ACL";
  string s1="ACL";
  for(int i=0;i<k-1;i++)
    s1+=s;
  cout<<s1<<'\n';
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int k,n;
    cin>>k>>n;
    vector<int>a(n);
    //a.push_back(0);
    REP(i,n) cin>>a[i];
   // a.push_back(k);
    int ans = a[n - 1] - a[0];
    for (int i = 0; i <n; i++)
    {
        chmin(ans,k + a[(n-1+i)%n] - a[i]);
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#define ll long long

using namespace std;

int main(){

    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> vec(Q);

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

    vector<int> sum(N + 1,0);

    for(int i = 0;i < Q;i++){
        if((vec[i]-1) != 0){
            sum[0]--;
            sum[vec[i] - 1]++;
        }
        if(vec[i] != N){
            sum[N]++;
            sum[vec[i]]--;
        }
    }

    int sum1 = 0;

    for(int i = 0;i < N;i++){
        sum1+=sum[i];
        if(K + sum1 <= 0){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const long long MOD=998244353;
int main(){
    int n,k;scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++){int a;scanf("%d",&a);}
    printf("%d\n",(n-2)/(k-1)+1);
    return 0;
}

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

namespace CSharp
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine().Split().Select(int.Parse).ToArray();

			var N = input[0];
			var K = input[1];
			

			var H = new int[N];

			for (var i = 0; i < N; i++)
			{
				H[i] = Console.ReadLine().Split().Select(int.Parse).ToArray()[0];
			}
			
			Array.Sort(H);
	
			var min = H[K -1] - H[0];
			for (var i = 0; i + K -1 < N; i++)
			{
				min = Math.Min(min, H[i + K -1] - H[i]);
			}
			Console.WriteLine(min);
		}
	}
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, h, w;
string s;
Vi dir = {1, 0, -1, 0, 1};

int main() {
    cin >> h >> w;

    Vs s(h);
    REP(i, h) cin >> s[i];

    VVi dis(h, Vi(w, -1));
    queue<Pii> q;
    q.push({0, 0});
    dis[0][0] = 1;
    while (!q.empty()) {
        int y = q.front().first, x = q.front().second;
        q.pop();
        REP(i, 4) {
            int Y = y + dir[i], X = x + dir[i+1];
            if (Y < 0 || X < 0 || Y >= h || X >= w) continue;
            if (dis[Y][X] != -1) continue;
            if (s[Y][X] == '#') continue;
            dis[Y][X] = dis[y][x] + 1;
            q.push({Y, X});
        }
    }

    int cnt = 0;
    REP(i, h) REP(j, w) {
        if (s[i][j] == '.') {
            cnt++;
        }
    }
    if (dis[h-1][w-1] == -1) {
        std::cout << -1 << '\n';
    } else {
        std::cout << cnt - dis[h-1][w-1] << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
A = input().split()
A = [ int(x) for x in A]
R = input().split()
R = [ int(x) for x in R]

N = A[0]
M = A[1]
X = A[2]
little = 0
large = 0

for i in range(M):
    if X > R[i]:
        little += 1
    else:
        large += 1

if little > large:
    ans = large
else:
    ans = little
    
print(ans)

Measured memory_bytes: 3064
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {

    static class Pair {
        int left;
        int right;

        public Pair(int left, int right) {
            this.left = left;
            this.right = right;
        }
    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int count = std.nextInt();
        Deque<Pair> deque = new ArrayDeque<>();

        List<Deque<Pair>> xs = IntStream
                .range(0, count)
                .mapToObj(it -> {
                    Stream<Pair> stream = IntStream
                        .range(0, count - 1)
                        .mapToObj(n -> new Pair(it, std.nextInt() - 1));
                  List<Pair> list = stream.collect(Collectors.toList());
                        return new ArrayDeque<Pair>(list);
                })
                .collect(Collectors.toList());

        Function<Integer, Boolean> check = index -> {
            Deque<Pair> targetMatches = xs.get(index);
            if (targetMatches.isEmpty()) {
                return false;
            }
            int opponentIndex = targetMatches.getFirst().right;
            Deque<Pair> opponent = xs.get(opponentIndex);
            if (opponent.isEmpty()) {
                return false;
            }

            Pair first = opponent.getFirst();
            if (first.right == index) {
                // same user
                Pair p = new Pair(first.left, first.right);
                if (p.right < p.left) {
                    int l = p.left;
                    p.left = p.right;
                    p.right = l;
                }
                if (deque.isEmpty()) {
                    deque.add(p);
                } else {
                    boolean contains = false;
                    for (Pair pair : deque) {
                        if (pair.left == p.left && pair.right == p.right) {
                            contains = true;
                            break;
                        }
                    }

                    if (!contains) {
                        deque.add(p);
                    }
                }
            }

            return true;
        };

        IntStream.range(0, count).forEach(check::apply);
        int days = 0;
        while (!deque.isEmpty()) {
            days++;
            Deque<Pair> prevDeque = new ArrayDeque<>(deque);

            deque.clear();
            for (Pair p : prevDeque) {
                xs.get(p.left).pollFirst();
                xs.get(p.right).pollFirst();
            }

            for (Pair p : prevDeque) {
                check.apply(p.left);
                check.apply(p.right);
            }
        }

        long rest = xs.stream().filter(it -> !it.isEmpty()).count();
        if (rest != 0) {
            System.out.println(-1);
        } else {
            System.out.println(days);
        }
    }
}


Measured memory_bytes: 304792
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL INF = 1LL << 30;
int n;
LL res, ans;
int main() {
	scanf("%d", &n);
	ans = INF;
	for(int i = 1; i <= n; i++) {
		LL a, b;
		scanf("%lld %lld", &a, &b);
		if(a > b)ans = min(ans, b);
		res += a;
	}
	if(ans == INF)printf("0\n");
	else printf("%lld\n", res - ans);
	return 0;
}

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

int main() {
    int n; cin >> n;
    long long a;
    long long total = 0;
    long long cost = LLONG_MAX;
    vector<long long> v;
    for(int i = 0; i < n; i++){
        cin >> a;
        v.push_back(a);
        total += a;
    }
    long long l = 0;
    long long r = 0;
    for(int j = 0; j < n-1; j++){
        l += v[j];
        r = total - l;
        if(r != l){ 
            cost = min(cost,abs(r-l));
        } else{ 
            cost = 0;
        }
    }
    cout << cost << endl;
	return 0;
}

Measured memory_bytes: 2420
e=enumerate
n,*a=map(int,open(0).read().split())
dp=[0]
for j,(a,i)in e(sorted((a,i)for i,a in e(a))[::-1]):dp=[dp[0]+a*abs(n-j-i-1)]+[max(dp[k]+a*abs(n-j+k-i-1),dp[k-1]+a*abs(i-k+1))for k in range(1,j+1)]+[dp[j]+a*abs(i-j)]
print(max(dp))

Measured memory_bytes: 74620
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>

using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
	int n;cin>>n;
	string s, t;cin>>s>>t;
	int ans=int(s.size()+t.size());
	for(int i=0;i<n;i++){
		string tmp = s.substr(i, n-i);
		bool match=true;
		for(int j=0;j<n-i;j++){
			if(t[j]!=tmp[j]){match=false;break;}
		}
		if(match){ans=int(t.size())+i;break;}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = replicateM 2 readInt >>= print . f . mp . sort

f ( 1, 2 ) = 3
f ( 1, 3 ) = 2
f ( 2, 3 ) = 1
f _ = undefined

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
//#include <fstream>

#define ll long long int
using namespace std;

void Solve()
{
    //cout << "Case " << t << ": ";
    set<int>p;
    int n, x;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> x;
        p.insert(x);
    }
    if(p.size() == n) cout << "YES";
    else cout << "NO";
}

int main()
{
    //ios_base::sync_with_stdio( false );
    //cin.tie( nullptr );
    //freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
    int t;
    //cin >> t;
    //for(int i=1; i<=t; i++)
    {
        Solve();
        cout << '\n';
    }
    return 0;
}


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

using ll = long long;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

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

int main(){
    int S;
    cin >> S;
    int mo = 1000000007;
    VV<ll> dp(667, V<ll>(1998));
    rep(i, 1998) dp.at(1).at(i) = i+1;
    rep2(i, 2, 667){
        dp.at(i).at(0) = 1;
        rep2(j, 1, 1998){ 
            dp.at(i).at(j) = (dp.at(i-1).at(j) + dp.at(i).at(j-1)) % mo;
        }
    }
    ll sum = 0;
    rep2(i, 1, S / 3 + 1){
        sum += dp.at(i).at(S - 3 * i);
        sum += mo;
        if(S - 3 * i > 0) sum -= dp.at(i).at(S - 3 * i - 1);
        sum %= mo;
    }

    cout << sum << endl;

}

Measured memory_bytes: 13816
#include<iostream>
using namespace std;
long N;
long A[200000],B[200000],dif[200000];

int main(){
  cin >> N;
  for (long i=1;i<=N;i++)cin >> A[i];
  for (long i=1;i<=N;i++)cin >> B[i];
  for (long i=1;i<=N;i++)dif[i]=A[i]-B[i];
  sort(dif+1,dif+N+1);
  long sum=0;
  long ans = 0;
  for (long i=1;i<=N;i++){
    if (dif[i]>=0)break;
    else sum-=dif[i];
    ans++;
  }
  if (sum==0){cout << 0 << endl; return 0;}
  long sum2=0;
  for (long i=N;i>=1;i--){
    if (dif[i]<=0)break;
    sum2+=dif[i];ans++;
    if (sum2>=sum){cout << ans << endl; return 0;}
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

ll dp[100010];

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll h(n);
    rep(i, n){
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    repr(i, 2, n){
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#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(){
    ll a, b , c, d;
    cin >> a >> b >> c >> d;

    ll a_count;
    ll t_count;
    if(a%d==0){
        a_count=a/d;
    }else{
        a_count=a/d+1;
    }

    if(c%b==0){
        t_count=c/b;
    }else{
        t_count=c/b+1;
    }

    if(t_count<=a_count){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  int k=s.size();
  vector<char> MY={'2'};
  int count=0;
  for(int i=k-1;i>=0;i--){
    if(s.at(i)=='B'){
      count++;
    }
    if(s.at(i)=='1'){
      if(count==0){
        MY.push_back('1');
      }
      else count--;
    }
    if(s.at(i)=='0'){
      if(count==0){
        MY.push_back('0');
      }
      else count--;
    }
  }
  string ans="";
  for(int i=MY.size()-1;i>=1;i--){
    ans+=MY.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int W = 0;
    int H = 0;
    int x = 0;
    int y = 0;
    int r = 0;
    
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    
    if((x-r < 0) || (x + r) > W){
        printf("No\n");
    }else if((y-r < 0) || (y+r) > H){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
 
    return 0;
}


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

int main()
{
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    vector<vector<ll>> dp(S.size(), vector<ll>(13, 0));
    if (S[0] == '?')
        rep(i, 10) dp[0][i]++;
    else
        dp[0][int(S[0] - '0')]++;
    int mods[] = {1, 10, 9, 12, 3, 4};
    auto shift = [&](int n, int k) {
        int mod = n * mods[k % 6];
        rep(j, 13) dp[k][(j + mod) % 13] += dp[k - 1][j];
        rep(i, 13) dp[k][i] %= ll(1e9 + 7);
    };
    for (int i = 1; i < S.size(); i++)
    {
        if (S[i] == '?')
        {
            rep(j, 10)
            {
                shift(j, i);
            }
        }
        else
        {
            shift(int(S[i] - '0'), i);
        }
    }
    cout << dp[S.size() - 1][5] << endl;
    return 0;
}


Measured memory_bytes: 15616
#include <stdio.h>

int sort(long *vlist,int *plist,int *qlist,int n){
  int i,j,k,l,m,s=0,p;
  for(i=0;i<n;i++){
    plist[i]=-1;
    qlist[i]=i+1;
  }
  qlist[n-1]=-1;
  while(qlist[s]!=-1){
    i=s;
    p=-1;
    while(i!=-1){
      j=i;
      k=qlist[j];
      if(k==-1) break;
      i=qlist[k];
      if(vlist[j]<vlist[k]){
        if(p==-1){
          s=k;
        }else{
          qlist[p]=k;
        }
        l=j;
        j=k;
        k=l;
      }
      qlist[j]=i;
      p=j;
      while(k!=-1){
        if((j==-1)|(vlist[j]<vlist[k])){
          l=plist[k];
          plist[k]=plist[m];
          plist[m]=k;
          m=k;
          k=l;
        }else{
          m=j;
          j=plist[m];
        }
      }
    }
  }
  return(s);
} 

int main(){
  int n,i,k,p[100005],q[100005],c[26];
  long m,j,l[100005],a;
  char s[11];
  for(i=0;i<26;i++){
    c[i]=0;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",&s);
    l[i]=0;
    k=0;
    for(j=0;j<10;j++){
      c[s[j]-'a']++;
    }
    for(j=0;j<26;j++){
      for(;c[j]>0;c[j]--){
        l[i]|=j<<k;
        k+=5;
      }
    }
  }
  a=0;
  j=0;
  m=0;
  for(i=sort(&l,&p,&q,n);i!=-1;i=p[i]){
    if(a==l[i]){
      j++;
    }else{
      m+=(j*(j+1))>>1;
      j=0;
    }
    a=l[i];
  }
  m+=(j*(j+1))>>1;
  printf("%ld",m);
  return(0);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[52],b[52];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j){
				continue;
			}
			ll sum=0;
			ll nowx=a[j]-a[i];
			ll nowy=b[j]-b[i];
			for(int k=0;k<n;k++){
				for(int l=0;l<n;l++){
					if(k==l){
						continue;
					}
					ll nex=a[l]-a[k];
					ll ney=b[l]-b[k];
					if(nowx==nex&&nowy==ney){
						sum++;
					}
				}
			}
			ans=max(ans,sum);
		}
	}
	cout << n-ans;
	// your code goes here
	return 0;
}

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

int main(){
  while(true) {
    int n, x, ans = 0;
    cin >> n >> x;
    if(!n && !x) {
      break;
    }
    int i, j, k;
    for(i = 1; i <= n; ++i) {
      for(j = 1; j <= n; ++j) {
        for(k = 1; k <= n; ++k) {
          if((i != j) && (j != k) && (i != k)){
            if((i < j) && (j < k)) {
              if(i + j + k == x) {
                //cout << i << j << k << endl;
                ans++;
              }
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(ll i = 0; i<n; i++)
#define rep_s(i, start, n) for(ll i= start;  i<n; i++)
#define rep_down(i, n) for(ll i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(ll i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()
#define print(ans) cout << ans << endl;
#define MOD 1000000007
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll keta_num(ll num){
  ll total = 0;
  while(num){
    num /= 10;
    total++;
  }
}


ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

ll fibonacchi(ll num){
  ll f0 = 0, f1 = 1, f2;
  ll count = 0;
  while(count<num){
    f2 = f0+f1;
    f0 = f1;
    f1 = f2;
    count++;
  }
  return f2;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, G, K,L, W, H, P, Q, R, V, X, Y;
  string S, T;
  cin >> N >> K;
  ll count = 0;
  while(N!=0){
    N/= K;
    count++;
  }
  cout << count << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  vll ans(n);
  rep(i,n){
    if(i%2==0){
      ans[0]+=a[i];
    }
    else{
      ans[0]-=a[i];
    }
  }
  for(int i=1;i<n;i++){
    ans[i]=(a[i-1]-ans[i-1]/2)*2;
  }
  rep(i,n){
    cout<<ans[i]<<" ";
  }
}

Measured memory_bytes: 2816
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;


int main(void)
{
	int N; cin >> N;
	vector<lli> A(N), B(N), C(N);
	rep(i, 0, N)cin >> A[i]; sort(A.begin(), A.end()); 
	rep(i, 0, N)cin >> B[i]; sort(B.begin(), B.end()); 
	rep(i, 0, N)cin >> C[i]; sort(C.begin(), C.end()); 

	lli ans = 0;
	
	rep(i,0,N) {
		vector<lli>::iterator Iter1 = lower_bound(A.begin(), A.end(), B[i]);
		vector<lli>::iterator Iter2 = upper_bound(C.begin(), C.end(), B[i]);
		lli k1 = Iter1 - A.begin();
		lli k2 = C.end() - Iter2;
		ans += k1 * k2;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
string S;

int main(){
	cin >> S;

	int N=S.size();

	vector<pair<int, int> > rl;
	vector<int> rlidx;
	pair<int, int> cur = {1, 0};
	for(int i=1; i<N; i++){
		if(S[i-1]=='R'){
			if(S[i]=='R') cur.first++;
			else{
				cur.second++;
				rlidx.push_back(i);
			}
		} else {
			if(S[i]=='R'){
				rl.push_back(cur);
				cur = {1, 0};
			} else cur.second++;
		}
	}
	rl.push_back(cur);

	vector<int> ans(N);
	for(int i=0; i<rl.size(); i++){
		ans[rlidx[i]-1] = (rl[i].first+1)/2 + rl[i].second/2;
		ans[rlidx[i]] = rl[i].first/2 + (rl[i].second+1)/2;
	}

	for(int i=0; i<N; i++){
		cout << ans[i] << (i==N-1?'\n':' ');
	}

	return 0;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x%mod;
    }
    x=x*x%mod;
    n>>=1;
  }
  return ans;
}

vec tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

ll comb(ll n, ll k) {
  return tfact.at(n)*mpow(tfact.at(k),mod-2)%mod*mpow(tfact.at(n-k),mod-2)%mod;
}

int main() {
  ll n,m,k;
  cin >> n >> m >> k;
  ll ans=0;
  fact(n*m);
  for(ll i=1;i<n;i++) {
    (ans+=i*(n-i)%mod*m%mod*m%mod*comb(n*m-2,k-2)%mod)%=mod;
  }
  for(ll i=1;i<m;i++) {
    (ans+=i*(m-i)%mod*n%mod*n%mod*comb(n*m-2,k-2)%mod)%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 78464
f1=False
f2=False
f3=True
s = list(input())
if s[0]=='A':
  f1=True
if s[1].isupper():
  f3=False
for i in s[2:-1]:
  if f3==False:
    break
  if i=='C':
    if f2==True:
      f3=False
    else:
      f2=True
  elif i.isupper():
    f3=False
if s[-1].isupper():
    f3=False
if f1 and f2 and f3:
  s='AC'
else:
  s='WA'
print(s)


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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  char c; cin >> c;
  if(c >= 'A' and c <= 'Z') cout << 'A';
  else cout << 'a';
}


#define GOOGLE 0
#define MULTIPLE_TC 0

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL); 

  pre();

  int t = 1, T;
  if(MULTIPLE_TC)
    cin >> t;

  for(T = 1; T <= t; T++){
    if(GOOGLE)
      cout << "Case #" << T << ": ";
    solve();
  }

  ktj();
}

Measured memory_bytes: 3840
#include <iostream>

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  if(((a == b) && (a != c)) ||
    ((a == c) && (a != b)) ||
    ((b == c) && (b != a)))
    std::cout << "Yes";
  else
    std::cout << "No";
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main() {
	string S; cin >> S;
	bool f = S[2] == S[3] && S[4] == S[5];
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

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

int main() {
  int x,y;
  cin >> x >> y;
  int a=0,b=0;
  if(x==1&&y==1){
    cout << 1000000 << endl;
  }else{
    if(x<4){
      a=100000*(4-x);
    }
    if(y<4){
      b=100000*(4-y);
    }
    cout << a+b << endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if (m1 == m2) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
	return 0;
}



Measured memory_bytes: 3620
import heapq

X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

heap = []
item = (0,(0,0,0))
max_score = A[0] + B[0] + C[0]
xyzset = set(item[1])
answer = []

heapq.heappush(heap,item)

while len(answer) < K:
    score,(x,y,z) = heapq.heappop(heap)
    answer.append(max_score - score)

    if x != X-1 and (x+1,y,z) not in xyzset:
        heapq.heappush(heap,(max_score - A[x+1] - B[y] - C[z],(x+1,y,z)))
        xyzset.add((x+1,y,z))

    if y != Y-1 and (x,y+1,z) not in xyzset:
        heapq.heappush(heap,(max_score - A[x] - B[y+1] - C[z],(x,y+1,z)))
        xyzset.add((x,y+1,z))

    if z != Z-1 and (x,y,z+1) not in xyzset:
        heapq.heappush(heap,(max_score - A[x] - B[y] - C[z+1],(x,y,z+1)))
        xyzset.add((x,y,z+1))
    
for x in answer:
    print(x)

Measured memory_bytes: 5232
#include <stdio.h>

// 入力受付用の変数
#define BUF 200002
char str[BUF];

// 入力された値
int L, R;

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d", &L, &R);
}

void solve() {
	int ans = 2019;
	const int C = 2019;

	if (R - L <= C) {
		for (size_t i = L; i <= R; i++) {
			for (size_t j = i+1; j <= R; j++) {
				int temp = (i % C) * (j % C);
				temp %= C;
				ans = ans < temp ? ans : temp;
			}
		}
	} else {
		for (size_t i = L; i <= L + C + 1; i++) {
			for (size_t j = i+1; j <= L + C + 1; j++) {
				int temp = (i % C) * (j % C);
				temp %= C;
				ans = ans < temp ? ans : temp;
			}
		}
	}


	printf("%d\n", ans);
}

int main(void) {
	receive_input();

	solve();

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  string s;
  cin >> s;
  bool flag = true;
  for (int i = 0; i < s.size(); i++) {
    if (i%2 == 0) {
      if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) {
        flag = false;
      }
    }
    else {
      if (!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) {
        flag = false;
      }
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
int N;
  cin >>N;
  if(N==25){
    cout <<"Christmas";
  }
  else if(N==24){
    cout <<"Christmas Eve";
  }
  else if(N==23){
    cout <<"Christmas Eve Eve";
  }
  else if(N==22){
    cout <<"Christmas Eve Eve Eve";
  }
  
    

}


Measured memory_bytes: 256
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> inline void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> inline void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; return ; } return ; }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; return ; } return ; }

const long long INF = 1LL<<60;

int main() {
    int x, n;
    cin >> x >> n;
    set<int> st;
    rep(i, n) {
        ll c;
        cin >> c;
        st.insert(c);
    }

    int ans = 0;
    rep(i, 102) {
        if(st.find(i) != st.end()) continue;
        if(abs(x-ans)>abs(x-i)) ans = i;
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 3624