akhauriyash/Code-Regression huggingface dataset:
import java.util.*; 
import java.io.*;

public class Main {
	static int dp[] = new int[100005]; 
	static ArrayList<Integer> g[] = new ArrayList[100005]; 
	static boolean visited[] = new boolean[100005]; 
	
	public static void dfs(int vertex) {
		visited[vertex] = true;  
		
		for(int child : g[vertex]) {
			if(!visited[child])
				dfs(child); 
		
			dp[vertex] = Math.max(dp[vertex], 1 + dp[child]); 
		}
	}
	
	public static void solve(InputReader in) {
		int n = in.readInt() , m = in.readInt();
		
		for(int i = 0; i<=n; i++) {
			g[i] = new ArrayList<Integer>(); 
		}
		
		for(int i = 0; i<m; i++) {
			int x = in.readInt() , y = in.readInt(); 
			g[x].add(y);
		}
		
		for(int i = 1; i<=n; i++) {
			if(!visited[i]) 
				dfs(i); 
		}
		
		int ans = 0; 
		for(int i = 1; i<=n; i++) {
			ans = Math.max(ans,dp[i]); 
		}
		System.out.println(ans); 
	}

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int t = 1; 
		while (t-- > 0)
			solve(in);
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	 public InputReader(InputStream stream) {
		this.stream = stream;
	}

     public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

     public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

     public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
     public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
     
     public String next() {
		return readString();
	}
    
     public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 54524
#include <iostream>
using namespace std;
int ans[101];
int main(){
  int n;
  int M_index=1;
  cin >> n;
  for(int i=1;i<=n;i++){
    int x=i;
    while(x>0){
      x/=2;
      ans[i]++;
    }
  }
  for(int i=2;i<=n;i++){
    if(ans[M_index]<ans[i])M_index=i;
  }
  cout << M_index << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int A,B; cin>>A>>B;
  char grid[100][100];

  rep(i,50){
    rep(j,100){
      grid[i][j]='#';
    }
  }
  reps(i,50,100){
    rep(j,100){
      grid[i][j]='.';
    }
  }

  int a=1,b=1;

  while(a<A){
    int aa=a%40;
    int aaa=a/40;
    grid[aaa*2+1][aa*2+1]='.';
    ++a;
  }
  while(b<B){
    int bb=b%40;
    int bbb=b/40;
    grid[bbb*2+51][bb*2+1]='#';
    ++b;
  }

  cout<< 100<<" "<<100<<"\n";

  rep(i,100){
    rep(j,100){
      cout<<grid[i][j];
    }
    cout<<"\n";
  }


}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    string s;
    int i;
    cin >> s;
    
    for(i=0; i<s.size(); i+=2) {
        cout << s[i];
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int k,a,b;
int main()
{ cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin>>k>>a>>b;
  int x=a-a%k;
  if(x==a || x+k<=b)
     cout<<"OK\n";
  else
     cout<<"NG\n";
  return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl

using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
class Seg_Tree{
    private:
    int e=1000000007;
    int n;
    vector<int> node;
    public:
    int process(int left,int right){
        if(left==e)return right;
        if(right==e)return left;
        return max(left,right);
    }
    Seg_Tree(vector<int> v){
        int num=1;
        int size=v.size();
        while(num<size){
            num*=2;
        }
        n=num;
        node.resize(2*num-1,e);
        for(int i=0;i<size;i++)node[i+num-1]=v[i];
        for(int i=n-2;i>=0;i--)node[i]=process(node[i*2+1],node[i*2+2]);
    }
    void update(int x,int val){
        x+=(n-1);
        node[x]=val;
        while(x>0){
            x=(x-1)/2;
            node[x]=process(node[x*2+1],node[x*2+2]);
        }
    }
    int out(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(a>=r||b<=l)return e;
        if(a<=l&&b>=r)return node[k];
        int vl=out(a,b,k*2+1,l,(l+r)/2);
        int vr=out(a,b,k*2+2,(l+r)/2,r);
        return process(vl,vr);
    }
};
signed main(){
  int n,k;cin>>n>>k;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  Seg_Tree tree(vector<int>(300005,0));
  rep(i,n){
    int l=max(0,a[i]-k);
    int r=min(300001,a[i]+k);
    int get=tree.out(l,r+1);
    tree.update(a[i],get+1);
  }
  cout<<tree.out(0,300001)<<"\n";
  return 0;
}


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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

string S;

bool bad;

int main(void){
	cin>>S;
	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i] == S[i + 1]) {
			bad = true;
			break;
		}
	}

