akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void run(int C[][]) {
        int r[] = new int[3];

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                int d = C[i][j] - C[i][j == 2 ? 0 : j + 1];
                if (i == 0) {
                    r[j] = d;
                } else if (d != r[j]) {
                    System.out.println("No");
                    return;
                }
            }
        }

        for (int j = 0; j < 3; j++) {
            for (int i = 0; i < 3; i++) {
                int d = C[i][j] - C[i == 2 ? 0 : i + 1][j];
                if (j == 0) {
                    r[i] = d;
                } else if (d != r[i]) {
                    System.out.println("No");
                    return;
                }
            }
        }

        System.out.println("Yes");
    }

    public static void runInput() {
        Scanner scanner = new Scanner(System.in);

        int C[][] = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                C[i][j] = scanner.nextInt();
            }
        }

        run(C);
    }

    public static void main(String args[]) {
        runInput();

    }
}


Measured memory_bytes: 21972
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct List {
  int num;
  struct List *before;
  struct List *next;
};

struct List l;

void insert(int key) {
  struct List *a = malloc(sizeof(struct List));
  a->num = key;
  a->before = &l;
  a->next = l.next;
  l.next = a;
  a->next->before = a;
}

void delete(int b) {
  struct List *c;
  c = l.next;
  while(c->num != -1) {
    if (c->num == b) {
      c->next->before = c->before;
      c->before->next = c->next;
      break;
    }  
    c = c->next;
  } 
  }

void delete_First() {
  l.next = l.next->next;
  l.next->before = &l;
}

void delete_Last() {
  l.before = l.before->before;
  l.before->next = &l;
}

