akhauriyash/Code-Regression huggingface dataset:
import sys


class UnionFind(object):
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        if self.par[x] != x:
            self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def is_same_group(self, x, y):
        return self.find(x) == self.find(y)

    def get_group_num(self):
        return sum([1 if self.par[i] == i else 0 for i in range(len(self.par))])


N, M = map(int, sys.stdin.readline().split())
uf = UnionFind(N)
for _ in range(M):
    x, y, z = map(int, sys.stdin.readline().split())
    x -= 1
    y -= 1
    uf.unite(x, y)

print(uf.get_group_num())


Measured memory_bytes: 74416
package main

import "fmt"

// 2018-08-02T22:04:07+0800
// 2018-08-02T22:14:13+0800
func main() {
	var N int
	fmt.Scanf("%d", &N)
	a := make([]int, N)
	aa := make([]int, N)
	ii := 0
	fmt.Scanf("%d", &a[0])
	aa[0] ++
	for i := 1; i < N; i++ {
		fmt.Scanf("%d", &a[i])
		if a[i] != a[i-1] {
			ii++
		}
		aa[ii]++
	}
	out := 0
	for i := 0; i <= ii; i++ {
		out += aa[i] / 2
	}
	fmt.Println(out)
}

Measured memory_bytes: 512
N = str(input())
K = int(input())
# dp[i][j][k] :=  i桁目まで決めたとき、非ゼロの個数がj個で、
# k->0: そこまでの桁はNと完全一致, k->1: そこまでの桁ですでにN未満であることが確定
# しているときのパターン数
# kは0or1の二通り, jは0~KのK+1通り, iは0~NのN+1通り
dp = [[[0]*2 for _ in range(K+1)] for _ in range(len(N)+1)]
dp[0][0][0] = 1
for i in range(len(N)):
    x = int(N[i])  # Nは文字列であることに注意
    for j in range(K):
        dp[i+1][j+1][1] += dp[i][j][1]*9  # すでにN未満が確定している世界線で、jの数を増やすから9倍される
        dp[i+1][j][1] += dp[i][j][1]  # すでにN未満が確定している世界線で、jの数は変えない
        if x > 0:
            dp[i+1][j][1] += dp[i][j][0]  # 新しい桁に0を埋め込んで、N以下になる道を選んだ世界線
            dp[i+1][j+1][1] += dp[i][j][0]*(x-1)  # 新しい桁に1~(x-1)のx-1通りを埋め込んでN以下になる道を選んだ世界線
            dp[i+1][j+1][0] += dp[i][j][0]  # 新しい桁にxを埋め込んでNのままであり続ける世界線
        else:
            dp[i+1][j][0] += dp[i][j][0]  # xが0の時は、Nのままであり続ける世界線は0しか入れようがない
    dp[i+1][K][1] += dp[i][K][1]
    dp[i+1][K][x>0] += dp[i][K][0]
print(sum(dp[len(N)][K]))


Measured memory_bytes: 3064
#include<stdio.h>
int smallSum(int n);

int main(void)
{
  int n = 0;
  int a, b  = 0;
  int ans, sum = 0;
  int cv = 1;

  scanf("%d%d%d", &n, &a, &b);

  while(cv <= n){
    ans = smallSum(cv);
    if(a<=ans && ans<=b){
      sum += cv;
    }
    cv++;
  }
  printf("%d\n", sum);
  return 0;
}

