akhauriyash/Code-Regression huggingface dataset:
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
    
def solve():
    a,b,c,d = invr()
    print(max(a * c,b * d,a * d,b * c))
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m): 
        for j in range(n): 
            b[i][j] = a[j][i]
    return(b)

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

Measured memory_bytes: 62880
import java.util.*;

public class Main {
    public static void main(String[] args) {    
        Scanner sc=new Scanner(System.in);
      ArrayList<Oder<Integer>>po=new ArrayList<>(); 
      int n=sc.nextInt();
      int m=sc.nextInt();
      for(int i=0;i<n;i++)
      po.add(new Oder<Integer>(sc.nextInt(),sc.nextInt()));
      Collections.sort(po,new Comparator<Oder<Integer>>() {
			public int compare(Oder<Integer> a,Oder<Integer> b) {
				return a.cont.compareTo(b.cont);
			}
		});
		long ans=0;
		for(int i=0;i<m;i++){
		    if(po.get(0).weight==0){
		        po.remove(0);
		        ans+=po.get(0).cont;
		        po.get(0).weight--;
		    }
		    else {
		        ans+=po.get(0).cont;
		        po.get(0).weight--;
		    }
		}
      System.out.println(ans);
    }
}
class Oder<T>{
	public T cont;
	public int weight;
	public Oder(T t) {
		this.cont =t;
	}
	public Oder(T t,int w) {
		cont =t;
		weight=w;
	}
	public String toString() {
		return cont.toString()+":"+weight;
	}
}

Measured memory_bytes: 69280
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <bitset>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

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

#define MOD ( 1e9 + 7 )

using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

Graph G;
vector<int> res;

void dfs( int v, int p, int c )
{
	res[v] = c;	//	ノードvはcで塗る

	for ( auto &&e : G[v] )	//	ノードvに繋がっているノード全部
	{
		if ( e.F == p )
		{
			// 親は考慮不要
			continue;
		}
		if ( e.S % 2 )
		{
			// 繋がってるノードへの距離が奇数
			dfs( e.F, v, c ^ 1 );	//	子は違う色にする
		}
		else
		{
			dfs( e.F, v, c );	//	偶数なので同じ色
		}
	}
}

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

	G.assign( N, vector<Edge>() );
	res.assign( N, 0 );

	rep( i, N - 1 )
	{
		int u, v, w;
		cin >> u >> v >> w;

		--u; --v;

		G[u].emplace_back( Edge( v, w ) );
		G[v].emplace_back( Edge( u, w ) );
	}

	// 計算
	dfs( 0, -1, 0 );

	// 出力
	for ( auto &&it : res )
	{
		cout << it << endl;
	}

	return ( 0 );
}


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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    i64 ans = 0, lo = 0;
    for (int i = 0; i < n; i++)
    {
        i64 a;
        cin >> a;
        i64 k = (a - 1) / (lo + 1);
        ans += k;
        if (a == lo + 1 || i == 0)
            lo++;
        //print(i, k, lo);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    n,m = LI()
    x = LI()
    y = LI()

    x.sort()
    y.sort()

    ysum = 0
    for j in range(1,m):
        ysum += j * (m-j) * (y[j]-y[j-1])

    ans = 0
    for i in range(1,n):
        ans = (ans + i * (n-i) * (x[i]-x[i-1]) * ysum) % MOD

    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 100068
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());

    int x = a[n - 1];

    int y = -1, z = -1;
    for (int i = 0; i < n - 1; i++) {
        int t = min(a[i], x - a[i]);
        if (t > z) {
            z = t;
            y = a[i];
        }
    }

    cout << x << ' ' << y << endl;

    return 0;
}

Measured memory_bytes: 640
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	var s = scala.collection.mutable.ListBuffer(Scanner.next.trim: _*)
	var rev_cnt = 0

	loop(0, Scanner.nextInt) { _ =>
		if (Scanner.nextInt == 1) rev_cnt += 1
		else if ((Scanner.nextInt + rev_cnt) % 2 == 1) s prepend Scanner.next.trim.charAt(0)
		else s append Scanner.next.trim.charAt(0)
	}

	pw.println( (if (rev_cnt % 2 == 0) s else s.reverse).mkString )
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 70576
#include<bits/stdc++.h>
using namespace std;
struct{
	double x, y;
}arr[9];
int main(){
	//ios_base::sync_with_stdio(0); cin.tie(0);
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		cin>>arr[i].x>>arr[i].y;
	}
	double ans=0;
	for(int i=1;i<=N;i++){
		for(int j=i+1;j<=N;j++){
			ans+=sqrt((arr[i].x-arr[j].x)*(arr[i].x-arr[j].x) + (arr[i].y-arr[j].y)*(arr[i].y-arr[j].y));
		}
	}
	ans=ans*(double)2/(double)N;
	printf("%.9lf\n",ans);
}

Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p = sorted(p, reverse=True)[:x]
q = sorted(q, reverse=True)[:y]

