akhauriyash/Code-Regression huggingface dataset:
/*
 * ID: 2497
 * Problem A: Approximate Circle
 */

#include <stdio.h>

int main(void)
{
    int n;
    double x1 = 0, y1 = 0;
    double x2 = 0, xy = 0, y2 = 0;
    double x3 = 0, x2y = 0, xy2 = 0, y3 = 0;

    scanf("%d", &n);

    int i;
    for (i = 0; i < n; i++) {
        double x, y, xd, yd;
        scanf("%lf %lf", &x, &y);
        x1 += x; y1 += y;
        xd = x * x; yd = y * y;
        x2 += xd; xy += x * y; y2 += yd;
        x3 += x * xd; x2y += xd * y; xy2 += x * yd; y3 += y * yd;
    }
    x1 /= n; y1 /= n;
    x2 /= n; xy /= n; y2 /= n;
    x3 /= n; x2y /= n; xy2 /= n; y3 /= n;

    double A = -x3 - xy2 +  x1 * (x2 + y2);
    double B = -x2y - y3 +  y1 * (x2 + y2);
    double C = xy -  x1 * y1;
    double X = x2 -  x1 * x1;
    double Y = y2 -  y1 * y1;

    double det = X * Y - C * C;
    double a = ( Y * A - C * B) / det;
    double b = (-C * A + X * B) / det;
    double c = -(x2 + y2 + a * x1 + b * y1);

    printf("%f %f %f\n", a, b, c);

    return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> data(N);
  for(int i=0;i<N;i++){
    cin>>data.at(i);
  }
  int sum=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      //cout<<"i"<<i<<"j"<<j<<endl;
      sum+=(data.at(i)*data.at(j));
      //cout<<"sum"<<sum<<endl;
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
int jumps(std::vector<int> arr, int n)
{
	vector<int> dp(n + 1);
	dp[1] = 0;
	for (int i = 2 ; i <= n; i++) {
		int op1 = abs(arr[i] - arr[i - 1]) + dp[i - 1];
		int op2 = (i == 2) ? inf : abs(arr[i] - arr[i - 2]) + dp[i - 2];
		dp[i] = min(op1, op2);
	}
	return dp[n];
}
int main() {
	int n; cin >> n;
	vector<int> arr(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	cout << jumps(arr, n);
	return 0;
}


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

using namespace std;

typedef long long ll;

const ll p = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  int n; cin >> n;
  vector<vector<int> > a(n, vector<int>(n));
  for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j];
  vector<vector<ll> > memo(n, vector<ll>((1 << n) + 9, -1));
  function<ll(int, int)> dp = [&](int i, int mask) {
    if (i == n) return ll(mask == (1 << n) - 1);
    else if (memo[i][mask] != -1) return memo[i][mask];
    else {
      ll ret = 0;
      for (int j = 0; j < n; j++) {
        if(mask & (1 << j)) continue;
        if(a[i][j]) ret = (ret + dp(i + 1, mask | (1 << j))) % p;
      }
      return memo[i][mask] = ret;
    }
  };
  cout << dp(0, 0) << endl;
  return 0;
}


Measured memory_bytes: 360832
#include<iostream>
#include<string.h>
using namespace std;

int main(){

    char a[100000];

    cin >> a;

    int i=0,kaisuu=0;

    while(a[i+1]!='\0'){
        if(a[i]==a[i+1]){
            if(a[i+1]=='0'){
                a[i+1] = '1';
                //cout << a[i+1];
            }
            else{
                a[i+1] = '0';
                //cout << a[i+1];
            }
            kaisuu++;
        }
        i++;
    }
    cout << kaisuu << endl;


    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long n = sc.nextLong();
			long a = sc.nextLong();
			long b = sc.nextLong();

			long tmp = b - a;
			if (tmp % 2 == 0) {
				System.out.println(tmp / 2);
				return;
			}

			long tmp1 = a + (tmp - 1) / 2;

			long tmpB = n - b + 1;
			long tmpA = a + tmpB;
			long tmp2 = n - b + 1 + (n - tmpA) / 2;

			System.out.println(tmp1 < tmp2 ? tmp1 : tmp2);
		}
	}
}

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

typedef pair<long, long> P;

long power(long n, long m){
    long ans = 1;
    if(m > 0){
        ans = power(n, m / 2);
        if(m % 2 == 0) ans = ans * ans;
        else ans = n * ans * ans;
    }
    return ans;
}

vector<P> prime(long n){
    vector<P> ans;
    if(n % 2 == 0) {
        long e = 0;
        while(n % 2 == 0){
            n /= 2;
            e++;
        }
        ans.push_back(P(2, e));
    }
    for(long i = 3; n != 1; i += 2){
        if(n % i == 0) {
            long e = 0;
            while(n % i == 0){
                n /= i;
                e++;
            }
            ans.push_back(P(i, e));
        }
    }
    return ans;
}

