akhauriyash/Code-Regression huggingface dataset:
import collections

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

n = int(input())
c = collections.Counter(prime_factorize(n))
val = list(c.values())

# print(val)
ans = 0
for v in val:
    i = 1
    c = 1
    while v >= c:
        # print(v, c)
        ans += 1
        i += 1
        c += i
print(ans)


Measured memory_bytes: 9464
#include <stdio.h>
int prime(int );
int main(){
	int c=0,tmp,n;
	scanf("%d",&n);
	while(n--){
		scanf("%d",&tmp);
		if(prime(tmp))c++;
	}
	printf("%d\n",c);
	return 0;
}
int prime(int data){
	int i,j;
	if(data == 0 || data == 1)return 0;
	if(data == 2)return 1;
	for(i=2;i*i<=data;i++){
		if(data % i == 0)return 0;
	}
	return 1;
}

Measured memory_bytes: 596
//Bismillah Hir Rehmanir Rahim
//Allah knows best
using namespace std;
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#define endl "\n"
#define mini -10000000000000000
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
#define ll long long
#define pi 3.141592653589793
#define vi              vector<int>
#define si              set<int>
#define pb              push_back
#define mp              make_pair
#define mod             1000000007
#define rr              return 0
#define ff              first
#define in              insert
#define ss              second
#define setbits(x)      __builtin_popcountll(x)
#define zrbits(x)       __builtin_ctzll(x)
#define deb(x)          cout << #x << " = " << x << endl
#define set_bit(x, idx) x = x|1LL<<idx
#define check_bit(x, idx) min(x&(1LL<<idx),1LL)
#define toggle_bit(x, idx) x = x^(1LL<<idx)
ll vis[100001],cc;
vector<ll>arr[100001];
void dfs(ll node)
{
    vis[node]=1;
    for(ll child: arr[node])
    {
        if(vis[child]==0)
        dfs(child);
    }
}
int main()
{
    start;
    //freopen("input.txt","r",stdin);
    ll i,j,k,n,m;
    cin>>n>>m;
    ll a,b;
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        arr[a].pb(b);
        arr[b].pb(a);
    }
    for(i=1;i<=n;i++)
    {
        if(vis[i]==0)
        {
            dfs(i);
            cc++;
        }
    }
    cout<<cc-1<<endl;
    rr;
}

Measured memory_bytes: 11104
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll A[MAX_N];
ll S[MAX_N];
pl D[MAX_N], E[MAX_N];

void pre(pl C[MAX_N]) {
	S[0] = A[0];
	rep(i, 1, N) S[i] = A[i] + S[i - 1];

	for(int i = 1; i < N; i++) {
		ll diff = linf;
		int at = lower_bound(S, S + N, (S[i] + 1) / 2) - S;
		MIN(diff, abs(S[i] - S[at] * 2));
		MIN(diff, abs(S[i] - S[at - 1] * 2));
		C[i] = make_pair((S[i] - diff) / 2, (S[i] + diff) / 2);
	}
}

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	pre(D);
	reverse(A, A + N);
	pre(E);
	reverse(E, E + N);
	ll ans = linf;
	for(int i = 1; i <= N - 3; i++) {
		ll l = linf, r = -linf;
		MIN(l, D[i].fst);
		MIN(l, E[i + 1].fst);
		MAX(r, D[i].sec);
		MAX(r, E[i + 1].sec);
		MIN(ans, r - l);
	}
	cout << ans << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 18688
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r = min(a) + min(b)
for S in range(M):
    x, y, c = map(int, input().split())
    r = min(r, a[x-1] + b[y-1] - c)
print(r)


Measured memory_bytes: 18736
import java.util.*;

class Main {
	static long mod = 1000000007;
	static int N = 200000;
	static long fact[] = new long[N];
	static long inv[] = new long[N];

	static long pow(long a, long b, long m) {
		if (a == 0)
			return 0;
		if (b == 0)
			return 1;
		long temp = pow(a, b / 2, m);
		temp = ((temp % m) * (temp % m)) % m;
		if ((b & 1) > 0)
			temp = ((temp % m) * (a % m)) % m;
		return temp;
	}

	static void pre() {
		fact[0] = inv[0] = 1;
		for (int i = 1; i < N; i++) {
			fact[i] = (fact[i - 1] * i) % mod;
			inv[i] = pow(fact[i], mod - 2, mod);
		}
	}

	static long ncr(int n, int r) {
		if (n == r) {
			return 1;
		}
		long ans = fact[n];
		ans = (ans * inv[n - r]) % mod;
		ans = (ans * inv[r]) % mod;
		return ans;
	}

