akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


int main(){
    string S, T;
    cin >> S;
    cin >> T;
    T.pop_back();
    if(S == T){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <functional>
#include <stack>
#include <cstring>
#include <cstdio>
#include <string>
#include <random>
#include <chrono>

using namespace std;

using ll = long long;

void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
}

int get_digits(int n, int k) {
	int ret = 0;
	do {
		ret++;
		n /= k;
	} while (n > 0);
	return ret;
}

int main() {
	//file();
	int n, k;
	scanf("%d %d", &n, &k);
	printf("%d\n", get_digits(n, k));

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


const int N = 1e9 + 1;
const int MOD = 1e9 + 7;

int mod_pow(int x, int n){
  int x_pow = 1;
  while(n > 0){
    if (n%2 == 1) x_pow = ((ll)x * x_pow) % MOD;
    x = ((ll) x * x) % MOD;
    n /= 2;
  }
  return x_pow;
}

int inv(int a, int m) {
    if (a == 0) return 0;
    int k = -inv(m%a,a);
    if (k < 0) k += a;
    return (ll(m)*k+1)/a;
}


int comb(int n, int a){
  int c=1, m=1;
  rep(i, a){
    c = ((ll) c * (n - i)) % MOD;
    m = ((ll) m * (a - i)) % MOD;
  }
  return (ll) c * inv(m, MOD) % MOD;
}

int mod_sub(int a, int b){
  if ((a += MOD-b) >= MOD) a -= MOD;
  return a;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = mod_pow(2, n) - 1;

  ans = ans - comb(n, a);
  ans = ans - comb(n, b);
  while(ans < 0){
    ans += MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
          int T,A[1000],i,j,k;
          double m,Tot=0,a=0,ans1,ans;
         while(1){
                    scanf("%d",&T);
         if(T==0)
         {
                   return 0;
         }
          for(j=0;j<T;j++)
          {
                    scanf("%d",&A[j]);
          }
          for(i=0;i<T;i++)
          {
                    Tot=Tot+A[i];
          }
          m=Tot/T;
          for(i=0;i<T;i++)
          {
                    a=a+((A[i]-m)*(A[i]-m));
          }
          ans1=a/T;
          ans=sqrt(ans1);
          printf("%.8lf\n",ans);
          ans=0;
          ans1=0;
          Tot=0;
          m=0;
          a=0;
         }

          return 0;

}



Measured memory_bytes: 2120
main :: IO ()
main = do
    _ <- getLine
    s <- getLine
    putStrLn $ solve s

-- |
--
-- >>> solve ")))())"
-- "(((()))())"
--
-- >>> solve "))))(((("
-- "(((())))(((())))"
--
-- >>> solve "()(()))"
-- "(((())))(((())))"
solve :: String -> String
solve s = replicate a '(' ++ s ++ replicate b ')'
  where
    a = negate $ min (minimum xs) 0
    b = last xs + a
    xs = f s

f :: String -> [Int]
f s = scanl1 (+) (map toNum s)

toNum :: Char -> Int
toNum '(' =  1
toNum ')' = -1
toNum _ = undefined


Measured memory_bytes: 508
n = gets.to_i
a = gets.split.map(&:to_i).sort.reverse

xy = []
i = 0
while i < n do
  if a[i] == a[i + 1]
    xy << a[i]
    break if xy.size == 2
    i += 1
  end
  i += 1
end

if xy.size == 2
  puts xy[0] * xy[1]
else
  puts 0
end


Measured memory_bytes: 10136
import java.util.*;
public class Main{
   public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     int  n = sc.nextInt();
     int m =sc.nextInt() ;
     int ans;
     ans = (n*n-n)/2+(m*m-m)/2;
     System.out.println(ans);
   }
}


Measured memory_bytes: 23764
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    vector<bool>nums(1e6+1);
    bool pairwise = true;
    bool setwise = false;
    for (int i=0; i<N; i++){
        cin >> A[i];
    }

    ll gc = GCD(A[0], A[1]);
    for (int i=1; i<N; i++)gc = GCD(gc, A[i]);
    
    for (int i=0; i<N; i++){

        vector<pair<ll, ll>>primes = prime_factorize(A[i]);

        for (int j=0; j<primes.size(); j++){
            int pr;
            pr = primes[j].first;
            if (nums[pr])pairwise = false;
            nums[pr] = true;
        }
    }

    if (gc == 1)setwise = true;

    if (pairwise)cout << "pairwise coprime" << endl;
    else if (setwise)cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

Measured memory_bytes: 7176
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M;
    cin >> M;
    cout << 48 - M << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

    int N, K;
    cin >> N >> K;
    int A[N];
    vector<int> vecm, vec0, vecp;
    rep(i,N){
        cin >> A[i];
        if(A[i] < 0){
            vecm.push_back(-A[i]);
        }
        else if(A[i] == 0){
            vec0.push_back(A[i]);
        }
        else{
            vecp.push_back(A[i]);
        }
    }
    sort(vecm.begin(), vecm.end());
    sort(vecp.begin(), vecp.end());
    int vm = vecm.size();
    int v0 = vec0.size();
    int vp = vecp.size();
    int left = 0, right = INF, mid;
    if(vm * vp < K && K < vm * vp + v0 * (N-1) - v0*(v0-1)/2){
        cout << 0 << endl;
        return 0;
    }
    else if(vm * vp >= K){
        while(right - left > 1){
            mid = (right+left)/2;
            int cou = 0;
            rep(i,vm){
                int z = (mid+vecm[i]-1)/vecm[i];
                cou += vecp.end() - lower_bound(vecp.begin(), vecp.end(), z);
            }
            if(cou < K) right = mid;
            else left = mid;
        }
        cout << -left << endl;
    }
    else{
        K = N*(N-1)/2 - K + 1;
        while(right - left > 1){
            mid = (right+left)/2;
            int cou = 0;
            rep(i,vm){
                int z = (mid+vecm[i]-1)/vecm[i];
                if(z <= vecm[i]) --cou;
                cou += vecm.end() - lower_bound(vecm.begin(), vecm.end(), z);
            }
            rep(i,vp){
                int z = (mid+vecp[i]-1)/vecp[i];
                if(z <= vecp[i]) --cou;
                cou += vecp.end() - lower_bound(vecp.begin(), vecp.end(), z);
            }
            cou /= 2;
            if(cou < K) right = mid;
            else left = mid;
        }
        cout << left << endl;
    }
}

Measured memory_bytes: 3700
#include <atcoder/all>
#include <bits/stdc++.h>
typedef long long ll;

#define for_(i, a, b) for(int i = (a); i < (b); ++i)
#define rfor_(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int d[5] = {0, 1, 0, -1, 0};

using namespace std;
using namespace atcoder;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    dsu d(N);

    int temp1, temp2;
    rep(i, M) {
        cin >> temp1 >> temp2;
        temp1--;
        temp2--;
        d.merge(temp1, temp2);
    }
    vector<vector<int>> group = d.groups();
    cout << group.size() - 1 << endl;
}