int main(){
    long n;
    cin >> n;
    vector<P> v = prime(n);
    long ans = 1;
    for(long i = 0; i < v.size(); i++)
        ans *= power(v[i].first, v[i].second) - power(v[i].first, v[i].second - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(int A, int B) {
        if (A > B) {
            return -1;
        }
        int L = min(A, B);
        int R = 20000;

        for (int i = L; i <= R; ++i) {
            if ((i * 8 / 100) == A && (i / 10) == B) {
                return i;
            }
        }
        return -1;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    Solution sol;
    int A, B;
    cin >> A >> B;

    cout << sol.solve(A, B) << "\n";

    return 0;
}

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

int main()
{
	// ?????°??£?¨?
	int a;
	int b;
	int c;
	int temp;
	// ??\???
	cin >> a >> b >> c;

	// ??????
	if (a > b)
	{
		temp = a;
		a = b;
		b = temp;
	}

	if (b > c)
	{
		temp = b;
		b = c;
		c = temp;
	}

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

	// ??????
	cout << a << " " << b << " " << c << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, N);
  VEC(ll, a, N);
  vector<ll> acc(N);
  acc[0] = a[0];
  rep(i, 1, N) {
    acc[i] = acc[i - 1] + a[i];
  }
  ll mn = LINF;
  rep(i, 0, N - 1) {
    mn = min(mn, abs(acc[i] - (acc[N - 1] - acc[i])));
  }
  print(mn);
}


Measured memory_bytes: 3456
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think('redcoder'), 1)

    def test_2(self):
        self.assertEqual(think('vvvvv'), 0)

    def test_3(self):
        self.assertEqual(think('abcdabc'), 2)


def solve():
    s = read()
    result = think(s)
    write(result)


def read():
    return read_line()


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    mid = len(data) // 2 - 1

    left = 0
    right = len(data) - 1
    count = 0
    while left <= mid:
        count += 0 if data[left] == data[right] else 1
        left += 1
        right -= 1
    return count


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

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


bool kaibun(string s) {
  int N = s.size();
  for(int i=0; i<N/2; i++) if(s[i] != s[N-1-i]) return false;
  return true;
}

signed main() {
  string S;
  cin >> S;
  int N = S.size();

  if(!kaibun(S)) {
    puts("No");
    return 0;
  }

  if(!kaibun(S.substr(0, (N-1)/2))) {
    puts("No");
    return 0;
  }

  if(!kaibun(S.substr((N+3)/2-1, (N-1)/2))) {
    puts("No");
    return 0;
  }
  puts("Yes");
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.stream.Stream;

public class Main {
    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static PrintWriter pw = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        int n = nextInt();
        if(n == 1){
            println("Hello World");
        }else{
            int a = nextInt();
            int b = nextInt();
            println(a + b);
        }
        // 解答ここから
//        int N = nextInt();
//        int[] X = arrayOfInt();
//        int[] x = X.clone();
//        Arrays.sort(x);
//        // 中央値の境界を取る
//        int floor = N/2 - 1;
//        int border = x[floor];
//
//        int a = x[floor + 1];
//        int b = x[floor];
//        for(int i = 0;i < N;i++){
//            if(X[i] <= border){
//                println(a);
//            }else{
//                println(b);
//            }
//        }

        //解答ここまで
        pw.flush();
        return;
    }
    // 入力受け取り
    static String next() throws IOException {return br.readLine();}
    static int nextInt() throws IOException{return getInt(br.readLine());}
    static long nextLong() throws IOException{return getLong(br.readLine());}
    static String[] arrayOfString() throws IOException{return br.readLine().split(" ");}
    static int[] arrayOfInt() throws IOException{return toIntArray(arrayOfString());}
    // 変換
    static long getLong(String val) {return Long.parseLong(val);}
    static int getInt(String val) {return Integer.parseInt(val);}
    static int[] toIntArray(String[] array) {return Stream.of(array.clone()).mapToInt(Integer::parseInt).toArray();}
    static String joinToString(String[] array) {
        StringBuilder sb = new StringBuilder();
        for(int i = 0;i < array.length;i++) sb.append(array[i]);
        return sb.toString();
    }

    // 出力
    static void println(Object val){pw.println(val);}
}


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


