akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var X = RL<int>();
            var N = X[0];
            var W = X[1];
            var dp = new List<long>[N+ 2];
            for (var i = 0; i <= N+1; i++) dp[i] = Enumerable.Repeat((long)0,W +1 ).ToList();
            var weight = new long[N + 1];
            var value = new long[N + 1];
            for (var i = 1; i <= N; i++) {
                var wv = RL<long>();
                weight[i] = wv[0];
                value[i] = wv[1];
            }

            for(var i = 0; i <= N; i++) {
                for(var w = 0; w <= W; w++) {
                    if(w - weight[i] >= 0) {
                        dp[i+ 1][w] = Math.Max(dp[i + 1][w], dp[i][(int)(w - weight[i])] + value[i]);
                    }
                    dp[i +1 ][w] = Math.Max(dp[i + 1][w], dp[i][w]);
                }
            }
          
          Console.Write(dp[N + 1][W]);
        }

        static T[] RL<T>() where T : IComparable {
            if (typeof(T) == typeof(int)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            }
            if (typeof(T) == typeof(long)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            }
            if (typeof(T) == typeof(double)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(double.Parse).ToArray();
            }
            if (typeof(T) == typeof(decimal)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(decimal.Parse).ToArray();
            }
            return (T[])(object)Console.ReadLine().Trim().Split().ToArray();
        }
    }
}


Measured memory_bytes: 104120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
    ll a,b,c;
    cin >> a >> b >> c;
    if(c-a-b<0){
        cout << "No" << endl;
    }
    else if(4*a*b<(c-a-b)*(c-a-b)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

signed main() {
	int x, y, z, k, a[1500], b[1500], c[1500], fin = 0;
	vector<int>d;
	vector<int>ans;
	cin >> x >> y >> z >> k;
	rep(i, x) cin >> a[i];
	rep(i, y) cin >> b[i];
	rep(i, z) cin >> c[i];
	rep(i, x) {
		rep(j, y) {
			d.push_back(a[i] + b[j]);
			fin++;
		}
	}
	sort(d.begin(), d.end());
	reverse(d.begin(), d.end());
	int mi = min(fin, k);
	for(long long i=0;i<mi;i++){
		rep(j, z) {
			ans.push_back(d[i] + c[j]);
		}
	}
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());
	rep(i, k) {
		cout << ans[i] << endl;
	}

	END;
}

Measured memory_bytes: 43364
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()
s = S()
t = ""
for e in s:
    if t == e:
        print("Bad")
        exit()
    t = e
print("Good")

Measured memory_bytes: 4584
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;



