akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int h, w; cin >> h >> w;
  vector<string> g(h);
  rep(i, h) cin >> g[i];

  vector<vector<int>> up(h, vector<int>(w, 0));
  rep(i, w) {
    for (int j = 1; j < h; j ++) {
      if (g[j - 1][i] == '.') up[j][i] = up[j - 1][i] + 1;
    }
  }
  vector<vector<int>> down(h, vector<int>(w, 0));
  rep(i, w) {
    for (int j = h - 2; j >= 0; j --) {
      if (g[j + 1][i] == '.') down[j][i] = down[j + 1][i] + 1;
    }
  }
  vector<vector<int>> right(h, vector<int>(w, 0));
  rep(i, h) {
    for (int j = w - 2; j >= 0; j --) {
      if (g[i][j + 1] == '.') right[i][j] = right[i][j + 1] + 1;
    }
  }
  vector<vector<int>> left(h, vector<int>(w, 0));
  rep(i, h) {
    for (int j = 1; j < w; j ++) {
      if (g[i][j - 1] == '.') left[i][j] = left[i][j - 1] + 1;
    }
  }

  int ans = 0;
  rep(i, h) rep(j, w) {
    if (g[i][j] == '.') {
      int t = up[i][j] + down[i][j] + right[i][j] + left[i][j] + 1;
      ans = max(ans, t);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 67200
n, k = map(int, input().split())
ans = 0
mod = 1000000007

maxNum = 0
minNum = 0

for i in range(k):
    maxNum += n - i
    minNum += i

for i in range(k, n+2):
    ans += maxNum - minNum + 1
    ans %= mod
    maxNum += n-i
    minNum += i

print(ans)

Measured memory_bytes: 9196
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <unordered_set>
#include <cctype>
#include <cassert>


using namespace std;

typedef long long ll;
typedef long double ld;

const int nax = (int)1e5 + 5;

int dp[nax];
int deg[nax];
vector<int>g[nax];

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("angle2.in", "r", stdin);
	//freopen("angle2.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].emplace_back(v);
		deg[v]++;
	}

	vector<int>q;
	for (int i = 0; i < n; i++) {
		if (deg[i] == 0) {
			q.push_back(i);
		}
	}

	for (int i = 0; i < (int)q.size(); i++) {
		int v = q[i];
		
		for (auto to : g[v]) {
			dp[to] = max(dp[to], dp[v] + 1);
			deg[to]--;
			if (deg[to] == 0) {
				q.push_back(to);
			}
		}
	}

	cout << *max_element(begin(dp), end(dp));
	return 0;
}

Measured memory_bytes: 7164
#include<stdio.h>

#define MAX 2000001
#define VMAX 10000

int A[MAX],C[VMAX+1],B[MAX];

void countingSort(int *A, int k) {
  
  int i,j;

  // 初期化
  for(i=0;i<VMAX;i++) {
    C[i] = 0;
  }

  // 出現数の記録
  for(j=1;j<=k;j++) {
    C[A[j]]++;
  }
  
  // トータルのカウント
  for(i=1;i<VMAX;i++) {
    C[i] += C[i-1];
  }
  
  for(j=1;j<=k;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
   
  }

  for(i=1;i<k;i++) {
    printf("%d ",B[i]);
  }
  printf("%d\n",B[k]);

}



int main(char args[]){

  int i,n;
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++) {
    scanf("%d",&A[i]);
  }

  countingSort(A,n);

  
  return 0;
}

Measured memory_bytes: 16264
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = (n - 1); i >= 0; i--)
#define PI 3.141592653589793

using namespace std;
using ll = long long;

