akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

int n;
double p, dp[1600];

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

    cin >> n;
    dp[0] = 1.0;
    rep(i, n) {
        cin >> p;
        for(int j = min((int)i, n / 2); j >= 0; j--) {
            dp[j + 1] += dp[j] * p;
            dp[j] *= 1.0 - p;
        }
    }

    printf("%.10f\n", dp[n / 2 + 1]);

    return 0;
}

Measured memory_bytes: 384
#if 0



#endif // 0

#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 1e5 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;
int N,W;
int dp[MAXN];

void work(){
    while(~scanf("%d%d",&N,&W)){
        memset(dp,0,sizeof(dp));
        for(int i=1;i<=N;i++){
            int v,w; scanf("%d%d",&v,&w);
            for(int j=W;j>=w;j--){
                dp[j]=max(dp[j],dp[j-w]+v);
            }
        }
        printf("%d\n",dp[W]);
    }
}

int main(){
    work();
    return 0;
}



Measured memory_bytes: 3624
N,M=map(int, input().split())
A=list(sorted(map(int, input().split())))
CB=[]
for i in range(M):
  b,c=map(int, input().split())
  CB.append((c, b))
CB.sort(key=lambda cb: cb[0], reverse=True)

l=0
D=[]
for c,b in CB:
  if l > N: break      
  for i in range(b):
    if l > N: break
    l += 1
    D.append(c)
S=0
ND=len(D)
for i in range(N):
  S += A[i] if i >= ND or D[i] < A[i] else D[i]
print(S)