	public static class point implements Comparable<point> {
		int r;
		int c;

		point(int a, int b) {
			r = a;
			c = b;
		}

		public int compareTo(point o) {
			return (this.r + this.c) - (o.r + o.c);
		}
	}

	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int r = scn.nextInt();
		int c = scn.nextInt();
		int n = scn.nextInt();
	
		point p[] = new point[n];
		for (int i = 0; i < n; i++) {
			int x = scn.nextInt();
			int y = scn.nextInt();
			p[i] = new point(x, y);
		}
		pre();
		Arrays.sort(p);
		long dis[] = new long[n];
		for (int i = 0; i < n; i++) {
			dis[i] = btwdis(new point(1, 1), p[i]);
			for (int j = i - 1; j >= 0; j--) {
				dis[i] = (dis[i] - (dis[j] * btwdis(p[j], p[i]) % mod) + mod) % mod;
			}
		}

		long ans = ncr(r + c - 2, r - 1);
		for (int i = 0; i < n; i++) {
			ans = (ans - (dis[i] * btwdis(p[i], new point(r, c)) % mod) + mod) % mod;
		}

		System.out.println(ans);

	}

	private static long btwdis(point p1, point p2) {
		if (p1.r <= p2.r && p1.c <= p2.c) {
			int down = p2.r - p1.r;
			int right = p2.c - p1.c;
			return ncr(right + down, down);
		}
		return 0;
	}
}

Measured memory_bytes: 33824
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,c;
  cin>>s>>c;
  rep(i,3){
    if(s[i]==c[2-i]){
    }
    else{
      cout<<"NO"<<'\n';
      return(0);
    }
  }
  cout<<"YES"<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 1010000000
#define infll 1010000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define N 2000009
#define mod 998244353
using namespace std;

int n,m,a[N];
void fwt(int *a){
	int i,j,k,x;
	for (k=1; k<m; k<<=1)
		for (i=0; i<m; i+=k<<1)
			for (j=i; j<i+k; j++){
				x=a[j];
				a[j]=(a[j]+a[j+k])%mod; a[j+k]=(x-a[j+k]+mod)%mod;
			}
}
int ksm(int x,int y){
	int ans=1; for (; y; y>>=1,x=(ll)x*x%mod) if (y&1) ans=(ll)ans*x%mod;
	return ans;
}
int main(){
	scanf("%d",&n); m=1<<n;
	int i,sum=0;
	for (i=0; i<m; i++){ scanf("%d",&a[i]); ad(sum,a[i]); }
	sum=ksm(sum,mod-2);
	for (i=0; i<m; i++) a[i]=(ll)a[i]*sum%mod;
	fwt(a);
	a[0]=0; for (i=1; i<m; i++) a[i]=ksm(a[i]-1+mod,mod-2);
	fwt(a);
	for (i=0; i<m; i++) printf("%d\n",(a[i]-a[0]+mod)%mod);
	return 0;
}


Measured memory_bytes: 3840
n=input()
if len(n)==1:
  print(n)
elif len(n)==2:
  print(9)
elif len(n)==3:
  print(10+int(n)-100)
elif len(n)==4:
  print(909)
elif len(n)==5:
  print(909+int(n)-10000+1)
else:
  print(90909)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int find(int a,vector<int>& uf){
  if(uf[a]<0)  return a;
  return uf[a]=find(uf[a],uf);
}

void unite(int a,int b,vector<int>& uf){
  a=find(a,uf),b=find(b,uf);
  if(a==b)return;
  if(uf[a]>uf[b])swap(a,b);
  uf[a]+=uf[b];
  uf[b]=a;
}

int main(){
  int n,m; cin >>n >>m;
  vector<int>  uf(n,-1);
  rep(i,m){
    int a,b; cin >>a >>b; a--; b--;
    unite(a,b,uf);
  }
  int ans=0;
  rep(i,n) ans=min(ans,uf[i]);
  print(-ans);
}


Measured memory_bytes: 4048
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

typedef pair<int, int> pi;
/*
#define num first
#define score second
*/
bool cmp(pi lhs, pi rhs)
{
	return (lhs.second > rhs.second);
}