	if (bad) cout<< "Bad" <<endl;
	else cout<< "Good" <<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void PDF(string S,string T)
{
    long long l,i,s =0;
    l = S.size();
    for (i=0;i<l;i++)
    {
        if(S[i]!=T[i])
        {
            s++;
        }
    }
    cout << s <<endl;
}
int main()
{
    int n,i,j,l;
    string S,T;
    cin >>S >> T;
    PDF(S,T);
    return 0;
}


Measured memory_bytes: 4100
pub struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        return UnionFind {
            par: (0..n).map(|i| i).collect::<Vec<usize>>(),
            rank: vec![0; n],
            size: vec![1; n]
        }
    }

    pub fn find_root(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            return x;
        } else {
            let par_x = self.par[x];
            self.par[x] = self.find_root(par_x);
            return self.par[x];
        }
    }

    pub fn merge(&mut self, x: usize, y: usize) {
        let root_x = self.find_root(x);
        let root_y = self.find_root(y);
        if self.rank[root_x] < self.rank[root_y] {
            self.par[root_x] = root_y;
            self.size[root_y] += self.size[root_x];
        } else {
            self.par[root_y] = root_x;
            self.size[root_x] += self.size[root_y];
            if self.rank[root_x] == self.rank[root_y] {
                self.rank[root_x] += 1;
            } 
        }
    }

    pub fn issame(&mut self, x: usize, y: usize) -> bool {
        if self.find_root(x) == self.find_root(y) {
            return true;
        } else {
            return false;
        }
    }

    pub fn get_size(&mut self, x: usize) -> usize {
        let root_x = self.find_root(x);
        return self.size[root_x];
    }
}

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.read();
    let m = sc.read();
    let mut p = sc.vec(n);

    let mut uf = UnionFind::new(n);

    for _ in 0..m {
        let x: usize = sc.read();
        let y: usize = sc.read();
        uf.merge(x-1, y-1);
    }
    
    let mut ans: usize = 0;
    for i in 0..p.len() {
        p[i] -= 1;
    }

    for i in 0..p.len() {
        if uf.issame(p[i], i) {
            ans += 1;
        }
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 8444
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	int b,r,g,c,s,t;
	while(cin>>b>>r>>g>>c>>s>>t,b||r||g||c||s||t){
		int sum = 100;
		sum +=15*b+r*15+7*g+2*c;
		sum +=15*(b*5+r*3);
		sum -=(3*(t-s-b*5-r*3))+2*(b*5+r*3);
		cout <<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int(), T = Reader.Int();
        var A = Reader.IntArray(N);
        int maxDiff = -1, count = 0;
        var maxFrom = new int[N + 1];
        for (int i = N - 1; i >= 0; i--)
            maxFrom[i] = Math.Max(maxFrom[i + 1], A[i]);

        for (int i = 0; i < N; i++)
        {
            int diff = maxFrom[i + 1] - A[i];
            if (diff > maxDiff) { maxDiff = diff; count = 1; }
            else if (diff == maxDiff) count++;
        }

        Console.WriteLine(count);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 16472
import numpy as np

N, Q = map(int, input().split(' '))
S = input()
len_S = len(S)

flags = [0] * len_S
for i, v in enumerate(S[:-1]):
  if v == 'A' and S[i + 1] == 'C':
    flags[i + 1] = 1
  else:
    flags[i + 1] = 0

sums = list(np.cumsum(flags))

for _ in range(Q):
  l, r = map(int, input().split(' '))
  print(sums[r - 1] - sums[l - 1])


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

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

const int MAXN = 1e5 + 5;
const int MOD = 998244353;

int N, M;
int a[MAXN], b[MAXN], c[MAXN];
int diag[MAXN], adj[MAXN], tmp[MAXN];
map <pii, int> num;

void load() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++)
		scanf("%d%d%d", a + i, b + i, c + i);
}

inline int mul(int x, int y) {
	return (ll)x * y % MOD;
}

void bye() {
	puts("0");
	exit(0);
}

bool test(int pos, int val) {
	if (diag[pos] != -1 && diag[pos] != val) 
		bye();
	diag[pos] = val;
}

