akhauriyash/Code-Regression huggingface dataset:
local t1, t2 = io.read("*n", "*n")
local a1, a2 = io.read("*n", "*n")
local b1, b2 = io.read("*n", "*n")
if a1 < b1 then
  a1, b1 = b1, a1
  a2, b2 = b2, a2
end
local c1, c2 = a1 - b1, a2 - b2
if c1 * t1 + c2 * t2 == 0 then
  print("infinity")
else
  local red = c1 * t1 + c2 * t2
  if 0 < red then
    print(0)
  else
    red = -red
    if (c1 * t1) % red == 0 then
      local z = math.floor((c1 * t1) / red)
      print(z * 2)
    else
      local z = math.ceil((c1 * t1) / red)
      print(z * 2 - 1)
    end
  end
end


Measured memory_bytes: 760
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a;
    double b;
    cin >> a >> b;
    ll c = b*100+0.5;
    ll ans = (a*c)/100;
    PRINT(ans);
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var s = Read();
            var ans = new List<char>();

            foreach (var a in s)
            {
                if (a == '0')
                {
                    ans.Add(a);
                }

                if (a == '1')
                {
                    ans.Add(a);
                }

                if (a == 'B' && ans.Count > 0)
                {
                    ans.RemoveAt(ans.Count-1);
                }
            }
            Println(string.Join("", ans));
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();

        static void Print(object value = null) => Console.Write(value.ToString());
        static void Println(object value = null) => Console.WriteLine(value.ToString());
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

int main(){
    int n;
    std::cin >> n;
    std::vector<int> num(100000);
    long long int sum = 0;
    for (int i = 0; i < n; i++)
    {
        int a;
        std::cin >> a;
        sum += a;
        num[a]++;
    }

    int q = 0;
    std::cin >> q;
    for (int i = 0; i < q; i++)
    {
        int b, c;
        std::cin >> b >> c;
        sum += (c - b) * num[b];
        num[c] += num[b];
        num[b] = 0;
        std::cout << sum << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3756
#include <algorithm>
#include <cstdio>
#include <functional>

using std::greater;
using std::max;
using std::min;
using std::sort;

const int MAXN=2e5+5;
int n;
long long K;
int A[MAXN],F[MAXN];

inline bool judge(long long lim){
	long long k=K;
	for(int i=1;i<=n;++i){
		int dta=A[i]-min((long long)A[i],lim/F[i]);
		if(k<dta) return false;
		k-=dta;
	}
	return true;
}

inline long long binary_search(){
	sort(A+1,A+n+1);
	sort(F+1,F+n+1,greater<int>());
	long long l=0,r=0;
	for(int i=1;i<=n;++i)
		r=max(r,(long long)A[i]*F[i]);
	while(l<=r){
		long long mid=l+r>>1;
		if(judge(mid)) r=mid-1;
		else l=mid+1;
	}
	return l;
}

int main(){
	scanf("%d%lld",&n,&K);
	for(int i=1;i<=n;++i)
		scanf("%d",&A[i]);
	for(int i=1;i<=n;++i)
		scanf("%d",&F[i]);
	printf("%lld",binary_search());
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main () {
	int n;
	cin >> n;
	int mat[n+1][3] = {0};
	long long dp[n+1][3] = {0}, ans = 0;
	
	
	for (int i=1; i<=n; i++){
		for (int j=0; j<3; j++){
			cin >> mat[i][j];
		}
	}
	
	for (int i=1; i<=n; i++){
		for (int j=0; j<3; j++){
			if (j == 0){
				dp[i][j] = max(dp[i-1][j+1], dp[i-1][j+2]) + mat[i][j];
			}
			if (j == 1){
				dp[i][j] = max(dp[i-1][j-1], dp[i-1][j+1]) + mat[i][j];
			}
			if (j == 2){
				dp[i][j] = max(dp[i-1][j-2], dp[i-1][j-1]) + mat[i][j];
			}
			ans = max(ans, dp[i][j]);
		}
	}
	
	cout << ans;
return 0;
}



Measured memory_bytes: 3712
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
//ll N,W;
 //ll dp[1000000001];
int main(){
   ll k;
   cin>>k;
   vector<ll> v(50);

   ll c = k/50;
   rep(i,51) {
       v[i] = i+c;
   }

   ll x = 50 - k%50;
    cout<<50<<endl;
   rep(i,51){
       if(i!=x) {
           cout << v[i] << " ";
       }
   }


   cout<<endl;


    
return 0;
}


Measured memory_bytes: 256
n,x=map(int, input().split(' '))
l = list(map(int, input().split(' ')))

d = [0]*(n+1)
ans = 0

for i in range(0, n+1):
  if i == 0:
    d[i] = 0
  else:
    d[i] = d[i-1] + l[i-1]

  if d[i] <= x:
    ans += 1

print(ans)

Measured memory_bytes: 3064
n = int(input())
p = list(map(int, input().split()))
c =0
for i in range(1,n-1):
    if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i+1] < p[i] and p[i] < p[i-1]):
        c+=1
print(c)

Measured memory_bytes: 3060
import collections
n=int(input())
a=[int(i) for i in input().split()]
def is_even(n):
    if(n%2==0):
        even=True
    else:
        even=False
    return even

c = collections.Counter(a)
ans=1
if(is_even(n)==True):
    for num,count in c.items():
        if(is_even(num)==True):
            print(0)
            exit()
        if(count>=3):
            print(0)
            exit()
        ans*=2
else:
    for num,count in c.items():
        if(is_even(num)==False):
            print(0)
            exit()
        if(count>=3):
            print(0)
            exit()
        if(count>=2 and num==0):
            print(0)
            exit()
        if(num!=0):
            ans*=2
print(ans%(10**9+7))







Measured memory_bytes: 14820
S=input()
flag=0
if (S.startswith("k") and S.endswith("eyence")) or \
(S.startswith("ke") and S.endswith("yence")) or \
(S.startswith("key") and S.endswith("ence")) or \
(S.startswith("keye") and S.endswith("nce")) or \
(S.startswith("keyen") and S.endswith("ce")) or \
(S.startswith("keyenc") and S.endswith("e")) or \
("keyence" in S):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    for(int i = 0; i < Math.min(k, 50); i++) {
      int[] rui = new int[n];
      for(int j = 0; j < n; j++) {
        int s = j - a[j];
        int t = j + a[j] + 1;
        if(s >= 0) {
          rui[s]++;
        } else {
          rui[0]++;
        }
        if(t >= n) {
          
        } else {
          rui[t]--;
        }
      }
      for(int j = 1; j < n; j++) {
        rui[j] += rui[j - 1];  
      }
      a = rui;
    }
    for(int i = 0; i < n; i++) {
      System.out.print(a[i]);
      System.out.print(" ");
    }
  }
}

