akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

const long MOD = 1e9 + 7;
int main()
{
  long h, w;
  cin >> h>>w ;

  // vector<long> v(n, 0);
  vector<vector<char>> v(h, vector<char>(w) );

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      char a;
      cin >> a;
      v[i][j] = a;
    }
  }





  for (int i = 0; i < h*2; ++i) {
    for (int j = 0; j < w; ++j) {
      cout << v[i/2][j]  ;
    }cout << endl;
  }


  return 0;
}






Measured memory_bytes: 256
// AOJ 2153: Mirror Cave
// 2017.11.11 bal4u@uu

#include <stdio.h>
#include <string.h>
#define TM 0
#if TM
#include <time.h>
#endif

#define QMAX 150000
typedef struct { char lr, lc, rr, rc; } Q;
Q q[QMAX+2]; int top, end;

char ml[52][52], mr[52][52];
char mk[52][52][52][52];
int mvl[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
int mvr[4][2] = {{-1,0},{0,-1},{1,0},{0,1}};

int main()
{
	int w, h, r, c, lr, lc, rr, rc, lr2, lc2, rr2, rc2, i, f;
	int slr, slc, srr, src, ans;
#if TM
	clock_t start, end;
	start = clock();
#endif
	for (r = 0; r <= 51; r++) ml[r][0] = mr[r][0] = '#';
	for (c = 0; c <= 51; c++) ml[0][c] = mr[0][c] = '#';

	while (scanf("%d%d", &w, &h) && w > 0) {
		for (f = 0, r = 1; r <= h; r++) {
			scanf("%s%s", ml[r]+1, mr[r]+1);
			if (f < 3) for (c = 1; c <= w; c++) {
				if (ml[r][c] == 'L') slr = r, slc = c, f |= 1;
				if (mr[r][c] == 'R') srr = r, src = c, f |= 2;
			}
		}
		for (r = 1; r <= h; r++) ml[r][w+1] = mr[r][w+1] = '#';
		for (c = 1; c <= w; c++) ml[h+1][c] = mr[h+1][c] = '#';

		memset(mk, 0, sizeof(mk));
		q[0].lr = slr, q[0].lc = slc, q[0].rr = srr, q[0].rc = src, top = 0, end = 1;
		mk[slr][slc][srr][src] = 1;
		ans = 0;
		while (top != end) {
			lr = q[top].lr, lc = q[top].lc, rr = q[top].rr, rc = q[top].rc;
			if (++top == QMAX) top = 0;
			if (ml[lr][lc] == '%' && mr[rr][rc] == '%') { ans = 1; break; }
			if (ml[lr][lc] == '%' || mr[rr][rc] == '%') continue;

			for (i = 0; i < 4; i++) {
				f = 3;
				lr2 = lr + mvl[i][0], lc2 = lc + mvl[i][1];
				rr2 = rr + mvr[i][0], rc2 = rc + mvr[i][1];
				if (ml[lr2][lc2] == '#') lr2 = lr, lc2 = lc, f &= 2;
				if (mr[rr2][rc2] == '#') rr2 = rr, rc2 = rc, f &= 1;
				if (!f) continue;
				if (mk[lr2][lc2][rr2][rc2]) continue;
				mk[lr2][lc2][rr2][rc2] = 1;
				q[end].lr = lr2, q[end].lc = lc2, q[end].rr = rr2, q[end].rc = rc2;
				if (++end == QMAX) end = 0;
			}
		}
		puts(ans ? "Yes" : "No");
	}
#if TM
	end = clock();
	printf("time %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 9404
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

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

    int sum = 0;
    rep(i, 0, n) sum += a[i];
    sort(ALLR(a));

    int count = 0;
    double t = (double)sum/(4*m);
    rep(i, 0, n){
        if(a[i] < t) break;
        count++;
    }

    if(count >= m) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3172
import sys
sys.setrecursionlimit(4100000)

H, W = map(int,input().split())
S = []
for _ in range(H):
    S.append(list(input()))

C = [[1 for i in range(W)] for j in range(H)]
L = ['.', '#']
D = {'.':0, '#':1}
tx = [1, 0, -1, 0]
ty = [0, 1, 0, -1]

def dfs(x, y, c, l):
    C[x][y] = 0
    l[c] += 1
    for i in range(4):
        nx = x + tx[i]
        ny = y + ty[i]
        if 0 <= nx < H and 0 <= ny < W and C[nx][ny] and L[c] != S[nx][ny]:
            l = dfs(nx, ny, 1 - c, l)
    return l

ans = 0
for i in range(H):
    for j in range(W):
        l = dfs(i, j, D[S[i][j]], [0, 0])
        ans += l[0] * l[1]

print(ans)

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


int main(){
  vector<int> a(5);

  for(int i=0; i<5; i++) cin >> a[i];

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

  for(int i=0; i<4; i++) cout << a[4-i] << " ";
  cout << a[0] << endl;
}
  
  


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

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

	int ans = 0;
	for (int i = a; i >= 0; i--) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (i * 500 + j * 100 + k * 50 == x) ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;

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

    for (int x = 1; x <= 1000; x++) {
        if ((int)floor(x * 0.08) == a
            &&(int)floor(x * 0.1) == b) {
            cout << x << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    int arr[n],dp[n];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++)
    {
        
        int temp=INT_MAX;
        for(int j=max(i-k,0);j<i;j++)
        {
            temp=min((abs(arr[i]-arr[j])+dp[j]),temp);
        }
        
        dp[i]=temp;
    }
    
    cout<<dp[n-1];
}

    

Measured memory_bytes: 4376
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

flag = True
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            flag = False
if flag:
    print("APPROVED")
else:
    print("DENIED")


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

int main() {
   int a, b, c;
   int k,hoge;
   int ans = 0;

   std::cin >> a >> b >> c;
   std::cin >> k;
   if (a > b) {
      hoge = a;
      ans += b;
   }else{
      hoge = b;
      ans += a;
   }
   if(hoge < c){
      ans += a;
      hoge = c;
   }else{
      ans += c;
   }
   for (size_t i = 0; i < k; i++) {
      hoge *= 2;
   }

      ans += hoge;
   std::cout << ans << '\n';
}


Measured memory_bytes: 256
def solve():
    h1 = a
    h2 = c
    while(1):
        h2 -= s1
        if h2<=0:
            print("Yes")
            exit()
        h1 -= s2
        if h1<=0:
            print("No")
            exit()


# n = int(input())
a, s1, c, s2 = [int(s) for s in input().split(" ")]
solve()


Measured memory_bytes: 61688
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x)
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx[]= {0,0,1,-1,-1,1,-1,1};
int fy[]= {1,-1,0,0,-1,1,1,-1};
int fx1[]={0,1,1,1,0,-1,-1,-1};
int fy1[]={1,1,0,-1,-1,-1,0,1};*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;

int main()
{
    FIO;
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
   // #endif
    cin>>t;
    vector<string>v;
    vector<int>v1;
    while(t--){
        cin>>s>>a;
        v.push_back(s);
        v1.push_back(a);
    }
    cin>>s1;
    for(int i=0;i<v.size();i++){
        if(v[i]==s1)
        {
            b=i;
            break;
        }
    }
    for(int i=b+1;i<v1.size();i++){
        ans+=v1[i];
    }
    cout<<ans<<endl;

    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}



Measured memory_bytes: 256
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
//¿ª O2£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡ 
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
typedef long long LL;
typedef double db;
const int N=1e5+5,mo=10007;
int a[N],n,i,ts,tt,b[N],nxt[N],fst[N],q1,q2,q3,d[N],fa[N],mx,du[N],x,y,ans,X[N],Y[N],lst,dis[N],j;
ll ans2,tmp;
void cr(int x,int y)
{
	tt++;
	b[tt]=y;
	nxt[tt]=fst[x];
	fst[x]=tt;
}
void bfs(int x,int y)
{
	int i;
	fo(i,1,n) fa[i]=0;
	d[q2=1]=x;
	q1=0;
	if (y) d[q2=2]=y,fa[x]=y,fa[y]=x;
	ts=n;
	dis[x]=dis[y]=1;
	while (q1<q2)
	{
		x=d[++q1];
		du[x]=0;
		for (int p=fst[x];p;p=nxt[p])
			if (b[p]!=fa[x])
			{
				du[x]++;
				fa[b[p]]=x;
				dis[b[p]]=dis[x]+1;
				d[++q2]=b[p];
			}
	}
	tmp=1+(y!=0);
	fo(i,1,n)
	{
		mx=0;
		fo(j,i,n) 
		{
			if (dis[d[i]]!=dis[d[j]]) break;
			cmax(mx,du[d[j]]);
		}
		j--;
		if (mx) tmp*=mx;
		i=j;
	}
	if (dis[d[q2]]<ans||dis[d[q2]]==ans&&tmp<ans2)
	{
		ans=dis[d[q2]];
		ans2=tmp;
	}
}
int main()
{
	scanf("%d",&n);
	fo(i,1,n-1)
	{
		scanf("%d %d",X+i,Y+i);
		cr(X[i],Y[i]);
		cr(Y[i],X[i]);
	}
	ans=1e9;
	fo(i,1,n)
		bfs(i,0);
	fo(i,1,n-1)
		bfs(X[i],Y[i]);
	printf("%d %lld\n",ans,ans2);
}

Measured memory_bytes: 256
y, m, d = map(int, input().split('/'))
ans = 'TBD'
if y < 2019:
    ans = 'Heisei'
elif y == 2019:
    if m < 4:
       ans = 'Heisei'
    elif m == 4:
        if d <= 30:
            ans = 'Heisei'
print(ans)


Measured memory_bytes: 2940
from sys import stdin
#入力
readline=stdin.readline
inf=10**9
n,a,b,c=map(int,readline().split())
l=[int(readline()) for _ in range(n)]

def dfs(now,x,y,z):
    if now==n:
        return abs(a-x)+abs(b-y)+abs(c-z)-30 if min(x,y,z)>0 else inf
    else:
        res1=dfs(now+1,x,y,z)
        res2=dfs(now+1,x+l[now],y,z)+10
        res3=dfs(now+1,x,y+l[now],z)+10
        res4=dfs(now+1,x,y,z+l[now])+10
        return min(res1,res2,res3,res4)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    i64 h;
    std::cin >> h;
    int n = 0;
    while(h) {
        h >>= 1;
        n++;
    }
    std::cout << (1LL << n) - 1 << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 256
S = input()
count = 0
if( S[0] == 'A' and S[2:-1].count('C') == 1):
    for i in range(len(S)):
        if S[i].isupper():
            count += 1
            if count == 3:
                print("WA")
                exit()
    print("AC")
else:
    print("WA")


Measured memory_bytes: 2940
import heapq


class Edge:
    def __init__(self, dst, weight):
        self.dst, self.weight = dst, weight

    def __lt__(self, e):
        return self.weight > e.weight


class Graph:
    def __init__(self, V):
        self.V = V
        self.E = [[] for _ in range(V)]

    def add_edge(self, src, dst, weight):
        self.E[src].append(Edge(dst, weight))


class ShortestPath:
    """Dijkstra's algorithm : find the shortest path from a vertex
       Complexity: O(E + log(V))
       used in GRL1A(AOJ)
    """

    def __init__(self, G, INF=10**9):
        """ V: the number of vertexes
            E: adjacency list (all edge in E must be 0 or positive)
            start: start vertex
            INF: Infinity distance
        """
        self.G, self.INF = G, INF

    class Node:
        def __init__(self, v, cost):
            self.v, self.cost = v, cost

        def __lt__(self, n):
            return self.cost < n.cost

    def dijkstra(self, start, goal=None):
        que = list()
        self.dist = [self.INF] * self.G.V  # distance from start
        self.prev = [-1] * self.G.V  # prev vertex of shortest path
        self.dist[start] = 0
        heapq.heappush(que, self.Node(start, 0))

        while len(que) > 0:
            n = heapq.heappop(que)
            if self.dist[n.v] < n.cost:
                continue
            if goal is not None and n.v == goal:
                return
            for e in self.G.E[n.v]:
                if self.dist[n.v] + e.weight < self.dist[e.dst]:
                    self.dist[e.dst] = self.dist[n.v] + e.weight
                    heapq.heappush(que, self.Node(e.dst, self.dist[e.dst]))
                    self.prev[e.dst] = n.v

    def getPath(self, end):
        path = [end]
        while self.prev[end] != -1:
            end = self.prev[end]
        return path[::-1]


N, M = map(int, input().split())
g = Graph(N)
for i in range(M):
    l, r, c = map(int, input().split())
    g.add_edge(l - 1, r - 1, c)

for i in range(N - 1):
    g.add_edge(i + 1, i, 0)
sp = ShortestPath(g, INF=10 ** 18)

sp.dijkstra(0)
if sp.dist[-1] == 10 ** 18:
    print(-1)
else:
    print(sp.dist[-1])


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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int R = sc.nextInt();
        int G = sc.nextInt();
        System.out.println(G*2-R);
        
        
        
        
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
	int N;
	string s, t;
	cin >> N >> s >> t;

	int ans = N;

	REP(i, N)
	{
		bool check = false;
		FOR(j, N, i)
		{
			if (s[j] != t[j - i])
			{
				break;
			}
			if (j == N - 1)
			{
				check = true;
			}
		}

		if (check)
		{
			ans += i;
			break;
		}
		if (i == N - 1)
		{
			ans += N;
		}
	}

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

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

int main() {
  int n;
  cin>>n;
  vector<string>s(n);
  for(int i=0;i<n;i++) {
    cin>>s[i];
    sort(s[i].begin(),s[i].end());
  }
  unordered_map<string,long long>num;
  long long ans=0;
  for(int i=0;i<n;i++){
    ans+=num[s[i]];
    num[s[i]]++;
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 17700
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    int n;
    cin >> n;
    vi cnt(4);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }

    vector<vector<vector<double>>> dp(301, vector<vector<double>>(301, vector<double>(301)));
    function<double(int, int, int)> dfs = [&](int i, int j, int k) {
        if (i + j + k == 0) return 0.0;
        if (dp[i][j][k]) return dp[i][j][k];
        double ret = (i ? dfs(i - 1, j, k) * i / (i + j + k) : 0)
                + (j ? dfs(i + 1, j - 1, k) * j / (i + j + k) : 0)
                + (k ? dfs(i, j + 1, k - 1) * k / (i + j + k) : 0)
                + n / double(i + j + k);
        dp[i][j][k] = ret;
        return ret;
    };
    
    cout << dfs(cnt[1], cnt[2], cnt[3]) << endl;
}

Measured memory_bytes: 217088
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int l = Integer.parseInt(sa[2]);
		long[][] d = new long[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(d[i], 100000000000000L);
		}
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			int a = Integer.parseInt(sa[0]) - 1;
			int b = Integer.parseInt(sa[1]) - 1;
			int c = Integer.parseInt(sa[2]);
			if (c <= l) {
				d[a][b] = c;
				d[b][a] = c;
			}
		}
		int q = Integer.parseInt(br.readLine());
		int[] s = new int[q];
		int[] t = new int[q];
		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			s[i] = Integer.parseInt(sa[0]) - 1;
			t[i] = Integer.parseInt(sa[1]) - 1;
		}
		br.close();

		int[][] ans = new int[n][n];
		long[][] ansd = new long[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(ans[i], 1000000000);
		}
		for (int i = 0; i < n; i++) {
			Set<Integer> set = new HashSet<>();
			for (int j = 0; j < n; j++) {
				set.add(j);
			}
			Node[] nodes = new Node[n];
			for (int j = 0; j < n; j++) {
				nodes[j] = new Node(j, 1000000000, 0);
			}
			TreeSet<Node> nset = new TreeSet<>();
			nset.add(nodes[i]);
			nodes[i].a = 0;
			ans[i][i] = 0;
			while (!nset.isEmpty()) {
				Node cur = nset.pollFirst();
				if (set.remove(cur.v)) {
					for (int j : set) {
						int alta = ans[i][cur.v];
						long c = d[cur.v][j];
						long altd = cur.d + c;
						if (altd >= 100000000000000L) {
							continue;
						}
						if (altd > l) {
							alta++;
							altd = c;
						}
						if (alta < ans[i][j]
								|| alta == ans[i][j] && altd < ansd[i][j]) {
							ans[i][j] = alta;
							ansd[i][j] = altd;
							nset.remove(nodes[j]);
							nodes[j].a = alta;
							nodes[j].d = altd;
							nset.add(nodes[j]);
						}
					}
				}
				if (nset.size() >= n) {
					throw new RuntimeException();
				}
			}
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			int o = ans[s[i]][t[i]];
			if (o == 1000000000) {
				pw.println(-1);
			} else {
				pw.println(o);
			}
		}
		pw.flush();
	}

	static class Node implements Comparable<Node> {
		int v;
		int a;
		long d;

		public Node(int v, int a, long d) {
			this.v = v;
			this.a = a;
			this.d = d;
		}

		public int compareTo(Node o) {
			if (a != o.a) {
				return a - o.a;
			}
			if (d != o.d) {
				return Long.compare(d, o.d);
			}
			return v - o.v;
		}
	}
}