int main(void) {
  int n;
  char command[12];
  int key;
  int adress = 1;
  struct List *box;
  l.num = -1;
  l.before = &l;
  l.next = &l;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", command);
    if (strcmp(command, "deleteFirst") == 0)
      delete_First();
    else if (strcmp(command, "deleteLast") == 0)
      delete_Last();
    else {
      scanf("%d", &key);
      if (strcmp(command, "insert") == 0) 
	insert(key);
      else if (strcmp(command, "delete") == 0)
	delete(key);
      }
    }
 
  
  box = l.next;
  while(box->num != -1) {
    printf("%d", box->num);
    box = box->next;
    if (box->num != -1)
      printf(" ");
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 36088
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
 
 
int main()
{
  	int N;
	cin >> N;
	vector <float> v(N);
	float answer;
	rep (i,N){
		cin >> v.at(i);
	}
	sort(v.begin(), v.end());
	answer = v[0];
	for (int i=1;i<N;i++){
		answer = (answer + v[i])/2;
	}
	cout << std::setprecision(10) << answer << endl;
	return 0;
}

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

using namespace std;

int main() {
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    if(abs(a-c) <=d) {
        cout << "Yes" << endl;
    } else if(abs(a-b) <= d && abs(b-c) <= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void checkNum(int a, int b){
    int sum = a + b;
    if(sum % 2 == 0){
        printf("%d\n", sum / 2);
    }else {
        printf("IMPOSSIBLE");
    }
}

int main(){
    int a;
    int b;
    scanf("%d %d", &a, &b);
    checkNum(a, b);
    return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while((a != 0) && (c != 0)){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N, M;
    cin >> N >> M;
    scc_graph graph(N);
    rep(i, M){
      ll a, b;
      cin >> a >> b;
      graph.add_edge(a, b);
    }
    vector<vector<int>> ans = graph.scc();
    cout << sz(ans) << endl;
    rep(i, sz(ans)){
      cout << sz(ans.at(i)) << " ";
      rep(j, sz(ans.at(i))-1){
        cout << ans.at(i).at(j) << " ";
      }
      cout << ans.at(i).at(sz(ans.at(i))-1) << endl;
    }
}

Measured memory_bytes: 40096
N, K = map(int, input().split())

if K % 2 == 0:
    ns1 = [i for i in range(1, N+1) if i % K == 0]
    ns2 = [i for i in range(1, N+1) if i % K == K//2]
    print(len(ns1)**3 + len(ns2)**3)
else:
    ns = [i for i in range(1, N+1) if i % K == 0]
    print(len(ns)**3)

Measured memory_bytes: 11016
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	while(true){
		int A=in();
		char OP=in<char>();
		int B=in();
		if(OP=='?') break;

		switch(OP){
		case '+':
			out(A+B);
			break;
		case '-':
			out(A-B);
			break;
		case '*':
			out(A*B);
			break;
		default:
			out(A/B);
		}
	}
	return 0;
}



Measured memory_bytes: 3108
def solve(depends, items, name)
  depend = depends[name]
  return items[name] if depend.nil?
  [depend.map {
     |dep_name| solve(depends, items, dep_name)
   }.reduce(&:+),
   items[name]].min
end
loop do
  items = {}
  n = gets.to_i
  break if n == 0
  n.times do 
    name, price = gets.split(" ")
    items[name] = price.to_i
  end
  depends = {}
  gets.to_i.times do
    v = gets.split(" ")
    depends[v[0]] = v[2..-1]
  end
  name = gets.strip
  puts solve(depends, items, name)
end

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

int main(){
    ll n,k;
    cin >> n >> k;
    int amax = 100000;
    ll count[amax+1] = {};
    for(int i = 0; i < n ; i++){
        int a,b;
        cin >> a >> b;
        count[a] += b;
    }

    for(int ans = 1; ans <= amax; ans++){
        if(k <= count[ans]){
            cout << ans << endl;
            break;
        }
        k -= count[ans];
    }

    return 0;
}

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

bool *vis, *col;
vector< pair<int,bool> > *adj;

void dfs(int v, bool c){
    if(vis[v]) return;
    vis[v] = 1;
    col[v] = c;
    for(auto& u : adj[v]){
        dfs(u.first, u.second ? c : !c);
    }
}
 
int main(){
    int n, a, b, c;
    cin >> n;
    vis = new bool[n];
    col = new bool[n];
    adj = new vector< pair<int,bool> >[n];
    for(int i = 0; i < n-1; i++){
        cin >> a >> b >> c;
        a--; b--;
        adj[a].push_back({ b, c % 2 == 0 });
        adj[b].push_back({ a, c % 2 == 0 });
        vis[i] = 0;
    }
    vis[n-1] = 0;
    dfs(0, 0);
    for(int i = 0; i < n; i++){
        cout << col[i] << '\n';
    }
}


Measured memory_bytes: 8064
#include <algorithm>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define ll long long

using namespace std;

class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll r, g, b;
        in >> r >> g >> b;
        ll ans = 100 * r + 10 * g + b;
        out << (ans % 4 == 0 ? "YES" : "NO") << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義(使うときはINFも書き換えろ!!)
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int n;cin>>n;
  vint a(n);vin(a);
  rep(i,n){
    if(a[i]%2==0){
      if(a[i]%3==0||a[i]%5==0){
        continue;
      }else{
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const string K = "keyence";
    string s; cin >> s;

    auto pos = s.find(K);
    if (pos != string::npos) {
        CFYN(true)
        return 0;
    } else {
        FOR(i,1,K.size()-1) {
            bool ok = true;
            REP(j,i) {
                if (s[j] != K[j]) ok = false;
            }
            REP(j,K.size()-i-1) {
                if (s[s.size()-j-1] != K[K.size()-j-1]) ok = false;
            }
            if (ok) {
                CFYN(true)
                return 0;
            }
        }
    }

    CFYN(false)

    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        r: f64,
    }
    println!("{}", 2.0*3.141592*r)

}


Measured memory_bytes: 2176
#include<bits/stdc++.h> 
//compiling code: g++ test.cpp(file) -o script(output) -std=c++11(version) -O2(make it 2x faster)
using namespace std;

string S;
stack<char> A, B;

int main(){
    cin >> S;
    for(int i=0; i<S.length(); i++){
        if (S[i] == '0' || S[i] == '1'){
            A.push(S[i]);
        } else if (!A.empty()){
            A.pop();
        }
    }

    while(!A.empty()){
        B.push(A.top());
        A.pop();
    }

    while(!B.empty()){
        cout << B.top();
        B.pop();
    }
    

    return 0;
}

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

typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector< ll > as;
  ll all_sum = 0;
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    all_sum += a;
    as.push_back(all_sum);
  }
  ll ans = LLONG_MAX;
  for (int i = 0; i < N-1; i++) {
    ans = min(ans, abs(2*as[i] - all_sum));
  }
  cout << ans << endl;
}

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

int main(){
  int N;
  float M;
  cin>>N>>M;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int sum = 0;
  int num_popular = 0;
  for(int i=0;i<N;i++){
    sum += A.at(i);
  }
  for(int i=0;i<N;i++){
    if(A.at(i) >= (sum/(4*M))){
      num_popular++;
    }
  }
  if(num_popular >= M){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
    

Measured memory_bytes: 384
#define    ll           long long
#define    dn           double
#define    mp           make_pair
#define    pb           push_back
#define    se           second
#define    fi           first
#define    mod          1000000007
#define    sob(v)       v.begin(),v.end()
#define    sobr(v)      v.rbegin(),v.rend()
#define    fr(i,a,b)    for(int i=a;i<=b;++i)
#define    frr(i,a,b)   for(int i=a;i>=b;--i)
#define    pi           acos(-1.00)
#define    inf          1e9
#define    check        cout<<"*"<<endl
#define    ffix(x)      cout<<fixed<<setprecision(x)
#define    fast         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#include<bits/stdc++.h>
#include<string.h>
using namespace std;

typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
///typedef pair<int,vi> pp;

int dr[8]= {0,0,-1,1,-1,-1,+1,+1};
int dc[8]= {-1,1,0,0,-1,+1,-1,+1};

const int N=1000005;
int lp[N+1];
vector<int> pr;
void sieve()
{
    for (int i=2; i<=N; ++i)
    {
        if (lp[i] == 0)
        {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}
int main()
{
    int n;
    cin>>n;
    ll cnt=0;
    sieve();
    fr(i,2,n-1)
    {
        int x=i;
        int cc=0;
        ll div=1LL;
        while(1)
        {
            int y=lp[x];
            cc=0;
            while(x%y==0)
            {
                cc++;
                x/=y;
            }
            div*=(cc+1);
            cc=0;
            if(x==1)break;
        }
        int xx=sqrt(i);
        cnt+=(div);
    }
    cnt++;
    cout<<cnt<<endl;
}


Measured memory_bytes: 7792
#include <bits/stdc++.h>
#define fi first
#define se second
#define maxn 300005
#define mod 1000000007
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;

int n,m,ans;
bool mark[maxn];
vector<int> adj[maxn];

void dfs(int u) {
	mark[u] = true;
	int deg = adj[u].size();
	for( int i = 0 ; i < deg ; i++ ) {
		int v = adj[u][i];
		if(!mark[v])
			dfs(v);
	}
}

int main() {
	scanf("%d%d",&n,&m);
	for( int i = 0 , u,v ; i < m ; i++ ) {
		scanf("%d%d",&u,&v);
		adj[u].pb(v);
		adj[v].pb(u);
	}
	for( int i = 1 ; i <= n ; i++ )
		if(!mark[i]) {
			ans++;
			dfs(i);
		}
	printf("%d\n",--ans);
	return 0;
}

Measured memory_bytes: 14908
import sys
n = int(input())
#print(n)
prod = 1
overflow = False

a = list(map(int,input().split()))

for aa in a:
  if prod * aa > 1000000 * 1000000 * 1000000:
    overflow = True
  else:
    prod = prod * aa

for aa in a:
  if aa == 0:
    overflow = False

if overflow:
  print(-1)
else:
  print(prod)



Measured memory_bytes: 84484
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long LL;

const int INF = int(1e9);
int N,M,R;
int Map[210][210];
int a[10];
int visit[10];
int min1;

void dfs(int n,int i,int sum){
    if(n >= R+1){
        if(min1>sum)
            min1 = sum;
        return;
    }
    for(int j = 0;j<R;j++)if(!visit[j])
    {
        visit[j]=1;
        if(i==-1)dfs(n+1,j,0);
        else dfs(n+1,j,sum+Map[a[i]][a[j]]);
        visit[j]=0;
    }
}

int main()
{
    cin>>N>>M>>R;
    for(int i = 0;i<=N;i++)
    for(int j = 0;j<=N;j++)
    if(i!=j) Map[i][j] = INF;

    for(int i = 0;i < R;i++) cin>>a[i];
    for(int i = 0;i < M;i++){
        int x,y,len;
        cin>>x>>y>>len;
        if(Map[x][y]>len)
        Map[x][y] = Map[y][x] = len;
    }

    for(int k = 1;k<=N;k++)
    for(int i = 1;i<=N;i++)
    for(int j = 1;j<=N;j++)
    Map[i][j] = min(Map[i][j],Map[i][k]+Map[k][j]);

    min1 = INF;
    dfs(1,-1,0);
    cout<<min1<<endl;


    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int solve(int,int);

int A[2000];
int n;
int main(){
  int q,mi,i,a;
  
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  
scanf("%d",&q);
 for(i=0;i<q;i++){
    scanf("%d",&mi);

    a = solve(0,mi);

    if(a == 0) printf("no\n");
    else printf("yes\n");
  }
  return 0;
}


int solve(int i,int m){
  int res;
  if (m==0) return 1;
  if (i >= n) return 0;


  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;

}

Measured memory_bytes: 580
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
using namespace std;
 
int main(){
  string S, T;
  cin >> S;
  cin >> T;
 
  int size = S.size();
  char a[30], b[30];
  for(int i=0; i<30; i++){
    a[i] = '0';
    b[i] = '0';
  }
      
  bool flag = true;
  for(int i=0; i<size; i++){
    if(a[T[i]-'a'] == '0') a[T[i]-'a'] = S[i];
    else{
      if(S[i] != a[T[i]-'a']) flag = false;
    }

    if(b[S[i]-'a'] == '0') b[S[i]-'a'] = T[i];
    else{
      if(T[i] != b[S[i]-'a']) flag = false;
    }
    if(!flag) break;
  }
      
     
  if(flag)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
  return 0;
}

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

using namespace std;

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

const int inf = 1e9;

int sum[25][100010];
int cnt[25];
int dp[1<<22];

signed main()
{
    int n, m; cin >> n >> m;

    rep(i, n) {
        int a; cin >> a;
        --a;
        sum[a][i+1]++;
        cnt[a]++;
    }

    rep(i, m) {
        rep(j, n) {
            sum[i][j+1] += sum[i][j];
        }
    }

    fill_n(dp, 1<<22, inf);

    dp[0] = 0;

    rep(bit, 1 << m) {
        rep(i, m) {
            if (!(bit & (1 << i))) {
                int pos = 0;
                rep(j, m) if (bit & 1 << j) pos += cnt[j];

                int v = cnt[i] - sum[i][pos + cnt[i]] + sum[i][pos];

                dp[bit | 1 << i] = min(dp[bit | 1 << i], dp[bit] + v);
            }
        }
    }

    cout << dp[(1 << m) - 1] << endl;
}

Measured memory_bytes: 27200
open Str

let read_list f =
  split (regexp " +") (read_line ()) |> List.map f

let () =
  let n = read_int () in
  let am = Array.make_matrix n n 0 in
  let rec read x =
    if x = 0 then
      Array.iter (fun a ->
                  Array.iteri (fun i v ->
                               if i = n-1 then string_of_int a.(i) |> print_endline
                               else (string_of_int a.(i)) ^ " " |> print_string
                              ) a
                 ) am
    else begin
        match read_list int_of_string with
          u :: _ :: vs -> begin
            List.iter (fun v -> am.(u-1).(v-1) <- 1) vs;
            read (x-1)
          end
        | _ -> failwith "read"
      end
  in read n

Measured memory_bytes: 2824
N=int(input())
A=list(map(int,input().split()))
B=list(sorted(A))
c=B.pop(0)
m=N-1
total=0
if N==2:
    max=sum(A)/2
elif N>2:
    for a in range(0,m):
        total+=B[a]/(2**(m-a))
    max=total+c/(2**m)

print(max)

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

typedef long long ll;

const int Maxd = 10;

int n;
int cnt[Maxd][Maxd];
ll res;

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int num = i;
        int a = num % 10;
        int b;
        while (num) {
            b = num % 10;
            num /= 10;
        }
        cnt[a][b]++;
    }
    for (int i = 0; i < Maxd; i++)
        for (int j = 0; j < Maxd; j++)
            res += ll(cnt[i][j]) * cnt[j][i];
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int x;
    x=scan.nextInt();


    for(int j=0;j<100;j++){
      if(isPrime(x+j)){
        System.out.println(x+j);
        return;
      }
    }
    //System.out.println(5+" sqrt "+Math.sqrt(5)+ " isp "+isPrime(5));
  }

  public static Boolean isPrime(int a){
    if(a<2){
      return false;
    }
    for(int i=2;i<=Math.sqrt(a);i++){
      if(a%i==0){
        return false;
      }
    }
    return true;
  }
}

Measured memory_bytes: 21844
def main():
    n,m=map(int,input().split())
    res=[1,1]
    flg=0
    mod=10**9+7
    a=n
    gap=[]
    if m!=0:
        a=int(input())
        gap.append(a-1)
        for i in range(m-1):
            b=int(input())
            dif=b-a-1
            if dif==0:
                flg=1
                break
            else:
                gap.append(dif-1)
                a=b
        gap.append(n-a-1)
    else:
        gap.append(n)
    if flg==1:
        print(0)
    else:
        for i in range(2,max(gap)+1):
            res.append((res[i-1]+res[i-2])%mod)
        ans=1
        for i in gap:
            ans=(ans*res[i])%mod
        print(ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 7056
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
	long int A,V,B,W,T ,g;
	scanf("%ld%ld%ld%ld%ld",&A,&V,&B,&W,&T);
	
	
	if(A>B) g = A-B;
	if(B>A) g = B-A;
	if(g <= T * (V-W)) {
		printf("YES");
	}else {
		printf("NO");
	}
	
	return 0;
}

Measured memory_bytes: 2140
int main(){
  
  int n, k;
  char s[100];
  
  scanf("%d %d" ,&n ,&k);
  scanf("%s" ,s);
  
  if(s[k-1] == 'A'){s[k-1] = 'a';}
  if(s[k-1] == 'B'){s[k-1] = 'b';}
  if(s[k-1] == 'C'){s[k-1] = 'c';}
  
  printf("%s\n",s);
  
  return 0;
  
}

Measured memory_bytes: 1612
#include<bits/stdc++.h>
using namespace std;
int a,b,k,i;
int main(){
	scanf("%d%d%d",&a,&b,&k);
	for (i=a;i;i--)
		if (a%i==0 && b%i==0){
			k--;
			if (!k) return printf("%d",i),0;
		}
}

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

int main(void){

    string s;

    cin >> s;

    int cnt_B = 0;
    long long sum = 0;

    for(int i = 0; i < s.size(); i++){
        if(s.at(i)=='B'){
            cnt_B++;
            sum += i;
        }
    }
    long long sum_Max = ((s.size() - 1ll) + (s.size() - cnt_B)) * cnt_B / 2ll;
    long ans = sum_Max - sum;

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,cnt; cin>>n;
  long long max_comf=0;
  vector<int> a(n); for(int i=0;i<n;i++) cin>>a[i];
  sort(a.rbegin(),a.rend());
  max_comf+=a[0];
  cnt=a.size()-2;
  for(int i=1;i<=cnt/2;i++) max_comf+=a[i]*2;
  if(cnt%2) max_comf+=a[a.size()/2];
  cout<<max_comf;
}

Measured memory_bytes: 4020
s = list(input())

for i in range(len(s)):
  if (i+1)%2 == 0:
    if s[i] != "R":
      continue
    else:
      print("No")
      exit()
      
  else:
    if s[i] != "L":
      continue
    else:
      print("No")
      exit()
      
print("Yes")

Measured memory_bytes: 9056
#include <iostream>
#include <cstdio>

using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	double w;
	while(scanf("%lf", &w) != EOF) {
		if(w <= 48.0) cout << "light fly" << endl;
		else if(w <= 51.0) cout << "fly" << endl;
		else if(w <= 54.0) cout << "bantam" << endl;
		else if(w <= 57.0) cout << "feather" << endl;
		else if(w <= 60.0) cout << "light" << endl;
		else if(w <= 64.0) cout << "light welter" << endl;
		else if(w <= 69.0) cout << "welter" << endl;
		else if(w <= 75.0) cout << "light middle" << endl;
		else if(w <= 81.0) cout << "middle" << endl;
		else if(w <= 91.0) cout << "light heavy" << endl;
		else cout << "heavy" << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(9
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
deleteFirst
deleteLast
)");
#endif
    int n;
    in >> n;
    list<int> values;
    string command;
    int value;

    for (int i = 0; i < n; ++i) {
        in >> command;
        if (command == "insert") {
            in >> value;
            values.push_front(value);
        }
        else if (command == "deleteFirst") values.pop_front();
        else if (command == "deleteLast") values.pop_back();
        else if (command == "delete") {
            in >> value;
            for (auto it = values.begin(); it != values.end(); it++) {
                if (*it == value) {
                    values.erase(it);
                    break;
                }
            }
        }
    }

    for (auto it = values.begin(); it != values.end(); it++) {
        if (it != values.begin()) cout << " ";
        cout << *it;
    }
    cout << endl;

    return 0;
}


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

int main()
{
	string a,b;
    cin >> a >> b;
    int l = a.length();
    int cnt=0;
    for(int i=0;i<l;i++)
    {
        if(a[i]!=b[i]) cnt++;
    }
    cout << cnt << endl;
	return 0;
}

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i=0; i<H; i++){
    cin >> S.at(i);
  }
  set<int> AnsH, AnsW;
  for(int i=0; i<H; i++){
    int Ans=1;
    for(int j=0; j<W; j++){
      if(S.at(i).at(j)=='#'){
        Ans=0;
        break;
      }
    }
    if(Ans==1){
      AnsH.insert(i);
    }
  }
  for(int i=0; i<W; i++){
    int Ans=1;
    for(int j=0; j<H; j++){
      if(S.at(j).at(i)=='#'){
        Ans=0;
        break;
      }
    }
    if(Ans==1){
      AnsW.insert(i);
    }
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(AnsH.count(i)==0 && AnsW.count(j)==0){
        cout << S.at(i).at(j);
      }
    }
    if(AnsH.count(i)==0){
      cout << endl;
    }
  }
}

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

int main(void) {
  string s;
  cin >> s;
  if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n,m;
int h[100005],a[100005],b[100005];
bool ans[100005],c[100005];
int ANS;
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>h[i+1];
    }
    for(int i=0;i<=n;i++){
        ans[i]=true;
        c[i]=false;
    }
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        c[a[i]]=true; c[b[i]]=true;
        if(h[a[i]]==h[b[i]]){
            ans[a[i]]=false;
            ans[b[i]]=false;
        }else if(h[a[i]]<h[b[i]]){
            ans[a[i]]=false;
        }else{
            ans[b[i]]=false;
        }
    }
    for(int i=1;i<=n;i++){
        //cout<<ans[i]<<" "<<c[i]<<endl;
        if(ans[i]==true) ANS++;
    }
    cout<<ANS<<endl;
    
}


