akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define MAX 100

int main(){

  int i, j, v, num;
  int data[MAX];
 
  scanf("%d", &num);

  for(i = 0; i < num; i++){

    scanf("%d",&data[i]);

  }

  data[i] = -1;

  for(i = 1; i < num; i++){

    j = 0;
  
    while(data[j + 1] != -1){

      printf("%d ", data[j]);

      j++;

    }

    printf("%d\n", data[j]);


    v = data[i];
    
    j = i - 1;

    while((j >= 0) && (data[j] > v)){

      data[j + 1] = data[j];

      j--;

      data[j + 1] =v;

    }

  }

  j = 0;

  while(data[j + 1] != -1){

    printf("%d ", data[j]);

    j++;

  }

  printf("%d\n", data[j]);

  return 0;

}

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

#define f first
#define s second
#define ll long long
#define pb push_back
#define mp make_pair
#define inp(x) cin>>x
#define print(x) cout<<x
#define pii pair<int,int>
#define pll pair<ll,ll>
#define gcd(a,b) __gcd(a,b)
#define reset(d,val) memset(d,val,sizeof(d))
#define sort(v) sort(v.begin(),v.end())
#define sort_arr(arr,i,f) sort(arr+i,arr+f)
#define pq priority_queue<int,vector<int>,greater<int> >
#define pq1 priority_queue<pll,vector<pll>,greater<pll> >

const int mod = 998244353;

ll dp[3002][3002];
int arr[3002];

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,s;
	cin>>n>>s;
	dp[0][0] = 1;
	for (int i = 1; i <=n; ++i)
	{
		cin>>arr[i];
		for(int j=0;j<=s;j++) {
			dp[i][j] = (2*dp[i-1][j])%mod;
			if(j-arr[i]>=0) dp[i][j] = (dp[i][j]+dp[i-1][j-arr[i]])%mod;
			//if(dp[i][j]>=mod) dp[i][j]-=mod;
		}
	}
	cout<<(dp[n][s]+mod)%mod;
	return 0;
}



Measured memory_bytes: 73924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int mpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = (long long) res * a % MOD;
		a = (long long) a * a % MOD;
		b >>= 1;
	}
	return res;
}

int main() {
	int n; cin >> n;
	int ans = ((ll) mpow(10, n) + mpow(8, n)) % MOD;
	for (int rep = 0; rep < 2; ++rep) 
		ans = (ans - mpow(9, n) + MOD) % MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

char C[2][3];

int main(){

	int i,j;

	for(i=0;i<2;i++){
	scanf("%s",C[i]);
	}
	int flag=1;
	for(i=0;i<2;i++){
		for(j=0;j<3;j++){
			if(C[i][j]!=C[1-i][2-j]){flag=0;}
		}
	}

	if(flag==1){
	printf("YES\n");
	}
	else{
	printf("NO\n");
	}

	return 0;
}

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

int main()
{
	int n,x,y;
	cin >> n >> x >> y;
	

	vector<vector<int>> M(n);
	for(int i = 0;i<n-1;i++)
	{
		M[i].push_back(i+1);
		M[i+1].push_back(i);
	}
	x--;
	y--;
	M[x].push_back(y);
	M[y].push_back(x);
	vector<vector<int>> DD(n,vector<int>(n,-1));
	for(int i = 0;i<n;i++)//i start
	{
		queue<int> S;
		S.push(i);
		DD[i][i] = 0;
		while(!S.empty())
		{
			int now = S.front();
			S.pop();
			for(auto ii:M[now])
			{
				if(DD[i][ii]==-1)
				{
					DD[i][ii] = DD[i][now]+1;
					S.push(ii);
				}
			}
		}
	}
	vector<int> D(n);
	for(int i = 0;i<n;i++)
	{
		for(int j = i+1;j<n;j++)
		{
			D[DD[i][j]]++;
		}
	}
	for(int i = 0;i<n-1;i++)
	{
		cout<<D[i+1]<<endl;
	}
	return 0;
}

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

#define PI 3.141592653589793238462643383279
typedef long long ll;
const long double EPS = 1e-9;
const ll MOD = 1e9+7;
#define N 10100
int dp[N][10];

bool is_better(const int* arr1, const int* arr2) {
    if(arr1[0] == -1) return false;
    if(arr2[0] == -1) return true;

    int cnt1 = 0, cnt2 = 0;
    for(int i=0;i<10;i++) cnt1 += arr1[i], cnt2 += arr2[i];
    if(cnt1 > cnt2) return true;
    else if(cnt1 < cnt2) return false;

    for(int i=9;i>0;i--) {
        if(arr1[i] > arr2[i]) return true;
        else if(arr1[i] < arr2[i]) return false;
    }
    return false;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(20);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    #ifdef LOCAL_TEST
    freopen("input.txt","r",stdin);
    #endif
    int n, m; cin >> n >> m;
    for(int i=1;i<=n;i++) dp[i][0] = -1;
    unordered_map<int, int> mp {
        {1, 2},
        {2, 5},
        {3, 5},
        {4, 4},
        {5, 5},
        {6, 6},
        {7, 3},
        {8, 7},
        {9, 6}
    };

    unordered_set<int> st;
    while(m-- > 0) {
        int a; cin >> a; st.insert(a);
    }

    for(int t : st) {
        for(int i=0;i<=n-mp[t];i++){
            dp[i][t] += 1;
            if(is_better(dp[i], dp[i+mp[t]]))
                for(int j=0;j<10;j++) dp[i+mp[t]][j] = dp[i][j];
            dp[i][t] -= 1;
        }
    }

    assert(dp[n][0] != -1);
    for(int j=9;j>0;j--) for(int i=0;i<dp[n][j];i++) cout << j;
    cout << '\n';
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int a,b;
 
        while(true){
            a = sc.nextInt();
            b = sc.nextInt();
 
            if(a == 0 && b == 0)break;
 
            System.out.printf("%d %d\n", Math.min(a, b),Math.max(a, b));
        }
 
    }
}


