akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>

#define MAX_M (100)
#define EPS (1e-5)
#define SQ(X) ((X) * (X))

using namespace std;

typedef struct {
	double x, y;
} Point;

vector<Point> Rect[MAX_M];
vector<int> G[MAX_M];
bool used[MAX_M];

double getSize(double a, double b, double c)
{
	double s;
	
	s = (a + b + c) / 2.0;
	
	if (s * (s - a) * (s - b) * (s - c) <= EPS){
		return (0);
	}
	
	return (sqrt(s * (s - a) * (s - b) * (s - c)));
}

double dist(Point a, Point b)
{
	return (sqrt(SQ(a.x - b.x) + SQ(a.y - b.y)));
}

bool checkCross(vector<Point> p, vector<Point> q)
{	
	for (int i = 0; i < 4; i++){
		for (int j = i + 1; j < 4; j++){
			for (int k = j + 1; k < 4; k++){
				for (int t = 0; t < 4; t++){
					double AB = dist(p[i], p[j]), BC = dist(p[j], p[k]), CA = dist(p[k], p[i]);
					double AP = dist(p[i], q[t]), BP = dist(p[j], q[t]), CP = dist(p[k], q[t]);
					double S = getSize(AB, BC, CA);
					double M = getSize(AP, BP, AB) + getSize(AP, CP, CA) + getSize(BP, CP, BC);
					if (fabs(S - M) <= EPS){
						return (true);
					}
				}
			}
		}
	}
	
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 4; j++){
			if (i == j) continue;
			for (int k = 0; k < 4; k++){
				for (int l = 0; l < 4; l++){
					if (k == l) continue;
					Point p1 = p[i], p2 = p[j], p3 = q[k], p4 = q[l];
					double a = (p3.x - p4.x) * (p1.y - p3.y) + (p3.y - p4.y) * (p3.x - p1.x);
					double b = (p3.x - p4.x) * (p2.y - p3.y) + (p3.y - p4.y) * (p3.x - p2.x);
					double c = (p1.x - p2.x) * (p3.y - p1.y) + (p1.y - p2.y) * (p1.x - p3.x);
					double d = (p1.x - p2.x) * (p4.y - p1.y) + (p1.y - p2.y) * (p1.x - p4.x);
					if (a * b < 0 && c * d < 0) return (true);
				}
			}
		}
	}
	
	return (false);
}

void dfs(int k)
{
	used[k] = true;
	for (int i = 0; i < (int)G[k].size(); i++){
		if (!used[G[k][i]]){
			dfs(G[k][i]);
		}
	}
}

int main()
{
	int n, m;
	int ans;
	
	while (scanf("%d", &n) && n){
		
		for (int i = 0; i < n; i++){
			scanf("%d", &m);
			for (int j = 0; j < m; j++){
				Rect[j].clear();
				G[j].clear();
			}
			
			for (int j = 0; j < m; j++){
				for (int k = 0; k < 4; k++){
					Point in;
					scanf("%lf %lf", &in.x, &in.y);
					Rect[j].push_back(in);
				}
			}
			
			for (int j = 0; j < m; j++){
				for (int k = 0; k < m; k++){
					if (checkCross(Rect[j], Rect[k]) == true){
						G[j].push_back(k);
						G[k].push_back(j);
					}
				}
			}
			
			memset(used, false, sizeof(used));
			ans = 0;
			for (int j = 0; j < m; j++){
				if (used[j] == false){
					ans++;
					dfs(j);
				}
			}
			
			printf("%d\n", ans);
		}
	}
	
	return (0);
}

Measured memory_bytes: 1108
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
string s;
int ans[2002],v[2002];
vector<int>g[2002];
int L[2005],R[2005],sum[2005];
void dfs(int x,int par=0){
	sum[x]=v[x];
	for(auto to:g[x]){
		if(to!=par){
			dfs(to,x);
			sum[x]+=sum[to];
			R[x]+=R[to]+sum[to];
		}
	}
	int mx=-inf;
	for(auto to:g[x]){
		if(to!=par){
			mx=max(mx,R[to]+L[to]+2*sum[to]);
		}
	}
	L[x]=max(mx-R[x],R[x]%2);
}
int check(int x){
	memset(L,0,sizeof L);
	memset(R,0,sizeof R);
	memset(sum,0,sizeof sum);
	dfs(x);
//	cerr<<x<<" "<<L[x]<<" "<<R[x]<<endl;
	if(L[x])return inf;
	return R[x]/2;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>s;
	for(int i=1;i<=n;i++)v[i]=s[i-1]-'0';
	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int best=inf;
	for(int i=1;i<=n;i++){
		best=min(best,check(i));
	}
	cout<<(best==inf?-1:best)<<endl;
	return 0;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanInit()

	s := nextStr()

	if s[len(s)-1] == 's' {
		s += "es"
	} else {
		s += "s"
	}

	fmt.Println(s)

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
  ll w , h , x ,y ;
  cin >> w >> h >> x >> y ; 
  
  cout <<fixed << setprecision(10) <<  double(w*h)/2 << " " ;
  
  if( x == (double)w/2 && y == (double)h/2){
    cout << 1 << endl ; 
    return 0 ; 
  }
  else cout << 0 << endl ; 
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    ll n,k; cin>>n>>k;
    vector<ll> a(n);
    rep(i,0,n){
        ll x;
        cin>>x;
        x--;
        a[i]=x;
    }
    vector<ll> box;
    set<ll> seen;
    seen.insert(0);
    ll loop=0;
    ll next=a[0];
    box.push_back(0);
    ll basho=0;
    rep(i,0,n+1){
        if(i==k){
            cout<<box.back()+1<<endl;
            return 0;
        }
        if(seen.count(next)){
            rep(j,0,box.size()){
                if(box[j]==next){
                    basho=j;
                }
            }
            loop=box.size()-basho;
            break;
        }else{
            seen.insert(next);
            box.push_back(next);
            next=a[next];
        }
    }
    cout<<(ll)(box[(ll)(k-basho)%loop +basho]+1)<<endl;

}