Measured memory_bytes: 99544
import java.util.Scanner;


public class Main {
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] s = new int[n];
		
		for(int i = 0; i < n; i++) {
			s[i] = stdIn.nextInt();
		}
		
		for(int i = n-1; i > 0; i--) {
			System.out.print(s[i] + " ");
		}
		System.out.println(s[0]);
	}

}

Measured memory_bytes: 18984
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
int pre[100005];
int find(int x){
    return (x==pre[x])?x:(pre[x]=find(pre[x]));
}
void merge(int x,int y){
    pre[find(x)]=find(y);
}
int main(){
    int n,m;cin>>n>>m;
    for(int i=1;i<=n;i++){
        pre[i]=i;
    }
    for(int i=1;i<=m;i++){
        int u,v;cin>>u>>v;
        merge(u,v);
    }
    set<int> s;
    for(int i=1;i<=n;i++){
        s.insert(find(i));
    }
    cout<<s.size()-1<<endl;
} 

Measured memory_bytes: 7772
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-10;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[210000];
int tmp[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
	}
	for(int i=0;i<a;i++){
		if(i==0&&p[i]){
			printf("-1\n");return 0;
		}
		if(i&&p[i-1]+1<p[i]){
			printf("-1\n");return 0;
		}
	}
	long long ret=0;
	for(int i=0;i<a;i++){
		tmp[i-p[i]]=max(tmp[i-p[i]],p[i]);
	}
	for(int i=0;i<a;i++)ret+=tmp[i];
	printf("%lld\n",ret);
}


