akhauriyash/Code-Regression huggingface dataset:
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){var t=e.split("\n"),r=Number(t[0]),n=t[1].split(" ").map(function(e){return Number(e)});n.sort(function(e,t){return e-t});var o=Math.floor(r/2),u=n[o]-n[o-1];console.log(u)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 28264
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int digit_sum(int n,int a) {
    int ret = 0;
    while(n > 0) {
        ret += n%a;
        n /= a;
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int s = digit_sum(n,10);
    cout << (n%s == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
  
public class Main implements Runnable {
     
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }
     
    public void run() {
        FastScanner sc = new FastScanner();
         
        int n = sc.nextInt();
        int k = sc.nextInt();
 
         
        if(n<=k){
            System.out.println(1);
        }
        else{
            System.out.println(0);
        }
    }
}
 
 
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public int[] nextIntArray(int n){
        int[] a = new int[n];
        for(int i=0;i<n;i++){
            a[i] = nextInt();
        }
        return a;
    }
    public Integer[] nextIntegerArray(int n){
        Integer[] a = new Integer[n];
        for(int i=0;i<n;i++){
            a[i] = nextInt();
        }
        return a;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 24496
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long numA = scan.nextLong();
		long numB = scan.nextLong();
		long numX = scan.nextLong();

		System.out.println((numB / numX) - (numA != 0 ? (numA - 1L)  / numX : -1L));
	}
}


Measured memory_bytes: 23124
#include <stdio.h>
#define rep(i, n) for (i = 0; i < n; i++)
 
int main() {
    int c, a = -1, z = -1, i;
    for (i = 0; (c = getchar()) != '\n'; i++) {
        if (c == 'A' && a == -1) a = i;
        if (c == 'Z' && z < i) z = i;
    }
    printf("%d\n", z - a + 1);
    return 0;
}

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

int main()
{
    int N;
    int A;
    int Q;
    int B;
    int C;
    int c;
    int64_t sum = 0;

    vector<int> count(100001);
  	cin >> N;
    for (int i = 0; i < N; i++){
        cin >> A;
        count.at(A) ++;
        sum += A;
    }
    cin >> Q;
    for(int j = 0; j < Q; j++){
        cin >> B >> C;
        c = count.at(B);
      	count.at(B) = 0;
      	count.at(C) += c;
        sum = sum + c * (C-B); 
        cout << sum << endl;
    }
    
    
}

Measured memory_bytes: 3708
#!usr/bin/env python3
from collections import defaultdict
import math
import bisect
import random
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return list(input())
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A

#B

#C
def gcd(a,b):
    if a == 0:
        return b
    return gcd(b%a,a)
n = II()
a = LI()
ans = a[0]
for i in range(1,n):
    ans = gcd(ans,a[i])
print(ans)
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 63344
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        int a[] = new int[n];
        int sum = x;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            sum += 1 + (d - 1) / a[i];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 22868
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int n,m,x,y; cin>>n>>m>>x>>y;
  int xm=-200;
  int ym=200;
  rep(i,0,n){
    int c; cin>>c;
    xm=max(c,xm);
  }
  rep(i,0,m){
    int c; cin>>c;
    ym=min(c,ym);
  }
  if(xm<ym&&xm<y&&ym>x)cout<<"No War"<<endl;
  else cout<<"War"<<endl;
  return 0;
}


Measured memory_bytes: 256
def f():
    p,w = input()
    for w0 in R[w:]:
        w1,p1 = w0+w,dt[w0]+p
        if dt[w1]<p1: dt[w1]=p1
    return

c = 0
while 1:
    W = input()
    if W==0: break
    R = range(W+1)[::-1]
    dt = [0]*1001
    c += 1
    N = input()
    for i in range(N): f()
    m = max(dt)
    n = dt.index(m)
    print "Case {}:\n{}\n{}".format(c,m,n)

Measured memory_bytes: 4312
#include<iostream>
#include<cstring>
#include<iomanip>
using namespace std;
const int maxn=10005;
const int MOD=1e9+7;
double dp[maxn][maxn];
int n,m;
double a[maxn],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=dp[i-1][0]*(1-a[i]);
		for(int j=1;j<=i;j++)
		{
			dp[i][j]=dp[i-1][j-1]*a[i]+dp[i-1][j]*(1-a[i]);
		}
	}
	for(int i=n/2+1;i<=n;i++)
	{
		ans+=dp[n][i];
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 50904
#include <iostream>

using namespace std;

typedef long long ll;

const ll MAX_N = 100000, MAX_A = 1000000000;

long long gcd(long long x, long long y){
  if(y == 0) return x;
  return gcd(y,x%y);
}


int main(int argc, char const *argv[]) {
  ll n, k, a[MAX_N], maxel = 0;
  cin >> n >> k;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    maxel = max(maxel,a[i]);
  }
  ll g = a[0];
  for (ll i = 1; i < n; i++) g = gcd(g,a[i]);
  if (k<=maxel && k%g==0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<uint64_t> v;
    v.push_back(2);
    v.push_back(1);
    rep(i,2,N+1){
        v.push_back(v.at(i-1)+v.at(i-2));
    }

    cout<<v.at(v.size()-1)<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n); i >= 0; i--)
