akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI 3.141592653589793238
int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("/home/pushkar/cpp/input.txt", "r", stdin);
    // freopen("/home/pushkar/cpp/output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    ll n = s.length();
    if (s[n-1] != 's')
    cout << (s + 's') << "\n";
    else
    cout << (s + "es") << "\n";
    return 0;
}

Measured memory_bytes: 3664
# abc081_b.py
n = int(input())
a = list(map(int,input().split()))
cnt = 0
end = False
while not end:
    for i in range(n):
        if a[i]%2 == 0:
            a[i] = a[i]//2
        else:
            end = True
            break
    if not end :
        cnt+=1
print(cnt)

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

class Node {
public:
    int number;
    ll dist;
    Node(ll d, int n) {
        dist = d;
        number = n;
    }
};
bool operator < (const Node &l, const Node &r) {
    return l.dist < r.dist
    || (!(r.dist < l.dist) && l.number < r.number);
};
bool operator > (const Node &l, const Node &r) {
    return r < l;
};

class Dijkstra {
private:
    class Edge {
    public:
        int to, cost;
        Edge(int t, int c) {
            to = t;
            cost = c;
        }
    };

    vector<vector<Edge>> edges;
    int node_n;

    void edge_initializer(int n) {
        edges = vector<vector<Edge>>(n);
    }

public:
    vector<ll> d;
    int start = 0;

    Dijkstra(int n, int s) {
        start = s;
        node_n = n;
        edge_initializer(n);
    }

    void add_edge(int from, int to, int cost, bool rev=true) {
        edges[from].pb(Edge(to,cost));
        if(rev) edges[to].pb(Edge(from,cost));
    }

    vector<ll> solve() {
        d = vector<ll>(node_n, LLONG_MAX); d[start] = 0;

        priority_queue<Node,vector<Node>,greater<Node>> Q;

        for(int i=0; i<node_n; i++) {
            Q.push(Node(d[i],i));
        }

        while(!Q.empty()) {
            Node u = Q.top(); Q.pop();
            if(u.dist > d[u.number]) continue;
            for(Edge &edge:edges[u.number]) {
                ll alt = d[u.number] + edge.cost;
                int v = edge.to;
                if(d[v] > alt) {
                    d[v] = alt;
                    Q.push(Node(d[v],v));
                }
            }
        }
        return d;
    }
};

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

    int N; cin >> N; Dijkstra di = Dijkstra(N+1, 0);
    rep(i,N-1) {
        int a, b, c; cin >> a >> b >> c;
        di.add_edge(a, b, c);
    }
    int Q, K; cin >> Q >> K;
    di.start = K; di.solve();
    V<int> x = V<int>(Q), y = V<int>(Q);
    rep(i, Q) {
        cin >> x[i] >> y[i];
        cout << di.d[x[i]] + di.d[y[i]] << endl;
    }

    return 0;
}


Measured memory_bytes: 13168
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		
		String in = scan.next();
		int a = Integer.parseInt(in);
		
		in = scan.next();
		int b = Integer.parseInt(in);
		
		if (a < b) {
			System.out.println("a < b");
		} else if (a > b) {
			System.out.println("a > b");
		} else {
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26020
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();

		int[][] list = new int[a][b];
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				list[i][j] = scanner.nextInt();
			}
		}
		int[] list2 = new int[b];
		for (int i = 0; i < b; i++) {
			list2[i] = scanner.nextInt();
		}
		int sum;
		for (int i = 0; i < a; i++) {
			sum = 0;
			for (int j = 0; j < b; j++) {
				sum += list[i][j] * list2[j];
			}
			System.out.println(sum);
		}

	}
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	cout << "A" << b[0] << "C" << endl;

	return 0;
}

Measured memory_bytes: 256
a =input()
def pp(n):
    n = int(n)
    return 0<n<13
if pp(a[:2]) and pp(a[2:]):
    print("AMBIGUOUS")
elif not pp(a[:2]) and pp(a[2:]):
    print("YYMM")
elif pp(a[:2]) and not pp(a[2:]):
    print("MMYY")
