akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,s1,s2,s3[55],s4="~";
	int ba=0;
	cin>>s>>s1;
	s2=s;
	if(s.size()<s1.size())
	{
		cout<<"UNRESTORABLE";
		return 0;
	}
	for(int t=0;t<=s.size()-s1.size();t++)
	{
		string s0;
		s0=s.substr(t,s1.size());
		if(s0==s1)
		{
			for(int i=0;i<s.size();i++)
			{
				if(s[i]=='?')
				{
					s[i]='a';
				}
			}
			cout<<s;
			return 0;
		}
	} 
	for(int t=s.size()-s1.size();t>=0;t--)
    {
    	bool ok=1;
    	for(int i=t;i<t+s1.size();i++)
    	{
    		if(s[i]==s1[i-t]||s[i]=='?')
    		{
    			s[i]=s1[i-t];
			}
			else
			{
				ok=0;
				s=s2;
				break;
			}
		}
		if(ok)
		{
			for(int i=0;i<s.size();i++)
			{
				if(s[i]=='?')
				{
					s[i]='a';
				}
			}
			s3[ba]=s;
			s4=min(s4,s);
			ba++;
		}
	}
	if(s4=="~")
	{
		cout<<"UNRESTORABLE";
	}
	else
	{
		cout<<s4;
	}
	return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const long long MAXN=300005;

long long N,T[MAXN];
long long q[MAXN],head,tail;
long long sum[MAXN],y[MAXN];
long long L[MAXN],R[MAXN],f[MAXN],g[MAXN],h[MAXN];

void DP(long long dp[],long long N)
{
	q[head=tail=1]=0;
	y[0]=0;
	for(long long i=1;i<=N;i++)
	{
		while(head<tail)
		{
			long long a=q[tail-1],b=q[tail];
			if((y[b]-y[a])<1LL*i*(b-a))
				tail--;
			else
				break;
		}
		long long j=q[tail];
		dp[i]=max(dp[i-1],dp[j]+(i-j)*(i-j-1)/2+(i-j)-sum[i]+sum[j]);
		y[i]=dp[i]+1LL*(i-1)*i/2+sum[i];
		while(head<tail)
		{
			long long a=q[tail-1],b=q[tail],c=i;
			if((y[b]-y[a])*(c-b)<1LL*(y[c]-y[b])*(b-a))
				tail--;
			else
				break;
		}
		q[++tail]=i;
	}
}

void CDQ(long long l,long long r,long long mode)
{
	if(l==r)
	{
		f[l]=max(f[l],L[l-1]+R[r+1]+1-T[l]);
		return;
	}
	long long mid=(l+r+mode)/2;
	CDQ(l,mid,mode);
	CDQ(mid+1,r,mode);
	
	q[head=tail=1]=l-1;
	g[l-1]=L[l-1];
	y[l-1]=g[l-1]+(l-1-1)*(l-1)/2+sum[l-1];
	for(long long i=l;i<=mid;i++)
	{
		g[i]=L[i];
		y[i]=g[i]+1LL*(i-1)*i/2+sum[i];
		while(head<tail)
		{
			long long a=q[tail-1],b=q[tail],c=i;
			if((y[b]-y[a])*(c-b)<1LL*(y[c]-y[b])*(b-a))
				tail--;
			else
				break;
		}
		q[++tail]=i;
	}
	
	for(long long i=mid+1;i<=r;i++)
	{
		while(head<tail)
		{
			long long a=q[tail-1],b=q[tail];
			if((y[b]-y[a])<1LL*i*(b-a))
				tail--;
			else
				break;
		}
		long long j=q[tail];
		g[i]=g[j]+(i-j)*(i-j-1)/2+(i-j)-sum[i]+sum[j]+R[i+1];
	}
	
	for(long long i=r-1;i>mid;i--)
		g[i]=max(g[i],g[i+1]);
	for(long long i=mid+1;i<=r;i++)
		f[i]=max(f[i],g[i]);
}

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	scanf("%lld",&N);
	for(long long i=1;i<=N;i++)
		scanf("%lld",&T[i]);
	
	for(long long i=1;i<=N;i++)
		sum[i]=sum[i-1]+T[i];
	DP(L,N);
	reverse(T+1,T+N+1);
	for(long long i=1;i<=N;i++)
		sum[i]=sum[i-1]+T[i];
	DP(R,N);
	reverse(R+1,R+N+1);

	memset(h,0x80,sizeof h);
	
	for(long long i=1;i<=N;i++)
		swap(L[i],R[N-i+1]);
	
	memset(f,0x80,sizeof f);
	CDQ(1,N,-1);
	for(long long i=1;i<=N;i++)
		h[i]=max(h[i],f[N-i+1]);

	reverse(T+1,T+N+1);
	for(long long i=1;i<=N;i++)
		swap(L[i],R[N-i+1]);
	
	for(long long i=1;i<=N;i++)
		sum[i]=sum[i-1]+T[i];
	
	memset(f,0x80,sizeof f);
	CDQ(1,N,0);
	for(long long i=1;i<=N;i++)
		h[i]=max(h[i],f[i]);
	
	long long M,P,X;
	scanf("%lld",&M);
	while(M--)
	{
		scanf("%lld%lld",&P,&X);
		long long ans=max(L[P-1]+R[P+1],h[P]+T[P]-X);
		printf("%lld\n",ans);
	}
	
	return 0;
}


