akhauriyash/Code-Regression huggingface dataset:
N = int(input())

A = list(map(int, input().split()))
A.sort()
pA = []
nA = []
for a in A:
    if a < 0:
        nA.append(a)
    else:
        pA.append(a)

ans=[]
def calc():
    # pAもnAも長さが2以上ある場合
    if len(pA) > 0 and len(nA) > 0: 
        for i in range(len(pA) -1):
            ans.append([nA[0], pA[i]])
            nA[0] -=  pA[i]

        for i in range(len(nA) -1):
            ans.append([pA[-1], nA[-i-1]])
            pA[-1] -= nA[-i-1]

        ans.append([pA[-1], nA[0]])
        return pA[-1] - nA[0]
    elif not nA:
        for i in range(1,len(pA) -1):
            ans.append([pA[0], pA[i]])
            pA[0] -=  pA[i]

        ans.append([pA[-1], pA[0]])
        return pA[-1] - pA[0]
    elif not pA:
        for i in range(1,len(nA) -1):
            ans.append([nA[-1], nA[-i-1]])
            nA[-1] -=  nA[-i-1]

        ans.append([nA[-1], nA[0]])
        return nA[-1] - nA[0]


x = calc()

print(x)
for a in  ans:
    print(*a)

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

using namespace std;