Measured memory_bytes: 62408
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;

struct data {
  ll index, h, p;

public:
  bool operator<(const data d) const { return p + h < d.p + d.h; }
};

ll N;
data D[5000];

int main(void) {
  cin >> N;
  REP(i, 0, N) {
    D[i].index = i;
    cin >> D[i].h >> D[i].p;
  }

  sort(D, D + N);

  /* dp[i + 1][j]: i番目までの人が参加してj人が積んだ場合の高さの最小値
   * dp[i + 1][j + 1] = min(dp[0][j], dp[1][j], dp[2][j], ..., dp[i][j])
   */
  vector< vector<ll> > dp(N + 1, vector<ll>(N + 1, INF));
  dp[0][0] = 0;

  REP(i, 0, N) for(ll j = i + 1; j >= 0; j--) {
    ll h1 = j >= 1 ? dp[i][j - 1] : INF;
    ll h2 = dp[i][j];
    dp[i + 1][j] = h1 <= D[i].h ? min(h1 + D[i].p, h2) : h2;
  }

  ll ans = 0;
  REP(i, 0, N + 1) if(dp[N][i] != INF) ans = i;
  cout << ans << endl;
}


Measured memory_bytes: 195968
n, m = gets.chomp.split(' ').map(&:to_i)
arr = []
m.times do
  arr << gets.chomp.split(' ').map(&:to_i)
end
arr.sort_by! { |i| i[1] }
pivot = arr[0]
count = 1
(1...m).each do |i|
  if arr[i][0] >= pivot[1]
    count += 1
    pivot = arr[i]
  end
end
puts count

## 他の方のコードを備忘録として提出させていただきます

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