Measured memory_bytes: 1664
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

const NMAX: usize = 8;

fn dfs(v: usize, mut visited: Vec<bool>, graph: &Vec<Vec<bool>>) -> i64 {
    let mut all_visited = true;
    for v in visited.iter() {
        if !v {
            all_visited = false;
        }
    }
    if all_visited {
        return 1;
    }
    let mut ret = 0;
    for i in 0..visited.len() {
        if !graph[v][i] {
            continue;
        }
        if visited[i] {
            continue;
        }
        visited[i] = true;
        ret += dfs(i, visited.clone(), &graph);
        visited[i] = false;
    }
    ret
}

fn main() {
    input! {
        n: usize,
        m: usize,
        abs: [(usize1, usize1); m],
    }
    let mut graph = vec![vec![false; NMAX]; NMAX];
    for ab in abs {
        graph[ab.0][ab.1] = true;
        graph[ab.1][ab.0] = true;
    }
    let mut visited = vec![false; n];
    visited[0] = true;
    println!("{}", dfs(0, visited, &graph));
}

Measured memory_bytes: 4352
import static java.lang.System.*;

import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			int a = scan.nextInt();
			int b = scan.nextInt();
			int c = scan.nextInt();
			if((a < b) &&(b < c))
				out.println("Yes");
			else
				out.println("No");
		}finally{
			if(scan !=null)scan.close();
		}

	}
}