Measured memory_bytes: 23552
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            

            int[] array = new int[]{in.nextInt(), in.nextInt(), in.nextInt()};

            Arrays.parallelSort(array);    // 5 5 7 になっていれば正解

            out.append(Arrays.equals(array, new int[]{5, 5, 7}) ? "YES" : "NO");


        }

    }
}



Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
using namespace std;
bool asyn(string s) {
  if (s.size() == 1) {
    return true;
  }
  if (s.size() % 2) {
    return false;
  }
  int c = s.size() / 2;
  for (int i = 0; i < c; i++) {
    if (s[i] != s[i + c]) {
      return false;
    }
  }
  return true;
}
int main() {
  string s;
  cin >> s;
  do {
    s = s.substr(0, s.size() - 1);
  } while(!asyn(s));
  cout << s.size() << endl;
}



Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] arr = input.Split(' ');
            int a = int.Parse(arr[0]);
            int b = int.Parse(arr[1]);
            int c = int.Parse(arr[2]);
            string judge = "";
            if (b-a == c-b)
            {
                judge = "YES";
            }
            else
            {
                judge = "NO";
            }
            Console.WriteLine(judge);
        }
    }
}


Measured memory_bytes: 11092
{-#LANGUAGE BangPatterns#-}
import Control.Monad
import Data.Functor

main::IO ()
main=
  do
    n <- read <$> getLine::IO Int
    list <- replicateM n (read <$> getLine)::IO [Int]
    print $ maxProfit list


maxProfit::Integral a=>[a]->a
maxProfit (x:y:ys)=maxProfit' (y:ys) x (y-x)
  where
    maxProfit'::Integral a=>[a]->a->a->a
    maxProfit' [] minV maxV = maxV
    maxProfit' (x:xs) !minV !maxV=maxProfit' xs (min x minV) (max (x-minV) maxV)

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

int main() {
    ll a;
    long double b;
    cin >> a >> b;

    cout << ll(a * b) << endl;

    return 0;
}

Measured memory_bytes: 3728
#include <iostream>

constexpr int MAX_N = 100000;
int B[MAX_N + 1];

int main() {
  int N;
  std::cin >> N;
  int A;
  for (int i = 1; i <= N; ++i) {
    std::cin >> A;
    B[A] = i;
  }
  for (int i = 1; i <= N; ++i) {
    if (i > 1) {
      std::cout << " ";
    }
    std::cout << B[i];
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		var dict = new Dictionary<string, int>();
		dict["SUN"] = 7;
		dict["MON"] = 6;
		dict["TUE"] = 5;
		dict["WED"] = 4;
		dict["THU"] = 3;
		dict["FRI"] = 2;
		dict["SAT"] = 1;
		WriteLine(dict[GetString()]); 
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 11220
#include <stdio.h>
int main(void)
{
int a,b,c,i,n=0;

scanf("%d %d %d",&a,&b,&c);

for( i = a ; i <= b ; i++ ){
 if(c % i  == 0)
   n++;
}
printf("%d\n",n);
 
return 0;
} 

Measured memory_bytes: 596
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<ll> W(N);
    rep(i, N) cin >> W[i];
    ll S1 = 0;
    ll S2 = 0;
    rep(i, N) S2 += W[i];
    ll ans = MOD;
    rep(i, N) {
        S1 += W[i];
        S2 -= W[i];
        ans = min(ans, abs(S1 - S2));
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int n;
vector<int> adj[N];
int dp[N][2];

void dfs(int src = 0, int par = -1) {
	dp[src][0] = dp[src][1] = 1; 
	for(int u: adj[src]) {
		if(u == par) continue;
		dfs(u, src);
		dp[src][0] = mul(dp[src][0], dp[u][1]);
		dp[src][1] = mul(dp[src][1], add(dp[u][1], dp[u][0]));
	}
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    cin>>n;
    f(i, n - 1) {
    	int u, v;
    	cin>>u>>v;
    	u--, v--;
    	adj[u].pb(v);
    	adj[v].pb(u);
    }
    dfs();
    cout<<add(dp[0][0], dp[0][1]);
    return 0;
}

Measured memory_bytes: 14208
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    vs64 a(n);
    rep (i, n) cin >> a[i];

    const s64 inf = 1e18;
    // vector< vector< vs64 > > dp(n + 1, vector< vs64 >(3, vs64(2, -inf)));
    // rep (i, 2) dp[0][i + 1][0] = 0;
    s64 dp[n + 1][3][2];
    rep (i, n + 1) rep (j, 3) rep (k, 2) dp[i][j][k] = -inf;
    rep (i, 2) dp[0][i + 1][0] = 0;

    rep (i, n)
    {
        if (i % 2 == 0)
        {
            dp[i + 1][0][0] = dp[i][0][0];
            dp[i + 1][1][0] = max(dp[i][1][1], dp[i][1][0]);
            dp[i + 1][1][1] = dp[i][0][0] + a[i];
            dp[i + 1][2][1] = dp[i][1][0] + a[i];
        }
        else
        {
            dp[i + 1][0][0] = max(dp[i][1][0], dp[i][1][1]);
            dp[i + 1][1][0] = max(dp[i][2][0], dp[i][2][1]);
            dp[i + 1][0][1] = dp[i][0][0] + a[i];
            dp[i + 1][1][1] = dp[i][1][0] + a[i];
            dp[i + 1][2][1] = dp[i][1][0] + a[i];
        }
    }

    cout << max(dp[n][1][0], dp[n][1][1]) << "\n";
    return 0;
}



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

int main() {
  int S ;
  cin >> S ;
  if ( S==0 )
    cout << 0 << endl;
  else if ( S==111 )
    cout << 3 << endl;
  else if ( S==100 || S==10 || S==1 )
    cout << 1 << endl;
  else
    cout << 2 << endl;
}

Measured memory_bytes: 256
N,W = [int(i) for i in input().split()]
VW = [[int(i) for i in input().split()] for _ in range(N)]
sVW = sorted(VW, key = lambda x:x[0]/x[1], reverse = True)
ans = 0
for i in sVW:
    if W < i[1]:
        ans += i[0] * W / i[1]
        break
    else:
        ans += i[0]
        W -= i[1]
print(ans)


Measured memory_bytes: 26352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;

string keyboard[2] = {"qwertasdfgzxcvb", "yuiophjklnm"};

int main()
{
	while (1)
	{
		string s; cin >> s;
		if (s[0] == '#') return 0;

		int ans = 0;
		int lr;
		if (keyboard[0].find(s[0]) != string::npos)
			lr = 0;
		else
			lr = 1;

		rep(i, 1, s.length())
		{
			if (keyboard[lr].find(s[i]) == string::npos)
			{
				lr = (lr + 1) % 2;
				ans++;
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3176
import java.util.*;
class Main{
	static Scanner input = new Scanner(System.in);
	static long Mod = 1000000007;
	public static void main(String[] args){
		String s = input.nextLine();
		long dp[][] = new long[13][s.length()+1];
		dp[0][0] = 1;
		for(int i = 1 ;i <= s.length() ; i++){
			for(int r = 0 ;r < 13 ; r++){
				if(s.charAt(i-1) == '?'){
					for(int curr = 0 ; curr < 10 ; curr++){
						dp[(r*10 + curr)%13][i] += dp[r][i-1];
						if(dp[(r*10 + curr)%13][i] >= Mod)
							dp[(r*10+ curr)%13][i] -= Mod;
					}
				}
				else{
					int curr = s.charAt(i-1)-'0';
					dp[(r*10+curr)%13][i] += dp[r][i-1];
					if(dp[(r*10 + curr)%13][i] >= Mod)
						dp[(r*10 + curr)%13][i] -= Mod;
				}
			}
		}
		System.out.println(dp[5][s.length()]);
	}
}

Measured memory_bytes: 36160
import itertools
N=int(input())
L=[]
S=[]
for i in range(3,10):
    for x in itertools.product('357',repeat=i):
        L.append(x)
for x in L:
    s=""
    for y in x:
        s+=y
    if "3" in s and "5" in s and "7" in s:
        S.append(int(s))
S.append(N)
S.sort()
if "3" in str(N) and "5" in str(N) and "7" in str(N):
    print(S.index(N)+1)
else:
    print(S.index(N))


Measured memory_bytes: 7924
#include<stdio.h>
int main(){
	
	int m,n,evenctr=0,oddctr= 0;
scanf("%d %d",&m,&n);

	for( int i=2;i<=m;i++){
		oddctr= oddctr+i-1;
		
	}
	for(int i=2;i<=n;i++){
		evenctr=evenctr+i-1;
}

printf("%d",oddctr+evenctr);
return 0;
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll L[87];
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i < 87; i++) {
    L[i] = L[i - 1] + L[i - 2];
  }
  ll N;
  cin >> N;
  cout << L[N] << endl;
}

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

l = [0 for i in range(N+1)]
l[0] = 1
p = [0 for i in range(N+1)]
p[0] = 1
for i in range(1, N+1):
    l[i] = 2*l[i-1]+3
    p[i] = 2*p[i-1]+1

x = X
d = N
ans = 0
while True:
    if x == 0:
        break
    if d == 0 and x != 0:
        ans += 1
        break

    m = (l[d]-1)//2
    if x < m:
        x = x - 1
    elif x == m:
        ans += p[d-1]
        break
    elif x > m:
        ans += p[d-1]+1
        x = x - (m+1)

    d -= 1

print(ans)


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

    int x = sc.nextInt();
    int n = sc.nextInt();

    if (n == 0) {
      System.out.println(x);
      return;
    }

    List<Integer> ps = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      ps.add(sc.nextInt());
    }

    int max = Integer.MAX_VALUE;
    for (int i = 1; i <= n; i++) {
      int tmp = x + i;
      if (!ps.contains(tmp)) {
        max = tmp;
        break;
      }
    }
    int min = Integer.MAX_VALUE;
    for (int i = 0; i <= n; i++) {
      int tmp = x - i;
      if (!ps.contains(tmp)) {
        min = tmp;
        break;
      }
    }

    if (Math.abs(x - min) <= Math.abs(x - max)) {
      System.out.println(min);
    } else {
      System.out.println(max);
    }
  }
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;


ll W, H, x, y;

int main(){

    cin >> W >> H >> x >> y;
    if(2 * x  == W && 2 * y == H){
        printf("%.10f %d\n", W * H / 2.0, 1);
    }
    else{
        printf("%.10f %d\n", W * H / 2.0, 0);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int MaxN = 20;
const int Max = 1100;
int N, M;
int a[Max], b[Max], c[Max][MaxN];
pair<int, int> keys[Max];
ll dp[1 << MaxN];
map<int, vector<int>> crate_key_map;
const ll INF = 1LL << 60;

int main(int argc, const char * argv[]) {
    cin >> N >> M;
    rep(i, M) {
        cin >> a[i] >> b[i];
        inputArray(c[i], b[i]);
    }

    rep(i, M) {
        int key = 0;
        rep(j, b[i]) {
            int crate = c[i][j]-1;
            key = key | (1 << crate);
            crate_key_map[crate].push_back(i);
        }
        keys[i] = make_pair(a[i], key);
        
    }

    int full = 1 << N;
    rep(i, full) {
        dp[i] = INF;
    }

    // dp: stateの箱を開けることができる鍵セットの最小コスト
    dp[0] = 0;
    rep(state, full) {
        rep(key_id, M) {
            auto& key = keys[key_id];
            int nextState = state | key.second;
            chmin(dp[nextState], dp[state] + key.first);
        }
    }

    if (crate_key_map.size() != N) {
        output(-1);
    } else {
        output(dp[full-1]);
    }

    return 0;
}

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

int main()
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    vector<int> Alice(101,0);
    vector<int> Bob(101,0);

    for(int i = A; i < B; i++)
    {
        Alice.at(i) = 1;
    }
    for(int i = C; i < D; i++)
    {
        Bob.at(i) = 1;
    }
    int count = 0;
    for(int i = 0; i <= 100; i++)
    {
        if(Alice.at(i) ==1 && Bob.at(i) == 1)count++;
    }
    
    cout << count << endl;
    return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  bool found = false;
  for (int i = 1; i <= B; i++) {
    if (A*i % B == C) found = true;
  }
  if (found) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


    EXPLAINATION BELOW->
    
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
ld expected_value[1001];
ld dp[200005];
void solve()
{
   int n,k,i,j;cin>>n>>k;
   ld A[n];
   ld mx=0;
   fo(i,0,n)cin>>A[i],mx=max(mx,A[i]);
   
   foe(i,1,mx)
   {
       ld sum=0;
       ld prob=(1.0/i);
       foe(j,1,i)
       sum+=j*prob;
       
       expected_value[i]=sum;
   }
   foe(i,1,n)
   {
       dp[i]=dp[i-1]+expected_value[(ll)A[i-1]];
   }
   
   i=0;
   j=k-1;
   ld ans=0;
   while(j<n)
   {
       ans=max(ans,dp[j+1]-dp[i]);
       i++;
       j++;
   }
   cout<<sp(12)<<ans<<"\n";
  
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 6528
#include <stdio.h>

int main(){
  int X, A, B;
  scanf("%d %d %d", &X, &A, &B);
  if(B <= A){
    printf("delicious\n");
  }else if(B <= A + X){
    printf("safe\n");
  }else{
    printf("dangerous\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int K, N;
    cin >> N >> K;
    
    long long int h[N];
    long long int cumsum[N];
    cumsum[0] = 0;
    for(int i=0; i<N; i++) {
        cin >> h[i];
    }

    sort(h, h+N);
    for(int i=0; i<N-1; i++) {
        cumsum[i+1] = h[i+1]-h[i] + cumsum[i];
    }
    
    long long int mn=1000000001;
    for(int i=0; i<N-K+1; i++) {
        if(mn>cumsum[i+K-1]-cumsum[i]) {
            mn = cumsum[i+K-1]-cumsum[i];
        }
    }
    
    cout << mn << endl;

    return 0;
    
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	int A[200000];
	ll Count[200001];
	ll Sum = 0;
	
	for(int i = 0; i < 200001; i++){
		Count[i] = 0;
	}
	
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d", &A[i]);
		Count[A[i]]++;
	}
	
	for(int i = 1; i <= N; i++){
		if(Count[i] > 1){
			Sum += Count[i] * (Count[i] - 1) / 2;
		}
	}
	
	for(int k = 0; k < N; k++){
		int c = Count[A[k]];
		if(c > 1){
			ll diff = (c * (c-1)/2) - ((c-1) * (c-2) / 2);
			printf("%lld\n", Sum - diff);
		}
		else{
			printf("%lld\n", Sum);
		}
	}
	
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string s, t; cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    (s<t) ? Yes() : No();
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int m,i,h,len;
    int count=0;
    char str[404],inc[203];
    while(1){
        scanf("%s",str);
        if(str[0]=='-'){
            break;
        }
        scanf("%d",&m);
        for(i=0;i<m;i++){
            scanf("%d",&h);
            count+=h;
        }
        len=strlen(str);
        count%=len;
        strcpy(inc,str);
        strcat(str,inc);
        strncpy(inc,str+count,len);
        printf("%s\n",inc);
        count=0;
    }
    return 0;
}


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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    vector<int> arr(n);
    loop(n) {
        cin >> arr[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (arr[i] != arr[j] && arr[i] != arr[k] && arr[k] != arr[j]) {
                    vector<int> vec{arr[i], arr[j], arr[k]};
                    sort(all(vec));
                    if (vec[2] < vec[0] + vec[1]) {
                        ++ans;
                    }
                }
            }
        }
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


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


Measured memory_bytes: 3136
#include <iostream>

using namespace std;

int main(void){
	int l,m[12],n[12];
	
	while(cin>>l&&l){
		
		for(int i=0;i<12;i++) cin >> m[i] >> n[i];
		for(int i=0;i<12;i++){
			l -= m[i]-n[i];
			if(l <= 0){
				cout << i+1 << endl;
				break;
			}
		}
		if(l > 0) cout << "NA" << endl;
	}
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout .tie(0);
  string s1, s2;
  cin >> s1 >> s2;
  int cnt = 0;
  for (int i = 0; i < s1.size(); i++)
    cnt += s1[i] != s2[i];
  cout << cnt;
  return 0;
}


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

int num_AC, num_TLE, num_WA, num_RE;

int main() {
    int n;
    cin >> n;
    string str;
    while(n --) {
        cin >> str;
        if(str == "AC") num_AC ++;
        else if(str == "TLE") num_TLE ++;
        else if(str == "WA") num_WA ++;
        else num_RE ++;
    }
    cout << "AC x " << num_AC << endl;
    cout << "WA x " << num_WA << endl;
    cout << "TLE x " << num_TLE << endl;
    cout << "RE x " << num_RE << endl;
    return 0;
}

Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		SalesManager sm = new SalesManager();
		while(true){
			String str = br.readLine();
			
			if(str == null){
				break;
			}
			
			String[] tmpArray = str.split(",");
			int price = Integer.parseInt(tmpArray[0]);
			int num = Integer.parseInt(tmpArray[1]);
			sm.addQuery(price, num);
		}
		
		sm.printSumOfSales();
		sm.printAverage();
	}
}

class SalesManager {
	int queryNum = 0;
	int sumOfSalees = 0;
	int sumOfQuant = 0;
	
	public void addQuery(int price, int num){
		queryNum++;
		sumOfSalees += price * num;
		sumOfQuant += num;
	}
	
	public void printSumOfSales(){
		System.out.println(sumOfSalees);
	}
	
	public void printAverage(){
		int average = (int)Math.round((double)sumOfQuant/queryNum);
		System.out.println(average);
		
	}
}

Measured memory_bytes: 24216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
typedef long long ll;
//プロトタイプ宣言
int gcd(int , int);


int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(),h.end());
  int ans = lower_bound(h.begin(),h.end(),k) - h.begin();
  cout << n - ans << endl;
}








































//以下、ライブラリ
//ユークリッドの互除法

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;


int main(){
    int N,K;
    cin >>N>>K;
    vector<int> H(N);
    long int count;
    rep(i,N){
        cin >> H[i];
    }
    if(N<=K){
        cout << 0 << endl; return 0;
    }else{
        sort(H.begin(),H.end());
        count=0;
        rep(i,K){
            H.pop_back();
        }
        for(auto&& i : H) {
            count =count + i;
        }
    }
    cout << count << endl;
    return 0;
}


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

void solve () {
    int n;
    cin >> n;
    int ans = 0;
    int cnt = 0;
    int r = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (r < x) {
            ans = max (cnt, ans);
            cnt = 0;
        }
        else {
            cnt++;
        }
        r = x;
    }
    ans = max (cnt, ans);
    cout << ans;

}

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


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n;
pair<string,ll> p[200];
ll a[e5];

int main(){
  cin >> n;
  for(ll i = 0;i < n;i++){
    string s;
    ll x;
    cin >> s >> x;
    p[i] = make_pair(s,-x);
  }
  iota(a,a+n,0ll);
  sort(a,a+n,[](ll a,ll b){
    return p[a] < p[b];
  });
  for(ll i = 0;i < n;i++){
    cout << a[i]+1 << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i, n, ai;
    int min = 1000000, max = -1000000;
    long sum = 0;
    //数値を入力
    scanf("%ld", &n);
	//n回数値を入力,最小値,最大値,合計の計算
    for(i = 0; i < n; i++){
        scanf("%d", &ai);
        if(ai < min){
            min = ai;
        }
        if(ai > max){
            max = ai;
        }
        sum = sum + ai;
    }
    //結果を出力
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}

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

int n;
string str, ans;

bool solve(char s, char e) {
	ans = "";
	for (int i = 0; i < n; i++) {
		ans += s;
		if ((str[i] == 'o' && s == 'S') || (str[i] == 'x' && s == 'W')) {
			char tmp = e;
			e = s;
			s = tmp;
		}
		else if ((str[i] == 'x' && s == 'S') || (str[i] == 'o' && s == 'W')) {
			if (e == 'S') {
				e = s;
				s = 'W';
			} else {
				e = s;
				s = 'S';
			}
		}
	}

	return (str[0] == 'o' && ans[0] == 'S' && ans[1] == ans[n - 1] ||
			str[0] == 'x' && ans[0] == 'S' && ans[1] != ans[n - 1] ||
			str[0] == 'o' && ans[0] == 'W' && ans[1] != ans[n - 1] ||
			str[0] == 'x' && ans[0] == 'W' && ans[1] == ans[n - 1]) &&
		   (str[n - 1] == 'o' && ans[n - 1] == 'S' && ans[0] == ans[n - 2] ||
			str[n - 1] == 'x' && ans[n - 1] == 'S' && ans[0] != ans[n - 2] ||
			str[n - 1] == 'o' && ans[n - 1] == 'W' && ans[0] != ans[n - 2] ||
			str[n - 1] == 'x' && ans[n - 1] == 'W' && ans[0] == ans[n - 2]);
}

int main() {
	
	cin >> n >> str;
	if (solve('S', 'S')) {
		cout << ans << endl;
	}
	else if (solve('S', 'W')) {
		cout << ans << endl;
	}
	else if (solve('W', 'S')) {
		cout << ans << endl;
	}
	else if (solve('W', 'W')) {
		cout << ans << endl;
	}
	else {
		cout << "-1" << endl;
	}

	return 0;
}

Measured memory_bytes: 640
rgbn=gets.chomp.split.map{|a| a.to_i}
r_jogen=rgbn[3]/rgbn[0]
count=0
for i in 0..r_jogen do
  g_jogen=(rgbn[3]-rgbn[0]*i)/rgbn[1]
  for j in 0..g_jogen do
    nokori=rgbn[3]-rgbn[0]*i-rgbn[1]*j
    count+=1 if nokori%rgbn[2]==0 && nokori>=0
  end
end

puts count

Measured memory_bytes: 1788
A,B,C,K=list(map(int, input().split()))
ans=0
if 0 < K and K <= A:
  ans += 1*K
elif K <= 0:
  pass
else:
  ans += 1*A
K -= A
if 0 < K and K <= B:
  ans += 0*K
elif K <= 0:
  pass
else:
  ans += 0*B
K -= B
if 0 < K and K <= C:
  ans += (-1)*K
elif K <= 0:
  pass
else:
  ans += (-1)*C
print(ans)

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll n;
    cin >> n;
    vll d(n);
    rep(i, n) cin >> d[i];

    ll s = 0, ss = 0;
    rep(i, n){
        s += d[i];
        ss += d[i]*d[i];
    }
    ll res = (s*s-ss) / 2;
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int
#define pb push_back
#define fi first 
#define se second 
#define mod 1000000007
int power(ll x, ll  y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
int main() 
{ 
  char s;
  cin >> s ;
  if(s-'A'>=0&&s-'A'<26) cout << "A" << endl;
  else cout << "a" << endl;

} 

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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 1;
    for (int i=0; i<N-1; i++){
        if(S.at(i) != S.at(i+1)){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
N = int(input())

min_a = N+1
max_a = 0
max_b = 0

for i in range(N):
    a, b = map(int, input().split())
    # min process
    if a<min_a:
        min_a = a
    # max process
    if a>max_a:
        max_a = a
        max_b = b

ans = (min_a - 1) + (max_a - min_a + 1) + max_b
print(ans)


Measured memory_bytes: 43864
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

bool[int] isPrime;

void init_isPrime() {
  foreach (i; 1..10^^5+1) {
    isPrime[i] = true;
  }

  foreach (i; 2..100001) {
    if (isPrime[i]) {
      for (int j = i + i; j <= 100000; j += i){
        isPrime[j] = false;
      }
    }
  }
}

bool isLike2017(int n) {
  return isPrime[n] && isPrime[(n+1)/2];
}

void main() {
  int Q = readln.chomp.to!int;
  bool[int] like2017;
  int[][] lrs = Q.iota.map!(_ => readln.chomp.split.to!(int[])).array;
  int[100001] dp;
  
  init_isPrime();

  for (int i = 3; i <= 100000; i += 2) {
    if (isLike2017(i)) {
      dp[i]++;
    }
  }

  for (int i = 3; i <= 100000; i++) {
    dp[i] += dp[i-1];
  }

  foreach (lr; lrs) {
    int l = lr[0],
        r = lr[1];

    writeln(dp[r] - dp[l-1]);
  }
}


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

using namespace std;

using int64 = long long;

struct Edge {
  int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

vector<vector<Edge>> ReadDirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge({v1, v2}));
  }
  return graph;
}

vector<int> TopologicalSort(const vector<vector<Edge>>& graph) {
  int n = graph.size();
  vector<int> in(n);
  for (int v = 0; v < n; v++) {
    for (const auto& edge : graph[v]) {
      in[edge.to]++;
    }
  }

  deque<int> queue;
  for (int v = 0; v < n; v++) {
    if (in[v] == 0) queue.push_back(v);
  }

  vector<int> vs;
  while (!queue.empty()) {
    int v = queue.front();
    queue.pop_front();
    vs.push_back(v);
    for (const auto& edge : graph[v]) {
      in[edge.to]--;
      if (in[edge.to] == 0) queue.push_back(edge.to);
    }
  }

  if (vs.size() < n) return vector<int>();
  return vs;
}

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

  int n, m;
  cin >> n >> m;
  auto graph = ReadDirectedGraph(n, m);
  auto vs = TopologicalSort(graph);
  for (int v : vs) {
    cout << v << endl;
  }
}


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

int n,k,a;
vector<int> V;
int dp[100005];

int main() {
    cin >> n >> k;
    for (int i=0;i<n;i++) {
        cin >> a;
        V.push_back(a);
    }
    for (int i=1;i<=k;i++) {
        for (auto x : V) {
            if (x>i) {continue;}
            if (dp[i-x]==0) {dp[i]=1; break;}
        }
    }
    if (dp[k]==1) {cout << "First";}
    else {cout << "Second";}
}


Measured memory_bytes: 4048
def readInt():
    return int(input())
def readList():
    return list(map(int,input().split()))
def readMap():
	return map(int,input().split())
def readStr():
    return input()
inf=float('inf')
mod = 10**9+7
import math
from itertools import permutations
def solve(K):
    return "ACL"*K

K=readInt()
print(solve(K))

Measured memory_bytes: 62236
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(int i=0; i<n; i++)
#define rep(i,start,n) for(int i=start; i<n; i++)

signed main(){
    fast;  

    int n;cin>>n;
    int mn = 200;
    int sum = 0;
    int s[n];

    loop(n){
    	cin>>s[i];
    	sum+=s[i];
    	if( s[i]%10!=0 )
    		mn = min(mn,s[i]);  	
    }
    if(mn==200){
    	cout<<0<<endl;
    	return 0;
    }
    if(sum%10!=0)
    	cout<<sum<<endl;
    else{
    	sum-=mn;
    	cout<<sum<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3628
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    string S; cin >> S;
    if (S[2]==S[3] && S[4]==S[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[]) {
	int i,n,q,num,mid,ans=0;
	queue<pair<string,int> > qu;
	string str;
	cin>>n>>q;
	for(i=0;i<n;i++){
		cin>>str>>num;
		qu.push(make_pair(str,num));
	}
	pair<string,int> tmp;
	while(!qu.empty()){
		tmp=qu.front();qu.pop();
		mid=min(tmp.second,q);
		tmp.second-=mid;
		ans+=mid;
		if(tmp.second)
			qu.push(tmp);
		else
			cout<<tmp.first<<" "<<ans<<endl;
	} 
	return 0;
}


Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<priority_queue<int, vector<int>, greater<int>>, int> P;

#define K_MAX 100
P state[K_MAX][K_MAX];

int main()
{
    int n, k;
    cin >> n >> k; 
    vector<int> v;
    rep(i, n){ int tmp; cin >> tmp; v.push_back(tmp);}

    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; i + j <= n; j++)
        {
            rep(ip, i) {
                state[i][j].first.push(v[ip]);
                state[i][j].second += v[ip];
            }   
            rep(jp, j) {
                state[i][j].first.push(v[n-1-jp]);
                state[i][j].second += v[n-1-jp];
            }
        }
    }
    // for (int i = 0; i <= n; i++)
    // {
    //     for (int j = 0; i + j <= n; j++)
    //     {
    //         cout << i << ":"<<j << "::" <<state[i][j].second << endl;
    //     }
    // }

    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; i + j <= n; j++)
        {
            rep(p, k-(i+j)){
                if (state[i][j].first.empty()) break;
                if (state[i][j].first.top() < 0){
                    state[i][j].second -= state[i][j].first.top();
                    state[i][j].first.pop();
                } else {
                    break;
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; i + j <= n; j++)
        {
            if (i + j > k) continue;
            ans = max(ans, state[i][j].second);
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 896
#include<stdio.h>
char a[28] = {"abcdefghijklmnopqrstuvwxyz"};
char b[27] = {};
char c[100] = {};
int i, j;
int d;

int main(){
	scanf("%s", c);
	for (i = 0; i < 100; i++){
		if (c[i] == NULL){
			break;
		}
		for (j = 0; j < 28; j++){
			if (c[i] == a[j]){
				b[j]++;
			}
		}
		}
	for (i = 0; i < 27; i++){
		if (b[i] % 2 == 0||b[i]%2==2){
			d++;
		}
		else{
		}
	}
	if (d == 27){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

ll MOD = 1000000007;

ll mypow(ll x, ll n) {
        ll ans = 1;
        while(n) {
                if(n & 1) ans = (ans * x) % MOD;
                x = (x * x) % MOD;
                n>>=1;
        }
        return ans;
}

int main(int, char**) {
	vector<ll> b(65, 0);
	int n; cin >> n;
	for (int i=0; i<n; i++) {
		ll a; cin >> a;
		for (int j=0; j<65; j++) {
			if (a & (1LL<<j)) b[j]++;
		}
	}
	ll ans = 0;
	for (int i=0; i<64; i++) {
		ll def = (mypow(2, i) * b[i]%MOD * (n - b[i])%MOD) % MOD;
		ans = (ans + def) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
        int n, i, max, min;
        long sum=0;
        scanf("%d", &n);
        int a[n];
        for(i=0;i<n;i++){
                scanf("%d", &a[i]);
                sum+=a[i];
        }
        max=a[0];
        min=a[0];
        for(i=1;i<n;i++){
                if(max<a[i])
                        max=a[i];
                if(min>a[i])
                        min=a[i];
        }
        printf("%d %d %ld\n", min, max, sum);
        return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

int main(){
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}

Measured memory_bytes: 256
a = input()
n = len(a)
flag = True
for i in range(1,n+1):
    if i%2 == 0 and (a[i-1]=='L' or a[i-1]=='U' or a[i-1]=='D'):
        pass
    elif i%2 == 1 and (a[i-1]=='R' or a[i-1]=='U' or a[i-1]=='D'):
        pass
    else:
        flag = False
        break
if flag == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
int n,m;
LL ans;
const int N=500010,mod=998244353;
LL jc[N],inv[N];
LL ksm(LL a,LL b,LL mod)
{
	LL res=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)res=res*a%mod;
	return res;
}
void YYCH()
{
	jc[0]=jc[1]=inv[0]=inv[1]=1;
	for(int i=1;i<=m;++i)jc[i]=jc[i-1]*i%mod;
	inv[m]=ksm(jc[m],mod-2,mod);
	for(int i=m-1;i>=1;--i)inv[i]=inv[i+1]*(i+1)%mod;
}
LL C(int n,int m){return jc[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	cin>>n>>m;if(n>m)swap(n,m);YYCH();
	for(int i=0;i<=n;++i)
		(ans+=(LL)(i&1?-1:1)*C(n,i)*C(m,i)%mod*jc[i]%mod*ksm(m+1,n-i,mod)%mod*ksm(n+1,m-i,mod))%=mod;
	cout<<(ans%mod+mod)%mod;
	return 0;
}

Measured memory_bytes: 8064