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

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

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

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

    int N;
    int A, B;
    cin >> N >> A >> B;

    if ((B+A) % 2 == 0) cout << "Alice" << endl;
    else cout << "Borys" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

def f(x,y):
    return x-y,x+y

def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    x = [0]*n
    y = [0]*n
    for i in range(n):
        x[i],y[i] = map(int,input().split())
    f0 = [0]*n
    f1 = [0]*n
    for i in range(n):
        f0[i],f1[i] = f(x[i],y[i])
    print(max(max(f0)-min(f0),max(f1)-min(f1)))

if __name__ == "__main__":
    main()

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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);
//----------------------------------------------------------------

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
    ll N,P;
    cin >> N >> P;
    ll ans = 1;
    auto F = prime_factorize(P);
    for (int i=0; i<F.size(); i++) {
        if (F[i].second>=N) {
            int n = F[i].second/N;
            rep(j,n) {
                ans *= F[i].first;
            }
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define lp(i, a, b) for (int i=a;i<=(int)b;++i)
#define lp2(i, a, b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define pr(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define clr(c, x) memset(c,x,sizeof(c));
template<class T> using OS = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int N = (int) 2e5 + 5;
const ll mod = 998244353;
int arr[N];
int n, m, l, r;

int main() {
    FAST;
    cin >> n >> m;
    lp(i, 1, m) {
        cin >> l >> r;
        arr[l]++;
        arr[r + 1]--;
    }
    int cnt = 0;
    lp(i, 1, n) {
        arr[i] += arr[i - 1];
        if (arr[i] == m) cnt++;
    }
    f(cnt);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

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

int main(){
	int n;
	cin >> n;
	vector <int> a(n), b(n);
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		cin >> b[i];
		
	int j = 0, prev = -1;
	for(int i = 0; i < n; i++){
		if(a[i] != prev)
			j = 0;
		
		if(b[i] == a[i]){
			for(j; j < n; j++)
				if(b[j] != a[i] && a[i] != a[j]){
					swap(b[i], b[j]);
					break;
				}
			
			if(a[i] == b[i])
				return cout << "No" << endl, 0;
		}
		prev = a[i];
	}
	
	cout << "Yes" << endl;
	for(int i = 0; i < n; i++)
		cout << b[i] << ' ';
	cout << endl;
	
	return 0;
}


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


int cnt_digit(long long n){
    int cnt=0;

    while(n>0){
        n/=10;
        cnt++;
    }

    return cnt;
}

int main(void){
    long long N;
    cin >> N;
    int ans=cnt_digit(N);
    
    for(long long i=1; i*i<=N; i++){
        if(N%i==0){
            int a=cnt_digit(i);
            int b=cnt_digit(N/i);
            int tmp=max(a,b);
            ans=min(tmp,ans);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <inttypes.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t N;
    char S[51];
    intmax_t ans = 0;

    scanf("%jd", &N);
    scanf("%s", S);

    for (size_t i = 0; i <= N - 3; i++) {
        if (strncmp(&S[i], "ABC", 3) == 0)
            ans++;
    }

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<cassert>
#include<algorithm>

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

#define sq(x)      ((x)*(x))
#define sqsum(x,y) (sq(x)+sq(y))

using namespace std;

struct path{ int n,t[1001],x[1001],y[1001]; };

struct event{ // ロボットの接触イベント
	double t;
	int u,v,io; // ロボット u と v が触れた(io=0)か離れた(io=1)か
	bool operator<(const event &e)const{ return t<e.t; }
};

vector<double> solve_quadratic_equation(double a,double b,double c){
	if(a==0) return vector<double>(0); // a==0 は 2 つのロボットが相対的にみて動いてないということだから, このときイベントは起こらない

	if(b*b-4*a*c<0) return vector<double>(0);
	vector<double> res(2);
	res[0]=(-b-sqrt(b*b-4*a*c))/(2*a);
	res[1]=(-b+sqrt(b*b-4*a*c))/(2*a);
	return res;
}

// パス P の時刻 t での位置を求める
void calc_point(const path &P,int t,int &x,int &y){
	x=P.x[0];
	y=P.y[0];
	rep(i,P.n-1){
		if(t<=P.t[i+1]){
			x+=(t-P.t[i])*P.x[i+1];
			y+=(t-P.t[i])*P.y[i+1];
			return;
		}
		x+=(P.t[i+1]-P.t[i])*P.x[i+1];
		y+=(P.t[i+1]-P.t[i])*P.y[i+1];
	}
	assert(0);
}

int R;

void calc_touch_points(const path &P,const path &Q,int u,int v,vector<event> &E){
	vector<int> t;
	t.insert(t.end(),P.t,P.t+P.n);
	t.insert(t.end(),Q.t,Q.t+Q.n);
	sort(t.begin(),t.end());
	t.erase(unique(t.begin(),t.end()),t.end());

	rep(k,t.size()-1){
		int x1,y1,x2,y2,x3,y3,x4,y4;
		calc_point(P,t[ k ],x1,y1);
		calc_point(P,t[k+1],x2,y2);
		calc_point(Q,t[ k ],x3,y3);
		calc_point(Q,t[k+1],x4,y4);

		int a=sqsum(x2-x1+x3-x4,y2-y1+y3-y4);
		int b=2*(x2-x1+x3-x4)*(x1-x3)+2*(y2-y1+y3-y4)*(y1-y3);
		int c=sqsum(x1-x3,y1-y3)-R*R;
		vector<double> sol=solve_quadratic_equation(a,b,c);
		if(sol.size()==2){
			if(0<=sol[0] && sol[0]<=1) E.push_back((event){t[k]+sol[0]*(t[k+1]-t[k]),u,v,0});
			if(0<=sol[1] && sol[1]<=1) E.push_back((event){t[k]+sol[1]*(t[k+1]-t[k]),u,v,1});
		}
	}
}

int main(){
	for(int n,T;scanf("%d%d%d",&n,&T,&R),n;){
		char s[100][9];
		path P[100];
		rep(i,n){
			scanf("%s",s[i]);
			int m=0,t,x,y;
			while(1){
				scanf("%d%d%d",&t,&x,&y);
				P[i].t[m]=t;
				P[i].x[m]=x;
				P[i].y[m]=y;
				m++;
				if(t==T) break;
			}
			P[i].n=m;
		}

		vector<event> E;
		rep(j,n) rep(i,j) calc_touch_points(P[i],P[j],i,j,E);

		sort(E.begin(),E.end());

		bool ans[100]={true};
		bool adj[100][100]={}; // ロボット i と j が通信できるかどうか
		// 初期状態を計算
		rep(i,n) rep(j,n) if(i!=j && sqsum(P[i].x[0]-P[j].x[0],P[i].y[0]-P[j].y[0])<=R*R) {
			adj[i][j]=adj[j][i]=true;
		}
		rep(_,n) rep(i,n) rep(j,n) if(adj[i][j]) {
			ans[i]|=ans[j];
			ans[j]|=ans[i];
		}
		// シミュレーション
		queue<int> Q;
		rep(i,E.size()){
			event e=E[i];
			int u=e.u,v=e.v;
			if(e.io==0){
				adj[u][v]=adj[v][u]=true;

				if(ans[u]==ans[v]) continue;
				// ans[u]!=ans[v] のとき
				// BFS でロボット 0 の情報を広める
				int tar=(ans[u]?v:u);
				ans[tar]=true;
				assert(Q.empty());
				Q.push(tar);
				while(!Q.empty()){
					int w=Q.front(); Q.pop();
					rep(x,n) if(adj[w][x] && !ans[x]) { ans[x]=true; Q.push(x); }
				}
			}
			else{
				adj[u][v]=adj[v][u]=false;
			}
		}

		vector<string> s_ans;
		rep(i,n) if(ans[i]) s_ans.push_back(s[i]);
		sort(s_ans.begin(),s_ans.end());
		rep(i,s_ans.size()) puts(s_ans[i].c_str());
	}

	return 0;
}

Measured memory_bytes: 2304
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	string ans = "No";
	for (int a = 1; a <= 9; ++a) {
		for (int b = 1; b <= 9; ++b) {
			if (a * b == n) {
				ans = "Yes";
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[100100];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll h(n);
  rep(i,n) cin>>h[i];
  fill(dp,dp+n,INF+1);
  
  dp[0]=0;
  irep(i,1,n){
    chmin(dp[i],abs(h[i]-h[i-1])+dp[i-1]);
    if(i!=1) chmin(dp[i],abs(h[i]-h[i-2])+dp[i-2]);
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(void) {
  int i;
  int n;
  int *arr;

  scanf("%d", &n);
  arr = (int *)malloc(sizeof(int) * n);
  for(i = 0; i < n; i++)
    scanf("%d", &arr[i]);

  qsort(arr, n, sizeof(int), compare);

  printf("%d\n", arr[n/2] - arr[n/2 - 1]);

  free(arr);
  return 0;
}


Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                int H = scan.nextInt();
                int W = scan.nextInt();
                int K = scan.nextInt();

                int output = 0;

                String[][] c = new String[H][W];

                for (int h = 0; h < H; h++) {
                	String tempS = scan.next();
                	for (int w = 0; w < W; w++) {
                		c[h][w] = tempS.substring(w, w+1);
                	}
                }

                for (int bit = 0; bit < Math.pow(2, H + W); bit++) {
                	int count = 0;
                	String[][] tempC = new String[H][W];
                	for (int h = 0; h < H; h++) {
                    	for (int w = 0; w < W; w++) {
                    		tempC[h][w] = c[h][w];
                    	}
                    }

                	for (int shift = 0; shift < H; shift++) {
                		if ((1&(bit>>shift)) == 1) {
                			for (int column = 0; column < W; column++) {
                				tempC[shift][column] = "red";
                			}
                		}
                	}

                	for (int shift = 0; shift < W; shift++) {
                		if ((1&(bit>>(shift+H))) == 1) {
                			for (int row = 0; row < H; row++) {
                				tempC[row][shift] = "red";
                			}
                		}
                	}

                    for (int h = 0; h < H; h++) {
                    	for (int w = 0; w < W; w++) {
                    		if (tempC[h][w].equals("#")) {
                    			count++;
                    		}
                    	}
                    }

                    if (count == K) {
                    	output++;
                    }

                }


                System.out.println(output);

                scan.close();

        }

}

Measured memory_bytes: 38880
package main

import (
	"fmt"
)

func COM(n, k int64) int64 {
	r := int64(1)
	for i := int64(0); i < k; i++ {
		r = ModMul(r, n-i)
		r = ModDiv(r, i+1)
	}

	return r
}

const (
	MOD = 1000000000 + 7
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

func main() {
	var N, M int
	fmt.Scanf("%d %d\n", &N, &M)
	m := map[int]bool{}
	for i := 0; i < M; i++ {
		var w int
		fmt.Scanf("%d\n", &w)
		m[w] = true
	}
	dp := [1000000]int{}
	dp[0] = 1
	for i := 0; i <= N; i++ {
		for j := i + 1; j <= N && j <= i+2; j++ {
			if m[j] {
				continue
			}
			dp[j] += dp[i]
			dp[j] %= MOD
		}
	}
	fmt.Println(dp[N])
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 13056
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
#define MOD 99994711
#define ba 47
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int64 N,X;
void Solve() {
    read(N);read(X);
    int64 ans = N;
    int64 A = X,B = N - X;
    while(A && B) {
	if(B < A) swap(A,B);
	ans += (B / A) * A * 2;
	int64 t = B % A;
	if(t == 0) ans -= A;
	B = A;A = t;
    }
    out(ans);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#define MAX 2000005
#define INFTY (1<<30)

int A[MAX];
int H = 0;

int left(int i)
{
	return 2 * i;
}
int right(int i)
{
	return 2 * i + 1;
}
int parent(int i)
{
	return i / 2;
}
void maxHeapify(int i)
{
	int l,r,largest;
	l = left(i);
	r = right(i);

	largest = i;
	if(l <= H && A[l] > A[largest]) largest = l;
	if(r <= H && A[r] > A[largest]) largest = r;

	if(largest != i)
	{
		int cur = A[i];
		A[i] = A[largest];
		A[largest] = cur;

		maxHeapify(largest);
	}
}

void heapIncreaseKey(int i, int key)
{
	if(key < A[i]) return;
	A[i] = key;
	while(i > 1 && A[i/2] < A[i]){
		int cur = A[i];
		A[i] = A[i/2];
		A[i/2] = cur;

		i /= 2;
	}
}

void insert(int key)
{
	H++;
	A[H] = -INFTY;
	heapIncreaseKey(H, key);
}


int extract()
{
	int maxv;
	if(H<1) return -INFTY;
	maxv = A[1];
	A[1] = A[H--];
	maxHeapify(1);

	return maxv;
}

int main()
{
	int key;
	char s[10];
	while(1)
	{
		scanf("%s", s);
		if(s[0] == 'i')
		{
			scanf("%d", &key);
			insert(key);
		}
		else
		{
			if(s[1] == 'x')
				printf("%d\n", extract());

			else
				break;
		}
	}

	return 0;

}


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

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	String repeat(String s, int n) {
		StringBuffer result = new StringBuffer();
		for (int i = 0; i < n; i++) {
			result.append(s);
		}
		return result.toString();
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();

		sc.close();

		StringBuffer ans = new StringBuffer();

		// (sx+1, sy) -> (tx, ty-1)
		ans.append("R");
		ans.append(repeat("R", tx - (sx + 1)));
		ans.append(repeat("U", (ty - 1) - sy));
		ans.append("U");

		// (tx-1, ty) -> (sx, sy+1)
		ans.append("L");
		ans.append(repeat("L", (tx - 1) - sx));
		ans.append(repeat("D", ty - (sy + 1)));
		ans.append("D");

		// (sx, sy-1) -> (tx+1, ty)
		ans.append("D");
		ans.append(repeat("R", (tx + 1) - sx));
		ans.append(repeat("U", ty - (sy - 1)));
		ans.append("L");

		// (tx, ty+1) -> (sx-1, sy)
		ans.append("U");
		ans.append(repeat("L", tx - (sx - 1)));
		ans.append(repeat("D", (ty + 1) - sy));
		ans.append("R");

		out.println(ans.toString());
	}

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


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), w = sc.nextInt();
        long[] ws = new long[n];
        int[] vs = new int[n];

        for (int i = 0; i < n; i++) {
            ws[i] = sc.nextInt();
            vs[i] = sc.nextInt();
        }
        System.out.println(maxKnapsack2D(ws, vs, w));
    }


    private static long maxKnapsack1D(long[] ws, int[] vs, int w) {
        int totVal = 0;
        for (int v : vs) totVal += v;
        long[] dp = new long[totVal + 1];

        Arrays.fill(dp, w + 1);
        dp[0] = 0;
        for (int i = 0; i < ws.length; i++) {
            for (int s = totVal; s >= 0; s--) {
                if (s >= vs[i])
                    dp[s] = Math.min(dp[s - vs[i]] + ws[i], dp[s]);
            }
        }

        long res = 0;
        for (int i = 0; i <= totVal; i++) {
            if (dp[i] <= w) {
                res = Math.max(res, i);
            }
        }
        return res;
    }

    private static long maxKnapsack2D(long[] ws, int[] vs, int w) {
        int totVal = 0;
        for (int v : vs) totVal += v;
        long[][] dp = new long[ws.length + 1][totVal + 1];

        Arrays.fill(dp[0], w + 1);
        dp[0][0] = 0;
        for (int i = 1; i <= ws.length; i++) {
            for (int s = totVal; s >= 0; s--) {
                dp[i][s] = dp[i - 1][s];
                if (s >= vs[i - 1])
                    dp[i][s] = Math.min(dp[i - 1][s - vs[i - 1]] + ws[i-1], dp[i][s]);
            }
        }

        long res = 0;
        for (int i = 0; i <= totVal; i++) {
            if (dp[ws.length][i] <= w) {
                res = Math.max(res, i);
            }
        }
        return res;
    }
}


Measured memory_bytes: 127572
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <unordered_map>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=r-1;i>=(int)(l);--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using ll=long long;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
//int read(){int a;scanf("%lld",&a);return a;}

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 7;

signed main()
{
	int n;
	cin >> n;
	cout << n * (n + 1) / 2 << endl;
}



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

int main(){
  int n, a[101];
  int flag = 0;
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  
  for(int i=0;i<n;i++){
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0){
        flag = 1;
      }
    }
  }
  
  if(flag==0)cout << "APPROVED";
  else cout << "DENIED";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i, j, w, h;
    
    while(1){
        scanf("%d%d", &h, &w);
        if(w == 0 && h == 0) break;
        for(i = 0; i < h; i++){
            for(j = 0; j < w; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2144
#!usr/bim/python
#! -*- coding: utf-8 -*-

s = raw_input()

#alist = [chr(i) for i in range(97,97+26)]
#anum = []

#for al in alist:
#    num = s.count(al)
#    anum.append(num)

status = 0

i = 0
j = -1
while i - j <= len(s):
    if s[i] == s[j]:
        i += 1
        j -= 1
    elif s[i] == "x":
        i += 1
        status += 1
    elif s[j] == "x":
        j -= 1
        status += 1
    else:
        status = -1
        break



print status


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2

int main()
{
	int n; cin >> n;
	vector<int> p(n);
	rep(i, 0, n) cin >> p[i];

	vector<int> dp(n, INF);
	dp[0] = 0;
	rep(i, 0, n - 1)
	{
		if (p[i] == 0)
		{
			rep(j, 1, 7)
			{
				int next = i + j;
				if (next < n) dp[next] = min(dp[next], dp[i] + 1);
			}
		}
		else
		{
			if (p[i] < 0)
			{
				if (dp[i] < dp[i + p[i]])
				{
					dp[i + p[i]] = dp[i];
					i = i + p[i];
					i--;
					continue;
				}
			}
			else
			{
				dp[i + p[i]] = min(dp[i + p[i]], dp[i]);
			}
		}
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound

using namespace std;
using namespace __gnu_pbds;

template<typename T> using ordered_set =
tree <T, null_type, less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

using namespace std;

#define int long long

typedef long long ll;
typedef long double ld;

const int N = (int)(1e6 + 5);
const int M = (int)(1e9 + 7);
const int INF = (int)(1e18 + 9);
const int dx[] = {0, 0, 1, 0, -1, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 0, 1, -1, 1, -1};

signed main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
//freopen("a.in", "r", stdin);
//freopen("a.out", "w", stdout);
  string s;
  cin >> s;
  for (auto x : s) {
    if (x == ',') {
      cout << " ";
    }
    else
      cout << x;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    string s;
    cin >> s;

    int m = 0;
    for (char c : s) {
        int i = c - '0';
        m += i;
        m %= 9;
    }

    cout << (m == 0 ? "Yes" : "No") << endl;


}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
const int inf = pow(10,9);
const int nil = -1;
int i, n, m;
char c;
vector<int> r;
vector<int> g;
vector<int> b;

int main() {
    scanf(" %d", &n);
    rep(0,n) {
        scanf(" %c", &c);
        if (c == 'R') r.push_back(i);
        else if (c == 'G') g.push_back(i);
        else if (c == 'B') b.push_back(i);
    }
    long long ans = r.size() * g.size() * b.size();
    for (auto itr = r.begin();itr!=r.end();itr++) {
        for (auto itg = g.begin();itg!=g.end();itg++) {
            if (binary_search(b.begin(), b.end(), 2 * *itg - *itr)) ans--;
            if (binary_search(b.begin(), b.end(), 2 * *itr - *itg)) ans--;
            if ((*itg-*itr)%2==0 && binary_search(b.begin(), b.end(), (*itg + *itr)/2)) ans--;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3848
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;




int main() {
 int a,b,c,d;
 cin>>a>>b>>c>>d;
 cout<<min(a,b)+min(c,d)<<endl;
}


Measured memory_bytes: 256
import sys
import math
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
data = [[] for i in range(N+1)]

for i in range(N):
  a = I()
  for j in range(a):
    data[i].append(IL())

ans = 0
for i in range(1 << N):
  TF = [-1]*N
  cnt = 0
  for j in range(N):
    if ((i >> j) & 1) == 1: #j人目が正しい
      TF[j] = True
      cnt += 1
    else:
      TF[j] = False
  
  for k in range(N):
    if TF[k] == True:
      for x,y in data[k]:
        if TF[x-1] == y:
          continue
        else:
          break
      else:
        continue
      break
  else:
    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 45420
#include <cstdio>
#include <cstring>

using namespace std;

char S[105];
int ans;

int main()
{
    scanf(" %s", S);
    for (int i = 0; i < (int) strlen(S) / 2; i++)
    {
        if (S[i] != S[strlen(S) - i - 1]) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {
    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        int weeks = sc.nextInt();

        int debt = 100000;

        for (int i = 0; i < weeks; i++) {
            debt = (int) Math.ceil((debt * 1.05) / 1000) * 1000;
        }

        System.out.println(debt);
    }
}

Measured memory_bytes: 26248
#include <iostream>

using namespace std;

bool mid(int y);
bool can_put(int y, int x);

int h;
bool mas[10005][4];

int main()
{
    int n;
    int y, x;
    int ans = 0;

    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;

        mas[y][x] = true;
    }

    for (int i = 0; i < h - 1; i++) {
        if (can_put(i, 0)) {
            ans++;

            mas[i][0] = mas[i][1] = mas[i + 1][0] = mas[i + 1][1] = true;
        }
        if (can_put(i, 2)) {
            ans++;

            mas[i][2] = mas[i][3] = mas[i + 1][2] = mas[i + 1][3] = true;
        }
        if (can_put(i, 1) && mid(i)) {
            ans++;

            mas[i][1] = mas[i][2] = mas[i + 1][1] = mas[i + 1][2] = true;
        }
    }

    cout << ans << endl;

    return 0;
}


bool mid(int y)
{
    int i = 0;
    ++y;
    while (y + i < h && !(mas[y + i][0] || mas[y + i][1] || mas[y + i][2] || mas[y + i][3])) i++;

    return i == 0 || i % 2;
}
    
bool can_put(int y, int x)
{
    return !(mas[y][x] || mas[y][x + 1] || mas[y + 1][x] || mas[y + 1][x + 1]);
}



Measured memory_bytes: 3124
#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];
    A[i] -= i + 1;
  }
  sort(A.begin(), A.end());
  int b = A[N / 2];
  long long ans = 0;
  for (auto a : A) {
    ans += abs(a - b);
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
 
using namespace std;
 
int main() {
	int N;
	cin >> N;
	long long back = ceil(N/15) *200;
	long long price = N*800 - back;
	cout << price << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[10]={0};
    while(n--)
    {
        int x;
        cin>>x;
        if (x<=399)
            a[0]++;
        else if (x<=799)
            a[1]++;
        else if (x<=1199)
            a[2]++;
        else if (x<=1599)
            a[3]++;
        else if (x<=1999)
            a[4]++;
        else if (x<=2399)
            a[5]++;
        else if (x<=2799)
            a[6]++;
        else if (x<=3199)
            a[7]++;
        else a[8]++;
    }
    int num=0;
    for (int i=0;i<8;i++)
        num+=(a[i]>0);
    int mn=max(num,1);
    int mx=num+a[8];
    cout<<mn<<' '<<mx<<endl;
}


Measured memory_bytes: 256
n,m,*z=map(int,open(0).read().split())
for i in range(10**n):
  S=str(i)
  if len(S)==n:
    if all(S[s-1]==str(c)for s,c in zip(z[0::2],z[1::2])):
      print(S)
      quit()
print(-1)

Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		String s;
		String t;
		FastScanner sc = new FastScanner(System.in);
		s = sc.next();
		t = sc.next();

		int ans = 0;
		for(int i = 0 ; i < 3 ; i++) {
			if(s.charAt(i) == t.charAt(i)) ans++;
		}

		System.out.println(ans);

	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if(hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

vl primes;
map<ll, ll> primeSet;
vvl buckets;
vl arr;
ll N;
vector<bool> thing;

int main(){

  ios_base::sync_with_stdio (false);
  cin.tie(NULL);
  primes = vl();
  thing = vector<bool> (1000001, true);
  FOR(i, 2, 1000001){
    if(!thing[i]) continue;
    primes.pb(i);
    primeSet[i] = primes.size()-1;
    ll s = i;
    while(s < thing.size()){
      thing[s]=false;
      s+=i;
    }
  }
  cin >> N;
  arr = vl(N, 0);

  FOR(i, 0, N) cin >> arr[i];
  buckets = vvl(primes.size(), vl());
  FOR(i, 0, N){
    ll j = 0;
    ll A = arr[i];
    if(primeSet.find(A) != primeSet.end()){
      buckets[primeSet[A]].pb(i);
      A = 1;
    }


    while(A > 1){
      if(A%primes[j]==0){
        buckets[j].pb(i);
        while(A%primes[j]==0) A = A/primes[j];
      }
      if(primeSet.find(A) != primeSet.end()){
        buckets[primeSet[A]].pb(i);
        A=1;
      }
      j++;
    }
  }


  bool pairwise = true;
  FOR(i, 0, buckets.size()){
    if(buckets[i].size() > 1) pairwise=false;
  }


  bool setwise = true;
  FOR(i, 0, buckets.size()){
    if(buckets[i].size() == N) setwise=false;
  }

  if(pairwise){
    cout << "pairwise coprime" << endl;
  }
  else if(setwise){
    cout << "setwise coprime" << endl;
  }
  else{
    cout << "not coprime" << endl;
  }
}


Measured memory_bytes: 60688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  int ans = k;
  for (int i = 1; i < n; i++) {
    ans *= (k - 1);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N), ans(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    for (int i = 0; i < N; i++) ans.at(A.at(i) - 1) = i + 1;
    for (int i = 0; i < N; i++) {
        if (i == N - 1) cout << ans.at(i) << endl;
        else cout << ans.at(i) << " ";
    }
}

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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N), B(N);
    map<ll, ll> map;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        map[A[i]] += B[i];
    }
    
    sort(A.begin(), A.end());
    for (int i = 0; i < N; i++) {
        B[i] = map[A[i]];
    }

    ll cost = 0;
    ll count = 0;

    for (int i = 0; i < N; i++) {
        if (i != 0) {
            if (A[i] == A[i-1]) continue;
        }
        cost += A[i]*B[i];
        count += B[i];
        if (count >= M) {
            cost -= (count-M)*A[i];
            break;
        }
    }

    cout << cost << endl;
    return 0;
}

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

using namespace std;

int main() {
    int N, T;
    cin >> N >> T;

    vector<int> A(N);

    int minVal = 1000000007;
    int maxDif = 0;
    int maxCnt = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];

        if (minVal > A[i]) {
            minVal = A[i];
        }

        if (A[i] - minVal == maxDif) {
            maxCnt++;
        } else if (A[i] - minVal > maxDif) {
            maxDif = A[i] - minVal;
            maxCnt = 1;
        }
    }

    cout << maxCnt << endl;

    return 0;
}


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

int main() {
    int w, q, id, nw, idx, i, j, k;
    char typ;
    bool f;

    while(cin >> w >> q) {
        if ((w==0)&&(q==0)) {
            break;
        }

        int emp[w];
        memset(emp, -1, sizeof(emp));
        for (i=0; i<q; i++) {
            cin >> typ;
            if (typ == 's') {
                cin >> id >> nw;
                idx = -1;
                for (j=0; j<w-nw+1; j++) {
                    f = true;
                    for (k=j; k<j+nw; k++) {
                        if (emp[k] != -1) {
                            f = false;
                            break;
                        }
                    }
                    if (f) {
                        idx = j;
                        break;
                    }
                }
                if (idx != -1) {
                    cout << idx << endl;
                    for (j=idx; j<idx+nw; j++) {
                        emp[j] = id;
                    }
                } else {
                    cout << "impossible" << endl;
                }
            } else {
                cin >> id;
                for (j=0; j<w; j++) {
                    if (emp[j] == id) {
                        emp[j] = -1;
                    }
                }
            }
        }

        cout << "END" << endl;
    }
    return 0;
}

Measured memory_bytes: 1168
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
(N,M) = (int(i) for i in input().split(" "))
print(max(N-M*2, 0))

Measured memory_bytes: 3952
import java.util.*;

public class Main {
    private static final long INF = 1145141919;

    public void main(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();

        long map[][] = new long[n][n];
        for (int i = 0; i < n; i++) {
            Arrays.fill(map[i], 0);
        }

        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            map[a - 1][b - 1] = c;
            map[b - 1][a - 1] = c;
        }

        long mins[][] = new long[n][n];
        for (int i = 0; i < n; i++) {
            mins[i] = dijkstra(i, n, map);
        }

        int cnt = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (map[i][j] != 0) {
                    boolean use = false;
                    for (int s = 0; s < n; s++) {
                        if (mins[s][i] + map[i][j] == mins[s][j]) {
                            use = true;
                        }
                    }
                    if (!use) {
                        cnt++;
                    }
                }
            }
        }
        System.out.println(cnt);
    }

    public long[] dijkstra(int start, int n, long map[][]) {
        long mins[] = new long[n];
        Arrays.fill(mins, INF);
        boolean flgs[] = new boolean[n];

        Queue<Node> queue = new PriorityQueue<>((o1, o2) -> Long.compare(o1.cost, o2.cost));
        queue.add(new Node(start, 0));
        while (!queue.isEmpty()) {
            Node src = queue.poll();
            if (flgs[src.id]) {
                continue;
            }

            flgs[src.id] = true;
            mins[src.id] = src.cost;

            for (int dst = 0; dst < n; dst++) {
                if (!flgs[dst] && map[src.id][dst] != 0) {
                    if (mins[dst] > mins[src.id] + map[src.id][dst]) {
                        Node next = new Node(dst, mins[src.id] + map[src.id][dst]);
                        queue.add(next);
                    }
                }
            }
        }

        return mins;
    }

    private class Node {
        int id;
        long cost;

        public Node(int id, long cost) {
            this.id = id;
            this.cost = cost;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 34360
//TLE
#include <iostream>
#include <vector>
#include <queue>
#define int long long
using namespace std;

int INF = 1e+15;
int n, m;
vector<int> et[1000];
vector<int> ec[1000];
int dp[1000];

signed main() {
	int i;
	
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c; a--; b--;
		et[a].push_back(b);
		ec[a].push_back(c);
	}
	
	for (i = 0; i < n; i++) dp[i] = -INF;
	
	queue<int> que;
	que.push(0);
	dp[0] = 0;
	
	int loopCnt = 0, updateTime = 0;
	while (!que.empty() && loopCnt <= 5000000) {
		int v = que.front(); que.pop();
		for (i = 0; i < et[v].size(); i++) {
			int nv = et[v][i];
			if (dp[nv] < dp[v] + ec[v][i]) {
				dp[nv] = dp[v] + ec[v][i];
				que.push(nv);
				if (nv == n - 1) { updateTime = loopCnt; }
			}
		}
		loopCnt++;
	}
	
	if (updateTime >= 3000000) { cout << "inf" << endl; }
	else { cout << dp[n - 1] << endl; }
	return 0;
}

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

struct edge{
    long long to;
    long long cost;
};

long long val[100001];
vector<edge> G[100001];

void dfs(long long v, long long dep){
    val[v]=dep;
    long long i;
    for(i=0; i<G[v].size(); i++){
        if(val[G[v][i].to]<0){
            dfs(G[v][i].to,dep+G[v][i].cost);
        }
    }
}

int main(){
    //input
    long long N;
    cin >> N;
    long long a,b,c;
    long long i;
    for(i=1; i<=N-1; i++){
        cin >> a >> b >> c;
        edge e = {b,c};
        G[a].push_back(e);
        edge f = {a,c};
        G[b].push_back(f);
    }
    long long Q, K;
    cin >> Q >> K;
    long long x[Q+1], y[Q+1];
    for(i=1; i<=Q; i++){
        cin >> x[i] >> y[i];
    }

    //calc
    for(i=1; i<=N; i++){
        val[i]=-1;
    }
    dfs(K,0);

    //answer
    for(i=1; i<=Q; i++){
        cout << val[x[i]]+val[y[i]] << endl;
    }
    system("pause");
    return 0;
}

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

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1; 
   // cin >> t;
    for(int T = 0; T < t ; T++){
        ll h, w;
        cin >> h >> w;
        ll a[h][w], mod = 1e9 + 7;
        string s[h];
        for(int i = 0; i < h; i++){
            cin >> s[i];
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                a[i][j] = 0;
            }
        }
        for(int i = 0; i < h; i++){
            if(s[i][0] == '.')
                a[i][0] = 1;
            else{
                break;
            }
        }
        for(int i = 0; i < w; i++){
            if(s[0][i] == '.')
                a[0][i] = 1;
            else{
                break;
            }
        }
        for(int i = 1; i < h; i++){
            for(int j = 1; j < w; j++){
                if(s[i][j] == '#')
                    a[i][j] = 0;
                else
                    a[i][j] = (a[i - 1][j] + a[i][j -1])%mod;
            }
        }
        if(s[0][0] == '.')
        cout << a[h - 1][w - 1] << endl;
        else
        cout << 0 << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    int b,f,r,v;

    int one[3][10];
    int two[3][10];
    int three[3][10];
    int four[3][10];

    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            one[i][j]=0;
            two[i][j]=0;
            three[i][j]=0;
            four[i][j]=0;
        }
    }

    for(int i=0;i<n;i++){
        cin>>b>>f>>r>>v;
        if(b==1){
            one[f-1][r-1]+=v;
        }else if(b==2){
            two[f-1][r-1]+=v;
        }else if(b==3){
            three[f-1][r-1]+=v;
        }else {
            four[f-1][r-1]+=v;
        }
    }

    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            if(one[i][j]<0)one[i][j]=0;
            if(two[i][j]<0)two[i][j]=0;
            if(three[i][j]<0)three[i][j]=0;
            if(four[i][j]<0)four[i][j]=0;
        }
    }

    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                if(i==0)     cout<<" "<<one[j][k];
                else if(i==1)cout<<" "<<two[j][k];
                else if(i==2)cout<<" "<<three[j][k];
                else         cout<<" "<<four[j][k];
            }
            cout<<endl;
        }
        if(i<3)cout<<"####################"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3076
s = input()
m = ord('a')
for i in range(26):
  c = chr(m+i)
  pj = -1
  flag = False
  for j, d in enumerate(s):
    if d!=c:
      continue
    if pj!=-1 and j-pj<3:
      print(pj+1,j+1)
      import sys
      sys.exit()
    pj = j
print(-1,-1)

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

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



Measured memory_bytes: 25216
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string weathers[3] = {"Sunny", "Cloudy", "Rainy"};
	string input;
  
  	cin >> input;
  	for(int i = 0; i < 3; i++)
    	if(input == weathers[i])
        {
          	i++;
          	if(i == 3) i = 0;
			cout << weathers[i] << endl;
          	break;
        }
  
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int f (int i);

int main(void){
    int n;
    scanf("%d",&n);
    int ans = 0;
    for(int i = 1;i <= n;i++){
        if(f(i)){
        ans++;
        }
    }
    printf("%d",ans);
}

int f (int i){
    int num = i;
    int keta = 0;
    while (num > 0){
        keta++;
        num /= 10;
    }
    return keta % 2;
}

Measured memory_bytes: 128