int main() {

	char a;
	cin >> a;

	bool ans = true;

	if (a > 90)ans = false;

	puts(ans ? "A" : "a");

	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=100 +117;
const int MM=100 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int n;
int dis[NN]={};
LL siz[NN]={};
vector<int> p[NN]={};
int ord[NN]={};
void dfs(int x,int fa){
	for(int i=0;i<p[x].size();++i){
		int cur=p[x][i];
		if(cur!=fa){
			dis[cur]=dis[x]+1;
			dfs(cur,x);
		}
	}
}
bool cmp(int a,int b){
	return dis[a]>dis[b];
}
int e[NN][2]={};
int res=1e9;
LL op=0;
int dep;
void upd(){
	dep=0;
	for(int i=1;i<=n;++i){
		ord[i]=i;
		dep=max(dis[i],dep);
	}
	sort(ord+1,ord+1+n,cmp);
	for(int i=0;i<=dep;++i)siz[i]=0;
	siz[dep]=1;
	for(int i=1;i<=n;++i){
		int x=ord[i];
		int cnt=0;
		for(int i=0;i<p[x].size();++i){
			if(dis[p[x][i]]>dis[x])++cnt;
		}
		siz[dis[x]]=max(siz[dis[x]],siz[dis[x]+1]*cnt);
	}
}
int main(){
	//open();
	n=read();
	for(int i=1;i<n;++i){
		int x=read(),y=read();
		p[x].push_back(y);
		p[y].push_back(x);
		e[i][0]=x,e[i][1]=y;
	}
	for(int i=1;i<=n;++i){
		dis[i]=0;
		dfs(i,0);
		upd();
		if(dep<res)res=dep,op=siz[0];
		if(res==dep)op=min(op,siz[0]);
	}
	for(int i=1;i<n;++i){
		dis[e[i][0]]=0;
		dis[e[i][1]]=0;
		dfs(e[i][0],e[i][1]);
		dfs(e[i][1],e[i][0]);
		upd();
		if(dep<res)res=dep,op=siz[0]*2;
		if(res==dep)op=min(op,siz[0]*2);
	}
	printf("%d %lld\n",res+1,op);
	close();
	return 0;
}

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

typedef long long ll;
const int maxn = 3e5 + 3;
int n, A[maxn], m;
ll a[maxn], sa[maxn];

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; ++i)
        scanf("%d", A + i);
    for(int i = 0; i < n; ++i)
        ++a[A[i]];
    std::sort(a, a + n + 1, std::greater<ll>());
    m = n + 1;
    while(m && a[m - 1] == 0)
        --m;
    sa[m - 1] = a[m - 1];
    for(int i = m - 2; i >= 0; --i)
        sa[i] = sa[i + 1] + a[i];
    for(int t = 1; t <= n; ++t) {
        ll l = 1, r = n + 1;
        while(r - l > 1) {
            ll mid = (l + r) / 2;
            ll k = std::lower_bound(a, a + m, mid, std::greater<ll>()) - a;
            if(mid * t <= (k * mid + sa[k]))
                l = mid;
            else
                r = mid;
        }
        ll k = std::lower_bound(a, a + m, l, std::greater<ll>()) - a;
        printf("%lld\n", (k * l + sa[k]) / (ll)t);
    }
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(int i=a; i<b; i++)
#define loopb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y, lli p){
    lli res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main(){
//	fastio;
	lli a, b;
	cin>>a>>b;
	lli res = a-2*b;
	if(res < 0)
		res = 0;
	cout<<res<<"\n";
}


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    S = LI()
    T = LI()

    dp = [[1]*(M+1) for _ in range(N+1)]

    for i in range(1,N+1):
        for j in range(1,M+1):
            if S[i-1] == T[j-1]:
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD
            else:
                dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % MOD
    print(dp[-1][-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 97572
// Aizu 1335: Equal Sum Sets
// 2017.9.19 bal4u@uu

#include <stdio.h>
#include <string.h>

int dp[12][22][205];

int main()
{
	int n, k, s;
	int i, j, a, b, max;
	int ans;

	while (scanf("%d%d%d", &n, &k, &s) && n) {
		memset(dp, 0, sizeof(dp));
		for (i = 1; i <= n; i++) dp[1][i][i] = 1;
		for (max = n, j = 1; j < k; j++, max += n)
			for (i = 1; i <= n; i++) 
				for (a = 1; a <= max; a++)
					for (b = 1; b + i <= n; b++)
						dp[j+1][i+b][i+a+b] += dp[j][i][a];
		for (ans = 0, i = 1; i <= n; i++) ans += dp[k][i][s];
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1892
N=int(input())

for i in range(1,N+1) :
    x,y,z = map(int,input().split())
    X=max(x,y,z)
    Y=min(x,y,z)
    Z=x+y+z-X-Y
    if X**2==Y**2+Z**2:
        print("YES")
    else :
        print("NO")
        


Measured memory_bytes: 5592
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {
    
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int X = int.Parse(input[1]);
            int[] L = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int ans = 1;
            int d = 0;

            for(int i = 0; i < N; i++)
            {
                d += L[i];
                if(d > X)
                {
                    break;
                }
                ans++;
            }

            Console.WriteLine(ans);
        }
    }
}

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

using namespace std;

int main()
{
	long long x;
	cin >> x;
	long long r = (x/11)*2;
	if (x%11 > 6) r += 2;
	else if (x%11 > 0) r += 1;
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b;
	cin>>a>>b;
	if(b%2)
	cout<<"No\n";
	else{
		int t=(b-a*2)/2;
		int c=a-t;
		if(t>=0 && c>=0)
		cout<<"Yes\n";
		else
		cout<<"No\n";
	}
}

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

void print(int a){
	int h,m,s;
	s=a%60;a/=60;
	m=a%60;a/=60;
	h=a;
	cout<<h/10<<h%10<<':'<<m/10<<m%10<<':'<<s/10<<s%10<<endl;
}
int main(){
	int h,m,s;
	while(cin>>h>>m>>s,~h|~m|~s){
		int a=120*60 - (60*(60*h+m)+s);
		print(a);
		print(3*a);
	}
	return 0;
}

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis,dis;
vector<vi> graph;
vector<vector<pair<li,li>>> wgraph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    wgraph.resize(n);
    dis.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
        dis[i]=INT_MAX;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

void dijkstra(li start)
{
    dis[start]=0;

    multiset<pair<li,li>> s;

    s.insert({0,start});

    while(!s.empty())
    {
        pair<li,li> tp=*s.B;
        s.erase(s.begin());

        li p=tp.S;

        if(!vis[p]) 
        {
            vis[p]=1;

            for(pair<li,li> v:wgraph[p])
            {
                if(dis[p]+v.S<dis[v.F])
                {
                    dis[v.F]=dis[p]+v.S;
                    s.insert({dis[v.F],v.F});
                }
            }
        }
    }
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n,k;

    cin>>n>>k;

    li a[n];

    for(li i=0;i<n;i++)
        cin>>a[i];

    sort(a,a+n,greater<li>());

    li ans=0;

    f(i,k,n-1)
    {
        ans+=a[i];
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
/*
!لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ
فَصَبْرٌ جَمِيلٌ
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define endl                         '\n'	
#define Ceil(x,y)             ((x+y-1)/y)
#define sz(s)               (int)s.size()
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define all(v) ((v).begin()), ((v).end())
#define vi                    vector<int>
#define Rabe3_adel           file();
#define fr(x,y) for(int x=0; x<(y); ++x)
const double PI = acos(-1), EPS = 1e-7;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x%y); }
ll lcm(ll x, ll y) { return ((x / gcd(x, y))*y); }
ll mod = 998244353;
ll power(ll x, ll y)
{
	if (y == 0)return 1;
	if (y == 1)return x;
	ll r = power(x, y / 2) % mod;
	return r%mod*r%mod*power(x, y % 2) % mod;
}
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}

int main()
{
	
	Rabe3_adel
		int n, m,a,b;
	cin >> n >> m; vi v(n+1), v2(n+1, 0);
	for (int i = 1; i <= n;++i)cin >> v[i];
		fr(i, m)
		{
			cin >> a >> b;
			v2[a] = max(v2[a], v[b]);
			v2[b] = max(v2[b], v[a]);
		}
		int ans = 0;
		for (int i = 1; i <= n; ++i)
		{
			ans += v[i] >v2[i];
		}
		cout << ans;


}

Measured memory_bytes: 3992
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/



void Calc() {

  set<tuple<int, int, int>> m;
  var(int, a, b, c);

  for (int i = 0; ; ++i) {
    if (a & 1 || b & 1 || c & 1) {
      cout << (i) << endl;
      return;
    }
    if (!m.insert(tie(a, b, c)).second) {
      cout << (-1) << endl;
      return;
    }
    int ba = b / 2 + c / 2;
    int bb = a / 2 + c / 2;
    int bc = a / 2 + b / 2;
    a = ba, b = bb, c = bc;
  }
}


Measured memory_bytes: 256
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

var sc = newScanner()

func insertionSort(a []int, g int) int {
	n := len(a)
	cnt := 0
	for i := g; i < n; i++ {
		v := a[i]
		j := i - g
		for j >= 0 && a[j] > v {
			a[j+g] = a[j]
			j -= g
			cnt++
		}
		a[j+g] = v
	}
	return cnt
}

func main() {
	n := scanInt()
	a := scanInts(n)
	cnt := 0
	g := []int{}
	for _, i := range []int{701, 301, 132, 57, 23, 10, 4, 1} {
		if n > i {
			g = append(g, i)
		}
	}
	if len(g) == 0 {
		g = append(g, 1)
	}
	m := len(g)
	for i := 0; i < m; i++ {
		cnt += insertionSort(a, g[i])
	}

	fmt.Println(m)
	fmt.Println(strings.Trim(fmt.Sprint(g), "[]"))
	fmt.Println(cnt)
	for i := 0; i < n; i++ {
		fmt.Println(a[i])
	}
}



Measured memory_bytes: 17452
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x){
    if (x==1){
        return false;
    }
    if(x==2){
        return true;
    }
    else if (x%2==0){
        return false;
    }
    else{
        for(int i=2;i*i<=x;i++){
            if(x%i==0){
                return false;
            }
        }
        return true;
    }
}

int main(){
    int Q=in();
    int a[50000];
    rep(i, 50000){
        a[i]=0;
    }
    rep(i, 50000){
        if(ifprime(2*i+1)&&ifprime(i+1)){
            a[i]=a[i-1]+1;
        }
        else{
            a[i]=a[i-1];
        }
    }
    int l, r;
    rep(i, Q){
        cin>>l>>r;
        if(l==1){
            cout<<a[(r-1)/2]<<endl;
        }
        else{
            cout<<a[(r-1)/2]-a[(l-1)/2-1]<<endl;
        }
    }
}

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, n, a) for(int i = (a); i >= (n); i--)
#define mod 1e9+7
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, x;
  cin >> n >> x;
  int s[100001];
  rep(i, 0, n) cin >> s[i];
  int a[100001];
  rep(i, 0, n) {
    a[i] = abs(s[i] - x);
  }
  int c = a[0];
  rep(i, 1, n) {
    int b = a[i];
    while(1) {
      if(c < b) swap(c, b);
      if(!b) break;
      c %= b;
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	string a, b;
	cin >> a;
	cin >> b;
	int la = a.length();
	int lb = b.length();
	if(la > lb) printf("GREATER\n");
	else if(lb > la) printf("LESS\n");
	else{
		for(int i = 0; i < la; i++){
			if(a[i] > b[i]) {
				printf("GREATER\n");
				return 0;
			}
			else if(a[i] < b[i]){
				printf("LESS\n");
				return 0;
			}
			else if(a[i] == b[i] && i == la - 1){
				printf("EQUAL\n");
				return 0;
			}
		}
	}
	return 0;
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout<< #i<< "= "<< i << endl
using namespace std;

int main(){
    int n,k;
    double ans = 0.0;
    cin >> n >> k;
    vector<int> d;
    vector<double> luck,sumluck;
    REP(i,n){
        int t;
        cin >> t;
        d.pb(t);
        luck.pb((t+1)/2.0);
        
    }
    sumluck.pb(0.0);
    REP(i,n){
        sumluck.pb(sumluck[i]+luck[i]);
    }

    REP(i,(n-k+2)){
        ans = max(ans,sumluck[i+k]-sumluck[i]);
        //debug(ans);
    }

    //REP(i,(n+1)) debug(sumluck[i]);
    printf("%.12lf\n",ans);
    return 0;
}


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

int main(){
	int r;
	int c;
	cin >> r >> c;
	int a[1000][1000] = {0};
	int y;
	int x;
	for ( y = 0 ;y<r ;y++ ) {
		for ( x = 0 ;x<c ;x++ ) {
			cin >> a[y][x];
			a[y][c]+=a[y][x];
			a[r][x]+=a[y][x];
			a[r][c]+=a[y][x];
		}
	}
	for ( y = 0 ;y<r+1 ;y++ ) {
		for ( x = 0 ;x<c+1 ;x++ ) {
			cout << a[y][x];
			if ( x < c ) cout << " ";
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 5072
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main(){
	int n,x,i,flag;
	while(cin>>n){
		x = n/4;
		flag=0;
		if(n%4 == 0 || n%7 == 0 || n%4%7 == 0 || n%7%4 == 0){
			cout<<"Yes"<<endl;
		}else{
			for(i=0;i<=x;i++){
				if((n-i*4)%7 == 0){
					flag =1;
					cout<<"Yes"<<endl;
					break;
				}
			}
			if(flag == 0){
				cout<<"No"<<endl;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N = input()
a = map(int, raw_input().split())
S1 = S2 = 0
for i in range(N):
    if i % 2:
        if a[i] > 0:
            S1 += a[i]
    else:
        if a[i] > 0:
            S2 += a[i]
if S1 == S2 == 0:
    print max(a)
    maxm = -INF
    for i in range(N):
        if maxm < a[i]:
            maxm = a[i]
            pos = i
    a[pos] = 1
    if pos % 2:
        S1 = 1
    else:
        S2 = 1
else:
    print max(S1, S2)
ls = []
for i in range(len(a)):
    a[i] = (a[i], (i % 2 == (S1 > S2)))
while True:
    #print a
    flag = True
    for i in range(len(a)):
        if a[i][0] < 0 and a[i][1]:
            ls.append(i + 1)
            if i == 0:
                a = a[1:]
            elif i == len(a) - 1:
                a = a[:-1]
            else:
                S = (a[i - 1][0] + a[i + 1][0], False)
                a = a[:i - 1] + [S] + a[i + 2:]
            flag = False
            break
    if not flag:
        continue
    for i in range(len(a)):
        if not a[i][1]:
            ls.append(i + 1)
            if i == 0:
                a = a[1:]
            elif i == len(a) - 1:
                a = a[:-1]
            else:
                S = (a[i - 1][0] + a[i + 1][0], True)
                a = a[:i - 1] + [S] + a[i + 2:]
            flag = False
            break
    if flag:
        break

print len(ls)
for num in ls:
    print num

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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 int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll x;
    cin >> x;
    ll ans = 0;
    ans += x / 11 * 2;
    x %= 11;

    if(x > 0)ans++;
    if(x > 6)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int gcd(int a, int b){
	if (a%b == 0) return(b);
	else return(gcd(b, a%b));
}

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

    // そいつを除いた累積GCDを求める
    vector<int> p(n), q(n);
    // 前からgcd
    ll m_gcd = a[0];
    p[0] = m_gcd;
    FOR(i, 1, n) {
        m_gcd = gcd(m_gcd, a[i]);
        p[i] = m_gcd;
    }
    debug(p);
    // 後ろからgcd
    m_gcd = a.back();
    q[n-1] = m_gcd;
    for (int i = n-2; i >= 0; i--) {
        m_gcd = gcd(m_gcd, a[i]);
        q[i] = m_gcd;
    }
    debug(q);
    int ans = 0;
    rep(i, n) {
        int tmp;
        if (i==0) {
            tmp = q[i+1];
        } else if (i==n-1) {
            tmp = p[i-1];
        } else {
            tmp = gcd(p[i-1], q[i+1]);
        }
        chmax(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort(all(v))
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};



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

	int n;
	cin >> n;
	int h[n];
	rep(i, n) cin >> h[i];
	int ans = 0;
	int dp[n] = {};
	REP(i, 1, n) {
    if(h[i - 1] >= h[i]) {
      dp[i] = dp[i - 1] + 1;
    }
  }

  rep(i, n) ans = max(ans, dp[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc141/tasks/abc141_e
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using I = int;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (I i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    I N;
    string S;
    cin >> N >> S;
    I len = S.length(), maxv = 0;
    REP(d, len) {
        I cnt = 0;
        REP(i, len - d) {
            if (S[i] == S[i + d]) {
                cnt++;
            } else {
                maxv = max(maxv, min(cnt, d));
                cnt = 0;
            }
        }
        maxv = max(maxv, min(cnt, d));
    }
    cout << maxv << endl;

    return 0;
}


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

int main(){
    int N=0;
    cin >> N;
    vector<int> L(N,0);
    for (int i=0; i<N; ++i) cin >> L[i];
    sort(L.begin(), L.end());

    int cnt=0;
    for (int i=0; i<N-2; ++i){
        for (int j=i+1; j<N-1; ++j){
            for (int k=j+1; k<N; ++k){
                if (L[i] + L[j] > L[k] && L[i]!=L[j] && L[j]!=L[k]) ++cnt;
            }
        }
    }
    cout << cnt;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
lli dfs(lli v,vector <lli> s[],lli vis[])
{
    if(vis[v]!=-1)
        return vis[v];
    lli ans=0;
    for(auto it=s[v].begin();it!=s[v].end();it++)
        ans=max(ans,1+dfs(*it,s,vis));
    vis[v]=ans;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    lli n,m,i,u,v,ans=0;
    cin>>n>>m;
    vector <lli> s[n+1];
    lli vis[n+1];
    memset(vis,-1,sizeof(vis));
    for(i=0;i<m;i++)
    {
        cin>>u>>v;
        s[u].push_back(v);
    }
    for(i=1;i<=n;i++)
        ans=max(ans,dfs(i,s,vis));
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 9216
#!/usr/bin/env python3
import sys


def solve(S: str):
    if(S == 'ABC'):
        ans = 'ARC'
    else:
        ans = 'ABC'
    return print(ans)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8900
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    rep(i,n-1){
        if(a[i]==a[i+1]){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";

    return 0;
}

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

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

const long long INF = 1LL << 60;

int main() {
  int N;
  cin >> N;
  long long h[100010];
  long long dp[100010];
  
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
  }
  
  for (int i = 0; i < 100010; ++i) {
    dp[i] = INF;
  }
  
  dp[0] = 0;
  
  for (int i = 1; i < N; ++i) {
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i > 1) {
      chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
  }
  
  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 5116
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

const int INF = 1e9+100;

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

	  vector<vector<int> > field;
	  vector<pair<int,int> > in;
	  vector<int> x, y;
	  int n, m, a, b;
	  int x1, x2, y1, y2;

	  cin>>n>>m;
	  
	  for(int i = 0; i < n; i++){
		cin>>a>>b;
		x.push_back(a);
		y.push_back(b);
		in.push_back(make_pair(b,a));
	  }

	  x.push_back(INF);
	  x.push_back(-INF);
	  y.push_back(INF);
	  y.push_back(-INF);
	  
	  sort(x.begin(), x.end());
	  sort(y.begin(), y.end());
	  sort(in.begin(), in.end());
	  
	  x.erase(unique(x.begin(), x.end()), x.end());
	  y.erase(unique(y.begin(), y.end()), y.end());
	  

	  field.resize(y.size()+4, vector<int>(x.size()+4, 0));
	  
	  for(int i = 0; i < in.size(); i++){
		int xkey = in[i].second, ykey = in[i].first;
		
		int tx = lower_bound(x.begin(), x.end(), xkey) - x.begin();
		int ty = lower_bound(y.begin(), y.end(), ykey) - y.begin();

		field[ty][tx]++;
	  }
	 
	  for(int i = 0; i < y.size(); i++){
		for(int j = 0; j < x.size(); j++){
		  field[i+1][j] += field[i][j];
		}
	  }

	  for(int j = 0; j < x.size(); j++){
		for(int i = 0; i < y.size(); i++){
		  field[i][j+1] += field[i][j];
		}
	  }
	  
	  for(int i = 0; i < m; i++){
		cin>>x1>>y1>>x2>>y2;
		
		int tx1l = lower_bound(x.begin(), x.end(), x1) - x.begin();
		int ty1l = lower_bound(y.begin(), y.end(), y1) - y.begin();
		int tx2u = upper_bound(x.begin(), x.end(), x2) - x.begin();
		int ty2u = upper_bound(y.begin(), y.end(), y2) - y.begin();
		
		int ans = field[ty2u-1][tx2u-1] + field[ty1l-1][tx1l-1] - field[ty2u-1][tx1l-1] - field[ty1l-1][tx2u-1];
		
		cout<<ans<<endl;
	  }
	  
	  return 0;
}



Measured memory_bytes: 100996
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int N=sc.nextInt();
		pw.println(1.*((N+1)/2)/N);
		pw.close();
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


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 int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

Measured memory_bytes: 21076
#include<stdio.h>
int main()
{
	int a, b, c;
	while(scanf("%d %d %d", &a, &b, &c))
	{
		if((a == -1 && b == -1) && c == -1)
		{
			break;
		}
	    if((a == -1 || b == -1) && c == -1)
	    {
		    printf("F\n");
	    }
	    else
	    {
		    int sum = 0, k = 0;
		    if(a >= 0)
		    {
			    sum += a;
		    }
		    if(b >= 0)
		    {
			    sum += b;
		    }
		    if(sum >= 80)
		    {
			    printf("A\n");
		    }
		    else if(sum >= 65 && sum < 80)
		    {
			    printf("B\n");
		    }
		    else if(sum >= 50 && sum < 65 || c >= 50)
		    {
		 	    printf("C\n");
		    }
		    else if(sum >= 30 && sum < 50)
		    {
			    printf("D\n");
		    }
		    else
		    {
			    printf("F\n");
		    }
	    }
    }
	return 0;
 } 


Measured memory_bytes: 2600
#include <bits/stdc++.h>
using namespace std;
int main(){
  string h;
  cin>>h;
  int c,f;
  for(int i=0;i<h.length();i++){
    if(h[i]=='C'){
      c=i;
    break;
    }
  }
    for(int i=0;i<h.length();i++){
    if(h[i]=='F'){
      f=i;
    }
    }
  if(c<f) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

using namespace std;

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

  int n;
  cin >> n;
  vector<int64_t> a(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] += a[i - 1];
  }

  int64_t ans = abs(2 * a[1] - a[n]);
  for (int i = 1; i < n - 1; ++i) {
    ans = min(ans, abs(2 * a[i] - a[n]));
  }
  cout << ans << "\n";
}


Measured memory_bytes: 1792
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (#x) << " is " << (x) << endl;
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 998244353;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " "; cout << endl;}
void PA(int v[], int n) { for (int i = 0 ; i < n ; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n) {for (int i = 0; i < n; i++)cin >> a[i];}
//continue break deque stack queue sort reverse accumulate  count lower_bound upper_bound
// next_permutation copy_n __builtin_popcount

signed  main() {
  SPD_emergency



  //int t; cin >> t; int tt = 1; while (t--)
  {
   int n,m;
   cin >> n >> m;
   int a[n+10],ans = 0, i = 0;
   IN(a,m);
   for(i=0;i<m;i++){
    ans+=a[i];
   }
   ans = n-ans;
   if(ans<0)
    cout<<-1<<endl;
  else
    cout<<ans<<endl;
   
  }
  return 0;
}

Measured memory_bytes: 3728
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const int cons = 1e9 + 7;

//A
int main(void) {
	int n, k;
	cin >> n >> k;
	cout << n - k + 1;
}


Measured memory_bytes: 256
// http://abc032.contest.atcoder.jp/tasks/abc032_d

import java.util.*;
 
public class Main {
    
	public static void main(String[] args) {
 
	Scanner sc  = new Scanner(System.in);
        


    int N  = Integer.parseInt(sc.next());
    int W  = Integer.parseInt(sc.next());
    String[][] map = new String[N+1][W+1];

    for(int i=0;i<N;i++){
        
        String s = sc.next();
        char[] c1 = s.toCharArray();
        
        for(int k=0;k<W;k++){
            
        map[i][k] =  String.valueOf(c1[k]);
        
        }
    }
    
      for(int i=0;i<N;i++){
        for(int k=0;k<W;k++){
            
            System.out.print(map[i][k]);

        }
        System.out.println();
        
         for(int j=0;j<W;j++){
            
            System.out.print(map[i][j]);

        }
        System.out.println();
    }


    //    System.out.print(ans);
        System.out.println();
	}
	  static 	public void mapDebug(String[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}
        
}

Measured memory_bytes: 15216
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())

    s = [input() for _ in range(n)]

    ss = set(s)

    print(len(ss))


if __name__ == '__main__':
    main()


Measured memory_bytes: 107488
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            long N = in.nextLong();
            long K = in.nextLong();
            long min = (N + K) % K;
            min = Math.min(min, Math.abs(min - K));
            out.println(min);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

    }
}



Measured memory_bytes: 21460
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sqr(x) (x) * (x)

using namespace std;
using namespace __gnu_pbds;

mt19937_64 gen(time(0));

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//const int mod = 1e9 + 7;

//const int inf = 1e9;
//const int maxn = 1e6 + 66;

int a[1002];

signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif
    ll n;
    cin >> n;
    string s;
    while(n > 0)
    {
        if (n % 26 == 0)
        {
            s += 'z';
            n -= 26;
        }
            else s += char('a' + (n % 26 - 1));
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s;
    return 0;
}


Measured memory_bytes: 3656
package main

import (
  "fmt"
)

func logic(k int, a int, b int) uint64 {
  if (b - a <= 2) {
    return uint64(k + 1)
  }
  turn := k - (a - 1)
  rest := turn - ((turn / 2) * 2)
  return uint64(a + (turn / 2 * (b - a)) + rest)
}

func main() {
  var k, a, b int
  fmt.Scan(&k)
  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Println(logic(k, a, b))
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 100000;

#define FILENAME ""
               
int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //	freopen(FILENAME ".in", "r", stdin);
    //	freopen(FILENAME ".out", "w", stdout);
   	string s;
   	cin >> s;
   	for (int i = 0; i < s.size() - 1; i++) {
   	 	if (s[i] == s[i + 1]) {
   	 	 	re cout << "Bad", 0;
   	 	}
   	}
   	cout << "Good";
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

def append(m, printed, cand_a, cand_b, cand_c):
    key = "{}-{}-{}".format(cand_a, cand_b, cand_c)
    key2 = "{}-{}-{}".format(cand_a-1, cand_b, cand_c)
    key3 = "{}-{}-{}".format(cand_a, cand_b-1, cand_c)
    key4 = "{}-{}-{}".format(cand_a, cand_b, cand_c-1)
    if not key in printed \
            and cand_a < len(A) \
            and cand_b < len(B) \
            and cand_c < len(C) \
            and not key in m \
            and not key2 in m \
            and not key3 in m \
            and not key4 in m :
#       print("Appended {}".format(key))
        m[key] = A[cand_a] + B[cand_b] + C[cand_c]
    return m

X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

a = 0
b = 0
c = 0

n_print = 0
#print(A, B, C)
memo = {}
printed = defaultdict(lambda: False)
while True:
    summ = A[a] + B[b] + C[c]
    printed["{}-{}-{}".format(a, b, c)] = True

    print(summ)

#   print(memo.items())
#   print(a, b, c)
#   print("")

    n_print += 1
    if n_print == K:
        break

    memo = append(memo, printed, a+1, b, c)
    memo = append(memo, printed, a, b+1, c)
    memo = append(memo, printed, a, b, c+1)

    max_k = max(memo, key=memo.get)
    a, b, c = max_k.split("-")
    a = int(a)
    b = int(b)
    c = int(c)
        
    memo.pop(max_k)
#   print("Pop {}".format(max_k))


Measured memory_bytes: 4568
#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 if (a == b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        ArrayList<Integer> D = new ArrayList<Integer>();
        for(int i=0; i<K; i++){
            int tmp = sc.nextInt();
            D.add(tmp);
        }
        int M = N;
        while(true){
            if(f(M,D))break;
            M++;
        }
        System.out.println(M);
    }
    static boolean f(int N, ArrayList<Integer> D){
        String S = String.valueOf(N);
        for(int i=0; i<S.length(); i++){
            int tmp = S.charAt(i)-'0';
            if(D.contains(tmp)){
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 15408
use std::io::Read;

fn main() {
    let inputstr = {
        let mut inputstr = String::new();
        std::io::stdin().read_to_string(&mut inputstr).unwrap();
        inputstr
    };
    let mut inputiter= inputstr.split_whitespace();
    let a =  inputiter.next().unwrap().parse::<usize>().unwrap();
    let s =  inputiter.next().unwrap();
    let print_string = if a >= 3200{
        s
    }else{
        "red"
    };
    println!("{}",print_string);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S;
    cin >> S;
    sort( ALL( S ) );
    cout << (  S == "abc" ? "Yes" : "No" )  << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000009
#define MK make_pair
#define EB emplace_back
#define PB push_back
#define F first
#define S second
using namespace std;
int main()
{
	
	ll a;
	long double b;
	cin>>a>>b;
	b=a*b;
	cout<<(ll)b<<endl;
	return 0;
}

Measured memory_bytes: 3656