Measured memory_bytes: 13600
#include <stdio.h>
#include <stdbool.h>
 
void judge(int pe, int pm, int pj);
int main(void)
{
    int n, pe, pm, pj;
    while (1) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        }
        for (int i = 0; i < n; ++i) {        
            scanf("%d %d %d", &pe, &pm, &pj);
            judge(pe, pm, pj);
        }
    }
}
void judge(int pe, int pm, int pj)
{
    int sum = pe + pm + pj;
    int sumem = pe + pm;
    bool flag2 = false;
    if (pm >= 80 || pe >= 80) {
        flag2 = true;
    }
    if (pe == 100 || pj == 100 || pm == 100 || sum >= 240 || sumem >= 180) {
        printf("A\n");
    } else if (sum >= 210) {
        printf("B\n");
    } else if (sum >= 150 && flag2 == true) {
        printf("B\n");
    } else {
        printf("C\n");
    }
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
#define int long long

int f(int n)
{
    if(n==1)
    return 1;
    
    return(2*f(n/2) +1 );
}

int32_t main()
{
int n;
  cin>>n;
  cout<<f(n)<<endl;
  
}

Measured memory_bytes: 256
fn main() {
    let (a, b, c) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        let abc: Vec<usize> = buf
            .trim()
            .split_whitespace()
            .map(|e| e.trim().parse().ok().unwrap())
            .collect();
        (abc[0], abc[1], abc[2])
    };

    let succeed = (1..(b + 1)).find(|i| a * i % b == c);
    match succeed {
        Some(_) => println!("{}", "YES"),
        None => println!("{}", "NO"),
    };
}


Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class sumitrust2019A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int m1 = Integer.parseInt(in.next());
            int d1 = Integer.parseInt(in.next());
            int m2 = Integer.parseInt(in.next());
            int d2 = Integer.parseInt(in.next());
            int ans = 0;

            if (d2 == 1) ans = 1;

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21972
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main(){

char N[21][21]={};
char L[21]={};

int W,H;
while(1){
cin>>W>>H;if(W==0&&H==0)break;


for(int i=0;i<H;i++){
scanf("%s",L);
for(int j=0;j<W;j++)
N[i][j]=L[j];
}

int n[22][22]={};int c=0;
for(int i=1;i<H+1;i++)
for(int j=1;j<W+1;j++)
{if(n[i][j]==0&&(N[i-1][j-1]=='@'||N[i-1][j-1]=='.')){c++;
n[i][j]=c;}
if(N[i-1][j-1]=='@'||N[i-1][j-1]=='.'){
if(N[i-1][j+1-1]=='@'||N[i-1][j+1-1]=='.')n[i][j+1]=n[i][j];
if(N[i+1-1][j-1]=='@'||N[i+1-1][j-1]=='.')n[i+1][j]=n[i][j];
}
}

for(int i=0;i<H+1;i++)
for(int j=0;j<W+1;j++)
{if(n[i][j]!=0&&n[i][j+1]>n[i][j]){
int t=n[i][j+1];
for(int ii=0;ii<H+1;ii++)
for(int jj=0;jj<W+1;jj++)
if(n[ii][jj]==t)n[ii][jj]=n[i][j];
}
if(n[i][j]!=0&&n[i][j-1]>n[i][j]){
int t=n[i][j-1];
for(int ii=0;ii<H+1;ii++)
for(int jj=0;jj<W+1;jj++)
if(n[ii][jj]==t)n[ii][jj]=n[i][j];
}
if(n[i][j]!=0&&n[i+1][j]>n[i][j]){
int t=n[i+1][j];
for(int ii=0;ii<H+1;ii++)
for(int jj=0;jj<W+1;jj++)
if(n[ii][jj]==t)n[ii][jj]=n[i][j];
}
if(n[i][j]!=0&&n[i-1][j]>n[i][j]){
int t=n[i-1][j];
for(int ii=0;ii<H+1;ii++)
for(int jj=0;jj<W+1;jj++)
if(n[ii][jj]==t)n[ii][jj]=n[i][j];
}
}

int p=0;
for(int i=0;i<H;i++)
for(int j=0;j<W;j++)
if(N[i][j]=='@')p=n[i+1][j+1];
/*
for(int i=1;i<H+2;i++){
for(int j=1;j<W+2;j++)
	cout<<n[i][j];
cout<<endl;
}*/

int g=0;
for(int i=1;i<H+1;i++)
for(int j=1;j<W+1;j++)
if(n[i][j]==p)g++;

cout<<g<<endl;
}

return 0;
}