int main(void)
{
    int N, D, X;
    cin >> N >> D >> X;
    int A[101];
    for(int i = 0; i < N; i++) cin >> A[i+1];

    int sum = X;
    for(int i = 0; i < N; i++){
        int j = 0;
        while(j * A[i+1] + 1 <= D) sum++, j++;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 998244353
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
  int res = 1;
  x = x % p;
  while (y > 0)
  {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res % p;
}
 
int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int tc;
  tc = 1;
  //cin >> tc;
  while (tc--)
  {
    int s, w;
    cin >> s >> w;
    if(s<=w){
      cout << "unsafe" << endl;
    }
    else{
      cout << "safe" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		ArrayList<Integer> small = new ArrayList();
		int answer = 1;

		for (int i = 0; i < N; i++) {
			int A = scan.nextInt();
			small.add(A);
		}

		Collections.sort(small);
		answer = gcd(small.get(0), small.get(1));

		if (small.size() > 2) {
			for (int i = 2; i < small.size(); i++) {
				answer = gcd(small.get(i), answer);
			}
		}
		System.out.println(answer);
	}

	public static int gcd(int A, int B) {
		int ans = 1;
		while ((ans = A % B) != 0) {
			A = B;
			B = ans;
		}
		if (ans == 0) {
			ans = B;
		}

		return ans;
	}
}

Measured memory_bytes: 60356
#include<bits/stdc++.h>
using namespace std;
char s[1002];
int w;
int main(){
    //ios::sync_with_stdio(false);
    scanf("%s",s);
    scanf("%d",&w);
    int len=strlen(s);
    for(int i=0;i<len;i+=w){
        printf("%c",s[i]);
    }
    return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    ld a,b;
    cin >> a>>b;
    int res= round(a*b*100.0);
    cout << res/100 << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <complex>
#include <cstdio>
#include <iomanip>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = (1e-10);    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

namespace std {
  bool operator<(const P a, const P b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

// 内積　dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積　cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
  return (conj(a)*b).Y;
}

int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

bool isecLP(P a1, P a2, P b) {
  return abs(ccw(a1, a2, b)) != 1;
}

bool isecLL(P a1, P a2, P b1, P b2) {
  return !isecLP(a2-a1, b2-b1, 0) || isecLP(a1, b1, b2);
}

VP convexHull(VP &ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  VP ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;  // 余計な点も含むなら == -1 とする
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

int main() {
  int n;
  while (true) {
    cin >> n;
    if (n == 0) break;

    VP ps(n);
    for (int i = 0; i < n; i++) {
      D x, y;
      scanf("%lf,%lf", &x, &y);
      ps[i] = P(x, y);
    }
    std::cout << n-convexHull(ps).size() << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    map<int, int> mp;
    map<int, int> mp2;

    for(int i=0; i<N; i++){
        int d; cin >> d;
        mp[d]++;
    }

    int M; cin >> M;
    for(int i=0; i<M; i++){
        int t; cin >> t;
        mp2[t]++;
    }

    bool flg = true;
    for(auto itr=mp2.begin(); itr!=mp2.end(); itr++){
        if(itr->second > mp[itr->first]) flg = false;
    }

    if(flg) cout << "YES" << endl;
    else cout << "NO" << endl;
    
}

Measured memory_bytes: 18944
import java.util.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		int sum = 0;
		for(int i = 0; i < 10; i++){
			int t = in.nextInt();
			sum += t;
		}
		System.out.println(sum);
	}

	

}

Measured memory_bytes: 26304
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int a, b; cin >> a >> b;
	if (a >= 13)cout << b << endl;
	else if (a >= 6)cout << b / 2 << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		String[] array = s.split(" ");
		String a = array[0];
		String b = array[1];

		if (a.equals("H")) {
			if (b.equals("H")) {
				System.out.println("H");
			} else {
				System.out.println("D");
			}
		} else if (a.equals("D")) {
			if (b.equals("H")) {
				System.out.println("D");
			} else {
				System.out.print("H");
			}

		}
	}
}


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

int main(){
  string s;
  cin >> s;
  
  long long k=0;
  long long ans=0;
  
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='B') k++;
    else ans+=k;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 640
const main = (input: string) => {
  const lines = input.trim().split("\n")
  const countMap = new Map()
  let maxCount = 0

  lines.slice(1).forEach(S => {
    if (!countMap.has(S)) {
      countMap.set(S, 1);
    } else {
      countMap.set(S, countMap.get(S) + 1)
    }
    maxCount = Math.max(countMap.get(S), maxCount)
  })

  const answer = Array.from(countMap).filter(entry => entry[1] === maxCount).map(entry => entry[0]).sort()

  console.log(answer.join("\n"))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

template <unsigned m> struct Mint {
    Mint():val(0){}
    Mint(int raw):val((raw%m+m)%m){}
    Mint(long long raw):val((raw%m+m)%m){}
    Mint(unsigned raw):val(raw%m){}
    Mint(unsigned long long raw):val(raw%m){}
    friend Mint operator+(Mint a, Mint b) { return a.val + b.val; }
    friend Mint operator-(Mint a, Mint b) { return m + a.val - b.val; }
    friend Mint operator*(Mint a, Mint b) { return 1ll * a.val * b.val; }
    friend Mint operator/(Mint a, Mint b) { return a * qpow(b, m-2); }
    friend Mint& operator+=(Mint& a, Mint b) { return a = a + b; }
    friend Mint& operator-=(Mint& a, Mint b) { return a = a - b; }
    friend Mint& operator*=(Mint& a, Mint b) { return a = a * b; }
    friend Mint& operator/=(Mint& a, Mint b) { return a = a / b; }
    friend bool operator==(Mint a, Mint b) { return a.val == b.val; }
    friend bool operator!=(Mint a, Mint b) { return a.val != b.val; }
    friend ostream& operator<<(ostream& out, Mint x) { return out << x.val; }
    unsigned val;
};

using M = Mint<1'000'000'007>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto h = load<int>();
    auto w = load<int>();
    auto tile = loadMany<string>(h);
    auto dyn = vector<vector<M>>(h, vector<M>(w, 0));
    dyn[0][0] = 1;
    for (auto y=0; y<h; ++y) {
        for (auto x=0; x<w; ++x) {
            if (tile[y][x] == '.') {
                if (y > 0) dyn[y][x] += dyn[y-1][x];
                if (x > 0) dyn[y][x] += dyn[y][x-1];
            }
        }
    }
    cout << dyn[h-1][w-1] << '\n';
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

ll N, M;

int main(void){
    
    scanf("%lld %lld", &N, &M);
    ll st = M / 2;
    printf("%lld\n", (st <= N) ? st : (st - N) / 2 + N);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int m = 9,ans,sum;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	vector<int> A(5);


	REP(i,5){
		cin >> A[i];
		if(A[i] % 10 < m && A[i] % 10 != 0){
          m = A[i] % 10;
			ans = i;
		}
	}

	REP(i,5){
		if(i == ans) continue;
		sum += ((A[i] + 9) / 10) * 10;
	}

	cout << sum + A[ans] << endl;
  //cout << ans << endl;


}

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

int main(){
    string s;
    cin >> s;
    stack<char> st;
    rep(i, s.length()) {
        if ( st.empty() ) {
            st.push(s[i]);
        }
        else if ( st.top() == '0' && s[i] == '1' ) {
            st.pop();
        }
        else if ( st.top() == '1' && s[i] == '0' ) {
            st.pop();
        } 
        else {
            st.push(s[i]);
        }
    }
    cout << s.size() - st.size() << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b;
string c;
cin >> a >> b;
vector<string> v(a);
 for(int i=0;i<a;i++){
   cin >> c;
  v.at(i) = c; 
 }
  for(int i=0;i<b+2;i++){
    cout << '#';
  }
  cout << "" << endl;
  for(int i=0;i<a;i++){
    cout << '#' << v.at(i) << '#' << endl;
  }
  for(int i=0;i<b+2;i++){
    cout << '#';
  }
}

Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int temp = a;
		a = b;
		b = temp;
		
		temp = a;
		a = c;
		c = temp;
		System.out.println(a + " " + b + " " + c);
	}

	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

}


Measured memory_bytes: 21204
### constant

ROPE2 = 50 * 50

### main

while true
  n = gets.strip.to_i
  break if n == 0

  bldgs = []
  bids = {}

  (0...n).each do |i|
    b, x, y = gets.strip.split(' ').map{|s| s.to_i}
    bldgs[i] = [b, x, y]
    bids[b] = i
  end

  edges = Array.new(n){Array.new(n){nil}}

  for i in (0...n)
    bi, xi, yi = bldgs[i]
    for j in ((i + 1)...n)
      bj, xj, yj = bldgs[j]
      d2 = (xi - xj) ** 2 + (yi - yj) ** 2
      if d2 <= ROPE2
        edges[i][j] = edges[j][i] = Math.sqrt(d2)
      end
    end
  end

  nbrs = Array.new(n){[]}

  for i in (0...n)
    nbrs[i] = (0...n).select{|j| ! edges[i][j].nil?}
  end

  m = gets.strip.to_i

  m.times.each do
    s, g = gets.strip.split(' ').map{|s| s.to_i}

    dist = (0...n).map{Float::INFINITY}
    dist[bids[s]] = 0.0
    prev = []
    queue = (0...n).map{|i| i}

    while ! queue.empty?
      u = queue.min{|a, b| dist[a] <=> dist[b]}
      queue.delete u

      for v in nbrs[u]
        ndist = dist[u] + edges[u][v]
        if dist[v].nil? || dist[v] > ndist
          dist[v] = ndist
          prev[v] = u
        end
      end
    end

    v = bids[g]
    if dist[v] == Float::INFINITY
      puts "NA"
    else
      rt = []
      while ! v.nil?
        rt << bldgs[v][0]
        v = prev[v]
      end

      puts rt.reverse.join(' ')
    end
  end
end

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


def dfs(s):
    if int(s) > N:
        return 0
    ret = 0
    for c in '753':
        ret += dfs(s+c)
    if '3' not in s or '5' not in s or '7' not in s:
        return ret
    return ret+1


print(dfs('0'))


Measured memory_bytes: 3316
//object C {
object Main {
  import InOut._
  def main(args: Array[String]): Unit = {

    val n, m, k = nextInt
    val as = nextInts(n)
    val bs = nextLongs(m)
    val bSums = bs.scan(0L)(_ + _)

    @annotation.tailrec
    def binSearch(low: Long, hi: Long, limit: Long): Long = {
      if (hi < low) low
      else {
        val mid = (low + hi) / 2
        if (bSums(mid.toInt) > limit) binSearch(low, mid - 1, limit)
        else binSearch(mid + 1, hi, limit)
      }
    }
//println(bSums.mkString(" "))
    var aSum = 0L
    var max = binSearch(0, m, k) - 1
    for (i <- as.indices) {
      aSum += as(i)
      if (aSum <= k) {
        val j = binSearch(0, m, k - aSum)
//        println(i, aSum, j, k - aSum)
//        if (j < m && bSums(j.toInt) > k - aSum) j -= 1
        val x = i + j
        if (x > max) {
          max = x
        }
      }
    }

    out.println(max)

    out.flush()
  }
 
  final object InOut {
    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)
    private[this] var tokenizer: java.util.StringTokenizer = _
    def nextToken: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new java.util.StringTokenizer(in.readLine)
      tokenizer.nextToken
    }
    def nextInt = Integer.parseInt(nextToken)
    def nextLong = java.lang.Long.parseLong(nextToken)
    def nextBig = BigInt(nextToken)
    def nextInts(n: Int) = Array.fill(n) { nextInt }
    def nextLongs(n: Int) = Array.fill(n) { nextLong }
    def nextBigs(n: Int) = Array.fill(n) { nextBig }
    def nextLine = in.readLine
  }
}