int main()
{
	int n, a;
	vector <pi> p;
	
	while (scanf("%d,%d", &n, &a), n != 0 || a != 0){
		p.push_back(make_pair(n, a));
	}
	
	sort(p.begin(), p.end(), cmp);
	
	int pt = 31, minnum = 0;
	for (int i = 0; i < p.size(); i++){
		if (pt == p[i].second){
			p[i].second = minnum;
		}
		else {
			pt = p[i].second;
			minnum++;
			p[i].second = minnum;
		}
	}
	
	/*for (int i = 0; i < p.size(); i++){
		cout << p[i].first << " " << p[i].second << endl;
	}*/
	
	int team;
	while (scanf("%d", &team) != EOF){
		for (int i = 0; i < p.size(); i++){
			if (team == p[i].first){
				cout << p[i].second << endl;
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 1212
#include<iostream>
#include<cstdio>
using namespace std;
int s[101],k[101];
int main()
{
	int i,j,n,m,a,b,a1,b1,q;
	cin>>n;
	for(i=1;i<=(n*(n-1))/2;i++)
	{
		cin>>a>>b>>a1>>b1;
		if(a1>b1)s[a]+=3;
		else if(b1>a1)s[b]+=3;
		else if(a1==b1)
		{
			s[a]++;
			s[b]++;
		}
	}
	for(i=1;i<=n;i++)
	{
		q=1;
		for(j=1;j<=n;j++)
		{
			if(s[i]<s[j])q++;	
		}
		k[i]=q;
	}
	for(i=1;i<=n;i++)cout<<k[i]<<endl;
	return 0;
}

Measured memory_bytes: 3088
R, G, B, N = map(int, input().split())


R, G, B = sorted((R, G, B), reverse=True)

ans = 0

for i in range(N//R+1):
    for j in range((N-R*i)//G+1):
        if (N-R*i-G*j) % B == 0:
            ans += 1

print(ans)

Measured memory_bytes: 40300
#include <stdio.h>
#include <stdlib.h>
 
void push(int);
int pop();
 
int t=0,c[100];
 
int main(){  
  int a,b;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
} 
void push(int x){
  t++;
  c[t]=x;  
}
int pop(){
  t--;
  return c[t+1];
}

Measured memory_bytes: 548
using static System.Math;using static System.Console;using System.Collections.Generic;using System.Linq;using System;
using System.Reflection;
using System.Runtime.CompilerServices;

class Program
{
    #region Reader
    static string ReadStr => Console.ReadLine();
    static string[] ReadStrs => Console.ReadLine().Split(' ');
    static int ReadInt => Convert.ToInt32(Console.ReadLine());
    static int[] ReadInts => Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    static long ReadLong => Convert.ToInt64(Console.ReadLine());
    static long[] ReadLongs => Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    #endregion

    static int mod = (int)Pow(10, 9) + 7;
    public static int Mod(int a,int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    public static long Mod(long a, int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }



    public class UnionFind
    {
        public UnionFind(int number)
        {
            Data = new List<int>();
            for (int i = 0; i < number; i++) Data.Add(-1);
        }

        /// <summary>
        /// 負なら親(絶対値はサイズ)　正なら子(絶対値は親のID)
        /// </summary>
        public List<int> Data { get; }

        public int Find(int node)
        {
            //自身が親なら、そのまま返す
            if (Data[node] < 0) return node;

            //子なら、その親を呼び、さらにその親を探す。再帰的に呼び出しrootを見つけ、全ての子の親をrootにする
            return Data[node] = Find(Data[node]);
        }

        public bool Unite(int node1, int node2)
        {
            //二つの点の親をさがす
            node1 = Find(node1);
            node2 = Find(node2);

            //二つの親が一致しているなら、することはない
            if (node1 == node2) return false;

            int parent = 0;
            int newSon = 0;

            //サイズが小さいほうが、大きい方の子になる(親のDataの値は負であることに注意)
            if (Data[node1] > Data[node2])
            {
                parent = node2;
                newSon = node1;
            }
            else
            {
                parent = node1;
                newSon = node2;
            }

            Data[parent] += Data[newSon];
            Data[newSon] = parent;

            return true;
        }
    }


    static void Main()
    {
        int[] nq = ReadInts;
        int N = nq[0];
        int Q = nq[1];

        int[][] query = new int[Q][];

        UnionFind tree = new UnionFind(N);

        for (int i = 0; i < Q; i++)
        {
            query[i] = ReadInts;
        }


        List<int> ans = new List<int>();
        for (int i = 0; i < Q; i++)
        {
            int node1 = query[i][1] ;
            int node2 = query[i][2] ;
            if (query[i][0] == 0)
            {
                tree.Unite(node1, node2);
            }
            else
            {
                ans.Add(tree.Find(node1) == tree.Find(node2) ? 1 : 0);
            }
        }

        WriteLine(string.Join("\n", ans));
    }



}



Measured memory_bytes: 26596
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);


int main(void) {

	int    N;
	long long   i,tmp = 0;

	i_cin(N);
	for (i = 1; i < N+1; i++) {
		if (!(i % 3) || !(i % 5)) continue;
		tmp += i;
	}
	ll_cout(tmp); return 0;	
}
	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}

	return 0;
}




Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

using ll = long long;

#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 input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

ll MOD = 1000000000 + 7;

int main() {
  ll input(n, k);
  vector<ll> a(n + 1);
  REP(i, n + 1) a[i] = i;
  vector<ll> cumsum(a.size() + 1, 0);
  partial_sum(a.begin(), a.end(), cumsum.begin() + 1);

  ll ans = 0;
  FOR(i, k, n + 1) {
    // print(cumsum[i], cumsum[n + 1] - cumsum[n + 1 - i]);
    (ans += (cumsum[n + 1] - cumsum[n + 1 - i]) - cumsum[i] + 1) %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  string S;
  cin >> S;

  reverse(S.begin(),S.end());
  S += '0';
  int N = S.size();

  int dp[1000010][2];
  const int INF = 1001001001;
  for(int i = 0;i <= N;i++) dp[i][0] = dp[i][1] = INF;

  dp[0][0] = 0;

  for(int i = 0;i < N;i++) {
    for(int j = 0;j < 2;j++) {
      int num = S.at(i)-'0';
      num += j;
      if(num < 10) dp[i+1][0] = min(dp[i+1][0],dp[i][j]+num);
      if(num > 0) dp[i+1][1] = min(dp[i+1][1],dp[i][j]+10-num);
    }
  }

  cout << dp[N][0] << endl;
}


Measured memory_bytes: 9220
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	bool zero = false;
	int cnt = 0;
	rep(i, n) {
		if (a[i] == 0)zero = true;
		if (a[i] < 0)cnt++;
	}
	int sum = 0;
	rep(i, n) {
		sum += abs(a[i]);
	}
	if (zero) {
		cout << sum << endl;
	}
	else {
		if (cnt % 2 == 0) {
			cout << sum << endl;
		}
		else {
			int mi = INF;
			rep(i, n) {
				chmin(mi, abs(a[i]));
			}
			cout << sum - mi*2 << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int n, k; cin >> n >> k;
	long long int a[100005];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	if(n==k){
		cout << 1 << endl;
		return 0;
	}
	int p = (n-1)/(k-1);
	int q = (n-1)%(k-1);
	if(q==0){
		cout << p << endl;
		return 0;
	}else{
		cout << p+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
using uint = unsigned int;
using ll = long long;
int H, W;
char a[1001][1001];
ll dp[1001][1001];
ll MOD = 1e9 + 7;

void input() {
    cin >> H >> W;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> a[i][j];
        }
    }
}
ll solve() {
    dp[0][0] = 1;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if((i==0&&j==0) || a[i][j] == '#') continue;
            if(i>0) {
                dp[i][j] += dp[i-1][j];
                dp[i][j] %= MOD;
            }
            if(j>0) {
                dp[i][j] += dp[i][j-1];
                dp[i][j] %= MOD;
            }
        }
    }
    return dp[H-1][W-1];
}
int main() {
    input();
    cout << solve() << endl;
}

Measured memory_bytes: 9088
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>
typedef long long ll ;
typedef double db;
typedef unsigned long long ull ;
const double pi = acos(-1.0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;

int main()
{
	double a,b,h,m;
	double hour,miniute,c,d;
	cin>>a>>b>>h>>m;
	hour=(h+(m*1.0/60))*30;
	//cout<<hour<<nw;
	miniute=m*6.0;
	d=abs(hour-miniute);
	d=min(360-d,d);
	//cout<<d<<nw;
	
	c=a*a+b*b-2*a*b*cos(d*pi/180.0);
	c=sqrt(c);
	printf("%.20f\n", c);
	//cout<<c<<nw;

	return 0;
}


Measured memory_bytes: 4236
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

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


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)



//cout<<fixed<<setprecision(10);
int main(){
    ll a,b;
    cin>>a>>b;
    if((a+b)%2==0){
        cout<<(a+b)/2<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }



    return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;
const int INF=1001001001;
//最大公約数
ll gcd(ll a,ll b){
   if(b==0) return a;
   else{
      return gcd(b,a%b);
   }
}
//最小公倍数
ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
ll f(ll x,ll c,ll d){
   ll res=x;
   res=res-x/c-x/d+x/lcm(c,d);
   return res;
}
int main(){
   ll a,b,c,d; cin>>a>>b>>c>>d;
   ll ans=f(b,c,d)-f(a-1,c,d);
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
import collections

n = int(input())
que = collections.deque()

for i in range(n):
    line = input()

    if line[0] == 'i':
        que.appendleft(int(line[7:]))
    elif line[6] == ' ':
        try:
            que.remove(int(line[7:]))
        except ValueError:
            pass
    elif line[6] == 'F':
        que.popleft()
    else:
        que.pop()

print(*que)



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

int main(){
    int n;
    cin>>n;
    vector<int> a(3);
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x%4==0) a[2]++;
        else if(x%2==0) a[1]++;
        else a[0]++;
    }
    cout<<((a[1]==0 && a[0]<=a[2]+1 || a[0]<=a[2])? "Yes" : "No")<<endl;
    return 0;
}


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

int main() {
  int a,b,t;
  cin >> a >> b >> t;
  int ans = b * (t / a);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>

int main()
{
	int a, b, c, d,e,f;
	int x = 0, y = 0;
	int z, z_;
	int ans_a = 0, ans_b = 0, ans_c = 0, ans_d = 0;
	double m,n,max = 0;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);

	m = 1.0 * e / 100;
	for (int i = 0; i <= 30; i++)
	{
		int ii = a * 100 * i;
		if (f < ii) break;
		for (int j = 0; j <= 30; j++)
		{
			int jj = b * 100 * j;
			if (f < jj + ii) break;
			for (int k = 0; k < 5000; k++)
			{
				int kk = c * k;
				if (f < ii + jj + kk) break;
				for (int l = 0; l < 5000; l++)
				{
					int ll = d * l;
					if (f < ii + jj + kk + ll) break;
					x = a*i * 100 + b*j * 100;
					y = c*k + d*l;
					if (f >= x + y && x != 0)
					{
						n = 1.0 * y / x;
						if (m >= n)
						{
							if(max <= n)
							{
								max = n;
								z = ii + jj;
								z_ = kk + ll;
							}
						}
					}
				}
			}
		}
	}
	if (z == 0)
	{
		printf("%d %d", 100 * a * 1, 0);
	}
	else
	{
		printf("%d %d", z + z_, z_);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


long double a, b;

void solve()
{
    cin >> a >> b;
    cout << fixed << setprecision(0) << floor(a*b) << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e2+10;
const int mod=1e9+7;
int dp[maxn][maxn][maxn];
vector<int>p[maxn],lim[maxn];
int n,m;
bool check(int a,int b,int c,int x)
{
	for(int i=0;i<p[x].size();i++)
	{
		int cnt=0;
		if(a>=p[x][i])cnt++;
		if(b>=p[x][i])cnt++;
		if(c>=p[x][i])cnt++;
		if(cnt!=lim[x][i])return false;
	}
	return true;
}
inline int md(int x){return x>=mod?x-mod:x;}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int l,r,x;
		scanf("%d%d%d",&l,&r,&x);
		p[r].push_back(l);
		lim[r].push_back(x);
	}
	dp[0][0][0]=1;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		for(int k=0;k<=j;k++)
		{
			if(!check(i,j,k,i)){dp[i][j][k]=0;continue;}
			dp[i+1][j][k]=md(dp[i+1][j][k]+dp[i][j][k]);
			dp[i+1][i][k]=md(dp[i+1][i][k]+dp[i][j][k]);
			dp[i+1][i][j]=md(dp[i+1][i][j]+dp[i][j][k]);
		}
	}
	int ret=0;
	for(int i=0;i<=n;i++)
	for(int j=0;j<=i;j++)ret=md(ret+dp[n][i][j]);
	printf("%d\n",ret);
}

Measured memory_bytes: 112896
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}
#define max(a, b) ((a) > (b) ? (a) : (b))
 
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;
 
signed main(void){
    ios::sync_with_stdio(false);
    int k, n;
    cin >> k >> n;
    vint as = vint();
    rep (i, n) {
        int a;
        cin >> a;
        as.push_back(a);
    }
    as.push_back(as[0] + k);
 
    int mx = 0;
    rep(i, n) {
        mx = max(mx, as[i + 1] - as[i]);
    }
    cout << k - mx << endl;
    return 0;
}

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

using namespace std;

int n;
vector <int> t;

// map <pair <int, long long int>, int> dp;

// int successor(int x, long long int k)
// {
//     if (k == 1)
//         return a[x];

//     pair <int, long long int> p = make_pair(x, k);

//     if (dp.find(p) == dp.end())
//     {
//         if (k % 2)
//             dp[p] = successor(a[x], k-1);
//         else
//             dp[p] = successor(successor(x, k/2), k/2);
//     }

//     return dp[p];
// }

// int successor(int x, long long int k)
// {
//     if (k == 1)
//         return a[x];

//     return successor(successor(x, k/2), k/2);
// }

// void precalc()
// {
//     for (int i = 1; i <= n; i++)
//     {
//         for (int j = 0; j < 22; j++)
//         {
//             dp[make_pair(i, (1LL << j))] = successor(i, (1LL << j));
//         }
//     }
// }

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

    long long int k;

    cin >> n >> k;

    t.assign(n+1, 0);

    for (int i = 1; i <= n; i++)
    {
        cin >> t[i];
    }

    int x = 1;

    int a = t[x];
    int b = t[t[x]];

    while (a != b)
    {
        a = t[a];
        b = t[t[b]];
    }

    a = x;

    while (a != b)
    {
        a = t[a];
        b = t[b];
    }

    int first = a;

    b = t[a];
    int len = 1;

    while (a != b)
    {
        b = t[b];
        len++;
    }
    
    // cout << first << " " << len << "\n";

    a = 1;

    while (k > 0 && a != first)
    {
        a = t[a];
        k--;
    }

    k = k % len;

    while (k)
    {
        k--;
        a = t[a];
    }

    cout << a << "\n";

    return 0;
}

Measured memory_bytes: 3976
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll N;cin>>N;
    if(N%2==1){
        cout<<0<<"\n";
        return 0;
    }
    //偶数なら
    ll cnt=0;
    N/=10;cnt+=N;
    while(N>0){
        N/=5;
        cnt+=N;
    }
    cout<<cnt<<"\n";
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    vi v(n);

    const int N = 100005;
    //const int N = 150;
    vi odd(N,0);
    vi even(N,0);

    REP(i,n){
        int a;
        cin>>a;
        if(i%2==0){
            even[a]++;
        }else{
            odd[a]++;
        }
    }

    int mxo=-1;
    int mxe=-1;
    int oidx=0;
    int oidx2=0;
    int eidx=0;
    int eidx2=0;
  
    REP(i,N){
        if(chmax(mxe, even[i])){
            eidx2 = eidx;
            eidx = i;
        }else if(eidx2 == -1 || even[eidx2] < even[i]){
            eidx2 = i;
        }
        if(chmax(mxo, odd[i])){
            oidx2 = oidx;
            oidx = i;
        }else if(oidx2 == -1 || odd[oidx2] < odd[i]){
            oidx2 = i;
        }
    }

    int ans = 0;
    
    if(oidx != eidx){
        ans = n-odd[oidx]-even[eidx];
    }else if(odd[oidx2] > even[eidx2]){
        ans = n-odd[oidx2]-even[eidx];
    }else{
        ans = n-odd[oidx]-even[eidx2];
    }     

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4512
import sys

sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

N,M = map(int, input().split())
lst_edge = [[] for _ in range(N)]
for _ in range(M):
	x,y = map(int, input().split())
	lst_edge[x-1].append(y-1)

dp = [-1] * N

def rec(v):
	if dp[v] != -1:
		return dp[v]
	ans = 0
	lst_nv = lst_edge[v]
	for nv in lst_nv:
		ans = max(ans, rec(nv)+1)
	dp[v] = ans
	return dp[v]

ans = 0
for v in range(N):
	ans = max(ans,rec(v))
print(ans)

Measured memory_bytes: 59056
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
int main(){
  int n;
  while(cin>>n,n){
    string s[n];
    map<int,string>m;
    vector<pair<pair<int,int>,int> >a(n);
    for(int i=0;i<n;i++){
      cin>>s[i];
      m[i]=s[i];
      a[i].se=i;
      for(int j=0;j<n-1;j++){
        int p;
        cin>>p;
        if(!p)a[i].fi.se--;
        if(p==1)a[i].fi.fi++;
      }
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++)swap(a[i].fi.se,a[i].fi.fi);
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++)
      cout<<m[a[i].se]<<endl;
  }
}

Measured memory_bytes: 3132
n = gets.to_i

ans = "Yes"
p = ""

x = Hash.new( 0 )

n.times do |i|
  s = gets.chomp
  x[ s ] += 1
  if x[ s ] > 1 then
    ans = "No"
  end

  h = s[ 0 ]
  l = s[ s.size - 1 ]
  if i == 0 then
    p = l
    next
  end

  if h != p then
    ans = 'No'
  end

  p = l
end

puts ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair

using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    if(n%2) cout<<n/2+1;
    else cout<<n/2;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a, b, c, d;
	while(1){
		scanf("%d %d %d %d", &a, &b, &c, &d);
		if((1<=a)&&(a<=100)&&(1<=b)&&(b<=100)){
			if((1<=c)&&(c<=100)&&(1<=d)&&(d<=100)){
				break;
			}
		}
	}
	 while(1){
		 c = c - b;
		 if(c<=0){
			 printf("Yes");
			 break;
		 }
		 a = a - d;
		 if(a<=0){
			 printf("No");
			 break;
		 }
	 }
	return 0;
}


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

