akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static int check(int[][] stone, int line) {
		int point = 0, flag, i, j;
		for (i = 0; i < 3; i++) {
			flag = 1;
			for (j = i + 1; j < 5; j++) {
				if (stone[i][line] == stone[j][line]) {
					flag++;
				} else {
					break;
				}
			}
			if (flag >= 3) {
				point = stone[i][line] * flag;
				for (j = 0; j < flag; j++) {
					stone[i + j][line] = 0;
				}
				break;
			}
		}
		return point;
	}

	public static void fall(int[][] stone, int n) {
		int i, j,k;
		for (i = 0; i < 5; i++) {
			for (j = 0; j < n; j++) {
				if (stone[i][j] == 0) {
					if (j + 1 == n) {
						stone[i][j] = 0;
					} else {
						for(k=j;k<n;k++) {
							if(stone[i][k]>0) {
								stone[i][j]=stone[i][k];
								stone[i][k]=0;
								break;
							}
						}
						
					}
				}
			}
		}
	}

	public static void show(int[][] stone, int n) {
		for (int i = n - 1; i >= 0; i--) {
			if(i==4) {
				System.out.println("----------");
			}
			System.out.printf("%d %d %d %d %d\n", stone[0][i], stone[1][i], stone[2][i], stone[3][i], stone[4][i]);
		}
		System.out.println();
	}

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

		while (true) {
			int point = 0;
			int n = scan.nextInt();
			if (n == 0) {
				break;
			}
			int[][] stone = new int[5][n];

			for (int i = n - 1; i >= 0; i--) {
				for (int j = 0; j < 5; j++) {
					stone[j][i] = scan.nextInt();
				}
			}

			while (true) {
				int add = 0;
				for (int i = 0; i < n; i++) {
					if (i < n) {
						add += check(stone, i);
					}
				}
				if (add == 0) {
					break;
				} else {
					point += add;
					fall(stone, n);
				}
			}

			System.out.println(point);
		}
		scan.close();
	}
}


Measured memory_bytes: 55160
import java.util.*;
import java.io.*;

public class Main {

    private static final int M = 1_000_000_007;

    public Main(FastScanner in, PrintWriter out, int test) {
        int N = in.nextInt();
        long[] A = new long[N];
        long[] B = new long[N];

        for (int i = 0; i < N; i++) {
            A[i] = in.nextLong();
            B[i] = in.nextLong();
        }

        Arrays.sort(A);
        Arrays.sort(B);

        long ma = N % 2 == 1 ? A[N / 2] : (A[N / 2] + A[(N - 1) / 2]);
        long mb = N % 2 == 1 ? B[N / 2] : (B[N / 2] + B[(N - 1) / 2]);
        long res = mb - ma + 1;
        out.println(res);
    }

    private int count(int x) {
        int i = 1, sum = 0, res = 0;
        while (i + sum <= x) {
            sum += i;
            i++;
            res++;
        }
        return res;
    }

    private long pow(int x, int p) {
        long res = 1, a = x;
        while (p > 1) {
            if (p % 2 == 1)
                res = res * a % M;

            a = a * a % M;
            p /= 2;
        }
        res  = res * a % M;
        return res;
    }

    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        // int T = in.nextInt();
        for (int t = 1; t <= 1; t++) {
            Main sol = new Main(in, out, t);
        }

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

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

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

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

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


Measured memory_bytes: 59444
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <numeric>
#include <iterator>
#include <math.h>
#include <list>
#include <bits/stdc++.h>

using namespace std;

int main(void){
  double N ,L;
  cin >> N >> L;

  cout << ceil((N-1) / (L-1)) << endl;
  return 0;
}

Measured memory_bytes: 3772
i = 1
while i<=100000:
    a,op,b = map(str,input().split())
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        r = a+b
    elif op == '-':
        r = a-b
    elif op == '/':
        r = a//b
    else:
        r = a*b
    print(r)


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

void solve(){
	string s; cin>>s;
	int ans=0;
	int count=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='R')
		{
			count++;
			if(count>ans)
				ans=count;
		}
		else
			count=0;
	}
	cout<<ans<<endl;
		
}