int smallSum(int n)
{
  int sum = 0;
  while(n > 0){
    sum += n%10;
    n /= 10;
  }

  return sum;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
ll h;
int main(){
    cin>>h;
    int t=0;
    while(h>0){
        h/=2;
        t++;
    }
    printf("%lld",(long long)(pow(2,t)-1));
}

Measured memory_bytes: 256
import heapq

N,M = map(int, raw_input().split())
A = list(map(lambda x: int(x)*(-1), raw_input().split()))

heapq.heapify(A)

for i in range(0,M):
  max_A = heapq.heappop(A)*(-1) / 2*(-1)
  heapq.heappush(A,max_A)

print sum(A)*(-1)


Measured memory_bytes: 11464
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

namespace {

// Array to store the answers
static int a[24] = {-1};

class Dice {
 public:
  Dice(const int* face) { copy(face, face + 6, face_); }

  void west() {
    const int t = face_[0];
    const int t2 = face_[3];
    face_[0] = face_[2];
    face_[2] = face_[5];
    face_[3] = t;
    face_[5] = t2;
  }

  void east() {
    const int t = face_[0];
    const int t2 = face_[2];
    face_[0] = face_[3];
    face_[2] = t;
    face_[3] = face_[5];
    face_[5] = t2;
  }

  void north() {
    const int t = face_[0];
    const int t2 = face_[4];
    face_[0] = face_[1];
    face_[1] = face_[5];
    face_[4] = t;
    face_[5] = t2;
  }

  void south() {
    const int t = face_[0];
    const int t2 = face_[1];
    face_[0] = face_[4];
    face_[1] = t;
    face_[4] = face_[5];
    face_[5] = t2;
  }

  int top() const { return face_[0]; }
  int front() const { return face_[1]; }
  int right() const { return face_[2]; }

 private:
  int face_[6];
};

struct PairHash {
  size_t operator()(const pair<int, int>& p) const {
    return (static_cast<size_t>(p.first) << 32) | p.second;
  }
};

void Walk(Dice& d,
          const std::string& ops,
          const unordered_map<pair<int, int>, int, PairHash>& m) {
  pair<int, int> p;
  for (auto op : ops) {
    if (!op)
      continue;
    switch (op) {
      case 'W':
        d.west();
        break;
      case 'E':
        d.east();
        break;
      case 'N':
        d.north();
        break;
      case 'S':
        d.south();
        break;
      default:
        fprintf(stderr, "ERROR: unsupported: [0x%x]\n", op);
        break;
    }
    p.first = d.top();
    p.second = d.front();
    auto it = m.find(p);
    if (it != m.end()) {
      a[it->second] = d.right();
    }
  }
}

}  // namespace

int main() {
  int face[6];
  int q;
  for (int i = 0; i < 6; ++i) {
    cin >> face[i];
  }
  cin >> q;
  const char ops[] = {'W', 'E', 'N', 'S'};

  unordered_map<pair<int, int>, int, PairHash> m;

  for (int i = 0; i < q; ++i) {
    pair<int, int> p;
    cin >> p.first >> p.second;
    m[p] = i;  // index to a
  }

  unordered_set<string> cache;
  char buf[5];
  for (auto op1 : ops) {
    for (auto op2 : ops) {
      for (auto op3 : ops) {
        for (auto op4 : ops) {
          for (auto op5 : ops) {
            snprintf(buf, sizeof(buf), "%c%c%c%c%c", op1, op2, op3, op4, op5);
            const string key(buf, 5);
            auto it = cache.find(key);
            if (it != cache.end())
              continue;

            Dice d(face);
            Walk(d, key, m);
            cache.insert(key);
          }
        }
      }
    }
  }

  for (int i = 0; i < q; ++i)
    cout << a[i] << endl;

  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int k;
    cin >> k;
    vector<int> ans;
    char now = s[0];
    int tmp = 0;
    for (int i = 0; i < s.size(); i++){
        if (now != s[i]){
            now = s[i];
            ans.push_back(tmp);
            tmp = 1;
        }
        else tmp++;
    }
    ans.push_back(tmp);
    long long a = 0;
    if (s[0] == s.back()){
        if (ans.size() == 1){
            a = ((long long)ans[0] * k) / 2;
        }
        else {
            a += (long long)(ans[0] / 2);
            a += (long long)(ans.back() / 2);
            a += (long long)((ans[0] + ans.back()) / 2) * (k - 1);
            for (int i = 1; i < ans.size() - 1; i++) {
                a += (long long)(ans[i] / 2) * k;
            }
        }
    }
    else {
        for (int i = 0; i < ans.size(); i++) {
            a += (long long)(ans[i] / 2) * k;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 256
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 110000
using namespace std;
struct node{int y,nex;}a[2*N];
int fir[N],len,n,m,now,A[N],num;
bool b[N];
void ins(int x,int y)
{
	a[++len].y=y;a[len].nex=fir[x];fir[x]=len;
}
void dfs(int x)
{
	if(now) A[++num]=x;
	for(int k=fir[x];k;k=a[k].nex)
	{
		int y=a[k].y;
		if(b[y]) continue;
		b[y]=1;dfs(y);
		break;
	}
	if(now==0) A[++num]=x;
}
int main()
{
	scanf("%d%d",&n,&m);
	int sx,sy;
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		sx=x;sy=y;
		ins(x,y);ins(y,x);
	}
	b[sx]=b[sy]=1;
	now=0;
	dfs(sx);
	now=1;
	dfs(sy);
	printf("%d\n",num);
	for(int i=1;i<=num;i++) printf("%d ",A[i]);
	return 0;
}

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

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		if(A>B) {
			A^=B;B^=A;A^=B;
		}
		pw.println(A<=C&&C<=B?"Yes":"No");
		pw.close();
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

Measured memory_bytes: 21204
#include<iostream>
using namespace std;
int main()
{
string s;
cin>>s;
int i=0,j=0;
for(;s[i]!='A';++i){
}
	for(j=s.length();s[j]!='Z';j--){
	}
	
	
j++;

     cout<<j-i<<"\n";
 return 0;
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
	N := getStdinInt64()
	A := getStdinIntArr64()
	var i int64 = 0
	//var j int64 = 0
	//var cnt int64 = 0
	var max int64 = 0

	// 最大値を求める
	for i = 0; i < N; i++ {
		if A[i] > max {
			max = A[i]
		}
	}

	// 素数を求める
	isPrime := make([]bool, max+1)
	for i := 2; i < len(isPrime); i++ {
		isPrime[i] = true
	}
	isPrime[0] = false
	isPrime[1] = false
	for i := 2; i < len(isPrime); i++ {
		if isPrime[i] {
			for j := i * 2; j < len(isPrime); j += i {
				isPrime[j] = false
			}
		}
	}

	// 個数
	countMap := make(map[int64]int64)
	for _, a := range A {
		countMap[a]++
	}

	// 1が1個、または1が2個以上の場合
	if countMap[1] == 1 {
		// x % 1 == 0のみ
		fmt.Printf("%d\n", 1)
		return
	}
	if countMap[1] >= 2 {
		// 全てが x % 1 == 0 になってしまう
		fmt.Printf("%d\n", 0)
		return
	}

	var ans int64 = 0
	for _, a := range A {
		if countMap[a] >= 2 {
			// x % x == 0 になってしまう
			continue
		}
		if isPrime[a] {
			// 素数なので明らか
			ans++
			continue
		}

		// 素因数分解
		fac := make([]int64, 0)
		for i = 2; i*i <= a; i++ {
			if a%i == 0 {
				fac = append(fac, i)
				if i*i != a {
					fac = append(fac, a/i)
				}
			}
		}

		flag := true
		for _, f := range fac {
			if countMap[f] >= 1 {
				flag = false
				break
			}
		}
		if flag {
			ans++
		}
	}

	fmt.Printf("%d\n", ans)
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func gcdimpl(n, m int64) int64 {
	var i int64 = 0
	for i = 0; i < 10; i++ {
		var t int64 = n - m
		q := false
		if m > t {
			q = true
		}
		if q {
			n = m
		} else {
			n = t
		}
		if q {
			m = t
		} else {
		}
		if m == 0 {
			return n
		}
	}
	return gcdimpl(m, n%m)
}

func gcd(n, m int64) int64 {
	if n > m {
		return gcdimpl(n, m)
	}
	return gcdimpl(m, n)
}

func reduce(x, N int64) int64 {
	return (x * N) >> 32
}


Measured memory_bytes: 30948
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char X, Y; cin >> X >> Y;
  if(X < Y) cout << "<";
  else if(X > Y) cout << ">";
  else cout << "=";
  cout << endl;
}

Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>


using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int K,A,B;
  cin >> K >> A >> B;
  bool flag = false;
  for(int i = A;i <= B;i++){
    if(i%K==0){
      flag = true;
      break;
    }
  }
  if(flag){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
 }


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 A, B, M;
	cin >> A >> B >> M;
	vector<int64> a(A), b(B);
	int64 res = INF_LL;
	REP(i, A) cin >> a[i];
	REP(i, B) cin >> b[i];
	REP(i, M) {
	  int64 x, y, c;
	  cin >> x >> y >> c; x--; y--;
	  chmin(res, a[x] + b[y] - c);
	}
	chmin(res, *min_element(all(a)) + *min_element(all(b)));
	cout << res << endl;
}


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

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__);
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
    Cin(int, a, b, c);
    CoutYN(c % gcd(a, b) == 0)
}


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int n, m; scanf("%d%d", &n, &m);
	int t = (1<<n);
	vll dp(t, -1);
	dp[0] = 0;
	forn(i, m) {
		int a, b; scanf("%d%d", &a, &b);
		int swit = 0;
		forn(j, b) {
			int input; scanf("%d", &input);
			swit |= (1 << (input - 1));
		}
		int s = (1<<n) - 1;
		while(s--) {
			if(dp[s] == -1)
				continue;
			if(dp[s|swit] < 0 || dp[s|swit] > dp[s] + a)
				dp[s|swit] = dp[s] + a;
		}
	}                            
	printf("%lld", dp[(1<<n) - 1]); 
	return 0;
}              	

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