int main(){
    int x,y,z;
    cin>>x>>y>>z;
    int c[6];
   
    //xyz xzy, yxz, yzx, zxy,zyx
    c[0]=abs(x-y)+abs(y-z);
    int temp=c[0];
    temp=(temp>c[0])? c[0]:temp;
    c[1]=abs(x-z)+abs(z-y);
    temp=(temp>c[0])? c[0]:temp;
    c[2]=abs(x-y)+abs(x-z);
    temp=(temp>c[2])? c[2]:temp;
    c[3]=abs(y-z)+abs(z-x);
    temp=(temp>c[3])? c[3]:temp;
    c[4]=abs(z-x)+abs(x-y);
    temp=(temp>c[4])? c[4]:temp;
    c[5]=abs(z-y)+abs(x-y);
    temp=(temp>c[5])? c[5]:temp;
    cout<<temp;
    return 0;
    
}

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

int main(){
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    int ac[100010];
    ac[0] = 0;
    ac[1] = 0;
    for (int i=1; i<S.size(); ++i) {
        ac[i+1] = ac[i];
        if (S[i-1] == 'A' && S[i] == 'C') {
            ac[i+1] ++;
        }
    }

    int l, r, ans = 0;
    for (int i=0; i<Q; ++i) {
        cin >> l >> r;
        cout << ac[r] - ac[l] << endl;
    }

    return 0;
}

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

void dfs(int node, vector<int> &dp, vector<bool> &vis, unordered_map<int, vector<int>> &m)
{
  vis[node]=true;
  for(auto i:m[node])
  {
    if(!vis[i])
      dfs(i, dp, vis, m);
    dp[node]=max(dp[node], 1+dp[i]);
  }
}
void addedge(unordered_map<int, vector<int>> &m, int u, int v)
{
  m[u].push_back(v);
}
int main()
{
  int n, m, i, j;
  cin>>n>>m;
  unordered_map<int, vector<int>> adj;
  for(i=0;i<m;i++)
  {
    int u, v;
    cin>>u>>v;
    addedge(adj, u, v);
  }
  vector<bool> vis(n+1, false);
  vector<int> dp(n+1,0);
  for(i=1;i<=n;i++)
  {
    if(!vis[i])
      dfs(i, dp, vis, adj);
  }
  int mx=0;
  for(i=1;i<=n;i++)
    mx=max(mx, dp[i]);
  cout<<mx<<endl;
  return 0;
}

Measured memory_bytes: 12836
local n=io.read("n")
local a_map={}
for i=(n%2==0 and 1 or 0),n,2 do
    a_map[i]=(i==0 and 1 or 2)
end

local a={}
for i=1,n do
    local input=io.read("n")
    a[input]=(a[input] or 0)+1
end

if #a~=#a_map then
    print(0)
    return
end

local counter=1
for k,v in pairs(a_map) do
    counter=(a[k]==a_map[k] and counter*v%1000000007 or 0)
end
print(counter)

Measured memory_bytes: 7404
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int v,e,s,t,visited[N],lowlink[N],num=1;
vector<int> G[N],ans;

void dfs(int x,int prev){
  visited[x]=num++;
  lowlink[x]=visited[x];
  int maxlowlink=0,cnt=0;
  for(int i=0;i<G[x].size();i++){
    int nx=G[x][i];
    if(nx==prev)continue;
    if(!visited[nx]){
      dfs(nx,x);
      cnt++;
      maxlowlink=max(maxlowlink,lowlink[nx]);
      lowlink[x]=min(lowlink[x],lowlink[nx]);
    }else lowlink[x]=min(lowlink[x],visited[nx]);
  }
  if(!x&&cnt>=2)ans.push_back(x);
  if(x&&visited[x]<=maxlowlink)ans.push_back(x);
}