else:
    print("NA")

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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

  ll v1 = (A1 - B1) * T1;
  ll v2 = (A2 - B2) * T2;
  if (v1 < 0) {
    v1 = -v1;
    v2 = -v2;
  }
  ll w = v1 + v2;
  if (w > 0) {
    cout << "0\n";
    return 0;
  }else if (w == 0) {
    cout << "infinity\n";
    return 0;
  }else {
    ll u = -w;
    if (v1 % u == 0) {
      cout << 2 * v1 / u << endl;
    }else {
      ll k = (v1 + u - 1) / u;
      cout << k * 2 - 1 << endl;
    }
    return 0;
  }
  

  

  return 0;
}



Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

x4 = 0
x2 = 0
a.each do |i|
  if i % 4 == 0
    x4 += 1
  elsif i % 2 == 0
    x2 += 1
  end
end

if x4 >= n / 2
  puts "Yes"
elsif (n - (x2 / 2) * 2) <= (x4 * 2 + 1) 
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 8452
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

bool in(ll x){
	cout << "? " << x << endl;
	string a; cin >> a;
	return a[0] == 'Y';
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	ll x = 9;
	vi nine, ten;
	rep(i, 10){
		nine.pb(in(x));
		x = x * 10 + 9;
	}
	x = 1;
	rep(i, 11){
		ten.pb(in(x));
		x *= 10;
	}
	auto func = [&](){
		rep(i, 10) if(!nine[i]){
			for(int j = i + 1; ; j++){
				if(nine[j]) return j + 1;
			}
		}
		rep(i, 11) if(!ten[i]) return i;
		return 1;
	};
	int digit = func();
	
	ll lo = 1, hi = 10, mid;
	rep(i, digit - 1){
		lo *= 10;
		hi *= 10;
	}
	lo--; hi--;
	
	while(lo + 1 < hi){
		mid = (lo + hi) / 2;
		if(in(mid * 10)) hi = mid;
		else lo = mid;
	}
	cout << "! " << hi << endl;
	return 0;
}

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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int a[MAXN];

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	scanf("%d", &n);
	n *= 3;
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	ll ans = 0;
	for(int i = 1, j = n - 1; i * 3 <= n; i++, j -= 2){
		ans += a[j];
	}
	cout<<ans<<endl;
}

void printans(){

}


int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" 
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 // freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n,m,d,ans=0,i=0;
  cin>>n>>m;
  while(i<m)
  {
    cin>>d;
    ans+=d;
    i++;
  }
  deb(max(-1ll,n-ans));
}

Measured memory_bytes: 3648
n, m = map(int, input().split())
li = list(map(int, input().split()))
 
li.sort()
move_cost = [li[i+1] - li[i] for i in range(m-1)]
move_cost.sort()
if n > 1:
    move_cost = move_cost[:-n+1]

print(sum(move_cost))

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

#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif

#define mp make_pair
#define pb push_back
#define put(x) { cout << #x << " = "; cout << (x) << endl; }

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef double db;

const ll M = 1e6 + 15;
const ll Q = 1e9 + 7;

inline ll mult(ll a, ll b) { return ll(((a * b) % Q + Q) % Q); }
inline ll sum(ll a, ll b) { return a + b >= Q ? a + b - Q : a + b; }
void inc(ll &a, ll b) { a = sum(a, b); }

ll a[M];

ll get(ll n) {
	for (ll i = 0; i < n; i++) cin >> a[i];
	ll res = 0;
	for (ll i = 0; i < n; i++) {
//		cout << a[i] << " " << 2 * i - n - 1 << endl;
//		res += 1LL * a[i] * (2 * i - n + 1);
		inc(res, mult(a[i], 2 * i - n + 1));
	}
	return res;
}

int main() {
    srand(time(NULL));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(0);

	ll n[2];
	cin >> n[0] >> n[1];

//	cout << get(n[0]) << " " << get(n[1]) << endl;
	ll a = get(n[0]);
	ll b = get(n[1]);
	cout << mult(a, b);
//	cout << mult(get(n[0]), get(n[1]));


    return 0;
}   