Measured memory_bytes: 17164
using System;

class Class01
{
    public static void Main(string[] args)
    {
        while (true)
        {
            string s = Console.ReadLine();
            if (s == null) break;

            string[] m = s.Split(' ');
            int sum = int.Parse(m[0]) + int.Parse(m[1]);

            int count = 1;
            while (true)
            {
                sum = sum / 10;
                if (sum == 0) break;
                count++;
            }
            Console.WriteLine(count);
        }
    }
}

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

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

    for (int i=0; i < N; i++){
        string S;
        cin >> S;

        if (S == "Y"){
            cout << "Four" << endl;
            break;
        }

        if (i == N-1){
            cout << "Three" << endl;
        }
    }
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int P, Q, R;
    cin >> P >> Q >> R;
    int ans = P + Q + R - max(P,max(Q,R));
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)

	tmp := 0
	if a < b {
		tmp += a
	} else {
		tmp += b
	}
	if c < d {
		tmp += c
	} else {
		tmp += d
	}
	fmt.Print(tmp)

}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    char a,b,c,d;
    char s[6];
    scanf("%s",&s);
    a=s[2];
    b=s[3];
    c=s[4];
    d=s[5];
    if((a==b)&&(c==d))
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 128
//解説AC(写経)
//https://youtu.be/TdR816rqc3s?t=6817
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