int solve() {
	memset(diag, -1, sizeof diag);
	memset(adj, -1, sizeof adj);
	for (int i = 0; i < M; i++) 
		num[{a[i], b[i]}] = c[i];

	ll cnt = (ll)N * (N - 1) / 2;	
	for (int i = 0; i < M; i++) {
		int diff = abs(a[i] - b[i]);
		if (num.find({a[i], b[i]}) == num.end())
			continue;
		if (diff)
			cnt--;
		auto it = num.find({b[i], a[i]});
		if (it == num.end())
			continue;
		int sum = c[i] ^ it -> second;
		
		if (diff == 0)	
			test(a[i], c[i]);
		else if (diff == 1) 
			adj[min(a[i], b[i])] = sum;
		else if (diff == 2) 
			test((a[i] + b[i]) / 2, sum);
		else if (sum)
			bye();
		
		num.erase(it);
	}
	
	int last = 1;
	for (int i = 1; i <= N; i++)
		if (adj[i] == -1) {
			bool bio[2] = {0};
			for (int j = last; j <= i; j++)
				if (diag[j] != -1)
					bio[diag[j] ^ tmp[j]] = true;
			if (bio[0] && bio[1])
				bye();
			if (!bio[0] && !bio[1])
				cnt++;
			last = i + 1;
		}
		else
			tmp[i + 1] = tmp[i] ^ adj[i];
			
	int sol = 1, sq = 2;
	for (; cnt; cnt /= 2) {
		if (cnt % 2) 
			sol = mul(sol, sq);
		sq = mul(sq, sq);
	}
	
	return sol;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 5120
n = int(input())
ans = 0
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
from collections import Counter
c = Counter(prime_factorize(n))
for i in c.values():
    for j in range(1,50):
        if j*(j+1)/2 <= i < (j+1)*(j+2)/2:
            ans += j
            break
print(ans)

Measured memory_bytes: 9464
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[][] bingo = new int[3][3];
        for (int i = 0; i < bingo.length; i++) {
            for (int j = 0; j < bingo.length; j++) {
                int cardNumber = scanner.nextInt();
                bingo[i][j] = cardNumber;

            }
        }

        int n = scanner.nextInt();
        int counter = 0;

        ArrayList<Integer> list = new ArrayList<>();
        for (int m = 0; m < n; m++){
            int inputNumber = scanner.nextInt();
            list.add(inputNumber);
        }


        for (int i = 0; i < bingo.length; i++) {
            for (int j = 0; j < bingo.length; j++) {
                if (list.contains(bingo[i][j])){
                    int index = list.indexOf(bingo[i][j]);
                    list.remove(index);
                    bingo[i][j] = 0;

                }

            }
        }


        //boolean tate1 = bingo[0][0] == 0 & bingo[1][0] == 0 & bingo[2][0] == 0;
        //boolean tate2 = bingo[0][1] == 0 & bingo[1][1] == 0 & bingo[2][1] == 0;
        //boolean tate3 = bingo[0][2] == 0 & bingo[1][2] == 0 & bingo[2][2] == 0;

        //boolean yoko1 = bingo[0][0] == 0 & bingo[0][1] == 0 & bingo[0][2] == 0;
        //boolean yoko2 = bingo[1][0] == 0 & bingo[1][1] == 0 & bingo[1][2] == 0;
        //boolean yoko3 = bingo[2][0] == 0 & bingo[2][1] == 0 & bingo[2][2] == 0;

        //boolean naname1 = bingo[0][0] == 0 & bingo[1][1] == 0 & bingo[2][2] == 0;
        //boolean naname2 = bingo[0][2] == 0 & bingo[1][1] == 0 & bingo[2][0] == 0;

        if (bingo[0][0] == 0 && bingo[1][0] == 0 && bingo[2][0] == 0 || bingo[0][1] == 0 && bingo[1][1] == 0 && bingo[2][1] == 0 || bingo[0][2] == 0 && bingo[1][2] == 0 && bingo[2][2] == 0) {
            System.out.println("Yes");
        } else if (bingo[0][0] == 0 && bingo[0][1] == 0 && bingo[0][2] == 0 || bingo[1][0] == 0 && bingo[1][1] == 0 && bingo[1][2] == 0 || bingo[2][0] == 0 && bingo[2][1] == 0 && bingo[2][2] == 0) {
            System.out.println("Yes");
        } else if (bingo[0][0] == 0 && bingo[1][1] == 0 && bingo[2][2] == 0 || bingo[0][2] == 0 && bingo[1][1] == 0 && bingo[2][0] == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }


    }

}