Measured memory_bytes: 79704
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	lint x,y,out=1145141919810893LL;
	cin>>x>>y;
	if(y>=x) out=min(out,y-x);
	if(y>=-x) out=min(out,1+y-(-x));
	if(-y>=x) out=min(out,1+(-y)-x);
	if(-y>=-x) out=min(out,2+(-y)-(-x));
	cout<<out<<endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

long long INF=numeric_limits<long long>::max();

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans;
    if(k%2==0)ans = a-b;
    else ans = b-a;
    ll check = abs(ans);
    if(check>1e18)cout << "Unfair" << endl;
    else cout << ans << endl;
}



Measured memory_bytes: 256
N, M = gets.split.map(&:strip).map(&:to_i)

A = []
B = []

M.times do
  a, b = gets.split.map(&:strip).map(&:to_i)
  A << a
  B << b
end

gs = {}
@dg = {}
g = 0
mn = 1

M.times do |i|
  a = A[i]
  b = B[i]
  if !gs[a]
    if !gs[b]
      g += 1
      gs[a] = g
      gs[b] = g
    else
      gs[a] = gs[b]
    end
  else
    if !gs[b]
      gs[b] = gs[a]
    else
      if gs[a] != gs[b]
        @dg[gs[a]] ||= {}
        @dg[gs[a]][gs[b]] = gs[b]
        @dg[gs[b]] ||= {}
        @dg[gs[b]][gs[a]] = gs[a]
      end
    end
  end