total = sorted(p+q+r, reverse=True)[:x+y]
print(sum(total))

Measured memory_bytes: 23328
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

bool hoge(pll a, pll b) {
	if(a.fi > b.fi) return true;
	else return false;
}
bool fuga(ll a, ll b) {
	if (a>b) return true;
	else return false;
}

int main() {
	int N,M;
	cin >> N >> M;
	vector<int> a(N);
	rep(i,N) cin >> a[i];
	sort(a.begin(),a.end());
	vector<pll> b(M);
	ll bt,ct;
	//cout << "test";
	rep(i,M) {
		cin >> bt >> ct;
		b[i] = pll(ct,bt);
	}
	//cout << "test2" << endl;
	sort(b.begin(), b.end(),hoge);
	int count = 0;
	vector<ll> c;
	rep(i,M) {
		rep(j, b[i].se) {
			c.pb(b[i].fi);
			count++;
		}
		if(count >= N) break;
	}
	sort(c.begin(), c.end(), fuga); 
	rep(i,min(N,count)) {
	//rep(i,N) {
		if(a[i] >= c[i]) break;
		a[i] = c[i];
	}
	ll ans = 0;
	rep(i,N) ans += a[i];
	cout << ans << endl;
	
  return 0;
}

Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e9)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)
 
const int mxn = 1*(1e5);
ll n, m;
 
void solve(){
    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    int dp[m+1][n+1] = {};
    for(int i=1; i<=m; i++) {
        for(int j=1; j<=n; j++) {
            dp[i][j] = max(dp[i-1][j-1] + ((t[i-1] == s[j-1])?1:0), max(dp[i-1][j], dp[i][j-1]));
        }
    }
    // for(int i=1; i<=m; i++) {
    //     for(int j=1; j<=n; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    string ans = "";
    int i=m, j=n;
    while(i||j) {
        if((dp[i][j] == dp[i-1][j])&&i>0) {
            // ans += t[i-1];
            i--;
            // j--;
        } else if((dp[i][j] == dp[i][j-1])&&j>0) {
            j--;
        } else {
            ans += t[i-1];
            i--, j--;
        }
        // if(i>1) {
        //     i--;
        // } else {
        //     j--;
        // }
    }
    // cout << i << " "<< j;
    reverse(ans.begin(), ans.end());
    cout << ans;
}
 
int main(){
    fast;
    //  tt
        solve();
}

Measured memory_bytes: 38756
while True:
    
    text = input()
    
    if text=='-' :
        break
    
    tlen = len(text)
    m = int(input())
    hlist = []
    
    for i in range(m):
        h = int(input())
        
        if tlen<=h :
            m -= 1
        
        else:
            hlist.append(h)
    
    tlist = list(text)
    
    for i in range(m):
        for k in range(hlist[i]):
            tlist.append(tlist[0])
            tlist.pop(0)
    
    text = ''.join(tlist)
    print(text)
    
    continue


Measured memory_bytes: 5600
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
	
    public static void main(String[] args)   throws Exception, IOException{        
        long mod=1000000007;
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int a[][][]=new int[n][][];
        
        for (int i = 0; i < a.length; i++) {
			a[i]=new int[sc.nextInt()][2];
			for (int j = 0; j < a[i].length; j++) {
				a[i][j][0]=sc.nextInt()-1;
				a[i][j][1]=sc.nextInt();
			}
		}
        int b[]=new int[n],r=0;

        lp:
        for (int i = 0,v; i < 1<<n; i++) {
        	v=0;
        	fill(b,0);
			for (int j = 0; j < n; j++) {
				if((i>>j)%2==1) {v++;b[j]=1;}
			}
			for (int j = 0; j < n; j++) {
				if(b[j]==0)continue;
				for (int t = 0; t < a[j].length; t++) {
					if(a[j][t][1]!=b[a[j][t][0]])continue lp;
				}
			}
			r=max(r,v);
		}

        out.println(r);
     	out.flush();
    }


    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//
//class P {
//	int x, y, d;
//	P(int  x, int y, int d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
        return -p.a+a;//as
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 22356
import java.util.Scanner
val scanner = Scanner(System.`in`)

fun main(args: Array<String>){
    var n = scanner.nextInt()
    val vol = Array<Int>(n, {0})
    for (i in 0 until n) {
        vol[i] += scanner.nextInt()
    }
    for (i in 0 until n) {
        vol[i] -= scanner.nextInt()
    }
    vol.sort()
    var ans = 0
    for (i in 1 .. n){
        val v = vol[n-i]
        if (v < 0) break
        ans += v
    }
    println(ans)
}