int main(void) {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  ll sum = inf;
  rep2(j,-100,101){
    ll kamo = 0;
    rep(i,n){
      kamo += (a[i]-j)*(a[i]-j);
    }
    sum = min(sum,kamo);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
/*

Coded and Decoded by : Yash Kapoor

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

// s.find_by_order(index);
// s.order_of_key(value);

#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll, ll>
#define vl vector<ll>
#define sl set<ll>
#define vll vector<pll>
#define ml map<ll, ll>
#define mll map<pll, ll>
#define all(a) a.begin(), a.end()
#define x first
#define y second
#define sz(x) (ll) x.size()
#define dl '\n'
#define why (ll)1000000007
//#define why         (ll)998244353
#define lp(i, a, b) for (ll i = a; i < b; ++i)
#define lpr(i, a, b) for (ll i = a; i >= b; i--)
#define lpd(i, x) for (auto i : x)
#define ios                                                                                                            \
  ios_base::sync_with_stdio(false);                                                                                    \
  cin.tie(0);                                                                                                          \
  cout.tie(0);

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base, ll power, ll mod)
{
  ll result = 1;
  while (power) {
    if (power % 2)
      result = (result * base) % mod;
    base = (base * base) % mod;
    power /= 2;
  }
  return result;
}

ll inverse(ll base, ll mod) { return fast_power(base, mod - 2, mod); }
int test = 1;
void solve() 
{
  ll n; cin >> n;
  vl a(n); lp(i,0,n) cin >> a[i];
  ll dp[n];
  dp[0] = 0;
  dp[1] = abs(a[1] - a[0]);
  lp(i,2,n){
    dp[i] = min(dp[i-1] + abs(a[i - 1] - a[i]),dp[i-2] + abs(a[i - 2] - a[i]));
  }
  cout << dp[n-1] << dl;
}

int main()
{
  // #ifndef ONLINE_JUDGE 
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt", "w", stdout);
  // #endif
  ios 
  ll t = 1;
  //cin >> t;
  while (t--) 
  {
    //cout << "Case #" << test++ << ": ";
    solve();
  }
}

Measured memory_bytes: 4680
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(),ans=0;
		for(int i=0;i<N;i++) 
		{
			int a = sc.nextInt();
			int b = sc.nextInt();
			ans += b - a+ 1;
		}
		
		System.out.println(ans);
	}
}


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

using namespace std;

int main() {
    int k, a, b;
    cin >> k >> a >> b;

    int tmp = (a / k) * k;
    if (a == tmp || (a <= tmp+k && tmp+k <= b)) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}


/* O(log n) */
struct UnionFind {
  vector<int> parent;  // parent[root] is the negative of the size.
  UnionFind(int n) : parent(n, -1){};
  bool unite(int u, int v) {
    u = root(u);
    v = root(v);
    if (u == v)
      return false;
    if (parent[u] > parent[v])
      swap(u, v);
    parent[u] += parent[v];
    parent[v] = u;
    return true;
  }
  bool issame(int u, int v) {
    return root(u) == root(v);
  }
  int root(int u) {
    return parent[u] < 0 ? u : parent[u] = root(parent[u]);
  }
  int size(int u) {
    return -parent[root(u)];
  }
};

signed main() {
  int N, M, K;
  cin >> N >> M >> K;
  vector<int> A(M), B(M);
  rep(i, M) {
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
  }
  vector<int> C(K), D(K);
  rep(i, K) {
    cin >> C[i] >> D[i];
    C[i]--, D[i]--;
  }

  vector<int> friends(N);
  rep(i, M) {
    friends[A[i]]++, friends[B[i]]++;
  }

  UnionFind u(N);
  rep(i, M) {
    u.unite(A[i], B[i]);
  }

  vector<int> size(N);
  rep(i, N) {
    size[u.root(i)]++;
  }

  vector<bool> valid_block(K, true);
  rep(i, K) {
    if (u.root(C[i]) != u.root(D[i]))
      valid_block[i] = false;
  }

  vector<int> block(N);
  rep(i, K) {
    if (!valid_block[i])
      continue;
    block[C[i]]++, block[D[i]]++;
  }

  vector<int> ans(N);
  rep(i, N) {
    ans[i] = size[u.root(i)] - friends[i] - block[i] - 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7936
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int n,x,y,ans[N];

int main() {
	qr(n); qr(x); qr(y);
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++) 
			ans[min(j-i,abs(j-y)+abs(i-x)+1)]++;
	for(int i=1;i<n;i++) pr2(ans[i]);
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }

const int MAXN = 1000000;
const int MAXTIMES = 1000000;

char s[MAXN + 1]; int slen;
char t[MAXN + 1]; int tlen;
int ntimes;

int reslen;
char sres[MAXN + MAXTIMES + 1];
char tres[MAXN + MAXTIMES + 1];

set<int> nonzero;

void process(int at) {
	int rem = ntimes;
	while (rem > 0) {
		//printf("at=%d rem=%d\n", at, rem);
		nonzero.erase(at); sres[at] = tres[at] = '0';
		int to = at - rem;
		auto it = nonzero.lower_bound(at);
		if (it != nonzero.begin()) {
			--it;
			to = max(to, *it);
		}
		assert(to >= 0);
		if (sres[to] == '0'&&tres[to] == '0') {
			rem -= at - to; at = to;
			nonzero.insert(at); sres[at] = tres[at] = '1';
		} else {
			assert(sres[to] == '0' || tres[to] == '0');
			rem -= at - to; at = to;
			if (sres[at] == '1') {
				sres[at] = '0', tres[at] = '1';
				for (--at;; --at) {
					assert(at >= 0);
					if (sres[at] == '0') {
						if (tres[at] == '0') {
							sres[at] = '1'; nonzero.insert(at); return;
						} else {
							sres[at] = '1'; break;
						}
					} else {
						assert(tres[at] == '0');
						sres[at] = '0'; nonzero.erase(at);
					}
				}
			} else {
				tres[at] = '0', sres[at] = '1';
				for (--at;; --at) {
					assert(at >= 0);
					if (tres[at] == '0') {
						if (sres[at] == '0') {
							tres[at] = '1'; nonzero.insert(at); return;
						} else {
							tres[at] = '1'; break;
						}
					} else {
						assert(sres[at] == '0');
						tres[at] = '0'; nonzero.erase(at);
					}
				}
			}
		}
	}
}

void run() {
	scanf("%d%d%d%s%s", &slen, &tlen, &ntimes, s, t);

	reslen = max(slen, tlen) + ntimes;
	REP(i, reslen) sres[i] = slen - reslen + i >= 0 ? s[slen - reslen + i] : '0'; sres[reslen] = '\0';
	REP(i, reslen) tres[i] = tlen - reslen + i >= 0 ? t[tlen - reslen + i] : '0'; tres[reslen] = '\0';
	//printf("%s\n%s\n", sres, tres);

	REP(i, reslen) if (sres[i] != '0' || tres[i] != '0') nonzero.insert(i);
	REP(i, reslen) if (sres[i] == '1'&&tres[i] == '1') process(i);
	//printf("%s\n%s\n", sres, tres);

	int soff = 0; while (soff < reslen&&sres[soff] == '0') ++soff;
	int toff = 0; while (toff < reslen&&tres[toff] == '0') ++toff;
	printf("%s\n%s\n", sres + soff, tres + toff);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 56320
# 01BFS
INF = 10**9 + 7


def main():
    from collections import deque
    H, W = (int(i) for i in input().split())
    Ch, Cw = (int(i)-1 for i in input().split())
    Dh, Dw = (int(i)-1 for i in input().split())
    A = [input() for i in range(H)]

    def bfs_2d(c, sy, sx, gh, gw, H, W):
        que0 = deque()
        que1 = deque()
        dist = [[INF]*W for i in range(H)]

        dist[sy][sx] = 0
        que0.append((sy, sx))
        while que0 or que1:
            if que0:
                uh, uw = que0.popleft()
            else:
                uh, uw = que1.popleft()
            for dh in range(-2, 3):
                for dw in range(-2, 3):
                    next_h = uh + dh
                    next_w = uw + dw
                    cost = 0 if abs(dh) + abs(dw) <= 1 else 1
                    if not(0 <= next_h < H and 0 <= next_w < W):
                        continue
                    if c[next_h][next_w] == "#":
                        continue
                    if dist[next_h][next_w] > dist[uh][uw] + cost:
                        dist[next_h][next_w] = dist[uh][uw] + cost
                        if cost == 0:
                            que0.append((next_h, next_w))
                        else:
                            que1.append((next_h, next_w))
        return dist[gh][gw] if dist[gh][gw] != INF else -1

    ans = bfs_2d(A, Ch, Cw, Dh, Dw, H, W)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 100248
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vi a(n), b(n), v;;
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) v.pb(a[i] - b[i]);
	sort(all(v));
	
	dbg(v);
	
	int ans = 0;
	ll rem = 0;
	for(int i = 0, j = n - 1; i <= j; i++){
		if(v[i] >= 0){
			cout << ans << endl;
			return 0;
		}
		while(i < j && rem + v[i] < 0){
			ans++;
			rem += v[j--];
		}
		ans++;
		rem += v[i];
		if(rem < 0){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1660
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 105
#define INF 40000000
int a[MAXN];
int main()
{
	int ans=INF,n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int i=-100;i<=100;i++)
	{
		int cnt=0;
		for(int j=0;j<n;j++)
			cnt+=(a[j]-i)*(a[j]-i);
		ans=min(ans,cnt);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

vector<int> A;
vector<int> B;

int main(){
	
    int a;
    int sum = 0;
    char b;
    bool test = true;
    
    A.clear();
    B.clear();
    
    for(int i=0; b!='=';i++) {
    	
    	cin >> a >> b;
    	A.push_back(a);
    	B.push_back(b);
    	
	}
	sum = A[0];
	B[B.size()+1] = '=';
    	for(int i=0;i<A.size();i++) {
    		
    		switch(B[i]) {
    			
    			case '+':
    			sum = ( A[i] + A[i+1]);
    			A[i+1] = sum;
    			break;
    			
    			case '-':
    			sum = ( A[i] - A[i+1]);
    			A[i+1] = sum;
    			break;
    			
    			case '*':	
    			sum = ( A[i] * A[i+1]);
    			A[i+1] = sum;
    			break;
    			
    			case '/':	
    			sum = ( A[i] / A[i+1]);
    			A[i+1] = sum;
    			break;
    			
    			default :
    			cout << sum << "\n";
    			break;
    				
			}
    			
		}
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int main() {
   int K;
   cin >>K;
  vector<int> vec;

  vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  cout << vec.at(K-1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <set>
#include <vector>
#include <list>
#include <deque>
#include <algorithm>
#include <stack>
#include <numeric>
#include <time.h>
#include<iomanip>
#pragma warning(disable:4996)
using namespace std;
const int inf = 0x7f7f7f7f;
const long long mod = 1e9 + 7;
pair<int, int>q[120000];
set<int>p[120000];
map<int, int>a;
int main()
{
	int n, m;
	cin >> n >> m;
	set<int>::iterator iter;
	map<int, int>::iterator it;
	for (int i = 0; i < m; i++)
	{
		cin >> q[i].first >> q[i].second;
		p[q[i].first].insert(q[i].second);
	}
	for (int i = 1; i <=n; i++)
	{
		int k = 1;
		for (iter = p[i].begin(); iter != p[i].end(); iter++)
			a[*iter] = k++;
	}
	for (int i = 0; i < m; i++)
	{
		printf("%06d", q[i].first);
		it = a.find(q[i].second);
		printf("%06d\n", it->second);
	}
}
// 运行程序: Ctrl + F5 或调试 >“始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门提示:
//   1. 使用解决方案资源管理器窗口添 加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件

Measured memory_bytes: 17280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int main()
{
	int n, m;
	cin >> n >> m;
	ll d[100001];
	d[0] = 0;
	FOR(i, 1, n)
	{
		int t; cin >> t;
		d[i] = d[i - 1] + t;
	}
	ll cnt = 0, tmp = 0;
	REP(i, m)
	{
		int a;
		cin >> a;
		cnt += abs(d[tmp] - d[tmp + a]);
		tmp += a;
	}
	cout << cnt%100000 << endl;
	return 0;
}

Measured memory_bytes: 1936
/*input
4
20 11 9 24
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
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>; 
//change null_type to get ordered_map
#define N  100005
void solve()
{
	lld n;
	cin >> n;
	vi val(n+1,0);
	rep(i,0,n){
		cin >> val[i];
	} 
	val[n]=val[0];
	vi ans(n,0);
	rep(i,0,n){
		lld t=i+1;
		ans[i]=val[i]^val[i+1];
	}
	lld xxor=0;
	for(lld i=0;i<n;i+=2){
		xxor^=ans[i];
	}
	rep(i,0,n){
		cout << (xxor^val[i]) << ' ';
	}
	cout << endl;	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 6344
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    String S = sc.next();
    boolean flag = true;
    for (int i = 0; i < A; i++) {
      if (S.charAt(i) == '-') {
        flag = false;
      }
    }
    if (S.charAt(A) != '-') {
      flag = false;
    }
    for (int i = A + 1; i < A + B; i++) {
      if (S.charAt(i) == '-') {
        flag = false;
      }
    }
    if (flag) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 10000000000
#define PI 3.141592653589793

int main() {
	int k, a, b;
	string ans = "NG";
	cin >> k >> a >> b;

	for (int i = a; i < b + 1; i++) {
		if (i%k == 0) {
			ans = "OK";
			break;
		}
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 3560
/*input
150
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=500005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

double f[maxn];

int s(ll i){
	if(i<10) return i;
	return i%10+s(i/10);
}

int cnt(ll n){
	if(n<10) return n;
	return n%10+cnt(n/10);
}

int main()
{
	IOS;
	ll ans=1,p=1;
	int n;
	cin>>n;
	REP(i,n){
		cout<<ans<<'\n';
		if((ans+p)*cnt(ans+p*10)>(ans+p*10)*cnt(ans+p)){
			p*=10;
		}
		ans+=p;
	}	
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);    
    int A = sc.nextInt();
    int B = sc.nextInt();
    int X = sc.nextInt();
    if(A<=X&&X<=A+B)
      System.out.println("YES");
    else
      System.out.println("NO");
}
}

Measured memory_bytes: 21844
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n = II()
    s = [c == 'o' for c in S()]
    for k in ['SS','SW','WS','WW']:
        r = k
        for i in range(1,n-1):
            t = r[-1]
            t2 = r[-2]
            if (t == 'S' and t2 == 'S' and s[i]) or (
                t == 'S' and t2 == 'W' and not s[i]) or (
                t == 'W' and t2 == 'S' and not s[i]) or (
                t == 'W' and t2 == 'W' and s[i]):
                r += 'S'
            else:
                r += 'W'
        if ((((r[-1] == 'S' and s[-1]) or (r[-1] == 'W' and not s[-1]))  and  r[-2] == r[0]) or (
            ((r[-1] == 'W' and s[-1]) or (r[-1] == 'S' and not s[-1]))  and r[-2] != r[0])) and (
            (((r[0] == 'S' and s[0]) or (r[0] == 'W' and not s[0]))  and  r[-1] == r[1]) or (
            ((r[0] == 'W' and s[0]) or (r[0] == 'S' and not s[0]))  and r[-1] != r[1])):
            return r
    return -1

print(main())


Measured memory_bytes: 7832
#include<iostream>
using namespace std;
int ans;
string s[300];
main()
{
	int n;cin>>n;
	for(int i=0;i<n;i++)cin>>s[i];
	for(int a=0;a<n;a++)
	{
		bool f=1;
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)f&=s[(i+a)%n][j]==s[(j+a)%n][i];
		if(f)ans+=n;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<ld> a(n);
    for (ld &x: a) {
        cin >> x;
    }
    ld res = a[0];
    int zeroes = count(a.begin(), a.end(), 0);
    if (zeroes) {
        cout << "0\n";
        exit(0);
    }
    for (int i = 1; i < n; i++) {
        if (res * a[i] > (ll) 1e18) {
            cout << "-1\n";
            exit(0);
        }
        res *= a[i];
    }
    cout << (ll) res << "\n";
}


Measured memory_bytes: 5300
#include<algorithm>
#include<iostream>

using namespace std;
int main(int argc, char** argv) {
	int a, b;
  	cin>>a;
  	cin>>b;
  	int ans = 0;
  	ans = max(ans, a + a-1);
  	ans = max(ans, a + b);
  	ans = max(ans, b + b-1);
  	cout << ans << endl;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 998244353;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  string s; cin >> s;
  int n = SZ(s);
  vi r(2*n), b(2*n);
  if(s[0] == '0') {
    r[0] = 2;
  } else if(s[0] == '1') {
    r[0] = 1;
    b[0] = 1;
  } else {
    b[0] = 2;
  }
  for(int i=1;i<n;++i) {
    if(s[i] == '0') {
      r[i] = r[i-1] + 2;
      b[i] = b[i-1];
    } else if(s[i] == '1') {
      r[i] = r[i-1] + 1;
      b[i] = b[i-1] + 1;
    } else if(s[i] == '2') {
      r[i] = r[i-1];
      b[i] = b[i-1] + 2;
    }
  }

  for(int i=n;i<2*n;++i) {
    r[i] = r[n-1];
    b[i] = b[n-1];
  }
  

  vvll dp(2*n+1, vll(2*n+1, 0));
  dp[0][0] = 1;

  for(int i=1;i<=2*n;++i) {
    for(int k=0;k<=i;++k) {
      int j = i-k;
      //cout << j << ":" << k << endl;
      if(j != 0 && r[i-1] - (j-1) > 0) {
        dp[j][k] += dp[j-1][k];
        dp[j][k] %= MOD;
      }
      if(k != 0 && b[i-1] - (k-1) > 0) {
        dp[j][k] += dp[j][k-1];
        dp[j][k] %= MOD;
      }
    }
  }

  ll res = 0;
  for(int i=0;i<=2*n;++i) {
    res += dp[i][2*n-i];
    res %= MOD;
  }
  cout << res << endl;

}


Measured memory_bytes: 125696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}

int find(vector<int>& p, int x){
    if(x == p[x]){
        return x;
    }else{
        find(p, p[x]);
    }
}

void unite(vector<int>& z, vector<int>& p, int x, int y){
    x = find(p, x); y = find(p, y);
    if(x==y) return;

    if(z[x] < z[y]) swap(x, y);
    z[x] += z[y];
    p[y] = x;
}

void same(vector<int>& p, int x, int y){
    printf("%d\n", find(p,x)==find(p,y));
}
 
int main()
{
    int n, q;
    cin >> n >> q;
    vector<int> z(n), p(n);
    rep(i, n){
        z[i] = 1;
        p[i] = i;
    }

    int com, x, y;
    set<int> tmp;

    rep(i, q){
        cin >> com >> x >> y;
        if(com==0){ //unite
            unite(z, p, x, y);
        }else if(com==1){
            same(p, x, y);
        }
    }

    return 0;
}


Measured memory_bytes: 3288
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <stack>
#include <set>
#include <deque>
using namespace std;

const int H = 3e5 + 1, W = H;
int h, w, m, a, b;
set<int> row[H], col[W];

int main(){
	cin >> h >> w >> m;
	for(int i = 0; i < m; i++){
		cin >> a >> b;
		a--; b--;
		row[a].insert(b);
		col[b].insert(a);
	}
	int ans = 0;
	{
		int ri = 0, ci = 0;
		for(int i = 1; i < h; i++){
			if(row[ri].size() < row[i].size()) ri = i;
		}
#define C(x) (int)(col[x].size() - row[ri].count(x))
		for(int j = 0; j < w; j++){
			if(C(ci) < C(j)) ci = j;
		}
		ans = max(ans, (int)row[ri].size() + C(ci));
	}
#undef C
	{
		int ri = 0, ci = 0;
		for(int i = 1; i < w; i++){
			if(col[ci].size() < col[i].size()) ci = i;
		}
#define C(x) (int)(row[x].size() - col[ci].count(x))
		for(int j = 0; j < h; j++){
			if(C(ri) < C(j)) ri = j;
		}
		ans = max(ans, (int)col[ci].size() + C(ri));
	}
	cout << ans << '\n';
}


Measured memory_bytes: 59880
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
string dic[100003];
int a=0, b=0, ab=0;
int main() {
	int n;
	cin >> n;
	rep(i,n) cin >> dic[i];
	int ans = 0;
	rep(i,n) {
		string s = dic[i];
		if (s[0] == 'B' && s[s.size()-1] == 'A') ab++;
		if (s[0] != 'B' && s[s.size()-1] == 'A') b++;
		if (s[0] == 'B' && s[s.size()-1] != 'A') a++;
		for (int i = 0; i < s.size()-1; i++)
		{
			if (s[i]=='A' && s[i+1] == 'B') ans++;
		}	
	}
	if (ab==0) ans += min(a,b);
	if (ab > 0 && a+b==0) ans += ab-1;
	if (ab>0 && a+b > 0) ans += (ab + min(a,b));
	cout << ans << endl;
	
	return 0;
}

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

int main(){
    int i,n,t_p=0,h_p=0;
    string t_s,h_s;

    cin >> n;
    for(i=0;i<n;i++){
        cin >> t_s >> h_s;
        if(t_s > h_s){
            t_p += 3;
        }else if(t_s < h_s){
            h_p += 3;
        }else if(t_s == h_s){
            t_p += 1;
            h_p += 1;
        }
    }
    cout << t_p << " " << h_p << endl;
    return 0;

}



Measured memory_bytes: 3136
n, *h = map(int, open(0).read().split())
left = h[0]
ans = 0
cnt = 0
for i in range(1,n):
    if left >= h[i]:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
    left = h[i]
print(max(ans, cnt))

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

int main() {
   string s; 
   cin >> s;
   if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
      cout << 3;
   } else if(s[0] == 'R' && s[1] == 'R') {
      cout << 2;
   } else if(s[1] == 'R' && s[2] == 'R') {
      cout << 2;
   } else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
      cout << 1;
   } else {
      cout << 0;
   }

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a > b; return true; } return false; }

int N;
long long a[100010][3];
long long dp[100010][3];

int main(){
	int N; cin >> N;
	for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

	for(int i = 0; i < N; ++i){
		for(int j = 0; j < 3; ++j){
			for(int k = 0; k < 3; ++k){
				if( j == k) continue;
				chmax(dp[i+1][k], dp[i][j] + a[i][k]);
			}
		}
	}

	long long res = 0;
	for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
	cout << res << endl;
}

Measured memory_bytes: 4992
//
// Created on 2020/06/21.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int n,k;
    cin>>n>>k;
    int ans = 0;
    vector<int>price(n);
    for (int j = 0; j < n; ++j) {
        cin>>price[j];
    }
    sort(all(price));

    for (int i = 0; i < k; ++i) {
        ans += price[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

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

const int N = 30000;
vi ans;

int main() {
  int n;
  S(n);
  if(n == 3) {
    printf("2 5 63\n");
    return 0;
  }
  int x = 3;
  while(x <= N && ans.size() < n - 2) {
    ans.pb(x);
    x += 6;
  }
  if(ans.size() & 1) ans.pop_back();
  x = 2;
  while(x <= N && ans.size() < n - 1) {
    ans.pb(x);
    x += 2;
  }
  int sum = 0;
  rep(i,0,ans.size()) sum += ans[i];
  while((sum + x) % 3 != 0) {
    x += 2;
  }
  ans.pb(x);
  rep(i,0,ans.size()) printf("%d ",ans[i]);
  assert(ans.size() == n);
  printf("\n");
  return 0;
}


Measured memory_bytes: 512
def fact(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
n = int(input())
if n == 1:
    print(0)
    exit()
D = fact(n)
ans = 0
for _, d in D:
    k = int(d**.5)
    while (k+1)*(k+2)//2 <= d:
        k += 1
    ans += k
print(ans)

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

int main(){
    ll X;
    string S;
    cin >> X;
    ll cnta=0,cntb=0;
    while(X>=500){
        X -= 500;
        cnta++;
    }
    while(X>=5){
        X -= 5;
        cntb++;
    }


    cout << (1000*cnta + 5*cntb) << endl;
    
}


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

int q,c,a,n;
int main(){
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> c >> a >> n;
    int res = 0, tmp;

    tmp = min(c,min(a,n));
    res += tmp; c -= tmp; a -= tmp; n -= tmp;

    tmp = min(c/2,a);
    res += tmp; c -= 2*tmp; a -= tmp;

    cout << res + c/3 << endl;
  }
}

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

constexpr int inf = 1e9+7;

struct edge {
  int t, w;
  edge(int t, int w) : t(t), w(w) {}
};

int in[301][301], n;
long long dist[301];
vector<tuple<int,int,int>> eg;
vector<edge> g[301];

int foo(int f, int t) {
  for(int i=0;i<n;i++) dist[i] = inf;
  dist[f] = 0;
  priority_queue<pair<int,int>> pq;
  pq.emplace(0,f);
  while(!pq.empty()) {
    int w, c;
    tie(w,c) = pq.top();
    pq.pop();
    w=-w;
    if(w > dist[c]) continue;
    for(auto & e : g[c]) {
      int ww = w + e.w;
      if(ww >= dist[e.t]) continue;
      dist[e.t] = ww;
      pq.emplace(-ww,e.t);
    }
  }
  return dist[t];
}

int main() {
  scanf("%d",&n);
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      scanf("%d",in[i]+j);
  for(int k=0;k<n;k++)
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++) {
        int tmp = in[i][k] + in[k][j];
        if(tmp < in[i][j]) {
          puts("-1");
          return 0;
        }
      }
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
      eg.emplace_back(in[i][j],i,j);
  sort(eg.begin(), eg.end());

  long long ans = 0;
  for(auto & e : eg) {
    int w,a,b;
    tie(w,a,b) = e;
    int d = foo(a,b);
    if(d == w) continue;
    ans += w;
    g[a].push_back(edge(b,w));
    g[b].push_back(edge(a,w));
  }
  printf("%lld\n",ans);
}


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

using namespace std;

int main(){
	unsigned long int v[4],d,n,a,b;
	for(int i=0;i<3;i++)
		scanf("%llu",&v[i]);
	v[0] = v[0]*4;
	v[1] = v[1]*2;
	scanf("%llu",&d);
	sort(v,v+3);
	scanf("%llu",&n);
	//printf("%I64d %I64d %I64d\n",v[0],v[1],v[2]);
	
	if(n%2==1){
		//printf("%I64d\n",((n-1)*d)/2);
		a = ((n-1)*d)/2;
		a += v[0];
		b = v[0]*n;
		printf("%llu\n",min(a,b));
	}else{
		a = (n*d)/2;
		b = v[0]*n;
		printf("%llu\n",min(a,b));
	}
}

Measured memory_bytes: 256
### subroutines

def hm2m(hm)
  (hm / 100) * 60 + (hm % 100)
end

### main

loop do
  n, hm0, hm1 = gets.strip.split(' ').map(&:to_i)
  break if (n | hm0 | hm1) == 0

  m0 = hm2m(hm0)
  m1 = hm2m(hm1)

  nts = m1 - m0
  ts = nts.times.map{false}

  n.times do
    k = gets.strip.to_i

    tmps = gets.strip.split(' ').map{|s| hm2m(s.to_i)}
    cms = (0...k).map{|i| [tmps[2 * i], tmps[2 * i + 1]]}.sort

    st = 0
    for tm in (cms + [[m1, m1]])
      et = tm[0] - m0
      for t in (st...et)
        ts[t] = true
      end
      st = tm[1] - m0
    end
  end
  #p ts

  max_m = 0
  prvi = -1

  for i in (0...nts)
    if ts[i]
      prvi = i if prvi < 0
    else
      if prvi >= 0
        m = i - prvi
        max_m = m if max_m < m
        prvi = -1
      end
    end
  end

  if prvi >= 0
    m = nts - prvi
    max_m = m if max_m < m
  end

  puts max_m
end

Measured memory_bytes: 6140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vc vector
#define a first
#define b second
#define pb push_back
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)

/////////////////////////////////////////////////////////

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

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

/////////////////////////////////////////////////////////

class robot{
public:
  ll x, l;
  robot() {x = 0; l = 0;}
  robot(ll a, ll b) {x = a; l = b;}
};

bool comp(robot p, robot q){
  return p.x + p.l < q.x + q.l;
}

void Main(){
  int N; cin >> N;
  vc<robot> V(N);
  rep(i, 0, N){
    cin >> V[i].x >> V[i].l;
  }
  int res = 1;
  sort(all(V), comp);
  int right = V[0].x + V[0].l;
  rep(i, 1, N){
    if(V[i].x - V[i].l >= right){
      res++;
      right = V[i].x + V[i].l;
    }
  }
  cout << res << endl;
  return;
}

/////////////////////////////////////////////////////////

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

  Main();

  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
    char cards[400];
    int h, i, j, l, m;
    
    while (1) {
	scanf("%s", cards);
	if (cards[0] == '-' && cards[1] == '\0')
	    break;

	l = 0;
	while (cards[l] != '\0')
	    l++;
	
	scanf("%d", &m);
	for (i = 0; i < m; i++) {
	    scanf("%d", &h);
	    for (j = 0; j < h; j++)
		cards[l + j] = cards[j];
	    for (j = 0; j < l; j++)
		cards[j] = cards[j + h];
	}

	cards[l] = '\n'; cards[l + 1] = '\0';
	printf("%s", cards);
    }
    return 0;
}


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

int f(string s){
  int temp, ans = 0;
  for(int i = 0; i < 3; i++){
    ans *= 10;
    temp = s[i] - '0';
    ans += temp;
  }
  return ans;
}

int main(void){
  string s;
  cin >> s;
  int ans = 1000;
  int temp;
  string t;
  for(int i = 0; i <= s.length() - 3; i++){
    t = s.substr(i, 3);
    temp = f(t);
    if(ans > abs(temp - 753)) ans = abs(temp - 753);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
using System;
using System.Linq;

namespace AOJ0003
{
    class Program
    {
        static void Main()
        {
            var count = int.Parse(Console.ReadLine() ?? "");

            for (var i = 0; i < count; i++)
            {
                var lengths = (from str in (Console.ReadLine() ?? "").Split(' ')
                               let n = int.Parse(str)
                               orderby n ascending
                               select n).ToArray();

                Console.WriteLine(lengths[0]*lengths[0] + lengths[1]*lengths[1] == lengths[2]*lengths[2] ? "YES" : "NO");
            }
        }
    }
}

Measured memory_bytes: 6292
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,k,ans=0;
  cin>>n>>k;
  vector<ll>v(n,0);
  vector<ll>a(n,0);
  vector<ll>b(n,0);
  for(ll i=0;i<n;i++){
    cin>>v[i];
  }
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      if(v[i]>v[j]){
        if(i<j)a[i]++;
        else b[i]++;
      }
    }
  }
  ll p=((k-1)*k/2)%MOD;
  ll q=((k+1)*k/2)%MOD;
  for(ll i=0;i<n;i++){
    ans=((b[i]*p)%MOD+ans)%MOD;
    ans=((a[i]*q)%MOD+ans)%MOD;
  }
  cout<<ans<<endl;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int H;
  cin >> H;
  int ans = 0;
  int tmp = 1;
  while(H) {
    ans += tmp;
    tmp *= 2;
    H /= 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

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

N = I()

def dfs(s):
    if int(s)>N:
        return 0
    else:
        if all(s.count(c)>=1 for c in ['3','5','7']):
            ret = 1
        else:
            ret = 0
        for x in ['3','5','7']:
            ret += dfs(s+x)
        return ret

print(dfs('0'))

Measured memory_bytes: 53340
#include<stdio.h>
int z,f=1;char i[9];int main(){for(puts("?aa");fflush(stdout),scanf("%s",i);){if(*i-97)return!puts("!OUT");if(i[1]){if(f&1<<i[1]-97)return!puts("!OUT");f|=1<<i[1]-97;printf("?%ca\n",i[1]);}else{if(z++)return!puts("!OUT");puts("?aaa");}}}

Measured memory_bytes: 0