using namespace std;

#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) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;} 

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int n,m;
   cin >> n >> m;
   vector<string> a(n);
   vector<string> b(m);
   rep(i,n)cin >> a[i];
   rep(i,m)cin >> b[i];
   
   if(m > n){
      cout << "No";
      return 0;
   }
   for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
         if(j+m-1>=n || i+m-1>=n)continue;

         bool exist = true;
         for(int y=0;y<m;y++){
            for(int x=0;x<m;x++){
               if(a[i+y][j+x] != b[y][x]){
                  exist = false;
                  break;
               }
            }
         }
         if(exist){
            cout << "Yes" << endl;
            return 0;
         }
      }
   }
   cout << "No" << endl;
   return 0;
}

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

#define int long long
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);


main(){
	FIO
	int n,q;
	cin>>n;
	int arr[n],i,j,k=0;
	map<int,int>mp;
	for(i=0;i<n;i++){
		cin>>arr[i];
		k = k^arr[i];
	}
	for(i=0;i<n;i++){
		cout<<(k^arr[i])<<" ";
	}
}

Measured memory_bytes: 5188
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int a[maxn+5];

int main()
{
    int n; scanf("%d",&n);
    rep(i,1,n) scanf("%d",&a[i]);
    ll sum=0;
    int now=a[1];
    rep(i,2,n) if(a[i]>now) now=a[i]; else sum+=now-a[i];
    printf("%lld\n",sum);
    return 0;
}

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