Measured memory_bytes: 34248
import math
MOD=10**9+7
MAX=10**6
sq_max=int(math.sqrt(MAX))

seive=[1 for _ in range(MAX+1)]
seive[0]=0
seive[1]=0
for i in range(sq_max+1):
  if seive[i]==0:
    continue
  for j in range(i*2,MAX+1,i):
    seive[j]=0

def factor(num):
  factordic={}
  for i in range(2,min([MAX+1,int(math.sqrt(num))+1])):
    if seive[i]==1 and num%i==0:
      factordic[i]=1
      num//=i
      while num%i==0:
        factordic[i]+=1
        num//=i
    if num==1:
      break
  else:
    factordic[num]=1
  return(factordic)


inv=[1,1]
for i in range(2, MAX+1):
  inv.append(MOD - inv[MOD % i] * (MOD // i) % MOD)

N=int(input())
ls=[int(s) for s in input().split()]
lcm={}
for num in ls:
  d=factor(num)
  for key,value in d.items():
    if key in lcm:
      lcm[key]=max(value,lcm[key])
    else:
      lcm[key]=value
lcmmod=1
for key,value in lcm.items():
  lcmmod=(lcmmod*(key**value))%MOD
invsum=0
for e in ls:
  invsum=(invsum+inv[e])%MOD
print((invsum*lcmmod)%MOD)

Measured memory_bytes: 51952
//B - *e**** ********e* *e****e* ****e**
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, K;
    string S;
    cin >> N >> S >> K;

    for (int i = 0; i < N; i++) {
        if (S.at(i) != S.at(K-1)) {
            S.at(i) = '*';
        }
    }

    cout << S << endl;
}

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 n, ao, ak;
	cin >> n >> ao >> ak;
    ll ans = n/(ao+ak);
    ll sa = n - ans*(ao+ak);
    ans *= ao;
    ans += min(ao, sa);
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
 
#define int long long
typedef pair<int, int> P;
 
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
 
/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/
 
//セグ木を用いたRMQ
const int MAX_N = 420000;
 
struct RMQ {
    int n, dat[2 * MAX_N - 1];
 
    void init(int n_) {
        n = 1;
        while (n < n_) n *= 2;
        for (int i = 0; i < 2 * n - 1; i++) dat[i] = LLONG_MAX;
    }
 
    void update(int k, int a) {
        k += n - 1;
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
 
    int query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return LLONG_MAX;
        if (a <= l && r <= b) return dat[k];
        else {
            int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};
 
typedef pair<int, P> seg;
RMQ rmq0, rmq1;
int N;
int p[220000], ap[220000];
 
// [l, r)
seg getSeg(int l, int r) {
    int pri;
    if (l % 2 == 0) pri = rmq0.query(l, r, 0, 0, rmq0.n);
    else  pri = rmq1.query(l, r, 0, 0, rmq1.n);
    return seg(pri, P(l, r));
}
 
signed main() {
    cin >> N;
    rmq0.init(N + 10), rmq1.init(N + 10);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        ap[p[i]] = i;
        if (i % 2 == 0) rmq0.update(i, p[i]);
        else rmq1.update(i, p[i]);
    }
    priority_queue<seg, vector<seg>, greater<seg>> pq;
    pq.push(getSeg(0, N));
    for (int i = 0; i < N / 2; i++) {
        seg cur = pq.top(); pq.pop();
        int l = cur.second.first, r = cur.second.second;
        int mid = ap[cur.first];
        cout << cur.first << " ";
        if (l != mid) pq.push(getSeg(l, mid));
        int pri;
        if ((mid + 1) % 2 == 0) pri = rmq0.query(mid + 1, r, 0, 0, rmq0.n);
        else  pri = rmq1.query(mid + 1, r, 0, 0, rmq1.n);
        cout << pri << " ";
        int nid = ap[pri];
        if (mid + 1 != nid)pq.push(getSeg(mid + 1, nid));
        if (nid + 1 != r)pq.push(getSeg(nid + 1, r));
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 16756
n = int(input())
x = input().split()
sumd = 0
for i in x:
  sumd += int(i)
p = int(sumd/n)+(sumd%n>=n/2)
sums = 0
for i in x:
  sums += (int(i)-p)*(int(i)-p)
print(sums)

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int n;
  int i,j,k,sw,c;
  int a[1000001]={};
  a[2]=1;
  j=1;
  for(i=3;i<1000000;i+=2){
    sw=0;
    for(k=2;k*k<=i;k++){
      if(a[k]==1)
	if(i%k==0){
	  sw=1;
	  break;
	}
    }
    if(sw==0)a[i]=1;
  }
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    c=0;
    for(i=2;i<=n/2;i++){
      if(a[i]==1)
	if(a[n-i]==1)
	  c++;
      if(i!=2)i++;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 4940
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define s second
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define f first
const ll N=4e5+5;
ll bexpo(ll x,ll n){
    if(n==0)return 1;
    else if(n%2==0)return bexpo(x*x,n/2);
    else return x*bexpo(x*x,(n-1)/2);
}
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);} 
int Arr[N];
void initialize()
{
    for(int i = 0;i<N;i++)
    Arr[ i ] = i ;
}
int root(int i)
{
    while(Arr[ i ] != i)       
    {
     i = Arr[ i ];
    }
    return i;
}

void unio(int A ,int B)
{
    int root_A = root(A);       
    int root_B = root(B);  
    if(root_A<root_B)
        Arr[ root_A ] = root_B ;    
    else
        Arr[root_B]=root_A;
}
bool find(int A,int B)
{
    if( root(A)==root(B) )    
    return true;
    else
    return false;
}
ll dp[N];
vector<ll> adj[N];
ll dfs(ll node)
{
   if(dp[node]!=-1)
         return dp[node];
     ll mx=0;
    for(auto i:adj[node])
      mx=max(mx,dfs(i)+1);
     dp[node]=mx;
     return mx;
}
int main() {
FIO;
  ll n,m,ans=0,i;
  cin>>n>>m;
  ll x,y;
  while(m--)
  {
     cin>>x>>y;
     adj[x].pb(y);
  }
 for(i=1;i<=n;i++)
   dp[i]=-1;
  for(i=1;i<=n;i++)
    {
       ans=max(ans,dfs(i));
    }
    cout<<ans;
}

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

int main() {
    int n; cin >> n;
    vector<bool> is_prime(55555, true);
    vector<int> prime;
  
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i <= 55555; ++i){
        if(is_prime[i]) {
            prime.push_back(i);
            is_prime[i] = false;
            for(int j = i*2; j <= 55555; j += i) is_prime[j] = false;
        }
    }

    int idx = 0;
    while(n) {
        while(true){
            if(prime[idx]%5==1) break;
            ++idx;
        }
        cout << prime[idx++] << (--n==0 ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n: Int = readLine()!!.toInt()
    val v: List<Int> = readLine()!!.split(" ").map(String::toInt)
    val c: List<Int> = readLine()!!.split(" ").map(String::toInt)
    var ans: Int = 0

    (0 until 1.shl(n)).forEach { bit ->
        var f: Int = 0
        (0 until n).forEach { i ->
            if (bit.shr(i).and(1) == 1) f += v[i] - c[i]
        }
        if (f > ans) ans = f
    }
    println(ans)
}

Measured memory_bytes: 52752
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

ll mod=1000000007;
const int SIZE=510000;
ll fac[SIZE], finv[SIZE], inv[SIZE];
void COMinit(ll m){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2; i<SIZE; ++i){
        fac[i]=(fac[i-1]*i)%m;
        inv[i]=m-(inv[m%i]*(m/i))%m;
        finv[i]=(finv[i-1]*inv[i])%m;
    }
}
ll COM(int n, int k, ll m){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return (fac[n]*((finv[k]*finv[n-k])%m))%m;
}

int main() {
	int n, k;
	cin >> n >> k;
	COMinit(mod);
	ll ans=0;
	for(int i=0; i<=min(n-1, k); ++i){
		ll t=(COM(n, i, mod)*COM(n-1, i, mod))%mod;
		ans=(ans+t)%mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12160
def main():

    S = list(input())
    T = list(input())

    d = dict()
    d_inv = dict()
    for i in range(len(S)):
        if S[i] not in d:
            if T[i] in d_inv:
                return "No"
            else:
                d[S[i]] = T[i]
                d_inv[T[i]] = S[i]
        else:
            if d[S[i]] != T[i]:
                return "No"
    return "Yes"
        
if __name__ == '__main__':
    print(main())


Measured memory_bytes: 6704
#include<stdio.h>                                                 
#include<string.h>                                                
                                                                  
int main(void){                                                   
   char S[10];                                                    
   char T[strlen(S)+1];                                           
   int i = 0;                                                     
   scanf("%s",S);                                                 
   scanf("%s",T);                                                 
                                                                  
   int ok = 0;                                                    
                                                                  
   while(S[i] != '\0'){                                           
      if(S[i] != T[i]){                                           
         ok++;                                                    
         break;                                                   
      }                                                           
      i++;                                                        
   }                                                              
                                                                  
   if(ok == 0){                                                   
      printf("Yes");                                              
   } else{                                                        
      printf("No");                                               
   }                                                              
   return 0;                                                      
} 

Measured memory_bytes: 1732
#define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <math.h> //円周率はM_PI
#include <map>
#include <bitset>
using namespace std;





int main() {

	int k;
	cin >> k;
	int a, b;
	cin >> a >> b;
	
	bool flag = false;
	for (int i = a; i <= b; i++) {
		if (i%k == 0) {
			flag = true;
			break;
		}

	}
	if (flag) {
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

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

		    int a = sc.nextInt();
		    int b = sc.nextInt();

		    int ans1 = a+b;
		    int ans2 = a-b;
		    int ans3 = a*b;
		    int ans =0;

		    if(ans1>=ans2) {
		    	ans = ans1;
		    }else {
		    	ans = ans2;
		    }
		    if(ans3>=ans) {
		    	ans = ans3;
		    }

		    System.out.println(ans);

		    sc.close();
	}
}


Measured memory_bytes: 21588
#include "stdio.h"

int N, res[100000];
long long int A[100000], sum = 0;

int main(void){
  scanf("%d\n", &N);
  for(int i = 0;i < N;i++){
    scanf("%lld ", &A[i]);
  }
  for(int i = 0;i < N;i++){
    sum += A[i];
  }
  for(int i = 0;i < (N - 1) / 2;i++){
    sum -= A[1 + i * 2] * 2;
  }
  res[0] = (int)sum;
  for(int i = 1;i < N;i++){
    res[i] = (int)A[i - 1] * 2 - res[i - 1];
  }
  for(int i = 0;i < N;i++){
    printf("%d ", res[i]);
  }
}

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

#define pb push_back
#define rb  pop_back
#define rf  pop_front
#define ins insert
#define f   first
#define s   second
#define um  unordered_map
#define us  unordered_set
#define pq  priority_queue

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< long long int ,long long int > iil;
typedef long long ll;
typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef vector<double> vd;
typedef pair<double,double> pd;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef us<int> si;
typedef us<double> sd;
typedef us<ll> sll;
typedef vector<vd> md;


const ll MAX = 1e5+5;
const int N = 200043;
const int MOD = 998244353;

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for( auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define EE '\n'
#define PI 3.14159265
#define g(a,b) a>b?a:b
#define l(a,b) a<b?a:b
#define SOT(A) sort(A.begin(),A.end())
#define SOTR(A) sort(A.rbegin(),A.rend())
#define REV(a) reverse(ALL(a))

// LOOP Control Statements
#define forn(i,j,n) for ( auto i=j ; i<n ; i++ )
#define fornd(i,j,n) for ( auto i=j ; i>n ; i-- )
#define FORE(i, b) for(auto &i:b)


#define SQ(i) (i*i)
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define tcase(term) int tc;cin>>tc;for(int term=0; cout<<EE,term<tc;term++)


int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	// IO
 //    tcase(term)
    {

        vl res(1000001,1e9+1);
        res[0]=0;
        ll N,W;
        cin>>N>>W;
        ll c,b;
        forn(i,0,N){
        	cin>>c>>b;
        	fornd(j,100000,b-1){
        		res[j]=min(res[j],res[j-b]+c);
        	}
        }
        fornd(i,100000,0){
        	if(res[i]<=W){
        		cout<<i<<EE;
        		break;
        	}
        }

    }
}



Measured memory_bytes: 8064
#include<stdio.h>
#include<stdlib.h>
#define Array_MAX 10000

void countingSort(short *A,short *B,int n){
  int i,j;
  int C[Array_MAX+1];

  for(i=0;i<=Array_MAX;i++)
    C[i] = 0;
  for(j=1;j<=n;j++)
    C[A[j]]++;
  for(i=1;i<=Array_MAX;i++)
    C[i] = C[i] + C[i-1];
  for(j=1;j<=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}

int main(){
  unsigned short *A, *B;
  int n,i;

  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=1;i<=n;i++)
    scanf("%hd",&A[i]);
  
  countingSort(A,B,n);

  for(i=1;i<n;i++)
    printf("%hd ",B[i]);
  printf("%hd\n",B[n]);

  return 0;
}
    
  

Measured memory_bytes: 8456
import sys
n,m = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(m)]
 
b=[pow(10,n-1)]#先頭が指定されない場合の最小値を予め入れておく
count=0
for i in range(0,m):
    
    if A[i][0]==1 and A[i][1]==0 and n>1:#n>1かつ先頭に0が来たら-1
        print(-1)
        sys.exit()
    else:
        b.append(A[i][1]*pow(10,n-A[i][0]))
        if n-A[i][0]==n-1:
            count+=1

if count>0 or n==1:#先頭が指定された場合(count>0)は最小値を削除
    b.remove(pow(10,n-1))

if n>1:
    b=[i for i in b if i != 0]#0が指定された場合は0を削除する

b=list(set(b))
 
c=[]
for i in range(len(b)):
    c.append(len(str(b[i])))
    
c=list(set(c))
 
if len(b)==len(c) and len(str(sum(b)))==n:
    print(sum(b))
else:
    print(-1)

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c, d = map(int, input().split())
    res = max(a * c, b * c, a * d, b * d)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9168
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    string s,t;
    cin >> s >> t;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i])ans++;
    }
    cout << ans << endl;
}

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




Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>