Measured memory_bytes: 22492
#include <stdio.h>
int main(void){
    int H,W,i,j;
    while(1){
            scanf("%d %d",&H,&W);
        if(H == 0 && W == 0){
            break;
        }
        for(i=1;i<=H;i++){
            for(j=1;j<=W;j++){
                if((i+j)%2==0){
                    printf("#");
                }
                    if((i+j)%2==1){
                        printf(".");
                    }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}
       

Measured memory_bytes: 572
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();
    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    let xs = line.trim().split_whitespace();
    let mut result = Vec::new();

    for x in xs {
        let ans = x.parse::<T>().map_err(|_| format!("{}", "parse error"))?;
        result.push(ans);
    }
    Ok(result)
}

fn main() {
    let (a, b) = read_parameters::<usize>().map(|xs| (xs[0], xs[1])).unwrap();

    let area = a * b;
    let peri = 2 * (a + b);
    println!("{} {}", area, peri)
}



Measured memory_bytes: 5032
#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;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  string num;
  int f = 0;
  cin >> num;
  for(int i = 0; i < num.size(); i++) f += (int)(num[i] - '0');
  int n = toInt(num);
  if(n % f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int mod = 1000000007;
        int n = sc.nextInt();
        int m = sc.nextInt();
        long dp[] = new long[100100];
        Arrays.fill(dp, 0);
        dp[0] = 0;
        dp[1] = 0;
        dp[2] = 1;
        dp[3] = 1;
        dp[4] = 2;
        dp[5] = 3;
        for (int i = 6; i < 100100; i++) {
            dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
        }
        int a[] = new int[m];
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();
        if (m == 0) {
            // System.out.println(n + 2);
            System.out.println(dp[n + 2]);
            return;
        }
        for (int i = 0; i < m - 1; i++) {
            int sa = a[i + 1] - a[i];
            if (sa == 1) {
                System.out.println(0);
                return;
            }
        }
        long ans = 1;
        ans *= dp[a[0] + 1];

        for (int i = 1; i < m; i++) {
            int sa = a[i] - a[i - 1];
            // System.out.println(sa);
            ans = ans * dp[sa] % mod;
        }
        ans = ans * dp[n + 1 - a[m - 1]] % mod;
        // System.out.println(n + 1 - a[m - 1]);
        /*
         * for (int i = 0; i < n; i++) { // System.out.println(dp[i]); }
         */

        System.out.println(ans);

    }
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, a, b;
	cin >> n >> a >> b;
	int p[n];
	rep(i, n) cin >> p[i];
	
	int cnt[3];
	rep(i, 3) cnt[i] = 0;
	rep(i, n) {
		if (p[i] <= a) cnt[0]++;
		else if (p[i] <= b) cnt[1]++;
		else cnt[2]++;
	}
	
	sort(cnt, cnt + 3);
	
	cout << cnt[0] << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    S = input()
    K = int(input())

    A = []
    for i in range(len(S)):
        for j in range(i+1, min(i+6, len(S)+1)):
            A.append(S[i:j])

    print(sorted(list(set(A)))[K-1])

main()


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

int main() {
	int h, n;
	cin >> h >> n;

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

	int dsum = 0;
	for (auto d : a)
	{
		dsum += d;
	}

	if (dsum >= h)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

}


Measured memory_bytes: 640
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys, math, bisect, random, itertools
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if (a + b) % 2:
        print("IMPOSSIBLE")
        return
    print((a + b) // 2)
    return

#B
def B():
    n = II()
    p = LI()
    for i in range(n):
        for k in range(i+1, n):
            pi = p[::1]
            pi[i], pi[k] = pi[k], pi[i]
            for j in range(n-1):
                if pi[j] > pi[j + 1]:
                    break
            else:
                print("YES")
                return
    print("NO")
    return

#C
def C():
    n = II()
    a = LI()
    b = LI()
    ans = 0
    for i in range(n):
        if a[i] >= b[i]:
            ans += b[i]
            continue
        ans += a[i]
        b[i] -= a[i]
        if a[i + 1] >= b[i]:
            ans += b[i]
            a[i + 1] -= b[i]
            continue
        ans += a[i + 1]
        a[i + 1] = 0
    print(ans)
    return

#D
def D():
    s = S()
    s = s[::-1]
    dp = [[0] * 13 for _ in range(len(s))]
    remain = 1
    if s[0] == "?":
        for i in range(10):
            dp[0][i] = 1
    else:
        dp[0][int(s[0])] = 1
    for i in range(1, len(s)):
        remain = (remain * 10) % 13
        dpi = dp[i]
        dpi1 = dp[i-1]
        if s[i] == "?":
            for k in range(10):
                for j in range(13):
                    dpi[(j + remain * k) % 13] += dpi1[j]
                    dpi[(j + remain * k) % 13] %= mod
        else:
            for j in range(13):
                dpi[(j + remain * int(s[i])) % 13] += dpi1[j]
    print(dp[-1][5])
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 66920
H, W = map(int, input().split())
A = [input() for _ in range(H)]

def check(n4, n2):

  for i in range(27):
    if n4 == 0:
      break
    while alpha[i] >= 4:
      alpha[i] -= 4
      n4 -= 1
      if n4 == 0:
        break

  for i in range(27):
    if n2 == 0:
      break
    while alpha[i] >= 2:
      alpha[i] -= 2
      n2 -= 1
      if n2 == 0:
        break
      
  if n4 == 0 and n2 == 0:
    print("Yes")
  else:
    print("No")      

alpha = [0] * 27
for i in range(H):
  for j in range(W):
    alpha[ord(A[i][j]) - ord("a")] += 1

if H % 2 and W % 2:
  n4 = (H * W - (H + W) + 1) // 4
  n2 = (H + W - 2) // 2
elif H % 2 == 0 and W % 2 == 0:
  n4 = H * W // 4
  n2 = 0
else:
  if H % 2:
    H, W = W, H
  n4 = (W - 1) * H // 4
  n2 = H // 2
check(n4, n2)

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <string.h>
#include <map>
#include <iomanip>
#include <time.h>
using namespace std;
typedef long long ll;

int main() {
    int k = 38;
    int n = k * k - k + 1;
    
    int a[n + 5][k + 5] = {};
    for (int i = 0; i < k; i++) {
        a[i][0] = 1;
        for (int j = 1; j < k; j++) {
            a[i][j] = (i + 1) * (k - 1) + 2 + j - k ;
        }
        //for (int j = 0; j < k; j++) cout << a[i][j] << " ";
        //cout << endl;
    }
    for (int i = 0; i < k - 1; i++) {
        a[k + i][0] = 2;
        for (int j = 1; j < k; j++) {
            a[k + i][j] = a[j][i + 1];
        }
        //for (int j = 0; j < k; j++) cout << a[k + i][j] << " ";
        //cout << endl;
    }
    
    for (int i = 2; i < k; i++) {
        for (int j = 0; j < k - 1; j++) {
            a[(k - 1) * i + j + 1][0] = i + 1;
            for (int p = 0; p < k - 1; p++) {
                a[(k - 1) * i + j + 1][p + 1] = a[k + (k - 1) * (i - 2) + (j + p) % (k - 1)][p + 1];
            }
        }
    }

    cout << n << " " << k << endl;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            if (j != 0) cout << " ";
            cout << a[i][j];
        }
        cout << endl;
    }

}


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

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

int N;
string s, t;
int dp[100100][40];

signed main()
{
    cin >> N >> s >> t;
    for(int i = 0; i < 26; i++){
        if(s[0] == 'a' + i){
            dp[0][i] = 1;
        }
    }
    for(int i = 1; i < N; i++){
        for(int j = 0; j < 26; j++){
            char c = 'a' + j;
            if(t[i] == c){
                dp[i][s[i] - 'a'] += dp[i - 1][j];
                dp[i][s[i] - 'a'] %= mod;
            }
            if(i < N - 1)dp[i][j] += dp[i - 1][j];
            dp[i][j] %= mod;
        }
    }
    int ans = 0;
    for(int i = 0; i < 26; i++){
        if(s[N - 1] == 'a' + i){
            ans = dp[N - 1][i];
        }
    }
    cout << ans << endl;

    return 0;
}
/*


*/



Measured memory_bytes: 34584
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int m, k; cin >> m >> k;
  int MAX = pow(2, m);
  int len = pow(2, m+1);
  if (m == 0) {
    cout << ((k == 0) ? "0 0" : "-1") << endl;
    return 0;
  }
  if (m == 1) {
    cout << ((k == 0) ? "0 0 1 1" : "-1") << endl;
    return 0;
  }

  if (k > MAX-1) {
    cout << "-1" << endl;
    return 0;
  }
  vi ans;
  rep(i, MAX) {
    if (i == k) continue;
    ans.pb(i);
  }
  ans.pb(k);
  rep(i, MAX) {
    if (i == MAX-k-1) continue;
    ans.pb(MAX-i-1);
  }
  ans.pb(k);

  rep(i, len) {
    cout << ans[i] << " \n"[i==len-1];
  }
  return 0;
}


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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int l,n;
    cin>>l>>n;
    int x[n],w[n];
    int now =0;
    for(int i=0;i<n;i++){
        cin>>x[i]>>w[i];
        now += x[i] * w[i];
    }
    if(now==0){
        cout << 0 << endl;
        return 0;
    }
    now = -now;
    int p=0;
    if(now>0) p=-1;
    else p=1;
    cout << 1 << endl;
    cout << -p << " " << abs(now) << endl;

}


