akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, w;
    cin >> n >> w;
    long long a[n];
    long long b[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    long long dp[n][w + 1];
    for (int i = 0; i <= w; i++) {
        if (i < a[0]) {
            dp[0][i] = 0;
        } else {
            dp[0][i] = b[0];
        }
    }
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= w; j++) {
            if (j < a[i]) dp[i][j] = dp[i - 1][j];
            else {
                dp[i][j] = max(dp[i - 1][j], b[i] + dp[i - 1][j - a[i]]);
            }
        }
    }
    cout << dp[n - 1][w];
    return 0;
}

Measured memory_bytes: 78336
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> place(N+1);
  for(int i=1; i<=N; i++){
    int a;
    cin >> a;
    place[a] = i;
  }
  set<int> se = {0,N+1};
  ll ans = 0;
  for(int i=1; i<=N; i++){
    auto itr = se.lower_bound(place[i]);
    int l,r;
    r = *itr;
    l = *(--itr);
    ans += (ll)i*(ll)(place[i]-l)*(ll)(r-place[i]);
    se.insert(place[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=152e2;

int n,m;
char s[N],t[N];

int a[N][2],b[N][2];

inline int abs(int o)
{return (o<0)?(-o):o;}

inline int min(int a,int b)
{return a<b?a:b;}

int main()
{
	scanf("%d",&n);
	scanf("%s%s",s+1,t+1);
	int u=0,v=0;
	s[0]=t[0]='.';
	fo(i,1,n)if(s[i]!=s[i-1])a[++u][1]=s[i]^48,a[u][0]=i;
	fo(i,1,n)if(t[i]!=t[i-1])b[++v][1]=t[i]^48,b[v][0]=i;
	
	int ans=n*n*2;
	
	fo(i,0,n){
		int zd=max(i+u,v);
		int lj=0,ok=1;
		fo(l,1,zd){
			int po=(l<=v)?b[l][0]:n+1;
			int co=(l<=v)?b[l][1]:2;
			int _po=(l<=i)?1:((l>i+u)?n+1:a[l-i][0]);
			int _co=(l<=i)?2:((l>i+u)?2:a[l-i][1]);
			if(_co!=co&&co!=2&&_co!=2)ok=0;
			lj=lj+abs(po-_po);
		}
		if(ok)ans=min(ans,lj);
	}
	
	u=v=0;
	fo(i,1,n)swap(s[i],t[i]);
	fo(i,1,n)if(s[i]!=s[i-1])a[++u][1]=s[i]^48,a[u][0]=i;
	fo(i,1,n)if(t[i]!=t[i-1])b[++v][1]=t[i]^48,b[v][0]=i;
	
	fo(i,0,n){
		int zd=max(i+u,v);
		int lj=0,ok=1;
		fo(l,1,zd){
			int po=(l<=v)?b[l][0]:n+1;
			int co=(l<=v)?b[l][1]:2;
			int _po=(l<=i)?1:((l>i+u)?n+1:a[l-i][0]);
			int _co=(l<=i)?2:((l>i+u)?2:a[l-i][1]);
			if(_co!=co&&co!=2&&_co!=2)ok=0;
			lj=lj+abs(po-_po);
		}
		if(ok)ans=min(ans,lj);
	}
	
	cout<<ans;
}

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

int main() {

    int w,a,b;

    cin >> w >> a >> b;

    int ans = 0;

    if(a+w < b){
        ans = b-(a+w);
    }
    else if(b+w < a){
        ans = a-(b+w);
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int x = 0;
    string S;
    cin >> S;
    vector<int> ans(N + 1, 0);
    for (int i = 1; i <= N; i++)
    {
        if (S[i - 1] == 'I')
            x++;
        else if (S[i - 1] == 'D')
            x--;
        ans[i] = x;
    }
    cout << *max_element(ans.begin(), ans.end()) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int sum_ex(int);
int input(){
    int N;
    cin >> N;
    return N; 
}
vector<int> input(int N){
    vector<int> vec(N);
    for(auto& v : vec)
        cin >> v;
    return vec;
}

vector<int> input_ex(int N){
    vector<int> vec(N);
    for(auto& v : vec){
        int rawdata = 0;
        cin >> rawdata;
        while(!(rawdata%2)){
            v++;
            rawdata/=2;
        }
    }
    return vec;
}

void Cont(){
    int K = input();//1~1000
    int A = input();
    int B = input();
    if(B-A > K){
        cout << "OK";
        return;
    }
    if(B/K - A/K || (!(B%K)) || (!(A%K))){
        cout << "OK";
        return;
    }
    else{
        cout << "NG";
        return;
    }
        
}

int main()
{
	std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Cont();
}

Measured memory_bytes: 3652
S = input()
Smod = [0] * 2019
Smod[0] = 1
ans = 0
S_i = 0
prevmod = 0
k = 1
for i in range(len(S)-1, -1, -1):
  S_i = (int(S[i]) * k + prevmod) % 2019
  ans += Smod[S_i]
  Smod[S_i] += 1
  prevmod = S_i
  k = (k * 10) % 2019
print(ans)

Measured memory_bytes: 9300
h,w=map(int,input().split())
a=[input() for _ in range(h)]
seen=[[-1]*w for _ in range(h)]
from collections import deque
todo=deque([])
for hi in range(h):
  for wi in range(w):
    if a[hi][wi]=='#':
      seen[hi][wi]=0
      todo.append((hi,wi,0))
while len(todo)>0:
  hi,wi,i=todo.popleft()
  if hi>0 and seen[hi-1][wi]==-1:
    todo.append((hi-1,wi,i+1))
    seen[hi-1][wi]=i+1
  if hi<h-1 and seen[hi+1][wi]==-1:
    todo.append((hi+1,wi,i+1))
    seen[hi+1][wi]=i+1
  if wi>0 and seen[hi][wi-1]==-1:
    todo.append((hi,wi-1,i+1))
    seen[hi][wi-1]=i+1
  if wi<w-1 and seen[hi][wi+1]==-1:
    todo.append((hi,wi+1,i+1))
    seen[hi][wi+1]=i+1
print(max([max(seeni) for seeni in seen]))


Measured memory_bytes: 162140
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

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



ll K,N;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  cin>>K;
  string s;
  cin>>s;
 
  if(s.length() <=K)
    cout<<s<<'\n';


  else{
    for(ll i = 0 ; i<K ; i++)
      cout<<s[i];

    cout<<"..."<<'\n';
  }



   

}



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

  return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define insum(a, b)  a = modsum(a, (b))
#define insubtract(a, b) a = modsubtract(a, (b))
#define inmultiply(a, b) a = modmultiply(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define cint const int &
#define SZ(a) ((int)(a.size()))
#ifdef MAX_HOME
#define watch(x) cout << (#x) << " = " << x << endl;
#else
#define watch(x) cerr << (#x) << " = " << x << endl;
#endif

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template<class T>
ostream & operator << (ostream &out, vector<T> &a) {
    out << "{";
    for (auto x : a) out << x << " ";
    return out << "}";
}

template<class T>
ostream & operator << (ostream &out, pair<T, T> &a) {
    out << "{";
    cout << a.first << ", " << a.second;
    return out << "}";
}

void smain();

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

#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
#endif

    cout << setprecision(12) << fixed;

    smain();
}
/* END OF TEMPLATE ========================================================================================================================================== */;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    while(b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

void smain() {

    int n, k;
    int g = 0;
    cin >> n >> k;
    int mx = 0;
    fori (i, n) {
        int cur;
        cin >> cur;
        inmax(mx, cur);
        g = gcd(g, cur);
    }
    if (k % g == 0 && k <= mx) cout << "POSSIBLE";
    else cout << "IMPOSSIBLE";
}



Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    int h[] = new int[n];
    for (int i = 0; i < n; i++) {
      h[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(h);
    long ans = 0;
    for (int i = n - k - 1; i >= 0; i--) {
      ans += h[i];
    }
    pw.println(ans);
  }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,N;
int A[10101],B[101010];
ll dp[20100];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>N;
	FOR(i,20001) dp[i]=1LL<<60;
	dp[0]=0;
	FOR(i,N) {
		cin>>x>>y;
		FOR(j,H) dp[j+x]=min(dp[j+x],dp[j]+y);
	}
	
	ll mi=1LL<<60;
	for(i=H;i<=20000;i++) mi=min(mi,dp[i]);
	cout<<mi<<endl;
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using graph=vector<vector<int>>;
vector<int> dist_ao,dist_tak;
graph G;
int N;

void dfs(int v,vector<int> &dist){
	for(auto nv : G[v]){
		if(dist[nv]>=0)continue;
		dist[nv]=dist[v]+1;
		dfs(nv,dist);
	}
}

signed main(){
	cin>>N;
	int u,v; v=0; u=N-1;
	G.assign(N,vector<int>(0));
	for(int i=0;i<N-1;i++){
		int a,b; cin>>a>>b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dist_ao.assign(N,-1);
	dist_tak.assign(N,-1);
	dist_ao[v]=0;
	dist_tak[u]=0;
	dfs(u,dist_tak);
	dfs(v,dist_ao);
	int fen=0,sunu=0;
	for(int i=0;i<N;i++){
		if(dist_ao[i]>dist_tak[i])fen++;
		else sunu++;
	}
	cout<<(fen<sunu ? "Fennec" : "Snuke")<<endl;
}

Measured memory_bytes: 12032
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    REP(i, ty - sy) cout << 'U';
    REP(i, tx - sx) cout << 'R';
    REP(i, ty - sy) cout << 'D';
    REP(i, tx - sx + 1) cout << 'L';
    REP(i, ty - sy + 1) cout << 'U';
    REP(i, tx - sx + 1) cout << 'R';
    cout << 'D' << 'R';
    REP(i, ty - sy + 1) cout << 'D';
    REP(i, tx - sx + 1) cout << 'L';
    cout << 'U';
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
n,m,l = gets.split(" ").map(&:to_i)
b = readlines.map{|i| i.chomp.split.map(&:to_i)}
a = b.slice!(0,n)
c = Array.new(n).map{Array.new(l,0)}
n.times do |i|
  l.times do |j|
    m.times do |k|
      c[i][j] += a[i][k]*b[k][j]
    end
    print c[i][j]
    print ' ' if (j < (l-1))
  end
  puts
end

Measured memory_bytes: 9232
#include <iostream>
using namespace std;
 
int main() {
   int N,K,a,b,c,d;
    cin >>N>>K;
  
  b=K-1;
  d=K-1;
  c=N-1;
      while(c>1){
        
       
        b=b*d;
        
        c-=1;
    
    }
  
 if(K==1){
  a=1; 
 }else if(N==1){a=K;}
     else{
    a=K*b;
  
   }
 
cout << a;
 
 
    }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main()
{
    string s;
    int m, y, flag = 0;

    cin >> s;

    m = (s[0] - '0') * 10 + (s[1] - '0');
    y = (s[2] - '0') * 10 + (s[3] - '0');
    if(12 >= m && m != 0){
        flag++;
    }
    if(12 >= y && y != 0){
        flag += 2;
    }

    if(flag == 1){
        cout << "MMYY";
    }
    else if(flag == 2){
        cout << "YYMM";
    }
    else if(flag == 0){
        cout << "NA";
    }
    else{
        cout << "AMBIGUOUS";
    }


    return 0;

}

Measured memory_bytes: 256
package main

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

const (
	BUFSIZE   = 10000000
	MOD       = 1000000007
	INF_INT   = math.MaxInt32
	INF_INT64 = math.MaxInt64
)

var rdr *bufio.Reader

func main() {
	rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)
	solve()
}

func solve() {
	N := readint()
	fmt.Println(N + N*N + N*N*N)
}

func readline() string {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			fmt.Println(e.Error())
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readIntSlice(size int) []int {
	slice := make([]int, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i(v)
	}
	return slice
}

func readInt64Slice(size int) []int64 {
	slice := make([]int64, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i64(v)
	}
	return slice
}

func readint() int {
	return s2i(readline())
}

func readint64() int64 {
	return s2i64(readline())
}

// For int64
func b2i64(b bool) int64 {
	if b {
		return 1
	}
	return 0
}

func abs64(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func min64(values ...int64) int64 {
	ret := int64(INF_INT64)
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max64(values ...int64) int64 {
	ret := -int64(INF_INT64)
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i64(s string) int64 {
	v, ok := strconv.ParseInt(s, 10, 64)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int64")
	}
	return v
}

// For int
func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func min(values ...int) int {
	ret := INF_INT
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max(values ...int) int {
	ret := -INF_INT
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i(s string) int {
	v, ok := strconv.Atoi(s)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int")
	}
	return v
}

func lcm(v1, v2 int) int {
	if v1 > v2 {
		v1, v2 = v2, v1
	}
	for v1 != 0 {
		v1, v2 = v2%v1, v1
	}
	return v2
}

func gcd(v1, v2 int) int {
	return v1 * v2 / lcm(v1, v2)
}

/* ------------------------------------------------ */
/* Data stracture                                   */
/* ------------------------------------------------ */
type IntHeap []int

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }


Measured memory_bytes: 2484
N = int(input())
A = list(map(int,input().split()))
ans = 0
process = []

def cumsum(reverse=False):
    global A,ans,process
    if reverse == False:
        for i in range(len(A)-1):
            A[i+1] += A[i]
            ans += 1
            process.append([i+1,i+2])
    else:
        for i in reversed(range(len(A)-1)):
            A[i-1] += A[i]
            ans += 1
            process.append([i+2,i+1])

def addmax():
    global A,ans,process
    ind = A.index(max(A))
    m = max(A)
    for i in range(N):
        A[i] += m
        ans += 1
        process.append([ind+1,i+1])

def addmin():
    global A,ans,process
    ind = A.index(min(A))
    m = min(A)
    for i in range(N):
        A[i] += m
        ans += 1
        process.append([ind+1,i+1])

def main():
    global A,ans,process
    if max(A) <= 0:##すべての要素が0以下の場合
        cumsum(reverse=True)
    elif min(A) >= 0:##すべての要素が0以上の場合
        cumsum()
    else:##正、負が両方ある場合
        if -1*min(A) < max(A):##最大値を足すほうが早い
            addmax()
            cumsum()
        else:##最小値を引くほうが畑井
            addmin()
            cumsum(reverse=True)
    ##出力
    print(ans)
    for i in range(ans):
        print(*process[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n/2);
  vector<int> b(n/2);
  for(int i=0; i<n/2; i++) cin >> a[i] >> b[i];
  int cnt1=0;
  int cnt2=0;
  map<int,int> p;
  map<int,int> q;
  vector<pair<int,int>> p1, q1;
  for(int i=0; i<n/2; i++){
    p[a[i]]++;
    q[b[i]]++;
  }
  for(pair<int, int> x : p){
    p1.push_back(make_pair(x.second, x.first));
  }
  for(pair<int, int> x : q){
    q1.push_back(make_pair(x.second, x.first));
  }
  sort(p1.rbegin(), p1.rend());
  sort(q1.rbegin(), q1.rend());
  cnt1 = p1[0].first;
  cnt2 = q1[0].first;
  if(p1[0].second==q1[0].second){
    if(cnt1>cnt2){
      cnt2 = q1[1].first;
    }
    else if(cnt1==cnt2){
      cnt1 = max(p1[1].first, q1[1].first);
    }
    else cnt1 = p1[1].first;
  }
  cout << n - cnt1 - cnt2 << endl;
}

Measured memory_bytes: 6520
#include <iostream>

using namespace std;

const int MAX_C = 30;
static int N, C;
static int D[MAX_C][MAX_C];
static int t[3][MAX_C];

int solve();

int solve() {
  int ans = 1 << 30;
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      for (int k = 0; k < C; k++) {
        if (i != j && j != k && k != i) {
          int tt = 0;
          for (int l = 0; l < C; l++) {
            tt += D[l][i] * t[0][l];
            tt += D[l][j] * t[1][l];
            tt += D[l][k] * t[2][l];
          }
          ans = min(ans, tt);
        }
      }
    }
  }
  return ans;
}

int main() {
  cin >> N >> C;
  int x;
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      cin >> x;
      D[i][j] = x;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> x;
      t[(i + j) % 3][x - 1] += 1;
    }
  }
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
//<<setprecision(30)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int N,K; cin>>N>>K;
  vector<int> x(N);
  rep(i,N)cin>>x.at(i);
  ll res = 0;
  rep(i,N){
    res+= min(K-x.at(i),x.at(i));
  }
  cout<<res*2<<endl;
}

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

int main(){

  double a;
  cin>>a;
  cout<<a*6.28318530717958623200<<endl;

}


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

#define ll long long int
#define ull unsigned long long int
#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

const int INF = 1e9 + 7;
const int N = 1e5+5;

int main() {

	IO; 
	
	int n;
	cin >> n;
	int mx = 0;

	map<string, int> mp;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		mp[s]++;
		mx = max(mp[s], mx);
	}
	for (auto it: mp) {
		if (it.second == mx) {
			cout << it.first << endl;
		}
	}

}


Measured memory_bytes: 19200
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,nga,ga,ans;
	cin>>a>>b>>c;
	nga=(a>b)? a:b;
	ga=(nga>c)? nga:c;
	ans=a+b+c-ga;
	cout<<ans<<endl;;
	return 0;
} 

Measured memory_bytes: 256
n, k = map(int, input().split())

l = [0] * k
r = [0] * k
dp = [0] * (n+1)
dpsum = [0] * (n+1)
dp[1] = 1
dpsum[1] = 1

for i in range(k):
    l[i], r[i] = map(int, input().split())

for i in range(2, n+1):
    for j in range(k):
        li = max(1, i - r[j])
        ri = i - l[j]
        if ri >= 0:
            dp[i] += dpsum[ri] - dpsum[li-1]
    dp[i] = dp[i] % 998244353
    dpsum[i] = (dpsum[i-1] + dp[i]) % 998244353
    
print(dp[n])


Measured memory_bytes: 24568
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
int a[106];
int main(){
    int n ; cin >> n ;
    map<ll,ll>mp;
    vector<ll> v(n);
    for(int i  =0 ; i<n ; i++){
    	  cin >> v[i];
    	  mp[v[i]]++;
	}
	vector<ll> ans ;
	ll res = 0;
	int count = 0 ;
	for(auto x : mp){
		if(x.second >=2){
			ans.push_back(x.first);
		}
		if(x.second >= 4){
			res = max(res , (x.first)*(x.first));
		}
	}
	if(ans.size() == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	sort(ans.begin() , ans.end());
	ll x = ans.back();
	ans.pop_back();
	ll y = ans.back();
	res = max(res , x*y);
	 cout << res << endl;
}



Measured memory_bytes: 10264
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define MP make_pair

inline int gn(){
    int s=0,f=1; 
    char ch = getchar();
    while(!isdigit(ch)) {if(ch == '-') f=-1;ch = getchar();}
    while(isdigit(ch)) {s=s*10+ch-'0';ch = getchar();}
    return s*f;
}

inline ll gl(){
    ll s=0,f=1; 
    char ch = getchar();
    while(!isdigit(ch)) {if(ch == '-') f=-1;ch = getchar();}
    while(isdigit(ch)) {s=s*10+ch-'0';ch = getchar();}
    return s*f;
}

const int N=2e5+100;
ll a,b,n;

void solve(){
    a=gl(),b=gl();n=gl();
    ll ans=b-1;
    if(ans>=n)ans=n;
    cout<<(a*ans)/b-a*(ans/b)<<endl;
}

int main(){
    // int t;
    // t=gn();
    // while(t--)
        solve();
}

/**
* In every life we have some trouble
* When you worry you make it double
* Don't worry,be happy.
**/


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

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i <= 50000; i++)
	{
		if ((int)floor(i * 1.08) == n)
		{
			printf("%d\n", i);
			return 0;
		}
	}
	cout << ":(";

	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        boolean flag = true;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (a[i] % 2 == 1) {
                flag = false;
            }
        }
        if (!flag) {
            System.out.println("first");
        } else {
            System.out.println("second");
        }

    }
}