using namespace std;
const double PI = (acos(-1));
const long long MOD = pow(10, 9) + 7;
long long kaizyou(int N);
long long POW(int J);

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

    cout << r*r*3;
    

}


Measured memory_bytes: 3628
n = int(input())
k = n%8
t = n//8
if n == 3:
  print(*[2,5,63])
  quit()
ans = [[2,3,4,6,8,9,10,12],[6],[3,9],[3,6,9],[2,3,9,10],[2,3,6,9,10],[2,3,4,8,9,10],[2,3,4,6,8,9,10]][k]
if k == 0:
  for i in range(1,t):
    ans.append(i * 12 + 2)
    ans.append(i * 12 + 3)
    ans.append(i * 12 + 4)
    ans.append(i * 12 + 6)
    ans.append(i * 12 + 8)
    ans.append(i * 12 + 9)
    ans.append(i * 12 + 10)
    ans.append(i * 12 + 12)
else:
  for i in range(1,t+1):
    ans.append(i * 12 + 2)
    ans.append(i * 12 + 3)
    ans.append(i * 12 + 4)
    ans.append(i * 12 + 6)
    ans.append(i * 12 + 8)
    ans.append(i * 12 + 9)
    ans.append(i * 12 + 10)
    ans.append(i * 12 + 12)