Measured memory_bytes: 1188
h,w = map(int,input().split())
a = []
for i in range(h):
    a.append(list(map(int,input().split())))

ans = []
for i in range(h):
    x = list(range(0,w))
    if i%2 == 1:
        x.reverse()
    for j in range(w-1):
        if a[i][x[j]]%2 == 1:
            a[i][x[j]] -= 1
            a[i][x[j+1]] += 1
            ans.append([i+1, x[j]+1, i+1, x[j+1]+1])

    if i < h-1:
        if a[i][x[-1]]%2 == 1:
            a[i][x[-1]] -= 1
            a[i+1][x[-1]] += 1
            ans.append([i+1, x[-1]+1, i+1+1, x[-1]+1])

print(len(ans))
for l in ans:
    print(' '.join(map(str,l)))


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

int main() {
  string s;
  cin>>s;
  
  set<char> st;	// 文字の集合
  
  for(int i=0;i<4;++i){
  	st.insert(s[i]);	// 重複をカット
  }
  if(st.size()==2)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if(a > b){
        cout << "a > b" << endl;
    }
    else if(a == b){
        cout << "a == b" << endl;
    }
    else{
        cout << "a < b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
N, K = map(int, input().split())
arr = list(map(int, input().split()))

jj = 0
koho=[]
for i in range(K):
    jj+=arr[i]
    koho.append(jj)

for i in range(N-K):
    jj+=arr[i+K]
    jj-=arr[i]
    koho.append(jj)

a=max(koho)
print(a/2+(K/2))



Measured memory_bytes: 93752
n, q = map(int, input().split())
s = input()
t = [0] * n
for i in range(1, n):
    t[i] = t[i - 1] + (1 if s[i - 1:i + 1] == "AC" else 0)
for i in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])

Measured memory_bytes: 7748
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;
int main() {
	int X, A;
	cin >> X >> A;
	cout << ((X < A) ? 0 : 10) << endl;
	return 0;
}

Measured memory_bytes: 256
M, D = map(int, input().split())