int main(){
    string a, b,c;
    cin>>a>>b;
    for(int i=0;i<a.size()+b.size();i++){
        if(i%2==0){
            c[i]=a[i/2];
        }
        else{
             c[i]=b[i/2];
        }
    }
    for(int i=0;i<a.size()+b.size();i++){
        cout<<c[i]<<flush;
    }
    cout<<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(){
	ll a,b,c,d;
	cin >> a >> b >> c >>d;
	ll ans = max(a*c,max(a*d,max(b*c,b*d)));
	cout << ans << endl;


}

// cout << fixed << setprecision(15) <<  << endl;

Measured memory_bytes: 3632
N,M,C=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
n=0
for i in range(N):
  Ai = list(map(int, input().strip().split(' ')))
  S = C
  j = 0
  while j < M:
    S += Ai[j]*B[j]
    j += 1
  if S > 0 : n += 1
print(n)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <cmath>
using namespace std;

int N, A[3], B[8], minx = (1 << 30);

int hantei(vector<int>D) {
	int ret = (1 << 30);
	for (int i = 0; i < D.size(); i++) {
		for (int j = 0; j < D.size(); j++) {
			for (int k = 0; k < D.size(); k++) {
				if (i == j || i == k || j == k) continue;

				int Z = abs(A[0] - D[i]) + abs(A[1] - D[j]) + abs(A[2] - D[k]);
				ret = min(ret, Z);
			}
		}
	}
	return ret;
}

void solve(vector<int>T) {
	minx = min(minx, hantei(T) + 10 * (int)(N - T.size()));
	if (T.size() <= 3) return;

	for (int i = 0; i < T.size(); i++) {
		for (int j = i + 1; j < T.size(); j++) {
			vector<int>I;
			for (int k = 0; k < T.size(); k++) {
				if (i == k || j == k) continue;
				I.push_back(T[k]);
			}
			I.push_back(T[i] + T[j]);

			solve(I);
		}
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < 3; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	vector<int>L; for (int i = 0; i < N; i++) L.push_back(B[i]);

	solve(L);
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PB push_back
using namespace std;
const LL mod = 1000 * 1000 * 1000 + 7;
const LL ob = (mod + 1) >> 1;
set<pair<int , int> > ye;
set<pair<int , int> > toCheck;
LL ans[10];
int main()
{
	ios_base::sync_with_stdio(0);
	int h , w , n;
	cin >> h >> w >> n;
	for(int i = 0; i < n; i++)
	{
		int x , y;
		cin >> x >> y;
		ye.insert({x , y});
		for(int i = max(1 , x - 2); i <= min(h - 2 , x); i++)
			for(int j = max(1 , y - 2); j <= min(w - 2 , y); j++)
			{
				toCheck.insert({i , j});
			}
	}
	LL all = (h - 2) * (LL)(w - 2);
	for(auto x : toCheck)
	{
		//cout << x.first << " " << x.second << endl;
		int cnt = 0;
		for(int X = x.first; X <= x.first + 2; X++)	
		{
			for(int Y = x.second; Y <= x.second + 2; Y++)
				cnt += ye.count({X , Y});
		}
		ans[cnt]++;
		all--;
	}
	ans[0] = all;
	for(int i = 0; i < 10; i++)
	{
		cout << ans[i] << endl;
	}
}




Measured memory_bytes: 47104
#include<bits/stdc++.h>
using namespace std;
const int N(111111);
vector<int> adj[N];
int dep[N], ans[N];
int main() {
	int n;
	cin >> n;
	for(int i(2); i <= n; i++) {
		int x;
		cin >> x;
		adj[x].push_back(i);
	}
	vector<int> q;
	q.push_back(1);
	for(int op(0); op < (int)q.size(); op++) {
		int v(q[op]);
		for(int p(0); p < (int)adj[v].size(); p++) {
			int y(adj[v][p]);
			dep[y] = dep[v] + 1;
			q.push_back(y);
		}
	}

	for(int i(n - 1); i >= 0; i--) {
		int v(q[i]);
		vector<int> vec;
		for(int j(0); j < (int)adj[v].size(); j++) {
			vec.push_back(ans[adj[v][j]]);
		}
		sort(vec.begin(), vec.end());
		for(int j((int)vec.size() - 1); j >= 0; j--) {
			ans[v] = max(ans[v], vec[j] + (int)vec.size() - j);
		}
	}
	cout << ans[1] << endl;
}


Measured memory_bytes: 7284
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,v,p,a[100001],ans,a1;
bool cmp(int i,int j){return i>j;}
signed main()
{
	scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
	ans=p;
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+n+1,cmp);
	for(int i=p+1;i<=n;i++)
	{
		if(a[i]+m<a[p])break;
		if(v<=p+n-i)++ans;
		else if(((v-p-n+i)*m-a1-1)/(i-p)+1+a[p]<=a[i]+m)++ans;
		a1+=a[p]-a[i];
	}
	printf("%lld",ans);
	return 0;
 } 

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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  vector<vector<int>> ch(26);
  for (int i = 0; i < N; i++) {
    ch[s[i]-'a'].push_back(i);
  }
  int ans = N;
  for (auto v : ch) {
    int k = v.size();
    if (k == 0) continue;
    int d = max(v[0],N-1-v[k-1]);
    for (int i = 0; i < k; i++) d = max(v[i]-v[i-1]-1,d);
    ans = min(ans,d);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
L X[]={0,1,1,1,0,-1,-1,-1};
L Y[]={1,1,0,-1,-1,-1,0,1};
L h,w,mark[51][51],c=0;
L grid[51][51];
void call(L x,L y){
    mark[x][y]=1;
    for(L i=0;i<8;i++){
        L xx=X[i]+x,yy=Y[i]+y;
        if((xx>=0&&xx<h &&yy >=0&&yy<w) && grid[xx][yy] &&mark[xx][yy]==0){
            call(xx,yy);
        }
    }
}
int main()
{
    while(scanf("%lld%lld",&w,&h)&& w||h ){
        for(L i=0;i<h;i++){
            for(L j=0;j<w;j++)scanf("%lld",&grid[i][j]);
        }
        for(L i=0;i<h;i++){
            for(L j=0;j<w;j++){
                if(!mark[i][j] && grid[i][j]){
                    c++;
                    call(i,j);
                }
            }
        }
        printf("%lld\n",c);c=0;
        memset(mark,0,sizeof(mark));
    }
    return 0;
}



Measured memory_bytes: 3296
from itertools import permutations
 
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
 
def count(x):
    i = 0
    for perm in permutations(range(1, n+1)):
        if perm == x:
            return i
        i += 1
 
print(abs(count(p) - count(q)))

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long T, long long X){
    printf("%.9f\n", (double)T / (double)X);
}

int main(){
    long long T;
    scanf("%lld",&T);
    long long X;
    scanf("%lld",&X);
    solve(T, X);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A,B,C; cin >> A>>B>>C;
    int a,b,c;
    int lena,lenb,lenc;
    a = -1; b = -1; c = -1;
    lena = A.length();
    lenb = B.length();
    lenc = C.length();
    char next = 'a';
    while(1){
        if(next == 'a'){
            a++;
            if(a == lena){
                cout << "A" << endl;
                return 0;
            }
            if(A[a] == 'a') next = 'a';
            else if(A[a] == 'b') next = 'b';
            else next = 'c';

        }
        else if (next == 'b'){
            b++;
            if(b == lenb){
                cout << "B" << endl;
                return 0;
            }
            if(B[b] == 'a') next = 'a';
            else if(B[b] == 'b') next = 'b';
            else next = 'c';

        }
        else{
            c++;
            if(c == lenc){
                cout << "C" << endl;
                return 0;
            }
            if(C[c] == 'a') next = 'a';
            else if(C[c] == 'b') next = 'b';
            else next = 'c';


        }
    }


}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

template <class T>
struct fenwick_tree {
  vector<T> x;
  fenwick_tree(int n) : x(n + 1) {}
  void add(int k, T a) {
    for (++k; k < x.size(); k += k & -k) x[k] += a;
  }
  T sum(int k) {
    T s = 0;
    for (; k > 0; k &= k - 1) s += x[k];
    return s;
  }
  int lower_bound(T a) {
    if (a <= 0) return 0;
    int k = x.size() - 1;
    for (int s : {1, 2, 4, 8, 16}) k |= (k >> s);
    for (int p = ++k; p > 0; p >>= 1, k |= p)
      if (k < x.size() && x[k] < a)
        a -= x[k];
      else
        k ^= p;
    return k + 1;
  }
};

struct event_t {
  int l, r, id;
};

int main() {
  int N, M, Q;
  while (cin >> N >> M >> Q) {
    vector<event_t> events;
    for (int i = 0; i < M; i++) {
      int L, R;
      cin >> L >> R;
      --L;
      --R;
      events.push_back({L, R, -1});
    }
    for (int i = 0; i < Q; i++) {
      int p, q;
      cin >> p >> q;
      --p;
      --q;
      events.push_back({p, q, i});
    }
    sort(events.begin(), events.end(), [&](auto& a, auto& b) {
      if (a.r != b.r) return a.r < b.r;
      return a.id < b.id;
    });
    fenwick_tree<int> bit(N);
    vector<int> res(Q);
    for (auto& ev : events) {
      if (ev.id < 0) {
        bit.add(ev.l, 1);
      } else {
        res[ev.id] = bit.sum(ev.r + 1) - bit.sum(ev.l);
      }
    }
    for (int x : res) {
      cout << x << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 7920
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define N 100005
#define inf 1e18
#define mem(a,b) memset(a,b,sizeof(a))

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}


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

void Sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}

//*********************************************************************************************************************************************//

ll dp[105][N];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
    ll n,lim;
    cin >> n >> lim;
    ll val[n+1],w[n+1];
    for(int i=0;i<n;i++)
        cin >> w[i+1] >> val[i+1];
    for(int i=0;i<=N-1;i++)
        for(int j=0;j<=n;j++)
            dp[j][i] = inf + 5;
    for(int i=0;i<=n;i++)
        dp[i][0]=0;
    ll ans =0 ;
    for(int j=1;j<=N;j++)
    {
        for(int i=1;i<=n;i++)
        {
            if(j-val[i]<0)
            {
                dp[i][j] = dp[i-1][j];
                continue;
            }
            dp[i][j] = min(dp[i-1][j] , dp[i-1][j-val[i]] + w[i]);
        }
    }
    /*for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=100;j++)
            cout << dp[i][j] << " ";
        cout << "\n";
    }*/
    for(int i=1;i<=N-1;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(dp[j][i]<=lim)
            {
                ans = max(ans,1LL*i);
            }
        }
    }
    cout << ans ;
}


Measured memory_bytes: 80256
import * as fs from 'fs';

namespace AtCoder.abc163 {

    export class Program {

        constructor(private readonly args: string[]) {
        }

        /**
         * in
         * 41 2
         * 5 6
         * out
         *
         */
        main(this: Program): void {
            const [n, m]: number[] = this.args[0].split(' ').map(Number);
            const a: number[] = this.args[1].split(' ').map(Number);

            const sum: number = a.reduce((acc, cur) => {
                return acc + cur
            }, 0);

            if (n<sum) {
                console.log(-1);
            } else {
                console.log(n-sum);
            }

        }
    }
}

const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg: AtCoder.abc163.Program = new AtCoder.abc163.Program(args);
prg.main();


Measured memory_bytes: 30676
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <assert.h>

using namespace std;

typedef long long ll;

int N, C[505], S[505], F[505];
int main() {
  scanf("%d", &N);
  for (int i = 1; i < N; i++) {
    scanf("%d %d %d", &C[i], &S[i], &F[i]);
  }
  for (int i = 1; i <= N; i++) {
    int arrive = 0;
    for (int j = i; j < N; j++) {
      if (arrive <= S[j]) {
        arrive = S[j] + C[j];
      } else {
        arrive = F[j] * ((arrive - 1) / F[j] + 1) + C[j];
      }
    }
    printf("%d\n", arrive);
  }
  return 0;
}


Measured memory_bytes: 256
def run(n, _in_list):
    '''
    '''
    is_doublet_count = 0
    for x in _in_list:
        if is_doublet_count == 3:
            break
        _in = list(x)
        if _in[0] ==_in[1]:
            is_doublet_count += 1
        else:
            is_doublet_count = 0
    
    print('Yes' if is_doublet_count >= 3 else 'No')
    




if __name__ == '__main__':
    n = int(input())
    _in_list = [map(int, input().split()) for _ in range(n)]
    run(n, _in_list)

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

const int N = 1000000;
int a[N + 1];

int main() 
{
	int n;
	scanf("%d", &n);
	int v;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &v);
		++a[v];
	}
	int ans = 0;
	for (int i = 1; i <= N; ++i) if (a[i]) {
		if (a[i] == 1) ++ans;
		for (int j = i; j <= N; j += i) a[j] = 0;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 5640
#include <stdio.h>
     
    int main()
    {
      int a, b, c;
      int sum1, sum2, sum3;
      int min;
     
      scanf("%d %d %d", &a, &b, &c);
       
      sum1 = a + b;
      sum2 = a + c;
      sum3 = b + c;
     
      min = sum1;
      if(min > sum2) min = sum2;
      if(min > sum3) min = sum3;
     
      printf("%d\n", min);
      return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, ans;
  cin >> A >> B;
  
  if(B%A == 0) {
    ans = A+B;
  }
  else {
    ans = B-A;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    A,B=map(int,input().split())
    if A%3==0 or B%3==0 or (A+B)%3==0:
        print('Possible')
    else:
        print('Impossible')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

int main() {
    int N, X;
    cin >> N >> X;
    int cnt = 1;
    int d = 0;
    int l;
    for (int i = 0; i < N; i++) {
        cin >> l;
        d += l;
        if (d <= X) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
r = [-1]*N
sumA_ev = sum([A[i] for i in range(N) if i%2 == 1])
r[0] = sum(A) - 2*sumA_ev
for i in range(N-1):
  r[i+1] = 2*A[i] - r[i]
print(" ".join(map(str,r)))

Measured memory_bytes: 19144
n, m = list(map(int, input().split()))
city_list = []

for i in range(m):
    pm, ym = list(map(int, input().split()))
    city_list.append([i,pm,ym])

city_count = {}
city = {}

for i,p,y in sorted(city_list, key=lambda x: x[2]):
    if not p in city_count:
        city_count[p] = 1
    else:
        city_count[p] += 1
    city[i,p] = city_count[p]

for i,p,y in city_list:
    print("{:0=6}{:0=6}".format(p, city[i,p]))

Measured memory_bytes: 47320
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;
    
    
    int main() {
    int n;
    int w;
    cin >> n >> w;
    int v[n];
    int ww[n];
    rep(i,n)	cin >> v[i] >> ww[i];
    int dp[110][10010] = {0};
    
    for(int i = 0; i < n; i++){
    	for(int j = 0; j <=w; j++){
    		if(ww[i] <= j){
    			dp[i+1][j] = max(dp[i][j],dp[i][j-ww[i]] + v[i]);
    		} else{
    			dp[i+1][j] = dp[i][j];
    		}
    	}
    }
    
    cout << dp[n][w] << endl;
     return 0;
    }
    


Measured memory_bytes: 7420
N, K = map(int, input().split())
A = map(int, input().split())

num_dic = {}
for num in A:
    num_dic.setdefault(num, 0)
    num_dic[num] += 1

if len(num_dic.keys()) <= K:
    print(0)
    exit()

else:
    change = 0
    num_dic = sorted(num_dic.items(), key=lambda x: x[1])
    for i in range(len(num_dic) - K):
        change += num_dic[i][1]
    print(change)
    exit()


Measured memory_bytes: 41120
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val x = readLine()!!.split(' ').map { it.toInt() }
    val sum = IntArray(n - k + 1){0}

    var min = 1000000000
    for (i in 0 .. n-k) {
        val left = x[i]
        val right = x[i + k-1]
        val tmp = if (left < 0 && right > 0 || left > 0 && right < 0 ) {
            Math.abs(left) +  Math.abs(right) + Math.min(Math.abs(left), Math.abs(right))
        } else {
            if (left < 0) Math.abs(left)
            else Math.abs(right)
        }
        min = Math.min(min, tmp)
    }
    println(min)
}


Measured memory_bytes: 49728
N=int(input())
s=str(N)
l=[2,4,5,7,9]
r=[0,1,6,8]
n=s[-1]
n=int(n)
#print(n)
if n in l:
    print("hon")
elif n in r:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9180
// luogu-judger-enable-o2
#include<cstdio>
int n,a[200010];
inline int read(){
	int ret=0;char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')ret=(ret<<1)+(ret<<3)+(c^48),c=getchar();
	return ret;
}
int main()
{
	n=read();
	for(register int i=1;i<=n;++i)a[i]=read();
	for(register int i=n;i>0;i-=2)printf("%d ",a[i]);
	for(register int i=(n&1)+1;i<=n;i+=2)printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using pll = pair<long,long>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n,k;
  cin >> n >> k;
  vector<pii> data(n);
  rep(i,n) cin >> data.at(i).second >> data.at(i).first;
  sort(data.begin(),data.end(),greater<pii>());
  long tmp = 0;
  set<int> st;
  vector<pii> list;
  rep(i,k){
    int t = data.at(i).second;
    int d = data.at(i).first;
    if(st.count(t)){
      list.push_back(data.at(i));
    }else{
      st.insert(t);
    }
    tmp += d;
  }
  long m = st.size();
  long ans = tmp + m*m;
  for(int i=k;i<n;i++){
    int nt = data.at(i).second;
    if(st.count(nt)) continue;
    if(list.size() == 0) break;
    int pd = list.at(list.size()-1).first;
    int nd = data.at(i).first;
    st.insert(nt);
    tmp = tmp - pd + nd;
    list.pop_back();
    m = st.size();
    ans = max(ans,tmp + m*m);
    if(st.size() == k) break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4348
#include<stdio.h>
#define MAX 102
#define WHITE 0
#define BLACK 1
#define GRAY 2


void init();
void DFSvisit(int);

int color[MAX];
int n, time = 0;
int d[MAX],f[MAX],edge[MAX],num[MAX][MAX],G[MAX][MAX];

void init(){

  int i,j;

  for(i = 0; i <= n; i++){
      color[i] = WHITE;
    }
  
}

void depthFirstSearch(){
  int i;
  for(i = 1; i <= n; i++){
    if(color[i] == WHITE) DFSvisit(i);
  }
}

void DFSvisit(int u){
  int i,j;
  //  printf("%d\n",u);
  color[u] = GRAY;
  time += 1;
  d[u] = time;

  /*  for(i = 1; i <= n; i++){
    if(color[i] == WHITE && edge[i] != 0){ 
      for(j = 0; j < n; j++){
	if(G[i][j] == 10) {
	  DFSvisit(j);
	}
      }
    }
  */
  for(j = 0; j < n; j++){
    if(G[u][j] == 10) {
      if(color[j+1] == WHITE ){ 
	DFSvisit(j+1);	 
      }
    }
  }


  color[u] = BLACK;

  time = time + 1;
  f[u] = time;


}


int main(){

  int i,j,k = 0,vertex,number;

  scanf("%d\n",&n);
  init();

  for(i = 1; i <= n; i++){
    scanf("%d %d",&vertex,&edge[i]);
    for(j = 1; j <= edge[i]; j++){
      scanf("%d",&number);
      G[vertex][number-1] = 10;
    }
    scanf("\n");
  }
  
/*for(i = 1; i <= n; i++){
    for(j = 0; j < n; j++){
      if(j == n-1){     
    printf("%d\n", G[i][j]);
      } else {
    printf("%d ", G[i][j]);
      }
    }
  }
*/

 depthFirstSearch();
  
  for(i = 1; i <= n; i++){
    printf("%d %d %d\n", i, d[i], f[i]);
  }
  
  return 0;


}

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

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int sum = 0;
    sort(p.begin(), p.end());
    rep(i, k) sum += p[i];
    cout << sum << endl;
    return 0;
}

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

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

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

long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}



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

    int B = (N+1)/2;
    cout << (float) B/N << endl;

}


Measured memory_bytes: 3792
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int m = stdIn.nextInt();
		for(int i=0;i<m;i++){
			Set<String> s = new TreeSet<String>();
			String a = stdIn.next();
			s.add(a);
			for(int j=1;j<a.length();j++){
				String b = a.substring(0, j);
				String c = a.substring(j);
				StringBuffer d = new StringBuffer(b);
				StringBuffer e = new StringBuffer(c);
				String f = d.reverse().toString();
				String g = e.reverse().toString();
				String h1 = b.concat(c);
				String h2 = b.concat(g);
				String h3 = c.concat(b);
				String h4 = c.concat(f);
				String h5 = f.concat(g);
				String h6 = g.concat(b);
				String h7 = f.concat(c);
				s.add(h1);
				s.add(h2);
				s.add(h3);
				s.add(h4);
				s.add(h5);
				s.add(h6);
				s.add(h7);
			}
			System.out.println(s.size());
		}
	}
}

Measured memory_bytes: 13000
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
    int[] buf = readln.chomp.split.to!(int[]);
    int a = buf[0], b = buf[1];
    int ans = a - 1 + (a <= b ? 1 : 0);

    writeln(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M;
char S[2010][2010];
int num[2010][2010],num2[2010][2010],num3[2010][2010],num4[2010][2010];

signed main(){
	cin>>N>>M;
	REP(i,N){
		cin>>S[i];
	}
	REP(i,N){
		int cnt=0;
		REP(j,M){
			if(S[i][j]=='#'){
				cnt=0;
			}
			else{
				num[i][j]=cnt;
				cnt++;
			}
		}
	}
	REP(i,M){
		int cnt=0;
		REP(j,N){
			if(S[j][i]=='#'){
				cnt=0;
			}
			else{
				num2[j][i]=cnt;
				cnt++;
			}
		}
	}
	REP(i,N){
		int cnt=0;
		for(int j=M-1;0<=j;j--){
			if(S[i][j]=='#'){
				cnt=0;
			}
			else{
				num3[i][j]=cnt;
				cnt++;
			}
		}
	}
	REP(i,M){
		int cnt=0;
		for(int j=N-1;0<=j;j--){
			if(S[j][i]=='#'){
				cnt=0;
			}
			else{
				num4[j][i]=cnt;
				cnt++;
			}
		}
	}
	int ans=0;
	REP(i,N){
		REP(j,M){
			ans=max(ans,num[i][j]+num2[i][j]+num3[i][j]+num4[i][j]+1);
		}
	}
	DEB(num3[1])
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 130560
n = int(input())
s = []

geta = 0
for i in range(n):
    a = int(input())
    if a % 10 == 0:
        geta += a
    else:
        s.append(a)

n = len(s)
s.sort(reverse=True)

tmp = sum(s)

ruiseki = [tmp]
for i in range(n-1):
    ruiseki.append(ruiseki[-1] - s[i])

ans = 0
def DFS(depth, now):
    global ans

    if depth == n:
        if now%10 != 0:
            ans = max(ans, now)
        return
    if now + ruiseki[depth] <= ans:
        return
    DFS(depth+1, now+s[depth])
    DFS(depth+1, now)
DFS(0,0)
if ans != 0:
    ans += geta
print(ans)

Measured memory_bytes: 3064
(w, h, n) = map(int, input().split())

minx = 0
maxx = w
miny = 0
maxy = h

for i in range(n):
	x, y, a = map(int, input().split())

	if a == 2:
		maxx = min(maxx, x)
	elif a == 1:
		minx = max(minx, x)
	elif a == 4:
		maxy = min(maxy, y)
	else:
		miny = max(miny, y)

ans = (maxx - minx) * (maxy - miny)

if minx < maxx and miny < maxy:
	print(ans)
else:
	print(0)


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(int argc, char *argv[]){

	char line[5];

	fgets(line, sizeof(line), stdin);


	if(line[0] == line[2]){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}

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

using namespace std;
typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;
#define debug_ printf("OK\n")

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)

const long long mod = 1000000007;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string str;
    cin>>str;
    if(str.find("A")!=std::string::npos&&str.find("B")!=std::string::npos)printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 256
import sys
# import numpy as np
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))
# import profile

def solve():
	n = int(inp())
	dic = read()
	for _ in range(n-1):
		arr = read()
		for i in range(3):
			# print(i, [dic[j] for j in range(3) if i != j])
			arr[i] += max([dic[j] for j in range(3) if i != j])
		dic = arr
		# print(dic, "*")
			# m = dic[]
			# for j in range(3):
			# 	if i != j:
			# print([dic[j]+arr[i] for j in range(3) if i!=j])
			# dic[i] = max([dic[j]+arr[i] for j in range(3) if i!=j])
			# print(dic, "****")
	print(max(dic))



if __name__ == "__main__":
	solve()

Measured memory_bytes: 3060
Cnt = [0] * 4
for i in range(3):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    Cnt[a] += 1
    Cnt[b] += 1

Cnt.sort()
if Cnt == [1, 1, 2, 2]:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define el '\n'
#define ull unsigned long long
#define ui unsigned int
#define ll long long
int main()
{
    vector <string > inp;
    string ss;
    char last;
    bool tr=false;
    int n;
    cin>>n;
    cin>>ss;
    if(n==1)
    {
        cout<<"Yes"<<el;
        return 0;
    }
    inp.push_back(ss);
    last=ss[ss.size()-1];
    for(int i=1;i<n;i++)
    {
        cin>>ss;
        inp.push_back(ss);
        if(ss[0]!=last)
        {

            tr=true;
        }
        last=ss[ss.size()-1];
    }
    if(tr)
    {
            cout<<"No"<<el;
            return 0;
    }
    sort(inp.begin(),inp.end());
    for(int i=1;i<n;i++)
        if(inp[i]==inp[i-1])
    {
        cout<<"No"<<el;
        return 0;
    }

    cout<<"Yes"<<el;


    return 0;
}


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

if P == 1 :
    print(1)
elif N == 1:
    print(P)
else:
    import math

    sq_P = math.floor(math.sqrt(P))
    prim = []
    P_tmp=P

    for i in range(2,sq_P):
        r=0
        if P_tmp%i == 0:
            r+=1
            P_tmp=P_tmp/i
            while P_tmp%i==0:
                r+=1
                P_tmp=P_tmp/i
            prim.append([i,r])

    ans = 1
    for i in range(len(prim)):
        if prim[i][1]>=N:
            ans = ans * prim[i][0]**math.floor(prim[i][1]/N)

    print(ans)

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

using namespace std;

int N;
vector <int> A(3001);

int main(){
    cin >> N;

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

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

    cout << ans << endl;
}

Measured memory_bytes: 256
(let ((n (read))
      (nc 0)
      (z 0)
      (ans 0)
      (mn 10000000000)
      temp)
     (dotimes (i n)
       (setf temp (read))
       (cond ((zerop temp) (incf z)
                           (setf mn 0))
             ((< temp 0) (incf nc)
                         (setf mn (min mn (abs temp)))
                         (incf ans (abs temp)))
             (t (setf mn (min mn (abs temp)))
                (incf ans (abs temp)))))
     (if (oddp nc) (decf ans (* 2 mn)))
     (princ ans))

Measured memory_bytes: 57824
#include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    unsigned long long int A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];

    }
    unsigned long long int temp;
    temp=A[0];
    for(int i=1;i<N;i++){
        temp^=A[i];
    }
    for(int i=0;i<N;i++){
        unsigned long long int tempa=temp^A[i];
        cout<<tempa<<" ";
    }

}


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