int main(void)
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  int n, k; cin >> n >> k;
  int ans = 0;
  vector<int> sunuke(2 * n);
  vector<int> A(n);
  for (int i = 0; i < n; i++)
    sunuke[i] = 0;
  int d;
  for (int i = 0; i < k; i++) {
    cin >> d;
    A.clear();
    for (int j = 0; j < d; j++) {
      cin >> A[i];
      A[i];
      sunuke[A[i]]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (sunuke[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <string>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> d;
    ll sum = 0;
    rep(i, N)
    {
        ll dd;
        cin >> dd;
        d.push_back(dd);
        sum += dd;
    }
    ll total = 0;
    for (int i = 0; i < N; ++i)
    {
        total += d[i] * sum;
        total -= d[i] * d[i];
    }
    cout << total  / 2;
    return 0;
}

Measured memory_bytes: 3140
//ABC109D

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) (v.begin(),v.end())
#define MP make_pair
#define pb(n) push_back(n)


int main(){
    int H,W;
    cin>>H>>W;
    VII A(H,VI(W));
    rep(i,H){rep(j,W)cin>>A[i][j];}

    vector<pair<int,int>> P;
    int cnt = 0;

    rep(i,H){
        rep(j,W-1){
            if(A[i][j]%2){
                --A[i][j];
                ++A[i][j+1];
                P.pb(MP(i+1,j+1));
                P.pb(MP(i+1,j+2));
                ++cnt;
            }
        }
        if(A[i][W-1]%2&&i!=H-1){
            --A[i][W-1];
            ++A[i+1][W-1];
            P.pb(MP(i+1,W));
            P.pb(MP(i+2,W));
            ++cnt;
        }
    }

    put(cnt);
    rep(i,P.size()) cout<<P[i].first<<" "<<P[i].second<<(i%2?"\n":" ");
}

Measured memory_bytes: 5232
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String PIN = sc.next();
		String[] PINs = PIN.split("");
		int[] li = new int[4];
		for(int count=0;count<4;count++){
			li[count] = Integer.parseInt(PINs[count]);
			if(count>0&&li[count]==li[count-1]){
				System.out.println("Bad");
				break;
			}else if(count==3){
				System.out.println("Good");
			}
		}
	}
}

Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
int main(){
	double a,b,c,d,e,f,x = 0, y = 0;
	while (~scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f)){
		x = 0; y = 0;
		x = double(b*f - c*e)/double(b*d-a*e);
		y = double(c - a*x)/double(b);
		if (x == 0) x = 0;
		if (y == 0) y = 0;
		printf("%.3lf %.3lf\n", x , y);
	}
	return 0;
}