int main(){
  cin>>v>>e;
  for(int i=0;i<e;i++){
    cin>>s>>t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  dfs(0,0);
  sort(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++)
    cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 6756
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         int N=gi();
         String[] s=new String[N];

         long ans=0;
         long ac=0;
         long bc=0;
         long abc=0;

         for (int i=0;i<N;i++) {
        	 s[i]=gs();
        	 ans+=s[i].split("AB").length-1;
        	 if(s[i].charAt(0)=='B' && s[i].charAt(s[i].length()-1)=='A') {
        		 abc++;
        	 } else if(s[i].charAt(s[i].length()-1)=='A') {
        		 ac++;
        	 } else if(s[i].charAt(0)=='B') {
        		 bc++;
        	 }
         }
         
         if(abc>0) {
        	 ans+=abc-1;
        	 if(ac>0) {
        		 ac--;
        		 ans++;
        	 }
        	 if(bc>0) {
        		 bc--;
        		 ans++;
        	 }
         }
         ans+=Math.min(ac, bc);
         
         System.out.println(ans);

     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> b;
	for(int i = 1; i <= N; ++i) {
		int t;
		cin >> t;
		if(t > i) {
			cout << "-1\n";
			return 0;
		}
		b.push_back(t);
	}
	vector<int> ans;
	while(b.size() > 0) {
		for(int i = b.size(); i >= 1; --i) {
			if(b[i - 1] == i) {
				ans.push_back(i);
				b.erase(b.begin() + (i - 1));
				break;
			}
		}
	}
	reverse(ans.begin(), ans.end());
	for(int i = 0; i < N; ++i) {
		cout << ans[i] << '\n';
	}
	return 0;
}



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

using VI = vector<long>;

int main() {
  long n, m, t;
  cin >> n >> m >> t;

  VI as;
  long ans = 0;
  for (int i = 0; i < n; i++) {
    long a;
    cin >> a;
    if (i == 0) ans += a - m;
    if (i == n - 1) ans += max(0l, t - a - m);
    as.push_back(a);
  }

  for (int i = 0; i < n - 1; i++) {
    ans += max(0l, as[i + 1] - as[i] - 2 * m);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3148
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  vll as(n);
  rep(i,n) cin >> as[i];
  rSort(as);

  ll ans = as[0];
  n -= 2;
  ll idx = 1;
  while(n > 0){
    ans += as[idx];
    n--;
    if(n == 0) break;
    ans += as[idx];
    n--;
    idx++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4840
#include<stdio.h>
int main()
{
long long int n,i,q;
  scanf("%lld",&n);
long long int a[n],sw[100000],sum;
  
  sum=0;
  
  for(i=0;i<100000;++i)
  {
   sw[i]=0;
  }
  
  for(i=0;i<n;++i)
  {
  scanf("%lld",&a[i]);
    sum=sum+a[i];
    sw[a[i]-1]++;
  }
  scanf("%lld",&q);
  long long int b[q],c[q];
  
  for(i=0;i<q;++i)
  {
  scanf("%lld %lld",&b[i],&c[i]);
    sum=sum+(c[i]-b[i])*sw[b[i]-1];
    printf("%lld\n",sum);
    sw[c[i]-1]=sw[c[i]-1]+sw[b[i]-1];
    sw[b[i]-1]=0;
    
  }

return 0;}

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

int H, W;
char s[202][202];
int adj[404][404];
int main()
{
    scanf("%d%d", &H, &W);
    for(int i=0; i<H; ++i)
        scanf("%s", s[i]);
    memset(adj, 0x3f, sizeof adj);
    for(int i=0; i<H; ++i)
    {
        for(int j=0; j<W; ++j)
        {
            int now = i*W+j;
            int r = i*W+j+1;
            int d = i*W+j+W;
            if(j != W-1)
            {
                adj[r][now] = adj[now][r] = 1;
            }
            if(i != H-1)
            {
                adj[d][now] = adj[now][d] = 1;
            }
        }
    }
    for(int i=0; i<H; ++i)
    {
        for(int j=0; j<W; ++j)
        {
            int n = i*W+j;
            if(s[i][j] == '#')
            {
                for(int k=0; k<H*W; ++k)
                    adj[n][k] = adj[k][n] = 0x3f3f3f3f;
            }
        }
    }
    for(int i=0; i<H*W; ++i) adj[i][i] = 0;
    for(int k=0; k<H*W; ++k)
        for(int i=0; i<H*W; ++i)
            for(int j=0; j<H*W; ++j)
                adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
    int maxv = 0;
    for(int i=0; i<H*W; ++i)
        for(int j=0; j<H*W; ++j)
        {
            if(adj[i][j] > 30303) continue;
            maxv = max(maxv, adj[i][j]);
        }
    cout << maxv <<endl;
}

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

using namespace std;

#define INF 1<<30
#define LINF 1ll<<60ll
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)


int main(){
    int n,h;
    vi a,b;
    cin>>n>>h;
    REP(i,n){
        int buf;
        cin>>buf;
        a.pb(buf);
        cin>>buf;
        b.pb(buf);
    }
    int s_max= *std::max_element(all(a));
    sort(all(b),greater<int>());
    int ans=0;
    FORVEC(i,b){
        if(b[i]<=s_max)break;
        ans++;
        h-=b[i];
        if(h<=0){
            cout<<ans<<endl;
            return 0;
        }
    }
    ans+=(h+s_max-1)/s_max;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1276
import java.util.*;
import static java.lang.System.out;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        if((a+b)>=c) {
            out.print("Yes");
        }else{
            out.print("No");
        }
    }
}

Measured memory_bytes: 21972
/*氏名：保坂優介, 学籍番号：200441141
  概要：xの3乗を計算するプログラム*/

#include<stdio.h>

int main(void)
{
    int x,ans;          //変数の宣言

    scanf("%d", &x);        //入力

    ans = x * x * x;        //計算

    printf("%d\n",ans);        //出力

    return 0;
}


Measured memory_bytes: 2040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = int.Parse(ReadLine());
		var l = new int[n];
		for(int i = 0; i < n; i++)
		{
			l[i] = int.Parse(ReadLine()) - 1;
		}
		var b = false;
		int j = 0;
		for(int i = 1; i <= n; i++)
		{
			j = l[j];
			if(j == 1)
			{
				WriteLine(i);
				return;
			}
		}
		WriteLine(-1);
	}
}