Measured memory_bytes: 23764
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int H, W;
    cin >> H >> W;
    vector< vector<int> > map(H, vector<int>(W, 0));
    vector< vector<P> > prev(H, vector<P>(W));
    REP(i, H) {
        string s;
        cin >> s;
        REP(j, W) {
            if(s[j] == '#') map[i][j] = 1;
        }
    }

    vector< vector<int> > dist(H, vector<int>(W, -1));
    queue<P> que;
    que.push(make_pair(0, 0));
    dist[0][0] = 0;

    while(!que.empty()) {
        P cur = que.front();
        que.pop();

        int x_now = cur.first, y_now = cur.second;
        for(int x = max(0, x_now - 1); x <= min(W-1, x_now + 1); ++x)
            for(int y = max(0, y_now - 1); y <= min(H-1, y_now + 1); ++y) {
                if(x == x_now && y == y_now) continue;
                if(x != x_now && y != y_now) continue;
                if(map[y][x] == 1) continue;
                if(dist[y][x] > 0) continue;
                dist[y][x] = dist[y_now][x_now] + 1;
                prev[y][x] = cur;
                que.push(make_pair(x, y));
            }
    }

    vector<P> path;
    path.push_back(make_pair(W-1, H-1));

    P cur = make_pair(W-1, H-1);
    while(cur.first != 0 || cur.second != 0) {
        cur = prev[cur.second][cur.first];
        path.push_back(cur);
    }

    // reverse(ALL(path));
    // REP(i, path.size()) {
    //     cerr << "x: " << path[i].first << " y: " << path[i].second << endl;
    // }
    if(dist[H-1][W-1] == -1) {
        cout << -1 << endl;
        return 0;
    }
    sort(ALL(path));

    int ans = 0;
    REP(i, H)
        REP(j, W) {
            P cand = make_pair(j, i);
            bool flag = true;
            for(P node: path) {
                if(node.second == cand.second && node.first == cand.first)
                    flag = false;
            }
            if(map[i][j] == 1) flag = false;
            if(flag) ans++;
        }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i,a,b) for (int i=a; i<(b); i++)
#define FOR(i,a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b); i >= a; i--)
#define FORd(i,a) for (int i = (a); i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy

int main() {


    int n;
    int k=2;
    cin>>n;//>>k;
    vi a(n);
    FOR(i,n)
    {
        cin>>a[i];
    }
    vector <ll> dp(n);
    fill(dp.begin(),dp.end(),1e12);
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i-j<0)
            {
                break;
            }
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<dp[n-1];
	return 0;
}













Measured memory_bytes: 4580
#include <cstdio>

int main (){
    int N,K,Q;
    scanf("%d %d %d",&N,&K,&Q);
    int point[N];
    for (int i = 0; i < N; i++){
        point[i]=K-Q;
    }
    int A[Q];
    for (int i = 0; i < Q; i++){
        scanf("%d",&A[i]);
        point[A[i]-1]++;
    }

    for (int i = 0; i < N; i++){
        if(point[i]>0) printf("Yes\n");
        else printf("No\n");
    }
}

Measured memory_bytes: 1280
import java.util.*;
public class Main{
    static long count=0;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] num=new int[n];
        for(int i=0;i<n;i++){
            num[i]=sc.nextInt();
        }
        mergeSort(num,0,n);
        System.out.println(count);
    }
    public static void mergeSort(int[] num,int left,int right){
        if(left+1<right){
            int mid=(left+right)/2;
            mergeSort(num,left,mid);
            mergeSort(num,mid,right);
            merge(num,left,mid,right);
        }
    }
    public static void merge(int[] num,int left,int mid,int right){
        int n1=mid-left;
        int n2=right-mid;
        int[] L=new int[n1+1];
        int[] R=new int[n2+1];
        for(int i=0;i<n1;i++){
            L[i]=num[left+i];
        }
        for(int i=0;i<n2;i++){
            R[i]=num[mid+i];
        }
        L[n1]=Integer.MAX_VALUE;
        R[n2]=Integer.MAX_VALUE;
        int l=0;
        int r=0;
        for(int k=left;k<right;k++){
            if(L[l]<R[r]){
                num[k]=L[l++];
                count+=r;
            }else{
                num[k]=R[r++];
            }
        }
    }
}