Measured memory_bytes: 3164
// C++ program to find the longest repeated 
// non-overlapping substring 
#include"bits/stdc++.h"
using namespace std; 
  
// Returns the longest repeating non-overlapping 
// substring in str 
string longestRepeatedSubstring(string str) 
{ 
    int n = str.length(); 
    int LCSRe[n+1][n+1]; 
  
    // Setting all to 0 
    memset(LCSRe, 0, sizeof(LCSRe)); 
  
    string res; // To store result 
    int res_length  = 0; // To store length of result 
  
    // building table in bottom-up manner 
    int i, index = 0; 
    for (i=1; i<=n; i++) 
    { 
        for (int j=i+1; j<=n; j++) 
        { 
            // (j-i) > LCSRe[i-1][j-1] to remove 
            // overlapping 
            if (str[i-1] == str[j-1] && 
                LCSRe[i-1][j-1] < (j - i)) 
            { 
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1; 
  
                // updating maximum length of the 
                // substring and updating the finishing 
                // index of the suffix 
                if (LCSRe[i][j] > res_length) 
                { 
                    res_length = LCSRe[i][j]; 
                    index = max(i, index); 
                } 
            } 
            else
                LCSRe[i][j] = 0; 
        } 
    } 
  
    // If we have non-empty result, then insert all 
    // characters from first character to last 
    // character of string 
    if (res_length > 0) 
        for (i = index - res_length + 1; i <= index; i++) 
            res.push_back(str[i-1]); 
  
    return res; 
} 
  