print(*ans)

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

using namespace std;

int main()
{
	int inp[3];
	for(int i = 0; i < 3; i++)
		scanf("%d", &inp[i]);
	
	bool ok = false;
	if(inp[0] + inp[2] == inp[1])
		ok = true;
	if(inp[0] + inp[1] == inp[2])
		ok = true;
	if(inp[1] + inp[2] == inp[0])
		ok = true;
	
	printf("%s\n", ok ? "Yes" : "No");
	
	return 0;
}


Measured memory_bytes: 256
import sys
import socket

hostnames = ['N551J', 'F551C', 'X553M']
input_file = 'e1.in'
if socket.gethostname() in hostnames:
    sys.stdin = open(input_file)


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


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()

inf = 10 ** 9
inf = 10 ** 3

def solve():
    n = read_int()
    a = read_int_list()
    b = [(a[i], i) for i in range(n)]
    b.sort()
    best = [[-inf] * (n + 1) for i in range(n + 1)]
    best[0][0] = 0
    for s in range(1, n + 1):
        for x in range(s + 1):
            y = s - x
            ai, i = b[-s]
            if x > 0:
                c = best[x - 1][y] + (n - x) * ai - i * ai
                if c > best[x][y]:
                    best[x][y] = c
            if y > 0:
                c = best[x][y - 1] - (y - 1) * ai + i * ai
                if c > best[x][y]:
                    best[x][y] = c

    # for i in range(n + 1):
    #     for j in range(n + 1):
    #         print(best[i][j], end='\t')
    #     print()

    res = - inf
    for x in range(n):
        y = n - x
        if res < best[x][y]:
            res = best[x][y]
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


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