Measured memory_bytes: 20896
#include<iostream>
#include<vector>
#define M   1500000
using namespace std;
int main(void){
int n,m;
while(1){
cin>>n>>m;
if(n==0)break;
vector<int> h(n),w(m);
vector<int> hl(M,0),wl(M,0);
for(int i=0;i<n;i++){
	cin>>h[i];
}
for(int i=0;i<m;i++){
	cin>>w[i];
}
int sum=0;
for(int i=0;i<n;i++){
	 sum=0;
	for(int j=i;j<n;j++){
		sum+=h[j];
		hl[sum-1]++;
	}
}
for(int i=0;i<m;i++){
	 sum=0;
	for(int j=i;j<m;j++){
		sum+=w[j];
		wl[sum-1]++;
	}
}
int t=0;
for(int i=0;i<M;i++){
		t+=hl[i]*wl[i];
	
}
cout<<t<<endl;
}
	return 0;
}

Measured memory_bytes: 14556
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N, X, L[110];
int acc[110];

void input() {
  cin >> N >> X;
  loop(n,0,N) cin >> L[n];
}

void solve() {
  acc[0] = 0;
  for (int n=0; n<N; n++) {
    acc[n+1] = acc[n] + L[n];
    if (acc[n+1] > X) {
      cout << n+1 << endl;
      return;
    }
  }

  cout << N+1 << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int h;

void maxHeapify(int A[],int i){
  if(i>h/2) return;
  
  int l,r,largest;
  l=2*i;
  r=2*i+1;
  if(A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=h && A[r]>A[largest]) largest=r;
  
  if(largest != i){
    swap(A[i],A[largest]);
    maxHeapify(A,largest);
  }
}

int main() {
  cin>>h;
  
  int vec[500010];
  for(int i=1;i<=h;i++) cin>>vec[i];
  
  for(int i=h/2;i>0;i--) maxHeapify(vec,i);
  
  for(int i=1;i<=h;i++) cout<<" "<<vec[i];
  cout<<endl;
      
  return 0;
}


Measured memory_bytes: 5048
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        a: usize, b: usize, c: usize
    }
    for x in 1..(b + 1) {
        if a * x % b == c {
            println!("YES");
            std::process::exit(0);
        }
    }
    println!("NO");
}


Measured memory_bytes: 4352
n = int(input())
A = [0]
for _ in range(n):
    A.append(int(input()))

seen = set()
up = 1
cnt = 0
while up != 2:
    if up in seen:
        cnt = -1
        break
    seen.add(up)
    up = A[up]
    cnt += 1

print(cnt)