using namespace std;

int main(int argc, const char * argv[]) {
    int A = 0;
    int B = 0;
    int T = 0;
    cin >> A >> B >> T;

    int biscuits = 0;
    for(int i = 0; i < T/A; i++) {
        biscuits += B;
    }
    cout << biscuits << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
 
using namespace std;
 
void compute(string text,string S)
{
  int nt = text.size(),nS = S.size();
  int mlen = inf;
  string ans;
  bool found[nS];
  int CNT = 0;
  int fpos[nS];
  rep(i,nS)found[i] = false;
 
  rep(i,nt)
    {
      bool update = false;
      int cnt = 0,mn,mx;
      mn = inf,mx = -inf;
      rep(j,nS)
	{
	  if(S[j] == text[i])
	    {
	      update = true;
	      found[j] = true;
	      fpos[j] = i;
	    }
	  if(found[j])
	    {
	      cnt++;
	      mn = min(mn,fpos[j]);
	      mx = max(mx,fpos[j]);
	    }
	}
      if(cnt == nS)
	{
	  int cost = mx - mn + 1;
	  if(cost < mlen)
	    {
	      mlen = cost;
	      ans = text.substr(mn,cost);
	      CNT = 1;
	    }
	  else if(cost == mlen && update)CNT++;	    
	}
    }
  cout << CNT << endl << endl;
  if(!CNT)return;

  rep(i,ans.size())
    if((i+1)%72 == 0 && i != 0)
      printf("%c\n",ans[i]);
    else
      printf("%c",ans[i]);
  if(ans.size()%72 != 0)puts("\n");
  else puts("");
}
 
int main()
{
  string blank;
  while(getline(cin,blank))
    {
      string text,S;
      text += blank;
      while(getline(cin,blank))
	{
	  if(blank.empty())break;
	  text += blank;
	}
      if(text.empty())goto Fin;
      while(getline(cin,blank))
	if(blank.empty())break;
	else S += blank;
      compute(text,S);
    }
 Fin:;
  return 0;
}

Measured memory_bytes: 2384
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
	long long l,r;
	int min_ans=2019;
	cin>>l>>r;
	if(r-l>=2018){
		cout<<0;
		return 0;
	}
	for(int i=l;i<r;i++){
		for(int j=i+1;j<=r;j++){
			int a=i%2019;
			int b=j%2019;
			min_ans=min(a*b%2019,min_ans);
		}
	}
	cout<<min_ans;
	return 0;
}

Measured memory_bytes: 256