Measured memory_bytes: 8976
/*
  1. don't do bfs each sample
  2. note when 0 is in the 3 and 4 position.
 */

#include <iostream>
#include <string>
#include <unordered_map>
#include <queue>
#include <algorithm>
using namespace std;

unordered_map<int, int> res;
int dpos[] = {1, -1, 4, -4};

void bfs() {
  int init = 1234567;
  res[init] = 0;
  queue<int> qu;
  qu.push(init);
  while (!qu.empty()) {
    int curr = qu.front(); qu.pop();
    int curr_pos = res[curr];
    string curr_s = to_string(curr);
    int pos0 = 0;
    for (int i = 0; i < curr_s.size(); ++i) 
      if (curr_s[i] == '0') {
        pos0 = i;
        break;
      }
    if (pos0 == 0) 
      curr_s = "0" + curr_s;
    for (int i = 0; i < 4; ++i) {
      if (pos0 == 3 && dpos[i] == 1 || pos0 == 4 && dpos[i] == -1) 
        continue;
      int npos = pos0 + dpos[i];
      if (npos >= 0 && npos < 8) {
        swap(curr_s[pos0], curr_s[npos]);
        int new_d = stoi(curr_s);
        if (res.find(new_d) == res.end()) {
          res[new_d] = curr_pos + 1;
          qu.push(new_d);
        }
        swap(curr_s[pos0], curr_s[npos]);
      }
    }
  }
  return;
}

int main() {
  bfs();
  string line;
  while (getline(cin, line)) {
    // remove() in algorithm
    line.erase(remove(line.begin(), line.end(), ' '), line.end());
    int input_digit = stoi(line);
    cout << res[input_digit] << endl;
  }
  return 0;
}


Measured memory_bytes: 3876
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define mod 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))
#define cio ios::sync_with_stdio(false);

int main()
{
   	string s;
   	cin >> s;
   	if(s=="ABC"){
   		cout << "ARC" << endl;
   	}else{
   		cout << "ABC" << endl;
   	}
    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
ll dp[25][2], arr[25]; 
int main()
{
	// freopen("AGC021-A.in", "r", stdin); 
	ll n; 
	scanf("%lld", &n); 
	int len = 0; 
	while (n)
	{
		arr[len++] = n % 10; 
		n /= 10; 
	}
	memset(dp, -0x3f, sizeof(dp)); 
	dp[len][1] = 0; 
	for (int i = len - 1; i >= 0; i--)
	{
		for (int x = 0; x < 2; x++)
		{
			for (int j = 0; j < 10; j++)
			{
				if (x && j > arr[i])
					continue; 
				int xx = x & (j == arr[i]); 
				dp[i][xx] = std::max(dp[i][xx], dp[i + 1][x] + j); 
			}
		}
	}
	printf("%lld\n", std::max(dp[0][0], dp[0][1]));
	return 0; 
}


Measured memory_bytes: 764
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  ll r, x, D;
  cin >> r >> D >> x;
  for (int i = 0; i < 10; i++) {
    x = x * r - D;
    cout << x << endl;
  }
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);	
		int a = stdin.nextInt();
		int b = stdin.nextInt();
		System.out.println(2*b-a);
		// TODO 自動生成されたメソッド・スタブ

	}

}


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

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(),  greater<char>());
    for(int i=0;i<min(s.length(), t.length());i++){
        if(s[i] > t[i]){
            cout << "No" << endl;
            break;
        }else if(s[i] < t[i]){
            cout << "Yes" << endl;
            break;
        }else if(i == min(s.length(), t.length()) - 1){
            if(s.length() < t.length()){
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }
    }
    return 0;
}

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