int main(){
	int k, s;
	cin >> k >> s;

	int ans = 0;
	for(int i = 0; i <= k; i++){
		for(int j = 0; j <= k; j++){
			int kari = s - i - j;
			if(0 <= kari && kari <= k)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
	int a, b, i;
	while(scanf("%d", &a) != 0){
		if(a == 0) break;
		for(i = 0; i < 9; i++){
			scanf("%d", &b);
			a -= b;
		}
		printf("%d\n", a);
	}
	return 0;
}

Measured memory_bytes: 1028
n = int(input())
all = int((1+n)*n/2)
count1 = int(n/3)
count2 = int(n/5)
count3 = int(n/15)
print(int(all-(1+count1)*count1/2*3-(1+count2)*count2/2*5+(1+count3)*count3/2*15))

Measured memory_bytes: 9184
#include<stdio.h>
#define N 1000

int main(){
  int gyou=0;
  int retu[N];
  int temp=0;
  int i=0,j=0,k=0;
  
  scanf("%d",&gyou);
  
  for(i=0;i<gyou;i++){
    scanf("%d",&retu[i]);
  }

  for(i=0;i<gyou-1;i++){
    printf("%d ",retu[i]);
  }
  printf("%d\n",retu[gyou-1]);
  
  for(i=1;i<gyou;i++){
    temp=retu[i];
    j=i-1;
    while((j>=0) && (retu[j]>temp)){
      retu[j+1]=retu[j];
      j--;
      retu[j+1]=temp;
    }
    for(k=0;k<gyou-1;k++){
      printf("%d ",retu[k]);
    }
    printf("%d\n",retu[gyou-1]);
  }
  return 0;
}



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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

struct L {
  int back, front;
  bool f;
};
int n, m, q;
vector<L> a(200001);

int main() {
  cin >> n >> m >> q;

  rep(i, 0, n) {
    a[i].front = i + 1;
    a[i].back = i - 1;
    a[i].f = true;
    if(i == 0) a[i].back = n - 1;
    if(i == n - 1) a[i].front = 0;
  }

  int p = 0;
  rep(i, 0, m) {
    int b;
    cin >> b;
    rep(j, 0, b) {
      if(b % 2) p = a[p].back;
      else p = a[p].front;
    }

    a[p].f = false;
    a[a[p].back].front = a[p].front;
    a[a[p].front].back = a[p].back;
    p = a[p].front;
  }

  rep(i, 0, q) {
    int b;
    cin >> b;
    cout << (a[b].f ? 1 : 0) << endl;
  }
}

Measured memory_bytes: 5140
#!/usr/bin/python2
# -*- coding: utf-8 -*-

import sys
from fractions import gcd

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def solve(A, B, C, D):
    if B > A:
        return False
    if B > D:
        return False
    if B <= C+1:
        return True
    A %= B
    #if A > C:
    #    return False
    g = gcd(B, D)
    k = (B-A) / g - 1
    if (B-A) % g:
        k += 1
    return A + k * g <= C


def main():
    T = rl(int)
    for t in xrange(1, T+1):
        A, B, C, D = srl(int)
        print "Yes" if solve(A, B, C, D) else "No"

if __name__ == '__main__':
    main()


Measured memory_bytes: 4392
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
        // Your code here!
        int N = int.Parse(Console.ReadLine());
        int[] array = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
        List<int> list = new List<int>();
        list.Add(0);
        list.AddRange(array);
        list.Add(0);
        var sum = 0;
        for(var i=1;i<N+2;i++){
            sum += Math.Abs(list[i] - list[i-1]);
        }
        int dif;
        for(var i=0;i<N;i++){
            dif = Math.Abs(list[i+1] - list[i]) + Math.Abs(list[i+2] - list[i+1]) - Math.Abs(list[i+2] - list[i]);
            Console.WriteLine(sum - dif);
        }
    }
}