Measured memory_bytes: 1024
function myout(text){console.log(text);}//standard output
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var strLen = parseInt(input[0].split(" ")[0]);
  var qLen = parseInt(input[0].split(" ")[1]);
  var output = [];
  var str = input[1].split("");
  input.shift();
  input.shift();
  //累積和の集合
  var ACList = [];
  var count = 0;
  ACList.push(0);
  for(var i = 0; i < str.length - 1; i++){
    if(str[i] == "A" && str[i+1] == "C"){
      count++;
    }
    ACList.push(count);
  }
  for(var i = 0; i < qLen; i++){
    var left = input[i].split(" ")[0] - 1;
    var right = input[i].split(" ")[1] - 1;
    output.push(ACList[right] - ACList[left]);
  }
  myout(output.join("\n"));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 35408
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
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;
}
struct UnionFind{
    vector<int>parent;//親の番号
    UnionFind(int N):parent(N){
        rep(i,N){
            parent[i]=i;
        }
    }//全て根であるとして初期化
    int root(int x){
        if(parent[x]==x){
            return x;
        }
        return parent[x]=root(parent[x]);
    }//根を探す
    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry){
            return;
        }
        parent[rx]=ry;
    }//xの根をyの根にくっつける
    bool same(int x,int y){
        int rx=root(x);
        int ry=root(y);
        return rx==ry;
    }//x,yの属する木が同じならtrue
};

int main(){
    int N,M;
    cin>>N>>M;
    UnionFind tree(N);
    rep(i,M){
        int x,y;cin>>x>>y;
        x--;y--;
        tree.unite(x,y);
    }
    vector<int>ans(N,0);
    rep(i,N){
        ans[tree.root(i)]++;
    }
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    cout<<ans[0]<<endl;
}

Measured memory_bytes: 10936
from typing import List


class Trump:
	def __init__(self, value, suit):
		self.value = value
		self.suit = suit

	def __repr__(self):
		return self.suit + str(self.value)


def bubble(C: List[Trump], N: int) -> None:
	for i in range(N):
		for j in range(N-1, i, -1):
			if C[j].value < C[j-1].value:
				C[j], C[j-1] = C[j-1], C[j]
	print(*C)


def selection(C: List[Trump], N: int) -> None:
	for i in range(N):
		minj = i
		for j in range(i, N):
			if C[j].value < C[minj].value:
				minj = j
		C[i], C[minj] = C[minj], C[i]
	print(*C)


if __name__ == "__main__":
	N = int(input())
	C1 = []
	for c in input().split():
		C1.append(Trump(int(c[1]), c[0]))
	C2 = C1.copy()

	bubble(C1, N)
	print("Stable")
	selection(C2, N)
	if C1 == C2:
		print("Stable")
	else:
		print("Not stable")


Measured memory_bytes: 7168
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Main me = new Main();
		while(in.hasNext()){
			long a = in.nextInt(),b = in.nextInt();
			long gcd = me.GCD(a,b);
			System.out.printf("%d %d\n",gcd,a*b/gcd);
			
		}
	}
	private long GCD(long a,long b){
		if(b == 0)
			return a;
		else
			return GCD(b,a%b);
	}
}

Measured memory_bytes: 18104
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
int arr[504][504];
int main(){
    std::ios::sync_with_stdio(false);
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    if(H%h==0 && W%w==0){
    	cout<<"No"<<endl;
    	return 0;
    }
    cout<<"Yes"<<endl;
    int ans=max(H,W)+12;
    int i,j;
    f(i,1,H+1){
    	f(j,1,W+1){
    		if(i%h==0 && j%w==0){
    			arr[i][j]=-1*(ans*(h*w-1)+1);
    		}
    		else{
    			arr[i][j]=ans;
    		}
    		cout<<arr[i][j]<<" ";
    	}
    	cout<<endl;
    }
    //cout<<ans*H*W<<endl;
    return 0;
    
}



Measured memory_bytes: 2304
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
  string s;
  cin>>s;
  ll n=sz(s);
  reverse(all(s));
  ll dp[100005][13];
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  ll a=1;
  rep(i,n){
    if(s[i]=='?'){
      rep(j,13){
        rep(z,10){
          dp[i+1][(j+(z*a))%13]+=dp[i][j];
          dp[i+1][(j+(z*a))%13]%=MOD;
        }
      }
    }
    else{
      ll nx=s[i]-'0';
      rep(j,13){
        dp[i+1][(j+(nx)*a)%13]+=dp[i][j];
        dp[i+1][(j+(nx)*a)%13]%=MOD;
      }
    }
    a*=10;
    a%=13;
  }
  COUT(dp[n][5]);
}