#define revrepr(i, a, b) for (int i = (a); i >= b; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

int main() {
    int n;
    cin >> n;
    map<int, int> m;
    rep(i, n) {
        int a;
        cin >> a;
        if (m[a] == 1) {
            cout << "NO" << endl;
            return 0;
        }
        m[a]++;
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>

using namespace std;

int main(){
	for(;;){
		unsigned long n,k;
		vector<int> a;
		cin>>n>>k;
		if(!n) return 0;
		int ai;
		for(unsigned long i=0;i<n;i++){
			cin>>ai;
			a.push_back(ai);
		}

		long sum=0,max=0;
		for(unsigned long i=0;i<k;i++){
			sum+=a[i];
		}
		max=sum;
		for(unsigned long i=1;i<n-k+1;i++){
			sum+=a[i+k-1]-a[i-1];
			if(max<sum) max=sum; 
		}
		cout<<max<<endl;
	}
	return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;cin>>N;
  
  double count=0;
  
  for(int i=1;i<=N;i++){
    if(i%2==1){
      count++;
    }
  }
  
  double ans=count/N;
  
  printf("%.8f",ans);
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vector<bool> a(n+1);
  vector<bool> b(n+1,false);
  vl ans;
  FOR(i,1,n+1){
    ll ai;
    cin >> ai;
    a[i] = ai==1;
  }
  FORR(i,1,n+1){
    bool t = false;
    for(ll j=i;j<=n;j+=i) t = t^b[j];
    if(t!=a[i]) {
      b[i] = true;
      ans.push_back(i);
    }
  }
  cout << ans.size() << endl;
  if(ans.size()>0){
    REP(i,ans.size()) cout << ans[i] << " ";
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 2296
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;
int main(){
    int a,b,c;cin >> a >> b >> c;
    if(c - (a -b) >= 0)cout << c - (a -b) << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
n=int(input())
p=[str(i) for i in input().split()]
p=','.join(p)
p=p.replace(",", "")
q=[str(i) for i in input().split()]
q=','.join(q)
q=q.replace(",", "")

r='1'
for i in range(2,n+1):
  r+=str(i)

List = []

for x in itertools.permutations(r):
  y=','.join(x)
  y=y.replace(",", "")
  List.append(y)
  
P=List.index(p)
Q=List.index(q)
print(abs(P-Q))

Measured memory_bytes: 6040
/*
    author:ujwalll
*/
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std; 
#define rep(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
const int INF = 1<<29;
const int MOD=1073741824;
#define pp pair<ll,ll>
#define ppi pair<int,int>
typedef long long int ll;
bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
////////////////////////////////////////////////////////////////////
set<int> adj[200005];
bool vis[200005];
int cnt=0;
void solve(int s){
    vis[s]=1;
    cnt++;
    for(auto i:adj[s]){
        if(vis[i])continue;
        solve(i);
    }
}
int main(){
    int tc=1;
    // cin>>tc;
    while(tc--){
        memset(vis,0,sizeof(vis));
        int n,m;
        cin>>n>>m;
        rep(i,m){
            int x,y;
            cin>>x>>y;
            adj[x].insert(y);
            adj[y].insert(x);
        }
        int ans=0;
        for1(i,n){
            if(!vis[i]){
                vis[i]=1;
                solve(i);
                ans=max(ans,cnt);
                cnt=0;
            }
        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 38152
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	long long N;
	cin >> N;

	vector<long long> a(N, 0);
	vector<long long> v(N, 0);

	cin >> a[0];
	v[0] = a[0];
	for (long long i = 1; i < N; i++) {
		cin >> a[i];
		v[i] = v[i - 1] + a[i];
	}

	long long v_min = 0;
	long long val;
	bool jdg = false;
	for (long long i = 0; i < N - 1; i++) {
		val = abs(2 * v[i] - v.back());
		if (val < v_min || jdg == false) {
			v_min = val;
			jdg = true;
		}
	}

	cout << v_min << endl;

	return 0;
}

Measured memory_bytes: 6420
from heapq import heappush, heappop
import sys
def solve():
    readline = sys.stdin.readline
    write = sys.stdout.write
    N, TI = map(int, readline().split())
    A, B = readline().split()
    S = []; T = []; X = []
    L = 0
    L = 0
    NA = set()
    for i in range(N):
        a = int(readline())
        *Si, = readline().split()
        *Ti, = map(int, readline().split())
        for s in Si:
            NA.add(s)
        X.append(a)
        S.append(Si); T.append(Ti)
        L += a
    M = len(NA); L += M
    MP = {e: i for i, e in enumerate(NA)}
    G = [[] for i in range(L)]
    cur = M
    INF = 10**18
    PN = 10**9
    for i in range(N):
        a = X[i]; Si = S[i]; Ti = T[i]
        prv = v = MP[Si[0]]
        G[v].append((cur, 1))
        G[cur].append((v, TI*PN))
        cur += 1
        for j in range(a-1):
            v = MP[Si[j+1]]; t = Ti[j]
            G[v].append((cur, 1))
            G[cur].append((v, TI*PN))
            G[cur-1].append((cur, t*PN))
            G[cur].append((cur-1, t*PN))
            cur += 1
            prv = v
    D = [INF]*L
    s = MP[A]; g = MP[B]
    D[s] = 0
    que = [(0, s)]
    while que:
        cost, v = heappop(que)
        if D[v] < cost:
            continue
        for w, d in G[v]:
            if cost + d < D[w]:
                D[w] = r = cost + d
                heappush(que, (r, w))
    if D[g] == INF:
        write("-1\n")
    else:
        d, k = divmod(D[g], PN)
        write("%d %d\n" % (d-TI, k-1))
solve()


Measured memory_bytes: 91208
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
int main()
{  
    int h , w;
    cin>>h>>w;
    char in[h][w];
    
    for(int i = 0 ; i < h ; i++){
    	for(int j = 0 ; j < w ; j++){
    		cin>>in[i][j];
		}
	}
	
	ll dp[h][w];
	dp[0][0] = 1;
	bool flag = true;
	for(int i = 1 ; i < w ; i++){
		if(in[0][i]=='#' && flag == true) flag = false;
		
		if(flag == false) dp[0][i] = 0;
		else dp[0][i] = 1;
	}
	flag = true;
	for(int i = 1 ; i < h ; i++){
		if(in[i][0]=='#' && flag == true) flag = false;
		
		if(flag == false) dp[i][0] = 0;
		else dp[i][0] = 1;
	}
    for(int i = 1 ; i < h ; i++){
		for(int j = 1 ; j <w ; j++){
			if(in[i][j] == '#'){
				dp[i][j] = 0;
			}
		}
	}
	for(int i = 1 ; i < h ; i++){
		for(int j = 1 ; j <w ; j++){
			if(in[i][j] == '.'){
				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
			}
		}
	}
	cout<<dp[h-1][w-1];
}



Measured memory_bytes: 9088
#include <bits/stdc++.h>
//#pragma GCC target("avx,avx2,sse4.2")
#define rep(q, a, b) for (int q = a, q##_end_ = b; q <= q##_end_; ++q)
#define dep(q, a, b) for (int q = a, q##_end_ = b; q >= q##_end_; --q)
#define mem(a, b) memset(a, b, sizeof a)
#define debug(a) cerr << #a << ' ' << a << "___" << endl
using namespace std;
// char buf[10000000], *p1 = buf, *p2 = buf;
#define Getchar() getchar()  // p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 10000000, stdin), p1 == p2) ? EOF : *p1++
void in(int &r) {
    static char c;
    r = 0;
    while (c = Getchar(), c < 48);
        ;
    do
        r = (r << 1) + (r << 3) + (c ^ 48);
    while (c = Getchar(), c > 47);
}
int val[200005],l_max[200005],r_max[200005];
int main(){
	int n;
	in(n);
	rep(q,1,n)in(val[q]);
	rep(q,1,n)l_max[q]=max(l_max[q-1],val[q]);
	dep(q,n,1)r_max[q]=max(r_max[q+1],val[q]);
	rep(q,1,n)printf("%d\n",max(l_max[q-1],r_max[q+1]));
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define ull unsigned long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define nl cout<<'\n'
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pll pair<long long,long long>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define sll set<long long>
#define all(v) (v).begin(),(v).end()
#define Unique(x)           (x).erase(unique(all(x)), x.end())
#define v_present(vec,x)  (find(all(vec),x)!=(vec).end())
#define present(myset,x)    ((myset).find(x)!=(myset).end())
#define Cprint(c)  for(auto i:(c)) { cout<<i<<" "; } nl
#define trace2(x,y) cout<<x<<" "<<y<<endl;
#define trace3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define trace4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<endl;
ll mod = 1e9+7;
const int MAX = 1e5+5;
using namespace std;

vll adj[100005];
ll ans[100005];
ll mini;


ll dfs(ll curr){
    ll &now = ans[curr];
    if(now!=-1)
        return now;
    now=0;
    for(int i=0;i<adj[curr].size();i++){
        now=max(now,dfs(adj[curr][i])+1);
    }

    return now;

}


int main()
{
    FAST_IO;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y; cin>>x>>y;
        adj[x].pb(y);
    }
    mini=0;
    memset(ans,-1,sizeof(ans));
    for(int i=1;i<=n;i++){
        mini=max(mini,dfs(i));
    }

    cout<<mini;

    return 0;

}


Measured memory_bytes: 8576
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX=200000;

int main(){
  int R[MAX],n;

  cin >> n;
  for(int i=0;i<n;i++)cin >> R[i];

  int maxv=-2000000000;
  int minv=R[0];

  for(int i=1;i<n;i++){
    maxv=max(maxv,R[i]-minv);
    minv=min(minv,R[i]);
  }
  cout << maxv << endl;

  return 0;
  
}

Measured memory_bytes: 3868
A = gets.chomp.chars
B = gets.chomp.chars

f = 0
if A.size > B.size then
  f = 1
elsif A.size < B.size then
  f = -1
else
  (0...A.size).each{|i|
    (f= 1; break) if A[i] > B[i]
    (f=-1; break) if A[i] < B[i]
  }
end

puts 'GREATER' if f == 1
puts 'LESS' if f ==-1
puts 'EQUAL' if f == 0


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {	
	
	private static int[] values = new int[100010];
	private static final int WOLF = 0 , SHEEP = 1;
	// o sheep both same
	// x wolf both same
	
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String input = scan.next() , ans = null;
		
		for (int i = 0;i < 2;i ++) {
			for (int j = 0;j < 2;j ++) {
				String temp = check(input , i , j);
				if (temp != null) {
					ans = temp;
					break;
				}
				if (ans != null)
					break;
			}	
		}
		if (ans == null)
			System.out.println(- 1);
		else
			System.out.println(ans);
		
	}
	
	private static int getValue(int current , int value , char ch) {
		
		if (current == WOLF) {
			if (ch == 'x') {
				return value;
			} else {
				return 1 - value;
			}
		} else {
			if (ch == 'o') {
				return value;
			} else {
				return 1 - value;
			}
		}
		
	}
	
	private static boolean check(int current , int left , int right , char ch) {
	
		if (current == WOLF) {
			if (ch == 'x') {
				if (left != right)
					return false;
			} else {
				if (left == right)
					return false;
			}
		} else {
			if (ch == 'o') {
				if (left != right)
					return false;
			} else {
				if (left == right)
					return false;
			}
		}
		return true;
		 
	}
	
	private static String check(String input , int value1 , int value2) {
		
		values[0] = value1;
		values[1] = value2;
		for (int i = 2;i < input.length();i ++) {
			values[i] = getValue(values[i - 1] , values[i - 2] , input.charAt(i - 1));
		}
		int length = input.length();
		for (int i = 0;i < length;i ++) {
			int left = (i == 0) ? (length - 1) : i - 1;
			int right = (i == length - 1) ? 0 : i + 1;
			char ch = input.charAt(i);
			if (!check(values[i] , values[left] , values[right] , ch)) {
				return null;
			}
		}
		StringBuilder builder = new StringBuilder();
		for (int i = 0;i < length;i ++) {
			if (values[i] == WOLF)
				builder.append("W");
			else
				builder.append("S");
		}
		return builder.toString();
		
	}
	
		
}














Measured memory_bytes: 26516
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
typedef long long ll;
typedef long double ld;

int a[200000+10];

int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    rep(i,0,n){
    	cin>>a[i];
    }
    if(n%2==0){
    	int i = n/2;
    	rep(j,0,i){
    		cout<<a[(2*(i-j))-1]<<" ";
    	}
    	rep(j,i,n){
    		cout<<a[2*(j-i)]<<" ";
    	}
    }	
    else{
    	int i = n/2;
    	rep(j,0,i){
    		cout<<a[(2*(i-j))]<<" ";
    	}
    	cout<<a[0]<<" ";
    	rep(j,i+1,n){
    		cout<<a[(2*(j-i))-1]<<"	 ";
    	}
    }
    cout<<endl;
}

Measured memory_bytes: 3072
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = [i for i in S()]

ss = list(set(s))

if len(ss) == 1:
  print("No")
elif s.count(ss[0]) == s.count(ss[1]) and len(ss) == 2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 21920
#include<stdio.h>
int main(){
    int m, f, r, i, sum = 0;
    for(;;){
        scanf("%d%d%d",&m, &f, &r);
        if( m == -1 && f == -1 && r == -1 ){
            break;
        }
        sum = m + f ;
        if( m == -1 || f == -1 || sum < 30 ){
            printf("F\n");
        }else if( sum >= 80 ){
            printf("A\n");
        }else if( sum <80 && sum >= 65 ){
            printf("B\n");
        }else if( sum < 65 && sum >= 50 || sum < 50 && sum >= 30 && r >= 50){
            printf("C\n");
        }else{
            printf("D\n");
        }
    }
    return 0;
}

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

int main()
{
	int n;

	cin >> n;

	while (n > 0) {

		int a[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
		for (int i = 0; i < n; i++) {
			int c;

			cin >> c;
			a[c]++;
		}

		for (int i = 0; i < 10; i++) {
			if (a[i] == 0)
				cout << "-" << endl;
			else {
				for (int j = 0; j < a[i]; j++)
					cout << "*";
				cout << endl;
			}
		}
		
		cin >> n;
	}
	
	return 0;
}


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

#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define endl "\n"
#define sz(x) ((ll)((x).size()))
const ll N=2e5+5,inf=1e9;
ll ary[N];
ll ans[N];
vll G[N];
ll n;
ll tree[4*N];
multiset<ll> res;
ll query(ll nd,ll st,ll ed,ll l,ll r)
{
	if(st>r||ed<l||st>ed)return 0;
	if(st>=l && ed<=r)
		return tree[nd];
	ll mid=(st+ed)/2;
	return max(query(2*nd,st,mid,l,r),query(2*nd+1,mid+1,ed,l,r));
}
ll update(ll nd,ll st,ll ed,ll id,ll val)
{
	if(st>id||ed<id)return tree[nd];
	if(st>=id&&ed<=id)
	{
		tree[nd]=val;
		return tree[nd];
	}
	ll mid=(st+ed)/2;
	tree[nd]= max(update(2*nd,st,mid,id,val),update(2*nd+1,mid+1,ed,id,val));
	return tree[nd];
}
 

ll dfs(ll a,ll p)
{
	ll x=query(1,0,n-1,0,ary[a-1]-1);
	ll pre=query(1,0,n-1,ary[a-1],ary[a-1]);
	res.insert(x+1);
	update(1,0,n-1,ary[a-1],x+1);
	ans[a]=*(--res.end());	
	lp(i,0,G[a].size())
	{
		ll x=G[a][i];
		if(x!=p)
			dfs(x,a);
	}
	update(1,0,n-1,ary[a-1],pre);
	res.erase(res.find(x+1));
	return 0;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin >> n;
	vll v;
	lp(i,0,n)
	{
		cin >> ary[i];
		v.pb(ary[i]);
	}	    
	map<ll,ll> M;
	sort(all(v));
	ll c=0;
	lp(i,0,n)
	{
		if(M.count(v[i])==0)
		{
			M[v[i]]=c++;
		}
	}
	lp(i,0,n)
	{
		ary[i]=M[ary[i]];
	}
	lp(i,0,n-1)
	{
		ll u,v;
		cin >>u >> v;
		G[u].pb(v);
		G[v].pb(u);
	}
	dfs(1,0);
	lp(i,0,n)
	{
		cout<<ans[i+1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 52912
#include<stdio.h>
#include<string.h>
int main()
{
	char s[15];
	gets(s);
	int n=strlen(s);
	int f=0;
	int sum=0;
	for(int i=0;i<n;i++){
		if(s[0]!='A'){
			f=1;
			break;
		}
		if(s[1]=='C'||s[n-1]=='C'){
			f=1;
			break;
		}
		else if(s[i]=='C'){
			sum++;
		}
		if(s[i]>'A'&&s[i]<'C'||s[i]>'C'&&s[i]<'Z'){
			f=1;
			break;
		}
	}
	if(sum==1&&f==0){
		printf("AC\n");
	}
	else printf("WA\n");
}

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

int main(){
  int N;
  cin >>N;
  vector <int>data(N);
  for(int i=0;i<N;i++){
    cin >> data[i];
  }
  int now = 101;
  int count = 0;
  sort(data.begin(),data.end(),greater<int>());
  for(int i=0;i<N;i++){
    if(now > data[i]){
      now = data[i];
      count++;
    }
    else if(now==data[i]){
    }
  }
  cout << count << endl;
}

    

Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#include "atcoder/all"
#else
#define NDEBUG
#include <atcoder/all>
#include <bits/stdc++.h>
#endif

using namespace std;
using namespace atcoder;
using large = long long;

int main()
{
    int n, m;
    cin >> n >> m; // 100'000
    auto d = dsu(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        d.merge(a, b);
    }
    auto roots = unordered_set<int>();
    for (int i = 0; i < n; ++i) {
        roots.emplace(d.leader(i));
    }
    auto count = roots.size();
    if (count > 0)
        --count;

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 7136
N = int(input())
S = sorted([int(a) for a in input().split()])
X = [1] + [0] * N

def popX(i0):
    for i in range(i0, N+1):
        if X[i]:
            X[i] -= 1
            return i
    return N+1
def addX():
    for l in L:
        for i in range(l+1, N+1):
            X[i] += 1

while S:
    a = S.pop()
    c = 1
    L = [popX(0)]
    while S and S[-1] == a:
        S.pop()
        c += 1
        L.append(popX(L[-1]))
    if L[-1] > N:
        print("No")
        break
    addX()
else:
    print("Yes")

Measured memory_bytes: 112460
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
int n, popcount[16399]; double x[16][2], y[16][2], dist[16][2][16][2], dp[16399][16][2];
int main() {
	for (int i = 0; i < 14; i++) {
		for (int j = 1 << i; j < 2 << i; j++) {
			popcount[j] = popcount[j - (1 << i)] + 1;
		}
	}
	int cnt = 0;
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) cin >> x[i][0] >> y[i][0] >> x[i][1] >> y[i][1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 2; j++) {
				for (int k = 0; k < n; k++) {
					for (int l = 0; l < 2; l++) {
						dist[i][j][k][l] = hypot(x[i][j] - x[k][l], y[i][j] - y[k][l]);
					}
				}
			}
		}
		for (int i = 0; i < 1 << n; i++) {
			for (int j = 0; j < n; j++) {
				dp[i][j][0] = dp[i][j][1] = 1.0e+10;
			}
		}
		for (int i = 0; i < n; i++) dp[1 << i][i][0] = dp[1 << i][i][1] = 0.0;
		for (int i = 1; i < 1 << n; i++) {
			if (popcount[i] == 1) continue;
			for (int j = 0; j < n; j++) {
				if (!(i & (1 << j))) continue;
				int sub = i - (1 << j);
				for (int k = 0; k < 2; k++) {
					for (int l = 0; l < n; l++) {
						if (!(sub & (1 << l))) continue;
						for (int m = 0; m < 2; m++) {
							dp[i][j][k] = min(dp[i][j][k], dp[sub][l][m] + dist[j][k ^ 1][l][m]);
						}
					}
				}
			}
		}
		double ret = 1.0e+10;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 2; j++) {
				ret = min(ret, dp[(1 << n) - 1][i][j]);
			}
		}
		for (int i = 0; i < n; i++) ret += dist[i][0][i][1];
		printf("Case %d: %.5lf\n", ++cnt, ret);
	}
	return 0;
}

Measured memory_bytes: 7280
#include <bits/stdc++.h>
using namespace std;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = 2147483647;

char board[110][110];
int cnt[110][110];
short mem[100][100][100][100]; // TODO: short?
int n, m;

#define Q(a,b,c,d) (cnt[b+1][d+1] - cnt[b+1][c] - cnt[a][d+1] + cnt[a][c])

int dp(int x0, int x1, int y0, int y1, int ax0, int ax1, int ay0, int ay1) {

    if (mem[x0][x1][y0][y1] != -1) {
        return mem[x0][x1][y0][y1];
    }

    int res = 0;
    if (x0 > 0) {
        int add = 0;
        int qx0 = max(x0-1, ax0),
            qx1 = min(x0-1, ax1),
            qy0 = max(y0, ay0),
            qy1 = min(y1, ay1);
        if (qx0 <= qx1 && qy0 <= qy1) add = Q(qx0, qx1, qy0, qy1);
        res = max(res, add + dp(x0-1, x1, y0, y1, ax0, ax1-1, ay0, ay1));
    }
    if (x1 < n-1) {
        int add = 0;
        int qx0 = max(x1+1, ax0),
            qx1 = min(x1+1, ax1),
            qy0 = max(y0, ay0),
            qy1 = min(y1, ay1);
        if (qx0 <= qx1 && qy0 <= qy1) add = Q(qx0, qx1, qy0, qy1);
        res = max(res, add + dp(x0, x1+1, y0, y1, ax0+1, ax1, ay0, ay1));
    }
    if (y0 > 0) {
        int add = 0;
        int qx0 = max(x0, ax0),
            qx1 = min(x1, ax1),
            qy0 = max(y0-1, ay0),
            qy1 = min(y0-1, ay1);
        if (qx0 <= qx1 && qy0 <= qy1) add = Q(qx0, qx1, qy0, qy1);
        res = max(res, add + dp(x0, x1, y0-1, y1, ax0, ax1, ay0, ay1-1));
    }
    if (y1 < m-1) {
        int add = 0;
        int qx0 = max(x0, ax0),
            qx1 = min(x1, ax1),
            qy0 = max(y1+1, ay0),
            qy1 = min(y1+1, ay1);
        if (qx0 <= qx1 && qy0 <= qy1) add = Q(qx0, qx1, qy0, qy1);
        res = max(res, add + dp(x0, x1, y0, y1+1, ax0, ax1, ay0+1, ay1));
    }

    // int qx0 = max(x0, ax0),
    //     qx1 = min(x1, ax1),
    //     qy0 = max(y0, ay0),
    //     qy1 = min(y1, ay1);
    // if (qx0 <= qx1 && qy0 <= qy1) {
    //     res += Q(qx0, qx1, qy0, qy1);
    // }
    return mem[x0][x1][y0][y1] = res;
}

int main() {
    cin >> n >> m;
    memset(cnt,0,sizeof(cnt));
    memset(mem,-1,sizeof(mem));
    rep(i,0,n) {
        rep(j,0,m) {
            cin >> board[i][j];
            if (board[i][j] == 'o') {
                cnt[i+1][j+1]++;
            }
            cnt[i+1][j+1] += cnt[i][j+1] + cnt[i+1][j] - cnt[i][j];
        }
    }

    // rep(i,0,n+1) {
    //     rep(j,0,m+1) {
    //         cout << cnt[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    rep(i,0,n) {
        rep(j,0,m) {
            if (board[i][j] == 'E') {
                cout << dp(i,i,j,j, 0,n-1, 0,m-1) << endl;
                return 0;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 195584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
struct segtree{
	using D = long long;
	D inf = 1e18;

	int N;
	vector<D> val;

	segtree(){}
	segtree(int n){
		N=1;
		while(N<n) N*=2;
		val.assign(N*2,-inf);
	}
	segtree(const vector<D>& ds){
		int n = ds.size();
		N=1;
		while(N<n) N*=2;
		val.assign(N*2,-inf);
		rep(i,n) val[i+N] = ds[i];
		for(int i=N-1;i>0;i--) val[i] = max(val[i*2],val[i*2+1]);
	}
	void assign(int k,D d){
		k+=N;
		val[k]=d;
		k/=2;
		while(k){
			val[k] = max(val[k*2],val[k*2+1]);
			k/=2;
		}
	}
	D getmax(int a,int b){
		D res = -inf;
		a+=N,b+=N;
		while(a<b){
			if(a&1) chmax(res,val[a++]);
			if(b&1) chmax(res,val[--b]);
			a/=2,b/=2;
		}
		return res;
	}
};
int N;
const int MN = 200100;
ll h[MN];
ll a[MN];
int main(){
	cin>>N;
	rep(i,N) cin>>h[i];
	{
		V<ll> hs;
		hs.pb(0);
		rep(i,N) hs.pb(h[i]);
		sort(all(hs));
		rep(i,N) h[i] = lower_bound(all(hs),h[i]) - hs.begin();
	}
	rep(i,N) cin>>a[i];
	segtree seg(N+1);
	seg.assign(0,0);
	rep1(i,N){
		ll val = a[i-1] + seg.getmax(0,h[i-1]);
		seg.assign(h[i-1],val);
	}
	cout<<seg.getmax(0,N+1)<<endl;
}

Measured memory_bytes: 7640
// 2011/01/08 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int b, r, g, c, s, t;
		cin >> b >> r >> g >> c >> s >> t;
		if(b==0&&r==0&&g==0&&c==0&&s==0&&t==0)
			break;

		int med = 100;

		med += (15+(15-2)*5)*b;
		med += (15+(15-2)*3)*r;
		med += 7*g;
		med += 2*c;

		med -= 3*(t-5*b-3*r-s);

		cout << med << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.math.BigDecimal;
	import java.util.ArrayList;
	import java.util.Collections;
	import java.util.Comparator;
	import java.util.HashMap;
	import java.util.List;
	import java.util.Scanner;
	import java.util.regex.Matcher;
	import java.util.regex.Pattern;
	
	
	public class Main {
		static Scanner sc = new Scanner(System.in);
	
		public static void main (String [] args){
			//		String [][] boad = new String[4][4];
			int n = Integer.parseInt(sc.next());
			int m = Integer.parseInt(sc.next());
			List <Integer> list = new ArrayList<Integer>();
			int total = 0;
			int c = 0;
			total = (n*m)/2;
			
			System.out.println(total);
			System.out.flush();
			sc.close();
		}
	}

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

int64_t gcd(int64_t a, int64_t b)
{
    if (a < b)
    {
        swap(a, b);
    }
    while (b != 0)
    {
        int64_t t = a % b;
        a = b;
        b = t;
    }
    return a;
}

int main()
{
    int64_t A, B;
    cin >> A >> B;
    int64_t g = gcd(A, B);
    cout << A * B / g << endl;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <cmath>

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  if(A == 0){
    cout << 0 << endl;
    return 0;
  }
  ll sum = N / (A+B) * A;
  ll amari = N % (A+B);
  if(amari <= A) sum += amari;
  else sum += A;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3192
import math

n = int(input())
towns = [list(map(int, input().split())) for _ in range(n)]
ans = 0
c = 0
for i in range(n-1):
    x1, y1 = towns[i]
    for j in range(i+1, n):
        x2, y2 = towns[j]
        ans += math.sqrt((x1-x2)**2 + (y1-y2)**2)*(n-1)*2

print(ans/((n-1)*n))

Measured memory_bytes: 9052
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

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

	string N;

	cin >> N;

	if(N[0]==N[1] && N[1]==N[2]){
		cout << "Yes" << endl;
	}else if(N[1]==N[2] && N[2]==N[3]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
s = str(input())
t = str(input())

d = {}

c = 0
for i in range(len(s)):
  if s[i] not in d:
    d[s[i]] = c
    c += 1

d_ = {}
used = set()
for i in range(len(t)):
  if t[i] not in d_ and s[i] not in used:
    d_[t[i]] = d[s[i]]
    used.add(s[i])
  elif t[i] not in d_ and s[i] in used:
    print('No')
    exit()
  else:
    pass

for i in range(len(s)):
  if d[s[i]] != d_[t[i]]:
    print('No')
    exit()
else:
  print('Yes')

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
n, m = map(int, input().split())

max_l = 0
min_r = n
for i in range(m):
    l, r = map(int, input().split())
    max_l = max(max_l, l)
    min_r = min(min_r, r)

res = min_r - max_l + 1

if res > 0:
    print(min_r - max_l + 1)
else:
    print(0)

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            pass
        else:
            print("DENIED")
            exit()
print("APPROVED")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    for(int i=N;i<1000;i++){
        if(i%111==0){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dp[3300][3300];
int a,b;
const int mod = 998244353;
int dfs(int x,int y){
	//a,b-x,yまで
	//trace(x,y);
	if(x == a && y == b)return 1;
	if(x < a || y < b)return 0;
	if(dp[x][y] != -1)return dp[x][y];
	int ret = 0;
	//x-1,yからx行目を追加（y個候補）
	{
		int tmp = dfs(x-1,y)*y%mod;
		ret = (ret + tmp)%mod;
	}
	//x,y-1からy列目を追加(x個候補)
	{
		int tmp = dfs(x,y-1)*x%mod;
		ret  = (ret+tmp)%mod;
	}
	//重複分の削除
	{
		int tmp = dfs(x-1,y-1)*(x-1)%mod;
		tmp = (tmp*(y-1))%mod;
		ret = (ret - tmp +mod)%mod;
	}
	return dp[x][y] = ret;
}
signed main(){
	int c,d;cin >> a >> b >> c >> d;
	rep(i,3300)rep(j,3300)dp[i][j] = -1;
	cout << dfs(c,d) <<endl;
	return 0;
}

Measured memory_bytes: 89076
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int dp[100001][3];
vector<char> v[100000];
int R, S, P;

int calc(char c){
    if(c == 'r') return P;
    if(c == 's') return R;
    if(c == 'p') return S;
}

bool win(char c1, char c2){
    if(c1 == 'r' && c2 == 's') return true;
    if(c1 == 's' && c2 == 'p') return true;
    if(c1 == 'p' && c2 == 'r') return true;
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N, K;
    
    string T;
    cin >> N >> K >> R >> S >> P;
    cin >> T;
    int ans = 0;
    for(int i = 0; i < N; i++){
        v[i%K].push_back(T[i]);
    }
    for(int i = 0; i < K; i++){
        if(v[i][0] == 'r') {
            dp[0][0] = 0;
            dp[0][1] = 0;
            dp[0][2] = P;
        }
        if(v[i][0] == 's') {
            dp[0][0] = 0;
            dp[0][1] = 0;
            dp[0][2] = R;
        }
        if(v[i][0] == 'p') {
            dp[0][0] = 0;
            dp[0][1] = 0;
            dp[0][2] = S;
        }
        for(int j = 1; j < v[i].size(); j++){
            if(v[i][j] == v[i][j-1]){
                dp[j][0] = max(dp[j-1][1], dp[j-1][2]);
                dp[j][1] = max(dp[j-1][0], dp[j-1][2]);
                dp[j][2] = max(dp[j-1][0], dp[j-1][1])+calc(v[i][j]);
            }else if(win(v[i][j], v[i][j-1])){
                dp[j][0] = max(dp[j-1][0], dp[j-1][2]);
                dp[j][1] = max(dp[j-1][0], dp[j-1][1]);
                dp[j][2] = max(dp[j-1][1], dp[j-1][2])+calc(v[i][j]);
            }else{
                dp[j][0] = max(dp[j-1][0], dp[j-1][1]);
                dp[j][1] = max(dp[j-1][1], dp[j-1][2]);
                dp[j][2] = max(dp[j-1][0], dp[j-1][2])+calc(v[i][j]);
            }
        }
        if(v[i].size() != 0){
            int j = v[i].size()-1;
            ans += max({dp[j][0], dp[j][1], dp[j][2]});
            
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5456
str = input()
q = int(input())

for _ in range(q):
    line = input().split()
    c = line[0]
    a = int(line[1])
    b = int(line[2]) + 1

    if c == 'replace':
        str = str[:a] + line[3] + str[b:]
    elif c == 'reverse':
        str = str[:a] + str[a:b][::-1] + str[b:]
    else:
        print(str[a:b])


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}


const int MAXN = 2e5 + 10;
const ll mod = 998244353;
ll fact[MAXN], inv[MAXN], finv[MAXN];


ll power(ll a, ll b, ll mod=1e9+7) {
  ll ret = 1;
  while (b) {
    if (b & 1) ret = ret * a;
    b >>= 1;
    a = a * a;

    ret %= mod;
    a %= mod;
  }

  return ret;
}

struct Ncr {
  void build() {
    fact[0] = fact[1] = 1;
    for (int i = 2; i < MAXN; ++i) {
      fact[i] = (i * fact[i-1]) % mod;
    }

    inv[0] = inv[1] = 1;
    for (int i = 2; i < MAXN; ++i) {
      inv[i] = (inv[mod%i] * (mod-mod/i)) % mod;
    }

    finv[0] = finv[1] = 1;
    for (int i = 2; i < MAXN; ++i) {
      finv[i] = (finv[i-1] * inv[i]) % mod;
    }
  }
  
  ll query(ll n, ll r) {
    return (((fact[n] * finv[n-r]) % mod) * finv[r]) % mod;
  }
};


int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    ll n,m,k; cin >> n >> m >> k;

    ll ans = 0;
    struct Ncr ncr;
    ncr.build();

    for (int i = 0; i <= k; ++i) {
      ll R = m;
      R = (R * ncr.query(n-1,i)) % mod;
      R = (R * power(m-1,n-i-1,mod)) % mod;
      ans += R;
      ans %= mod;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 8344