Measured memory_bytes: 94216
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long a = long.Parse(str[0]);
		long b = long.Parse(str[1]);
		string ans = "x";
		if(a+b==15){
			ans = "+";
		} else if(a*b==15){
			ans = "*";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
#include <iostream>
 
using namespace std;
 
int main()
{
    double tmp;
     
    while(cin >> tmp)
	{
        if(tmp <= 48.0)
		{
            cout << "light fly" << endl;
        } else if(tmp <= 51.0)
		{
            cout << "fly" << endl;
        } else if(tmp <= 54.0)
		{
            cout << "bantam" << endl;
        } else if(tmp <= 57.0)
		{
            cout << "feather" << endl;
        } else if(tmp <= 60.0)
		{
            cout << "light" << endl;
        } else if(tmp  <= 64.0)
		{
            cout << "light welter" << endl;
        } else if(tmp <= 69.0)
		{
            cout << "welter" << endl;
        } else if(tmp <= 75.0)
		{
            cout << "light middle" << endl;
        } else if(tmp <= 81.0)
		{
            cout << "middle" << endl;
        } else if(tmp <= 91.0)
		{
            cout << "light heavy" << endl;
        } else 
		{
            cout << "heavy" << endl;
        }
    }
     
    return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mx 10000000000008
#define mod 1000000007
ll n,t,arr[sz],brr[sz],crr[sz],j;
vector<ll>v;
char c[sz];
int main()
{
    t=1;
   // scanf("%lld",&t);
    while(t--)
    {
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld %lld",&arr[i],&brr[i]);
        if(i>=3)
        {
            if(arr[i]==brr[i] && arr[i-1]==brr[i-1] && arr[i-2]==brr[i-2])
                j++;
        }
    }
    if(j)
        printf("Yes\n");
    else
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define input_from_file  freopen("input.txt", "r", stdin);

int main()
{
  // input_from_file;
  ll n,k;cin>>n>>k;
  vector<ll> vec(n,0),dp(k+1,0);
  for(ll i=0;i<n;i++)   {cin>>vec[i];dp[vec[i]]=1;}
  for(ll i=vec[0];i<=k;i++){
    for(ll j=0;j<n;j++){
      if(dp[i] || i-vec[j]<0) break;
      if(dp[i-vec[j]]==0) dp[i]=1;
    }
  }
  // for(ll i=0;i<=k;i++)  cout<<dp[i]<<" ";cout<<endl;
  if(dp[k]) cout<<"First";
  else  cout<<"Second";
  return 0;

}

Measured memory_bytes: 1024
<?php
fscanf(STDIN, '%d', $n);
$v = array_map('intval', explode(' ', trim(fgets(STDIN))));
$c = array_map('intval', explode(' ', trim(fgets(STDIN))));
$ans = 0;
for ($i = 0; $i < $n; $i++) {
    $val = $v[$i] - $c[$i];
    if ($val > 0) $ans += $val;
}
echo $ans . PHP_EOL;

Measured memory_bytes: 4728
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef bitset<16> BS;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;
const int MAX_K = 1000;

ll N, K;

ll mod[4 * MAX_K + 1][4 * MAX_K + 1], sum[4 * MAX_K + 1][4 * MAX_K + 1];

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

    cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        ll x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W') {
            mod[x % (2 * K) + 1][(y + K) % (2 * K) + 1]++;
        } else {
            mod[x % (2 * K) + 1][y % (2 * K) + 1]++;
        }
    }

    for (int i = 0; i < 4 * K; i++) {
        for (int j = 0; j < 4 * K; j++) {
            mod[i + 1][j + 1] = mod[i % (2 * K) + 1][j % (2 * K) + 1];
        }
    }

    for (int i = 1; i <= 4 * K; i++) {
        for (int j = 1; j <= 4 * K; j++) {
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + mod[i][j];
        }
    }

    ll ans = 0;
    for (int i = 1; i <= 2 * K; i++) {
        for (int j = 1; j <= 2 * K; j++) {
            ll res = 0;
            res += sum[i + 2 * K - 1][j + 2 * K - 1] - sum[i + K - 1][j + 2 * K - 1] - sum[i + 2 * K - 1][j + K - 1] + sum[i + K - 1][j + K - 1];
            res += sum[i + K - 1][j + K - 1] - sum[i + K - 1][j - 1] - sum[i - 1][j + K - 1] + sum[i - 1][j - 1];
            ans = max(res, ans);
        }
    }

    /*
    for (int i = 1; i <= 2 * K; i++) {
        for (int j = 1; j <= 2 * K; j++) {
            cout << "i = " << i << ", j = " << j << ", sum = " << sum[i][j] << "\n";
        }
    }
    */

    cout << ans << "\n";

    return 0;
}

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


