akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


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

    ll N, K ;
    cin >> N >> K ;

    vector<ll> h;
    rep(i,N){
        ll inp;
        cin >> inp;
        h.pb(inp);
    }

    sort(all(h));

    ll l = 0;
    ll r = K-1;

    ll ans = 1000000000 ;
    while(r != N){

        ans = min(ans, h[r] - h[l]);
        l ++;
        r ++;
    }

    cout << ans << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let r = input::<i64>();
    println!(
        "{}",
        if r < 1200 {
            "ABC"
        } else if r < 2800 {
            "ARC"
        } else {
            "AGC"
        }
    );
}


Measured memory_bytes: 4352
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		String S = sc.next();
		int min = 1000;
		for(int i = 0; i + 2 <= S.length()-1; i++){
			int s = Integer.parseInt(S.substring(i, i+3));
			min = Math.min(min, Math.abs(s-753));
		}
		System.out.println(min);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


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

int ei[4] = {-1,0,1,0};
int ej[4] = {0,-1,0,1};

int main(){
  int h,w;
  cin >> h >> w;
  string s[h];
  rep(i,h) cin >> s[i];
  
  int ans=0;
  
  rep(si,h){
    rep(sj,w){
      if(s[si][sj]=='#') continue;
      
      vector<vector<int>> dist(h, vector<int>(w, 100));
      
      queue<pair<int,int>> q;
      
      auto update = [&](int i, int j, int x){
        if(dist[i][j] != 100) return;
        
        dist[i][j] = x;
        q.push(pair<int,int>(i,j));
      };
      
      update(si, sj, 0);
      
      while(!q.empty()){
        int i = q.front().first;
        int j = q.front().second;
        q.pop();
        
        rep(k,4){
          int ni = i+ei[k], nj = j+ej[k];
          if(ni<0 || ni>=h || nj<0 || nj>=w) continue;
          if(s[ni][nj]=='#') continue;
          update(ni, nj, dist[i][j]+1);
        }
      }
      
      rep(i,h){
        rep(j,w){
          if(dist[i][j] == 100) continue;
          if(dist[i][j] > ans) ans = dist[i][j];
        }
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int K, N;
  cin >> K >> N;
  VEC<LL> A(N);
  REP(i, 0, N) cin >> A[i];
  VEC<LL> D(N);
  D[0] = abs(A[0] + K-A[N - 1]);
  REP(i, 1, N) { D[i] = A[i] - A[i - 1]; }
  // DUMP(D);
  LL ma= 0;
  REP(i,0,N){
    ma=max(ma, D[i]);
  }
  cout<<K-ma<<endl;

  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int N,R;
    cin >> N >> R;

    if(N < 10){
        cout << R + 100 * (10 - N) << endl;
    }else{
        cout << R << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
 ll L;
  ll R;
  cin >>L>>R;
if(R-L>=2018) {
  cout<<0<<endl;
}
  else {
    ll mini=(L%2019)*((L+1)%2019);
    repl(i,L,R) {
      repl(j,i+1,R+1) {
        ll a=i%2019;
        ll b=j%2019;
        ll c=(a*b)%2019;
       mini=min(mini,c);
      }
    }
    cout<<mini<<endl;
  }
  
  
}

    


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


int main()
{
	int n; cin >> n;
	float res;
	if (n & 1) {
		res = (float)(n / 2 + 1) / n;
	}
	else {
		res =   (float)(n / 2) / n;
	}
	cout << setprecision(6) <<res << endl;
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

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

  if ((k - a) < 0) {
    a = abs(k - a);
    k = 0;
  } else {
    k -= a;
    a = 0;
  }
  b = max(ll(0), b - k);

  cout << a << " " << b << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    N = 10
    for line in readlines():
        *L, v1, v2 = map(int, line.split(","))
        LS = sum(L)
        vs = v1 + v2
        s = 0
        for i in range(N):
            l = L[i]
            if s * vs <= v1 * LS <= (s + l) * vs:
                write("%d\n" % (i+1))
                break
            s += l
solve()



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

using namespace std;

#define lli long long int

lli b[3005][3005];
char  c[3005][3005];
string s;
string x,y;

void lcs()
{
    int n=x.size();
    int m=y.size();
    for(int i=0;i<n;i++)
    {
        b[i][0]=0;
    }
    for(int i=0;i<m;i++)
    {
        b[0][i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(x[i-1]==y[j-1])
            {
                b[i][j]=b[i-1][j-1]+1;
                c[i][j]='c';
            }
            else if(b[i-1][j]>b[i][j-1])
            {
                b[i][j]=b[i-1][j];
                c[i][j]='u';
            }
            else
            {
                b[i][j]=b[i][j-1];
                c[i][j]='l';
            }
        }
    }
}

void print(int n,int m)
{
    if(n==0 or m==0)
        return;
    else if(c[n][m]=='c')
    {
        print(n-1,m-1);
        s+=x[n-1];
    }
    else if(c[n][m]=='u')
    {
        print(n-1,m);
    }
    else if(c[n][m]=='l')
    {
        print(n,m-1);
    }
}

int main()
{
    cin>>x>>y;
    lcs();
    print(x.size(),y.size());
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 79616
N,K=map(int,input().split())
Dlist=list(map(int,input().split()))
flag=True
i=0
while flag:
    ans=str(i)
    num=0
    if i>=N:
        
        for j in range(len(ans)):
            if int(ans[j]) not in Dlist:
                num+=1
            if num==len(ans):
                print(i)
                flag=False
    i+=1

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

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



int main() {
    string s;
    cin >> s;
    int n = s.size();

    int cnt[26] = {0};
    for (auto&& c : s) cnt[c - 'a']++;

    for (char c = 'a'; c <= 'z'; c++) {
        if (cnt[c - 'a'] < 2) continue;
        vector<int> pos;
        rep(i, n) if (s[i] == c) pos.push_back(i + 1);
        rep(i, pos.size() - 1) {
            if (pos[i + 1] - pos[i] <= 2) {
                cout << pos[i] << " " << pos[i + 1] << endl;
                return 0;
            }
        }
    }
    
    cout << -1 << " " << -1 << endl;

    return 0;
}

Measured memory_bytes: 816
#include <vector>
#include <set>
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;

using vector2D = vector< vector<int> >;
const int B = 5;
int N;

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

struct State {
  vector2D board;
  int x, y;
};

vector<int> score;
long long int solve(vector2D board) {
  long long int ret = 0, bonus = 1;
  for(; ; bonus++) {
    bool update = false;
    vector2D checked(B, vector<int>(B));
    
    for(int i=0; i<B; i++) {
      for(int j=0; j<B; j++) {
        // empty
        if(board[i][j] == 0) continue;

        vector<int> dirs = {2, 0};
        for(auto k : dirs) {
          // right or down
          int cons = 0;
          int nx = i, ny = j;
          while(nx < B && ny < B) {
            if(board[nx][ny] != board[i][j]) break;
            cons++;
            nx += dx[k], ny += dy[k];
          }
          if(cons >= 3) {
            update = true;
            nx = i, ny = j;
            while(nx < B && ny < B) {
              if(board[nx][ny] != board[i][j]) break;
              checked[nx][ny] = 1;
              nx += dx[k], ny += dy[k];
            }
          }
        }
      }
    }
    // printf("bonus = %lld, update = %d\n", bonus, update);
    if(!update) break;

    for(int i=0; i<B; i++) {
      for(int j=0; j<B; j++) {
        // empty or no change
        if(board[i][j] == 0 || checked[i][j] == false) continue;

        int col = board[i][j] - 1;
        board[i][j] = 0;
        ret += bonus * score[col];
      }
    }

    // blockfall
    for(int i=B-1; i>=0; i--) {
      for(int j=0; j<B; j++) {
        int row = i;
        for(; row < B-1 && board[row+1][j] == 0; row++) {
          swap(board[row][j], board[row+1][j]);
        }
      }
    }
  }
  
  return ret;
}

int main() {
  while(cin >> N, N >= 0) {
    vector2D board(B, vector<int>(B));
    for(int i=0; i<B; i++) {
      for(int j=0; j<B; j++) {
        cin >> board[i][j];
      }
    }
    score.clear();
    for(int i=0; i<B; i++) {
      int val; cin >> val;
      score.push_back(val);
    }

    set<vector2D> cand;
    cand.insert(board);
    queue<State> que;
    for(int i=0; i<B; i++) {
      for(int j=0; j<B; j++) {
        que.push(State{board, i, j});
      }
    }

    // printf("enumerate begin\n");
    for(int i=0; i<N; i++) {
      queue<State> nxt;
      while(que.size()) {
        State cur = que.front(); que.pop();
        vector2D board = cur.board;
        int x = cur.x, y = cur.y;

        for(int k=0; k<4; k++) {
          int nx = x + dx[k], ny = y + dy[k];
          if(nx < 0 || nx >= B || ny < 0 || ny >= B) continue;
          swap(board[x][y], board[nx][ny]);
          nxt.push(State{board, nx, ny});
          cand.insert(board);
          swap(board[x][y], board[nx][ny]);
        }
      }
      swap(nxt, que);
    }
    // printf("enumerate end\n");

    long long int ans = 0;
    for(auto b : cand) {
      ans = max(ans, solve(b));
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 7488
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define __int64 long long
const ll M=1000000007;
ll n,k;
int a[111111];
int b[111111];
ll cnt[111111];
int main(){
	cin>>n>>k;
	rep(i,n)cin>>a[i]>>b[i];
	rep(i,n)cnt[a[i]]+=b[i];
	ll sum=0;

	for(int i=1;i<=111111;i++){
		sum+=cnt[i];
		if(sum>=k){cout<<i<<endl;return 0;}
	}
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = -1;
        for (int i = 1; i < 15000; i++) {
            int x = (int)(i * 0.08);
            int y = (int)(i * 0.10);
            if(x == a && y == b){
                ans = i;
                break;
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


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

int main()
{
    long long X;
    cin >> X;

    long long a = 100;
    for (int i = 1; ; i++) {
        a *= 1.01;
        if (a >= X) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include <stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define NIL -6
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

int prim() {
	int i;
	int sum;
	int u, v, minv;
	int d[MAX], p[MAX], color[MAX];

	for ( i = 0; i < n; i++) {
		d[i] = INFTY;
		p[i] = NIL;
		color[i] = WHITE;
	}

	d[0] = 0;

	while ( 1 ) {
		minv = INFTY;
		u = NIL;
		for ( i = 0; i < n; i++) {
			if ( minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == NIL) break;
		color[u] = BLACK;
		for (v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != INFTY) {
				if (d[v] > M[u][v]) {
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}

	sum = 0;
	for ( i = 0; i < n; i++) {
		if (p[i] != NIL) sum += M[i][p[i]];
	}

	return sum;
}

int main() {
	int e;
	int i, j;

	scanf("%d",&n);
	for ( i = 0; i < n; i++) {
		for ( j = 0; j < n; j++) {
			scanf("%d",&e);
			M[i][j] = (e == -1) ? INFTY : e;
		}
	}

	printf("%d\n",prim());

	return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

// ====================================================================

int main() {
  int d, l;
  cin >> d >> l;
  vector<int> dp(d + 1);
  for (int i = 0; i <= d; i++) dp[i] = INF;
  dp[0] = 0;
  for (int i = 0; i < d; i++) {
    if (i + l <= d)
      dp[i + l] = min(dp[i + l], dp[i] + 1);
    dp[i + 1] = min(dp[i + 1], dp[i] + 1);
  }
  cout << dp[d] << endl;
  // cout << dp << endl;
}



Measured memory_bytes: 3092
using namespace std;
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>

int main() {
	
	int n;
	cin>>n;
	string str[n],temp;
	for (int i = 0; i < n; ++i)
	{
		/* code */
		cin>>str[i];
		sort(str[i].begin(),str[i].end());
	}

	sort(str,str+n);
	long ans = 0;
	long len = 1;
	for (int i = 1; i < n; ++i)
	{
		if(str[i].compare(str[i-1])==0){
			len++;
		}else{
			ans += (len*(len-1))/2;
			len = 1;
		}
	}
	ans += (len*(len-1))/2;
	cout<<ans;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pdd = pair<double, double>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int N, K;
double x[60], y[60], c[60], r[60];

double dist(const pdd &a, const pdd &b) {
	double xx = a.X - b.X;
	double yy = a.Y - b.Y;
	return sqrt(xx * xx + yy * yy);
}
vector<pair<double, double>> inter(int a, int b) {
	vector<pair<double, double>> ret;
	double d = dist(pdd(x[a], y[a]), pdd(x[b], y[b]));

	if (r[a] + r[b] < d) return ret;
	if (x[a] == x[b] && y[a] == y[b] || d < abs(r[a] - r[b])) return { { x[a], y[a] } };

	double tmp = (r[a] * r[a] - r[b] * r[b] + d * d) / (2 * d);
	double h = sqrt(r[a] * r[a] - tmp * tmp);

	double xx = x[a] + tmp / d * (x[b] - x[a]);
	double yy = y[a] + tmp / d * (y[b] - y[a]);

	ret.emplace_back(xx + h * (y[b] - y[a]) / d, yy - h * (x[b] - x[a]) / d);
	ret.emplace_back(xx - h * (y[b] - y[a]) / d, yy + h * (x[b] - x[a]) / d);

	return ret;
}
int check(double t) {
	for (int i = 0; i < N; ++i) r[i] = t / c[i];

	int ret = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			auto pts = inter(i, j);
			for (auto &p : pts) {
				int cnt = 0;
				for (int k = 0; k < N; ++k)
					if (dist(p, pdd(x[k], y[k])) <= r[k] + 1e-9) ++cnt;
				ret = max(ret, cnt);
			}
		}
	}

	return ret;
}
int main() {
	fastio;
	cin >> N >> K;
	for (int i = 0; i < N; ++i) cin >> x[i] >> y[i] >> c[i];

	double s = 0, e = 1e10;
	while (s < e - 1e-9) {
		double m = (s + e) / 2.0;
		
		if (check(m) < K) s = m;
		else e = m;
	}

	cout << fixed << setprecision(9) << (s + e) / 2.0;

	return 0;
}

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

int dp[4001][16001];
int ax[4001];
int ay[4001];
int tx,ty;

void dfsx(int n,int m){
	if(dp[n][m+8000]) return;
	
	if(n<tx){
		dfsx(n+1,m-ax[n]);
		dfsx(n+1,m+ax[n]);
	}
	
	dp[n][m+8000]=1;
}

void dfsy(int n,int m){
	if(dp[n][m+8000]) return;
	
	if(n<ty){
		dfsy(n+1,m-ay[n]);
		dfsy(n+1,m+ay[n]);
	}
	
	dp[n][m+8000]=1;
}

int main()
{
	string s;
	int x,y;
	cin>>s>>x>>y;
	
	int dir=1;
	
	for(int i=0;i<s.size();i++){
		if(s[i]=='F'){
			if(dir) ax[tx]++; 
			else ay[ty]++;
		}
		else if(s[i]=='T'){
			if(dir) dir=0,tx++;
 			else dir=1,ty++;
		}
	}
	
	if(s[s.size()-1]=='F'){
		if(dir) tx++;
 		else ty++;
	}
	
	dfsx(1,ax[0]);
	bool xx=dp[tx][8000+x];	
	memset(dp,0,sizeof(dp));
    
    dfsy(0,0);
    bool yy=dp[ty][8000+y];
    
    if(yy && xx) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 250496
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
          Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        int A = input.nextInt();
        int B = input.nextInt();
        int train = N*A;
        if(train < B){
        	System.out.println(train);
        }else{
        	System.out.println(B);
        }
  }
}

Measured memory_bytes: 21844
fun main(args: Array<String>) {
    val (K, S) = readInputLine().split(" ").map { it.toInt() }

    var ans = 0

    for (i in 0..K) {
        for (j in 0..K) {
            if (i + j > S) {
                break
            }
            if (S - i - j <= K) {
                ans++
            }
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 36084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int a, b, c;
    cin >> a>> b >> c;
    cout << c << " " << a << " " << b << '\n';
    return 0;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  string s, t;
  cin >> s >> t;
  int n = sz(s);
  int m = sz(t);
  if(n < m) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  bool ok = false;
  per(i,n-m+1) {
    bool ok2 = true;
    rep(j,m) {
      if(s[i+j] != t[j] && s[i+j] != '?') { ok2 = false; break; }
    }
    if(ok2) {
      ok = true;
      rep(j,m) s[i+j] = t[j];
      break;
    }
  }
  if(ok) {
    rep(i,n) {
      if(s[i] == '?') cout << 'a';
      else cout << s[i];
    }
    cout << endl;
  }
  else cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 250

void Max_Heapify(int);

int main(){
int i, size;
int T[MAX];

  scanf("%d",&size);

  for(i=1; i<=size; i++){
    scanf("%d",&T[i]);
  }

  for(i=1; i<=size; i++){
    printf("node %d: key = %d, ",i,T[i]);
    if(i/2 != 0) printf("parent key = %d, ",T[i/2]);
    if(i*2 <= size) printf("left key = %d, ",T[i*2]);
    if(i*2+1 <= size) printf("right key = %d, ",T[i*2+1]);
    printf("\n");
  }
  return 0;
}




Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
 
signed main(){
	int n; cin>>n;
	
	int arr[n+1];
	for(int i=1; i<=n; i++){
		cin>>arr[i];
	}
	
	int dp[n+1];
	dp[1]=0;
	dp[2]=abs(arr[2]-arr[1]);
	
	for(int i=3; i<=n; i++){
		dp[i]=min( dp[i-1]+ abs(arr[i]-arr[i-1]), dp[i-2]+ abs(arr[i]-arr[i-2]));
	}
	
	cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1792
s = input()
t = input()
ns = len(s)
nt = len(t)

dp = [[0] * (nt + 1) for _ in range(ns + 1)]
for i in range(ns):
    for j in range(nt):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        else:
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

ans = []
i, j = ns, nt
while dp[i][j]:
    while dp[i - 1][j] == dp[i][j]:
        i -= 1
    while dp[i][j - 1] == dp[i][j]:
        j -= 1
    ans.append(s[i - 1])
    i -= 1
    j -= 1
ans.reverse()
print("".join(ans))


Measured memory_bytes: 144512
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

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

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

int gcd(int x,int y){
  if(x%y ==0)
    return y;
  else
    return gcd(y,(x%y));
}
int main()
{
  int a,b;
  cin >>a>>b;
  if(a <b)
    swap(a,b);
  cout <<gcd(a,b)<<endl;;
  return 0;
}

Measured memory_bytes: 1160
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int main()
{
    string O, E;
    
    cin >> O >> E;
    int o = O.size(), e = E.size();
    rep(i, o) {
        cout << O[i];
        if (!(o > e && i == o - 1)) cout << E[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
//08
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

int main(){
  for(double a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;){
    double x=(c*e-f*b)/(a*e-d*b);
    double y;
    if(e){
      y=(f-d*x)/e;
    }else{
      y=(c-a*x)/b;
    }
    if(fabs(x)<1e-4){
      x=0;
    }
    if(fabs(y)<1e-4){
      y=0;
    }
    cout<<fixed<<setprecision(3)<<x<<' '<<y<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int n;
int ht[200100], val[200100];
long long segtree[800100];
void update (int x, int l, int r, int p, long long v) {
	if (p < l || p > r) return;
	segtree[x] = max(segtree[x], v);
	if (l == r) return;
	int m = (l+r)/2;
	update(2*x+1, l, m, p, v);
	update(2*x+2, m+1, r, p, v);
}
long long query (int x, int l, int r, int a, int b) {
	if (r < a || b < l) return 0;
	if (a <= l && r <= b) return segtree[x];
	int m = (l+r)/2;
	return max(query(2*x+1, l, m, a, b), query(2*x+2, m+1, r, a, b));
}
int main () {
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> ht[i];
		ht[i]--;
	}
	for (int i=0; i<n; i++) {
		cin >> val[i];
	}
	long long ans = 0;
	for (int i=0; i<n; i++) {
		long long cur = query(0, 0, n-1, 0, ht[i])+val[i];
		update(0, 0, n-1, ht[i], cur);
		ans = max(ans, cur);
	}
	cout << ans << endl;
}

Measured memory_bytes: 9304
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  char str[256];
  cin.getline(str,256);
  for(char c : str){
    if(c=='\0'){putchar('\n');break;}
    if(c<'a'||c>'z'){putchar(c);}
    else{putchar(c+'A'-'a');}
  }
}

Measured memory_bytes: 1112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll L, R;
  cin >> L >> R;
  ll v = 2019;
  ll m = L + min(R - L, 2019ll);
  for (ll i = L; i < m ; i++) {
    for (ll j = i + 1; j <= m; j++) {
      ll t = (i % 2019) * (j % 2019);
      t %= 2019;
      v = min(t, v); 
    }
  }
  cout << v << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector

signed main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int arr[6];
    forn(i,1,5)cin>>arr[i];
    int k;
    cin>>k;
    forn(i,1,5)forn(j,1,5)
    {
        if(abs(arr[i]-arr[j]) > k)
        {
            
            cout<<":(";
        
            return 0;
        }
    }
    cout<<"Yay!";



     return 0;

}

//       g++ -g c.cpp ; ./a.exe

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

int main() {
    int n, b;
    char a;
    int card[4][13] = {0};
    cin >> n;
    
    for(int j=0;j<n;j++){
        cin >> a >> b;
        
        switch(a){
            case 'S' :
            card[0][b-1]++;
            break;
            case 'H' :
            card[1][b-1]++;
            break;
            case 'C' :
            card[2][b-1]++;
            break;
            case 'D' :
            card[3][b-1]++;
            break;
        }
    }
    
    for(int i=0; i<4; i++) {
        for(int j=0;j<13;j++){
            if(!card[i][j]){
            switch(i){
                case 0 :
                cout << "S" << " " << j+1 << endl;
                break;
                case 1 :
                cout << "H" << " " << j+1 << endl;
                break;
                case 2 :
                cout << "C" << " " << j+1 << endl;
                break;
                case 3 :
                cout << "D" << " " << j+1 << endl;
                break;
            }
            }
        }
    }
}


Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <bitset>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	long long  ten = 1;
	string s;
	cin >> s;
	long long res = 0;

	for(long long i = 0;i < 1 << (s.size()-1);i++){
		long long k = 0;
		ten = 1;
		for(long long  j = 1;j < 1 << (s.size());j = j << 1){
			res += atoi(s.substr(s.size()-k-1, 1).c_str()) * ten;
			ten *= 10;
			if((j & i) == j){;
				ten = 1;
			}
			k++;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
M, D = input().split()
M = int(M)

count = 0
for m in range(1, int(M + 1)):
    for d in range(1, int(D) + 1):
        d1 = int(str(d).zfill(2)[1])
        d10 = int(str(d).zfill(2)[0])
        if d1 >= 2 and d10 >= 2 and d1 * d10 == m:
            count += 1
print(count)


Measured memory_bytes: 3060
from collections  import Counter
n = int(input())
l = [int(i) for i in input().split()]
 
l1 = [l[i] for i in range(n) if i%2 ==0]
l2 = [l[i] for i in range(n) if i%2 ==1]
 
c1 = Counter(l1)
c2 = Counter(l2)
 
even1 = c1.most_common()[0][1]
even2 = c1.most_common()[1][1] if len(c1) > 1 else 0
odd1 = c2.most_common()[0][1]
odd2 = c2.most_common()[1][1] if len(c2) > 1 else 0

if c1.most_common()[0][0] == c2.most_common()[0][0]:
    ans = min((n - even1 - odd2),(n - odd1 - even2))
else:
    ans = (n//2 - even1) + (n//2 - odd1)
    
print(ans)

Measured memory_bytes: 19040
def levenshtein(str1, str2):
    l1, l2 = len(str1), len(str2)
    dp = [list(range(l2 + 1))] + [[i + 1] + [0] * l2 for i in range(l1)]

    for i1, c1 in enumerate(str1):
        for i2, c2 in enumerate(str2):
            dp[i1 + 1][i2 + 1] = min(dp[i1][i2 + 1] + 1, dp[i1 + 1][i2] + 1, dp[i1][i2] + int(c1 != c2))

    return dp[l1][l2]


print(levenshtein(input(), input()))

Measured memory_bytes: 44852
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

N, K = map(int, input().split())
A = list(map(int, input().split()))
if max(A) < K:
    print('IMPOSSIBLE')
    exit()
res = A[0]
for i in range(1, N):
    a = A[i]
    b = res
    if a < b:
        a, b = b, a
    res = gcd(a, b)
if K % res == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n;
int a[20], x[20][20], y[20][20];
void solve() {
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        rep(j, a[i]) {
            cin >> x[i][j] >> y[i][j];
            --x[i][j];
        }
    }

    int e = 1 << n;
    int ans = 0;
    rep(s, e) {
        bool ok = false;
        rep(i, n) rep(j, a[i]) {
            if (((s >> i) & 1) == 1 && ((s >> x[i][j]) & 1) != y[i][j]) { ok = true; break; }
        }
        if (ok) continue;

        int res = 0;
        rep(i, n) if (((s >> i) & 1) == 1) ++res;
        maxs(ans, res);
    }

    cout << ans << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    in1(N);

    vll x(N), y(N), h(N);
    rep(i, N) in3(x[i], y[i], h[i]);

    int nonzero = -1;
    rep(i, N)
    {
        if (h[i] != 0)
        {
            nonzero = i;
            break;
        }
    }

    repse(cx, 0, 100)
    {
        repse(cy, 0, 100)
        {
            ll H = h[nonzero] + abs(x[nonzero] - cx) + abs(y[nonzero] - cy);

            bool flg = true;

            rep(i, N)
            {
                ll tmp = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0LL);

                if (tmp != h[i])
                {
                    flg = false;
                    break;
                }
            }

            if (flg)
            {
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }

    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;



ll h,w; 

char maze[30][30];
ll dist[30][30];
ll dx[4] = {0,1,0,-1};
ll dy[4] = {1,0,-1,0};

ll bfs(ll sx, ll sy){
    if (maze[sx][sy] == '#') return 0;

    REP(i, 30) REP(j,30) dist[i][j] = -1;
    dist[sx][sy] = 0;

    queue<P> que;
    que.push(P(sx,sy));
    
    while(que.size()){
        auto p = que.front();
        que.pop();

        REP(i,4){
            ll nx = p.first + dx[i], ny = p.second + dy[i];
            if(nx >= 0 && ny >= 0 && nx < h && ny < w &&
            dist[nx][ny] == -1 && maze[nx][ny] != '#'){
                que.push(P(nx,ny));
                dist[nx][ny] = dist[p.first][p.second] + 1;
            }
        }
    }
    ll ret = 0;
    REP(i,h) REP(j,w) ret = max(ret, dist[i][j]);
    // cout << ret << endl;
    return ret;
}

int main(){
	cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> h >> w;
    REP(i,h) REP(j,w) cin >> maze[i][j];

    ll ans = 0;
    REP(i,h){
        REP(j,w){
            ans = max(bfs(i,j), ans);
        }
    }

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



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

#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define forup(i,l,r) for (register int i = l ; i <= r ; i += lowbit(i))
#define fordown(i,id) for (register int i = id ; i ; i -= lowbit(i))
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define lowbit(x) (x&(-x))

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pr;

const ll MAX = 2e18;
const ld inf = 2e18;
const int maxn = 220;
const ll mod = 1e9 + 7;

inline ll power(ll x,ll y){
	y = ((y % (mod - 1)) + (mod - 1)) % (mod - 1);
//	if ( y < 0 ) return power(power(x,-y),mod - 2);
	ll res = 1;
	while ( y ){
		if ( y & 1 ) res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int a[maxn],n,odd[maxn],even[maxn],cnt1,cnt2;
set <int> s;
namespace Prime{
	const int N = 1e7;
	int prime[N + 20],tag[N + 20],mn[N + 20],Cnt;	
	void init (){
		tag[1] = 1;
		rep(i,2,N){
			if ( !tag[i] ) prime[++Cnt] = i;
			rep(j,1,Cnt){
				if ( prime[j] * i > N ) break;
				tag[i * prime[j]] = 1;
				mn[i * prime[j]] = prime[j];
				if ( i % prime[j] == 0 ) break;
			}
		}
	}
}
using namespace Prime;

struct node{
	int next,to;
}e[maxn * maxn];
int head[maxn],cnt;
int from[maxn],use[maxn],tot;

inline void adde(int x,int y){
	e[++cnt].to = y;
	e[cnt].next = head[x];
	head[x] = cnt;
}
bool match(int x){
	fore(i,x){
		if ( !use[e[i].to] ){
			use[e[i].to] = 1;
			if ( from[e[i].to] == -1 || match(from[e[i].to]) ){
				from[e[i].to] = x;
				return 1;
			}
		}
	}
	return 0;
}
void hungary(){
	tot = 0;
	memset(from,-1,sizeof(from));
	n = cnt1;
	rep(i,1,n){
		memset(use,0,sizeof(use));
		if ( match(i) ) ++tot;
	}
}


int main(){
	init();
	scanf("%d",&n);
	rep(i,1,n){
	   	scanf("%d",&a[i]);
		if ( s.find(a[i]) == s.end() ) s.insert(a[i]);
		else s.erase(a[i]);

		if ( s.find(a[i] + 1) == s.end() ) s.insert(a[i] + 1);
		else s.erase(a[i] + 1);
	}
	for (auto it = s.begin() ; it != s.end() ; ++it){
		int x = *it;
		if ( x & 1 ) odd[++cnt1] = x;
		else even[++cnt2] = x;
	}
	rep(i,1,cnt1){
		rep(j,1,cnt2){
			int c = abs(odd[i] - even[j]);
			if ( !tag[c] ) adde(i,j + cnt1);
		}
	}
	hungary();
	cout<<cnt1 + cnt2 - tot + ((cnt1 - tot) & 1)<<endl;
}



Measured memory_bytes: 81920
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    int a,b,c;
    cin>>a>>b>>c;
    string ans = "No";
    if(a+b>=c)ans = "Yes";
    cout<<ans<<endl;
    
    
    return 0;
}

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

int main(void){
	string n;
	cin >> n;
	for(int index = 0; index < n.size(); index++){
		if(n[index] == '1') cout << '9';
		if(n[index] == '9') cout << '1';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby                                                                                                                                   
# -*- coding: utf-8 -*-                                                                                                                           

a = 0; b = 0; o = 0; ab = 0;
while s = gets
  btype = (s.chomp.split(','))[1]
  if btype == "A"
    a += 1
  elsif btype == "B"
    b += 1
  elsif btype == "O"
    o += 1
  else
    ab += 1
  end
end
puts a
puts b
puts ab
puts o

Measured memory_bytes: 6096
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {

	int n, a[200100] = {}, serch = 1,ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] == serch) { serch++; }
		else { ans++; }
	}

	if (serch == 1) { cout << "-1" << endl; }
	else { cout << ans << endl; }

	return 0;
}

Measured memory_bytes: 1024