end

def ag(g, ng)
  return if @rg[g]
  @rg[g] = ng
  @dg[g].each do |a, _|
    ag(a, ng)
  end
end

@rg = {}
ng = g
(1..g).each do |g|
  next if @rg[g]
  if sg = @dg[g]
    ng += 1
    ag(g, ng)
  else
    @rg[g] = g
  end
end

m = 1
c = {}
gs.each do |_, g|
  gg = @rg[g]
  c[gg] ||= 0
  c[gg] += 1
  if c[gg] > m
    m = c[gg]
  end
end

# puts gs.inspect
# puts @dg.inspect
# puts @rg.inspect
puts m


Measured memory_bytes: 64672
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod = 1'000'000'007;
const int INF = 1e9;

vi dp(100010, INF);

int rec(int n){
    if (dp[n] != INF) return dp[n];
    if (n == 0) return 0;
    int res = INF;
    res = min(res, rec(n-1)+1);
    for (int i=6; i<=n; i*=6){
        res = min(res, rec(n-i)+1);
    }
    for (int i=9; i<=n; i*=9){
        res = min(res, rec(n-i)+1);
    }
    return dp[n] = res;
}

int main(){
    int n;
    cin >> n;
    cout << rec(n) << endl;
    return 0;
}


Measured memory_bytes: 8324
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAXN 404
int N;
int A[MAXN];
llong PS[MAXN];
llong sum(int L, int R) {
   return PS[R] - PS[L-1];
}

