akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	double v1,v2,x=0;
	int p,s[10];
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%lf,%lf",
			&s[0],&s[1],&s[2],&s[3],&s[4],&s[5],&s[6],&s[7],&s[8],&s[9],&v1,&v2)+1){
		double x=0,temp=0;
		for(int i=0;i<10;i++) x+=s[i];
		v1/=(v1+v2); x*=v1;
		for(p=0;x>temp;p++) temp+=s[p];
		cout<<p<<endl;
	} return 0;
}

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

int main()
{
 int x,num,flag=1,temp=-1,t=1,n=4;

 cin>>x;
  while(n--)
        {
          num=x%10;x=x/10;
    if(temp==num)flag=0;
    temp=num;
  		}

    if(flag)cout<<"Good";
    else cout<<"Bad";
}


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

int n,a[105],tmp;
long long sum,ans=0x7fffffff;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=a[n];i++){
		sum=0;
		for(int j=1;j<=n;j++){
			tmp=abs(a[j]-i); 
			sum+=pow(tmp,2);
			if(sum>ans) break;
		}
		ans=min(ans,sum);
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		
		// 計算
		long takahashi = max(0, a - k);
		long aoki = max(0, b - max(0, k - a));
		
		
		// 出力
		System.out.println(takahashi + " " + aoki);
	}
}


Measured memory_bytes: 21844
/*input
30
*/

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int x;
  cin >> x;
  if (x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,h[101010],dp[101010];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	}
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 1 ; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int[] b = new int[n];
        for (int i = 1 ; i < n ; i++) {
            b[a[i] - 1]++;
        }
        for (int i = 0 ; i < n ; i++) {
            System.out.println(b[i]);
        }
    }

}

Measured memory_bytes: 62456
#include<stdio.h>

int main(){

	char line[10];
  	int m1,m2;
  	int d1,d2;
  
  	fgets(line,sizeof(line),stdin);
  	sscanf(line,"%d %d",&m1,&d1);
    fgets(line,sizeof(line),stdin);
  	sscanf(line,"%d %d",&m2,&d2);
  
  	if(m1!=m2)printf("1");
  	else printf("0");
}

Measured memory_bytes: 128
#include <stdio.h>

#define N 10

int main() {
	static int aa[N];
	int n, i, max, sum;

	scanf("%d", &n);
	max = sum = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		if (max < aa[i])
			max = aa[i];
		sum += aa[i];
	}
	printf("%d\n", sum -= max / 2);
	return 0;
}