Measured memory_bytes: 3200
/*
  #問題：
  


  #分析：
  #オブジェクト：
  
  #条件：
  

  #要求：
  

  #解法：
  
*/

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int (i)=(b);i<(e);++i)
#define FORQ(i,b,e) for(int (i)=(b);i<=(e);++i)
#define FORD(i,b,e) for(int (i)=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int main(void){
  int  N;  cin>>N;
  
  vector<int> h(N+2);
  FORQ(i,1,N){
    cin>>h[i];
  }
  h[0] = 0;
  h[N+1] = 0;
  // for(auto x:h) cerr<<x<<" ";
  // cerr<<endl;
  
  //
  int ope_cnt = 0;               //
  int id_nowlooking;
  int id_left = 0, id_right = 0; // 
  int minx;                     // 「今見ている「部分数列の範囲」」での「値」の最小値
  bool flag_thereIsNonZeroNumber = false;
  
  // for(auto x: h) cerr<<x<<" ";
  // cerr<<endl;
  
  while(1){
    FORQ(id_nowlooking, 0, N)
      if( h[id_nowlooking] ==  0 && h[id_nowlooking + 1] != 0)  id_left = id_nowlooking + 1;
    FORQ(id_nowlooking, 0, N){
      if ( h[id_nowlooking] != 0 && h[id_nowlooking +1] == 0){
        id_right = id_nowlooking;
        flag_thereIsNonZeroNumber = true;
      }
    }
    // cerr<<" id_left : "<<id_left<<" id_right : "<<id_right<<endl;
    if(flag_thereIsNonZeroNumber == false) break;

    minx = *min_element(h.begin() + id_left, h.begin() + id_right+1);
    FORQ(i, id_left, id_right){
      h[i] -= minx;
    }
    ope_cnt += minx;
    // cerr<<" ope_cnt : "<<ope_cnt<<endl;
    // cerr<<"minus operation conducted  :";
    // for(auto x: h) cerr<<x<<" ";
    // cerr<<endl;
    flag_thereIsNonZeroNumber = false;
  }
  cout<<ope_cnt<<endl;
  
  return 0;
}



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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n; 
	cin >> n; 
	vector<int> a(n);
	rep(i,n) cin >>a[i];
	SORT(a);
	int now = 0 ;
	int num = 0 ;//種類
	int same = 0 ; //ダブリが何枚あるか
	rep(i,n){
		if(now == a[i]){
			same ++ ;
		} else {
			now = a[i] ;
			num ++ ;
		}
	}
	cout << num - (same % 2) << endl;
}