int main(){
  int H,W,k=0;
  cin>>H>>W;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++){
      char c;
      cin>>c;
      if(c=='#')
        k++;
    }
  if(k==H+W-1)
    cout<<"Possible"<<endl;
  else
    cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
using namespace std;
typedef long long ll;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
const int INF = 1e9;

int main() {
    string s;
    cin >> s;
    int n = (int)s.size();
    if(n == 2) cout << s;
    else rep(i,n) cout << s[n-i-1];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
#define el putchar('\n')
#define ta putchar('	')
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int mod=998244353;
int n,cnt[3],ans;
char s[300010];

inline int mul(int a,int b){return(ll)a*b%mod;}

int main()
{
	n=rd();scanf("%s",s+1);ans=1;
	fo(fa,1,n+n+n){
		int x=s[fa]=='R'?0:(s[fa]=='G'?1:2);
		int hh=0,id;
		fo(i,0,2)if(x!=i&&cnt[i])++hh,id=i;
		if(hh==2){
			int mn=1e9;
			fo(i,0,2)if(x^i)mn=min(mn,cnt[i]--);
			ans=mul(ans,mn);continue;
		}
		if(!hh){++cnt[x];continue;}
		if(cnt[id]>cnt[x])ans=mul(ans,cnt[id]-cnt[x]);
		++cnt[x];
	}
	fo(i,1,n)ans=mul(ans,i);cout<<ans;
	return 0;
}


Measured memory_bytes: 640
import math
A,B,C,D = map(int,input().split())

def lcm(a,b):
    return a*b // math.gcd(a,b)

x = [(A-1)//C,(A-1)//D,(A-1)//lcm(C,D)]
y = [B // C,B//D,B//lcm(C,D)]

an = (A-1) - (x[0]+x[1]-x[2])
bn =  B - (y[0]+y[1]-y[2])

print(bn-an)

Measured memory_bytes: 9004
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


x, y = inl()
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if x in a and y in a or x in b and y in b or x == 2 and b == 2:
    print("Yes")
else:
    print('No')


Measured memory_bytes: 3828
"use strict";

function main(input) {
    input = input.split(" ").map(s => +s);
    const ia = input[0],
          ib = input[1],
          limit = ib * 100;

    for (let i = ib * 10; i < limit; i++) {
        if (~~(i * 0.08) === ia && ~~(i * 0.1) === ib) {
            return console.log(i);
        }
    }
    console.log(-1);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

lst = []
for i in range(N):
  N, K = map(int, input().split())
  lst.append((N, K))

lst.sort(key=lambda tup: tup[1])
time = 0
for x in lst:
  time += x[0]
  if time > x[1]:
    print("No")
    exit()

print("Yes")


Measured memory_bytes: 31808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(10);
    ll N,K;
    cin >> N >> K;
    cout << min(K-N%K,N%K) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		long sum = 0;

		for(int i = 1; i <= k; i++) {
			for(int j = 1; j <= k; j++) {
				for(int n = 1; n <= k; n++) {
					sum += gcd(gcd(i, j), n);
				}
			}
		}


		System.out.println(sum);
		sc.close();
	}

	static int gcd(int x, int y) {
		if(x < y) {
			int temp = x;
			x = y;
			y = temp;
		}

		if(x % y == 0) return y;
		else return gcd(y, x % y);
	}
}

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


void m_sort(int a[], int tmp[], int left, int right);
void m_sort(int a[], int tmp[], int left, int right);
void sort(int a[], int total) {
	int tmp;
	for (int i = 0; i < total; i++) {
		for (int j = i + 1; j < total; j++) {
			if (a[i] < a[j]) {
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}

}

void mergeSort(int a[], int tmp[], int size)
{
	m_sort(a, tmp, 0, size - 1);
}
void merge(int a[], int tmp[], int left, int mid, int right)
{
	int i, left_end, num_elements, tmp_pos;

	left_end = mid - 1;
	tmp_pos = left;
	num_elements = right - left + 1; // 要素 

	while ((left <= left_end) && (mid <= right))
	{
		if (a[left] <= a[mid])
		{
			tmp[tmp_pos] = a[left];
			tmp_pos = tmp_pos + 1;
			left = left + 1;
		}
		else
		{
			tmp[tmp_pos] = a[mid];
			tmp_pos = tmp_pos + 1;
			mid = mid + 1;
		}
	}


	while (left <= left_end)
	{
		tmp[tmp_pos] = a[left];
		left = left + 1;
		tmp_pos = tmp_pos + 1;
	}

	while (mid <= right)
	{
		tmp[tmp_pos] = a[mid];
		mid = mid + 1;
		tmp_pos = tmp_pos + 1;
	}


	for (i = 0; i <= num_elements; i++)
	{
		a[right] = tmp[right];
		right = right - 1;
	}
}
void m_sort(int a[], int tmp[], int left, int right)
{
	int mid;

	if (right > left)
	{
		mid = (right + left) / 2;
		m_sort(a, tmp, left, mid);
		m_sort(a, tmp, mid + 1, right);

		merge(a, tmp, left, mid + 1, right);
	}
}


long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmim(long x, long y) {
	if (x < y)return x;
	return y;
}

int mim(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}


double houwa;
int N,C,H,n, M,D[200001],T[200001],DD[200001],TT[200001],K,W,A,B,ans;
string S,k;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> D[i];
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> T[i];
	}
	if (M > N) {
		cout << "NO" << endl;
		return 0;
	}
	n = 0;
	mergeSort(D, DD, N);
	mergeSort(T, TT, M);

	for (int i = 0; i < M; i++) {
		while (D[i + n] != T[i]) {
			if (D[i + n] < T[i]) {
				n++;
			}
			if (D[i + n] > T[i]||i+n>N) {
				cout << "NO" << endl;
				return 0;
			}
		}

	}

	cout << "YES"<<endl;

	
	return 0;
}




Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;

const LL inf = 0x3f3f3f3f3f3f3f3f;
const int N = 55;
int n, m, s;
LL dis[N][2510];
struct Edge {
	int from, to, next;
	LL w, cost;
}e[N * 2];
int cnt, head[N];
LL c[N], d[N];

void add(int u, int v, int a, int b) {
	e[++cnt].to = v;
	e[cnt].from = u;
	e[cnt].w = b;
	e[cnt].cost = a;
	e[cnt].next = head[u];
	head[u] = cnt;
}

void spfa() {
	queue<PII> q;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= 2500; j++) {
			dis[i][j] = inf;
		}
	}
	dis[1][s] = 0;
	q.push({1, s});
	while(!q.empty()) {
		int u = q.front().first, w = q.front().second; q.pop();
		for(int i = head[u]; i; i = e[i].next) {
			LL v = e[i].to, a = e[i].cost, b = e[i].w;
			if(w >= a && dis[v][w - a] > dis[u][w] + b) {
				dis[v][w - a] = dis[u][w] + b;
				q.push({v, w - a});
			}
		}
		if(dis[u][min(w + c[u], (LL)2500)] > dis[u][w] + d[u]) {
			dis[u][min(w + c[u], (LL)2500)] = dis[u][w] + d[u];
			q.push({u, min(w + c[u], (LL)2500)});
		}
	}
}