int main(){
	long long  K, A, B;
	cin >> K >> A >> B;
	long ans = 1;
	if (A + 2 >= B) {
		ans += K;
	}else
	{
		K -= (A - 1);
		if(K % 2 == 0) ans = K / 2 * (B - A) + A;
		else ans = K / 2 * (B - A) + A + 1;
	}
	
	
	cout << ans << endl;
}

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

int compo[100010];
map<int, vector<int>> mp;
int dfs(int key){
    for(int i=0; i<mp[key].size(); ++i){
        if(compo[mp[key][i]]<1){
            compo[mp[key][i]]=compo[key];
            dfs(mp[key][i]);
        }
    }
}
int main() {
	int N, M, p[100010]; cin >> N >> M;
	for(int i=1; i<=N; ++i) cin >> p[i];
	int x, y;
	for(int i=0; i<M; ++i){
	    cin >> x >> y;
	    mp[x].push_back(y);
	    mp[y].push_back(x);
	}
	for(int i=1, j=1; i<=N; ++i){
	    if(compo[i]<1){
	        compo[i]=j;
	        dfs(i);
	        ++j;
	    }
	}
	int ans=0;
	for(int i=1; i<=N; ++i){
	    if(compo[p[i]]==compo[i]) ++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 17024
def solve():
    R,G,B,N = map(int,input().split())

    cnt = 0
    for r in range(0,3000+1):
        for g in range(0,3000+1):
            b = N - (r * R + g * G)
            if b >= 0 and b % B == 0:
                cnt += 1
    
    print(cnt)
        
if __name__ == '__main__':
    solve()


Measured memory_bytes: 73232
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

#define MAX_N 100000

int par[MAX_N]; // 親の番号
int rank_of_tree[MAX_N];

// n要素で初期化
void init(int n){
  for(int i=0; i<n; i++){
    par[i] = i;
    rank_of_tree[i] = 0;
  }
}
// 木の根を求める
int root(int x){
  if(par[x] == x){ // 根
    return x;
  } else {
    return par[x] = root(par[x]); // 経路圧縮
  }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y){
  return root(x) == root(y);
}

// xとyの属する集合を併合
void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y) return;

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

int main(){
  int N, M;
  cin >> N >> M;
  int P[N];
  for(int i=0; i<N; i++){
    cin >> P[i];
    P[i]--; // 0 <= P[i] <= N-1
  }

  init(N);
  for(int i=0; i<M; i++){
    int x, y;
    cin >> x >> y;
    unite(x-1, y-1);
  }

  int ret = 0;
  for(int i=0; i<N; i++)
    if(same(P[i], i))
      ret++;
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 1408
#coding:utf-8
#??????????????????????????§??§??????????°??????????????°????????????§???????????????????????????

text = list(raw_input())
for i in range(len(text)) :
	if ord(text[i])<=90 and ord(text[i])>=65:
		text[i] = chr(ord(text[i])+32)
	elif ord(text[i])<=122 and ord(text[i])>=97:
		text[i] = chr(ord(text[i])-32)
print(''.join(text))

Measured memory_bytes: 6432
#include<stdio.h>

int main(){
  int N,i;
  double x[10],sum=0;
  char u[3];

  scanf("%d", &N);
  for(i=0;i<N;i++){
    scanf("%lf %s", &x[i],u);

    if(u[0]=='J'){
      sum=sum+x[i];
    }else{
      sum=sum+x[i]*380000;
    }
  }

  printf("%lf\n", sum);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
  string s;
  getline(cin,s);
  int l=s.size();
  int i;
  char a;
  for(i=0;i<l;i++)
  {
    if(s[i]==' ')
    {
      i++;
      a=s[i];
     break;
    }
  }
  cout<<"A"<<a<<"C";
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
vector<vector<P>> G;
vector<int> vis, s, a;
int res;
int dfs(int i, int p) {
    int co = 0;
    if (a[i]) {
        co++;
    }
    vis[i] = 1;
    int deg = 0;
    if (p != -1) {
        deg++;
    }
    for (auto &e : G[i]) {
        if (vis[e.first]) {
            continue;
        }
        co += dfs(e.first, e.second);
        if (s[e.second] == 1) {
            deg++;
        }
    }
    if (p != -1) {
        if (deg % 2 != a[i]) {
            s[p] = 0;
        } else {
            s[p] = 1;
            res++;
        }
    }
    return co;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    G.resize(n + 1);
    vis.resize(n + 1);
    a.resize(n + 1);
    s.resize(m);
    vector<P> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    sort(all(v));
    for (int i = 0; i <= n; i++) {
        if (i == 0) {
            a[i] = v[i].second;
        } else if (i < n) {
            a[i] = (v[i].second ^ v[i - 1].second);
        } else {
            a[i] = v[i - 1].second;
        }
    }
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        int p = lower_bound(all(v), P(l, -1)) - v.begin();
        int q = lower_bound(all(v), P(r + 1, -1)) - v.begin();
        G[p].eb(P(q, i));
        G[q].eb(P(p, i));
    }
    for (int i = 0; i <= n; i++) {
        if (vis[i]) {
            continue;
        }
        if (dfs(i, -1) % 2) {
            cout << -1 << '\n';
            return 0;
        }
    }
    cout << res << '\n';
    for (int i = 0; i < m; i++) {
        if (s[i]) {
            cout << i + 1 << " ";
        }
    }
    if (res > 0) {
        cout << '\n';
    }
}
/*
階差を取ると、「M個の2点flipをして、全て0にできるか？」という問題になる
各2点flipに辺を張ったグラフを考えると、「次数が、元々1なら奇数、0なら偶数になるようにグラフを構築せよ」という問題になる。
木の場合を考える。
下から辻褄を合わせていく。偶奇が違うなら親への辺を削除。
根における偶奇が等しいことが条件。
(連結成分内の1の個数)が偶数であるなら、必ず構築可能。
なぜなら、「次数奇数が偶数個である」が全部分木について満たされている限り、根で変更する必要はないから
*/

Measured memory_bytes: 21120
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const int MOD = 998244353;

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n, k; cin >> n >> k;
	vector<int> L(k), R(k);
	REP(i, k) cin >> L[i] >> R[i];
	vector<int> dp(n + 1, 0), s(n + 1, 0);
	dp[1] = s[1] = 1;
	for(int i = 2; i <= n; i++) {
		REP(j, k) {
			int l = i - R[j];
			int r = i - L[j];
			if (r < 1) continue ;
			l = max(l, 1);
			int sum = s[r] - s[l-1];
			sum %= MOD;
			sum += MOD;
			sum %= MOD;
			dp[i] += sum;
			dp[i] %= MOD;
		}
		s[i] = s[i-1] + dp[i];
		s[i] %= MOD;
	}
	cout << dp[n] << '\n';
	return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<bool> AC(N,false);
  vector<int> P(N,0);
  for(int i = 0; i < M; ++i){
    int p;
    string s;
    cin >> p >> s;
    --p;
    if(s == "AC") AC[p] = true;
    else if(!AC[p]) ++P[p];
  }
  int p = 0, c = 0;
  for(int i = 0; i < N; ++i){
    if(!AC[i]) continue;
    ++c;
    p += P[i];
  }
  cout << c << " " << p << endl;
}


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

int main(){
    long long int X,Y,A,B,C; cin>>X>>Y>>A>>B>>C;
    vector<long long int> p(A,0);
    vector<long long int> q(B,0);
    vector<long long int> r(C,0);
    for(ll i=0;i<A;i++){
        cin>>p[i];
    }
    for(ll i=0;i<B;i++){
        cin>>q[i];
    }
    for(ll i=0;i<C;i++){
        cin>>r[i];
    }
    sort(p.begin(),p.end());reverse(p.begin(),p.end());
    sort(q.begin(),q.end());reverse(q.begin(),q.end());
    sort(r.begin(),r.end());reverse(r.begin(),r.end());

    vector<long long int> tmp(X+Y+C,0);
    for(ll i=0;i<X;i++){
        tmp[i]=p[i];
    }
    for(ll i=X;i<X+Y;i++){
        tmp[i]=q[i-X];
    }
    for(ll i=X+Y;i<X+Y+C;i++){
        tmp[i]=r[i-(X+Y)];
    }
    sort(tmp.begin(),tmp.end());reverse(tmp.begin(),tmp.end());
    long long int ans=0;
    for(ll i=0;i<X+Y;i++){
        ans=ans+tmp[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

const char * c005()
{
    size_t n;
    cin >> n;
    vector<size_t> a(n);
    cin >> a;

    const auto d = * max_element(begin(a), end(a));
    vector<size_t> cnt(d + 1, 0);

    for(const auto i: a)
    {
        if(2 * i < d)
            return "Impossible";

        ++ cnt[i];
    }

    for(size_t i = d / 2 + 1; i < d + 1; ++ i)
        if(cnt[i] < 2)
            return "Impossible";

    if(!(d & 1) && cnt[d / 2] != 1)
        return "Impossible";

    if((d & 1) && cnt[d / 2 + 1] != 2)
        return "Impossible";

    return "Possible";
}

int main(const int argc, char * argv [])
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << c005();

    return EXIT_SUCCESS;
}


Measured memory_bytes: 384
#include<iostream>
 using namespace std ;
 int main()
{
 int A,B,C;
 cin>>A;
 cin>>B;
 cin>>C;
 if ((A+B)>=C)
 {
 cout << "Yes"<< endl;
 }
 else {
 cout <<"No" << endl;
 }
 
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define var auto
using ll = long long;
const char newl = '\n';
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {if(a > b) a = b;}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {if(a < b) a = b;}
using namespace std;

int main(){
    int c, n, m;
    cin >> c >> n >> m;
    vector<ll> maxPrice(c + 1, 0);
    for (int ctr = 0; ctr < n; ctr++){
        int w, v;
        cin >> w >> v;
        for (int i = maxPrice.size() - 1; i >= w; i--){
            chmax(maxPrice[i], maxPrice[i - w] + v);
        }
    }
    for (int i = 1; i <= m; i++){
        cout << maxPrice[c / i] * i << endl;
    }
}


Measured memory_bytes: 3188
#include <stdio.h>
int HANTEI(int,int);
int n,a[2000];

int main(){
  int i,b,c;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

   scanf("%d",&b);
  
  for(i=0;i<b;i++){
    scanf("%d",&c);
    if(HANTEI(0,c)==0){
      printf("no\n");
    } else{
      printf("yes\n");
    }
  }
  return 0;
  
}

int HANTEI(int i,int m){
  int res;
  if(m==0){
    return 1;
  }
    if(i>=n){
      return 0;
    }
    res=HANTEI(i+1,m)||HANTEI(i+1,m-a[i]);
    return res;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;
    int ans = stoi(a + b);
    //cout << ans << endl;
    for (int i = 1; i < ans; i++)
    {
        int tmp = ans / i;
        if (tmp == sqrt(ans))
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";

    return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> c(n), s(n), f(n);
  for (int i = 0; i < n - 1; ++i) {
    cin >> c[i] >> s[i] >> f[i];
  }

  for (int j = 0; j < n - 1; ++j) {
    int time = 0;
    for (int i = j; i < n - 1; ++i) {
      time = max(time, s[i]);
      if ((time % f[i]) == 0) {
        time += c[i];
      } else {
        time = (time + f[i] - 1) / f[i] * f[i] + c[i];
      }
    }
    cout << time << "\n";
  }
  cout << 0 << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
//#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007ll
#define pb push_back
#define fi first
#define se second
#define mk(a, b) make_pair(a, b)
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int n, ans;

signed main()
{
    cin >> n;
    for(int i = 1; i <= n; i+=2){
        int cnt = 0;
        for(int j = 1; j <= i; j++){
            if(i % j == 0){
                cnt++;
            }
        }
        if(cnt == 8){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}
/*


*/


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
   int n,T;
   cin>>n>>T;
   int ans=1001;
   rep(i,0,n){
      int c,t;
      cin>>c>>t;
      if (t<=T&&ans>c) ans=c;
   }
   if (ans==1001) cout<<"TLE";
   else cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int counter = 0;
        while (n != 0) {
            n /= k;
            counter++;
        }
        System.out.println(counter);
        sc.close();
    }
}

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

int main() {
	
	int A, B, C, D;
	
	std::cin >> A >> B >> C >> D;
	
	int min1, min2;
	
	min1 = min(A, B);
	min2 = min(C, D);
	
	std::cout << min1 + min2 << std::endl;
	
	return 0;
}

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

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

    int sum1=0, sum2=0;
    for(int P=1; P<101; P++){
        for(int i=0; i<N; i++){
            sum1+= (x[i]-P)*(x[i]-P);
        }
        if(sum1<sum2){
            sum2= sum1;
        }
        else if(P==1){
            sum2=sum1;
        }
        sum1=0;
    }
    cout << sum2 <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int n,k,r,s,p;
cin>>n>>k>>r>>s>>p;
string st;
cin>>st;
int dp[n];
for(int i=0;i<k;i++)
if(st[i]=='r')
dp[i]=p;
else if(st[i]=='p')
dp[i]=s;
else
dp[i]=r;
for(int i=k;i<st.size();i++)
{
    if(st[i]=='r')
    {
       if(dp[i-k]==0 || st[i-k]!='r')
       dp[i]=p;
       else
       {
           
           dp[i]=0;
       } 
    }
    else if(st[i]=='p')
    {
        if(dp[i-k]==0 || st[i-k]!='p')
        dp[i]=s;
        else
        dp[i]=0;
    }
    else
    {
        if(st[i-k]!='s' || dp[i-k]==0)
        dp[i]=r;
        else
        dp[i]=0;
    }
}
int sum=0;
for(int i=0;i<n;i++)
sum+=dp[i];
cout<<sum;
}

Measured memory_bytes: 1232
#include <iostream>
#include <map>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  int a, b, k;
  cin >> a >> b >> k;
  if(b - a + 1 <= k*2){
    for(int i=a; i<=b; i++){
      cout << i << endl;
    }
  }else{
    for(int i=a; i<a+k; i++){
      cout << i << endl;
    }
    for(int i=b-k+1; i<=b; i++){
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
# 19-String-Finding_a_Word.py

# ?????????????´¢
# ??????????????? W ??¨?????? T ????????????????????????T ??????????????? W ?????°???????????????????????°?????????????????????????????????
# ?????? T ????????????????????????????????????????????§????????????????????????????????? Ti ??¨????????????
# ???????????? Ti ?????????????????? W ??¨??????????????????????????°??????????????????
# ???????????§????????¨?°???????????????\???????????????

# Constraints
# W????????????????????????10????¶????????????????
# T??????????????????????????????????????????1000????¶????????????????

# Input
# ?????????????????? W ????????????????????????
# ?¶???????????????°????????????????????£??????????????????????????????
# END_OF_TEXT ??¨??????????????????????????????????????????????????????

# Output
# ?????? W ?????°???????????????????????????

# Sample Input
# computer
# Nurtures computer scientists and highly-skilled computer engineers
# who will create and exploit "knowledge" for the new era.
# Provides an outstanding computer environment.
# END_OF_TEXT

# Sample Output
# 3
# Note

import re

count=0

w = input().lower()

while 1:
	string = input()
	if string=="END_OF_TEXT":
		break;

	string=string.lower().split()
	for i in string:
		count += w==i

print(count)

Measured memory_bytes: 7536
use proconio::{fastout, input};

fn gcd(a: usize, b: usize) -> usize {
    use std::cmp::{max, min};
    let mi = min(a, b);
    let ma = max(a, b);

    let r = ma % mi;
    if r == 0 {
        return mi;
    }

    gcd(mi, r)
}

fn reduce(mut a: isize, mut b: isize) -> (isize, isize) {
    if a == 0 {
        return (0, 1);
    }

    if b == 0 {
        return (1, 0);
    }

    if b < 0 {
        b = -b;
        a = -a;
    }

    let g = gcd(a.abs() as usize, b.abs() as usize) as isize;
    (a / g, b / g)
}

fn inv(ab: (isize, isize)) -> (isize, isize) {
    if ab == (1, 0) {
        return (0, 1);
    }

    if ab == (0, 1) {
        return (1, 0);
    }

    if ab.0 < 0 {
        (ab.1, -ab.0)
    } else {
        (-ab.1, ab.0)
    }
}

static MOD: isize = 1000000007;

#[fastout]
fn main() {
    input! {
        n: usize,
        abs: [(isize, isize); n]
    };

    let mut f = vec![0; n + 1];
    f[0] = 1;
    for i in 1..=n {
        f[i] = (f[i - 1] * 2) % MOD;
    }

    let mut abzero = 0;
    let mut abs2 = vec![];
    let mut hash = std::collections::HashMap::<(isize, isize), usize>::new();
    for (a, b) in abs {
        if a == 0 && b == 0 {
            abzero += 1;
            continue;
        }

        let rab = reduce(a, b);
        if let Some(v) = hash.get_mut(&rab) {
            *v = *v + 1;
        } else {
            hash.insert(rab, 1);
        }

        abs2.push((a, b));
    }

    let mut set = std::collections::HashSet::<(isize, isize)>::new();
    let mut m = 1;
    let abs2len = abs2.len();

    while let Some((&rab, &c)) = hash.iter().next() {
        hash.remove(&rab);

        let mut s = 1;
        for _ in 0..c {
            s *= 2;
            s %= MOD;
        }

        let rab_inv = inv(rab);

        if let Some(d) = hash.remove(&rab_inv) {
            s += (MOD - 1);
            s %= MOD;

            let mut t = 1;
            for _ in 0..d {
                t *= 2;
                t %= MOD;
            }

            t += (MOD - 1);
            t %= MOD;

            m *= (s + t + 1) % MOD;
            m %= MOD;
        } else {
            m *= s;
            m %= MOD;
        }
    }

    println!("{}", (abzero as isize + m + (MOD - 1)) % MOD);
}


Measured memory_bytes: 25976
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int[] b = new int[a-1];
    int[] c = new int[a];
    int ans = 0;
    for(int i = 0;i < b.length;i++){
      b[i] = sc.nextInt();
    }
    c[0] = b[0];
    c[a-1] = c[a-2];
    for(int j = 1;j<b.length;j++){
      if(b[j-1] <= b[j]){
        c[j] = b[j-1];
      }else{
        c[j] = b[j];
      }
      c[a-1] = b[a-2];
    }
    //System.out.println(Arrays.toString(c));
    for(int x = 0;x < c.length;x++){
      ans +=c[x];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#include<stdio.h>
char s[51],a[51];
int n,k;
int main(void){
    scanf("%d%d%s",&n,&k,s);
    if(s[k-1] == 'A'){
        s[k-1] = 'a';
    }else if(s[k-1] == 'B'){
        s[k-1] = 'b';
    }else{
        s[k-1] = 'c';
    }
  printf("%s",s);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  long double a,b;
  cin >> a >> b;
  a*=b;
  cout << (ll)a << endl;
  return 0;
}


Measured memory_bytes: 3736
def maybe_prime(d,s,n):
    for a in (2,3,5,7):
        x = pow(a,d,n)
        if x==1 or x==n-1:
            continue
        for i in range(1,s):
            x = x*x%n
            if x==1: return False
            elif x == n-1:
                break
        else:
                return False
    return True
 
def is_prime(n):
    if n in (2,3,5,7): return True
    elif 0 in (n%2,n%3,n%5,n%7): return False
    else:
        d,s = n-1, 0
        while not d%2:
            d,s = d>>1,s+1
        return maybe_prime(d,s,n)
cnt = 0
n = int(input())
for i in range(n):
  n = int(input())
  if is_prime(n): cnt+=1
 
print(cnt)

Measured memory_bytes: 7736
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(',');
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        for(int i=0; i<3; i++){
            sb.Append(input[i]);
            sb.Append(" ");
        }
        Console.WriteLine(sb.ToString());
	}
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll x,ans=0;
    cin >> x;
    ll a = (ll)x/11;
    ans += (ll)a*2;
    ll b = x%11;
    if(b>6) ans += 2;
    else if(b != 0)ans+=1;

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

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define int long long
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int  n;
int a[100000+5];
bool before[100000+5];
bool after[100000+5];
int cnt[100000+5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i,n) cin >> a[i];
    int ans=0;
    rep(i,n){
        if (before[i]) continue;
        int l=0;
        int now=i;
        int start=i;
        vector<int> path;
        bool flag=false;
        while (true){
            if (after[now]) break;
            if (before[now] && !after[now]){
                flag=true;
                break;
            }
            before[now]=true;
            cnt[now]=l;
            path.pb(now);
            now=(now+a[now])%n;
            l++;
        }
        for (auto i: path) after[i]=true;
        if (flag){
            if (start==now) ans+=l;
            else ans+=l-cnt[now];
        }
    }
    cout << ans << endl;
}

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 200000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	vi bit1(62);
	rep(j, 62) bit1[j] = 0;

	rep(i, n) {
		ll a;
		cin >> a;
		rep(j, 62) {
			if (a%2)bit1[j]++;
			a /= 2;
		}
	}

	ll ans = 0;

	rep(j, 62) {
		ll hoge=1;
		hoge *= (ll)bit1[j];hoge %= MOD;
		hoge *= ((ll)n - bit1[j]);hoge %= MOD;
		rep(k, j) {
			hoge *= 2;
			hoge %= MOD;
		}
		ans +=hoge;
		ans %= MOD;
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

h,w = readInts()
ch,cw = readInts()
dh,dw = readInts()
s = ["#"*(w+2)]+["#"+input()+"#" for i in range(h)]+["#"*(w+2)]
visited = [[-2]*(w+2) for i in range(h+2)]
for i in range(h+2):
	for j in range(w+2):
		if s[i][j]==".":
			visited[i][j] = -1

delta1 = [[0,1],[1,0],[-1,0],[0,-1]]

q = {(ch,cw)}
set_list = set()
cost = 0
while 1:
	if len(q)==0:
		break
	while len(q) !=0:
		x,y = q.pop()
		set_list.add((x,y))
		visited[x][y] = cost
		for dx,dy in delta1:
			x2 = x+dx
			y2 = y+dy
			if visited[x2][y2]==-1:
				q.add((x2,y2))
	cost+=1
	while len(set_list) != 0:
		x,y = set_list.pop()
		for dx in range(-2,3):
			for dy in range(-2,3):
				x2 = x+dx
				y2 = y+dy
				if visited[min(x2,h+1)][min(y2,w+1)]!=-1: continue
				q.add((x2,y2))

print(visited[dh][dw])

Measured memory_bytes: 85648
#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

//-----------------------------------------------------------------------------------

	int n, a, m;
	m = 0;
	cin >> n;
	for(int i =0; i < n; i++){
		cin >> a;
		if(a != i+1){
			m += 1;
		}
	}
	if(m <= 2){
		cout << "YES\n";
	}else{
		cout << "NO\n";
	}

}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <bitset>
#include <cstdio>

using namespace std;
using namespace std::placeholders;

// namespace { struct NoSync { NoSync() { cin.tie(0); ios::sync_with_stdio(false); } } nosync; }

using ll = long long;
#define float double

constexpr ll INF = 999999999;
constexpr ll MOD = 1e9 + 7;

#define y0 Y0
#define y1 Y1
#define j0 J0
#define j1 J1
#define prev PREV
#define next NEXT

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i##_len = (n), i = (i##_len) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define permutations(v) sort(all(v));for(bool v##p = true; v##p; v##p=next_permutation(all(v)))
#define UNIQUE(v) (v).erase(unique(all(v)), (v).end())
#define REMOVE(v) (v).erase(remove(all(v)), (v).end())
#define ROTATE(v, n) rotate((v).begin(), (v).begin() + (n), (v).end())
#define TO_SUMS(v) partial_sum(all(v), (v).begin())
#define SUMS(srcv, dstv) partial_sum(all(srcv), (dstv).begin())
#define nth_bit(n) (1LL<<(n))

template <typename T> T high()  { return numeric_limits<T>::max(); }
template <typename T> T high(T) { return numeric_limits<T>::max(); }
template <typename T> T low()   { return numeric_limits<T>::lowest(); }
template <typename T> T low(T)  { return numeric_limits<T>::lowest(); }

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; }

// f には functional のオブジェクトが便利 (lambda 式も   [](int a){ return a / 2 }   みたいな)
template<class C, class F> inline C mapped(const C& c, F f){// mapっていうSTLがあるから...
    // ex: mapped(v, bind(plus<ll>(), _1, 2))   [v の各要素について x + 2]
    C r; r.reserve(c.size()); transform(all(c), back_inserter(r), f); return r;
}
template<class C, class F> inline C filtered(const C& c, F f){
    // ex: filtered(v, bind(equal_to<ll>(), bind(modulus<ll>(), _1, 2), 0)   [x mod 2 == 0 な x を取ってくる]
    C r; copy_if(all(c), back_inserter(r), f); return r;
}
template<class C, class I, class F> inline typename C::value_type foldl(const C& c, I i, F f){
    // ex: foldl(v, 1, multiplies<int>())   [v の総乗]
    return accumulate(all(c), static_cast<typename C::value_type>(i), f);
}


int main(){
    ll S;
    cin >> S;
    cout << S / 3600 << ":" << (S % 3600) / 60 << ":" << S % 60 << endl;

    return 0;
}



Measured memory_bytes: 3072
<?php
    fscanf(STDIN, "%d", $n);
    $ok = 1;
    $ng = $n + 1;
    while($ok + 1 < $ng){
        $mid = floor(($ok + $ng) / 2);
        if($mid * $mid <= $n){
            $ok = $mid;
        }else{
            $ng = $mid;
        }
    }
    echo ($ok * $ok)."\n";
?>


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define all(v) v.begin(),v.end()
int mod =1e9+7;

int cache[102][100008];
int n,w,wt[100006]={0},v[100006]={0};

int solve(int index,int have)
{
    if(index == n) return 0;
    if(cache[index][have] != -1) return cache[index][have];
    int &ans = cache[index][have];
    ans = 0;
    if(wt[index]+have <= w)
    {
        ans = max(v[index]+solve(index+1,have+wt[index]),solve(index+1,have));
    }
    else ans = solve(index+1,have);
    return ans;
}

int32_t main() {
    memset(cache,-1,sizeof(cache));
	cin>>n>>w;
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>v[i];
    }
    cout<<solve(0,0)<<"\n";
    return 0;
}

Measured memory_bytes: 80000
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <map>

using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define ld long double
#define forever while(true)
//#define 

  int main(){
string a;
while(cin>>a)
{ 
bool owin=false;
bool xwin=false;
if(a[0]==a[1]&&a[1]==a[2]){
if(a[0]=='o'){owin=true;}
else if(a[0]=='x'){xwin=true;}
}
if(a[3]==a[4]&&a[5]==a[4]){
if(a[4]=='o'){owin=true;}
else if(a[4]=='x'){xwin=true;}
}
if(a[6]==a[7]&&a[7]==a[8]){
if(a[6]=='o'){owin=true;}
else if(a[6]=='x'){xwin=true;}
}
if(a[0]==a[4]&&a[4]==a[8]){
if(a[0]=='o'){owin=true;}
else if(a[0]=='x'){xwin=true;}
}
if(a[4]==a[6]&&a[4]==a[2]){
if(a[4]=='o'){owin=true;}
else if(a[6]=='x'){xwin=true;}
}
if(a[0]==a[3]&&a[3]==a[6]){
if(a[0]=='o'){owin=true;}
else if(a[0]=='x'){xwin=true;}
}
if(a[4]==a[1]&&a[4]==a[7]){
if(a[1]=='o'){owin=true;}
else if(a[1]=='x'){xwin=true;}
}
if(a[2]==a[5]&&a[8]==a[2]){
if(a[2]=='o'){owin=true;}
else if(a[5]=='x'){xwin=true;}
}
if(owin){cout<<"o"<<endl;}
else if(xwin){cout<<"x"<<endl;}
else{cout<<"d"<<endl;}
}return 0;
}


Measured memory_bytes: 2992
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int x;
    cin >> x;
    if(x==3||x==5||x==7)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
from itertools import permutations

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

a = range(1, n+1)
t, u = 0, 0
for i, s in enumerate(permutations(a)):
    if s == p: t = i
    if s == q: u = i

print(abs(t - u)) 


Measured memory_bytes: 3060
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
constexpr double EPS = 1e-8;

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T &a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    string s;
    cin >> s;

    int n = s.size();

    int ans = n;
    rep(i, n - 1){
        if(s[i] == s[i + 1]){
            --ans;
            i += 2;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 720
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b = sc.nextInt();
		int ans = 0;
        if(a == 0){a = 1;}
        else if(a == 1){a = 100;}
        else {a = 10000;}
        for(int i = 1;i <= b; i++){
          ans = a * i;
          if(i >= 100){
            ans = a * (i + 1);
          }
        }
        
          System.out.println(ans);

 
      	
 
    }
}

Measured memory_bytes: 35816
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using  namespace std;
int main() {
  int n;
  cin >> n;
  int a[n+2];
  rep(i, n) cin >> a[i+1];
  a[0] = a[n+1] = 0;
  int l[n+2], r[n+2];
  l[0] = r[n+1] = 0;
  for (int i = 1; i <= n+1; ++i) {
    l[i] = l[i-1] + abs(a[i]-a[i-1]);
    r[n+1-i] = r[n+2-i] + abs(a[n+1-i]-a[n+2-i]);
  }
  for (int i = 1; i <= n; ++i) {
    cout << l[i-1] + r[i+1] + abs(a[i-1]-a[i+1]) << endl;
  }
  return 0;
}

Measured memory_bytes: 2432