Measured memory_bytes: 50556
import numpy as np

A = np.array([[1,0,0,0], [1,1,0,0], [0,0,1,0], [0,0,0,1]])
B = np.array([[1,0,0,0], [0,1,0,0], [0,1,1,0], [0,0,0,1]])
C = np.array([[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,1,1]])
Q = A + B + C

x = np.array([1,0,0,0])

for ch in raw_input().rstrip():
    if ch == 'A':
        x = np.dot(A, x) 
    elif ch == 'B':
        x = np.dot(B, x) 
    elif ch == 'C':
        x = np.dot(C, x) 
    elif ch == '?':
        x = np.dot(Q, x) 

    x %= 1000000007

print x[3]


Measured memory_bytes: 17344
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#define ll long long
using namespace std;

int main() {
	ll n;
	cin >> n;
	vector<ll>dp(n+1, LLONG_MAX);
	vector<ll>a = { 1,6,9,36,81,216,729,1296,6561,7776,46656,59049 };
	dp[0] = 0;
	for (ll i =0; i <= n; i++) {
		for (ll j = 0; j < a.size(); j++) {
			if (i+a[j]<=n) {
				dp[i + a[j]] = min(dp[i]+1, dp[i+a[j]]);

			}
		}
	}
	for (ll i = 0; i <= n; i++) {
		//cout << dp[i] << endl;
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pb push_back
#define mk make_pair
#define REP(i,a,b) for(int i=a; i<=b; i++)
#define mod 1000000007
int main()
{
    string s;
  	cin>>s;
  int n = s.size();
  int i =0;
  for(i=0;i<n-1;)
  {
	if(s[i]=='h' && s[i+1]=='i')
    {
        i += 2;
		continue;
    }
    else
      break;
  }
  //cout<<i;
  if(i==n)
    cout<<"Yes";
  else
    cout<<"No";
    
  
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int[] Num;
		Num = new int[11];
		Scanner n=new Scanner(System.in);
			for (int i = 0; i < 10;i++){
				Num[i]=n.nextInt();
		}
		
			for (int a = 9; a >= 0; a--){
				for (int b = 0; b < a; b++){
						if (Num[b] < Num[b+1]){
						Num[10]=Num[b];
						Num[b]=Num[b+1];
						Num[b+1]=Num[10];
						}
				}
				}
		
		System.out.println(Num[0]);
		System.out.println(Num[1]);
		System.out.println(Num[2]);
	}	
}

Measured memory_bytes: 17320
N, M, Q = gets.split.map &:to_i
$table = Array.new(N){[0] * N}
M.times{
  l, r = gets.split.map(&:to_i).map &:pred
  $table[l][r] += 1
}
# $table.each{|s|puts s*" "};puts
$imos = Array.new(N+1){ [0] * (N+1) }
N.times{|i|
  sum = 0
  N.times{|j|
    $imos[i+1][j+1] = sum += $table[i][j]
  }
}
# $imos.each{|s|puts s*" "};puts
N.times{|i|
  N.times{|j|
    $imos[j+1][i+1] += $imos[j][i+1]
  }
}
# $imos.each{|s|puts s*" "}


Q.times{
  p, q = gets.split.map(&:to_i).map &:pred
  p $imos[q+1][q+1] - $imos[q+1][p] - $imos[p][q+1] + $imos[p][p]
}


Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n;
  cin >> n;
  int i;
  ll c=0,d=0;
  vector<ll> a(n),b(n);
  for(i=0;i<n;i++){
    cin >> a[i];
    c+=a[i];
  }
  for(i=0;i<n;i++){
    cin >> b[i];
    d+=b[i];
  }
  if(c<d){
    cout << -1 << endl;
    return 0;
  }
  ll ans=0,sum=0;
  vector<ll> x;
  for(i=0;i<n;i++){
    if(a[i]>=b[i]){
      x.push_back(a[i]-b[i]);
    }
    else{
      sum+=b[i]-a[i],ans++;
    }
  }
  sort(x.begin(),x.end(),greater<ll>());
  for(i=0;i<x.size();i++){
    if(sum<=0){
      break;
    }
    sum-=x[i];
    ans++;
    if(sum<=0){
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5692
fun main(args: Array<String>) {
    // Your code here!
    val (K,N) = readLine()!!.split(" ").map{it.toInt()}
    val mList = readLine()!!.split(" ").map{it.toInt()}
    
    var ans = mList[N-1] - mList[0]
    for(i in 1 until N){
        ans = Math.min(ans, K - mList[i] + mList[i-1])
    }
    
    println(ans)
}


Measured memory_bytes: 82872
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7

bt = [0]*60

ans = 0

for j in range(60):
    for i in range(n):
        s = a[i]
        if((s>>j) & 1):
            ans += (i-bt[j])*(2**j)
            ans %= mod
            bt[j] += 1
        else:
            ans += bt[j]*(2**j)
            ans %= mod

print(ans)


Measured memory_bytes: 122808
#include <bits/stdc++.h>
#define MAXN 310
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int n, f[4];
double dp[MAXN][MAXN][MAXN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++){
    	int t;
    	cin >> t;
    	f[t]++;
    }
	for(int k = 0; k < MAXN - 1; k++){			
    	for(int j = 0; j < MAXN - 1; j++){
    		for(int i = 0; i < MAXN - 1; i++){
    			if(i == 0 and j == 0 and k == 0){
    				dp[i][j][k] = 0;
    				continue;
    			} 
    			double t = 0;
    			if(i > 0) t += (double) i * dp[i - 1][j][k] / n;
    			if(j > 0) t += (double) j * dp[i + 1][j - 1][k] / n;
    			if(k > 0) t += (double) k * dp[i][j + 1][k - 1] / n;
    			t++;
    			t /= (double)(i + j + k) / n;
    			//cout << t;
    			dp[i][j][k] = t;
    		}
    	}
    }
    cout << fixed << setprecision(11) << dp[f[1]][f[2]][f[3]];
}

Measured memory_bytes: 232320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,M,R;
  cin >> N >> M;
  vector<int> road(N);
  for(int i=0;i<M*2;i++){
  	cin >> R;
    road.at(R-1) += 1;
  }
  for(int i=0;i<N;i++){
  	cout << road.at(i) << endl; 
  }
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
/*
	vec1.size();
	str1.length();
	vec1.pop_back;
*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<pll> vplll;
#define rep(i,l,r) for (ll i = l; i < r; ++i)
#define reprev(i,l,r) for (ll i = r; i >= l; --i)
ll mod = 1e9+7;
ll expo_mod(ll x, ll y, ll p) 
{ 
	ll res = 1;
	x = x % p; 
	if (x == 0) 
		return 0; 
	while (y > 0) 
	{
		if (y%2==1) 
			res = (res*x) % p; 
		y = y>>1; // y = y/2 
		x = (x*x) % p; 
	} 
	return res; 
} 
ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll val1,val2;
	val1=(c+b-1)/b;
	val2=(a+d-1)/d;
	if(val2>=val1)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		if (N % 2 == 0) {
			System.out.println((double)(N/2)/N);
		} else {
			System.out.println((double)(N/2+1)/N);
		}
		
		
	}

}


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

const int INF = 1e9;
int h, w, dp[110][110];
char grid[110][110];

int main()
{
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> grid[i][j];
    rep(i, h) rep(j, w) dp[i][j] = INF;
    
    dp[0][0] = (grid[0][0] == '#');
    
    rep(i, h)
    {
        rep(j, w)
        {
            if(grid[i][j] == '.' && grid[i + 1][j] == '#')
            {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
            }
            else
            {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            }

            if(grid[i][j] == '.' && grid[i][j + 1] == '#')
            {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1);
            }
            else
            {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
            }
        }
    }
    
    cout << dp[h - 1][w - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Data.Function
import Control.Monad
import Data.List
import Data.Char
import Control.Monad.State

rev a b s = take a s ++
            (reverse $ take (b+1-a) . drop a $ s) ++ drop (b+1) s
rep a b s c = take a s ++ c ++ drop (b+1) s

main :: IO ()
main = do
    str <- getLine
    q <- readLn
    cs <- replicateM q (words <$> getLine)
    (`evalStateT` str) $ forM_ cs $ \c -> do
        let   cmd = c !! 0
              a = read $ c !! 1
              b = read $ c !! 2

        s <- get
        case cmd of
            "replace" -> put $ rep a b s (c !! 3)
            "reverse" -> put $ rev a b s
            "print"   -> lift $ putStrLn $ take (b+1-a) . drop a $ s
            otherwise -> return ()
    return ()


Measured memory_bytes: 5648
#include <iostream>
#include <cmath>
using namespace std;
int a,b,h,m;
double pi=acos(-1);
int main()
{
    cin>>a>>b>>h>>m;
    h%=24,m%=60;
    double t=pi*2*h/12+2*pi/12.0*m/60;;
    double k=pi*2*m/60;
    // cout<<t<<' '<<k<<endl;
    double h=min(abs(2*pi-abs(k-t)),abs(k-t));
    //min(abs(2*pi-abs(k-t)),abs(k-t));
    // cout<<h<<endl;
    double c=sqrt(a*a+b*b-2*a*b*cos(h));
    printf("%.15lf",c);
}

Measured memory_bytes: 4160
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(){
    int a,b,c,d;
    string ans ;
    cin >> a >> b >> c >> d;
    if (abs(a-c) <= d || (abs(b-c) <= d && abs(a-b) <= d)) {
        ans = "Yes";
    }else{
        ans = "No";
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
/*input
cupofcoffee
cupofhottea
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
 
using namespace std; 
 
int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;
 
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string a,b;
	cin >> a >> b;
	int ans=0;
	rep(i, a.size()) if(a[i]!=b[i]) ans++;
	cout << ans;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

int n;
int dp[1234567];
const int mod = 1e9 + 7;
int cdp[1234567];
int last[1234567];
VI c;

int main() {
	read(n);
	FOR(i,0,n) {
		make(a); 
		last[a] = -1;
		if (!c.empty() && c.back() == a) continue;
		c.pb(a);
	}
	n = c.size();
	dp[n] = 1;
	FORD(i,n-1,0) {
		if (last[c[i]] == -1) {
			dp[i] = dp[i+1];
			cdp[c[i]] = dp[i];
			last[c[i]] = i;
		} else {
			dp[i] = (cdp[c[i]] + dp[i+1])%mod;
			cdp[c[i]] = dp[i];
			last[c[i]] = i;
		}
	}
	printf("%d\n", dp[0]);
}






Measured memory_bytes: 8052
from collections import Counter
mod=10**9+7
N=10**5+11
fac,finv,inv = [0]*N,[0]*N,[0]*N
 
def cmb_init():
        fac[0]=fac[1]=finv[0]=finv[1]=inv[1]=1
        for i in range(2,N):
                fac[i] = fac[i-1]*i%mod
                inv[i] = mod-inv[mod%i] * (mod//i) % mod
                finv[i] = finv[i-1] * inv[i] % mod
 
 
def cmb_mod(n,k):
        if n<k : return 0
        return fac[n]*(finv[k]*finv[n-k]%mod)%mod
 
n=int(input())
a=list(map(int,input().split()))
ac = Counter(a).most_common()[0][0]
sames=[i for i,x in enumerate(a) if x==ac]
same_len = sames[0]+(n-sames[1])
cmb_init()
print(n)
 
for i in range(1,n):
        nums = cmb_mod(n+1,i+1) - cmb_mod(same_len,i)
        if nums < 0: nums+=mod
        print(nums)
print(1)

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cnt = 1;
    for (int i = 1; i < n; i++) {
        if (s.at(i - 1) != s.at(i)) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    long long N,D,i,j,k,m,count;
    cin>>N>>D;
    long long X[N][D];
    for(i=0;i<N;i++){
        for(j=0;j<D;j++){
            cin>>X[i][j];
        }
    }
    count=0;
    for(i=0;i<N-1;i++){
        for(j=i+1;j<N;j++){
            m=0;
            for(k=0;k<D;k++){
                m+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            for(k=0;k<130;k++){
                if(m==k*k){
                    count++;
                }
            }
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>

int cast0(char a){
	switch(a){
		case '1':
				return 1;
		case '2':
				return 2;
		case '3':
				return 3;
		case '4':
				return 4;
		case '5':
				return 5;
		case '6':
				return 6;
		case '7':
				return 7;
		case '8':
				return 8;
		case '9':
				return 9;

	}
}
using namespace std;

int main(){
	int A, B;
	string a;
	int X;
	int Y = 1000;
	cin >> a;
	
	for(int i = 0; i < a.size(); i++){
		if(i == 0){
			A = cast0(a.at(0));
		}else if(i == 1){
			B = cast0(a.at(1));
		}else if(i > 1){
			X = 753 - ((A*100) + (B*10) + cast0(a.at(i)));
			if(X < 0) X *= -1;
			if(X < Y) Y = X;
			A = B;
			B = cast0(a.at(i));
		}
	}

	cout << Y << endl;
	
	return 0;
}

Measured memory_bytes: 256
x = input()
x_len = len(x)
count_w, count_l = 0,0
for i in range(len(x)):
  if x[i] == 'o':
    count_w += 1
  if x[i] == 'x':
    count_l += 1
    
if 15 - x_len + count_w >= 8:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
 
N, M, K = MAP()
F = [LIST() for i in range(M)]
B = [LIST() for i in range(K)]

friends = defaultdict(list)
tree = UnionFind(N)
for a, b in F:
    tree.union(a-1, b-1)
    friends[a-1].append(b-1)
    friends[b-1].append(a-1)

blocks = defaultdict(list)
for a, b in B:
    blocks[a-1].append(b-1)
    blocks[b-1].append(a-1)

for i in range(N):
    m = 0
    for b in blocks[i]:
        if tree.same(i, b):
            m += 1
    print(tree.size(i)-len(friends[i])-1-m, end=" ")
    


Measured memory_bytes: 109320
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i=0; i<N; i++){
    cin >> d[i];
  }
  int sum = 0;
  for (int i=0; i<N; i++) {
    for (int j=i+1; j<N; j++) {
      sum += d[i]*d[j];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc,char const *argv[])
{
	int n;
	cin>>n;
	int a[2][n];
	int dp[2][n];
	for(int i = 0;i < 2; ++i)
	{
		for(int j = 0;j < n; ++j)
		{
			dp[i][j] = 0;
		}
	}
	for(int i = 0;i < 2; ++i)
	{
		for(int j = 0;j < n; ++j)
		{
			cin>>a[i][j];
		}
	}
	dp[0][0] = a[0][0];
	for(int j = 1;j < n; ++j)
	{
		dp[0][j] = dp[0][j - 1] + a[0][j];
		// printf("dp[%d][%d] = %d\n",0,j,dp[0][j]);
	}
	dp[1][0] = a[0][0] + a[1][0];
	for(int j = 1;j < n; ++j)
	{
		dp[1][j] = max(dp[0][j],dp[1][j - 1]) + a[1][j];
		// printf("dp[%d][%d] = %d\n",1,j,dp[1][j]);
	}
	printf("%d\n",dp[1][n - 1]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  if (a[N - 1] - a[0] > 1){
    cout << "No" << endl;
  } else if (a[0] == a[N - 1]){
    if (a[0] * 2 <= N || a[0] == N - 1){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    int cnt = upper_bound(a.begin(), a.end(), a[0]) - a.begin();
    if (cnt > a[0]){
      cout << "No" << endl;
    } else {
      if (a[0] < N / 2){
        cout << "Yes" << endl;
      } else {
        if (a[N - 1] * 2 - N <= cnt){
          cout << "Yes" << endl;
        } else {
          cout << "No" << endl;
        }
      }
    }
  }
}

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

int main()
{
    vector<int> v;
    for (int i = 0; i < 5; i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    int k;
    cin >> k;
    for (int i = 0; i < 5; i++)
    {
        for(int j = i + 1; j < 5; j++)
        {
            if (v[j] - v[i] > k) {
                cout << ":(" << "\n";
                return 0;
            }
            
        }
        
    }
    cout << "Yay!"
         << "\n";
}

Measured memory_bytes: 256
from collections import defaultdict
n=int(input())

pf=defaultdict(int)

for m in range(2, n+1):
    pf2=defaultdict(int)
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf2[i]=pf2.get(i,0)+1
            m//=i
    if m>1:pf2[m]+=1
    for k in pf2.keys():
        pf[k]+=pf2[k]
mod=10**9+7
ans=1
for k in pf.keys():
    ans*=(pf[k]+1)%mod
    ans%=mod
print(ans)

Measured memory_bytes: 41328
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int main() {
  int N; cin >> N;
  cout << 3 * N * N << endl;
}


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

typedef pair<int,int> P;
const int MAX_W = 30*2+1;
const int MAX_H = MAX_W;
int W, H;
bool G[MAX_H][MAX_W];

void init() {
  fill(G[0], G[MAX_H], 0);
  for(int i = 1; i < H; i += 2) {
    for(int j = 1; j < W; j += 2) {
      G[i][j] = 1;
    }
  }
}

int solve() {
  const static int dx[] = {1,0,-1,0};
  const static int dy[] = {0,1,0,-1};
  queue<P> que;
  int vis[MAX_H][MAX_W];
  fill(vis[0], vis[MAX_H], -1);
  vis[0][0] = 2;
  que.push(P(0,0));
  while(!que.empty()) {
    P p = que.front();
    que.pop();
    for(int k = 0; k < 4; ++k) {
      int nx = p.first + dx[k];
      int ny = p.second + dy[k];
      if(nx < 0 || nx >= W) continue;
      if(ny < 0 || ny >= H) continue;
      if(vis[ny][nx] != -1) continue;
      if(G[ny][nx]) continue;
      vis[ny][nx] = vis[p.second][p.first] + 1;
      if(nx == W-1 && ny == H-1) return vis[ny][nx]/2;
      que.push(P(nx,ny));
    }
  }
  return 0;
}

int main() {
  while(cin >> W >> H && (W | H)) {
    W = W*2-1;
    H = H*2-1;
    init();
    for(int i = 0; i < H; ++i) {
      for(int j = 1-i%2; j < W; j += 2) {
	cin >> G[i][j];
      }
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 924