// Driver program to test the above function 
int main() 
{ 
    int n;
    string str = "geeksforgeeks"; 
    cin >> n;
    cin >> str;
    cout << longestRepeatedSubstring(str).size() << endl;; 
    return 0; 
} 

Measured memory_bytes: 97920
import sys

s=input()
t=input()
s_list=[]
t_list=[]
for i in range(len(s)):
	s_list.append(s[i])
for j in range(len(t)):
	t_list.append(t[j])
s_list.sort()
t_list.sort(reverse=True)
print("Yes" if s_list<t_list else "No")

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
    int A, B, C;

    scanf("%d %d %d", &A, &B, &C);

    if(A == B)
        printf("%d\n", C);
    else if(A == C)
        printf("%d\n", B);
    else
        printf("%d\n", A);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; int K; int V[60] = {}; 
	cin >> N >> K; 	int S[60] = {}; 
	for(int i = 1; i <= N; i++){
		cin >> V[i]; S[i] = S[i-1] + V[i]; 
	}
	int ans = 0; 
	int A[60][60] = {}; 
	for(int i = 0; i <= N; i++){
		for(int j = i; j <= N; j++){
			int nokori = K - (i + N - j); 
			if(nokori < 0) continue; 
			vector<int> T = {}; 
			for(int k = 1; k <= i; k++){
				T.push_back(V[k]); 
			}
			for(int k = j+1; k <= N; k++){
				T.push_back(V[k]); 
			}
			sort(T.begin(), T.end()); 
			int neg = T.size(); 
			for(int l = 0; l < T.size(); l++){
				if(T[l] >= 0) {neg = l; break;}
			}
          if(neg == 0){
            for(int n = 0; n < T.size(); n++){
				A[i][j] += T[n]; 
			}
          }
          else{
			int m = min({nokori, neg, (int) T.size()}); 
			for(int n = m; n < T.size(); n++){
				A[i][j] += T[n]; 
			}
          }
		}
	}
	for(int i = 0; i < 55; i++){
		for(int j = 0; j < 55; j++){
			ans = max(ans, A[i][j]); 
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.length();
	long long ans = 0;
	long long sp_s;

	for (int i=0; i<(1 << (n-1)); i++) {
		sp_s = s[0] - '0';
		for (int j=0; j<(n-1); j++) {
			if(i & ( 1 << j )) {
				ans += sp_s;
				sp_s = 0;
			}
			sp_s = sp_s*10 + (s[j+1] - '0');
		}
		ans += sp_s;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256