Measured memory_bytes: 4984
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;

void main() {
  auto N = readln.chomp.to!int;
  auto An = readln.split.to!(int[]);

  int[][] indexedList;
  for(int i=0; i<N; i++) {
    indexedList ~= [i+1, An[i]];
  }
  auto indexedListHeap = indexedList.heapify!"a[1] > b[1]";
  int[] answer;
  foreach(i; 1..N+1) {
    answer ~= indexedListHeap.front[0];
    indexedListHeap.removeFront();
  }

  writeln(answer.to!(string[]).join(" "));
}


Measured memory_bytes: 15560
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int N = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    int[] A = new int[N];
    
    for (int i=0; i<N; i++){
      A[i] = Integer.parseInt(sc.next());
      if (i >= K){
        if (A[i] > A[i-K])
          System.out.println("Yes");
        else
          System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 60920
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <unordered_map>


int main (void) {
  int N;
  std::vector<int> V, C;
  std::cin >> N;
  V.resize(N); C.resize(N);

  for(int i=0; i<N; i++){
    std::cin >> V[i];
  }

  for(int i=0; i<N; i++){
    std::cin >> C[i];
  }

  int max = 0;
  for(int i=0; i<N; i++) {
    if ( V[i] > C[i] ) max += (V[i]-C[i]);
  }

  std::cout << max << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    ll n,h,w;
    cin >> n >> h >> w;
    ll a[n], b[n],ans=0;
    rep(i,n){
        cin >> a[i] >> b[i];
        if(a[i] >= h && b[i] >= w) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def main():
  A,B,m=map(int,input().split())
  a=list(map(int,input().split()))
  b=list(map(int,input().split()))
  xyc=[list(map(int,input().split())) for _ in [0]*m]
  ans=min(a)+min(b)
  for i in range(m):
    ans=min(a[xyc[i][0]-1]+b[xyc[i][1]-1]-xyc[i][2],ans)
  print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 39332
import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        if(K<=A)
            System.out.println(K);
        else if(K<=(A+B))
            System.out.println(A);
        else
            System.out.println(2*A-K+B);
    }
}

Measured memory_bytes: 35696
#include <bits/stdc++.h>
using namespace std;
string S, T, B = "~";
bool isOK(string A1, string A2) {
	for (int i = 0; i < A1.size(); i++) {
		if (A1[i] != '?' && A1[i] != A2[i])return false;
	}
	return true;
}
int main() {
	cin >> S >> T;
	for (int i = 0; i <= (int)S.size() - (int)T.size(); i++) {
		string U = S.substr(i, T.size());
		if (isOK(U, T) == true) {
			string V = S;
			for (int j = i; j < i + T.size(); j++)V[j] = T[j - i];
			for (int j = 0; j < i; j++) { if (V[j] == '?')V[j] = 'a'; }
			for (int j = i + T.size(); j < V.size(); j++) { if (V[j] == '?')V[j] = 'a'; }
			B = min(B, V);
		}
	}
	if (B == "~")cout << "UNRESTORABLE" << endl;
	else cout << B << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int main(){
    int n,q;
    cin>>n>>q;
    ll a[q+1];
    a[q]=n;
    rep(i,q)cin>>a[q-i-1];
    vector<ll> b;
    b.push_back(a[0]);
    rep(i,q)if(b.back()>a[i+1])b.push_back(a[i+1]);
    int m=b.size();
    vector<ll> cnt(m+1);
    vector<ll> ans(n+1);
    cnt[0]=1;
    rep(i,m+1){
        if(!cnt[i])continue;
        ll cur=b[i];
        while(cur>b.back()){
            int idx=upper_bound(b.begin(),b.end(),cur,[](auto x,auto y){
                return x>y;
            })-b.begin();
            cnt[idx]+=(cur/b[idx])*cnt[i];
            cur%=b[idx];
        }
        ans[cur]+=cnt[i];
    }
    rep(i,n-1)ans[n-i-1]+=ans[n-i];
    rep(i,n)cout<<ans[i+1]<<"\n";

    return 0;
}

Measured memory_bytes: 4980
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

int main(void){


    int A,B,C,D; cin>>A>>B>>C>>D;

    while(1){

        C -= B;
        if(C<=0) break;
        A -= D;
        if(A<=0) break;
    }

    if(A < C) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

}


Measured memory_bytes: 3636
#include<stdio.h>

int main(){

  int Seconds,hour,minute,second;
  scanf("%d",&Seconds);

  second = (Seconds%3600) %60;
  Seconds = Seconds - second;
  minute = (Seconds%3600) / 60;
  Seconds = Seconds - 60*minute;
  hour = Seconds / 3600;

  printf("%d:%d:%d\n",hour,minute,second);

  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <climits>
using namespace std;
typedef long long int ll;

int const INF=INT_MAX;

struct SegmentTree{
private:
    int n;
    vector<int> node;
public:
    SegmentTree(vector<int> v){
        int sz=v.size();
        n=1;
        while(n<sz)n*=2;
        node.resize(2*n-1,INF); // INF
        // 最下段に値を入れた後に、下の段から順番に値を入れる
        for(int i=0;i<sz;i++){
            node[i+n-1]=v[i];
        }
        for(int i=n-2;i>=0;i--){
            node[i]=min(node[2*i+1],node[2*i+2]);
        }
    }
    void update(int x,int val){
        //最下段のノードにアクセスする
        x+=(n-1);
        node[x]=val;
        while(x>0){
            x=(x-1)/2;
            node[x]=min(node[2*x+1],node[2*x+2]);
        }
    }
    void add(int x,int val){
        x+=(n-1);
        node[x]+=val;
        while(x>0){
            x=(x-1)/2;
            node[x]=node[2*x+1]+node[2*x+2];
        }
    }
    int getmin(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(r<=a||b<=l)return INF;
        if(a<=l&&r<=b) return node[k];
        int vl=getmin(a,b,2*k+1,l,(l+r)/2);
        int vr=getmin(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
    int getsum(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(b<=l||r<=a)return 0;
        if(a<=l&&r<=b)return node[k];
        int vl=getsum(a,b,2*k+1,l,(l+r)/2);
        int vr=getsum(a,b,2*k+2,(l+r)/2,r);
        return vl+vr;
    }
};

int main(){
    int n,q; cin >> n >> q;
    SegmentTree seg(vector<int> (n,0));
    for(int i=0;i<q;i++){
        int c,x,y; cin >> c >> x >> y;
        if(c==0){
            seg.add(x-1,y);
        }
        else{
            cout << seg.getsum(x-1,y) << endl;
        }
    }
}


Measured memory_bytes: 4176
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44


const int MOD = 998244353;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

using namespace std;

const int MAXN = (int) 1e6;

int fact[2 * MAXN + 1], invfact[2 * MAXN + 1];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}

inline int solve(int sum, int n, int odd) {
    int ans = 0;
    for(int i = 0; i <= odd; i++) {
        int cur = comb(n, i);
        if((sum - i) % 2 == 0) {
            mul(cur, comb(n - 1 + (sum - i) / 2, n - 1));
            add(ans, cur);
        }
    }
    return ans;
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int n, m;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> m;

    prec(n + 2 * m);

    int ans = solve(3 * m, n, m);

    int cur = 0;
    add(cur, solve(m, n, m));
    sub(cur, solve(m, n - 1, m));
    mul(cur, n);

    sub(ans, cur);

    cout << ans;

    return 0;
}


Measured memory_bytes: 15872
#include <iostream>

int main() {
    std::string s;
    std::cin >> s;
    for (char c : s) {
        char tmp;
        switch (c) {
            case 'A':
                tmp = 'T';
                break;
            case 'T':
                tmp = 'A';
                break;
            case 'C':
                tmp = 'G';
                break;
            case 'G':
                tmp = 'C';
                break;
        }
        std::cout << tmp;
    }
    std::cout << '\n';
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Data.List
import Data.Char

getInt :: IO Int
getInt = (\a -> read a :: Int) <$> getLine

getIntArray :: IO [Int]
getIntArray = ((map (\a -> read a :: Int)) . words) <$> getLine

getStrArray :: Int -> IO [String]
getStrArray 0 = return [] :: IO [String]
getStrArray n = (:) <$> getLine <*> (getStrArray (n - 1))

main = do
    [a, b, c] <- getIntArray
    putStrLn $ if c <= a + b then "Yes" else "No"


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	map<int, map<int, char>> mx, my, ms, md;
	IN(int, n);
	inc(i, n) {
		IN(int, x, y);
		IN(string, s);
		char c = s[0];
		mx[x][y] = c;
		my[y][x] = c;
		ms[x + y][x - y] = c;
		md[x - y][x + y] = c;
	}
	
	const int INF = 1e7;
	int ans = INF;
	auto f = [&](auto mm, char a, char b) {
		for(auto [v_, m]: mm) {
			int p = -2 * INF;
			for(auto [x, c]: m) {
				if(c == a) { p = x; }
				if(c == b) { setmin(ans, x - p); }
			}
		}
	};
	f(mx, 'U', 'D');
	f(my, 'R', 'L');
	f(ms, 'R', 'U');
	f(ms, 'D', 'L');
	f(md, 'U', 'L');
	f(md, 'R', 'D');
	OUT(ans == INF ? "SAFE" : to_string(ans * 5));
}


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

bool isDigis(char c)
{
    return (c >= '0') && (c <= '9');
}

int main(int argc, const char * argv[]) {
    int A, B;
    string S;
    
    cin >> A >> B;
    cin >> S;
    
    if (S[A] != '-') {
        cout << "No" << endl;
        return 0;
    }
    
    S[A] = '0';
    
    for (int i = 0; i < S.length(); i++) {
        if (!isDigis(S[i])) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 764
n = int(input())
for i in range(1, n+1):
  x = i
  if x%3 == 0:
    print("", i, end = "")
  else:
    while(x > 0):
      if x%10 == 3:
        print("", i, end = "")
        break
      else:
        x = x//10
print()


Measured memory_bytes: 6160
#include<iostream>
#include<string>
#include<stdio.h>
#include<vector>
using namespace std;
int main(){
  int N,Q,ans=0,l,r;
  string S;
  cin>>N>>Q>>S;
  vector<int> Z(N);
  for(int i=0;i<N-1;i++){
      if(S[i]=='A'&&S[i+1]=='C') ans++;
      Z[i+1]=ans;
  }
  for(int j=0;j<Q;j++){
    scanf("%d%d",&l,&r);
    cout<<Z[r-1]-Z[l-1]<<endl;
  }
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

vector<int>graph[60] ;
int visited[60], dfs_low[60], dfs_num[60], timer = 0, cnt = 0 ;

void dfs(int u , int p = -1){
  visited[u] = true ;
  dfs_num[u] = dfs_low[u] = timer++ ;

  for(auto v: graph[u]){
    if(v == p) continue ;
    if(visited[v]){
      dfs_low[u] = min(dfs_low[u], dfs_num[v]) ;
    }
    else{
      dfs(v, u) ;
      dfs_low[u] = min(dfs_low[u], dfs_low[v]) ;
      if(dfs_low[v] > dfs_num[u]) cnt++ ;
    } 
  }
}

int main() {
  int n ,m, u, v;
  scanf("%d %d", &n , &m) ;

  for(int i = 0 ;i<m ;i++){
    scanf("%d %d", &u, &v) ;
    graph[u].pb(v) ;
    graph[v].pb(u) ;
  }

  dfs(1) ;

  cout << cnt << endl ;

  return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a > b) System.out.println("a > b");
        if(a == b) System.out.println("a == b");
        if(a < b) System.out.println("a < b");
	}
}


Measured memory_bytes: 26344
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  set<string>st;
  rep(i,0,n){
    string s;cin>>s;st.insert(s);
  }
  cout<<st.size()<<endl;
  return 0;
}

Measured memory_bytes: 19284
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan  = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    
    if(a == b && b == c){
      System.out.println("1");
      return;
    }
    else if(a != b && a != c && b != c){
      System.out.println("3");
      return;
    }
    else{
      System.out.println("2");
      return;
    }
  }
}

Measured memory_bytes: 21844