Measured memory_bytes: 101260
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i=0; i<(int)(n); i++)

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

int main(){
  int N, X;
  cin >> N >> X;
  vector<ll> x(N), y(N);
  rep(i,N){
    cin >> x.at(i);
    y.at(i) = abs(x.at(i) - X);
  }
  int ans = y.at(0);
  rep(i,N){
    ans = gcd(ans,y.at(i));
    if(ans==1) break;
  }
  cout << ans;
  return 0;
}

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

#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)1e5 + 5;

int T = 1;
int N;
string w;
map<char, int> m;

bool ok() {
        for (auto& a : m) {
                if (a.second % 2 != 0) return false;
        }
        return true;
}

void solve() {
        cin >> w;
        for (auto& c : w) {
                m[c]++;
        }
        cout << (ok() ? "Yes" : "No") << endl;
}

signed main() {
  cout << fixed << setprecision(20);
  rep(i, T) solve();
  return 0;
}

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL(x) memset(x,0,sizeof(x))


using namespace std;

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

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

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

  ll div =N/K;
  cout << min(abs(N-div*K), abs((div+1)*K-N)) << endl;

  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



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

#define int long long
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) otp(v[i]) cte
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,a;
vector<int> v;

main() {
    cin >> n;
    rep(i,n) {
        cin >> a;
        v.pb(a)
    }
    sort(all(v));
    ct(v[n-1]-v[0])
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int k[1000];
	int n,i,j,a,b,t=0,f=0;
	scanf("%d%d",&a,&b);
	for(i=1;i<=999;i++)
	{
		t+=i;
		k[i]=t;
	}
	i=1;
	while(i<499500)
	{
		t=a+i;
		for(j=1;j<1000;j++)
		{
			if(k[j]==t)
				if(k[j+1]==(b+i))
				{
					f=1;
					break;
				}
		}
		if(f==1)
		    break;
		i++;
	}
	printf("%d",i);
}

Measured memory_bytes: 128
using System;
class atcorder
{
    static void Main(string[] args)
    {
        int a,b,c;
        string[] str = Console.ReadLine().Split(' ');
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);
        c = int.Parse(str[2]);

        int num1 = b % a;
        int num2 = b - num1;
        int num3 = num2 / a;
        if(num3 >= c)
        {
            Console.Write(c);
        } 
        else{
            Console.Write(num3);
        }
    }
}

Measured memory_bytes: 11092
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
char S[300010];

signed main()
{
	cin >> N;
	cin >> S;

	int num = 0;

	for (int i = 1; i < N; i++)
	{
		if (S[i] == 'E')
		{
			num++;
		}
	}

	int min = num;

	for (int i = 1; i < N; i++)
	{
		if (S[i] == 'E')
		{
			num--;
		}
		if (S[i - 1] == 'W')
		{
			num++;
		}
		if (min > num)
		{
			min = num;
		}
	}

	cout << min << endl;
}







Measured memory_bytes: 512
#include<iostream>

#include<cstdlib>

int main() {


	int N,Z,W;
	int a[4096];

	std::cin >> N >> Z >> W;

	for (int i = 0; i < N; i++) {
		std::cin >> a[i];
	}
	
	//Xさんのターンです、彼は高Scoreを目指します

	//要素が一つしかない場合、強制的にLastとWの差がScoreとなります
	if (N == 1) {
		std::cout << abs(a[0] - W);

		return 0;
	}

	//WのScoreがラスト-1のScoreを越えている場合、ラストを取ります
	if (
		abs(a[N - 1] - W)
		>=
		abs(a[N - 1] - a[N - 2])
		) 	{
		std:: cout << abs(a[N - 1] - W);
	}
	//現在のScoreよりラスト-1のScoreが高い場合、ラスト-1を取ります
	else {
		std:: cout << abs(a[N - 1] - a[N - 2]);
	}




	return 0;

}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
from math import floor,ceil,sqrt,factorial,log
from heapq import heapify, heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from decimal import Decimal
inf = float('inf')
mod = 1000000007

a, b = map(int, input().split())

print(a*b)