Measured memory_bytes: 640
//23
#include<iostream>

using namespace std;

char s[501];
int x;
bool f;

void chk(){
  if(s[x]!='m')return;
  x++;
  chk();
  f|=s[x++]!='e';
  chk();
  f|=s[x++]!='w';
}

int main(){
  cin>>s;
  chk();
  cout<<((!s[x]&&!f)?"Cat":"Rabbit")<<endl;
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    string ss;
    string atgc = "ATGC";
    int m = 0;
    for (const auto& c : s) {
        auto pos = atgc.find(c);
        if (pos != string::npos) {
            ss += c;
        } else {
            ss.clear();
        }
        m = max(m, (int)ss.size());
    }
    cout << m << endl;
}


Measured memory_bytes: 3536
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, m, a, b, ok, ans = 0;
	cin >> num >> m;
	vector<int> d(num);
	vector<list<int>> r(num);
	rep(i, num)
		cin >> d[i];
	rep(i, m) {
		cin >> a >> b;
		a--; b--;
		r[a].push_back(b);
		r[b].push_back(a);
	}
	rep(i, num) {
		ok = true;
		for (auto it = r[i].begin(); it != r[i].end(); it++) {
			if (d[i] <= d[*it]) {
				ok = 0;
				break;
			}
		}
		if (ok)
			ans++;
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
  int N,A,B,s;
  cin >> N >> A >> B;
  s=N*A;
  if(s<B)
    cout << s << endl;
  else 
    cout << B << endl;
  // ここにプログラムを追記
}

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

int main() {
	
	int max = -1000005;
	int min = -max;

	int n;
	cin >> n;

	long long int sum = 0;
	int num;

	for (int i = 0; i < n; i++) {
		cin >> num;
		sum += num;
		if (num > max) {
			max = num;
		}
		if (num < min) {
			min = num;
		}
	}

	cout << min << ' ' << max << ' ' << sum << endl;

	return 0;
}


Measured memory_bytes: 3108
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()


s = ri()
cnt = 0
flag = False
ans = 0
if s[0] == 'R':
    cnt+=1
    flag = True
    ans = 1
for i in range(1, 3):
    if s[i] == 'R':
        if flag :
            cnt+=1
        else:
            flag = True
            cnt = 1
    else:
        flag = False
    ans=  max(ans, cnt)
print(ans)

Measured memory_bytes: 62868
n = int(input())
p = list(map(int,input().split()))

from collections import deque
temp = deque()
for i in range(3):
    temp.append(p[i])
counter = 0
temp1 = sorted(temp)
if temp[1] == temp1[1]:
    counter += 1
for i in range(n-3):
    temp.popleft()
    temp.append(p[i+3])
    temp1 = sorted(temp)
    if temp[1] == temp1[1]:
        counter += 1
print(counter)

Measured memory_bytes: 9464
#include<iostream>

using namespace std;

int main(){
	int n, x, i, j, ans = 0;
	
	cin>>n;
	for(i = 1; i <= n; i++){
		cin>>x;
		if(i % 2 == 1 && x % 2 == 1) ans++;
	}
	
	cout<<ans<<"\n";
	
	return 0;
}

Measured memory_bytes: 3596
import static java.lang.Math.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int meter, rotate, deg = 90;
		double x = 0, y = 0;
		String str, buf[] = new String[2];
		while((str = br.readLine()) != null){
			buf = str.split(",");

			meter = Integer.parseInt(buf[0]);
			rotate = Integer.parseInt(buf[1]);

			if(meter == 0 && rotate == 0)break;

			x += meter * cos(toRadians(deg));
			y += meter * sin(toRadians(deg));

			deg -= rotate;
		}
		System.out.println((int) x);
		System.out.println((int) y);
	}

}

Measured memory_bytes: 15072
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int p[12];
PII arr[12];
double dis(PII x,PII y){
	return sqrt((x.ff-y.ff)*1.0*(x.ff-y.ff)+(x.ss-y.ss)*1.0*(x.ss-y.ss));
}
int main(){
    //freopen("file.in", "r", stdin);
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
    	int x,y;
		scanf("%d%d",&x,&y);
		arr[i]=mp(x,y);p[i]=i;	
    }
    double res=0,cnt=0;
    do{
    	for(int i=0;i<n-1;i++)
    		res+=dis(arr[p[i]],arr[p[i+1]]);
    	cnt++;
	}while(next_permutation(p,p+n));
	printf("%.12lf\n",res/cnt);
	return 0;
}


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