Measured memory_bytes: 41104
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
        int sum = 0;
        
        for (int i = 0; i < n.length(); i++) {
            String ni = String.valueOf(n.charAt(i));
            sum += Integer.parseInt(ni);
            if (sum % 9 == 0) {
                sum = 0;
            }
        }
        if (sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

int main() {
    int r = read(), d = read(), x = read();
    for (int i = 0; i < 10; i++) {
        x = r * x - d;
        printf("%d\n", x);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>

int main(int argc, char *argv[]) {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> h(n + 1);
  for (int i = 1; i <= n; ++i)
    std::cin >> h.at(i);

  std::vector<bool> ans(n + 1, true);
  for (int i = 0; i < m; ++i) {
    int a, b;
    std::cin >> a >> b;
    if (h.at(a) >= h.at(b))
      ans.at(b) = false;
    if (h.at(a) <= h.at(b))
      ans.at(a) = false;
  }

  std::cout << std::accumulate(ans.begin(), ans.end(), 0) - 1 << std::endl;
}


Measured memory_bytes: 3340
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

vector<int> histogram(const string& s)
{
  vector<int> counts(26, 0);
  for (char c: s) ++counts[c - 'a'];
  counts.erase(remove(counts.begin(), counts.end(), 0), counts.end());
  sort(counts.begin(), counts.end());
  return counts;
}

bool check(const vector<int>& s, const vector<int>& t)
{
  if (s.size() != t.size()) return false;
  for (size_t i = 0; i < s.size(); ++i) if (s[i] != t[i]) return false;
  return true;
}

int main()
{
  string S, T;
  cin >> S >> T;
  cout << (check(histogram(S), histogram(T)) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 776
#include <iostream>
using namespace std;
int main(void){
    int N,K,X,Y;
    cin>>N>>K>>X>>Y;
    if(N<=K){
        cout<<N*X<<endl;
    }
    else if(N>K){
        cout<<K*X+(N-K)*Y<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    var args = chunk.split(' ');
    var a = parseInt(args[0]);
    var b = parseInt(args[1]);
    var operator;
    switch (true) {
        case a < b:
            operator = '<';
            break;
        case a > b:
            operator = '>';
            break;
        case a == b:
        default:
            operator = '==';
            break;
    }
    console.log('a %s b', operator);
});

Measured memory_bytes: 7644
N,W = map(int,input().split())
wv = list(list(map(int,input().split()))for i in range(N))
DP = [[float('inf')]*(N*1000+1)for i in range(N+1)]
DP[0][0] = 0
for i in range(N):
    w,v = wv[i]
    for j in range(N*1000+1):
        if j < v:
            DP[i+1][j] = DP[i][j] 
        else:
            DP[i+1][j] = min(DP[i][j],DP[i][j-v]+w)
for i in range(len(DP[-1])-1,-1,-1):
    if DP[-1][i] <= W:
        print(i)
        break

Measured memory_bytes: 311192
import math

N, M = map(int, input().split())

def divisors(M):
    for d in range(1, math.floor(math.sqrt(M)) + 1):
        if M % d == 0:
            yield d
            yield M // d

d = max(d for d in divisors(M) if d <= M // N)
print(d)

Measured memory_bytes: 38512
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int gcd(int a, int b) {
    return b ? gcd(b, a%b) : a;
}

int main(void)
{
    
    ll k = 0;
    
    cin >> k;
    
    ll r = 0;
    
    
    rrep (i1, k) {
        rrep(i2, k) {
            rrep(i3, k) {
                r += gcd (gcd(i1, i2), i3);
            }
        }
    }
    
    cout << r;
    
}

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

int main() {
	string w;
	cin >> w;
	map<char, int> m;
	for (int i = 0; i < w.size(); i++) {
		m[w[i]]++;
	}
	map<char, int>::iterator it;
	for (it = m.begin(); it != m.end(); it++) {
		if (it->second % 2 != 0) {
			cout << "No" <<endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
word = input()
odd_v = ['R', 'U', 'D']
odd_list = []
even_v = ['L', 'U', 'D']
even_list = []

for index, i in enumerate(word, 1):
    if index % 2 == 1:
        odd_list.append(i)
    else:
        even_list.append(i)

if set(odd_list).issubset(odd_v) and set(even_list).issubset(even_v):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9116
#include <stdio.h>

void right_triangle_check(int a, int b, int c);

int main(void)
{
	int set, x, y, z;
	scanf("%d", &set);
	for (int i = 0; i < set; i++) {
		scanf("%d %d %d", &x, &y, &z);
		right_triangle_check(x ,y ,z);
	}
	return 0;
}

void right_triangle_check(int a, int b, int c)
{
	if (a * a + b * b == c * c) {
		printf("YES\n");
	} else if (b * b + c * c == a * a) {
		printf("YES\n");
	} else if (c * c + a * a == b * b) {
		printf("YES\n");
	} else {
		printf("NO\n");
		}
}

Measured memory_bytes: 1008
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
    input! {
        n:usize,
        mut s:Chars
    }

    let mut r = vec![0; n + 1];
    let mut g = vec![0; n + 1];
    let mut b = vec![0; n + 1];

    let mut ans = 0_usize;

    for i in 0..n {
        r[i + 1] = r[i];
        g[i + 1] = g[i];
        b[i + 1] = b[i];
        if s[i] == 'R' {
            r[i + 1] += 1;
        } else if s[i] == 'G' {
            g[i + 1] += 1;
        } else {
            b[i + 1] += 1;
        }
    }

    r.reverse();
    g.reverse();
    b.reverse();
    s.reverse();

    for i in 0..n {
        for j in i + 1..n {
            if s[i] == s[j] {
                continue;
            }
            let q;
            if s[i] != 'R' && s[j] != 'R' {
                q = 'R';
            } else if s[i] != 'G' && s[j] != 'G' {
                q = 'G';
            } else {
                q = 'B';
            }

            if q == 'R' {
                ans += r[j];
            }
            if q == 'G' {
                ans += g[j];
            }
            if q == 'B' {
                ans += b[j];
            }
            if j + j - i < n && s[j + (j - i)] == q {
                ans -= 1;
            }
            //println!("{} {} {}", i, j, ans);
        }
    }

    //dbg!(&r);
    //dbg!(&g);
    //dbg!(&b);

    println!("{}", ans);
}

Measured memory_bytes: 2244
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
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;
}
 
const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;
 
ll N;

void solve() {
    cin >> N;
    vector<string> a(N);
    vector<l_l> adds, subs;
    
	int tlc = 0, trc = 0;
 
    for (int i = 0; i < N; i++) {
		int lc = 0, rc = 0;
		cin >> a[i];
		for (auto& c : a[i]) {
			if (c == '(') {
				lc++;
			} else {
				if (lc) lc--;
				else rc++;
			}
		}
		if (lc && !rc) tlc += lc;
		else if (!lc && rc) trc += rc;
		else if (lc && rc) {
			if (lc >= rc) adds.push_back({rc, lc});
			else subs.push_back({lc, rc});
		}
	}
	sort(adds.begin(), adds.end());
    sort(subs.begin(), subs.end(), greater<pair<int, int>>());
    
    bool pos = true;
    for (auto& i : adds) {
		if (i.first > tlc) {
			pos = false;
			break;
		} else {
			tlc -= i.first;
			tlc += i.second;
		}
	}
	
	for (auto& i : subs) {
		if (i.second > tlc) {
			pos = false;
			break;
		} else {
			tlc -= i.second;
			tlc += i.first;
		}
	}
    
    if (pos && tlc == trc) cout << "Yes";
    else cout << "No";
}
 
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}
 
/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 34484
n = int(input())
a = list(map(int, input().split()))
c4 = 0
ce = 0
for i in a:
	if i%4 == 0:
		c4 += 1
	elif i%2 == 0:
		ce += 0.5
if (c4+int(ce)) >= n//2:
	print ("Yes")
else:
	print ("No")


Measured memory_bytes: 15020
#include<iostream>

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

int N, C, X;
int D[30][30];
int t[3][30];

int main() {
  scanf("%d %d", &N, &C);
  rep(i,C) rep(j,C) scanf("%d", &D[i][j]);
  rep(i,N) rep(j,N) scanf("%d", &X), ++t[(i+j)%3][X-1];
  
  int res = 1 << 30;
  rep(i,C) rep(j, C) if(i!=j) rep(k,C) if(i!=k && j!=k) {
    int tt = 0;
    rep(l,C) tt += D[l][i]*t[0][l];
    rep(l,C) tt += D[l][j]*t[1][l];
    rep(l,C) tt += D[l][k]*t[2][l];
    if (tt < res) res = tt;
  }
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) {
        cin >> A[i];
    }
    reverse(all(A));
    vector<int> dp(n + 1, INF);
    rep(i, n) {
        *upper_bound(all(dp), A[i]) = A[i];
    }
    cout << lower_bound(all(dp), INF) - dp.begin() << endl;
}

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


Measured memory_bytes: 3992
using System;

namespace ABC119B
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            double sum = 0;
            for (int i = 0; i < N; i++)
            {
                string[] XU = Console.ReadLine().Split(' ');
                string U = XU[1];
                if (U == "JPY")
                {
                    sum += int.Parse(XU[0]);
                }
                else
                {
                    sum += double.Parse(XU[0]) * 380000;
                }
            }
            Console.WriteLine(sum);
        }
    }
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	multiset<long long> memo;
	long long a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		memo.insert(a[i]);
	}
	sort(a,a+n);
	reverse(a,a+n);
	long long now=1LL;
	while (now<=a[0])
	{
		now*=2LL;
	}
	long long ans=0LL;
	for (int i = 0; i < n; ++i)
	{
		while (now>a[i]*2LL)
		{
			now/=2LL;
		}
		int cnt=memo.count(a[i]),cnt2=memo.count(now-a[i]);
		if (cnt==0)
		{
			continue;
		}
		if (now==a[i]*2LL)
		{
			if (cnt>1)
			{
				for (int j = 0; j < cnt/2; ++j)
				{
					++ans;
					memo.erase(memo.lower_bound(a[i]));
					memo.erase(memo.lower_bound(a[i]));
				}
			}
			else if (cnt==1)
			{
				memo.erase(memo.lower_bound(a[i]));
			}
		}
		else if (cnt>0&&cnt2>0)
		{
			for (int j = 0; j < min(cnt,cnt2); ++j)
			{
				++ans;
				memo.erase(memo.lower_bound(a[i]));
				memo.erase(memo.lower_bound(now-a[i]));
			}
		}
		else
		{
			for (int j = 0; j < cnt; ++j)
			{
				memo.erase(memo.lower_bound(a[i]));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define rep(x,a,b)         for(int x = a; x < b; x++)
#define per(x,a,b)         for(int x = a; x >= b; x--)
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).rbegin(), container.rend()
#define sz(container)      (int) (container).size()
#define pb                 push_back
#define eb                 emplace_back
#define fi                 first
#define sc                 second

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> bool smin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool smax(T &a, T b) { return a < b ? (a = b, true) : false; }

#ifdef LOCAL_DEFINE
    #include "DEBUG.hpp"
#else
    #define debug(...) 0
#endif
const int maxn = 200010;
vector<int> e[maxn];
int vis[maxn], cc = 0;
void dfs(int at) {
    vis[at] = 1;
    ++cc;
    for(auto& x : e[at]) {
        if(vis[x]) continue;
        dfs(x);
    }
}
int main(void)
{
    int n, m;
    scanf("%d%d", &n, &m);
    memset(vis,0,sizeof(vis));
    rep(i,0,m) {
        int from, to;
        scanf("%d%d", &from, &to);
        e[from].pb(to);
        e[to].pb(from);
    }
    int ans = 0;
    rep(i,1,n+1) {
        if(vis[i]) continue;
        cc = 0;
        dfs(i);
        smax(ans, cc);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 21724
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<map>
#include<algorithm>
#define pii pair<int,int>
#define piii pair<pii,int>
#define mp make_pair
using namespace std;
map<piii,bool> ma;
int ans=0;
int main()
{
	int a[3],b[3];
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	while(1)
	{
		if(a[0]%2 || a[1]%2 || a[2]%2) break;
		sort(a,a+3);
		piii t=mp(mp(a[0],a[1]),a[2]);
		if(ma.count(t)) {ans=-1;break;}
		ans++;
		ma[t]=1;
		b[0]=(a[1]+a[2])/2;
		b[1]=(a[0]+a[2])/2;
		b[2]=(a[0]+a[1])/2;
		for(int i=0;i<3;i++) a[i]=b[i];
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

void sort(char *num, int size);

int main(void)
{
	char num[16];
	long max, min;
	int i, j, n;
	
	scanf("%d", &n);
	while (n != 0){
		n--;
		max = 0;
		min = 0;
		
		scanf("%s", num);
		
		sort(num, 8);
	//	printf("num = %s\n", num);
		for (i = 0; i < 8; i++){
			max = max * 10 + num[i] - '0';
		}
		for (i = 8 - 1; i >= 0; i--){
			min = min * 10 + num[i] - '0';
		//	printf("min = %d\n", min);
		}
	//	printf("%ld\n%ld\n", max, min);
		printf("%ld\n", max - min);
		
	}
	
	return (0);
	
}

void sort(char *num, int size)
{
	int i, j, max, dum;
	
	for (i = 0; i < size - 1; i++){
		max = i;
		for (j = i + 1; j < size; j++){
			if (num[max] < num[j])max = j;
		}
		dum = num[i];
		num[i] = num[max];
		num[max] = dum;
	}
}

Measured memory_bytes: 596
import Control.Monad
main = do
  mnl_in <- (return . map (read::String->Int) . words) =<< getLine
  let m:n:l:[] = mnl_in
  mA <- replicateM m $ (return . map (read::String->Int) . words) =<< getLine
  mB <- replicateM n $ (return . map (read::String->Int) . words) =<< getLine
  let mAB = matmul mA mB
  forM_ [0..m-1] $ \i -> do
    forM_ [0..l-1] $ \j -> do
      putStr $ show ((mAB!!i)!!j)
      putStr $ if j == l-1 then "\n" else " "
      
matmul :: [[Int]] -> [[Int]] -> [[Int]]
matmul mA mB = let r = length mA
                   c = length $ mB!!0
                   mAi i = mA !! i
                   mBj j = [(mB!!i)!!j |i<-[0..((length $ mB) -1)]]
                  in [[sum . map (\(x,y)->x*y) $ zip (mAi i) (mBj j)| j<-[0..c-1]] |i<-[0..r-1]]


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

int main()
{
	int n;
	int p[100];

	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> p[i];

	sort(p, p + n, greater<int>());

	for (int i = 0; i < n; i++) {
		if (p[i] == i + 1) {
			cout << i + 1 << endl;
			break;
		}
		else if (p[i] < i + 1) {
			cout << i << endl;
			break;
		}
		else if (i == n - 1) {
			cout << n << endl;
		}
	}

	return 0;
}



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

const ll M=1e9+7;
ll memo[5005][5005];
ll prefix[5005][5005];
ll getCost(int row,int left,int right){
    return ((prefix[row][right+1]%M-prefix[row][left]%M)+M)%M;
}
int main(){
    int n;
    cin>>n;
    string str;
    cin>>str;
    for(int i=0;i<n;i++){
        memo[0][i]=1;
        prefix[0][i+1]=(prefix[0][i]%M+memo[0][i]%M)%M;
    }
    
    for(int i=1;i<n;i++){
        for(int j=0;j<n;j++){
            if(j>n-i-1){
                memo[i][j]=0;
            }
            else if(str[i-1]=='<'){
                memo[i][j]=getCost(i-1,j+1,n-1);
            }
            
            else{
                memo[i][j]=getCost(i-1,0,j);
            }
            
            prefix[i][j+1]=prefix[i][j]+memo[i][j];
        }
    }
    
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<n;j++){
    //         cout<<memo[i][j]<<" ";
    //     }
        
    //     cout<<endl;
    // }
    
    printf("%lld\n",memo[n-1][0]%M);
}

Measured memory_bytes: 237184
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> t(N),x(N),y(N);
    for(int i = 0; i < N;i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    ll nt = 0,nx = 0, ny = 0;
    for(int i = 0; i < N;i++){
      //  cout << i << endl;
        ll dif = abs(nx - x[i]) + abs(ny - y[i]);
        if(t[i] - nt < dif){
            cout << "No" << endl;
            return 0;
        }
        ll dif2 = (t[i] - nt) - dif;
        if(dif2%2 != 0){
            cout << "No" << endl;
            return 0;
        }
        nt = t[i]; nx = x[i]; ny = y[i];
    }
    cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 2560
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let mut mat1 : Vec<Vec<i32>> = Vec::new();
    for _i in 0..3 {
        let v : Vec<i32> = get_vec();
        mat1.push(v);
    }
    let n : usize = get_one();
    let mut tfs = vec!(vec!(false;3);3);
    for i in 0..n {
        let x : i32 = get_one();
        for j in 0..3 {
            for k in 0..3 {
                if x == mat1[j][k] {
                    tfs[j][k] = true;
                }
            }
        }
    }
    let mut ans = false;
    for i in 0..3 {
        let mut la = true;
        for j in 0..3 {
            if tfs[i][j] == false {
                la = false;
                break;
            }
        }
        if la == true {
            ans = true;
            break;
        }
    }
    for i in 0..3 {
        let mut la = true;
        for j in 0..3 {
            if tfs[j][i] == false{
                la = false;
                break;
            }
        }
        if la == true {
            ans = true;
            break;
        }
    }
    let mut la = true;
    for i in 0..3 {
        if tfs[i][i] == false {
            la = false;
            break;
        }
    }
    if la == true {
        ans = true;
    }
    la = true;
    for i in 0..3 {
        if tfs[i][2-i] == false {
            la = false;
            break;
        }
    }
    if la == true {
        ans = true;
    }
    println!("{}", if ans {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int a;
int cnt[200010];
int vis[200010];
int s[200010];
bool cmp(int x,int y)
{
    return x>y;
}
int main(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>cnt[i];
        vis[cnt[i]]++;
    }
    for(int i=0;i<n;i++){
       if(vis[cnt[i]]){
        s[ans++]=vis[cnt[i]];
        vis[cnt[i]]=0;
       }
    }
    sort(s,s+ans,cmp);
    int t=0;
    for(int i=0;i<k;i++){
        t+=s[i];
    }
    cout<<(n-t)<<endl;
    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
//        long startTime = System.currentTimeMillis();
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        scanner.close();

        long count = 0;

        if ((A >= 1 && A <= 9) && (B >= 1 && B <= 9)) {
            count = A * B;
        }else{
            count = -1;
        }

        System.out.println(count);

    }

}



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

void Main()
{
  ll A,B,N;
  cin >> A >> B >> N;
  if (B <= N) {
    cout << (ll)(floor(A*(B-1)/B)) - A*(ll)(floor((B-1)/B)) << endl;
  } else {
    cout << (ll)(floor(A*N/B)) - A*(ll)floor(N/B) << endl;
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main() {
  int W;
  cin >> W >> W;
  auto a = [&]() { cout << string(W + 2, '#') << endl; };
  a();
  string S;
  while (cin >> S) {
    cout << '#' << S << "#\n";
  }
  a();
  return 0;
}


Measured memory_bytes: 256
import copy
n = int(input())
a = [2**x for x in range(0,21) ]
b = 0
for i, name in enumerate(a):
    b_copy = copy.deepcopy(b)
    b = name
    if b > n:
        break

ans = []
ans_l = []
c = n - b_copy
for j in range(i-1)[::-1]:
    if a[j] <= c:
        c -= a[j]
        ans.append(j)
        ans_l.append(b_copy)
        b_copy += a[j]

N = i
H = 0
A = []

for k in range(1, i):
    A.append([k, k+1, 0])
    A.append([k, k+1, 2**(k-1) ])
    H += 2
    if k-1 in ans:
        A.append([k, N, ans_l[ans.index(k-1)]])
        H += 1

print(" ".join([str(N), str(H)]))
for kk in A:
    print(" ".join(list(map(str, kk))))

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

void solve() {
    string S; cin >> S;
    int N = S.size() + 1;
    vector<int> ans(N);
    int cnt = 0;
    for(int i = 0; i < N; ++i) {
        if(S[i] == '<') {
            ans[i + 1] = max(ans[i + 1], ++cnt);
        } else {
            cnt = 0;
        }
    }
    cnt = 0;
    for(int i = N - 1; i >= 0; --i) {
        if(S[i] == '>') {
            ans[i] = max(ans[i], ++cnt);
        } else {
            cnt = 0;
        }
    }
    long long sum = accumulate(ans.begin(), ans.end(), 0LL);
    cout << sum << '\n';
}

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


Measured memory_bytes: 2844
N = int(input())
As = list(map(int,input().split()))
c = 0
nums = [0]*(10**5+2)
for a in As:
    nums[a]+=1

for i in range(1,len(nums)-1):
    t = nums[i-1]+nums[i]+nums[i+1]
    c = max(c,t)
print(c)




Measured memory_bytes: 84640
import std.stdio, std.conv, std.string, std.range, std.array, std.algorithm;
import std.bigint;

bool[1000001] p;

void main()
{
  int[10002] sum;
  p[2 .. 1000001] = true;

  for (int i = 2; i <= 1000000; i++){
    if (p[i]){
      for (int j = i * 2; j <= 1000000; j += i){
        p[j] = false;
      }
    }
  }
  for (int i = 1, j = 0; j <= 10000; i++){
    if (p[i]){
      sum[j + 1] = sum[j] + i;
      j++;
    }
  }

  while (true){
    int n = readln().chomp().to!int;
    if (n == 0) break;
    writeln(sum[n]);
  }
}

Measured memory_bytes: 3416
n, k = map(int, input().split())
a = list(map(int, input().split()))
def f(l, s):
    return s if l % s == 0 else f(s, l % s)

z = f(max(a), min(a))
for i in a:
    z = f(i, z)
if max(a) >= k and k % z == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 14224
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	[n, r] <- readToListN 2 <$> BS.getLine
	let diff =  max 0 $ 100 * (10 - n)
	print $ r + diff


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

void init_dp(string a, string b, vector<vector<int> > &dp){
    dp[0][0] = a[0] == b[0] ? 1 : 0;
    for(int i=1; i<b.size();i++)
        if(a[0] == b[i])
            dp[0][i] = 1;
        else
            dp[0][i] = dp[0][i-1];
    
    for(int i=1; i<a.size();i++)
        if(b[0] == a[i])
            dp[i][0] = 1;
        else
            dp[i][0] = dp[i-1][0];
}

int LCS(string a, string b, vector<vector<int> > &dp){
    for(int i=1;i<a.size();i++)
        for(int j=1;j<b.size();j++)
            if(a[i] == b[j])
                dp[i][j] = 1+dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    
    return dp[a.size()-1][b.size()-1];
}

string getstring(string a, string b, vector<vector<int> > &dp, int lcssize){
    if(lcssize == 0)
        return "";

    int i,j;
    i = a.size()-1;
    j = b.size()-1;
    string ans;

    while(lcssize){
        if(a[i] == b[j]){
            ans += a[i];
            i--;
            j--;
            lcssize--;
        }
        else if((i > 0 && dp[i-1][j] > dp[i][j-1]) || j == 0)
            i--;
        else
            j--;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

int main(){
    
    string s, t;
    int asize, bsize, lcssize;
    cin >> s >> t;
    asize = s.size();
    bsize = t.size();
    vector<vector<int> > dp(asize, vector<int> (bsize));
    init_dp(s,t,dp);
    lcssize = LCS(s, t, dp);
    cout << getstring(s, t, dp, lcssize) << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
	ll n, m;
	cin >> n;
	string s;
	vector<string>ans;
	map<string, ll> mp;
	for (int i = 0; i < n; i++) {
		cin >> s;
		mp[s]++;
		ans.push_back(s);
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> s;
		mp[s]--;
	}
	ll ma = 0;
	for (int i = 0; i < ans.size(); i++) {
		ma = max(ma, mp[ans[i]]);
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
VI dp(101010, -1);
map<int, VI> g;

int dfs(int cur)
{
    if (dp[cur] != -1)
        return dp[cur];
    int ret = 0;
    for (auto x : g[cur])
    {
        chmax(ret, 1 + dfs(x));
    }
    dp[cur] = ret;
    return ret;
}

int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
    }
    rep(i, n)
    {
        if (dp[i] == -1)
        {
            dfs(i);
        }
    }
    int ans = -1;
    rep(i, n) ans = chmax(ans, dp[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14976
from collections import deque
N = int(input())
X = [[] for _ in range(N)]
for i in range(N):
    s = input()
    for j in range(N):
        if s[j] == "1":
            X[i].append(j)

def bipartite(n, E):
    col = [-1] * n
    f = 0
    for i in range(n):
        if col[i] >= 0: continue
        que = deque([[i, 0]])
        while que:
            v, c = que.popleft()
            if col[v] == -1:
                col[v] = c
            elif col[v] == c:
                continue
            else:
                f = 1
                break
            for ne in E[v]:
                if col[ne] == c:
                    f = 1
                    break
                if col[ne] < 0:
                    que.append([ne, 1-c])

            if f:
                break
        if f:
            break
    return 1-f

def BFS(n, E, i0=0):
    Q = deque([i0])
    D = [-1] * n
    D[i0] = 0
    while Q:
        x = Q.popleft()
        for c in E[x]:
            if D[c] == -1:
                D[c] = D[x] + 1
                Q.append(c)
    return D

if bipartite(N, X):
    print(max([max(BFS(N, X, i)) for i in range(N)])+1)
else:
    print(-1)


Measured memory_bytes: 4460
def main():
    n = int(input())
    s = input()
    r_set, g_set, b_set = set(), set(), set()

    for i, c in enumerate(s):
        if c == "R":
            r_set.add(i)
        elif c == "G":
            g_set.add(i)
        elif c == "B":
            b_set.add(i)

    cnt = 0
    for i in range(n):
        for j in range(i + 1, n):
            k = 2 * j - i
            if k >= n:
                continue
            if s[i] == s[j] or s[j] == s[k] or s[k] == s[i]:
                continue
            cnt += 1

    print(len(r_set) * len(g_set) * len(b_set) - cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 73208
#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll mod(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  mod(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*mod(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return mod(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}

ll man(ll x,ll y,ll xx,ll yy){
return abs(x-xx)+abs(y-yy);
}

int main()
{
    ll n;
    cin>>n;
    vector<pair<ll,ll>>a;
    ll mi =1e16;ll ma = INT_MIN;
    ll f= 1e16,g=INT_MIN;

    ll xx,yy,xxx,yyy;
    ll ww,zz,www,zzz;


    ll ans=-1;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
       a.push_back({x,y});

    }
    for(auto p:a){

        if(p.first+p.second<mi){
            mi=p.first+p.second;
            xx=p.first;
            yy=p.second;
        }
        if(p.first+p.second>ma){
             ma=p.first+p.second;
            xxx=p.first;
            yyy=p.second;
        }


   if(p.first-p.second>g){
             g=p.first-p.second;
            www=p.first;
            zzz=p.second;
        }
        if(p.first-p.second<f){
             f=p.first-p.second;
            ww=p.first;
            zz=p.second;
        }

    }
  //  cout<<mi<<" " <<ma<<" "<<f<<" "<<g<<endl;
    cout<<max(man(xx,yy,xxx,yyy),man(ww,zz,www,zzz));


    return 0;
}


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

public class Main {
	public static void main(String args[]) {

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();

		int a[] = new int[n];
		a[0] = sc.nextInt();

		int curentInt = a[0];
		int beforeCur = curentInt;
		for (int i = 1; i < (n - 1); i++) {
			curentInt = sc.nextInt();
			a[i] = (beforeCur > curentInt) ? curentInt : beforeCur;
			beforeCur = curentInt;
		}

		a[n - 1] = curentInt;

		long sum = java.util.Arrays.stream(a).sum();
		System.out.println(sum);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

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

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

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

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

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

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

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

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

Measured memory_bytes: 28500
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DPracticalSkillTest solver = new DPracticalSkillTest();
        solver.solve(1, in, out);
        out.close();
    }

    static class DPracticalSkillTest {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int h = in.nextInt();
            int w = in.nextInt();
            int d = in.nextInt();
            HashMap<Integer, Pair> hm = new HashMap<>();
            int[] cumDist = new int[h * w + 1];
            for (int i = 0; i <= d; i++) {
                cumDist[i] = 0;
            }
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    Pair p = new Pair(i, j);
                    int val = in.nextInt();
                    hm.put(val, p);
                }
            }

            for (int i = d + 1; i <= h * w; i++) {
                Pair p1 = new Pair(hm.get(i).x, hm.get(i).y);
                Pair p2 = new Pair(hm.get(i - d).x, hm.get(i - d).y);
                cumDist[i] = cumDist[i - d] + Pair.dist(p1, p2);
            }
            int q = in.nextInt();
            for (int i = 0; i < q; i++) {
                int st = in.nextInt();
                int en = in.nextInt();
                out.println(cumDist[en] - cumDist[st]);
            }
        }

    }

    static class Pair {
        int x;
        int y;

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        static int dist(Pair p1, Pair p2) {
            return Math.abs(p1.x - p2.x) + Math.abs(p1.y - p2.y);
        }

    }
}



Measured memory_bytes: 99804
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <functional>

using namespace std;
#define PI 3.14159265359
#define ll long long int


int main()
{
    ll N, K, ans = 0;
    cin >> N >> K;

    ll temp = N;
    while (1)
    {
        temp /= K;
        ans++;
        if(temp == 0) break;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N;
	cin >> N;
	cout << "ABC" << N << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
const int INF=1001001001;
int N;
int dp[100010];
 
int main(){
    cin>>N;
    fill_n(dp,N+3,INF);
 
 
    for(int i=0;i<N;i++){
        int A;cin>>A;
        *lower_bound(dp,dp+N+3,A)=A;
    }
 
    cout<<lower_bound(dp,dp+N+3,INF)-dp<<endl;
}


Measured memory_bytes: 3520