ans = 0
for mul in range(1, M + 1):
    for date in range(11, D + 1):
        if (date // 10) == 1 or (date % 10) in [0, 1]:
            continue
        temp = (date//10)*(date % 10)

        if temp == mul:
            ans += 1
            # print((mul, date))
print(ans)


Measured memory_bytes: 2940
n, k = int(input()), int(input())
# O(2^N)??
m = 1
def f(m, n, k):
    if n==0:
        return m
    else:
        return min(f(m*2, n-1, k), f(m+k, n-1, k))

print(f(m, n, k))

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

int main()
{
    string s;
    cin >> s;
    string t;
    t = "CODEFESTIVAL2016";
    int num = 0;
    rep(i, 16) {
        if(s[i] != t[i]) num++;
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

int main(){
	string n;
	int flag = 0;
	cin >> n;
	for(int i = 0; i < 3; i++){
		if(n[i] == '7')flag = 1;
	}
	if(flag == 1)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N = 3e5;
int arr[N];

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    for(i = 0; i < n-1; i++){
        int in; cin>>in; arr[in]++;
    }
    for(i = 1; i <= n; i++) cout << arr[i] << endl;
    return 0;
}


Measured memory_bytes: 4400
import re
import sys
from collections import *
from functools import lru_cache
from heapq import *
from itertools import *
from statistics import *
from string import (
    ascii_letters as letters,
    ascii_lowercase as lcletters,
    ascii_uppercase as ucletters,
    digits
)

hexdigits='01234567890ABCDEFabcdef'
inf=float('inf')

sys.setrecursionlimit(2**31-1)

rfs=lambda:rl().split()
ri=lambda:int(rl())
ris=lambda:list(map(int,rfs()))
rls=lambda:list(sys.stdin)
rl=lambda:next(sys.stdin)
rrs=lambda:list(map(str.strip,rls()))
rs=lambda:rl().strip()
rt=lambda:sys.stdin.read()
rg=lambda:list(map(list,rrs()))
rig=lambda:[[*map(int,x.split())] for x in rls()]

def n4(i,j):
    return [
                (i-1,j),
        (i,j-1),        (i,j+1),
                (i+1,j),
    ]

def n8(i,j):
    return [
        (i-1,j-1),(i-1,j),(i-1,j+1),
        (  i,j-1),        (  i,j+1),
        (i+1,j-1),(i+1,j),(i+1,j+1),
    ]

inb=lambda i,j,m,n:0<=i<m and 0<=j<n

###########################################

N,Q=ris()

adj=defaultdict(list)
for _ in range(N-1):
    a,b=ris()
    adj[a].append(b)
    adj[b].append(a)

ct=[0]*(N+1)
for _ in range(Q):
    p,x=ris()
    ct[p]+=x
    
ans=[0]*N
def dfs(u,x,p):
    x=x+ct[u]
    ans[u-1]=x
    for v in adj[u]:
        if v!=p:
            dfs(v,x,u)

dfs(1,0,-1)

print(*ans)


Measured memory_bytes: 247972
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
//typedef pair<int, int> pii;
//#define fi first
//#define se second
#define lbd(a, x) lower_bound(all(a), x)
const int mod = 1e9 + 7;
const int M = 10100;
const int N = 2100;
struct pii {
	int fi, se;
	pii(int x=0, int y=0):fi(x),se(y) {}
};
bitset<M> ok[N];
char vs[N][M];
int len[N];
const int S = 15000;
pii q[2][S+N];
int t[2];
int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, k; cin >> n >> k;
	for(int i = 0; i < n; i++) {
		cin >> vs[i];
		len[i] = strlen(vs[i]);
	}
	ok[n][0] = 1;
	for(int i = n - 1; i; i--) {
		ok[i] = ok[i + 1] | (ok[i + 1] << len[i]);
	}
	int now = 0;
	for(int i = 0; i < n; i++) {
		if(ok[i + 1][k - len[i]]) {
			q[now][t[now]++] = pii(i, 0);
		}
	}
	string ans;
	for(int i = 0; i < k; i++) {
		now ^= 1;
		char z = 'z' + 1;
		for(int j = 0; j < t[now^1]; j++) {
			auto &e = q[now^1][j];
			z = min(z, vs[e.fi][e.se]);
		}
		ans.push_back(z);
		int zz = n;
		for(int j = 0; j < t[now^1]; j++) {
			auto &e = q[now^1][j];
			if(vs[e.fi][e.se] == z) {
				if(e.se == len[e.fi] - 1) {
					zz = min(zz, e.fi);
				} else {
					e.se++;
					q[now][t[now]++] = e;
				}
			}
		}
		int need = k - i - 1;
		for(int j = zz + 1; j < n && t[now] < S; j++)
			if(need >= len[j] && ok[j + 1][need - len[j]])
				q[now][t[now]++] = pii(j, 0);
		if(t[now] >= S) t[now] = S;
		t[now^1] = 0;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 22784
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.La;
		long p=Abs(s[0])/s[2];
		if(s[1]>=p){s[1]-=p;}
		else{
			if(s[0]<0){s[0]+=s[1]*s[2];}
			else {s[0]-=s[1]*s[2];}
			Console.WriteLine("{0}",Abs(s[0]));
			return;
		}
		if(s[0]<0){s[0]+=p*s[2];}
		else {s[0]-=p*s[2];}
		s[1]%=2;
		if(s[1]==0){
			Console.WriteLine("{0}",Abs(s[0]));
			return;
		}
		Console.WriteLine("{0}",Min(Abs(s[0]-s[2]),Abs(s[0]+s[2])));
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

sys.setrecursionlimit(1000000)
mod = 998244353


def solve():
    m,n,k = LI()
    if n < k:
        print(0)
        return
    if m < k:
        print(0)
        return
    ans = pow(m,n,mod)
    p = [pow(i,n,mod) for i in range(k+1)]
    c = m
    comb = [[0 for i in range(i+1)] for i in range(k+1)]
    comb[0][0] = 1
    for i in range(k):
        for j in range(i+1):
            comb[i+1][j] += comb[i][j]
            comb[i+1][j+1] += comb[i][j]
    for i in range(1,k):
        k = 0
        for j in range(1,i+1)[::-1]:
            if (i+j)&1:
                k -= comb[i][j]*p[j]
            else:
                k += comb[i][j]*p[j]
        k *= c
        c *= (m-i)
        c *= pow(i+1,mod-2,mod)
        c %= mod
        ans -= k
        ans %= mod
    print(ans)
    return


if __name__ == "__main__":
    solve()



Measured memory_bytes: 60068
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans,b[n-1];
  for(int i=0;i<n-1;i++){
    cin>>b[i];
  }
  ans+=b[0];
  ans+=b[n-2];
  for(int i=0;i<n-2;i++){
    ans+=min(b[i],b[i+1]);
  }
  cout<<ans;
  return 0;
}

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

A.sort()

i=0
j=1
ANS=1

while j<N:
    x=A[i]
    if A[j]<=x+2:
        ANS=max(ANS,j-i+1)
        j+=1
    else:
        i+=1
        
print(ANS)


Measured memory_bytes: 13964
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))

using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n);
vector<int> split(int n,int a);
string xal_number(int n,int x);
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
class Factorial{
private:
	vector<int> fac;
public:
	Factorial(int N){
		fac.push_back(1);
		rep(i,N) fac.push_back(fac[i]*(i+1)%mod);
	}
	int fact(int a){return fac[a];}
	int ifac(int a){return m_inv(fac[a]);}
	int cmb(int n,int r);
};
struct UnionFind {
    vector<int> par; // 親ノード
    UnionFind(int n = 1) { init(n);}
    void init(int n = 1) {
        par.resize(n);
        rep(i,n) par[i] = -1;
    }
    int root(int x) {
        if (par[x] <0) return x;
        else return par[x] = root(par[x]);      
    }
    int size(int x){ return -par[root(x)];}
    bool issame(int x, int y) {return root(x)==root(y);}
    bool connect(int x, int y);
};
int n,a,b;
vector<int> h,m;
bool enough(int T){
	int count=0;
	rep(i,n){
		if(h[i]-b*T>0) count+=(h[i]-b*T-1)/(a-b)+1;
	}
	if(count>T) return false;
	else return true;
}

signed main(){

	cin>>n>>a>>b;
	h.resize(n);m.resize(n);
	rep(i,n) cin>>h[i];
	sort(h.rbegin(),h.rend());
	int l=0,r=h[0]/b+1;
	while((l+1)!=r){
		int k=(l+r)/2;
		if(enough(k)) r=k;
		else l=k;
	}
	cout<<r<<endl;
}

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

ll T, N, M, A, B;

int main() {
    cin >> T;
    rep(i, T) {
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << endl;
    }
}

Measured memory_bytes: 3636
/*

*/

#include <stdio.h>

int max = 10000000;

short prime[10000000];

void make_prime(){
	int i,p,n;
	for(i=0; i<=max; i++){
		prime[i]=1;
	}
	prime[0]=0;
	prime[1]=0;
	for(p=2; p<=max; p++){
		if(prime[p]){
			for(n=p+p; n<=max; n+=p){
				prime[n]=0;
			}
		}
	}
}

int main()
{
	int n;
	make_prime();
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		else if(n>=13&&n<=10000000){
			while(1){
				if(prime[n]){
					if(prime[n-2]){
						if(prime[n-6]){
							if(prime[n-8]){
								printf("%d\n", n);
								break;
							}
						}
					}
				}
				n--;
			}
		}
	}
	return 0;
}

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