struct UnionFind {
    vector<int> d;//子:親のID(非負) 根:-サイズ(負)
    UnionFind(int n): d(n, -1) {}//全員根→サイズ1に初期化
    int find(int x) {//どのクループか特定
        if (d[x] < 0) return x;//親のID=自分
        return d[x] = find(d[x]);
        //親に対してfindを投げて、親のID取得。
        //代入はメモ化(経路縮約)して計算量を減らしてる。
    }
    bool unite(int x, int y){
        x = find(x); y = find(y);//根を代入
        if(x == y) return false;//同じならやることがない。falseを返してるのはMSTなどに使うため。
        if(d[x] > d[y]) swap(x, y);
        //サイズの大きい方を小さい方にくっつけるため、xを小さくする。(マイナスに注意)
        d[x] += d[y];//サイズの合算
        d[y] = x;//親を変更
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}//同じ集合に属しているか判別
    int size(int x) { return -d[find(x)];}//連結成分サイズを取る
};

int deg[100001];
vector<int> to[100005];

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    int a, b;
    rep(i, m){//UnionFind木を生成＆直接つながる辺の数を数える。
        cin >> a >> b;
        a--; b--;//0-index化
        deg[a]++;
        deg[b]++;
        uf.unite(a, b);
    }
    int c, d;
    rep(i, k){
        cin >> c >> d;
        c--; d--;//0-index化
        //隣接リストの生成(ブロックリスト)
        to[c].push_back(d);
        to[d].push_back(c);
    }
    rep(i, n){
        int ans = uf.size(i)-1-deg[i];//自分自身と友人を引く
        for(int x : to[i]){
            if(uf.same(i, x)) ans--;//同じ集合に属しているブロック人数分を引く。
        }
        cout << ans;
        if(i!=n-1) cout << " ";
    }
    return 0;
}