Measured memory_bytes: 128
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0].split(" ")[0]);
  const K = parseInt(input[0].split(" ")[1]);
  let prices = [];
  
  for (let i = 0; i < N; i++){
    prices.push(parseInt(input[1].split(" ")[i]))
  }


  prices.sort((a, b) => {
    return a - b;
  });

  let answer = 0;

  for (let i = 0; i < K; i++){
    answer += prices[i];
  }

  console.log(answer);

}
// デバッグ用
function debug() {
  var input = document.getElementById("input").value;
  Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32556
from math import gcd
n,x = map(int, input().split())
l = sorted([x]+list(map(int, input().split())))

nums = [0]*n
for i in range(n): nums[i] = l[i+1] - l[i]

ans = nums[0]
for i in range(1,n):
  ans = gcd(ans,nums[i])
print(ans)

Measured memory_bytes: 20296
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;
		for(int i = 1;i <= N;i++) {
			int sum = 0;
			int k = i;
			while(k >= 1) {
				sum = sum + (k % 10);
				k = k  / 10; 
			}
			if(sum >= a && sum <= b) {
				ans += i;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


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

int main() {
 int n,l;
 cin >> n >> l;
int sum=n*(n+2*l-1)/2 ;//一つ食べる前の味の総和はこの式で表せる。
 if(l>=0){
   cout << sum-l << endl;//lが正なら味の最小値は一個目だからl引けばいい。
 }
 else{
   if(n+l>0){
     cout << sum << endl;//l<0 and n+l>0なら味が0となるリンゴがあり、それを引けばいい.
   }
   else{
     cout << sum-(l+n-1) << endl;//l<0 and n+l<=0ならl+n-1番目のリンゴが味が<0かつ最大なので、それを引けばいい.
   }
 }
}


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

const int MAXN = 24;
int n;
int x[MAXN], y[MAXN], r[MAXN], c[MAXN], top[MAXN];
bool dp[1<<MAXN];

int main() {
  while(cin >> n && n) {
    for(int i = 0; i < n; ++i) {
      cin >> x[i] >> y[i] >> r[i] >> c[i];
    }
    for(int i = 0; i < n; ++i) {
      top[i] = 0;
      for(int j = 0; j < i; ++j) {
        if((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j])
           < (r[i]+r[j])*(r[i]+r[j])) {
          top[i] |= 1 << j;
        }
      }
    }
    memset(dp, 0, sizeof(dp));
    dp[(1<<n)-1] = 1;
    for(int b = (1<<n)-1; b >= 0; --b) {
      if(!dp[b]) continue;
      for(int i = 0; i < n; ++i) {
        if(!(b>>i&1) || (b & top[i])) continue;
        for(int j = i+1; j < n; ++j) {
          if(!(b>>j&1) || (b & top[j]) || c[i] != c[j]) continue;
          dp[b - (1<<i) - (1<<j)] = 1;
        }
      }
    }
    int res = n;
    for(int b = 0; b < (1<<n); ++b) {
      if(dp[b]) res = min(res, __builtin_popcount(b));
    }
    cout << n - res << endl;
  }
  return 0;
}

Measured memory_bytes: 17556
#include<iostream>
#include<algorithm>

int main(){

	int w;
	while (std::cin >> w, w != -1){

		int cost = 1150;

		if (w > 10){
			cost += 125 * std::min(10, (w - 10));
		}

		if (w > 20){
			cost += 140 * std::min(10, (w - 20));
		}

		if (w > 30){
			cost += 160 * (w - 30);
		}

		std::cout << 4280 - cost << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
A, B, C, X, Y = list(map(int, input().split()))
C *= 2
ans = X*A+Y*B
if X <= Y:
    ans = min(ans, C*X+B*(Y-X))
else:
    ans = min(ans, C*Y+A*(X-Y))
ans = min(ans, C*max(X, Y))
print(ans)

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

/* */

int main(){
    // 入力スタンダード
    int n,m;
    cin >> n >> m;

    // 入力スタンダード（複数指定）
    vector<int> a;
    int sum = 0;
    for(int i=0; i<n; i++) {
        int ai;
        cin >> ai;
        a.push_back(ai);
        sum += ai;
    }
    // ***************************************
    sort(a.begin(), a.end(), greater<int>());

    // 解説を見た、せっかくソートしているのだから
    // M番目が超えていたら良い、そりゃそうだ
    if(a.at(m-1)*4*m >= sum){
        cout << "Yes" <<endl;
    }else{
        cout << "No" << endl;
    }

    /* 純粋に初めからチェックしていった 
    int c = 0;
    for(int i=0; i<n; i++){
        if(a.at(i)*4*m >= sum){
            c++;
            if(c>=m){
                cout << "Yes" << endl;
                return 0;
            }
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    */

    return 0;
}

Measured memory_bytes: 256
import math
A, B, H, M = map(int,input().split())

H_Angle = (H * 60 + M) * 0.5
M_Angle = M * 6
difAngle = M_Angle - H_Angle
ans_2 = A**2 + B**2 - 2 * A * B * math.cos(math.radians(difAngle))

print(math.sqrt(ans_2))

Measured memory_bytes: 9500
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long a, b, n, ans, tmp;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> a >> b >> n;
	if (b <= 1e6) {
		for (int i = 0; i <= min(b - 1, n); i++) {
			tmp = a * i / b;
			tmp -= a * (i / b);
			ans = max(ans, tmp);
		}
	}
	else {
		for (long long i = min(n, b - 1); i <= n; ) {
			tmp = a * i / b;
			tmp -= a * (i / b);
			ans = max(ans, tmp);
			if (i == n) break;
			if (i + b <= n)
				i += b;
			else i = n;
		}
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

#define bzero(m)  memset(m,0,sizeof(m))
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef unsigned long long u64;
typedef long long i64;

#define ABS(x) (x < 0 ? (-(x)) : x)

int c[100005];

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

        int n, m;
        vector<int> a, b;

        cin >> n >> m;

        REP(i, m) {
                u64 tmp;
                cin >> tmp;
                a.push_back(tmp);
                c[i] = i;
        }

        sort(a.begin(), a.end());

        REP(i,m-1) {
                b.push_back(a[i+1] - a[i]);
        }
        sort(b.begin(), b.end());

        int r = 0;
        REP(i,m-n)
                r += b[i];
        cout << r << endl;

        return 0;
}


Measured memory_bytes: 1784
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
mark = [[False, False, False] for _ in range(3)]

for i in range(3):
    for j in range(3):
        if a[i][j] in b:mark[i][j] = True
ans = 'No'
for i in range(3):
    if all(mark[i]):
        ans = 'Yes'
        break
        
for j in range(3):
    if mark[0][j] and mark[1][j] and mark[2][j]:
        ans = 'Yes'
        break
        
if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[0][2] and mark[1][1] and mark[2][0]): ans = 'Yes'
print(ans)

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

#define pb push_back

using VI = vector <int>;
using ll = long long;

const int MXT = 26;
const int MXD = 365;

int D;
int C[MXT+10], S[MXD+10][MXT+10];

VI best;
ll best_score;

namespace MyChecker {
	int last[MXT+10];
	ll calc_score(VI ans = best) {
		fill_n(last + 1, MXT, 0);
		if (ans.size() != D) {puts("Wrong Answer"); assert(0);}
		int d = 0;
		ll score = 0;
		for (auto x : ans) {
			++ d;
			score += S[d][x];
			last[x] = d;
			for (int i = 1; i <= MXT; i ++) score -= 1ll * C[i] * (d - last[i]);
		}
		return max(0ll, score + 1000000);
	}
}

void update(VI &current, ll &new_score) {
	if (best.empty() || best_score < new_score) {
		best_score = new_score;
		best = current;
	}
	return;
}

void input() {
	scanf("%d", &D);
	for (int i = 1; i <= MXT; i ++) scanf("%d", &C[i]);
	for (int i = 1; i <= D; i ++) {
		for (int j = 1; j <= MXT; j ++) scanf("%d", &S[i][j]);
	}
	return;
}
void output() {
	for (auto x : best) printf("%d\n", x);
}

namespace Greedy {
	int last[MXT+10];
	VI greedy() {
		fill_n(last, MXT+1, 0);
		ll delta[MXT + 1] = {0};
		VI greedy_ans;
		ll score = 0;
		for (int i = 1; i <= D; i ++) {
			ll sum = 0;
			for (int j = 1; j <= MXT; j ++) delta[j] += C[j];
			sum = accumulate(delta + 1, delta + MXT + 1, 0ll);
			ll mx = -2e18;
			int ansd = -1;
			for (int j = 1; j <= MXT; j ++) {
				ll val = 8 * (- sum + delta[j]) + S[i][j];
				if (mx < val) mx = val, ansd = j;
			}
			score += S[i][ansd] + delta[ansd] - sum;
			delta[ansd] = 0;
			greedy_ans.pb(ansd);
		}
		update(greedy_ans, score);
		return greedy_ans;
	}
}

int main() {
//	freopen("sample2.in", "r", stdin);
	input();
	Greedy::greedy();
//	cerr << best_score + 1000000 << endl;
//	cerr << MyChecker::calc_score() << endl;
	output();
	return 0;
}


Measured memory_bytes: 3840
import Control.Monad

solve :: String	-> [Int] -> String
solve xs (i:is)
  | null is = xs
  | otherwise	= solve (drop i xs ++ take i xs) is

main = do
  xs <- getLine
  if xs == "-" then return () else do
    n <- readLn	
    s <- replicateM n readLn
    putStrLn $ solve xs	(s ++ [1])
    main

Measured memory_bytes: 4148
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		for(int i = 0; i < 3; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		System.out.println(Math.abs(a[2] - a[1]) + Math.abs(a[1] - a[0]));
	}
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;

namespace ABC110_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            var dics = new Dictionary<char, char>();
            var dict = new Dictionary<char, char>();
            for (int i = 0; i < s.Length; i++)
            {
                if (dics.ContainsKey(s[i]) && dics[s[i]] == t[i]) continue;
                else if (dics.ContainsKey(s[i]) && dics[s[i]] != t[i])
                {
                    Console.WriteLine("No");
                    return;
                }
                if (dict.ContainsKey(t[i]) && dict[t[i]] == s[i]) continue;
                else if (dict.ContainsKey(t[i]) && dict[t[i]] != s[i])
                {
                    Console.WriteLine("No");
                    return;
                }

                dics.Add(s[i], t[i]);
                dict.Add(t[i], s[i]);
            }
            Console.WriteLine("Yes");
        }
    }
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll N;
vector<ll> p;

bool f() {
  rep(i,0,N-1)
    if (p[i]>p[i+1])
      return false;
  return true;
}

signed main() {
  cin>>N;
  p.resize(N);
  rep(i,0,N)
    cin>>p[i];
  ll ok = false;
  if (f())
    ok = true;
  rep(i,0,N)
    rep(j,i+1,N){
      swap(p[i],p[j]);
      if (f())
        ok = true;
      swap(p[i],p[j]);
    }
  cout<<(ok?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    vector<Pi> ans;
    int MAX = 0;
    int id_M = 0;
    int MIN = INF;
    int id_m = 0;
    rep(i,N){
        if(a[i] > MAX){
            MAX = a[i];
            id_M = i;
        }
        if(a[i] < MIN){
            MIN = a[i];
            id_m = i;
        }
    }
    if(MAX == MIN){
        cout << 0 << endl;
        return 0;
    }
    else if(abs(MAX) >= abs(MIN)){
        rep(i,N){
            a[i] += MAX;
            ans.emplace_back(id_M+1,i+1);
        }
        rep(i,N-1){
            ans.emplace_back(i+1,i+2);
        }
    }
    else{
        rep(i,N){
            a[i] += MIN;
            ans.emplace_back(id_m+1,i+1);
        }
        for(int i = N-1; i >= 1; i--){
            ans.emplace_back(i+1,i);
        }
    }
    int s = ans.size();
    cout << s << endl;
    rep(i,s) cout << ans[i].first << " " << ans[i].second << endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        var tempArray = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        var N = tempArray[0];
        var K = tempArray[1];
        var Q = tempArray[2];

        var memberPoints = Enumerable.Repeat(K - Q, N).ToList();

        for (var i = 0; i < Q; i++)
        {
            var A = int.Parse(Console.ReadLine());

            memberPoints[A - 1]++;
        }

        var ret = memberPoints.Select(f => f > 0 ? "Yes" : "No").ToArray();
        Console.WriteLine(string.Join("\n", ret));
    }
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  int ev = 0, od = 0;
  cin >> n;
  int a[n];
  REP(i,n) {
    scanf("%d", &a[i]);
    if(a[i]%2==0) ++ev;
    else ++od;
  }
  if(od%2 == 0) cout << "YES";
  else cout << "NO";
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 640
#include<stdio.h>
char a[]={'A','B','C','D','E','F'};
char b[2];
int main()
{
    int i=0,j=0;
    scanf("%c %c",&b[0],&b[1]);
    getchar();
    while(a[i]!='\0')
    {
        if(b[0]==a[i])
        {
            break;
        }
        i++;
    }
    i=i+1;
    while(a[j]!='\0')
    {
        if(b[1]==a[j])
        {
            break;
        }
        j++;
    }
    j=j+1;
    if(i>j)
    {
        printf(">\n");
    }
    else if(i==j)
    {
        printf("=\n");
    }
    else
    {
        printf("<\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

#define MAX 260
#define NIL -1

int Tree[MAX];

int n;

void maxHeapify(int i){
  int largest ,exchange;
  int l,r;

  l = getLeft(i);
  r = getRight(i);
  
  if( n >= l && Tree[l] > Tree[i] )
    largest = r;
  if (largest != i){
    exchange =  Tree[i];
    Tree[i] = Tree[largest];
    Tree[largest] = exchange;
  }
  maxHeapify(largest);
}


int getParent( int i ){
  return i/2;
}

int getLeft(int i){
  return (2*i);
}

int getRight(int i){
  return (2*i + 1);
}

main()
{
  int i;
  scanf("%d", &n );

  for(i = 1; i <= n; i++){

    scanf("%d", &Tree[i]);

  }

  for(i = 1; i <= n; i++){
    
    printf("node %d: key = %d, ", i, Tree[i]);
    if(getParent(i) != 0)printf("parent key = %d, ", Tree[getParent(i)]);
    if(getLeft(i) <= n) printf("left key = %d, ", Tree[getLeft(i)]);
    if(getRight(i) <= n)printf("right key = %d, ", Tree[getRight(i)]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
function checkAll(div, As) {
    var mod = 0
    var result = true;
    As.forEach(element => {
        if (element % div > 0) {
            mod++;
            if (mod > 1) {
                result = false;
            }
        }
    });
    return result;
}

function Main(input) {
    const N = parseInt(input.shift());
    var As = input.map(x => parseInt(x));

    As = As.sort((a, b) => { return a - b; }); // 昇順ソート

    var firstDiv = 0;
    var secondDiv = 0;

    for (var div = As[0]; div > 0; div--) {
        if (As[0] % div == 0) {
            // 約数なら
            if (checkAll(div, As)) {
                firstDiv = div;
                break;
            }
        }
    }

    for (var div = As[1]; div > firstDiv; div--) {
        if (As[1] % div == 0) {
            // 約数なら
            if (checkAll(div, As)) {
                secondDiv = div;
                break;
            }
        }
    }

    console.log(Math.max(firstDiv, secondDiv));
}

// 改行・空白で分割
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 27052
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
main(){
    int n,a,b,x1=999,x2=999;
    cin>>n>>a>>b;
    int p[n+2];
    p[0]=-1;
    p[n+1]=21;
    for(int i=0;i<n;i++){
        cin>>p[i+1];
    }
 
    sort(p,p+n+2);
 
    for(int i=0;i<n+2;i++){
        if(p[i]<a+1&&p[i+1]>a){
            x1=i;
        }
        if(p[i]<b+1&&p[i+1]>b){
            x2=i;
        }
    }
    //x1問:A以下 n-x2問:B以上
 
    cout<<fmin(fmin(x1,n-x2),x2-x1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

string s="";
string ans="123456789ABCDEF0";
int Limit=45,limit=0;
int d[4] = {-1,1,-4,4};
int dis[16][16]={};

string to(int a){
  if(a==10)return "A";
  if(a==11)return "B";
  if(a==12)return "C";
  if(a==13)return "D";
  if(a==14)return "E";
  if(a==15)return "F";
  stringstream ss;
  ss<<a;
  return ss.str();
}

int f(char c){
  if(c=='0')return 16;
  if('A'<=c && c<='F')return 10+(c-'A');
  return c-'0';
}

bool rec(string v,int c_index,int p_index,int step,int h){
  if(limit<step+h)return false;
  if(v==ans)return true;
  FOR(i,0,4){
    if(c_index%4==0 && d[i]==-1)continue;
    if((c_index+1)%4==0 && d[i]==1)continue;
    if(c_index<=3 && d[i]==-4)continue;
    if(12<=c_index && d[i]==4)continue;
    int n_index = c_index+d[i];
    if(n_index==p_index)continue;
    string u = v;
    int n_h=h-dis[n_index][f(v[n_index])-1]+dis[c_index][f(v[n_index])-1];
    swap(u[c_index],u[n_index]);
    if(rec(u,n_index,c_index,step+1,n_h))return true;
  }
  return false;
}

int solve(){
  int ind = 0,h = 0;
  FOR(i,0,16)FOR(j,0,16)dis[i][j]=abs(i/4-j/4)+abs(i%4-j%4);
  FOR(i,0,16){
    if(f(s[i])==16)continue;
    h+=dis[i][f(s[i])-1];
  }
  FOR(i,0,16)if(s[i]=='0')ind=i;
  FOR(i,h,Limit+1){
    limit=i;
    if(rec(s,ind,-1,0,h))return i;
  }
  return inf;
}

int main()
{
  FOR(i,0,16){
    int a;
    cin>>a;
    s+=to(a);
  }
  cout<<solve()<<endl;
  return 0;
}



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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    ll n;
    cin >> n;

    ll count_ac = 0, count_wa = 0, count_tle = 0, count_re = 0;

    REP(i, n) {
      string s_in;
      cin >> s_in;
      if (s_in == "AC") {
        count_ac++;
      }
      else if (s_in == "WA") {
        count_wa++;
      }
      else if (s_in == "TLE") {
        count_tle++;
      }
      else if (s_in == "RE") {
        count_re++;
      }                  
    }

    cout << "AC x " << count_ac << endl;
    cout << "WA x " << count_wa << endl;
    cout << "TLE x " << count_tle << endl;
    cout << "RE x " << count_re << endl;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


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

int main(){
  int a, b;
  char op;
  while(1){
  cin >> a >> op >> b;
  if(op == '+'){
    cout << a+b << "\n";
  }else if(op == '-'){
    cout << a-b << "\n";
    }else if(op == '*'){
    cout << a*b << "\n";
    }else if(op == '/'){
    cout << a/b << '\n';
  }else{
      break;
  }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  rep(i, n) {
    if (a[i] <= x) {
      x -= a[i];
      ans++;
    }
  }
  if (x && ans == n)
    ans--;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int dx[]={0,1,0,-1},
	dy[]={-1,0,1,0};
int main()
{
	int H,W,x,y,a,i,sx,sy;
	long long L,count;
	while(scanf("%d%d%lld",&H,&W,&L),L)
	{
		char*p,m[128][128]={},*A="NESW";
		for(i=1;i<=H;++i)
		{
			scanf("%s",m[i]+1);
			if(p=strpbrk(m[i]+1,A))
			{
				x=p-m[i];
				y=i;
				switch(*p)
				{
				case'N':a=0;break;
				case'E':a=1;break;
				case'S':a=2;break;
				case'W':a=3;break;
				}
				*p='.';
			}
		}
		long long f[128][128][4]={};
		for(count=0;L;++count,--L)
		{
			if(f[y][x][a])
			{
				L%=(count-f[y][x][a]);
				if(!L)break;
			}
			f[y][x][a]=count;
			for(;;)
			{
				sx=x+dx[a];
				sy=y+dy[a];
				if(m[sy][sx]=='.')break;
				a=(a+1)%4;
			}
			x=sx;y=sy;
		}
		printf("%d %d %c\n",y,x,a[A]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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 dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

struct BipartiteMatching {
    vector<vector<int>> E; int n, m; vector<int> match, dist;
    void init(int _n,int _m){n=_n,m=_m;E.resize(n+m+2);match.resize(n+m+2);dist.resize(n+m+2);}
    bool bfs() {
        queue<int> que;
        for(int i=1;i<n+1;i++) {
            if (!match[i]) dist[i] = 0, que.push(i);
            else dist[i] = INF;
        }
        dist[0] = INF;
        while (!que.empty()) {
            int u = que.front(); que.pop();
            if (u) for(auto v:E[u]) if (dist[match[v]] == INF) {
                dist[match[v]] = dist[u] + 1;
                que.push(match[v]);
            }
        }
        return (dist[0] != INF);
    }
    bool dfs(int u) {
        if (u) {
            for(auto v:E[u]) if (dist[match[v]] == dist[u] + 1) if (dfs(match[v])) {
                match[v] = u; match[u] = v;
                return true;
            }
            dist[u] = INF;
            return false;
        }
        return true;
    }
    void add(int a, int b) { b += n; E[a + 1].push_back(b + 1); E[b + 1].push_back(a + 1); }
    int whois(int x) { return match[x + 1] - 1; }
    int solve() {
        for(int i=0;i<n+m+1;i++) match[i] = 0;
        int res = 0;
        while (bfs()) for(int i=1;i<n+1;i++) if (!match[i] && dfs(i)) res++;
        return res;
    }
};

int N, A[101], B[101], C[101], D[101];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N;
    REP(i,N) cin>>A[i]>>B[i];
    REP(i,N) cin>>C[i]>>D[i];

    BipartiteMatching bm;
    bm.init(N,N);
    REP(i,N) REP(j,N){
        if(A[i]<C[j] && B[i]<D[j]) bm.add(i,j);
    }
    cout<<bm.solve()<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int t = scanner.nextInt();
		while (t-- > 0) {
			map = new char[h][w];
			for (int i = 0; i < h; i++)
				map[i] = scanner.next().toCharArray();
			int ans = 0;
			v = new boolean[h][w];
			while (true) {
				boolean flag = false;
				for (int i = 0; i < h; i++)
					Arrays.fill(v[i], false);
				for (int y = 0; y < h; y++) {
					for (int x = 0; x < w; x++) {
						if (map[y][x] == '.' || map[y][x] == 'O' || v[y][x])
							continue;
						step = 0;
						if (!slove(y, x, map[y][x]))
							continue;
						flag = true;
						dfs(y, x, map[y][x]);
					}
				}
				if (!flag) {
					System.out.println(ans);
					break;
				}
				ans++;
				for (int i = 0; i < 11; i++) {
					for (int y = 0; y < 11; y++) {
						for (int x = 0; x < w; x++) {
							if (map[y][x] != '.' && map[y + 1][x] == '.') {
								map[y + 1][x] = map[y][x];
								map[y][x] = '.';
							}
						}
					}
				}
			}
		}
	}

	private void dfs(int y, int x, char c) {
		map[y][x] = '.';
		for (int[] m : move) {
			int ny = y + m[0];
			int nx = x + m[1];
			if (!isOK(ny, nx))
				continue;
			if (map[ny][nx] == 'O') {
				map[ny][nx] = '.';
				continue;
			}
			if (map[ny][nx] != c)
				continue;
			dfs(ny, nx, c);
		}

	}

	private boolean slove(int y, int x, char c) {
		step++;
		v[y][x] = true;
		if (step == 4)
			return true;
		for (int[] m : move) {
			int ny = y + m[0];
			int nx = x + m[1];
			if (!isOK(ny, nx))
				continue;
			if (map[ny][nx] != c || v[ny][nx])
				continue;
			if (slove(ny, nx, c))
				return true;
		}
		return false;
	}

	private boolean isOK(int ny, int nx) {
		return 0 <= ny && ny < h && 0 <= nx && nx < w;
	}

	int h = 12, w = 6;
	int step;
	char[][] map;
	boolean[][] v;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
}

Measured memory_bytes: 23836
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().run();
	}
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			char[] mes = scan.next().toCharArray();
			int[][] c = new int[n][2];
			for(int j = 0;j < n;j++){
				c[j][0] = scan.nextInt() - 1;
				c[j][1] = scan.nextInt() - 1;
			}
			for(int i = n-1;i >= 0;i--){
				mes[c[i][0]] += (c[i][1] - c[i][0]);
				mes[c[i][1]] += (c[i][1] - c[i][0]);
				while((int)mes[c[i][0]] >= 123){
					mes[c[i][0]] -= 26;
				}
				while((int)mes[c[i][1]] >= 123){
					mes[c[i][1]] -= 26;
				}
				char temp = mes[c[i][0]];
				mes[c[i][0]] = mes[c[i][1]];
				mes[c[i][1]] = temp;
			}
			for(int j = 0;j < mes.length;j++){
				System.out.print(mes[j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 23316
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<sqrt(n);i++)
    {
        if(n%i==0)
        {
          c++;
        }
    }
    c=c*2;
    if(pow(sqrt(n),2)==(sqrt(n)*sqrt(n)))
        c++;
    return  c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
   int n;
   cin>>n;
   int arr[n];
   for(int i=0;i<n;i++)
   {
        cin>>arr[i];
   }
   sort(arr,arr+n);
   long long int sum=0;
   for(int i=0;i<n-1;i++)
   sum=sum+arr[i];
   sum=sum+(arr[n-1]/2);
   cout<<sum;
 return 0;
}








Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar()
#define pc(x) putchar(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
const int MM = 2e5+5;

int n, ans;
char s[MM];

int main(){
	scanf("%d %s", &n, s);
	int l = 0, r = n-1;
	while(l < r){
		if(s[l] == 'R')
			l++;
		else if(s[r] == 'W')
			r--;
		else{
			ans++;
			l++;
			r--;
		}
	}
	print(ans);
}

Measured memory_bytes: 3948
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 struct node{

  struct node *right,*left,*parent;
  int key;
};
typedef struct node * Node; 
#define NIL NULL
Node root;

void insert(int);
void inorder(Node);
void preorder(Node);
Node find( Node,int);
Node treemin(Node);
Node successor(Node);
void treedel(Node);

int main(){
  int n,x,i;
  char str[20];
  Node get;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(str[0]=='f') {
      scanf("%d",&x);
      get = find(root,x);
      if(get != NIL) printf("yes\n");
      else printf("no\n");
    }else if(strcmp(str,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }else if(strcmp(str,"print")==0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(strcmp(str,"delete")==0){
      scanf("%d",&x);
      treedel(find(root,x));
    }
  }

  return 0;
  }


void insert(int k){
  Node y,x,z;

  y= NIL; //x's parent
  x=root;
  z=malloc(sizeof(struct node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
    
  }
  z->parent = y;
  if(y==NIL){
    root=z;

  }else{
    if(z->key < y->key){
      y->left =z;
    }else{
      y->right =z;
    }

  }


}
void inorder(Node x){
  if(x == NIL) return;
  inorder(x->left);
  printf(" %d",x->key);
  inorder(x->right);
}
void preorder(Node x){
  if(x == NIL) return;
  printf(" %d",x->key);
  preorder(x->left);
  preorder(x->right);


}

Node find(Node x,int k){

  while(x != NIL&&k!=x->key){
    if(k < x->key) x = x->left;
    else x = x->right;

  }


  return x;
}

Node treemin(Node x){
  while(x->left !=NIL) x =x->left;
  
  return x;
}

Node successor(Node x){
  Node y;

  if(x->right != NIL) return treemin(x->right);
  y=x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treedel(Node k){
  Node x,y;

  if(k->left == NIL||k->right == NIL ) y = k;
  else y=successor(k);

  if(y->left != NIL) x=y->left;
  else x=y->right;

  if(x != NIL){
    x->parent = y->parent;
  }

  if(y->parent == NIL){
    root = x;
  }else{
    if(y==y->parent->left){
      y->parent->left=x;
    }else{
      y->parent->right=x;
    }
  }
  if(y != k) k->key = y->key;

  free(y);
}
 



Measured memory_bytes: 20496
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<long long> A(N);
	bool isZero = false;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		if (A[i] == 0) isZero = true;
	}

	if (isZero)
	{
		cout << "0" << endl;
		return 0;
	}

	long long ans=1;
	for (int i = 0; i < N; ++i)
	{
		if (A[i] <= 1000000000000000000 / ans) ans *= A[i];
		else
		{
			cout << "-1" << endl;
			return 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4008
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        mut a: usize,
        b: usize,
        mut c: usize,
        d: usize,
    }
    let mut ans = "Yes";

    loop {
        if c <= b {
            break;
        }
        c -= b;

        if a <= d {
            ans = "No";
            break;
        }
        a -= d;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2120
n = int(input())
w_list = [input() for nesya in range(n)]
a = len(set(w_list))
t = 1
c = 0
while t < n:
  if (w_list[t-1])[-1] != (w_list[t])[0]:
    print('No')
    c += 1
    break
  t +=1
if c == 0:
  if a == n:
    print('Yes')
  else:
    print('No')


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

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

	int N; cin >> N;
	string s[310];
	for (int i = 0; i < 2*N; i+=2) {
		cin >> s[i] >> s[i + 1];
	}
	for (int l = 0; l < 2 * N; l += 2) {
		int dp[1010][1010];
		int m = 0;
		int i = 0;
		while (i < s[l].length()&&s[l][i]!=s[l+1][0]) {
			dp[i][0] = 0;
			i++;
		}
		while (i < s[l].length()) {
			dp[i][0] = 1;
			i++;
			m = 1;
		}
		i = 0;
		while (i < s[l+1].length() && s[l+1][i] != s[l][0]) {
			dp[0][i] = 0;
			i++;
		}
		while (i < s[l+1].length()) {
			dp[0][i] = 1;
			i++;
			m = 1;
		}
		for (i = 1; i < s[l].length(); i++) {
			for (int j = 1; j < s[l + 1].length(); j++) {
				dp[i][j] = dp[i - 1][j - 1];
				if (s[l][i] == s[l + 1][j])dp[i][j]++;
				dp[i][j] = max({ dp[i][j],dp[i][j - 1],dp[i - 1][j] });
				m = max(dp[i][j], m);
			}
		}
		cout << m << endl;
	}
}


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

int main() {
	int A , B;
  	cin >> A >> B;
  	int kaibun_number = 0;
  	int a , b ;
  	// a と b は後で比べるために最初のA と B を残しておくためのコピー
	a = A;
  	b = B;
  	int A2, B2;
    // A2 と　B2 は5桁の先頭3桁を切り出した数
  	A2 = A / 100;
  	B2 = B / 100;
	// 回分は A2からB2までの個数なので B2 から A2 を引いて 1 足した数
  	kaibun_number = B2 - A2 + 1;
    // ただし、A2（先頭）とB2（末尾）の回文は、A と B に含まれていない可能性があるので
    // A2の回文がAより小さい場合とB2の回文がBより大きい場合はkaibun_numberから引く必要がある
    int AM , AS , BM , BS;
	// Aの5桁目をAM、Aの4桁目をAS、Bの5桁目をBM、Bの4桁目をBSとする
  	AM = A / 10000;
	A = A % 10000;
	AS = A / 1000;
	BM = B / 10000;
	B = B % 10000;
	BS = B / 1000;
  	//もし、もともとのAの値（つまりa）が、A2 * 100 + AS * 10 * AMより大きかったら
  	// kaibun_numberにA2を含めてはいけないので、kaibun_numberから1引く必要がある
	if(a > A2 * 100 + AS * 10 + AM){
 		kaibun_number -= 1;
	}
  	//もし、もともとのBの値（つまりb）が、B2 * 100 + BS * 10 * BMより小さかったら
  	// kaibun_numberにA2を含めてはいけないので、kaibun_numberから1引く必要がある
	if(b < B2 * 100 + BS * 10 + BM){
 		kaibun_number -= 1;
	}
  	cout << kaibun_number << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b="ABC";
int ans,n;
int main(){
	cin>>n;
    cin>>a;
    for(int i=0;i<a.size()-b.size()+1;i++){
    	if(a.substr(i,b.size())==b) ans++;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<string>
#include<cstdio>
#include<cctype>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;

int main(){
    int n,ans[105]={0},trans=0;
    string ring[105],fi;
    cin >>fi>>n;
    for(int i=0;i<n;i++){
        int ff=0;
        cin >>ring[i];
        ring[i]=ring[i]+ring[i];
        ff=ring[i].find(fi);
        if(ff>-1)trans++;
    }
    cout <<trans<<endl;
    return 0;
}

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

using namespace std;

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

const int N = 1e5 + 5;

ll a,b,c,d,ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> a >> b >> c;
  d = min(b,c);
  ans += d * 2;
  b -= d;
  c -= d;
  if (c == 0) {
    ans += b;
    cout << ans << endl;
    return 0;
  }
  d = min(a,c);
  ans += d;
  a -= d;
  c -= d;
  if (c)
    ans ++;
  cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;


fn main(){
    let n = read::<usize>();
    let mut ans = 0;
    for _ in 0..n{
        let l = read::<usize>();
        let r = read::<usize>();
        ans += r-l+1;
    }
    println!("{}",ans);
}

#[allow(dead_code)]
fn read_str() -> Vec<char>{
    let s :String = read();
    s.chars().collect::<Vec<char>>()
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().unwrap_or_else(|_| panic!("Faild to parse {}", s))
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
    int n;
    int h[128];
    int max,count;

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    count = 1;

    max = h[0];
    for (int i = 1; i < n; i++) {
        if (max <= h[i]) {
            count++;
            max = h[i];
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
$S = str_split(trim(fgets(STDIN)));
$T = trim(fgets(STDIN));
$count = count($S);
for($i=0;$i<=$count;$i++){
array_unshift($S,$S[$count-1]);
array_pop($S);

  if(implode($S)==$T){
    echo 'Yes';
    exit;

}

}
echo 'No';

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

using namespace std;

typedef long long int ll;
typedef long double ld;

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

    int n, d;
    
    cin >> n >> d;
    
    int ans = ceil((double) n / (2 * d + 1));
    
    cout << ans << endl;
    
    return 0;
}



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

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> edge(n,vector<int>(n,0));
    for(int i=0; i<m; i++){
        int a,b;
        cin>>a>>b;a--;b--;
        edge[a][b]=1;
        edge[b][a]=1;
    }
    vector<int> perm;
    int ans=0;
    for(int i=1; i<n; i++) perm.push_back(i);
    do{
        bool flag = edge[0][perm[0]];
        for(int i=1; i<n-1; i++){
            flag = flag&&(edge[perm[i-1]][perm[i]]==1);
        }
        ans+=flag;
    }while(next_permutation(perm.begin(),perm.end()));
    cout<<ans;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    bool ans = false;

    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <=9; j++) {
            if (i * j == N) ans = true;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

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

ll s[200000];
int main(){
	int n;scanf("%d",&n);
	rep(i,n){
		scanf("%lld",&s[i]);
	}
	ll Max=0;
	for(int i=1;i<=n-3;i++){
		ll s1=0;
		int p=0;
		ll s2=0;
		for(int A=n-1-i;A>0&&A>i;A-=i){
			int B=A-i;
			int need=(n-1-A)/i;
			if(A%(A-B)==0&&A/(A-B)<=need)continue;
			s2+=s[A];
			while(p<need){
				p++;
				s1+=s[p*i];
			}
			Max=max(Max,s1+s2);
		}
	}
	cout<<Max<<endl;
}

Measured memory_bytes: 1024
#encoding utf-8

s = list(input())

count = []
code_pass = False
if s[0] == "A":
    capital_count = 0
    for i in range(len(s)):
        # print(s[i])
        if "C" == s[i]:
            count.append(i)
            # print(count)

        if s[i].isupper():
            capital_count += 1
            # print(capital_count)

    if len(count) == 1 and 2 <= count[0] <= len(s)-2:
        if capital_count == 2:
            code_pass = True

if code_pass == True:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
  string s;
  cin>>s;
  cout<<s.substr(0,s.size()-8)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, T;
    cin >> n >> T;
    int c[n], t[n], ci = 1001;
    for(int i = 0; i < n; i++){
        cin >> c[i] >> t[i];
        if(c[i] < ci && t[i] <= T){
            ci = c[i];
        }
    }
    if(ci == 1001) cout << "TLE" << endl;
    else cout << ci << endl;


return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int h, w;
    cin >> h >> w;

    if (h == 1 || w == 1)
        cout << 1 << "\n";
    else
        cout << (h * w + 1) / 2 << "\n";
    return 0;
}


Measured memory_bytes: 3600