Measured memory_bytes: 29660
#include <iostream>

using namespace std;

int adj[300][300];

int main(){

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

  bool solveFlg = true;
  long long int result = 0;
  for(int i=0;solveFlg&&i<N;i++){
    for(int j=i+1;solveFlg&&j<N;j++){
      bool pathFlg = false;
      for(int k=0;k<N;k++){
        if(k!=i&&k!=j){
          if(adj[i][k]+adj[k][j]==adj[i][j]){
            pathFlg = true;
          } else if(adj[i][k]+adj[k][j]<adj[i][j]){
            solveFlg = false;
          }
        }
      }
      if (!pathFlg) result += adj[i][j];
    }
  }

  if (solveFlg) {
    cout << result << endl;
  } else {
    cout << "-1" << endl;
  }

  return 0;
}


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

int main ()
{
    int num1 , num2 , maxm , minm , res = 0 ;

    cin >> num1 >> num2 ;

    maxm = max (num1 , num2 ) ;
    minm = min (num1 , num2 ) ;

    if (maxm < 3 )
    {
        res = maxm + minm ;
    }
    else if (maxm == 3 )
    {
        res = maxm - minm ;
    }

    cout << res << endl ;

    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<ll>> dp(h,vector<ll>(w,0));
    rep(i,h){
        rep(j,w){
            char t;cin>>t;
            if(t=='#')  dp[i][j]=-1;
        }
    }
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            if(i==0&&j==0)  continue;
            if(dp[i][j]<0)  continue;
            if(i==0){
                dp[0][j]=dp[0][j-1];
            }
            else if(j==0){
                dp[i][0]=dp[i-1][0];
            }
            else{
                if(dp[i-1][j]>=0)   dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
                if(dp[i][j-1]>=0)   dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vector<vector<ll>> dp(5, vector<ll>(n, 0));
	for (ll i = 0; i < 4; i++) {
		dp[i][0] = 1;
		dp[i][1] = 4;
		dp[i][2] = 16;
	}
	dp[4][0] = 4;
	dp[4][1] = 16;
	dp[1][2] -= 2;
	dp[2][2]--;
	for (ll i = 0; i < 4; i++) dp[4][2] += dp[i][2];

	for (ll j = 3; j < n; j++) {
		for (ll i = 0; i < 4; i++) dp[i][j] = dp[4][j - 1];
		dp[1][j] -= (dp[0][j - 2] + dp[2][j - 2]) % p;
		if (dp[1][j] < 0) dp[1][j] += p;
		dp[2][j] -= (dp[0][j - 2] - dp[2][j - 3] + ((dp[0][j - 2] < dp[2][j - 3])?p:0)) % p;
		if (dp[2][j] < 0) dp[2][j] += p;
		dp[1][j] -= dp[0][j - 3] * 3 % p;
		if (dp[1][j] < 0) dp[1][j] += p;
		for (ll i = 0; i < 4; i++) {
			dp[4][j] += dp[i][j];
			dp[4][j] %= p;
		}
	}
	cout << dp[4][n - 1] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

long long gcd(long long a, long long b);

int main(void){
    long long A,B,C,D;
    scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
    long long LCM=C*D/gcd(C,D);
    long long  retval = B-A-(B/C + B/D - B/LCM - ((A-1)/C+(A-1)/D - (A-1)/LCM))+1;
    printf("%lld\n",retval);
}

long long gcd(long long a, long long b){
    long long m,M;
    if(a>=b){
        m=b;
        M=a;
    }
    else{
        m=a;
        M=b;
    }
    if(m==0){return M;}
    else{return gcd(m,M%m);}
}


Measured memory_bytes: 128
import collections
n=int(input())
v=list(input().split())
ans=0

even=[v[i] for i in range(n) if i%2 == 0]
odd=[v[i] for i in range(n) if i%2 == 1]

ep=collections.Counter(even).most_common()
op=collections.Counter(odd).most_common()
ep.append((0,0))
op.append((0,0))

if ep[0] != op[0]:
    ans=n-(ep[0][1]+op[0][1])
else:
    if len(even)-ep[1][1]<len(odd)-op[1][1]:
        ans=n-ep[1][1]-op[0][1]
    else:
        ans=n-ep[0][1]-op[1][1]
print(ans)        

Measured memory_bytes: 23516
X = [1, 2, 3, 4, 5, 6, 7, 8, 9]
A = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(9):
    B = []
    for a in A:
        r = a % 10
        if r > 0:
            B.append(10*a+r-1)
        if r < 9:
            B.append(10*a+r+1)
        B.append(10*a+r)
    X = X+B
    A = B
X.sort()
k = int(input())
print(X[k-1])


Measured memory_bytes: 54128
s=list(input())
n=len(s)
s_in_not = [a for a in s[1:] if 'C' not in a]
s_not = ''.join(s_in_not)
s_not.islower()
if not s[0]=='A':
    print("WA")
elif not s[2:n-1].count("C")==1:
    print("WA")
elif not s_not.islower()==True:
    print("WA")
else:
    print("AC")

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	char S[100001];
	scanf("%s", S);
	int N = strlen(S);
	int nokori = N - 1;
	int saigo = N;
	int kaisuu = (N - 2) / 2;
	int base = 2;
	if (S[0] == '0' || S[N - 1] == '1' || S[N - 2] == '0') {
		printf("-1");
	}
	else {
		rep1(i, kaisuu) if (S[i] != S[N - i - 2]) {
			printf("-1");
			return 0;
		}
		putint(1);
		putint(2);
		nokori--;

		rep(i, kaisuu) {
			if (S[i + 1] == '0') {
				putint(base);
				putint(saigo);
				saigo--;
				nokori--;
			}
			else {
				putint(base);
				putint(base + 1);
				base++;
				nokori--;
			}
		}
		rep1(i, nokori) {
			putint(base);
			putint(base + i);
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    vector<int> vec;
    int cnt = 1;
    rep (i, 1, n) {
        if (s[i - 1] != s[i]) {
            vec.push_back (cnt);
            cnt = 1;
        } else {
            cnt++;
        }
    }
    vec.push_back (cnt);
    // cout << vec.size() << "\n";
    // rep (i, 0, vec.size()) cout << vec[i] << " ";
    // cout << "\n";
    //累積和
    int sum[vec.size()];
    sum[0] = 0;
    rep (i, 0, vec.size()) sum[i + 1] = sum[i] + vec[i];
    //計算
    if (vec.size() <= k * 2) {
        cout << n << "\n";
        return 0;
    }
    int res = 0;
    if (s[0] == '0') res = sum[k * 2];
    for (int i = s[0] == '1' ? 0 : 1; i < vec.size() - 2 * k; i += 2) {
        int ans;
        ans = sum[i + k * 2 + 1] - sum[i];
        res = max (ans, res);
    }
    res = max (res, sum[vec.size()] - sum[vec.size() - 2 * k]);
    cout << res << "\n";
}

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

int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")
        cout<<"Cloudy"<<endl;
    else if(s=="Cloudy")
        cout<<"Rainy"<<endl;
    else if(s=="Rainy")
        cout<<"Sunny"<<endl;

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    ll A, V, B, W, T; cin >> A >> V >> B >> W >> T;
    if(A>B) swap(A,B);
    if(A+V*T<B+W*T) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 3596