Measured memory_bytes: 6784
#include <stdio.h>

int s[10],c[10];

int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d %d", &s[i],&c[i]);
    }
    int cap = 1,ans=-1;
    for(int i =0;i<n-1;i++) cap*=10;
    for(int i = (n==1)?0:cap;i<cap*10;i++){
        int ok = 1;
        for(int j = 0;j<m;j++){
            int cur = i;
            for(int z = 0;z<n-s[j];z++){
                cur/=10;
            }
            cur = cur%10;
            if(cur != c[j]){
                ok=0;
                break;
            }
        }
        if(ok){
            ans=i;
            break;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
int a, b;
    scanf("%d %d", &a, &b);
    if(a>b){
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}

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

int main(){

  int a,b;
  cin>>a>>b;

  assert(-100 <= a && a <= 100);
  assert(-100 <= b && b <= 100);

  cout<<max({a+b,a-b,a*b})<<endl;

  return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace arc_063__A
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            int ans = 0;
            for (int i = 0; i < a.Length; i++)
            {
                if (i != 0)
                {
                    if (a[i] == a[i - 1]) { } else { ans++; }
                }
            }Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11232
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple
bool isPrime(int n){
      if(n <= 1)return false;
      if(n <= 3)return true;
      if(n % 2 == 0 || n % 3 == 0)return false;
      for(int i = 5;i * i <= n;i += 6){
            if(n % i == 0 || n % (i + 2) == 0)return false;
      }
      return true;
}

int main(){
      int n;cin >> n;
      for(int i = n;;i++){
            if(isPrime(i))return cout << i, 0;
      }
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;
//1/26 done
public class Main { //CHANGE TO MAIN WHEN SUBMITTING
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int limit = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++) a[i] = in.nextInt();
        int[] dp = new int[n];
        Arrays.fill(dp,(int)1e9);
        dp[0] = 0;
        if(dp.length==1){
            out.print(0);
        }
        else{
            dp[1] = Math.abs(a[1]-a[0]);
            for(int i = 2; i<n; i++){
                for(int k = i-1, temp = 1; k>=0 && temp<=limit; k--, temp++){
                    dp[i] = Math.min(dp[i],Math.abs(a[i]-a[k])+dp[k]);
                }
            }
            out.print(dp[n-1]);
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 43892
def main() -> None:
    h, w = map(int, input().split())
    a = []
    for _ in range(h):
        a.append(input())

    row = [False] * h
    col = [False] * w
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                row[i] = True
                col[j] = True

    for i in range(h):
        if row[i]:
            for j in range(w):
                if col[j]:
                    print(a[i][j], end='')
            print()


if __name__ == '__main__':
    main()


Measured memory_bytes: 4468
#include <iostream>
#include <vector>
#include <set>
#define llint long long

using namespace std;

llint n, k;
llint a[200005], b[400005];
llint succ[400005], nx[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k; k--;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) b[i] = b[n+i] = a[i];
	
	for(int i = 1; i < 200005; i++) nx[i] = 2*n;
	for(int i = 2*n-1; i >= 0; i--){
		succ[i] = nx[b[i]];
		nx[b[i]] = i;
	}
	for(int i = 0; i < n; i++) succ[i] %= n;
	
	llint cnt = 0, p = 0;
	do{
		if(p >= succ[p]) cnt++;
		p = succ[p];
		if(p == n-1) cnt++;
		p = (p+1)%n;
	}while(p != 0);
	
	p = 0;
	if(k > 0){
		k %= cnt;
		while(k > 0){
			if(p >= succ[p]) k--;
			p = succ[p];
			if(p == n-1) k--;
			p = (p+1)%n;
		}
	}
	if(k < 0) p = n;
	
	vector<llint> ans; set<llint> S;
	for(int i = p; i < n; i++){
		if(S.count(a[i])){
			while(S.count(a[i])){
				S.erase(ans.back());
				ans.pop_back();
			}
		}
		else{
			ans.push_back(a[i]);
			S.insert(a[i]);
		}
	}
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i];
		if(i < (int)ans.size()-1) cout << " ";
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 21872
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void)
{
    int n,d;
    cin >>n >>d;
    vector<vector<int> > x(n, vector<int>());
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            int tmp;
            cin >>tmp;
            x[i].push_back(tmp);
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int sum = 0;
            for(int k = 0; k < d; k++){
                sum += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            double sq = sqrt(sum);
            if(ceil(sq) == sq){
                ans++;
            }
        }
    }


    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <cstring>
# include <cstdio>
using namespace std;
int main(void)
{
	int a[105][105];
    int n,cnt,u,k;
    memset(a,0,sizeof(a));
    scanf("%d",&n);
    for(int w = 0;w < n;w++)
    {
    	scanf("%d %d",&u,&cnt);
    	for(int i = 0;i < cnt;i++)
    	{
    		scanf("%d",&k);
    		a[u][k] = 1;
		}
	}
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= n;j++) cout<<a[i][j]<<(j == n?"\n":" ");
	return 0;
}


Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	set<int>s;
	s.insert({1,2,3});
	int a,b;
	cin >> a >> b;
	s.erase(a);
	s.erase(b);
	cout << *s.begin();
}

Measured memory_bytes: 3548
//package Atcoder;

import java.util.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer;


public class Main {
	
	static class IO 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public IO() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	
	public static void main(String[] args) {
		IO fs = new IO();
		int n = fs.nextInt();
		int [] x = new int[n];
		int [] y = new int[n];
		int [] h = new int[n];
		for(int i = 0; i<n; i++) {
			x[i] = fs.nextInt();
			y[i] = fs.nextInt();
			h[i] = fs.nextInt();
		}
		int ansx,ansy;
		int resx = -1,resy = -1,resh = -1;
		Set<Integer> st = new HashSet<Integer>();
		for(ansx = 0; ansx<=100; ansx++) {
			for(ansy = 0; ansy<=100; ansy++) {
				st.clear();
				boolean canbe = true;
				int ph = 0;
				for(int i = 0; i<n; i++) {
					if(h[i]!=0) {
						ph = h[i] + Math.abs(ansx-x[i]) + Math.abs(ansy - y[i]);
						if(st.isEmpty()||st.contains(ph)) {
							st.add(ph);
							continue;
						}
						else {
							canbe = false;
							break;
						}
					}
				}
				if(canbe) {
					boolean stillpos = true;
					for(int i = 0; i<n; i++) {
						if(h[i] == 0) {
							if(ph> Math.abs(ansx-x[i])+Math.abs(ansy-y[i])) {
								stillpos = false;
								break;
							}
						}
					}
					if(stillpos) {
						resx = ansx;resy = ansy;resh = ph;
						break;
					}
				}
			}
			if(resx!=-1 || resy!=-1 || resh!=-1)break;
		}
		System.out.println(resx+" "+resy+" "+resh);
	}

}


Measured memory_bytes: 27528
n = int(input())
a = list(map(int, input().split()))
x = min(a)
while True:
    for i in range(n):
        if a[i] % x == 0:
            a[i] = x
        else:
            a[i] = a[i] % x
    if x == min(a):
        print(x)
        break
    else:
        x = min(a)

Measured memory_bytes: 19912
# ABC111c
from collections import Counter
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def calc():
    ans = 0
    for i in range(len(v)):
        if i % 2 == 0:
            if v[i] != f:
                ans += 1
        else:
            if v[i] != f2:
                ans += 1
    return ans


n = int(input())
v = list(map(int, input().split()))
V1 = Counter(v[::2]).most_common()
V2 = Counter(v[1::2]).most_common()
f = V1[0][0]
f2 = V2[0][0]
if f == f2:
    if len(V2) > 1:
        f2 = V2[1][0]
    else:
        f2 = 'x'
    a = calc()
    if len(V1) > 1:
        f = V1[1][0]
    else:
        f = 'x'
    f2 = V2[0][0]
    print(min(a, calc()))
else:
    print(calc())


Measured memory_bytes: 64732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 230;
const int A = 108;

const int INF = 19191919;
const int F = 20;
int dp[N][N][F][F];

struct State{
    int x,y,b,s;
};

int nxt[20][3]={
    {5,1,4},
    {6,2,0},
    {7,3,1},
    {8,4,2},
    {9,0,3},
    {0,10,11}, //5
    {1,11,12},
    {2,12,13},
    {3,13,14},
    {4,14,10},
    {15,5,9}, //10
    {16,6,5},
    {17,7,6},
    {18,8,7},
    {19,9,8},
    {10,19,16}, //15
    {11,15,17},
    {12,16,18},
    {13,17,19},
    {14,18,15}
};

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

const int LIM = 100;

int main(){
    rep(i,N)rep(j,N)rep(k,F)rep(l,F) dp[i][j][k][l] = INF;
    dp[A][A][0][5] = 0;
    queue<State> que;
    que.push({A,A,0,5});
    while(!que.empty()){
        State c = que.front();
        que.pop();
        if(dp[c.x][c.y][c.b][c.s]>=LIM) continue;

        // printf("NOW : %d %d %d %d   ::: %d\n",c.x,c.y,c.b,c.s,dp[c.x][c.y][c.b][c.s]);

        int ad = 0;
        while(nxt[c.b][ad] != c.s) ++ad;

        int oe = (c.x+c.y)%2;
        rep(i,3){
            int nx = c.x+dx[oe][i], ny = c.y+dy[oe][i];
            if(!(0<=nx && nx<N && 0<=ny && ny<N)) continue;
            int noe = (nx+ny)%2;

            int nb = nxt[c.b][(i+ad)%3];
            int ns = -1;
            rep(j,3){
                int xx = nx+dx[noe][j], yy = ny+dy[noe][j];
                if(xx == c.x && yy == c.y){
                    int idx = 0;
                    while(nxt[nb][idx] != c.b) ++idx;

                    idx = (idx-j+3)%3;
                    ns = nxt[nb][idx];
                    break;
                }
            }
            assert(ns != -1);

            // printf(" nx %d :: %d %d %d %d\n",i,nx,ny,nb,ns);
            if(dp[nx][ny][nb][ns] > dp[c.x][c.y][c.b][c.s]+1){
                dp[nx][ny][nb][ns] = dp[c.x][c.y][c.b][c.s]+1;
                que.push({nx,ny,nb,ns});
            }
        }
    }

    int x,y,n;
    while(cin >>x >>y >>n){
        if(x==0 && y==0 && n==0) break;
        int ans = INF;
        rep(i,F) ans = min(ans, dp[x+A][y+A][n][i]);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 85876
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    #define int long long  
    typedef long double ld;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
    #define INF 1e10
    const double pi=3.14159265358979323;
    const int mod=998244353;
    int gcd(int a, int b) 
    { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
    } 
    void swap(int a,int b)
    {
      int temp=a;
      a=b;
      b=temp;
    } 
    int  binpow(int  a,int  b) 
    {
    int res = 1;
    while (b > 0) {
        if (b%2 == 1)
            res = (res * a)%mod;
        a = (a* a)% mod;
        b >>= 1;
    }
    return res;
}
    int modinv(int y)
    {
        return binpow(y,mod-2);
    }

    int fact[500000+5];
    void precal()
    {
    fact[0]=1;
    for(int i=1;i<500000+5;i++)
    {
        fact[i]=(i*fact[i-1])%mod;
    }
}
    signed main() {

 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout); 
      }
    #endif  
    // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1; 
    //cin>>t;
    while(t--)
    {
        int x,y,z,e,r;
        cin>>x>>y>>z>>e>>r;
        if(x==0)
        cout<<1<<endl;
        else if(y==0)
            cout<<2<<endl;
        else if(z==0)
            cout<<3<<endl;
        else if(e==0)
            cout<<4<<endl;
        else
            cout<<5<<endl;

    }
}


Measured memory_bytes: 3580