void solve() {
	scanf("%d %d %d", &n, &m, &s);
	s = min(s, 2500);
	while(m--) {
		int u, v, a, b;
		scanf("%d%d%d%d", &u, &v, &a, &b);
		add(u, v, a, b);
		add(v, u, a, b);
	}
	for(int i = 1; i <= n; i++) scanf("%lld %lld", &c[i], &d[i]);
	spfa();
//	for(int i = 0; i <= 10; i++) printf("%d\n", dis[2][i]);
	for(int i = 2; i <= n; i++) {
		LL res = inf;
		for(int j = 0; j <= 2500; j++) res = min(res, dis[i][j]);
		printf("%lld\n", res);
	}
}

int main() {
//	freopen("in.txt", "r", stdin);
	solve();
	return 0;
}

Measured memory_bytes: 4996
N = gets.to_i
S = ["a"]
25.times{S << S[-1].next}
b = 1
i = 1
loop{
    bb = b + 26 ** i
    break if bb > N
    b = bb
    i += 1
}
warn [b, i].inspect
n = N - b
warn n
s = ""
i.times{
    s << S[n % 26]
    n /= 26
}
puts s.reverse


Measured memory_bytes: 14380
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String result = "";
		for(int i = 0; i < n; i++) {
			result += "ACL";
		}
		System.out.println(result);
		sc.close();
	}
}