Measured memory_bytes: 10624
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int a,b,k,n,cnt=0;
  cin >> a >> b >> k;
  n=2*k;
  vector<int>stock(n);
  if(a+k>=b){
    for(int i=a; i<=b; i++){
      cout << i << endl;
    }
  }
  else{
    for(int i=a; i<a+k; i++){
      stock.at(cnt)=i;
      cnt++;
    }
    for(int i=b; i>b-k; i--){
      stock.at(cnt)=i;
      cnt++;
    }
    sort(stock.begin(), stock.end());
    for(int i=0; i<n-1; i++){
      int j=i+1;
      if(stock.at(i)==stock.at(j)){
        stock.at(j)=1000000000;
        sort(stock.begin(),stock.end());
        n--;
      }
      cout << stock.at(i) << endl;
    }
    cout << stock.at(n-1) << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>

using namespace std;

int W,H;

char maze[22][22];

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

int sy,sx;

int DFS(int posy,int posx){

    maze[posy][posx]='#';

    int ret=1;
    for(int i=0;i<4;i++){
        int y,x;
        y=posy+dy[i];
        x=posx+dx[i];

        if (y<1||y>H) continue;
        if (x<1||x>W) continue;
        if (maze[y][x]=='#') continue;


        ret+=DFS(y,x);
    }
    return ret;
}

int main(){

    while(scanf("%d%d",&W,&H)&&W!=0&&H!=0){
        getchar();
        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                maze[i][j]=getchar();
                if (maze[i][j]=='@') sy=i,sx=j;
            }
            getchar();
        }

        printf("%d\n",DFS(sy,sx));

    }


    return 0;
}


Measured memory_bytes: 2772
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<float> vc;
    float sum = 0;
    for (int i = 0;i<n;i++){
        int x;
        cin >> x;
        vc.push_back(x);
    }
    sort(vc.begin(), vc.end());
    sum = (vc[0]+vc[1])/2;
    for (int i = 2;i<n;i++){
        sum = (sum+vc[i])/2;
    }
    cout << sum;
}

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

int main(){
    int n;
    cin >> n;
    int b[n-1], a[n];
    long long r = 0;
    for(int i = 0; i < n-1; i++){
        cin >> b[i];
    }
    a[0] = b[0];
    r += b[0];
    for(int i = 1; i < n-1; i++){
        a[i] = min(b[i], b[i-1]);
        r += a[i];
    }
    a[n-1] = b[n-2];
    r += a[n-1];
    cout << r << '\n';
}


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

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

    int cnt = 0;
    while (a > 0 && c > 0) {
        if (cnt % 2 == 0) {
            c -= b;
        } else {
            a -= d;
        }
        cnt++;
    }

    if (a <= 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	int n,k; cin>>n>>k;
	int arr[n+1]; for(int i = 0; i <n+1; i++) arr[i] = 0;
	for(int  i = 0; i < k; i++){
		int x; cin>>x;
		for(int j = 0; j < x; j++) {
			int y; cin>>y;
			arr[y] = 1;
		}
	}
	int co = 0;
	for(int i = 1; i < n+1; i++){
		if(!arr[i]) co++;
	}
	cout<<co<<"\n";
	
}


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