Measured memory_bytes: 77380
#include<iostream>
using namespace std;
int main()
{
    string s,t;
    int i,c=0;
    cin>>s;
    cin>>t;
    for(i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        {
            c++;
        }
    }
    if(c==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;


}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <sstream>
#include <numeric>
#include <queue>
#include <sstream>
#include <set>
using namespace std;


int main(){
    string s ;
    cin >> s ;
    string a[16] = {"AKIHABARA","KIHABARA","AKIHBARA","KIHBARA",
                    "AKIHABRA","KIHABRA","AKIHBRA","KIHBRA",
                    "AKIHABAR","KIHABAR","AKIHBAR","KIHBAR",
                    "AKIHABR","KIHABR","AKIHBR","KIHBR"} ;
    for (size_t i = 0; i < 16; i++)
    {
        if (s == a[i])
        {
            cout << "YES" << endl ;
            return 0; 
        }
        
    }
    cout << "NO" << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  int b;
  int c;
  int d;
  cin >> a >> b >> c >> d;
  string ret = "No";
  if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d )) ret = "Yes";
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define INF 2000000000
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main(){
    int k;
    cin>>k;
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<a[k-1]<<endl;
}

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

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int h,w;
    cin>> h >>w;

    vector<vector<char>> s(h, vector<char>(w));
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin >> s.at(i).at(j);

    vector<vector<char>> ans(h, vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s.at(i).at(j)=='#')
                ans.at(i).at(j)='#';

            else{
                // cout << i <<j <<endl;
                int cnt =0;
                for(int d=0;d<8;d++){
                    int ni= i+dx[d];
                    int nj= j+dy[d];
                    if(ni<0 or h<=ni)continue;
                    if(nj<0 or w<=nj)continue;
                    if(s.at(ni).at(nj) == '#') cnt++;
                }
                ans.at(i).at(j)= char(cnt + '0');
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << ans.at(i).at(j);
        }
        if(i<h-1) cout << "\n" ;
    }
}

Measured memory_bytes: 256
n = int(input())
matrix = [[0] * n for _ in range(n)]
for _ in range(n):
    line = list(map(int, input().split()))
    u = line[0]
    for v in line[2:]:
        matrix[u-1][v-1] = 1
for row in matrix:
    print(' '.join(map(str, row)))