Measured memory_bytes: 38440
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int n;
  cin >> n;
  string s = to_string(n);
  int count = 0;
  REP(i, s.size()) count += s[i] - '0';
  print(n % count == 0 ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	while(true){
		int R, N;
		cin >> R >> N;
		if(R == 0 && N == 0)break;
		double r = (double)R;

		int xl, xr;
		double h;
		vector<double> H(40, 0.0);
		for(int i = 0; i < N; i ++){
			cin >> xl >> xr >> h;
			for(int j = xl; j < xr; j ++){
				H[j + 20] = max(H[j + 20], h);
			}
		}

		double ans = 1000.0;
		for(int i = -R; i < R; i ++){
			//t = 0のときの太陽の高いほうのy座標(幅が[i,i+1]の中で)
			double sun_edge_high = max(sqrt(r * r - (double)(i * i)), sqrt(r * r - (double)((i + 1) * (i + 1)))) - r;
			ans = min(ans, H[i + 20] - sun_edge_high);
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3288
a = int(input())
li = list(map(int,input().split()))

NGflag = 0
count = 0

while True:
    for i in range(a):
        if li[i] % 2 == 0:
            li[i] = li[i] / 2 

        else:
            NGflag = 1

    if NGflag == 1:
        break
    else:
        count = count + 1

print(count)

Measured memory_bytes: 3060
a,b=map(int,input().split())
for i in range (1,100100):
  if 1<=b<=9:
    if 10*a+b==i**2:
      print('Yes')
      exit()
  if 10<=b<=99:
    if 100*a+b==i**2:
      print('Yes')
      exit()
  if b==100:
    if 1000*a+b==i**2:
      print('Yes')
      exit()
print('No')

    

Measured memory_bytes: 2940
N,M,X = map(int ,input().split())
ls = []
for i in range(N):
  C,*A = map(int, input().split())
  ls.append((C,A))
ans = 10**10
for i in range(2**N):
  used = [0]*M
  m = 0
  for j in range(N):
    if i%2==0:
      C,A = ls[j]
      m += C
      for h in range(M):
        used[h] += A[h]
    i >>= 1
  if all(c>=X for c in used):
    ans = min(ans,m)
if ans==10**10:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9224
// dpj.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include "pch.h"
#include <iostream>
#include <vector>
using namespace std;
double dp[310][310][310];
int n;
double dps(int i, int j, int k) {
	if (dp[i][j][k] != -1)return dp[i][j][k];
	if (i == 0 && j == 0 && k == 0)return 0.0;
	double ret = 0.0;
	if (i > 0)ret += dps(i - 1, j, k)*i;
	if (j > 0) ret += dps(i + 1, j - 1, k)*j;
	if (k > 0)ret += dps(i, j + 1, k - 1)*k;
	ret += n;
	ret *= 1.0 / (i + j + k);
	dp[i][j][k] = ret;
	return ret;
}
int main()
{
	cin >> n; // 皿の数

	int i=0;
	int j = 0;
	int k = 0;
	int a;
	for (int d = 0; d < n; d++)
	{
		cin >> a;
		if (a == 1) i++;
		if (a == 2) j++;
		if (a == 3) k++;
	}
	for (int is = 0; is < 310; is++) {
		for (int js = 0; js < 310; js++)
		{
			for (int ks = 0; ks < 310; ks++)
			{
				dp[is][js][ks] = -1;
			}
		}
	}
	double ans = dps(i, j, k);
	printf("%10.10f\n", ans);

}


Measured memory_bytes: 232960
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 


int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n;
	cin>>n;
	
	
	long double ans = 0;
	
	long double arr[n+1];
	
	for(ll i=0;i<n;i++)cin>>arr[i];
	
	sort(arr,arr+n);
	
	for(ll i=0;i<n;i++)
	{
		if(i==0)
		{
			ans = arr[i];
			
		}
		else{
			ans = (ans+arr[i])/2;
		}
	}
	
	cout<<fixed<<setprecision(10)<<ans<<endl;
	
	
}




Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(A) < sum(B):
  print(-1)
else:
  diffs = [a - b for a, b in zip(A, B)]
  diffs.sort()
  changed = set()
  l = 0
  r = n - 1
  while l < r:
    if diffs[l] >= 0:
      break
    if diffs[r] + diffs[l] == 0:
      changed.add(l)
      changed.add(r)
      l += 1
      r -= 1
    elif diffs[r] + diffs[l] > 0:
      changed.add(l)
      changed.add(r)
      diffs[r] += diffs[l]
      l += 1
    else:
      changed.add(l)
      changed.add(r)
      diffs[l] += diffs[r]
      r -= 1
  print(len(changed))      


Measured memory_bytes: 25828
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
#include <stack>
using namespace std;
long long l,h=10000000000,n,a,b,s[100010],mx;
bool check(long long mid){
long long sum=0;
 for(int i=0;i<n;i++)
 {if(s[i]-mid*b>0)
   sum+=(s[i]-mid*b+a-b-1)/(a-b);
  }
 return sum<=mid;
}
int main(){
cin>>n>>a>>b;
for(int i=0;i<n;i++){
 cin>>s[i];
 mx=max(mx,s[i]);
}
long long mid,ans;
while(l<=h){
 mid=(l+h)/2;
 if(check(mid)==1)
 {
  ans=mid;
  h=mid-1;
 }
 else
  l=mid+1;
}
cout<<ans;
system("pause");
return 0;
}

Measured memory_bytes: 1272
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 2e5+5;

void solve(){
	int x;
	cin>>x;
	cout<<(x?0:1);		
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}


Measured memory_bytes: 3636
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int n;
int a[100], dp[100*100+200];

int main(){
	cin>>n; rep(i, n) cin>>a[i];
	dp[0] = 1;
	rep(i, n){
		rep(j, 100*100) dp[10000-j-1+a[i]] |= dp[10000-j-1];
	}
	int res = 0;
	rep(j, 10000+1) if(j%10&&dp[j]) res = j;
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5 + 5;
vector<pair<ll,ll>> a , b;
priority_queue<ll , vector<ll> , greater<ll>>Q;
int main()
{
    ios::sync_with_stdio(false);
    int t; cin >> t;
    while (t--){
        a.clear();
        b.clear();
        int n ; cin >> n;
        ll ans = 0;
        for (int i = 1 ; i <= n ; i++){
            ll k , l , r; cin >> k >> l >> r;
            if (l > r || k == n) ans += r , a.push_back(make_pair(k , l - r));
            else ans += l , b.push_back(make_pair(n - k , r - l));
        }
        sort(a.begin() , a.end());
        sort(b.begin() , b.end());
        for (auto & g : a){
            // 排序之后不可能出现 Q.size() > g.k的情况吧
            if (Q.size() < g.first) Q.push(g.second);
            else if (Q.top() < g.second) Q.pop() , Q.push(g.second);
        }
        while (Q.size()) ans += Q.top() , Q.pop();
        for (auto & g : b){
            if (Q.size() < g.first) Q.push(g.second);
            else if (Q.top() < g.second) Q.pop() , Q.push(g.second);
        }
        while (Q.size()) ans += Q.top() , Q.pop();
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 8276
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,n,x,y,x1,y1,cnt;
    cin>> n >> x >> y;
    x1 = x;
    y1 = y;
    for(i = 1;i < n;i++){
        cin>> x >> y;
        if(x > x1 && y > y1){
            x1 = x;
            y1 = y;
        }
        else{
            cnt = max( (x1 / x) + ( x1 % x ? 1 : 0 ) , (y1 / y) + (y1 % y ? 1 : 0) );
            x1 = x * cnt;
            y1 = y * cnt;
        }
    }
    cout<<x1 + y1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int N;
    cin >> N;
    VLL A(N);
    rep(i,N){
        cin >> A[i];
    }
    bool judge=true;
    rep(i,N){
        if(A[i]%2==0){
            if(A[i]%3!=0 && A[i]%5!=0){
                judge=false;
            }
        }
    }
    if(judge){
        cout << "APPROVED" << endl;
    }
    else{
        cout << "DENIED" << endl; 
    }
}

Measured memory_bytes: 256
import math


n = int(input())
ans_L = []
d = []
for val in range(int(math.sqrt(n)+1),0,-1):
    if n % val ==0:
        x = val
        y = int(n/val)
        #st = str(x) + "*" +str(y)
        #d.append(st) 
        #ans_L.append(int(x+y-2))
        print(int(x+y-2))
        exit()
#print(d)
#print(ans_L)
#print(min(ans_L))

Measured memory_bytes: 40044
import java.util.Scanner;

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

		int a = scan.nextInt();
		String op = scan.next();
		int b = scan.nextInt();

		if(op.equals("+")){
			System.out.println(a+b);
		}
		else{
			System.out.println(a-b);
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    string s; cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
struct BIT { //1-indexed
private:
    int n;
    vector<ll> bit;

public:
    BIT(vector<ll> v){
        n = v.size();
        rep(i,0,n) bit.push_back(v[i]);
    }

    ll sum(ll i){
        ll s = 0;
        while(i > 0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(ll i, ll x){
        while(i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    rep(i,0,N) A[i] -= K;
    vector<ll> sum(200010, 0);
    rep(i,0,N) sum[i+1] = sum[i] + A[i];
    vector<ll> v;
    rep(i,0,N+1) v.push_back(sum[i]);
    sort(v.begin(), v.end());
    vector<ll> sum_comp;
    rep(i,0,N+1){
        ll pos = lower_bound(v.begin(), v.end(), sum[i]) - v.begin();
        sum_comp.push_back(pos+1);
    }
    vector<ll> init(200010, 0);
    BIT bit(init);
    ll ans = 0;
    rep(i,0,N+1){
        ans += bit.sum(sum_comp[i]);
        bit.add(sum_comp[i], 1);
    }
    print(ans);


    
}

Measured memory_bytes: 13680
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include <iomanip>

#define rep0(i,N) for(int i=0;i<N;i++)
#define rep1(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005

using namespace std;

int main(){
	string s;
	lint ss;
	cin>>s;
	ss=s.size();
	rep0(i,s.size()){
		if(s[i]=='b'){
			if(s[ss-1-i]!='d'){
				cout<<"No";
				return 0;
			}
		}
		if(s[i]=='d'){
			if(s[ss-1-i]!='b'){
				cout<<"No";
				return 0;
			}
		}
		if(s[i]=='p'){
			if(s[ss-1-i]!='q'){
				cout<<"No";
				return 0;
			}
		}
		if(s[i]=='q'){
			if(s[ss-1-i]!='p'){
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class35
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool frag = true;
            Array.Sort(a);
            
            for(int i = 0; i < n-1; i++)
            {
                if (a[i] == a[i + 1])
                {
                    frag = false;
                    break;
                }
            }
            Console.WriteLine(frag ? "YES" : "NO");
        }
        
    }
}


Measured memory_bytes: 32220
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)

// ワーシャルフロイド法　O(V^3)
// 全点対最短路問題を解くdp
#define MAX_V (100)
int dp[MAX_V][MAX_V];

int main() {

	int V, E; // V:頂点数、E:辺数
	cin >> V >> E;

	for (int i = 0; i < V; i++) {
		for (int j = 0; j < V; j++) {
			if (i != j) dp[i][j] = INF;
		}
	}

	for (int i = 0; i < E; i++) {
		int s, t, cost;
		cin >> s >> t >> cost;
		dp[s][t] = cost; // 有向グラフ
	}

	for (int k = 0; k < V; k++) {
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V; j++) {
				// i,jの最短距離は、　min( i,jを直接行く, kを経由していく)
				if (dp[i][k] < INF && dp[k][j] < INF) {
					dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
				}
			}
		}
	}

	// dp[i][i]が負の値となる場合、ネガティブサイクルが存在する
	for (int i = 0; i < V; i++) {
		if (dp[i][i] < 0) {
			cout << "NEGATIVE CYCLE" << endl;
			return 0;
		}
	}

	for (int i = 0; i < V; i++) {
		for (int j = 0; j < V; j++) {
			if (dp[i][j] < INF) cout << dp[i][j];
			else cout << "INF";
			if (j != V - 1) cout << " ";
		}
		cout << endl;
	}

	return 0;

}



Measured memory_bytes: 3148
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n = Integer.parseInt(scanner.nextLine());
		String[] temp = scanner.nextLine().split(" ");
		int[] list = new int[n];

		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(temp[i]);

		}

		Arrays.sort(list);



		int a = list[n / 2];
		int b = list[n / 2 - 1];

		System.out.println(a - b);


	}
}


Measured memory_bytes: 48200