void solve(long long N, long long L){
    L -= 1;
    long long sum = ((N*(N+1))/2)+(L*N);
    long long largest = (N)+L;
    long long smallest = L+1;
    if (smallest < 0 and largest < 0) {
	cout << sum-largest;
    } else if (smallest > 0 and largest > 0) {
	cout << sum-smallest;
    } else {
	cout << sum;
    }
    cout << "\n";
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    solve(N, L);
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
A = sorted(list(map(int,input().split())),reverse = 1)

if N %2 == 0:
    ans = sum(A[:N//2])*2-A[0]
elif N %2 == 1:
    ans = sum(A[:N//2])*2-A[0]+A[N//2]
print(ans)
    


Measured memory_bytes: 31380
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	ull n,k,a,b,cnt[100001] = {0},memo = 0;
	cin >> n >> k;
	
	rep(i,0,n){
		cin >> a >> b;
		cnt[a] += b;
	}
	
	
	rep(i,0,100001){
		if(cnt[i] + memo >= k){
			cout << i << endl;
			return 0;
		}
		else{
			memo += cnt[i];
		}
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int main(int argc, char *argv[])
{
  int A[10];
  int n;
  scanf("%d",&n);
  for (int i = 0; i < n; i++) {
    scanf("%d",&A[i]);
  }
  int k=1;
  for (int i = 0; i < n; i++) {
    if(A[i]%2==0) k*=2;
  }
  int l =pow(3,n);

  printf("%d\n",l-k);
  
  return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
dist = [[0]*10 for _ in range(10)]
for i in range(10):
    for j, c in enumerate(input().split()):
        dist[i][j] = int(c)
for k in range(10):
    for i in range(10):
        for j in range(10):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
count = 0
for _ in range(H):
    for a in input().split():
        if not int(a) == -1:
            count += dist[int(a)][1]
print(count)

Measured memory_bytes: 40428
n = int(input())
p = [int(i) for i in input().split()]
c = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i + 1] < p[i] < p[i - 1]:
        c += 1
print(c)

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

int main(int argc, char const *argv[])
{
	int n;cin>>n;
	bool f=1;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		if(x%2==0){
			if((x%3!=0)&&(x%5!=0))f=0;
		}
	}
	if(!f)cout<<"DENIED"<<endl;
	else	cout<<"APPROVED"<<endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        t: i64,
        x: [i64;n],
    }

    let mut d = 0;
    for i in 0..n-1 {
        d += max(0,x[i]+t-x[i+1]);
    }

    println!("{}", t*(n as i64) - d);

}


Measured memory_bytes: 5464
#include <bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register long long
#define il inline

il ll read() {
	rgl x = 0, f = 0, ch;
	while(!isdigit(ch = getchar())) f |= ch == '-';
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

ll gcd(ll x, ll y) {
	return !y ? x : gcd(y, x % y);
}

int main() {
	ll a = read(), b = read();
	ll g = gcd(a, b);
	printf("%lld", a / g * b);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<VMAX+1;i++){
    C[i]=0;
  }
  for(i=1;i<=n;i++){   //配列Aは１オリジン
    scanf("%hu",&A[i]);
    C[A[i]]++;
  }
  for(i=1;i<VMAX+1;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1;i<n+1;i++){
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 9620
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  int n,a,b,p[110],s=0,t=0,u=0;
  std::cin >> n >> a >> b;
  for(int i=0; i<n; i++) std::cin >> p[i];

  for(int i=0; i<n; i++){
  if(p[i]<=a) s++;
  else if(p[i]<=b) t++;
  else u++;
 }
std::cout << min(s,min(t,u)) << '\n';

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int array_length = sc.nextInt();
    int[] array_to_reverse;
    array_to_reverse = new int[array_length];
    int tmp=0;
    for (int i=0; i < array_length; i++) {
      array_to_reverse[i] = sc.nextInt();
    }
    for (int k=array_length-1; k >= 0; k--) {
      if (k == 0) {
        System.out.println(array_to_reverse[k]);
      } else {
        System.out.printf("%d", array_to_reverse[k]);
        System.out.printf(" ");
      }
    }
  }
}



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

int main(){
    long long int N, Q;
	map<long long int, long long int>BC;
	long long int res=0;

	cin >> N;

	rep(i, N){
		long long int tmp;
		cin >> tmp;
		BC[tmp] = BC[tmp] + 1;
	}

	auto begin = BC.begin(), end = BC.end();
   	for (auto iter = begin; iter != end; iter++) {
        res += (iter->first)*(iter->second);
    }

	cin >> Q;

	rep(i, Q){
		long long int B, C;
		cin >> B >> C;
		res -= B * BC[B];
		res += C * BC[B];
		BC[C] = BC[B] + BC[C];
		BC[B] = 0;

		cout << res << endl;
		
	}

	

 
	return 0;
}

Measured memory_bytes: 9364
#include<iostream>
#include<queue>
#include<utility>
using namespace std;
int main(){
while(true){
        int w,h;
        cin >>w >>h;
        if(w==0&&h==0)break;
        char map[w][h];
        bool is_reached[w][h];
        queue<pair<int,int> >recentpos;
        int ans =0;
        for(int j =0;j<h;++j){
                for(int i = 0;i<w;++i){
                        char temp;
                        cin >>temp;
                        map[i][j]=temp;
                        is_reached[i][j]=false;
                        if(temp=='@'){
                                recentpos.push(pair<int,int>(i,j));
                                is_reached[i][j]=true;
                                ans++;
                      }
                }
        }
        while(!recentpos.empty()){
                int old_x=recentpos.front().first;
                int old_y=recentpos.front().second;
                recentpos.pop();
                for(int dx =-1;dx<2;dx++){
                        for(int dy=-1;dy<2;dy++){
                                if(dx*dy!=0)continue;
                                int x=old_x+dx;
                                int y=old_y+dy;
                                if(x<0||x>=w||y<0||y>=h)continue;
                                if(is_reached[x][y]||map[x][y]=='#')continue;
                                recentpos.push(pair<int,int>(x,y));
                                is_reached[x][y]=true;
                                ans++;
                        }
                }
        }
        cout<<ans<<'\n';
        }
        return 0;
}



Measured memory_bytes: 3144
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	printf("%d", n - k + 1);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>

using namespace std;



int main() {
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	int x;
	int ans = 0;
	int consec = 0;
	int prev = -1;

	for (size_t i = 0; i < n; i++)
	{
		cin >> x;

		if (x <= prev) {
			consec++;
			ans = max(ans, consec);
		}
		else {
			consec = 0;
		}

		prev = x;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	 	int n =sc.nextInt();
	 	char[] w = sc.next().toCharArray();
	 	String[]sign=new String[n];
	 	boolean[] board = new boolean[n];
	 	int count=0;
	 	for(int i=0; i<n; i++){
	 		sign[i] = sc.next();
	 		}
	    for(int i=0; i<100; i++){
	    	for(int k=0; k<n; k++){
	    		if(board[k]){ continue;}
	            char[] c = sign[k].toCharArray();
	            for(int l=0; l<c.length; l++){
	                for(int j=0; j<w.length; j++){
	                int idx = i * j + j + l;
	                if(idx>=c.length) break;
	                if(c[idx]!=w[j]) break;
	                if(j==w.length-1) board[k] = true;
	                }
	                if(board[k]) break;
	            }	
	    	}
	    	}
	    for(int i=0; i<board.length; i++){
	        if(board[i]) count++;
	    }
	 
	    System.out.println(count);
	    }

	 	
}

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

int main() {
  string S;
  cin >> S;
  
  while(S.size()) {
    if (S.size() >= 7 && (S.substr(S.size() - 7) == "dreamer")) {
      S = S.erase(S.size() - 7);
      continue;
    } else if (S.size() >= 6 && (S.substr(S.size() - 6) == "eraser")) {
      S = S.erase(S.size() - 6);
      continue;
    } else if (S.size() >= 5) {
      if (S.substr(S.size()-5) == "dream") {
        S = S.erase(S.size() - 5);
        continue;
      } else if (S.substr(S.size() - 5) == "erase") {
        S = S.erase(S.size() - 5);
        continue;
      } else {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 512
let read f = stdin.ReadLine() |> f
let n = read float
let f a = a * 1.08 |> int
match n / 1.08 |> int with
| x' when f (float x') = int n -> string x'
| x' when f (float (x'-1)) = int n -> string (x'-1)
| x' when f (float (x'+1)) = int n -> string (x'+1)
| _ -> ":("
|> printfn "%s"


Measured memory_bytes: 14040
s=input()
if s[-1]=='1':
  print(-1)
  exit()
if s[-2]=='0':
  print(-1)
  exit()

t=s[:-1]
D=[]
for i in range((len(t)+1)//2):
  if t[i]!=t[-1-i]:
    print(-1)
    exit()
m=1
A=[]
for i in range(1,len(s)//2+1):
    A.append((m,i+1))
    if s[i-1]=='1':
        m=i+1
for i in range(len(s)//2+2,len(s)+1):
    A.append((m,i))
for i in A:
    print(*i)

Measured memory_bytes: 21084
#include <bits/stdc++.h>
typedef long long int ll;
typedef std::pair<ll, ll> PLL;
#define chmax(a, x) do { a = max(a, x); } while(0)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
 
using namespace std;

ll N;
vector<PLL> c;
ll dp[3000][3000];

signed main() {
  cin >> N;
  rep(i, N) {
    ll a;
    cin >> a;
    c.emplace_back(a, i);
  }
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  dp[0][0] = c[0].first * (N - 1 - c[0].second);
  dp[0][1] = c[0].first * c[0].second;
  // printf("dp[%d][%d]=%d\n", 0, 0, dp[0][0]);
  // printf("dp[%d][%d]=%d\n", 0, 1, dp[0][1]);
  rep(i, N) rep(l, N+1) {
    ll r = i - l + 1;
    // i+1 を追加
    if (i + 1 >= N) continue;
    if (dp[i][l] == 0) continue;
    // printf("dp[%d][%d]=%d\n", i, l, dp[i][l]);
    chmax(dp[i+1][l+1], c[i+1].first * (c[i+1].second - l) + dp[i][l]);
    chmax(dp[i+1][l], c[i+1].first * (N - r - 1 - c[i+1].second) + dp[i][l]);
  }
  ll ans = -1;
  rep(l, N+1) {
    chmax(ans, dp[N-1][l]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 27332
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int main() {
    #ifdef LOCAL
    assert(freopen("a.in", "r", stdin));
    #else
    #endif
    int a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0) {
        cout << "Zero\n";
    } else {
        int neg = min(-1, b) - a + 1;
        if (neg < 0)
            neg = 0;
        if (neg % 2)
            cout << "Negative\n";
        else
            cout << "Positive\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,dp[3][100005],abc[3][100005];
int main(){
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
        scanf("%d %d %d",&abc[0][i],&abc[1][i],&abc[2][i]);
    for(int i = 1;i <= n;i++){
        dp[0][i] = max(dp[1][i-1],dp[2][i-1])+abc[0][i];
        dp[1][i] = max(dp[0][i-1],dp[2][i-1])+abc[1][i];
        dp[2][i] = max(dp[0][i-1],dp[1][i-1])+abc[2][i];
        //printf("%d %d %d\n",dp[0][i],dp[1][i],dp[2][i]);
    }
    printf("%d",max({dp[0][n],dp[1][n],dp[2][n]}));
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main()
{
  int N,sum,ans;
  
  cin >> N;
  int A[2][N];
  for(int i=0; i<N; i++) cin >> A[0][i];
  for(int i=0; i<N; i++) cin >> A[1][i];
  
  for(int i=0; i<N; i++){
    sum = 0;
    for(int j=0; j<=i; j++){
      sum += A[0][j];
    }
    for(int j=i; j<N; j++){
      sum += A[1][j];
    }
    ans = max(ans,sum);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);       
} 

ll lcm(ll a,ll b){  
    return (a*b)/gcd(a, b);  
}  
 

ll ans,mx,sum,mn=1e8;
int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	ans  = a[0];
	for(ll i=1; i<n; i++){
		ans = gcd(ans,a[i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdlib>

int main()
{
  std::string input;
  std::cin >> input;
  long long cnt = 0;
  long long result = 0;
  for (auto it = input.rbegin(); it != input.rend(); it++) {
    switch (*it) {
      case 'B':
        result += cnt;
        break;
      case 'W':
        cnt++;
        break;
      default:
        std::cerr << "Invalid char found.\n";
        exit(1);
    }
  }
  std::cout << result << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;

using namespace std;
char g[1002][1002];
ll dp[1002][1002];
ll done[1002][1002];

int main(){
    ll h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> g[i][j];
        }
    }


    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            dp[i][j] = 0;
            done[i][j] = 0;
        }
    }

    dp[0][0] = 1;
    queue<pair<int, int> > q;
    q.push(make_pair(0,0));
    while(!q.empty()){
        pair<int,int> p = q.front();
        q.pop();

        if(done[p.first][p.second] != 0) continue;

        if(g[p.first][p.second+1] == '.'){
            dp[p.first][p.second+1] += dp[p.first][p.second] %MOD;
            q.push(make_pair(p.first,p.second+1));
        }
        if(g[p.first+1][p.second] == '.'){
            dp[p.first+1][p.second] += dp[p.first][p.second] %MOD;
            q.push(make_pair(p.first+1,p.second));
        }

        done[p.first][p.second] = 1;
    }

    cout << dp[h-1][w-1]%MOD << endl;

    return 0;
}

Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ll long long
#define mp make_pair
#define MAXN 1e6
const int mod=1e9+7;

void solve()
{
  int n,k,x;
  cin>>n>>k;
  ll dp[n];
  vector<int> V;
  for(int i=0;i<n;i++)
  {
    dp[i]=INT_MAX;
    cin>>x;
    V.pb(x);
  }
  dp[0]=0;
  for(int i=1;i<n;i++)
  {
    for(int j=1;j<=k;j++)
    {
      int x=i-j;
      if(x>=0)
      {
        dp[i]=min(dp[i],dp[x]+abs(V[x]-V[i]));
      }
    }
  }
  cout<<dp[n-1]<<endl;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 1528
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	
	if (n >= m) {
		cout << 0 << endl;
		return 0;
	}
	vector<int> x;
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		x.push_back(a);
	}
	sort(x.begin(), x.end());

	vector<int> dis;
	for (int i = 0; i < m - 1; i++) {
		dis.push_back(x[i + 1] - x[i]);
	}

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

	int ans = 0;
	for (int i = 0; i < m - n; i++) {
		ans = ans + dis[i];
	}
	
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 1400
#include <iostream>
#include<algorithm>
#include<cmath>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll n;
		cin >> n;
		ll arr[n];
		for (ll i = 0; i < n; i++) cin >> arr[i];
		sort(arr, arr + n);
		ll ans = 0;
		// for (auto i : arr)
		// 	cout << i << " ";
		// cout << endl;
		for (ll i = 0; i < n; i++)
		{
			ll temp = arr[i];
			ll p = 0;
			if (i != n - 1)
				if (arr[i] == arr[i + 1])
					continue;
			for (ll j = 1; j <= (sqrt(temp) + 1); j++)
			{
				if (temp % j == 0)
				{
					if (binary_search(arr, arr + i, j) == 1)
					{
						p = 1;
						break;
					}
					if (binary_search(arr, arr + i, temp / j) == 1)
					{
						p = 1;
						break;
					}
				}
			}
			if (p == 0)
			{
				// cout << temp << " ";
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 5256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    string s;
    cin >> s;
    char cur = s[0];
    int cnt = 0;
    for (int i = 1; i < s.size(); i++) {
        if(s[i] == cur) continue;
        cur = s[i];
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static int pathCount(char[][] grid){
        int[][] sum = new int[grid.length][grid[0].length];
        for (int i = 0; i < grid.length; i++) {
            for (int j = 0; j < grid[0].length; j++) {
                if (i == 0 && j == 0){
                    if (grid[i][j] == '#'){
                        sum[i][j] = 0;
                    }else{
                        sum[i][j] = 1;
                    }
                }else {
                    if (grid[i][j] == '#'){
                        sum[i][j] = 0;
                    }else {
                        int top, left;
                        if (i == 0) {
                            top = 0;
                        } else {
                            top = sum[i-1][j];
                        }
                        if (j==0){
                            left = 0;
                        }else {
                            left = sum[i][j-1];
                        }
                        sum[i][j] = top + left;
                        if (sum[i][j] > mod){
                            sum[i][j] -= mod;
                        }
                    }
                }
            }
        }
        return sum[grid.length - 1][grid[0].length - 1];
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int r,c;
        StringTokenizer st = new StringTokenizer(reader.readLine());
        r = Integer.parseInt(st.nextToken());
        c = Integer.parseInt(st.nextToken());
        char[][] grid = new char[r][c];
        for (int i = 0; i < r; i++) {
            String line = reader.readLine();
            for (int j = 0; j < c; j++) {
                grid[i][j] = line.charAt(j);
            }
        }
        System.out.println(pathCount(grid));
    }

    private static int mod = (int) (Math.pow(10, 9)+7);
}


Measured memory_bytes: 31876