int main(){
	solve();
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
   int a, b, c;
   cin >> a >> b >> c;
   if(a == b && b == c) cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>

typedef long long ll;

ll INF = 1000000;
const ll SIZE = 200000;

void possible()
{
  std::cout << "POSSIBLE" << std::endl;
  std::exit(0);
}

int main()
{
  ll N, M;
  bool flag = false;
  std::vector<ll> linked_list[SIZE];
  std::cin >> N >> M;

  for (ll i = 0; i < M; i++) {
    ll a, b;
    std::cin >> a >> b;
    a--;
    b--;
    linked_list[a].push_back(b);
    linked_list[b].push_back(a);
  }

  for (const auto& first : linked_list[0]) {
    if (first == N - 1)
      possible();

    for (const auto& second : linked_list[first]) {
      if (second == N - 1)
        possible();
    }
  }
std::cout << "IMPOSSIBLE" << std::endl;

  return 0;
}


Measured memory_bytes: 12776
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"

#define lp(n) for (ll i = 0; i < n; i++)
#define LP(n,i) for (ll i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
typedef long long ll;
using namespace std;

ll n;

int main(){
	cin >> n;
	lp(3500) {
		LP(3500, j) {
			if (4 * (i + 1)*(j + 1) - n*(i + 1) - n*(j + 1)>0) {
				if ((n*(i + 1)*(j + 1)) % (4 * (i + 1)*(j + 1) - n*(i + 1) - n*(j + 1)) == 0) {
					cout << i + 1 << sp << j + 1 << sp << (n*(i + 1)*(j + 1)) / (4 * (i + 1)*(j + 1) - n*(i + 1) - n*(j + 1)) << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MOD2 100000000
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(v) v.begin(),v.end()
ll mod=MOD;
using namespace std;
long long int fast_exp(long long int base,long long int ex) {
    long long int res=1;
    while(ex>0) {
       if(ex%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       ex/=2;
    }
    return res%mod;
}
long long int gcd(long long int a, long long int b)
{
    if(b==0)return a;
     return gcd(b,a%b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   ll n;
   cin>>n;
   double t,a;
   cin>>t>>a;
   double c=0.006;
   double mi=1e10;
   ll ans=-1;
   for(int i=0;i<n;i++)
   {
      double k;
      cin>>k;
      double av=t-(c*k);
      if(abs(av-a)<mi){mi=abs(av-a);ans=i;}
   }
   cout<<ans+1<<"\n";
   return 0;

}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int main(){
  int n;
  cin >> n;
  vector<int> v(n, 0);
  bool flag = false;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if(v[i] % 2 == 1) flag = true;
  }

  if(flag) cout << "first" << endl;
  else cout << "second" << endl;

}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
n = int(input())
s = input()

max_length = 0

for i in range(1, n-1):
    tmp_len = 0
    for c1, c2 in zip(s[0:n-i:], s[i::]):
        if c1 == c2:
            tmp_len += 1
        else:
            tmp_len = 0

        max_length = max(max_length, tmp_len)
        if tmp_len >= i:
            break

print(max_length)


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

def identity(x):
    return x

def mapv(f,s):
    return list(map(f,s))

def readln():
    _res = mapv(int,str(input()).split(' '))
    return _res

def seq(n,f=(lambda x: 0)):
    return [f(i) for i in range(0,n)]

n = int(input())
a = sorted(readln())
s = seq(n)
v = 0
s[0] = a[0]
for i in range(1,n):
    s[i] = s[i-1] + a[i]
for i in range(1,n):
    index = n - 1 - i
    if s[index] << 1 >= a[index + 1]:
        v = i + 1
    else: break
print(v)


Measured memory_bytes: 14520
using System;

    public class Program
    {
        public static void Main(string[] args)
        {
            int Q=int.Parse(Console.ReadLine());
            double R=(Math.Sqrt(8*Q+1)-1)/2;
            int S=(int)Math.Floor(R);
            for (int i=1;i<=S;i++)
            {
                Q=Q-i;
            }

            for (int i=S;i>0;i--)
            {
                if (Q!=0)
                {
                    Console.WriteLine(i+1);
                    Q--;
                }
                else
                    Console.WriteLine(i);
            }
        }
    }

Measured memory_bytes: 2776
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();
        int tmp = 0,sum = 0;
        for(int i=0;i<=n;i++)
        {
            tmp = Digitsum(i);
            if(tmp>=a && b>=tmp)
            {
                sum+=i;
            }
        }
        System.out.println(sum);
    }
    
    static int Digitsum(int a){
        int sum=0;
        while(a>0)
        {
            sum+=a%10;
            a/=10;
        }
        return sum;
    }
}

Measured memory_bytes: 22996
#include <iostream>
    using namespace std;
    int n,m,ans=1;
    int main(void){
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>m;
            ans*=(m%2==0);
        }
        if(ans)cout<<"second"<<endl;
        else cout<<"first"<<endl;
    }

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
res=0
for  i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500*i + 100*j + 50*k == X:
                res += 1
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  int free = 0;
  rep(i,n) {
    int a;
    cin >> a;
    if (a < 400) mp[0] = 1;
    else if (a < 800) mp[1] = 1;
    else if (a < 1200) mp[2] = 1;
    else if (a < 1600) mp[3] = 1;
    else if (a < 2000) mp[4] = 1;
    else if (a < 2400) mp[5] = 1;
    else if (a < 2800) mp[6] = 1;
    else if (a < 3200) mp[7] = 1;
    else free++; 
  }
  cout << (!mp.empty() ? mp.size() : 1) << " " << mp.size() + free << endl;
  return 0;
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
ll in(){ll x; cin >> x; return x;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;

	Vec2<ll> dp(n, Vec(4));

	rep(i, n){
		if(!i){
			rep(j, 4) dp[i][j] = 1;
			continue;
		}

		rep(j, 4){
			rep(k, 4)  dp[i][j] += dp[i-1][k];
			if(i >= 2){
				if(j == 1) dp[i][j] -= dp[i-2][0]+dp[i-2][2];
				if(j == 2) dp[i][j] -= dp[i-2][0];
			}
			if(i >= 3){
				if(j == 1) dp[i][j] -= dp[i-3][0]*3;
				if(j == 2) dp[i][j] += dp[i-3][2];
			}

			dp[i][j] %= MOD;
		}
	}

	ll ans = 0;
	rep(i, 4) ans += dp[n-1][i];
	while(ans < 0) ans += MOD;
	ans %= MOD;
	co(ans);

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
	int x,y,temp;
	
	Scanner scan = new Scanner(System.in);
	x = scan.nextInt();
	y = scan.nextInt();
	
      	if(1>x || x>1000000000){System.exit(0);}
	if(1>y || y>1000000000){System.exit(0);}
	
	if(x>=y){
	    while((temp = x%y) != 0){
		x = y;
		y = temp;
	    }
	    System.out.println(y);
	}
	else {
	    while((temp = y%x)!=0){
		y = x;
		x = temp;
	    }
	    System.out.println(x);
	}
    }
}



Measured memory_bytes: 26376
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    w,h,n=map(int,input().split())
    A=[0,w,0,h] # xl,xh,yl,yh
    for _ in range(n):
        x,y,a=map(int,input().split())
        if a==1: A[0]=max(A[0],x)
        elif a==2: A[1]=min(A[1],x)
        elif a==3: A[2]=max(A[2],y)
        elif a==4: A[3]=min(A[3],y)
    print(max(0,A[1]-A[0])*max(0,A[3]-A[2]))
resolve()

Measured memory_bytes: 38384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
   int x,y,z; cin>>x>>y>>z;
   cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;

	REP(i, n){
		int j = i;
		while(s[j] == s[i+1]) i++;
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int A,B,K;
   cin >> A >> B >> K;
   int mx = min(A,K);
   A -= mx;
   K -= mx;
   mx = min(B,K);
   B -= mx;
   cout << A << ' ' << B << '\n';
   return 0;
}

Measured memory_bytes: 256
n = int(input())
sum = 0
for i in range(1, n + 1):
    y = 0
    if i % 2 == 0:
        continue
    for j in range(1, i + 1):
        if i % j == 0:
            y += 1
    if y == 8:
        sum += 1
print(sum)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int N;
    string s;
    cin >> N;
    cin >> s;
    if(N%2==1){
            cout << "No";
            return 0;
    }
    REP(i, N / 2) {
        if(s[i] != s[i + N / 2]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

VI G[100010];
int reached[100010];
int color[100010];


int main(){
    int n,d;cin>>n>>d;
    int x[n][d];
    int ans=0;
    rep(i,n) rep(j,d) cin>>x[i][j];
    rep(i,n) rep(j,i+1,n){
        double res=0;
        rep(k,d){
            res+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double compare=floor(sqrt(res));
        if(compare*compare==res)ans++;
    }
    cout<<ans<<endl;
}


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

int main() {
    int n, q; cin >> n >> q;
    vector<stack<int>> S(n);
    
    for (int i = 0; i < q; ++i) {
        int command, t, x; cin >> command >> t;
        
        switch(command) {
            case 0:
                cin >> x;
                S[t].push(x);
                break;
                
            case 1:
                if (!S[t].empty()) cout << S[t].top() << endl;
                break;
                
            case 2:
                if (!S[t].empty()) S[t].pop();
                break;
        }
    }
    return 0;
}


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

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int64_t n , k , d;
	cin >> n >> k >> d;
	n = abs(n);
	if(n/d >= k){
		n = n - d*k;
		cout << n;
		return 0;
	}
	int64_t x = n/d;
	
	n = n - x *d;
	k = k - x; // Hope's are left

	if(k % 2 == 0){
		cout << n;
		return 0;
	}
	else{
		cout << min(n + d  , abs(n-d));
	}
	return 0;
}



Measured memory_bytes: 3560
N, M, C = map(int, input().split())
B_list = list(map(int, input().split()))
A_lists = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for A_list in A_lists:
    tmp = [a * b for a, b in zip(A_list, B_list)]
    tmp = sum(tmp) + C
    if tmp > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 9168
s = input()
n = int(s)
dg = len(s)

all_list = []

for i in '753':
    for j in '753':
        for k in '753':
            all_list.append(''.join([i,j,k]))

for i in range(4,dg+1):
    add_list = []
    for c in '753':
        add_list += [''.join(c+e) for e in all_list]
    all_list += add_list

all_list = set(all_list)
res = sum([True for _ in all_list if set(list(_))=={'7','5','3'} and int(_) <= n])
print(res)



Measured memory_bytes: 13848
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(string S) {
    return iota(S.length - 2)
        .map!(i => to!long(S[i .. i + 3]))
        .map!(i => abs(i - 753))
        .reduce!min;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    string S;
    S = input.front.to!string;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(S);
    else {
        auto ans = solve(S);

        static if (isFloatingPoint!(ReturnType!solve))
            writeln(format("%.9f", ans));
        else static if (is(ReturnType!solve == bool))
            writeln(ans ? YES : NO);
        else
            writeln(ans);
    }
}


Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N=int(input())
    S=list(input())

    cnt=1
    for i in range(N-1):
        if S[i]!=S[i+1]:
            cnt+=1

    print(cnt)


resolve()

Measured memory_bytes: 4084
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N,T,c,t;
  cin >> N >> T;
  vector<pair<int,int>> cost(N);

  for(int i=0; i<N; i++){
      cin >> c >> t;
      cost[i] = make_pair(c,t);
  }
  sort(cost.begin(), cost.end());

  for(int i=0; i<N; i++){
    if(cost[i].second <= T){
        cout << cost[i].first << endl;
        return 0;
    }  
  }
  cout << "TLE" << endl;
  
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

ans=B[A[0]-1]
buf=A[0]

for a in A[1:]:
    ans+=B[a-1]
    if a-buf==1:
        ans+=C[buf-1]
    buf=a

print(ans)

Measured memory_bytes: 3064
def next_koch(n):
    turn60 = 0.5 + 3 ** 0.5 * 0.5j
    n_next = [n[0]]
    for i in range(1, len(n)):
        s = (n[i - 1] * 2 + n[i]) / 3
        t = (n[i - 1] + n[i] * 2) / 3
        u = (t - s) * turn60 + s
        n_next +=[s, u, t, n[i]]
    return n_next

p1 = 0 + 0j
p2 = 100 + 0j
koch = [p1, p2]

n = int(input())
for i in range(n):
    koch = next_koch(koch)

for z in koch:
    print("{:.8f} {:.8f}".format(z.real, z.imag))



Measured memory_bytes: 5744
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int a[N];
int32_t main()
{
	int n,m;
	cin>>n>>m;
	int cnt=0;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		
		sum+=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=((sum+4*m-1)/(4*m)))
			cnt++;
	}
	if(cnt>=m)
	{
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define re(v) {for(auto &_re : v) cin >> _re;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define prr(v) {for(auto _prr : v) cout << _prr.ff << " " << _prr.ss << endl;}
using namespace std;
const ll M = 1e9 + 7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}

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

int main(){
  	int K, N;
  	cin >> K >> N;
  	int A[N], dist[N], extra=K;
  	for(int i=0; i<N; i++){
    	cin >> A[i];
    }
  	
  
  	for(int i=0; i<N-1; i++){
    	dist[i] = A[i+1]-A[i];
      	extra-=dist[i];
    }
  
  	sort(dist, dist+N);
  	int num = max(dist[N-1], extra);
  	/*for(int i=0; i<N; i++){
    	cout << dist[i] << endl;
    }*/
  	
  	cout << K-num << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>              //including header files
long int h(int a, int b)        
{
    if(a%b==0)
        return b;       //returning b if b divides a
    else if(b%a==0)
        return a;       //returning b if a divides b
    else if(a>b)
        return h(a%b,b);        //recursive call
    else
        return h(a,b%a);        //recursive call
}
int main()          //definition of main()
{
    int t=1;
    //scanf("%d",&t);         //accepting IMPOSSIBLE. of terms
    while(t-->0)
    {
        int n,i;
        long int k;
        scanf("%d%ld",&n,&k);       //accepting values of n and k
        long int a[n],g,max=0;
        for(i=0;i<n;i++)
        {
            scanf("%ld",&(a[i]));       //accepting values
            if(max<a[i])
                max=a[i];               //calculating maximum
        }
        if(max<k)               //if required value is greater than the maximum present
            printf("IMPOSSIBLE\n");
        else
        {
            g=h(a[0],a[1]);     //invoking h(...)
            for(i=2;i<n;i++)
            {
                g=h(g,a[i]);
                if(g==1)
                    break;
            }
            if(g==1)
                printf("POSSIBLE\n");
            else if((max-k)%g==0)
                printf("POSSIBLE\n");            //displaying results based on conditions
            else
                printf("IMPOSSIBLE\n");
        }
    }
    return 0;                   //returning 0
}

Measured memory_bytes: 896
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

const int Maxn = 1e5;

int N, M;
vector<int> G[Maxn + 5];
int dep[Maxn + 5];
vector<pair<int, int> > edges;

int DFS(int u, int fa) {
	dep[u] = dep[fa] + 1;
	int deg = 0;
	for(int i = 0; i < (int)G[u].size(); i++) {
		int v = G[u][i];
		if(v == fa) continue;
		if(dep[v]) {
			if(dep[v] < dep[u])
				deg++, edges.push_back(make_pair(u, v));
			continue;
		}
		int degv = DFS(v, u);
		if(degv & 1) edges.push_back(make_pair(v, u));
		else edges.push_back(make_pair(u, v)), deg++;
	}
	return deg;
}

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d %d", &N, &M);
	for(int i = 1; i <= M; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		G[u].push_back(v), G[v].push_back(u);
	}
	dep[1] = 1;
	int res = DFS(1, 0);
	if(res & 1) {
		puts("-1");
		return 0;
	}
	for(int i = 0; i < (int)edges.size(); i++)
		printf("%d %d\n", edges[i].first, edges[i].second);
	return 0;
}

Measured memory_bytes: 17524
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll i, n, ans, maxm, temp;
    cin >> n;
    for (i = 0, ans = 0, maxm = 0; i < n; i++)
    {
        cin >> temp;
        if (maxm < temp)
            maxm = temp;
        ans += maxm - temp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
n = int(input())
a = list(map(int, input().split()))
ans = 0
num = 1
index = 0
while index < n:
    if a[index] != num:
        ans += 1
    else:
        num += 1
    index += 1
if ans == n:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 77644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pair<int,int>>
#define mi          map<int,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(i=a;i<b;i++)
#define inf         INT_MAX

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }

using namespace std;
void solve()
{
    int n;
    cin>>n;
    if(n>=30)cout<<"Yes";
    else cout<<"No";
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3616
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define rep(i,n)  for(int i=0;i<(n);i++)

int N,A,B,C;
vi l;

int rec(int i,int a,int b,int c){
    if(i==N){
      	if(!a||!b||!c)return 100000;
        return abs(A-a)+abs(B-b)+abs(C-c);
    }
    
    int res = rec(i+1,a,b,c);
    res = min(res,rec(i+1,a+l[i],b,c)+(a?10:0));
    res = min(res,rec(i+1,a,b+l[i],c)+(b?10:0));
    res = min(res,rec(i+1,a,b,c+l[i])+(c?10:0));
    return res;
}

int main(){
    cin>>N >>A >>B >>C;
    l.resize(N);
    rep(i,N)cin>>l[i];
    cout<<rec(0,0,0,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
// #define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
const int N=500001;
// vector<pair<ll, ll> > adj[N];
// bool vis[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;
vector <int> adj[N];


void solve() 
{
    ll a, b;
    cin>>a>>b;

    if(a > b) swap(a, b);

    if(a == b)
    {
        cout<<2*a - 2<<endl;
    }
    else if(a + 1 == b)
    {
        cout<<2*a - 2<<endl;
    }
    else
    {
        ll c =sqrt(a*b);
        if(c*c == a*b) c--;

        if(c*(c+1) >= a*b)
        {
            cout<<2*c - 2<<endl;
        }
        else
        {
            cout<<2*c - 1<<endl;
        }
    }

} 

int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

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

const int INF = 1001001001001001001LL;
signed main() {
    int N;
    cin >> N;
    vector<vector<int>> ABC(N);
    for (int i = 0; i < N; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        ABC[i] = {a, b, c};
    }
    vector<vector<int>> dp(N + 1, vector<int>(4, -INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 1; k < 4; k++) {
                if (dp[i][j] == -INF) continue;
                if (j != k) {
                    chmax(dp[i + 1][k], dp[i][j] + ABC[i][k - 1]);
                }
            }
        }
    }
    int ans = max({dp[N][1], dp[N][2], dp[N][3]});
    cout << ans << endl;
}


Measured memory_bytes: 12800
/*#include<bits/stdc++.h>
using namespace std;
int main()
{
	int d;
	cin>>d;
	if(d==24) cout<<"Christmas Eve";
	else if(d==23) cout<<"Christmas Eve Eve";
	else if(d==22) cout<<"Christmas Eve Eve Eve";
	else cout<<"Christmas";
}A*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	double sum=0;
	cin>>n;
	int f[n];
	for(int i=0;i<n;i++)
	{
		cin>>f[i];
		sum+=f[i];
	}
	sort(f,f+n);
	sum-=f[n-1]/2;
	cout<<sum;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.math.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		
		int N=sc.nextInt();
		int[] a=new int[N];
		for(int i=0;i<N;i++){
			a[i]=sc.nextInt();
		}
		//int counter=0;
		int sum=0;
		
		for(int i=1;i<N-1;i++){
			if(a[i-1]==a[i]){
				if(a[i]!=1 && a[i+1]!=1){
					a[i]=1;
					sum++;
				}else if(a[i]!=2 && a[i+1]!=2){
					a[i]=2;
					sum++;
				}else{
					a[i]=3;
					sum++;
				}
			}
		}
		if(a[N-2]==a[N-1]){
			sum++;
		}
		//for(int i=0;i<N;i++){
			//System.out.println("a["+i+"]:"+a[i]+",");
		//}
		System.out.println(sum);
		
	}
}

Measured memory_bytes: 21844
s = str(input())
n = len(s)
s_num = [1 for _ in range(n)]

# 右から
for i in range(n - 2):
    if s[i] == "R":
        if s[i+1] == "R":
            s_num[i+2] += s_num[i]
            s_num[i] = 0

# 左から
for i in range(n-2):
    i = n - i - 1
    if s[i] == "L":
        if s[i-1] == "L":
            s_num[i-2] += s_num[i]
            s_num[i] = 0
ans = list(map(str, s_num))
print(" ".join(ans))


Measured memory_bytes: 49076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner kbScanner = new Scanner(System.in);
		String input = kbScanner.next();
		if(input.charAt(2) == input.charAt(3) && input.charAt(4) == input.charAt(5)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		kbScanner.close();
	}

}


Measured memory_bytes: 23124
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
int n;
long long int a,b;
int main()
{
	cin>>n>>a>>b;
	vector<long long>h;
	h.resize(n);
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	}
	long long int lb=-1,ub=1000000000,mid;
	while(ub-lb>1)
	{
		mid=(lb+ub)/2;
		long long int t=0;
		for(int i=0;i<n;i++)
		{
			long long int x=h[i];
			x-=b*mid;
			if(x>0)
			{
				t+=ceil((double)x/(a-b));
			}
		}
		if(t<=mid)
		{
			ub=mid;
		}
		else
		{
			lb=mid;
		}
	}
	cout<<ub;
	return 0;
}

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

int main() {

  int N;
  int K,x,sum;
  int A,B; 
    cin>>N;
    cin>>K;
    
 for(int i=0;i<N;i++)
 {
   cin>>x;
     A=x;
     B=K-x;
     if(A>B)
     {
      sum+=B*2;         
     }
     else
     {
         sum+=A*2;
     }
     
 }
  cout<<sum<<endl;
     
     
 }
    
   


Measured memory_bytes: 256
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
R, G, B, N = map(int, input().split())

# rR+gG+bB=Nになるようなrgbの組み合わせの個数
# N<3000なのでO(n**2)で全探索して良さそう
# r,gがgivenのとき、rR+gG-N=-bB が成り立つ整数bが存在すれば、良い
ans = 0
for r in range(0, N + 1):
    for g in range(0, N + 1):
        left = (N - (r * R + g * G))
        if left >= 0 and left % B == 0:
            ans += 1
print(ans)


Measured memory_bytes: 67344
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 500005;
int n, q, d[MX], a[MX];
int main(){
	scanf("%d%d", &n, a);
	rep(i,n){
		scanf("%d", d+i);
		a[i+1] = min(abs(a[i]-d[i]), a[i]);
	}
	for(int i = n-1; i > 0; i--) d[i] = d[i+1] + ((d[i+1] + 1) * 2 > d[i] ? d[i] : 0);
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &q);
		puts(a[q-1] > d[q] ? "YES" : "NO");
	}
}

Measured memory_bytes: 5888
import math
member = []
score = []
while True:
    num = int(raw_input())
    if num == 0: break
    member.append(num)
    score.append(map(int, raw_input().split()))

alpha = []
for m, s in zip(member, score):
    average = sum(s)/float(m)
    sigma = 0
    for t in s:
        sigma += (t - average)**2
    else:
        alpha += [sigma/m]

for a in alpha:
    print math.sqrt(a)

Measured memory_bytes: 6556
import sys
N = int(input())
A = list(map(int, input().split()))

x = 0
for i in A:
    x ^= i

# 0以上A1未満
# a1 ^ a2 -> (a1-n) ^ (a2+n)
# x -> 0

# a + b = 0 -> b=-aは逆元
# a * b = 1 -> b=1/aは逆元
# a ^ a = 0 -> aが逆元
# -> 自由に式変形しやすい

# a1^a2^あまり=x
# b1^b2^あまり=0
# a1^a2^x=b1^b2

# 上のビットからやる
old = A[0] ^ A[1] ^ x

# b0 ^ b1 = old

# b0 + b1 - 2 * (b0 & b1) = old

b0pb1 = A[0] + A[1]
# print(A[0], A[1], b0pb1, old, file=sys.stderr)

if b0pb1 < old or (b0pb1 - old) % 2 == 1:
    print(-1)
    exit(0)

b0andb1 = (b0pb1 - old) // 2
print(A[0], A[1], b0pb1, old, b0andb1, file=sys.stderr)

if (b0andb1 & old) != 0:
    print(-1)
    exit(0)


# A[0]を減らして
# A[0] & ~old = b0andb1
# にするのが最終目標

if A[0] < b0andb1:
    print(-1)
    exit(0)

ans = b0andb1
for i in reversed(range(0,40)):
    if((old >> i) & 1) == 0:
        continue
    if ans + (1 << i) <= A[0]:
        ans += 1 << i

if ans == 0:
    print(-1)
    exit(0)

print(A[0] - ans)


Measured memory_bytes: 62076
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			int[] a=new int[n];
			for(int i=0;i<n;i++){
				a[i]=sc.nextInt();
			}
			Arrays.sort(a);
			BigInteger sum=BigInteger.ZERO;
			BigInteger add=BigInteger.ZERO;
			for(int i=1;i<n;i++){
				add=add.add(BigInteger.valueOf(a[i-1]));
				sum=sum.add(add);
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 50064
"""
問題文

N個の整数 A1,A2,...,ANが黒板に書かれています。
あなたはこの中から整数を 1つ選んで、1 以上 109以下の好きな整数に書き換えます。
元の整数と同じ整数に書き換えても構いません。書き換えた後のN個の整数の最大公約数の最大値を求めてください。

制約
入力は全て整数である。
2≤N≤105
1≤Ai≤109
"""

"""
3 5 7
最大公約数: 1
最大の最大公約数: 1

8 4 6
最大公約数: 2
最大の最大公約数: 4
『aとbとcの最大公約数』　＝　『aとbの最大公約数』と『c』　の最大公約数

A1 , A2 , A3 ... An

gcd(A1 , A2 , A3 ... An-1) * N
= gcd * N * N
= gcd * N^2

gcd(A1 , A2 , A3 ... An-1)
gcd(A1 , A2 , A3 ... An-2 , An) = gcd(A1 , A2 , A3 ... An-2) , An
"""
def gcd(a, b):  # a>b
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

from functools import reduce
def GCD(numbers):
    if len(numbers) == 0 : return 0
    if len(numbers) == 1 : return numbers[0]
    if len(numbers) == 2 : 
        return gcd(numbers[0] , numbers[1])
    else : 
        value = GCD(numbers[:len(numbers)-1])
        result = gcd(value , numbers[len(numbers) - 1])
        return result

def main() : 
    N = int(input())
    a_list = input().split(" ")
    a_list = [int(i) for i in a_list]
    R = [0 for i in range(N - 1)]
    L = [0 for i in range(N - 1)]
    R[0] = a_list[0]
    L[0] = a_list[-1]

    for i in range(1 , N-1) : 
        R[i] = gcd(R[i - 1] , a_list[i])
    
    for j in range(1 , N-1) : 
        L[j] = gcd(L[j - 1] , a_list[- j - 1])
    
    maxValue = 0
    for i in range(N - 2) : 
        value = gcd(R[i] , L[N - i - 3])
        if value > maxValue : maxValue = value
    print(max(maxValue , R[-1] , L[-1]))
main()


Measured memory_bytes: 14652
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		int n1, n2;
		for(n1 = 0; n1 < totalVertex; n1 ++)
			for(n2 = 0; n2 < totalVertex; n2 ++) 
				adjMatrix[n1][n2] = 0;

		Iterator<LinkedList<Integer>> it1 = adjList.iterator();
		n1 = 0;
		while(it1.hasNext()) {
			LinkedList<Integer> one = it1.next();
			Iterator<Integer> it2 = one.iterator();
			while(it2.hasNext()) { 
				n2 = it2.next();
				adjMatrix[n1][n2] = 1;
			}
			n1 ++;
		}
		for(n1 = 0; n1 < totalVertex; n1 ++) {
			for(n2 = 0; n2 < totalVertex; n2 ++) {
				if(n2 == totalVertex - 1)
					System.out.println(adjMatrix[n1][n2]);
				else
					System.out.print(adjMatrix[n1][n2] + " ");
			}
		}
	}
}

public class Main {
	public static void main(String args[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}

}


Measured memory_bytes: 32464
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
int n;

int main(){
  cin >> n;
  int ans = 0;
  int m = n;
  for(int i=1;i<=m;i++){
    //cout << i << endl;
    n -= i;
    ans ++;
    //cout << ans << endl;
    if(n<=0){
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N=0, Y=0;
  int a=-1,b=-1,c=-1;
  int i,j,k;
  cin >> N >> Y;
  for(i=0;i<=N;i++){
    for(j=0;j<=(N-i);j++){
      for(k=0;k<=(N-(i+j));k++){
        if(i*10000+j*5000+k*1000 == Y && i+j+k == N){
          a=i;
          b=j;
          c=k;
          break;
        }
      }
    }
  }
    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 3624
n,k = map(int,input().split())
a = list(map(int,input().split()))
prod = [a[0]]*(n+1)
for i in range(n):
	prod[i+1] = prod[i] + a[i]

for i in range(k+1,n+1):
	if prod[i] - prod[i-k] > prod[i-1] - prod[i-1-k]:
		print('Yes')
	else:
		print('No')

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

int main(){
    int n; cin >> n;
    int ans = 100000000;
    for(int i = 0; i < n; i++){
        int count = 0;
        int mid;
        cin >> mid;
        while(mid % 2 == 0){
            mid = mid / 2;
            count++;
        }
        ans = min(count, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

static int N, M;
static int D[100004];
static int X[100004], Y[100004];

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

    cin >> N >> M;
    for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        ++D[x];
        if (D[x] % 2 == 0) ++X[x % M];
        ++Y[x % M];
    }

    int ans = 0;

    // M == 0
    ans += Y[0] / 2;

    for (int i = 1, j = M - 1; i < j; ++i, --j) {
        if (Y[i] < Y[j]) {
            if (Y[i] <= Y[j] - X[j] * 2) {
                ans += Y[i] + X[j];
            } else {
                ans += Y[i] + (Y[j] - Y[i]) / 2;
            }
        } else {
            if (Y[i] - X[i] * 2 >= Y[j]) {
                ans += Y[j] + X[i];
            } else {
                ans += Y[j] + (Y[i] - Y[j]) / 2;
            }
        }
    }

    if (M % 2 == 0) ans += Y[M / 2] / 2;
    cout << ans << "\n";
}


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

int main(void){
    int n, h[100010], ans[100010];
    cin >> n;
    for(int i=0;i<n;++i) cin >> h[i];
    for(int i=0;i<n;++i) ans[i] = 100000000;
    ans[0] = 0;
    ans[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;++i){
        ans[i] = min(ans[i-1] + abs(h[i]-h[i-1]), ans[i-2] + abs(h[i]-h[i-2]));
    }
    cout << ans[n-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define int long long
 
#define pii pair<int, int>
 
#define x1 x1228
#define y1 y1228
 
#define left left228
#define right right228
 
#define pb push_back
#define eb emplace_back
 
#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   
 
#define matr vector<vector<int> > 
 
#define all(x) x.begin(), x.end()
 
 
using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 1e9 + 9, inf = 1e9, MAXN = 1e6 + 7;
const double eps = 1e-9;
mt19937 rnd(time(0));
int a, b;  
void solve() { 
    cin >> a >> b; 
    int cur = (b - 1 + a - 2) / (a - 1);   
    cout << cur; 
}                                
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}  

Measured memory_bytes: 256