int main() {
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    for (int i = 0; i < N; ++i) {
        cin >> v.at(i);
    }
    vector<int> vv(N+1);
    for (int i = 0; i < N; ++i) {
        vv.at(v.at(i))++ ;
    }
    sort(vv.begin(), vv.end());
    reverse(vv.begin(), vv.end());
    int ans = 0;
    for (int i = 0; i < vv.size(); ++i) {
        if (vv.at(i) != 0 && K > 0) {
            K--;
        } else {
            ans += vv.at(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
ll A[200100];
ll L ,R;
int main(){
	cin >> N;
	L = 0,R = 0;
	for(int i=0;i<N;i++){
		cin >> A[i];
		A[i]-=(i+1);
	}
	sort(A,A+N);
	for(int i=0;i<N;i++){
		if(i>0)R += A[i];
	}
	ll ans = 1000000000000000ll;
	for(int i=0;i<N;i++){
		//cout << L << ' ' << R << endl;
		ans = min(ans,R-A[i]*(ll)(N-i-1)+A[i]*i-L);
		L += A[i];
		R -= A[i+1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
// -*- compile-command: "g++ -g -Wno-return-type -Wall -Wextra -DLOCAL -std=c++11 -D_GLIBCXX_DEBUG b.cpp -ob && ./b " -*-
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
#define int LL
#define vc vector
#define pb push_back
#define pr pair
#define fi first
#define se second
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define f(i,n) for(int i=0;i<(n);i++)
#define fr(i,n) for(int i=(n);i--;)
#define fv(i,v) f(i,sz(v))

main(){
	ios::sync_with_stdio(0),cin.tie(0);
	int n;
	cin>>n;
	unordered_set<char> s;
	f(i,n){
		char c;
		cin>>c;
		s.insert(c);
	}
	if(sz(s)==3) cout<<"Three\n";
	else cout<<"Four\n";
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Range
{
    class Program
    {

        static void Main(string[] args)
        {
            int[] i = Console.ReadLine().Split(' ')
                    .Select(e => int.Parse(e)).ToArray();
            
            int a = i[0];
            int b = i[1];
            int c = i[2];

            Console.WriteLine(a < b && b < c ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 9312
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(long i=0;i<n;i++)
#define rn(i,n) for(long i=1;i<=n;i++)

int main(void){
  	int N;
  	cin >> N;

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

  	sort(v.rbegin(), v.rend());
  	//reverse(v.begin(), v.end());

  	double mul = 1;
  	double val = 0;
  	for (int i = 0; i < N; i++) {
  		if (i != N - 1)	mul *= 2;
  		val += (v[i] / mul);
      
  	}

  	cout << val;

  return 0;
}


Measured memory_bytes: 256
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    AB = [ii() for _ in range(2)]
    ret = {1, 2, 3}
    print(*ret-set(AB))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 x, y;
  cin >> x >> y;
  if (x % y == 0) x = -1;
  cout << x << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    int count=0;
    bool endOverlap = false;
    string s,t,ans;
    cin >> n;
    cin >> s;
    cin >> t;
    
    if(s == t && n <= s.size()){
        cout << s.size() << endl;
        return 0;
    }
    
    for(int i=t.size()-1;i>=0;i--){
        for(int j=s.size()-1-count;j>=0;j--){
            if(t[i] == s[j]){
                count++;
            }
            break;
        }
    }
    
    if((s.size() + t.size() - count) > n){
        cout << s.size() + t.size() - count << endl;
    }else{
        cout << n << endl;
    }
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define eps 1e-6
#define pi 3.141592653589793
using namespace std;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

int main(int argc, char* argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	VII bts;
	while(n>0)
    {
	    bts.pb(n%k);
	    n/=k;
    }
	cout<<bts.size();
	return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  ll ac = 0, wa = 0, tle = 0, re = 0;
  rep(i, n) {
    string s;
    cin >> s;
    if (s == "AC")
      ac++;
    else if (s == "WA")
      wa++;
    else if (s == "TLE")
      tle++;
    else if (s == "RE")
      re++;
    else
      assert(false);
  }
  cout << "AC " << "x " << ac << endl;
  cout << "WA " << "x " << wa << endl;
  cout << "TLE " << "x " << tle << endl;
  cout << "RE " << "x " << re << endl;

  return 0;
}


Measured memory_bytes: 3624
a, b, k = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


a_div = make_divisors(a)
b_div = make_divisors(b)
div_list = a_div + b_div

ans = sorted([x for x in set(div_list) if div_list.count(x) > 1])

print(ans[-k])

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    long double a, b;
    cin >> a;
    cin >> b;
    
    cout<< int(a)/int(b) << " " << int(a)%int(b) << " ";
    cout << setprecision(5) << fixed << a/b << endl;

    return 0;
}


Measured memory_bytes: 3304
Key_str = 7

S = str(input())
count =0

if len(S)<Key_str:
    print("No")

else:
    del_str = len(S)-Key_str
    
    for i in range(len(S)-del_str):
        try_str = S[:i] + S[i+del_str:]
        if try_str == 'keyence':
            print("YES")
            count+=1
            break
    if count==0:
        print("NO")
        

            
            
            
    

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

vector<int> G[100000];
int n,m;
ll dis[100000][3];


int main()
{
	cin >> n >> m;
	for(int i = 0;i<m;i++)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		G[a].push_back(b);
	}
	int s,t;
	cin >> s >> t;
	s--;t--;
	for(int i = 0;i<100000;i++)
	{
		for(int j = 0;j<3;j++)dis[i][j] = -1;
	}
	using P = pair<ll,ll>;
	queue<P> Q;
	Q.emplace(s,0);
	dis[s][0] = 0;
	while(Q.size())
	{
		auto now = Q.front();
		int nken = (now.second+1)%3;
		Q.pop();
		for(auto &i:G[now.first])
		{
			if(dis[i][nken]==-1)
			{
				if(now.second==0)dis[i][nken] = dis[now.first][now.second] +1;
				else dis[i][nken] = dis[now.first][now.second];
				Q.emplace(i,nken);
			}
		}
	}
	cout << dis[t][0] << endl;

}


Measured memory_bytes: 11448
#include<iostream>
#include<numeric>
#include<vector>
#include<cmath>
#include<climits>
#include<cfloat>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<limits>

using namespace std;
typedef pair<int,bool> Pair;

int main(){

    long long H;
    long long cnt=0;
    long long kai;
    
    cin >> H;

    while(H > 0){

        H = H >> 1;
        cnt++;
    }

    cout << 2LL*(long long)pow(2,cnt - 1LL)-1LL << endl;

    return 0;

}


Measured memory_bytes: 256
N = int(input())
s = [input() for i in range(N)]
flg = 1
cnt = 0
ca = 0
cb = 0
for i in range(N):
  if s[i][0] == 'B' and s[i][-1] == 'A':
    ca += 1
    cb += 1
  elif s[i][0] == 'B':
    cb += 1
    flg = 0
  elif s[i][-1] == 'A':
    ca += 1
    flg = 0
  cnt += s[i].count('AB')

if  min(ca, cb) > 0:
  cnt += min(ca, cb) - flg

print (cnt)



Measured memory_bytes: 3700
#!/usr/bin python3
# -*- coding: utf-8 -*-

####################################################
# LCS(longest common sequence)
# 部分列で最長の共通のもの
####################################################

# dp[i+1][j+1]:= s の i 文字目までと t の j 文字目まででの LCS の長さ

import numpy as np

def main():
    S = np.array(list(input()), dtype='unicode')
    T = np.array(list(input()), dtype='unicode')
    ls = len(S)
    lt = len(T)

    equal = S[:, None] == T[None,:]
#    print(eq)

    dp = np.zeros((ls + 1, lt + 1), dtype=int)

    for i in range(ls):
        dp[i + 1][1:] = np.maximum(dp[i][1:], dp[i][:-1] + equal[i])
        dp[i + 1] = np.maximum.accumulate(dp[i + 1])

#    for i in range(ls):
#        for j in range(lt):
#            dp[i+1][j+1] = max(dp[i][j+1], dp[i][j]+ eq[i][j])
#            dp[i+1][j+1] = max(dp[i+1][j+1] , dp[i+1][j])

#    print(dp)

    # 復元
    res = ''
    i, j = ls, lt
    while (i > 0 and j > 0):
        # (i-1, j) -> (i, j) と更新されていた場合
        if dp[i][j] == dp[i-1][j]:
            i-=1   # DP の遷移を遡る
        # (i, j-1) -> (i, j) と更新されていた場合
        elif dp[i][j] == dp[i][j-1]:
            j-=1   # DP の遷移を遡る
        # (i-1, j-1) -> (i, j) と更新されていた場合
        else:
            res += S[i-1]
            # このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            i-=1
            j-=1   # DP の遷移を遡る
    print(res[::-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 91592
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        int[] H = new int[N];
        for(int i=0; i<N; i++){
            H[i] = nextInt();
        }

        int before = H[0];
        int count = 0;
        int max = 0;
        for(int i=1; i<N; i++){
            if(before >= H[i]){
                count++;
            }else{
                count = 0;
            }
            max = Math.max(max, count);
            before = H[i];
        }
        println(max);
    }

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

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

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 48796
#include <stdio.h>

int main(void){
	
	int a,b,c=0;
	for(a=1;a<=9;a++){
		for(b=1;b<=9;b++){
			c=a*b;
			printf("%dx%d=%d\n",a,b,c);
		}
	}
	return 0;
}


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

int main() {
    int A, B, K, ans = 100, count = 0;
    cin >> A >> B >> K;
    while (true) {
        if  (A % ans == 0 && B % ans == 0){
            count++;
            if (count == K) {
                cout << ans << endl;
                return 0;
            }
        }
        ans--;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
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;
}

int main(){
    int n;
    cin >> n;
    n++;
    vector<ll> a(n);
    vector<ll> s(n);
    rep(i,n) cin >> a[i];
    for(int i=n-1;i>=0;i--){
        s[i] = a[i];
        if(i!=n-1)s[i] += s[i+1];
    }
    if(n==1){
        if(a[0]==1){
            cout << 1 << endl;

        }else{
            cout << -1 << endl;
        }
        return 0;
    }
    if(a[0]>=1){
        cout << -1 << endl;
        return 0;
    }
    ll sm = 0;
    ll K = 1;
    for(int i=0;i<n;i++){
        sm += K;
        K -= a[i];
        K *= 2;
        if(i!=n-1&&K>s[i+1])K = s[i+1];
        if(K<0){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 4468