Measured memory_bytes: 5668
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=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 ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    string S,T;cin>>S>>T;
    ll N=S.size(),M=T.size();
    vvl dp(M+1,vl(N+1,0));
    repl(i,1,M+1){
        repl(j,1,N+1){
            if(T[i-1]==S[j-1])dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ll l=M,r=N;
    string ans;
    while(true){
        while(true){
            if(l==0 or r==0)break;
            if(dp[l][r]==dp[l-1][r])l--;
            else if(dp[l][r]==dp[l][r-1])r--;
            else break;
        }
        if(l==0 or r==0)break;
        if(dp[l][r]==dp[l-1][r-1]+1){
            ans=T[l-1]+ans;
            l--,r--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70784
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a,b,c,d;
        d = 0;
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        for(int i = a; i < b + 1; i++){
            if(c%i == 0){
                d = d + 1;
            }
        }
        System.out.println(d);
    }
}


Measured memory_bytes: 26408
#include <stdio.h>

void aryreset(int a[]) {
  int i;
  for (i = 0; i < 12; i++)
    a[i] = 0;
}

int aryequal(int a[], int b[], int n) {
  int i;
  for (i = 0; i < n; i++)
    if (a[i] != b[i])
      return 0;
  return 1;
}

void arycpy(int a[], int b[], int n) {
  int i;
  for (i = 0; i < n; i++)
    a[i] = b[i];
}

int main(void) {
  int n, i, j, t, count, s[12], c[12];

  while (1) {
    count = 0;
    aryreset(s);
    aryreset(c);
    scanf("%d", &n);
    if (n == 0) break;

    for (i = 0; i < n; i++)
      scanf("%d", &s[i]);
    while (1) {
      for (i = 0; i < n; i++) {
	t = 0;
	for (j = 0; j < n; j++)
	  if (s[i] == s[j])
	    t++;
	c[i] = t;
      }
      
      if (aryequal(s, c, n)) {
	printf("%d\n", count);
	printf("%d", s[0]);
	for (i = 1; i < n; i++)
	  printf(" %d", s[i]);
	putchar('\n');
	break;
      }
      else {
	arycpy(s, c, n);
	count++;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <cstdio>
#include <memory>

using namespace std;

struct Node {
  int key;
  Node* parent;
  Node* left;
  Node* right;
  
  Node(int key = -1) : key(key), parent(nullptr), left(nullptr), right(nullptr) {};
};

struct Tree {
  Node* root;  
  
  Tree() : root(nullptr) {};
};

static void insert(Tree& tree, int v) {
  Node* z = new Node(v);
  Node* x(tree.root);
  Node* y(nullptr);
  while (x != nullptr) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if (y == nullptr) {
    tree.root = z;
  } else if (z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
}

static bool find(const Node* node, int v) {
  if (node == nullptr) {
    return false;
  }
  if (node->key > v) {
    return find(node->left, v);
  } else if (node->key < v) {
    return find(node->right, v);
  }
  return true;
}

void preorderWalk(const Node* node) {
  if (!node->key) {
    return;
  }
  cout << " " << node->key;
  if (node->left != nullptr) {
    preorderWalk(node->left);
  }
  if (node->right != nullptr) {
    preorderWalk(node->right); 
  }
}

void inorderWalk(const Node* node) {
  if (!node) {
    return;
  }
  
  if (node->left != nullptr) {
    inorderWalk(node->left);
  }
  cout << " " << node->key;

  if (node->right != nullptr) {
    inorderWalk(node->right); 
  }
}

static Tree TREE;

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

  string command;
  int v;
  for (int i = 0; i < n; i++) {
    cin >> command;
    if (command[0] == 'i') {
      scanf("%d", &v);
      insert(TREE, v);
    } else if (command[0] == 'f') {
      scanf("%d", &v);
      bool found = find(TREE.root, v);
      cout << (found ? "yes" : "no") << endl;
    } else {
      inorderWalk(TREE.root);
      cout << endl;
      preorderWalk(TREE.root);
      cout << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 21984
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

using namespace std;
typedef long long ll;



int main(void){
	int a, b;
	cin >> a >> b;
	cout << a * b;

	cout << endl;
}


Measured memory_bytes: 3632
$<.each do |l|
  n = l.to_i
  p ([n - 2000, 0].max..[n, 2000].min).map {|i| ([i, 1000].min - [i - 1000, 0].max + 1) * ([n-i, 1000].min - [n-i - 1000, 0].max + 1) }.inject 0, :+
end

Measured memory_bytes: 8820
N,K = map(int, input().split())
H = [0]*N
for i in range(N):
  H[i] = int(input())

H.sort()
ans = float('inf')
for i in range(N-K+1):
  diff = abs(H[i] - H[i+K-1])
  if diff < ans:
    ans = diff
print(ans)

Measured memory_bytes: 7472
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (a : b : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print $ if a <= 9 && b <= 9 then a * b else (-1)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  bool conda = c - a - b >= 0;
  bool condb = 4 * a * b < (c - a - b) * (c - a - b);

  bool cond = conda && condb;

  string ans = (cond) ? "Yes" : "No";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d%d",$h,$w);
for($i=0;$i<$h;$i++){
  $c_li[]=str_split(trim(fgets(STDIN)));
}
$re_li = array();
//print_r($c_li);
$ii=0;

  for($i=1;$i<=$h*2;$i++){
    $index = (int)(($i+1)/2);
    for($j=0;$j<$w;$j++){
      //echo $index." ".$j."\n";
      $re_li[$i][$j]=$c_li[$index-1][$j];

    }
  }

//print_r($re_li);

  for($i=1;$i<=$h*2;$i++){
    for($j=0;$j<$w;$j++){
      echo $re_li[$i][$j];
    }
    echo "\n";
  }




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

int main(){
	string s; cin >> s;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == '1'){
			cout << '9';
		}else{
			cout << '1';
		}
	}
	cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define s(x) (x).begin(),(x).end();
using namespace std;
typedef long long ll; 
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; }
const ll INF = 0;
ll dp[100010];
vector<vector<int>>g;


int rec(int v){
    if(dp[v]!=-1)return dp[v];
    int ans=0;
    for(auto vn:g[v]){
        chmax(ans,rec(vn)+1);
    }
    return dp[v] = ans;
}




int main(){
    ll N,M;
    cin >> N>>M;
    g.assign(N,vector<int>());
    rep(i,N)dp[i]=-1;
    rep(i,M){
        int a,b;cin>>a>>b;
        g.at(a-1).push_back(b-1);
    }
    int ans =0;

    rep(i,N)chmax(ans,rec(i));

    cout<<ans<<endl;

}

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

void solve(long long N, long long x, std::vector<long long> a) {
    long long res = 0;
  for (int i = 0; i < N - 1; i++) {
    if (a[i] + a[i + 1] > x) {
	long long needToSub = a[i] + a[i+1] - x;
	res += needToSub;
        if (a[i + 1] < needToSub) {
	    a[i]-= needToSub-a[i+1];
	    a[i+1] = 0;
        } else {
	    a[i+1] -= needToSub;
        }
    }
  }
  cout << res << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  long long x;
  scanf("%lld", &x);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, x, std::move(a));
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cstdio> //fgets
using namespace std;

int main(){
	char str[1001];
	char word[100][100]={0};
	int longest=0;
	int check[100]={0};
	char *tmp;
	int freq=0;
	int count=0;
	int i,j;
	size_t len , prev;
	fgets(str , sizeof(str) , stdin);
		tmp=str;
		for(i=0 ; str[i]!='\0' ;i++){
			if(str[i]==' '){
				str[i]='\0';
				strcpy((char*)&word[count] , (const char*)tmp);
				tmp=str+i+1;
				count++;
			}
		}
		strcpy((char*)&word[count],(const char*)tmp);
		count++;
	for(i=0 ; i<count ; i++){
		for(j=i ; j<count ; j++){
			if(strcmp((const char*)&word[i] , (const char*)&word[j])==0){
				check[i]++;
			}
		}
	}
	for(i=0 ; i<count-1 ; i++){
		if(check[freq]<check[i+1]){
			freq=i+1;
		}
	}
		prev=strlen(word[0]);
	for (i=1 ; i<count ; i++){
		len=strlen(word[i]);
		if(len > prev){
			prev = len;
			longest=i;
		}
	}
	cout << (char*)&(word[freq]) << " "<< (char*)&(word[longest]) << endl;
	return 0;
}

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

int w(long long x)
{
	int ans;
	ans=0;
	while (x!=0)
	{
		ans+=x%10;
		x/=10;
	}
	return ans;
}

int main()
{
	int n;
	cin>>n;
	int i,x[n+1],ans=0;
	cin>>x[1];
	for (i=2;i<=n;i++)
	{
		cin>>x[i];
		if (x[i]==x[i-1])
		{
			ans++;
			x[i]=-1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(){

    int n;
    cin >> n;
    int a, b, c;
    int dp[100100][3];
    for (int i = 0; i < n; i++){//iとi+1の推移を考える
        cin >> a >> b >> c;
        dp[i+1][0] = a + max(dp[i][1], dp[i][2]);
        dp[i+1][1] = b + max(dp[i][0], dp[i][2]);
        dp[i+1][2] = c + max(dp[i][1], dp[i][0]);

    }
    cout << max({dp[n][0],dp[n][1],dp[n][2]}) << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

vector<ll> sum;
void pre_process(vector<ll> &a, vector<ll> &s)
{ //累積和のvector
    ll n = (ll)a.size();
    s.assign(n + 1, 0);
    for (ll i = 0; i < n; i++)
    {
        s[i + 1] = s[i] + a[i];
    }
}
ll query(ll i, ll j, vector<ll> &s)
{ //区間[i,j]の和
    return (s[j] - s[i]);
}

int main(){
    string s;
    cin >> s;
    ll n = s.size();
    vector<ll> cnt, ans(n);
    s.push_back('#');

    ll cou = 1;
    rep(i, n)
    {
        if (s[i] == s[i + 1])
        {
            cou++;
        }
        else
        {
            cnt.push_back(cou);
            cou = 1;
        }
    }

    //rep(i,cnt.size()) cout<<cnt[i]<<" ";
    //cout<<endl;

    pre_process(cnt, sum);
    for (ll i = 1; i <= cnt.size(); i++)
    {
        if (i % 2 == 1)
        { //R
            ans[sum[i]] += cnt[i - 1] / 2;
            ans[sum[i] - 1] += (cnt[i - 1] - cnt[i - 1] / 2);
        }
        else
        { //L
            ans[sum[i - 1]] += (cnt[i - 1] - cnt[i - 1] / 2);
            ans[sum[i - 1] - 1] += cnt[i - 1] / 2;
        }
    }

    rep(i, n)
    {
        cout << ans[i];

        if (i != n - 1)
            cout << " ";
        else
            cout << endl;
    }

    return 0;
}

Measured memory_bytes: 5536
S = input()
if S == 'SAT':
    print(1)
elif S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)


Measured memory_bytes: 2940