const int N = 3e4 + 10;
int n;
int nxt[N][10], now[10];
char str[N];
int main()
{
	scanf("%d%s", &n, str);
	memset(now, -1, sizeof(now));
	for (int i = n - 1; i >= 0; i--)
		memcpy(nxt[i], now, sizeof(now)), now[str[i] - '0'] = i;
	int ans = 0;
	for (int i = 0; i <= 9; i++)
		if (~now[i])
			for (int j = 0; j <= 9; j++)
				if (~nxt[now[i]][j])
					for (int k = 0; k <= 9; k++)
						if (~nxt[nxt[now[i]][j]][k])
							++ans;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1408
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc;

  class Circle {
    byte x, y, r, c;

    Circle(byte x, byte y, byte r, byte c) {
      this.x = x;
      this.y = y;
      this.r = r;
      this.c = c;
    }

    boolean intersect(Circle o) {
      return ( (int) r + o.r ) * ( (int) r + o.r ) > ( (int) x - o.x )
          * ( (int) x - o.x ) + ( (int) y - o.y ) * ( (int) y - o.y );
    }
  }

  int n = 24;
  Circle[] list = new Circle[n];
  boolean[] done = new boolean[n];
  byte[] memo = new byte[1 << n];
  boolean[] fill = new boolean[1 << n];

  byte dfs(int BITS) {
    if ( fill[ BITS ] ) {
      return memo[ BITS ];
    }
    byte max = 0;

    for ( int i = 0; i < n; ++i ) {
      if ( done[ i ] || !isTop( i ) )
        continue;
      for ( int j = i - 1; 0 <= j; --j ) {
        if ( done[ j ] || !isTop( j ) )
          continue;

        if ( list[ i ].c == list[ j ].c ) {
          done[ i ] = done[ j ] = true;
          max = (byte) Math
              .max( max, 2 + dfs( BITS | ( 1 << i ) | ( 1 << j ) ) );
          done[ i ] = done[ j ] = false;
        }
      }
    }

    fill[ BITS ] = true;
    memo[ BITS ] = max;
    return max;
  }

  boolean isTop(int index) {
    boolean flag = true;
    for ( int i = index - 1; 0 <= i; --i ) {
      flag &= done[ i ] | !list[ i ].intersect( list[ index ] );
    }
    return flag;
  }

  void run() {
    for ( ;; ) {
      n = ni();
      if ( n == 0 ) {
        break;
      }

      Arrays.fill( done, false );
      Arrays.fill( fill, false );
      for ( int i = 0; i < n; ++i ) {
        byte x = ni();
        byte y = ni();
        byte r = ni();
        byte c = ni();
        list[ i ] = new Circle( x, y, r, c );
        // debug(isTop(i));
      }

      System.out.println( dfs( 0 ) );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  byte ni() {
    return (byte) sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

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

}

Measured memory_bytes: 61840
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()

result = 0
cur = 0
while cur < N:
    a = A[cur]
    count = 0
    while cur < N and A[cur] == a:
        cur += 1
        count += 1
    result += count % 2

print(result)

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

using namespace std;

#define ll long long

ll power(int a, int times) {
	ll ans = 1;
	for (int i = 0; i < times; i++) {
		ans *= a;
	}
	return ans;
}

void solve() {
	int a, b;
	cin >> a >> b;
	int ans = 1900*b+100*(a-b);
	cout << ans*power(2, b) << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3600
N,M = map(int,input().split())

A = [[9999 for _ in range(N)] for _ in range(N)]
B = []
for i in range(M):
    a,b,c = map(int,input().split())
    A[a-1][b-1] = c
    A[b-1][a-1] = c
    B.append((a-1,b-1,c))

for k in range(N):
    for i in range(N):
        for j in range(N):
            if i==j:
                A[i][j] = 0
            else:
                A[i][j] = min(A[i][j], A[i][k]+A[k][j])

ans = 0
for i in range(M):
    a,b,c = B[i]
    for j in range(N):
        if A[j][b] == A[j][a] + c:
            break
    else:
        ans += 1

print(ans)

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

using namespace std;

int main()
{
    map <string, int> map;
    int n,m;

    cin >> n;
    while (n--) {
        string x; cin >> x;
        map[x]++;
    }

    cin >> m;
    while(m--) {
        string x; cin >> x;
        map[x]--;
    }

    int best = 0;
    for (auto p : map){
        best = max(best, p.second);
    }
    cout << best << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Edges = vector<int>;
using Graph = vector<Edges>;

const int INF = 1e9;

int main()
{
	int N, M;
	cin >> N >> M;
	Graph G(N);
	for (int i = 0, a, b; i < M; i++) {
		cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> d(N, INF);
	vector<int> q;
	q.push_back(0);
	d[0] = 0;
	for (int i = 0; i < 2; i++) {
		auto tmp = q; q.clear();
		for (auto v : tmp) {
			for (auto to : G[v]) {
				if (d[to] == INF) {
					d[to] = 0;
					q.push_back(to);
				}
			}
		}
	}
	cout << (d[N - 1] != 0 ? "IMPOSSIBLE" : "POSSIBLE") << endl;
	return 0;
}


Measured memory_bytes: 13680
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define mod 1000000007

int main () {
    int n = 0, m = 0;
    cin >> n >> m;
    vector<long long>s(n), t(m);
    for (int i=0; i<n; i++) {
        cin >> s.at(i);
    }
    for (int i=0; i<m; i++) {
        cin >> t.at(i);
    }
    vector<vector<long long>> dp(n+1, vector<long long>(m+1));
    vector<vector<long long>> sum(n+1, vector<long long>(m+1));
    dp.at(0).at(0) = 0;
    sum.at(0).at(0) = 1;
    for (int i=0; i<n+1; i++) {
        for (int j=0; j<m+1; j++) {
            if (i == 0 && j == 0) continue;
            else if (i == 0 || j == 0) {
                dp.at(i).at(j) = 0;
                sum.at(i).at(j) = 1;
            }
            else {
                if (s.at(i-1) != t.at(j-1)) {
                    dp.at(i).at(j) = 0;
                }
                else {
                    dp.at(i).at(j) = sum.at(i-1).at(j-1);
                }
                sum.at(i).at(j) += ((sum.at(i-1).at(j) + mod - sum.at(i-1).at(j-1)) % mod + (sum.at(i).at(j-1) + dp.at(i).at(j)) % mod) % mod;
                sum.at(i).at(j) %= mod;
            }
        }
    }
    cout << sum.at(n).at(m) << endl;
    return 0;
}


Measured memory_bytes: 62976
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  while(cin>>n,n){
    int x[n][n],y[n][n];
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	cin>>x[j][i]>>y[j][i];
    bool used[n][n];
    bool visit[n][n];
    memset(used,0,sizeof(used));
    int ans=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(used[i][j]) continue;
	memset(visit,0,sizeof(visit));
	int tx=i,ty=j;
	bool f=1;
	while(!visit[tx][ty]){
	  //cout<<tx<<" "<<ty<<endl;
	  if(used[tx][ty]){
	    f=0;
	    break;
	  }
	  visit[tx][ty]=1;
	  int py=ty,px=tx;
	  tx=x[px][py];
	  ty=y[px][py];
	}
	if(f){
	  ans++;
	  while(!used[tx][ty]){
	    used[tx][ty]=1;
	    int py=ty,px=tx;
	    tx=x[px][py];
	    ty=y[px][py];
	  }
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3224
n = int(input())
cnt = 0
ml = ['S', 'H', 'C', 'D']
s = [[i+1 for i in range(13)] for i in range(4)]
while cnt < n: 
    M, N = list(input().split())
    N = int(N)
    if M == ml[0]:
        s[0][N-1] = False
    elif M == ml[1]:
        s[1][N-1] = False
    elif M == ml[2]:
        s[2][N-1] = False
    elif M == ml[3]:
        s[3][N-1] = False
    cnt += 1
for i in range(len(ml)):
    for j in range(len(s[i])):
        if s[i][j] != False:
            print('{} {}'.format(ml[i], s[i][j]))


Measured memory_bytes: 5604
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		100000									// 最大配列数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Array[D_ARRAY_MAX];								// 配列
static int siACnt;												// 配列数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// ソート関数 - int昇順
int
fSortFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	int *lipVal1 = (int *)pzpVal1;
	int *lipVal2 = (int *)pzpVal2;

	// int昇順
	if (*lipVal1 > *lipVal2) {
		return 1;
	}
	else if (*lipVal1 < *lipVal2) {
		return -1;
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 配列数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siACnt);

	// 配列 - 取得
	for (i = 0; i < siACnt; i++) {
		fscanf(szpFpI, "%d", &si1Array[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 配列 - ソート
	qsort(si1Array, siACnt, sizeof(int), fSortFnc);

	// 合計値
	int liSum = 0;
	for (i = 0; i < siACnt; i++) {
		liSum += abs(si1Array[i]);
	}
	if (si1Array[0] > 0) {
		liSum -= si1Array[0] * 2;
	}
	else if (si1Array[siACnt - 1] < 0) {
		liSum += si1Array[siACnt - 1] * 2;
	}
	sprintf(lc1Buf, "%d\n", liSum);
	fOut(lc1Buf);

	// 操作
	for (i = 1; i < siACnt - 1; i++) {
		if (si1Array[i] >= 0) {
			sprintf(lc1Buf, "%d %d\n", si1Array[0], si1Array[i]);
			fOut(lc1Buf);
			si1Array[0] -= si1Array[i];
		}
	}
	for (i = 1; i < siACnt - 1; i++) {
		if (si1Array[i] < 0) {
			sprintf(lc1Buf, "%d %d\n", si1Array[siACnt - 1], si1Array[i]);
			fOut(lc1Buf);
			si1Array[siACnt - 1] -= si1Array[i];
		}
	}
	sprintf(lc1Buf, "%d %d\n", si1Array[siACnt - 1], si1Array[0]);
	fOut(lc1Buf);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 2232
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,m,ans;
int dp[305][305][305];
struct query{
	int l,r,x;
}e[305];

int cmp(query u,query v){
	return u.r<v.r;
}

int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d %d %d",&e[i].l,&e[i].r,&e[i].x);	
	}
	sort(e+1,e+m+1,cmp);
	dp[1][0][0]=3;
	int R=0;
	for(int i=1;i<=n;i++){
		while(e[R+1].r==i&&R<m){
			R++;
			for(int j=0;j<=i-1;j++){
				for(int k=j;k<=i-1;k++){
					if(e[R].x==1&&(j>=e[R].l||k>=e[R].l)) dp[i][j][k]=0;
					if(e[R].x==2&&((j>=e[R].l&&k>=e[R].l)||(j<e[R].l&&k<e[R].l))) dp[i][j][k]=0;
					if(e[R].x==3&&(j<e[R].l||k<e[R].l)) dp[i][j][k]=0;
				}
			}
		}
		if(i==n){
			for(int j=0;j<=i-1;j++){
				for(int k=j;k<=i-1;k++){
					ans+=dp[i][j][k];if(ans>=mod) ans-=mod;
				}
			}
			printf("%d\n",ans);return 0;
		}
		for(int j=0;j<=i-1;j++){
			for(int k=j;k<=i-1;k++){
				dp[i+1][j][k]+=dp[i][j][k];if(dp[i+1][j][k]>=mod) dp[i+1][j][k]-=mod;
				dp[i+1][k][i]+=dp[i][j][k];if(dp[i+1][k][i]>=mod) dp[i+1][k][i]-=mod;
				dp[i+1][j][i]+=dp[i][j][k];if(dp[i+1][j][i]>=mod) dp[i+1][j][i]-=mod;
			}
		}
	}
	
	return 0;
} 

Measured memory_bytes: 108800
import numpy as np
from pprint import pprint


def solve(MM, H, W):

    L, R, U, D = np.zeros((H, W), dtype=int), np.zeros((H, W), dtype=int), np.zeros((H, W), dtype=int), np.zeros((H, W), dtype=int)

    for i in range(H):
        i_r = H - 1 - i

        # L, U
        for j in range(W):
            j_r = W - 1 - j

            # L
            if MM[i][j]:
                if j == 0:
                    L[i][j] = 1
                else:
                    L[i][j] = L[i][j - 1] + 1

            # R
            if MM[i][j_r]:
                if j_r == W - 1:
                    R[i][j_r] = 1
                else:
                    R[i][j_r] = R[i][j_r + 1] + 1

            # U
            if MM[i][j]:
                if i == 0:
                    U[i][j] = 1
                else:
                    U[i][j] = U[i - 1][j] + 1

            # D
            if MM[i_r][j]:
                if i_r == H - 1:
                    D[i_r][j] = 1
                else:
                    D[i_r][j] = D[i_r + 1][j] + 1

    print((L + R + U + D - 3).max())


def solve2(MM, H, W):
    L, R, U, D = [MM.copy() for _ in range(4)]

    # U, D
    for i in range(1, H):
        U[i] = (U[i - 1] + 1) * MM[i]
        i_r = H - 1 - i
        D[i_r] = (D[i_r + 1] + 1) * MM[i_r]

    MM_T = MM.T
    L_T, R_T = L.T, R.T

    # L, R
    for i in range(1, W):
        L_T[i] = (L_T[i - 1] + 1) * MM_T[i]
        i_r = W - 1 - i
        R_T[i_r] = (R_T[i_r + 1] + 1) * MM_T[i_r]

    L, R = L_T.T, R_T.T
    print((L + R + U + D).max() - 3)


def stdin():
    H, W = [int(x) for x in input().split()]
    MM = np.zeros((H, W), dtype=int)

    for i in range(H):
        line = str(input())

        for j in range(W):
            if line[j] != '#':
                MM[i][j] = 1

    solve2(MM, H, W)


if __name__ == '__main__':
    stdin()


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

int main()
{
  string S,T;cin>>S>>T;
  int ans=1000;
  for(int i=0;i<S.size()-T.size()+1;i++)
  {
    int count=0;
    for(int j=0;j<T.size();j++)if(S[i+j]!=T[j])count++;
    ans=min(ans,count);
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 3728
import sys
import bisect


def main():
    n, *a = map(int, sys.stdin.read().split())
    lr = [[i - 1,i + 1] for i in a]
    lr.sort(key=lambda x: x[0])
    l = [i[0] for i in lr]
    res = 0
    for i in range(n):
        right = bisect.bisect(l, lr[i][1])
        left = bisect.bisect_left(l, l[i])
        res = max(res, right - left)
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 25292
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

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



Measured memory_bytes: 256
def solve(ls, rs, ans):
    if len(rs) == 0:
        return ans
    ans = max(ans, len(set(ls).intersection(set(rs))))
    return solve(ls + [rs[0]], rs[1:], ans)

if __name__ == "__main__":
    n = int(input())
    s = input()
    print(solve([], s, 0))


Measured memory_bytes: 3060
// Who_Says_a_Pun? 
// https://atcoder.jp/contests/abc141/tasks/abc141_e
// date: 2020-08-11T20:47:18.409724

// #配列の初期化 #0埋め #memsetではなく{0}

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

#define REP(i, n) for(ll i=0;i<ll(n);i++)
#define REPD(i, n) for(ll i=n-1;i>=0;i--)
#define FOR(i, a, b) for(ll i=a;i<=ll(b);i++)
#define FORD(i, a, b) for(ll i=a;i>=ll(b);i--)

#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

template<typename T, typename ...Args>
void IN(T& first, Args&... args) {
    ((cin >> first), ..., (cin >> args)); //C++17
}

template<char Sep, typename T, typename ...Args>
void print_sep(const T& first, const Args&... args) {
    ((cout << first), ..., (cout << Sep << args)); //C++17
}

template<typename... Words>
void OUT(Words... words) {
    print_sep<' '>(words...);
    cout << endl;
    return;
}

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 5000 //10^5:配列の最大のrange

int main(void){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll N;
    string s;
    IN(N);
    IN(s);

    // https://qiita.com/Ki4mTaria/items/b6ab0bcbe9c87d4dc071#%E9%85%8D%E5%88%97%E6%A7%8B%E9%80%A0%E4%BD%93%E3%81%AE%E4%B8%AD%E8%BA%AB
//    bool arr[MAXR][MAXR]= {false};
//    REP(i,N) FOR(j,i,N) {
//        arr[i][j] = s[i] == s[j];
//    }

    ll max_len=0;
    FOR(i, 1, N-1) {
        ll buf_len=0;
        FOR(j, 0, N - i - 1) {
            if (s[j] == s[i+j]) {
                buf_len++;
            } else{
                buf_len=0;
            }
            max_len = max(max_len, buf_len);
            if (buf_len==i) {
                break;
            }
        }
    }
    OUT(max_len);
    return 0;

}


Measured memory_bytes: 3580
n=int(input())
n-=1
c=[0]*n
s=[0]*n
f=[0]*n
for i in range(n):
    c[i],s[i],f[i]=map(int,input().split())
for i in range(n):
    t=0
    for j in range(i,n):
        if t<s[j]:
            t=s[j]
        elif t%f[j]==0:
            pass
        else:
            t=t+f[j]-t%f[j]
        t+=c[j]
    print(t)
print(0)


Measured memory_bytes: 3064
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;

int main(){
    char s[5];
    cin>>s;
    if((s[0]==s[1] || s[2]==s[3]) && s[1]==s[2]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int a, b, c;
	char op;
	cin >> a >> op >> b;

	while (op != '?' ){
		if (op == '+') c = a + b;
		if (op == '-') c = a - b;
		if (op == '*') c = a * b;
		if (op == '/') c = a / b;
		cout << c << endl;
		cin >> a >> op >> b;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
string s;

int main() {
	cin >> s;
	ll n = s.size();
	ll ten = 1;
	vector<vector<ll> > dp(n+1,vector<ll>(13,0));
	dp[n][0] = 1;
	for(int i=n-1;i>=0;i--)
	{
		if(s[i] == '?')
		{
			for(int j=0;j<=9;j++)
			{
				for(int k=0;k<13;k++)
				{
					dp[i][(k+j*ten)%13] += dp[i+1][k];
					dp[i][(k+j*ten)%13] %= MOD;
				}
			}
		}else
		{
			ll tmp = s[i] - '0';
			for(int k=0;k<13;k++)
			{
				dp[i][(k+tmp*ten)%13] += dp[i+1][k];
				dp[i][(k+tmp*ten)%13] %= MOD;
			}
		}
		ten *= 10;
		ten %= 13;
	}
	cout << dp[0][5] << endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int h, w; std::cin >> h >> w;
    vvi grid(h, vi(w));
    rep(i, h) rep(j, w) std::cin >> grid[i][j];

    struct Transition {
        int i, j, ni, nj;
        void print() {
            std::cout << i << " " << j << " ";
            std::cout << ni << " " << nj << "\n";
        }
    };
    vector<Transition> trans;
    rep(i, h) {
        if (~i&1) rep(j, w) {
            if (~grid[i][j]&1) continue;
            if (j == w-1 && i == h-1) continue;
            int ti = i, tj = j+1;
            if (j == w-1) ti = i+1, tj = j;
            grid[ti][tj]++, grid[i][j]--;
            trans.pb({i+1, j+1, ti+1, tj+1});
        } else drep(j, w) {
            if (~grid[i][j]&1) continue;
            if (j == 0 && i == h-1) continue;
            int ti = i, tj = j-1;
            if (j == 0) ti = i+1, tj = j;
            grid[ti][tj]++, grid[i][j]--;
            trans.pb({i+1, j+1, ti+1, tj+1});
        }
    }
    std::cout << trans.size() << "\n";
    rep(i, trans.size()) trans[i].print();
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    llint a, b, k;
    cin >> a >> b >> k;
    if (k <= a) {
        cout << a - k << " " << b << endl;
    } else if (k < a + b) {
        cout << 0 << " " << b - (k - a) << endl;
    } else {
        cout << 0 << " "  << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256