int main() {
    int n,m;
    cin>>n>>m;
    vector<int> h(n);
    vector<int> counter(n,0);
    int ans = 0;
    rep(i,n) {
        int h_t;
        cin>>h_t;
        h[i] = h_t;
    }
    rep(i,m) {
        int a,b;
        cin>>a>>b;
        if (h[a-1] > h[b-1]) {
            counter[b-1] = -1;
        } else if (h[b-1] > h[a-1]) {
            counter[a-1] = -1;
        } else {
            counter[a-1] = -1;
            counter[b-1] = -1;
        }
    }
    rep(i,n) {
        if (counter[i] == 0) {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

signed main()
{
  int n;
  int b, f, r, v;
  int i, j, k;
  int room[4][3][10] = {0};
  cin >> n;

  for (i = 0; i < n; i++){
    cin >> b >> f >> r >> v;
    room[b - 1][f - 1][r - 1] += v; 
  }

  for (i = 0; i < 4; i++){
    for (j = 0; j < 3; j++){
      for (k = 0; k < 10; k++){
        cout << " " << room[i][j][k];
      }
      cout << endl;
    }
    if (i != 3){
      cout << "####################" << endl;
    }
  }
  return (0);
}

Measured memory_bytes: 3048
#include <iostream>

using namespace std;

bool check_only_one_char(int num) {
    int n = num % 10;
    num /= 10;

    while (num > 0) {
        int tmp = num % 10;
        if (n != tmp)
            return false;
        num /= 10;
    }
    return true;
}

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

    for (int i = n;; ++i) {
        if (check_only_one_char(i)) {
            cout << i << '\n';
            break;
        }
    }
}


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

int main(void){
    int N, M, ans=0;
    std::cin >> N >> M;
    std::vector<int> imos(N + 2, 0);

    for (int i=0; i<M; ++i){
        int l, r;
        std::cin >> l >> r;
        ++imos[l];
        --imos[r + 1];
    }

    for (int i=1; i<N+2; ++i){
        imos[i] += imos[i - 1];
        if (imos[i] == M && i != N + 1) ++ans;

    }

    std::cout << ans << std::endl;

    return 0;
}


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n, k, x, y;
    cin >> n >> k >> x >> y;

    cout << min(n, k) * x + max(0, n - k) * y << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define pb push_back
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fs(s) for(ll i=0;s[i]!='\0';i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define gcd(a,b) __gcd(a,b)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define c1(x) __builtin_popcountll(x)
#define setprs(x) cout << fixed << setprecision(x);
#define endl '\n'
const ll mod=1e9 + 7;
const ll sz=1e5 + 100;
const double PI =3.14159265;
ll power(ll a, ll b, ll m = mod){if(b==0)return 1;else if(b==1)return a%m;else{ll t=power(a,b>>1,m);t=((t%m)*(t%m))%m;if(b&1)return ((t%m)*(a%m))%m;else return t%m;}}
 
//--------------------------------------------------------
#define int ll

int n, W;
int w[sz], v[sz], dp[sz][103];

int dpfunc(int weight, int pos){
    if(weight <= 0 || pos >= n)
        return 0;
    if(dp[weight][pos] != 0)
        return dp[weight][pos];
    int ans = 0;
    int i = pos;
    int m1 = 0;
    if(weight >= w[i])
        m1 = dpfunc(weight - w[i], i + 1) + v[i];
    int m2 = dpfunc(weight, i + 1);
    if( max(m1, m2)> ans){
        ans = max(m1, m2);
    }
    return dp[weight][pos] = ans;
}

void solve()
{
    cin >> n >> W;
    f(i, 0, n){
        cin >> w[i] >> v[i];
    }
    cout << dpfunc(W, 0);


} 
 
int32_t main()
{
    fastio
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 83808
/*
 *  Created on: 16 / 8 / 2020
 *  Author:     Eslam Waheed
 */

#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO

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

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

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)
#define test(t)      while(t--)

//ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ld PI = acos(-1);
//const ll mod = 1e9 + 7;
//const ld EPS = 1e-8;
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
	//stp(0)
	Eslam__Waheed;
	ll n; cin >> n;
	vector<ll>v(n);
	for (auto& it : v)
	{
		cin >> it;
	}

	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int u = i + 1; u < n; u++)
		{
			for (int j = u + 1; j < n; j++)
			{
				if (v[i] != v[u] && v[i] != v[j] && v[u] != v[j])
					if (((v[i] + v[u] + v[j]) - max({ v[i], v[u], v[j] })) > max({ v[i], v[u], v[j] }))
						ans++;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3624
N = int(input())
town = [list(map(int,input().split())) for i in range(N)]

d = 0
for i in range(N):
    for j in range(i,N):
        d += ((town[i][0]-town[j][0])**2 + (town[i][1]-town[j][1])**2)**0.5

print(d*2/N)

Measured memory_bytes: 38512
#include<stdio.h>

int main(void)
{
    int length=0, breadth=0;
    char buffer[256];
    while((length < 1 || 100 < length)
    || (breadth < 1 || 100 < breadth))
    {
        fgets(buffer,256, stdin);
        sscanf(buffer, "%d %d", &length, &breadth);
    }
    //printf("%d %d", length, breadth);
    printf("%d %d\n", length*breadth,
    2*(length+breadth));
    
    return(0);
}


Measured memory_bytes: 2040
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vi A(N);
	double sum = 0;
	REP(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	sum /= N;
	double dis = INF;
	int ind = -1;
	REP(i, N) {
		if (abs(A[i] - sum) < dis) {
			ind = i;
			dis = abs(A[i] - sum);
		}
	}
	cout << ind << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7

def factorial(N, mod=MOD):
    res = 1
    for i in range(2, N+1):
        res *= i
        res %= mod
    return res

def main():
    N, M = map(int, readline().rstrip().split())
    if abs(N-M) > 1:
        ans = 0
    elif N == M:
        ans = factorial(N) * factorial(M) * 2
    else:
        ans = factorial(N) * factorial(M)

    print(ans % MOD)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<algorithm>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
#define pb push_back
#define mp make_pair
#define mh make_heap
#define F first
#define S second
//#define fin cin
//#define fout cout
#define file ifstream fin("input.txt");ofstream fout("output.txt");
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long int ll;
typedef pair<ll,ll> pairs;
typedef vector<ll> vi;
typedef vector<pairs> vpair;

void solve()
{
    ll a,b;cin>>a>>b;
    ll ini=1,cnt=0;
    while(ini<b)
    {
        ini=ini+(a-1);
        cnt++;
    }
    cout<<cnt<<endl;

    return ;

}
int main()
{
    ll t=1;
    //cin>>t;
    fr(t)
    {
        solve();
    }
    return 0;
}


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

const int N = 1e5 + 9;

int n, m, a[N], f[N], cnt[3];
bool o[N], p[N];

int find (int x) {
	if (x == f[x]) return x;
	int pos = f[x];
	f[x] = find(f[x]);
	a[x] ^= a[pos];
	return f[x];
}

int main () {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) f[i] = i;
	for (int i = 1, u, v, ru, rv; i <= m; ++i) {
		scanf("%d%d", &ru, &rv);
		u = find(ru); v = find(rv);
		if (u == v) {
			if (a[ru] == a[rv]) o[u] |= 1;
		} else {
			a[u] = a[ru] ^ a[rv] ^ 1;
			f[u] = v;
			o[v] |= o[u];
		}
	}
	for (int i = 1; i <= n; ++i) if (i != find(i)) p[find(i)] = 1;
	for (int i = 1; i <= n; ++i) if (i == find(i)) { if (p[i]) ++cnt[!o[i]]; else ++cnt[2]; }
	printf("%lld\n", 1ll * cnt[0] * cnt[0] + 2ll * cnt[1] * cnt[1] + 2ll * cnt[1] * cnt[0] + 2ll * cnt[2] * (n - cnt[2]) + 1ll * cnt[2] * cnt[2]);
	return 0;
}

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

int main () {

    int N, K;
    scanf("%d %d", &N, &K);

    int h[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &h[i]);
    }

    sort(h, h + N, greater<int>());

    int ans = INT_MAX;

    for (int i = 0; i < N - K + 1; i++) {
        
        int hmax = h[i], hmin = h[i+K-1];

        ans = min(ans, hmax - hmin);
    }
    printf("%d\n", ans);

    return 0;
}

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


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

       map<string,int> m;
       map<string,int> :: iterator it;

      string s3[n];

      int ans=-1;

      for(int i=0;i<n;i++){
          string s;
          cin>>s;
          m[s]++;

          ans=max(ans,m[s]);

      }

      // cout<<ans<<endl;

      for(it=m.begin();it!=m.end();it++){
         //cout<<
         if(it->second==ans){
            cout<<it->first<<endl;
         }
      }

       return 0;
}


Measured memory_bytes: 27520
from collections import deque
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N,M = map(int,input().split())
to = [[] for i in range(N)]
for i in range(N-1) :
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    to[u].append(v)
    to[v].append(u)

ans = [0]*N

for i in range(M) :
    p,x = map(int,input().split())
    p -= 1
    ans[p] += x

q = deque([0])
par = [-1]*N
while q :
    u = q.popleft()
    for v in to[u] :
        if v == par[u] :
            continue
        ans[v] += ans[u]
        par[v] = u
        q.append(v)
print(*ans)


Measured memory_bytes: 56260
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int INF=1e10;


int main() {
	int	h,w;
	P	st,gl;
	cin >> h >> w >> st.first >> st.second >> gl.first >> gl.second;
	st.first--;st.second--;gl.first--;gl.second--;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	vector<vector<int>> dist(h,vector<int>(w,INF));
	deque<P> q;
	dist[st.first][st.second] = 0;
	q.emplace_back(st.first,st.second);
	while(!q.empty()){
		int	i = q.front().first;
		int	j = q.front().second;
		int	d = dist[i][j];
		q.pop_front();
		if (dist[i][j] != d) continue;
		rep(k,4){
			int	mi = dy[k] + i; int mj = dx[k] + j;
			if (mi < 0 || mi >= h || mj < 0 || mj >= w) continue;
			if (s[mi][mj] == '#') continue;
			if (dist[mi][mj] <= d) continue;
			dist[mi][mj] = d;
			q.push_front(P(mi,mj));
		}
		for (int ei = -2; ei <= 2; ei++){
			for (int ej = -2; ej <= 2; ej++){
				int mi = i + ei;int mj = j + ej;
				if (mi < 0 || mi >= h || mj <0 || mj >= w) continue;
				if (s[mi][mj] == '#') continue;
				if (dist[mi][mj] <= d) continue;
				dist[mi][mj] = d + 1;
				q.push_back(P(mi,mj));
			}
		}
	}
	int	ans = dist[gl.first][gl.second];
	if (ans == INF) ans = -1;
	cout << ans <<endl;
}

Measured memory_bytes: 10108
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>

typedef long long ll;
using namespace std;
int main(void){
    // Your code here!
   int N;
   string S;
   cin >> N;
   cin >> S;
   if(S.size() < 2 || S.size() % 2 != 0) {
       cout << "No" << endl;
       return 0;
   }

   
   if(S.substr(0, S.size() /2) == S.substr(S.size() / 2, S.size() - 1)) {
       cout << "Yes" << endl;
   } else{
       cout << "No" << endl;
   }
   
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

#define LISTSIZE 3000
 
int main(){
    string n[LISTSIZE];

    int count = 0;
    while (1){
        int a, b, tmp;
        ostringstream ostr;

        cin >> a >> b;
        if (a==0 && b==0) {
            break;
        }

        if (a>b) {
            tmp = a;
            a = b;
            b = tmp;
        }

        ostr << a << ' ' << b;
        n[count] = ostr.str();
        count += 1;
    }

    for (int t=0; t<count; t+=1) {
        cout << n[t] << endl;
    }
    return 0;
}

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

const ll INF = 10000000000;

int main(){
    int h, n; cin >> h >> n;
    vector<ll> dp(h + 20000, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        ll a, b; cin >> a >> b;
        for(int l = 0; l < h + 20000; l++){
            if(l-a >= 0)
                dp[l] = min(dp[l], dp[l-a] + b);
        }
    }
    ll ans = INF;
    for(int i = h; i < h + 20000; i++){
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;
}

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

int MaximumProfit(vector<int> R, int n){
  int minR = INT_MAX;
  int maxp = INT_MIN;
  for(int i = 0; i < n; i++){
    maxp = max(maxp, R.at(i) - minR);
    minR = min(minR, R.at(i));
  }
  return maxp;
}

int main(){
	int n;
  cin >> n;
  vector<int> R(n);

  for(int i = 0; i < n; i++){
    cin >> R.at(i);
  }

  cout << MaximumProfit(R, n) << endl;

}



Measured memory_bytes: 4488
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    while(a>=b){
        b*=2;
        k--;
    }
    while(b>=c){
        c*=2;
        k--;
    }
    Yes(k>=0);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3640
input()
(*a,) = map(int, input().split())

ただの倍数 = 1
for i in set(a):
    ただの倍数 *= i
ans = ただの倍数 / sum(ただの倍数 // i for i in a)
print([ans, int(ans)][ans % 1 == 0])

Measured memory_bytes: 9196
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    _ <- fst . fromJust . B.readInt <$> B.getLine
    as <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    print $ maximum as - minimum as


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

using namespace std;

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

#define N 100010
#define M 200010
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n, k, arr[1010];
	
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	
	sort(arr, arr + n);
	
	int ans = 0;
	for(int i = 0; i < k; i++){
		ans += arr[i];
	}
	
	cout << ans << endl;
	
	return 0;
}

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

#define maxn 400005
#define mod 998244353

typedef pair<int, int> P;

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    int k;
    cin >> k;
    cout << a[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

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

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//comparision
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 (a>b) { a=b; return 1; } return 0; }

//pair
#define fir first
#define sec second
#define mp make_pair

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(long long a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

////////////////////

void Main() {
    //code here
    int n = gi, d = gi;
    print(ceil((double)n/(2*d+1)));
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>
#include <queue>
#include <functional>

using namespace std;
typedef long long int ll;
//考察が詰めきれず難しかった.
//クソコードにより添字地獄が発生して無限バグらせ死亡
int main(){

    string S;
    cin >> S;
    vector<pair<char, ll > > SS;
    char tmp = 'a';
    for(ll i = 0; i < 26; i++){
        SS.push_back(make_pair(tmp + i, 0));
    }

    for(ll i = 0; i < S.length(); i++){
        SS[S[i] - 97].second = -1;
    }

    //何が使えるか
    priority_queue<char, vector<char>, greater<char > > que;
    for(ll i = 0; i < SS.size(); i++){
        if(SS[i].second != -1) {
            que.push(SS[i].first);
        }
    }

    //26文字以下なら使っていないやつの中で最小を取り出す
    if(S.length() < 26){
        cout << S << que.top() << endl;
        return 0;
    }

    //後ろから２文字比較していって左(j-1)が右(j)より小さければj-1以上でまだ辞書順
    //で大きいものを採用できる.
    //j-1以上の文字でj-2の文字より辞書順で大きく，一番小さいのを選んでやる
    ll j = S.length()-1;
    bool flg = false;
    while(j > 0){
        //降順
        if(S[j-1] > S[j]){
            que.push(S[j]);
            //cout << S[j] << endl;
        }else{
            //辞書順でもうこれ以上無理なとき
            flg = true;
            que.push(S[j]);
            break;
        }
        j--;
    }

    if(flg == false){
        cout << "-1" << endl;
    }else{
        for(ll i = 0; i < j - 1; i++){
            //cout << i << endl;
            cout << S[i];
        }
        //cout << S[j];
        while(!que.empty()){
            if((S[j - 1] >  que.top())){
                //cout << que.top() << endl;
                que.pop();
            }else{
                break;
            }
        }
        cout << que.top() << endl;
    }

} 

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

typedef long long LL;

int main () {
	string s;
	cin >> s;
	set<string> st;
	if (s.size()<100) {
		for (int i=0;s.size()>i;i++) {
			for (int j=i;s.size()>j;j++) {
				string t=s;
				reverse(t.begin()+i,t.begin()+j+1);
//				cout<<"i = "<<i<<" , j = "<<j<<" , t = "<<t<<" : ";
//				if (st.find(t) != st.end()) cout<<"old";
//				else cout<<"new";
				st.insert(t);
//				cout<<endl;
			}
		}
//		cout<<"tot = "<<st.size()<<endl;
		cout<<st.size()<<endl;
	}
	else {
		LL cnt[1234];
		memset(cnt,0,sizeof(cnt));
		for (int i:s) cnt[i]++;
		LL n=s.size();
		LL ans=(n+1)*n/2;
		for (LL i:cnt) {
			ans -= i*(i+1)/2;
		}
		cout<<ans+1<<endl;
	}
	
}


Measured memory_bytes: 644
#include <stdio.h>
int main(void){
  int n,m;
  int sum=0;
  int i;
  scanf("%d", &n); 
  scanf("%d", &m);
  int a[m];
  for (i=0; i<m; i++){
  scanf("%d", &a[i]);
        sum=sum+a[i];
  }
 if(sum<=n){
    printf("%d", n-sum);
  }
  else
    printf("%d", -1);
    
 return 0;
}
  


Measured memory_bytes: 1708
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int n, t;
    cin >> n >> t;
    vector<P> ti_ta(n);
    rep(i,n) cin >> ti_ta[i].first >> ti_ta[i].second;
    sort(ti_ta.begin(), ti_ta.end());

    vector<vector<int>> dp(n, vector<int>(t+1, 0));
    rep(i,t+1) {
        if (i >= ti_ta[0].first) dp[0][i] = ti_ta[0].second;
    }

    int ans = 0;
    rep(i,n) {
        rep(ti,t+1) {
            if(i == n-1) break;
            // i+1番目の食べ物を食べるときにi番目までの食べ物を食べるのにかかる時間
            int nti = ti - ti_ta[i+1].first;
            // もしi+1番目の食べ物を食べると制限時間内に食べ終わらないとき
            if (nti < 0) dp[i+1][ti] = dp[i][ti];
            // もしi+1番目の食べ物を食べないほうがいいときor食べたほうがいいとき
            else dp[i+1][ti] = max(dp[i][ti], dp[i][nti] + ti_ta[i+1].second);
        }
        int ans_tmp;
        if (i == 0) ans_tmp = ti_ta[0].second;
        else ans_tmp = dp[i-1][t-1] + ti_ta[i].second;
        ans = max(ans, ans_tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35584