const llong INF = 1e18 + 1e9 + 1;
llong memo[MAXN][MAXN];
// go(L, R): min cost of merging slimes from L to R into a single slime
llong go(int L, int R) {
   if (L == R)
      return 0;
   llong& res = memo[L][R];
   if (res < 0) {
      res = INF;
      FOR(j, L+1, R) {
         // split between j-1 and j
         llong cur = go(L, j-1) + go(j, R) + sum(L, j-1) + sum(j, R);

         res = min(res, cur);
      }
   }
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   cin >> N;
   FOR(i, 1, N)
      cin >> A[i];

   FOR(i, 1, N)
      PS[i] = PS[i-1] + A[i];

   memset(memo, -1, sizeof(memo));
   llong res = go(1, N);
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 1536
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

string S;
signed main(){
    cin >> S;
    int ans = 0;
    rep(i, S.size()/2){
        if(S[i] != S[S.size()-1-i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//validate by AOJ 2397
#include <bits/stdc++.h>
using namespace std;
typedef int elm;
typedef vector<elm> vec;
typedef vector<vec> mat;

bool gauss_jordan(const mat &A, const vec &b) {
  int n = A.size();
  mat B(n, vec(n+1));
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < n; ++j) {
      B[i][j] = A[i][j];
    }
  }

  for(int i = 0; i < n; ++i) B[i][n] = b[i];

  for(int i = 0; i < n; ++i) {
    int pivot = i;
    for(int j = i; j < n; ++j) {
      if(abs(B[j][i]) > abs(B[pivot][i])) pivot = j;
    }
    swap(B[i], B[pivot]);

    if(B[i][i] == 0) continue;

    //for(int j = i+1; j <= n; ++j) B[i][j] /= B[i][i];
    for(int j = 0; j < n; ++j) {
      if(i != j) {
        for(int k = i + 1; k <= n; ++k) {
          B[j][k] -= B[j][i] * B[i][k];
          B[j][k] = (B[j][k] % 2 + 2) % 2;
        }
      }
    }
  }
  for(int i = 0; i < n; ++i) {
    if(B[i][i] == 0 && B[i][n] != 0) return false;
  }
  return true;
}

int main() {
  for(int c, r, d; cin >> c >> r >> d && (c|r|d); ) {
    mat S(r, vector<elm>(c));
    for(int i = 0; i < r; ++i) {
      for(int j = 0; j < c; ++j) {
        cin >> S[i][j];
      }
    }
    mat T(r*c, vector<elm>(r*c));
    for(int i = 0; i < r; ++i) {
      for(int j = 0; j < c; ++j) {
        for(int ti = 0; ti < r; ++ti) {
          for(int tj = 0; tj < c; ++tj) {
            int dist = abs(ti - i) + abs(tj - j);
            T[ti*c+tj][i*c+j] = (!dist || dist == d);
          }
        }
      }
    }
    vec b(r*c);
    for(int i = 0; i < r; ++i) {
      for(int j = 0; j < c; ++j) {
        b[i*c+j] = S[i][j];
      }
    }
    cout << gauss_jordan(T, b) << endl;
  }
  return 0;
}

Measured memory_bytes: 4244
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s,t; cin >> s >> t;
  string ans;
  for(int i = 0; i < (int)t.length() - 1; i++)
    ans += t[i];
   if(s == ans)
     cout << "Yes\n";
    else
      cout << "No\n";
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{	
	int n, a[100];
	cin >> n;
	for (int i = 0;i < n;i ++)
		cin >> a[i];

	cout << a[n - 1];
	for (int i = n - 2;i >= 0;i--)
		cout << " " << a[i];

	cout << endl;

	return 0;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e6 + 6;
int A[N];
int dp[N];
int n;


void solve()
{
    cin >> n;

    loop(i,1,n+1)cin >> A[i];

    loop(i,0,n+1)dp[i] = inf;

    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(A[2] - A[1]); 

    for(int i = 3; i  <= n; i++)
    {
        dp[i] = min(dp[i-1] + abs(A[i]-A[i-1]),
                dp[i-2] + abs(A[i] - A[i-2]));
    }

    cout << dp[n];
}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

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

     int t = 1;
     // cin >> t;
     while(t--)solve();
  
}

Measured memory_bytes: 5120
//看劳资手打一遍过
#include<bits/stdc++.h>
using namespace std;

int Solve(int x, int y)
{
if (!(x % y)) return x / y;
int v=x/y+1;
return Solve(x-max(x%y/v,1)*v,y);
}

int main()
{
int Ans = 0, n, x, y;
scanf("%d", &n);
while (n --) {
scanf("%d%d", &x, &y);
Ans ^= Solve(x, y);
}
if (Ans) puts("Takahashi");else puts("Aoki");
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	int x;
	long double h;
};

long double calc(long double tmp_x,long double tmp_distance){
	return sqrt(tmp_x*tmp_x + (tmp_distance/(2*tmp_x))*(tmp_distance/(2*tmp_x)));
}

int main(){

	double distance;
	int N,bounce_limit;

	scanf("%lf %d %d",&distance,&N,&bounce_limit);

	Info info[N];

	for(int i = 0; i < N ;i++){
		cin >> info[i].x >> info[i].h;
	}

	long double tmp_distance;

	long double ans = 1000000.0;
	long double left,right,m,tmp_x,max_x,tmp_y,tmp_dist,tmp_h;

	bool FLG;

	for(int b_count = 1; b_count <= bounce_limit+1; b_count++){

		tmp_distance = (double)distance/b_count;

		left = 0.0,right = DBL_MAX,m = (left+right)/2;

		int count = 0;

		while(count < 5000){

			tmp_x = m;
			tmp_y = tmp_distance/(2*tmp_x);

			FLG = true;

			for(int i = 0; i < N; i++){
				tmp_dist = info[i].x;

				while(tmp_dist >= tmp_distance)tmp_dist -= tmp_distance;

				tmp_h = (-1.0/(2*tmp_x*tmp_x)*(tmp_dist*tmp_dist))+(tmp_y/tmp_x)*tmp_dist;

				FLG &= (info[i].h <= tmp_h);
			}
			if(FLG){
				left = m;
			}else{
				max_x = m;
				right = m;
			}
			m = (left+right)/2;
			count++;
		}

		ans = min(ans,calc(max_x,tmp_distance));

		left = 0.0,right = max_x;

		count = 0;

		while(count < 30){
			long double mid1 = left + (right-left)/3;
			long double mid2 = left + (right-left)/3*2;

			long double v_1 = calc(mid1,tmp_distance);
			long double v_2 = calc(mid2,tmp_distance);

			ans = min(ans,min(v_1,v_2));

			if(v_1 < v_2){
				right = mid2;
			}else{
				left = mid1;
			}
			count++;
		}
	}

	printf("%.12Lf\n",ans);

	return 0;
}

Measured memory_bytes: 3244
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
ll dp[200001][2];
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string t;
    cin>>t;
    for(int i = 0; i < t.length(); i++) {
    	if(t[i] == '?') {
    		t[i] = 'D';
    	}
    }
    cout<<t<<"\n";
}	

Measured memory_bytes: 3784
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int x[5], cou = 0, i;

    for(i = 0; i< 5; i++){
        cin >> x[i];
    }

    for(i = 0; i< 5; i++){
        cou++;
        if(x[i] == 0)
            break;
    }

    cout << cou << endl;

    return 0;
}


Measured memory_bytes: 3576
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;

long long int mod(long long int a,long long int b){
    a=a%1000000007;
    b=b%1000000007;
    return (a*b)%1000000007;
}

int main() {
    long long int n,m;cin>>n>>m;
    long long int A[n],B[m];
    long long int k;cin>>k;
    for(long long int i=1;i<=n-1;i++){
        long long int b;cin>>b;
        A[i]=b-k;
        k=b;
    }
    long long int aa;cin>>aa;
    for(long long int i=1;i<=m-1;i++){
        long long int b;cin>>b;
        B[i]=b-aa;
        aa=b;
    }
    long long int a[n],b[m];
    for(int i=1;i<=n-1;i++){
        a[i]=i*(n-i);
    }
    for(int i=1;i<=m-1;i++){
        b[i]=i*(m-i);
    }
    long long int x=0,y=0;
    for(int i=1;i<=n-1;i++){
        x=x+A[i]*a[i];
    }
    for(int i=1;i<=m-1;i++){
        y=y+B[i]*b[i];
    }
    long long int ans=mod(x,y);
    printf("%lld",ans);
    
    
    return 0;
}

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


int X[1010];
vector<int> ch[1010];

pair<int,int> dfs(int root){
	vector<int> dp(5010, 1e9);

	dp[0] = 0;
	for(int c : ch[root]){
		vector<int> ndp(5010, 1e9);
		int w,b;
		tie(w,b) = dfs(c);
		for(int i = 5000 ; i >= X[c] ; i--){
			ndp[i] = min(ndp[i], dp[i-X[c]] + w);
		}
		for(int i = 5000 ; i >= b ; i--){
			ndp[i] = min(ndp[i], dp[i-b] + X[c]);
		}
		dp = ndp;
	}
	int minB = 1000000000, minW = 1000000000;
	for(int i = 0 ; i <= X[root] ; i++)
		minW = min(dp[i], minW);
	

	for(int i = 0 ; i <= 5000 ; i++)
		if( dp[i] <= X[root] ){
			minB = min(i, minB);
		}
	return make_pair(minW, minB);
}

int main(){
	int N;
	cin >> N;
	for(int i = 1 ; i < N ; i++){
		int p;
		cin >> p;
		ch[--p].push_back(i);
	}
	for(int i = 0 ; i < N ; i++) cin >> X[i];

	auto p = dfs(0);
	int mn = min(p.first,p.second);
	if( mn < 1e9 ) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int a, b, c, d; std::cin >> a >> b >> c >> d;
  bool turn = true;
  while (a > 0 && c > 0) {
    if (turn) c -= b;
    else a -= d;
    turn ^= 1;
  }
  std::cout << (a > 0 ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int X;
    cin >> X;

    int a, b, r;
    a = X / 500;
    r = X - (500 * a);
    b = r / 5;

    LL ans = 1000 * a + 5 * b;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

int main(){
    int N,W,H;
    cin >> N >> W >> H;
    
    vector<P> X(N);
    vector<P> Y(N);
    rep(i,N){
        int x,y,w;
        cin >> x >> y >> w;
        X[i] = {max(x-w, 0), min(x+w, W)};
        Y[i] = {max(y-w, 0), min(y+w, H)};
    }
    sort(all(X));
    sort(all(Y));
    int minX = X[0].first, minY = Y[0].first;
    int maxX = X[0].second, maxY = Y[0].second;
    rep(i,N){
        if(minX <= X[i].first && X[i].first <= maxX) maxX = max(maxX, X[i].second);
        if(minY <= Y[i].first && Y[i].first <= maxY) maxY = max(maxY,Y[i].second);
    }

    if((minX == 0 && maxX == W) || (minY == 0 && maxY == H)) cout << "Yes" << endl;
    else cout << "No" << endl;
}



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


int main(){
	int n,p; 
	cin>>n>>p; 
	int a[n];
	int b=0,c=0;
	for(int i=0;i<n;i++){
	    cin>>a[i];
	    if(a[i]%2==0) b++;
	    else c++;
	}
	long long ans;
	if(c==0){
	    if(p==0) ans=pow(2,n);
	    else ans=0;
	}
	else{
	    ans=pow(2,n-1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
if n>=3 and m>=3:
    print((m-2)*(n-2))
elif n>=3 and m==2:
    print(0)
elif n>=3 and m==1:
    print(n-2)
elif n==2 and m>=3:
    print(0)
elif n==1 and m>=3:
    print(m-2)
elif m==1 and n==1:
    print(1)
else:
    print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

signed main() {
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i,n) cin >> b[i];
    deque<int> c;
    int cnt = 0;
    rep(j,n) {
        int id = n-1-j;
        //cout << "id "<<id << endl;
        rrep(i,n) {
            if(b[i]==-1) continue;
            if(b[i]==id+1) {
                b[i]=-1;
                c.push_front(id+1);
                cnt++;
                break;
            }
            id--;
        }
    }
    if(cnt!=n) cout << -1 << endl;
    else {
        rep(i,n)cout << c[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

int main() {
    string s;
    cin >> s;
    map<char, int> mp;
    for (int i = 0; i < 4; i++) mp[s[i]]++;
    bool cnt = true;
    for (auto v : mp) {
        if (v.se != 2) cnt = false;
    }
    dump(cnt ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
using namespace std;



int main(){
ll N,D;
cin>>N>>D;
ll jj = 1+2*D;
if(N%jj==0)
cout<<N/jj<<endl;
else
cout<<(N/jj)+1<<endl;
return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

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

const ll MOD = ll(1e9) + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = ll(1e5) + 5;
const double EPS = 10e-8;
const double PI = 3.14159265359;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

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

int main() {
    int n, cnt[3]{};
    cin >> n;
    REP(i, n) {
        int a;
        cin >> a;
        if (a % 4 == 0)
            cnt[2]++;
        else if (a % 2 == 0)
            cnt[1]++;
        else
            cnt[0]++;
    }
    if (cnt[0] <= cnt[2] || cnt[0] - 1 == cnt[2] && cnt[1] == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

static const ll INF = 20000000000;



int main(){
    ll a,b,q;
    cin >> a>> b>> q;
    vector<ll> s(a+2), t(b+2);
    s[0]=-1*INF;
    t[0]=-1*INF;
    
    rep2(i,a) cin >> s[i];
    rep2(i,b) cin >> t[i];
    s[a+1]=INF;
    t[b+1]=INF;
    //２分対策でまず場所を考える
    rep2(i,q){
        ll res=INF;
        ll x;
        cin >> x;
        //sort(s.begin(),s.end());//sortしてないとupperboundは使えないこともある　　というか並ばせとけ
        //sort(t.begin(),t.end());

        ll shrine=upper_bound(s.begin(),s.end(),x)-s.begin();//upper_bound ２分探索ライブラリ　探索したいkeyより大きいイテレータを返す//イテレータとはポイントで、begin()は一番左のポインタのことなので要するに何-1番目の神社かを示している。
        ll temple=upper_bound(t.begin(),t.end(),x)-t.begin();

        res=min(res,min(abs(t[temple]-x),abs(s[shrine]-x))+abs(t[temple]-s[shrine]));//両方xより大きい方に行った。
        res=min(res,min(abs(t[temple-1]-x),abs(s[shrine]-x))+abs(t[temple-1]-s[shrine]));
        res=min(res,min(abs(t[temple]-x),abs(s[shrine-1]-x))+abs(t[temple]-s[shrine-1]));
        res=min(res,min(abs(t[temple-1]-x),abs(s[shrine-1]-x))+abs(t[temple-1]-s[shrine-1]));

        cout<<res<<endl;
    }
}

Measured memory_bytes: 2944
use std::io::*;
use std::str::FromStr;
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
#[allow(non_snake_case, unused_variables)]
fn main() {
    let H: u8 = read();
    let W: u8 = read();
    let mut S: Vec<Vec<String>> = Vec::new();
    for i in 0..H {
        S.push((0..W).map(|_| read()).collect());
    }
    for i in 0..H {
        for j in 0..W {
            if S[i as usize][j as usize]=="snuke" {
                println!("{}{}", (j+'A' as u8) as char, i+1);
            }
        }
    }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    map<ll, ll> cnt;
    rep(i, n){
        ll a; cin >> a;
        cnt[a]++;
    }
    ll ans = cnt.size();
    cout << ((ans%2 == 0) ? ans-1 : ans) << endl;
}

Measured memory_bytes: 6528
let gcd (m, n) =
  let rec doit x y =
    if y <= 0 then x else doit y (x mod y) in
  doit (max m n) (min m n)

let () =
  Scanf.scanf "%d %d\n" (fun a b -> (a, b)) |> gcd |> Printf.printf "%d\n"

Measured memory_bytes: 2388
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main()
{
    int N, M, sum;
    cin >> N >> M;
    std::vector<long> v(N), ans(N,1);

    for(int i = 0; i < N; i++){
        long H; cin >> H;
        v[i] = H;
    }
    for(int i=1; i <= M; i++){
        int A, B;   cin >> A >> B;
        if(v[A-1] > v[B-1]){
            ans[B-1] = 0;
        }else if(v[A-1] < v[B-1]){
            ans[A-1] = 0;
        }else{
            ans[A-1] = 0;
            ans[B-1] = 0;
        }
    }
    sum = 0;
    for(int i=0;i<N; i++){
        sum += ans[i];
    }
    
    cout << sum;
}

Measured memory_bytes: 4824
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int i, len = 0, flag = 0, count = 0;
	char ch[200000];

	scanf("%s", ch);
	for (i = 0; (ch[i] != '\0'); i++) {
		len++;
	}
	for (i = 0; i < len; i++) {
		if (ch[i] == 'T') {
			if(flag!=0){
				flag--;
			}else{
				count++;
			}
		}
		if (ch[i] == 'S') {
			flag++;
		}
	}

	printf("%d\n", count+flag);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
 

 

int main()
{
int F[44];
int n,i,total;
F[0]=1;
F[1]=1;
 
scanf("%d",&n);
 
for(i=2;i<n+2;i++)
{
 F[i] = F[i-2] + F[i-1];
}
 
printf("%d\n",F[n]);
return 0;
 
}
 
 

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define NMAX 2000
#define MOD 1000000007
#define INF 2000000000

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)

using namespace std;

int a, b;

int main()
{
	cin >> a >> b;
	if ((a + b) % 2 == 1)
		cout << "IMPOSSIBLE\n";
	else
		cout << (a + b) / 2 << '\n';
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {


        static void Main(string[] args)
        {
            int.Parse(Console.ReadLine());
            long[] nums = Array.ConvertAll(
                Console.ReadLine().Split(' '),
                new Converter<string,long>( s => long.Parse(s) ));

            Console.WriteLine("{0} {1} {2}",
                nums.Min(),
                nums.Max(),
                nums.Sum()
                );
        }
    }
}

Measured memory_bytes: 10352
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <list>
#include <cstring>
#include <stdio.h>
using namespace std;

int n, q;
int nList[20];
int qList[200];

bool solve(int i, int m){
	if (m == 0) return true;
	else if(i >= n) return false;

	bool ret;
	ret = solve(i + 1, m) || solve(i + 1, m - nList[i]);

	return ret;
}


int main(){

	scanf("%d", &n);
	for(int i=0; i<n; ++i) scanf("%d", &nList[i]);

	scanf("%d", &q);
	for(int i=0; i<q; ++i) scanf("%d", &qList[i]);

	for(int i=0; i<q; ++i){
		if (solve(0, qList[i])){
			cout << "yes" << endl;
		}
		else{
			cout << "no" << endl;
		}
	}

	return 0;
}



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

int main() {
  string S; cin >> S;
  int ans=0;
  for(int i=0; i<3; i++) {
    if(S.at(0)=='R' && S.at(1)=='R' && S.at(2)=='R') ans=3;
    else if(S.at(0)=='R' && S.at(1) =='R') ans=2;
    else if(S.at(1)=='R' && S.at(2)=='R') ans=2;
    else if(S.at(0) =='S' && S.at(1)=='S' && S.at(2)=='S') ans=0;
    else ans =1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        int i = 1;
        while ((line = br.readLine()) != null) {
            
            int num = Integer.parseInt(line);
            if (num == 0) {
                break;
            }
            System.out.println("Case "+ i++ +": "+ num);
        }
    }
}



Measured memory_bytes: 31976
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    set<ll> s;
    rep(i,n){
        ll a;
        cin>>a;
        s.insert(a);
    }
    if(s.size()==n) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 12968