akhauriyash/Code-Regression huggingface dataset:
// @hritikkumar

#include<bits/stdc++.h> // all header files

using namespace std; 


int main(void)
{
	int k, a, b;
	cin>>k>>a>>b;
	
	int finder = b/ k;
	finder *= k;
	if( finder >=a && finder <= b)
		cout<<"OK"<<endl;
	else
		cout<<"NG"<<endl;
	return 0 ; 
}


Measured memory_bytes: 3628
x, y = gets.chomp.split.map(&:to_i)
arr = [x]
n = y - x
(0..(n - 2)).each do |i|
  break if y <= arr[i]
  arr[i + 1] = arr[i] * 2
end

if arr.last == y
  puts arr.count
else
  puts (arr.count - 1)
end

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

int main() {
  int N, W;
  cin >> N >> W;
  auto w = vector<int>(N);
  auto v = vector<int>(N);
  for(auto i=0; i<N; ++i) {
    cin >> w[i] >> v[i];
  }
  auto dp = vector<int64_t>((N+1)*(W+1));
  fill(dp.begin(), dp.end(), int64_t(0));
  for(int n=1; n<=N; ++n) {
    for(int w0 = 0; w0 <= W; ++w0) {
      if (w0 - w[n-1] < 0) {
        dp[n*(W+1) + w0] = dp[(n-1)*(W+1) + w0];
      } else {
        dp[n*(W+1) + w0] = max(dp[(n-1)*(W+1) + w0], v[n-1] + dp[(n-1)*(W+1) + w0-w[n-1]]);
      }
    }
  }
  cout << dp[N*(W+1) + W] << endl;
  return 0;
}


Measured memory_bytes: 79104
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

void maxHeapify(int A[], int n, int i) {

	int largest = i;
	int l = i * 2;
	int r = i * 2 + 1;

	if (l <= n && A[l] > A[i])
		largest = l;
	if (r <= n && A[r] > A[largest])
		largest = r;

	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapify(A, n, largest);
	}
}

void buildMaxHeap(int A[], int n) {
	for (int i = n / 2; i >= 1; --i)
		maxHeapify(A, n, i);
}

int main() {

	int n;
	scanf("%d", &n);

	int H[n + 1];

	for (int i = 1; i <= n; ++i) {
		int key;
		scanf("%d", &key);
		H[i] = key;
	}

	buildMaxHeap(H, n);

	for (int i = 1; i <= n; ++i) {
		cout << " " << H[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 5048
#include<iostream>
using namespace std;
int main() {
    long long x[4];
    long long out;
    long long buf;
    for(int i =0;i<=3;i++ ) {
        cin >> x[i];
    }
    out = x[0]*x[2];
    buf = x[0]*x[3];
    if(out < buf) {
        out = buf;
    }
    buf = x[1]*x[2];
    if(out < buf) {
        out = buf;
    }
    buf = x[1]*x[3];
    if(out < buf) {
        out = buf;
    }
    cout << out << endl;

    return 0;
}

Measured memory_bytes: 3632
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  private static class Pair {
    long price;
    long num;
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int m = sc.nextInt();

    Queue<Pair> pairs = new PriorityQueue<>(Comparator.comparing(p -> p.price));

    for (int i = 0; i < n; i++){
      Pair pair = new Pair();
      pair.price = sc.nextLong();
      pair.num = sc.nextLong();
      pairs.add(pair);
    }

    int remain = m;
    long cost = 0;
    while (!pairs.isEmpty()) {
      Pair reasonable = pairs.remove();
      if (remain > reasonable.num ) {
        cost += reasonable.price * reasonable.num;
        remain -= reasonable.num;
      } else {
        cost += reasonable.price * remain;
        os.println(cost);
        return;
      }
    }
  }

}

Measured memory_bytes: 90492
N = int(input())
A = list(map(int, input().rstrip().split()))

def gcd(X):
    if len(X) == 1:
        return X[0]
    X.sort()
    residue = set(map(lambda x: x % X[0], X[1:]))
    if 0 in residue:
        residue.remove(0)

    if len(residue) == 0:
        return X[0]
    elif len(residue) == 1:
        return gcd([X[0], residue.pop()])
    return gcd(list(residue))

print(gcd(A))


Measured memory_bytes: 14252
K = int(input())
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(li[K - 1])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;

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

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> field(H);
    for (int h = 0; h < H; h++) {
        cin >> field[h];
    }

    // 黒マスの数を数える
    int num_black = 0;
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            if (field[h][w] == '#') num_black++;
        }
    }

    // cout << num_black << endl;

    // 各点まで到達する距離
    int dist[50][50];
    memset(dist, -1, sizeof(dist));

    // 探索のキュー
    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));
    dist[0][0] = 0;

    // BFS
    while (!que.empty()) {
        pair<int, int> p;
        p = que.front();
        que.pop();

        for (int i = 0; i < 4; i++) {
            int nh = p.first + dy[i];
            int nw = p.second + dx[i];
            pair<int, int> next_p = make_pair(nh, nw);

            // cout << "here3?" << endl;
            if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;

            // cout << "here1?" << endl;
            if (dist[nh][nw] != -1) continue;

            // cout << "here2?" << endl;
            if (field[nh][nw] == '#') continue;

            // cout << "here4?" << endl;
            dist[nh][nw] = dist[p.first][p.second] + 1;
            que.push(next_p);

            // cout << "here5?" << endl;
        }
    }

    // cout << dist[H - 1][W - 1] << endl;

    if (dist[H - 1][W - 1] == -1) cout << -1 << endl;
    else {
        // 前マスの数 - 黒マスの数 - 最短経路 - 1（←スタート地点）が答え
        int ans = H * W - num_black - dist[H - 1][W - 1] - 1;

        cout << ans << endl;
    }   
}


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

using namespace std;
#define ll  long long
#define ld  long double

#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN=1e5+5;

int main()
{
int n;
cin>>n;
ll arr[n];
for(int i=0;i<n;i++)
{
    cin>>arr[i];
}
int ans=0;
for(int i=0;i<n;i++)
{
    if(arr[i]==i+1 && i!=n-1)
    {
        swap(arr[i],arr[i+1]);
        ans++;
    }
        if(i==n-1 && arr[i]==i+1)
        {
            swap(arr[i],arr[i-1]);
            ans++;
        }

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


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

int main(){
  double N;cin>>N;
  int M=(N+1)/2;
  cout<<fixed<<setprecision(7)<<(double)(M/N)<<endl;
}

Measured memory_bytes: 3724
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    map<int, int> cnt;
    vector<int> x(m, 0), dou(m, 0);
    rep(i,n){
        int a;
        cin >> a;
        cnt[a]++;
        x[a%m]++;
    }
    for(auto p : cnt){
        if(p.second >= 2){
            dou[p.first%m] += p.second / 2;
        }
    }
    int ans = 0;
    rep(i,m){
        if(i == (m-i)%m){
            ans += x[i] / 2;
            x[i] %= 2;
        }
        else{
            int add = min(x[i], x[m-i]);
            ans += add;
            x[i] -= add;
            x[m-i] -= add;
        }
        if(dou[i] > 0 && x[i] >= 2){
            int add2 = min(x[i]/2, dou[i]);
            ans += add2;
            x[i] -= add2 * 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// INT_MAX	2,147,483,647 = 2*1.0e9
// long long max 9,223,372,036,854,775,807

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, k; cin >> n >> k;
    vector<int> x(n), y(n);
    for(int i= 0; i < n; i++) cin >> x[i] >> y[i];

    ll ans = LLONG_MAX;
    for(int ix = 0 ; ix < n; ix++){
        for(int jx = ix+1; jx < n; jx++){
            int l = x[ix]; int r = x[jx];
            if(l > r) swap(l, r);
            for(int iy = 0; iy < n; iy++){
                for(int jy = iy+1; jy < n; jy++){
                    int t = y[iy]; int b = y[jy];
                    if(t < b) swap(t,b);
                    int cnt = 0;
                    for(int a = 0; a < n; a++){
                        if(l <= x[a] && x[a] <= r && b <= y[a] && y[a]<=t) cnt++;
                        if(cnt == k) ans = min(ans, (ll)(r-l)*(t-b));
                    }
                }
            }
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    while(y > 0) {
        ll tmp = x % y;
        x = y;
        y = tmp;
    }
    return x;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll n = gcd(a, b);

    map<ll, ll> factor;
    ll x = n;
    for (ll i = 2; i * i <= x; i++) {
        while (n % i == 0) {
            factor[i]++;
            n /= i;
        }
    }
    if (n != 1) factor[n]++;

    cout << factor.size() + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
import math
def start_process(length, num):

    print(ans)

def main():
    N = int(input())
    a = [int(input()) for i in range(5)]
    min_data = min(a)
    ans = 4 + math.ceil(N / min_data)
    print(ans)

def kari():
    a = list(map(int, input().split()))
    a, b = map(int, input().split())

if __name__ == '__main__':
    main()


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    string a, b;
    cin >> a >> b;
    int n = a.length(), m = b.length();
    vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i-1] == b[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    int row = n, col = m;
    string ans = "";
    while(row > 0 and col >0)
    {
        if(dp[row][col] == dp[row-1][col])
            row--;
        else if(dp[row][col] == dp[row][col-1])
            col--;
        else
        {
            ans.push_back(a[row-1]);
            row--;
            col--;
        }
    }
    reverse(all(ans));
    cout << ans << "\n";

    return 0;
}



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


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

    vector<double> ing(n);

    for(double &x : ing)
        cin >> x;

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

    double tempRes = (ing[0] + ing[1]) / 2;

    for(int i = 2 ; i < n; ++i)
    {
        tempRes = (tempRes + ing[i])/2;
    }

    cout << setprecision(12) <<  tempRes << endl;

    return 0;
}


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

int main() {
    ll n;
    cin >> n;
    ll sum = 0;
    for (int i = 2; i <= n; i++)
    {
        if (i == n) {
            sum++;
            break;
        }
        sum += i;
    }
    cout << sum << endl;
    return 0;
}


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

int main() {
	int n, t[2] = { 0 }, x[2] = { 0 }, y[2] = { 0 };
	cin >> n;
	int i;
	for (i = 0; i < n; i++) {
		t[1] = t[0];
		x[1] = x[0];
		y[1] = y[0];
		cin >> t[0] >> x[0] >> y[0];
		if (t[0] - t[1] >= abs(x[0] - x[1]) + abs(y[0] - y[1])) {
			if ((t[0] - t[1]) % 2 != (abs(x[0] - x[1]) + abs(y[0] - y[1])) % 2)
				break;
		}
		else break;
	}
	if (i == n) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define ll long long
using namespace std;
int n,m;
int a[15];
int tac[15]={-1,2,5,5,4,5,6,3,7,6};
bool d[5010][10010];
int main()
{
	cin >>n>>m;
	for (int i=0;i<m;i++) cin >>a[i];
	d[0][0]=1;
	for (int i=0;i<n/2;i++)
	{
		for (int j=0;j<=n;j++)
		{
			if (!d[i][j]) continue;
			for (int k=0;k<m;k++)
			{
				//cout <<i<<" "<<j+tac[a[k]]<<" ##\n";
				d[i+1][j+tac[a[k]]]=1;
			}
		}
	}
	int t=0;
	for (int i=n/2;i>0;i--)
	{
		if (d[i][n])
		{
			t=i;
			break;
		}
	}
	int tt=n;
	for (int i=t;i>0;i--)
	{
		int r=0;
		for (int j=0;j<m;j++)
		    if (d[i-1][tt-tac[a[j]]]) r=max(r,a[j]);
        cout <<r;
        tt-=tac[r];
	}
	return 0;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N;
    cin >> N;
    pli p[N];
    rep(i, N){
        cin >> p[i].first;
        p[i].second = i;
    }
    sort(p, p+N, greater<pli>());
    multiset<ll> s;
    ll ans = 0;
    s.insert(-1), s.insert(-1), s.insert(N), s.insert(N);
    rep(i, N){
        int j = p[i].second;
        s.insert(j);
        multiset<ll>::iterator itel = s.find(j), iter = s.find(j);
        itel--, iter++;
        ll l1 = *itel, r1 = *iter;
        itel--, iter++;
        ll l2 = *itel, r2 = *iter;
        ll num = (j-l1)*(r2-r1) + (r1-j)*(l1-l2);
        ans += p[i].first*num;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main() {
	int ans=0,a[100000],n,ta=0,i;
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	
//	for(i=0;i<n;i++) {
//		ta=0;
//		while(a[i+1]<=a[i]) {
//			ta++;
//			i++;
//			if(i>=n-1) break;
//		}
//		if(ta>ans) ans=ta;
//	}
	
	for(i=0;i<n-1;i++) {
		if(a[i+1]<=a[i]) {
			ta++;
		} else {
			if(ta>ans) ans=ta;
			ta=0;
		}
	}
	if(ta>ans) ans=ta;
	cout<<ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
using namespace std ;
int read() {
  int x = 0 , f = 1 ;
  char c = getchar() ;
  while(c < 48 || c > 57) {
    if(c == '-') f = -1 ;
    c = getchar() ;
  }
  while(c > 47 && c < 58) {
    x = (x << 1) + (x << 3) + (c & 15) ;
    c = getchar() ;
  }
  return x * f ;
}
void print(int x) {
  if(x < 0) x = -x , putchar('-') ;
  if(! x) { putchar('0') ; }
  static char st[30] ; int stp = 0 ;
  while(x) { st[++ stp] = x % 10 ^ 48 ; x /= 10 ;}
  while(stp) { putchar(st[stp --]) ; }
  putchar('\n') ;
}
int n , m ;
const int N = 100 ;
int a[N][N] , b[N][N] , c[N][N] ;
bool dp[81][81][12801] ;
signed main() {
  n = read() ; m = read() ;
  for(int i = 1 ; i <= n ; i ++) {
    for(int j = 1 ; j <= m ; j ++) {
      a[i][j] = read() ;
    }
  }
  for(int i = 1 ; i <= n ; i ++) {
    for(int j = 1 ; j <= m ; j ++) {
      b[i][j] = read() ;
    }
  }
  for(int i = 1 ; i <= n ; i ++)
    for(int j = 1 ; j <= m ; j ++) c[i][j] = abs(a[i][j] - b[i][j]) ;
  dp[1][1][c[1][1] + 6400] = 1 ;
  dp[1][1][-c[1][1] + 6400] = 1 ;
  for(int i = 1 ; i <= n ; i ++) {
    for(int j = 1 ; j <= m ; j ++){
      if(i == 1 && j == 1) continue ;
      for(int k = 0 ; k <= 12800 ; k ++) {
        if(dp[i - 1][j][k]){
          if(k - c[i][j] > 0) dp[i][j][k - c[i][j]] = 1 ;
          if(k + c[i][j] < 12800) dp[i][j][k + c[i][j]] = 1 ;
        }
        if(dp[i][j - 1][k]){
          if(k - c[i][j] > 0) dp[i][j][k - c[i][j]] = 1 ;
          if(k + c[i][j] < 12800) dp[i][j][k + c[i][j]] = 1 ;
        }
      }
    }
  }
  for(int i = 6400 ; i <= 12800 ; i ++)
    if(dp[n][m][i]) { print(i - 6400) ; return 0 ; }
  return 0 ;
}


Measured memory_bytes: 81152
from collections import Counter


n = int(input())
a = list(map(int, input().split()))

a_plus_idx = Counter([a[i] + i for i in range(n)])
a_minus_idx = Counter([i - a[i] for i in range(n)])

total = 0
for k, v in a_plus_idx.items():
    total += v * a_minus_idx[k]

print(total)


Measured memory_bytes: 61644
#include<bits/stdc++.h>
using namespace std;
int main(){
  long double n,m,d;
  cin>>n>>m>>d;
  if(d==0)cout<<fixed<<setprecision(16)<<(m-1)/n<<endl;
  else cout<<fixed<<setprecision(16)<<2*(n-d)*(m-1)/(n*n)<<endl;
}

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

double fun(int a,int b,int c,int d)
{
	return sqrt(((a-c)*(a-c))+((b-d)*(b-d)));
}


ll fact(int n)
{
	if(n==0||n==1)return 1ll;
	else
	{
		ll fact=1,i;
		for(i=1;i<=n;i++)
		{
			fact=fact*i;
		}
		return fact;
	}
}
int main()
{
	int n;
	double sum=0,fct;
	cin>>n;
	int a[n+1],b[n+1];
	int i,j;
	fct=fact(n-1);
	for(i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
	}
	for(i=1;i<=n-1;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			sum=sum+fun(a[i],b[i],a[j],b[j])*2*fct;
		}
	}
	cout<<setprecision(7)<<sum/fact(n);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;

    cin >> N;

    int d[100];
    int num[100] = {};
    
    for (int i=0; i<N; i++) {
        cin >> d[i];
        
    }

    for (int i=0; i<N; i++) {
        num[d[i]-1]++;
    }

    int height = 0;
    for (int i=0; i<100; i++) {
        if (0 < num[i]) {
            ++height;
        }
    }

    cout << height << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A=0,Z=0,c=0,m=0,n=0;
    string s;
    getline(cin,s);
        int b=s.length();
        for(int x=0;x<b;x++)
        {
            if(s[x]=='A')
            {
                 A=x+1;
                 m=1;
                break;
            }
            if(m)
                break;
        }
        for(int x=b-1;x>0;x--)
        {
            if(s[x]=='Z')
            {
            Z=x+1;
            n=1;
            break;
            }
            if(n)
                break;
        }
        c=Z-A+1;

    cout<<c;
}

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

class Team{
public:
	Team(int x,int y){n=x;t=y;}
	int n;
	int t;
	bool operator<(const Team arg)const{
		if(t < arg.t){
			return true;
		}else{
			return false;
		}
	}
};
int main(void){
	int n,m,s,t,no;
	while(cin >> n && n){
		vector<Team> v;
		for(int i=0;i<n;i++){
			cin >> no;
			t=0;
			for(int j=0;j<4;j++){
				cin >> m >> s;
				t += m*60+s;
			}
			v.push_back(Team(no,t));
		}
		sort(v.begin(), v.end());
		cout << v[0].n << endl;
		cout << v[1].n << endl;
		cout << v[v.size()-2].n << endl;
	}
}

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

int main() {
 	vector<int> x(3);
  cin>>x[0]>>x[1]>>x[2];
  sort(x.begin(),x.end());
  if(x[0]==5&&x[1]==5&&x[2]==7) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	int m, pos, p[1001], i, n, cnt, c;
	char s[30], x[10];
	while (fscanf(stdin, "%d%d", &m, &n) && (m || n)) {
		getchar();
		memset(p, 0, sizeof(p));
		memset(x, '\0', sizeof(x));
		pos = 1, cnt = m;
		for (i = 1; i <= n; i++) {
			memset(s, '\0', sizeof(s));
			fscanf(stdin, "%[^\n]*s", s),getchar();
			if (cnt == 1) continue;
			while (p[pos]) {
				pos++;
				if (pos > m) pos = 1;
			}
			if (i % 15 == 0) {
				if (strcmp(s, "FizzBuzz") != 0) p[pos] = 1, cnt--;
			}
			else if (i % 5 == 0) {
				if (strcmp(s, "Buzz") != 0) p[pos] = 1, cnt--;
			}
			else if (i % 3 == 0) {
				if (strcmp(s, "Fizz") != 0) p[pos] = 1, cnt--;
			}
			else { sprintf(x, "%d", i); if (strcmp(s, x) != 0)p[pos] = 1, cnt--; }
			pos++;
			if (pos > m) pos = 1;
		}
		for (i = 1, c = cnt; i <= m&&c!=0; i++) if (!p[i]) fprintf(stdout,"%d%c", i, c == 1? '\n' : ' '), c--;
	}
	return 0;
}

Measured memory_bytes: 628
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

set<ll> dic;
void func(ll x) {
    ll X = x;
    int cnt = 0;
    while (X > 0) {
        cnt++;
        X /= 10;
    }
    if (cnt >= 11) return;
    ll a = x%10;
    rep(i,10) {
        if (abs(a-i) <= 1) {
            ll val = x*10+i;
            if (!dic.count(val)) {
                dic.emplace(val);
                func(val);
            }
        }
    }
    return;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int K; cin >> K;

    for (int i = 1; i <= 9; i++) {
        dic.emplace(i);
        func(i);
    }
    int cnt = 0;
    for (auto i : dic) {
        cnt++;
        if (cnt==K) {
            cout << i << ln;
            return 0;
        }
    }
}


Measured memory_bytes: 27520
fn main() {
    let (a, b, n): (usize, usize, usize) = (read::<usize>(), read::<usize>(), read::<usize>());
    let x = min(b - 1, n);
    println!("{}", (a * x) / b);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

int main() {
  int n; cin >> n;
  vector<int>d(n);
  rep(i,n) cin >> d[i];
  
  int ans=0;
  for(int i=0; i<n-1; ++i) {
    for(int j=i+1; j<n; ++j) {
      ans += (d[i] * d[j]);
    }
  }
  cout << ans << endl;
  return 0;
}
 
  

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N;
int endA=0, beginB=0;
int ans=0;
int typeA=0;
int typeB=0;
int typeC=0;

signed main(void) {
    cin>>N;
    rep(i,N) {
        string S; cin>>S;
        REP(i,1,S.size()-1) {
            if (S[i-1]=='A' && S[i]=='B') ans++;
        }
        if (S[0] == 'B') {
            beginB++;
            if (S[S.size()-1] != 'A') {
                typeB++;
            }
        }
        if (S[S.size()-1] == 'A') {
            endA++;
            if (S[0] != 'B') {
                typeA++;
            }
        }
        if (S[0] == 'B' && S[S.size()-1] == 'A') {
            typeC++;
        }
    }
    if (typeA==0 && typeB==0 && typeC > 0) {
        ans = ans + min(endA, beginB) - 1;
    } else {
        ans = ans + min(endA, beginB);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int a[3];
int main()
{
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    printf("%d\n",a[0]*a[1]/2);
}

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

int main()
{
    ll n;cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++){
        cin>>ara[i];
        sum+=ara[i];
    }
    ll m;cin>>m;
    for(ll i=1;i<=m;i++)
    {
        ll a,b;cin>>a>>b;
        cout<<sum-ara[a]+b<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int num[3];
    scanf("%d %d %d", &num[0], &num[1], &num[2]);
    int len = sizeof(num) / sizeof(*num);
    for(int i = 0; i < len -1; i++) {
        for(int j = 0; j < len - 1; j++) {
            if (num[j] > num[j + 1]) {
                int tmp = num[j + 1];
                num[j + 1] = num[j];
                num[j] = tmp;
            }
        }
    }
    printf("%d %d %d\n", num[0], num[1], num[2]);
}



Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> idk1(20,0);
vector<int> idk2(20,0);
vector<vector<pair<int,int> > > vect1(20);
vector<int> taken(20,0);
void fill(int node){
  if(taken[node]==1){
    return;
  }
  taken[node] = 1;
  idk1[node] = 1;
  for(auto k:vect1[node]){
    if(k.second==1){
      idk1[k.first] = 1;
      fill(k.first);
    }
    else{
      idk2[k.first] = 1;
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int no_of_input,no_of_input1,input1,input2;
  cin >> no_of_input;
  for(int i=0;i<no_of_input;i++){
    cin >> no_of_input1;
    for(int j=0;j<no_of_input1;j++){
      cin >> input1 >> input2;
      input1--;
      vect1[i].push_back({input1,input2});
    }
  }
  int ans = 0;
  for(int i=0;i<(1<<no_of_input);i++){
    int ccnt=0;
    for(int j=0;j<no_of_input;j++){
      if(i&(1<<j)){//assumes person is true
      ccnt++;
        fill(j);
      }
    }
    for(int j=0;j<no_of_input;j++){
      //idk1 is ishonest idk2 is dishonest
      if(idk1[j]==1&&idk2[j]==1){
        goto cont;
      }
    }
    ans = max(ans,ccnt);
    cont: ;
    for(int j=0;j<idk1.size();j++){
      idk1[j] = 0;
      idk2[j] = 0;
      taken[j] = 0;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t money = 100;
  int64_t X;
  cin >> X;
  int year = 0;
  
  while(money < X){
    money = money + money/100;
    year++;
  }
  
  cout << year << endl;
}
    


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[4];
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  sort(a,a+4);
  if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)cout << "YES";
  else cout << "NO";
  /*
  int n;
  cin >> n;
  int a[n],r[n],b[n],p=0,q=0;
  char s[n];
  for(int i=0;i<n;i++){
    r[i]=99999999;
    b[i]=99999999;
  }
  for(int i=0;i<n;i++){
    cin >> a[i] >> s[i];
    if(s[i]=='R'){
      r[p]=a[i];
      p++;
    }
    else{
      b[q]=a[i];
      q++;
    }
  }
  sort(r,r+n);
  sort(b,b+n);
  for(int i=0;i<n;i++){
    if(r[i]==99999999)break;
    cout << r[i] << endl;
  }
  for(int i=0;i<n;i++){
    if(b[i]==99999999)break;
    cout << b[i] << endl;
  }
  */
}


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

using namespace std;
using ll = long long;
constexpr int mo = 1000000007;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<62;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
        cout << max(c -(a-b),0) << endl;
    return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int a, b;
    cin >> a >> b;
    for (int k = min(a, b); k <= max(a, b); k++) {
        if (abs(a - k) == abs(b - k)) {
            cout << k << "\n";
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << "\n";
    return 0;
}

Measured memory_bytes: 256
#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 long double ld;
typedef pair<int,int> P;

template <typename T>
struct Dinic {
  const T INF;
  struct edge {
    int to;
    T cap;
    int rev;
  };

  vector<vector<edge>> g;
  vector<int> level;
  vector<int> itr;


  Dinic (int V) : INF(numeric_limits<T>::max()) {
    g.resize(V);
  }

  void add_edge(int from, int to, T cap = 1) {
    g[from].emplace_back((edge){to, cap, (int)g[to].size()});
    g[to].emplace_back((edge){from, 0, (int)g[from].size() - 1});
  }

  bool bfs(int s, int t) {
    level.assign(g.size(), -1);
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
      int u = que.front(); que.pop();
      for (auto &e : g[u]) {
        if (e.cap > 0 && level[e.to] < 0) {
          level[e.to] = level[u] + 1;
          que.push(e.to);
        }
      }
    }
    return level[t] != -1;
  }

  T dfs(int u, int t, T flow) {
    if (u == t) return flow;
    for (int &i = itr[u]; i < g[u].size(); i++) {
      edge &e = g[u][i];
      if (e.cap > 0 && level[u] < level[e.to]) {
        T d = dfs(e.to, t, min(flow, e.cap));
        if (d > 0) {
          e.cap -= d;
          g[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  T max_flow(int s, int t) {
    T flow = 0;
    while (bfs(s, t)) {
      itr.assign(g.size(), 0);
      T f = 0;
      while ((f = dfs(s, t, INF)) > 0) flow += f;
    }
    return flow;
  }
};
int main() {
  int n, m;
  cin >> n >> m;
  Dinic<int> mf_g(n * m + 2);
  int S = n * m, T = n * m + 1;
  vector<string> s(n);
  rep(i,n) cin >> s[i];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i + 1 < n && s[i][j] == '.' && s[i + 1][j] == '.') {
        if ((i + j) % 2) mf_g.add_edge(i * m + j, (i + 1) * m + j);
        else mf_g.add_edge((i + 1) * m + j, i * m + j);
      }
      if (j + 1 < m && s[i][j] == '.' && s[i][j + 1] == '.') {
        if ((i + j) % 2) mf_g.add_edge(i * m + j, i * m + j + 1);
        else mf_g.add_edge(i * m + j + 1, i * m + j);
      }

      if ((i + j) % 2) mf_g.add_edge(S, i * m + j);
      else mf_g.add_edge(i * m + j, T);
    }
  }

  cout << mf_g.max_flow(S, T) << endl;
  
  for (int i = 0; i < n * m; i++) {
    int x1 = i / m, y1 = i % m;
    if ((x1 + y1) % 2 == 0) continue;
    for (auto e : mf_g.g[i]) {
      int x2 = e.to / m, y2 = e.to % m;
      if (e.to >= n * m) continue;
      if (e.cap == 0) {
        if (x1 == x2) s[x1][min(y1, y2)] = '>', s[x2][max(y1, y2)] = '<';
        else s[min(x1,x2)][y1] = 'v', s[max(x1, x2)][y2] = '^'; 
      }
    }
  }
  
  for (auto e : s) cout << e << endl;
  return 0; 
}


Measured memory_bytes: 4948
si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

x = ii()

d, m = divmod(x, 11)

ans = 2 * d
if m > 0:
    ans += 1
    if m > 6:
        ans += 1

print(ans)





Measured memory_bytes: 3064
n, m = map(int, input().split())
h = list(map(int, input().split())) 
ab = [list(map(int, input().split())) for i in range(m)]

g = [[] for i in range(n)]
for i in range(m):
    a,b = ab[i]
    g[a-1].append(h[b-1])
    g[b-1].append(h[a-1])

cnt = 0
for i in range(n):
    if g[i] == []:
        mx = 0
    else:
        mx = max(g[i])
    if h[i] > mx:
        cnt += 1 

print(cnt)

Measured memory_bytes: 41400
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class EGetEverything {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,m,a,b,c,d;
        in>>n>>m;
        vector<int> dp(1<<n,1<<30);
        dp[0]=0;
        fr(i,m){
            in>>a>>b;
            c=0;
            fr(_,b) in>>d,c^=(1<<(--d));
            fr(j,1<<n) dp[j|c]=min(dp[j|c],dp[j]+a);
        }
        int ans=dp[(1<<n)-1];
        out<<(ans!=1<<30?ans:-1)<<endl;
    }
};

int main() {
    EGetEverything solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
#define tc int t;cin>>t;while(t--)
#define get cin>>
#define geta ll a[n];for (int i = 0; i < n; ++i){cin>>a[i];}
#define puta for (int i = 0; i < n; ++i){cout<<a[i];}
#define put cout<<
ll maxi=LLONG_MIN;
ll mini=LLONG_MAX;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
ll dp[405][405];
ll pre[405]={0};
ll slime(int i,int j)
{
	if (i>=j)
	{
		return 0;
	}
	if (dp[i][j]!=-1)
	{
		return dp[i][j];
	}
	dp[i][j]=LLONG_MAX;
	for (int k = i; k < j ; ++k)
	{
		dp[i][j]=min(dp[i][j],slime(i,k)+slime(k+1,j)-pre[i-1]+pre[j]);
	}
	return dp[i][j];
}
int main() 
{
   int n;cin>>n;
   memset(dp,-1,sizeof(dp));
   memset(pre,0,sizeof(pre));
   ll a[n];
   for (int i = 1; i <= n; ++i)
   {
   	cin>>a[i];
   	pre[i]=pre[i-1]+a[i];
   }
   cout<<slime(1,n);
   return 0;
}

Measured memory_bytes: 1536
s = [int(input()) for _ in range(int(input()))]

if sum(s) % 10 != 0:
    print(sum(s))
else:
    s.sort()
    for x in s:
        if x % 10 != 0:
            print(sum(s) - x)
            break
    else:
        print(0)

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

int debug = 0;

int main()
{
    int n;
    cin >> n;
    vector<int> p;
    int tmp;
    rep(i,n){
        cin >> tmp;
        p.push_back(tmp);
    }

    vector<int> minv;
    int tmp1 = 1000000;
    for (int i = 0; i < n;i++){
        if(p[i] <= tmp1){
            // found new
            minv.push_back(p[i]);
            tmp1 = p[i];
        }else {
            minv.push_back(tmp1);
        }

    }

    if(debug){
        for(auto x:minv){
            cout << x << ",";
        }
        cout << endl;
    }

    int ans = 0;
    for (int i = 0; i < n;i++){
        if(p[i] <= minv[i])
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

int main () {
  char c;
  cin >> c;
  c++;
  cout << c << endl;
  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);
		String a = sc.next();
		String b = sc.next();

		int number = Integer.parseInt(a + b);

		for(int i = 2; i*i <= number; i++) {
			if(i * i == number) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21712
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N,M,C;
cin >> N >> M >> C;
vector<int> B(M);
for (int i = 0;i < M;i++) cin >> B.at(i);

vector<vector<int>> A(N,vector<int>(M)); 
int cnt = 0;

for (int i = 0;i < N;i++) {
    int gou = 0;
    for (int j = 0;j < M;j++) {
        cin >> A.at(i).at(j);
        gou += B.at(j) * A.at(i).at(j);
    }
    gou += C;
    if (gou > 0) cnt++;
}

cout << cnt << endl;


return 0;
}


Measured memory_bytes: 256
//product of pairs
#include<bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
int main()
{
    long long int tt;
    tt = 1;
    while (tt--)
    {
        long long int n, i, count = 0;
        cin >> n;
        long long int a[n + 1], p[n + 1];
        for (i = 1; i <= n; i++)
        {
            cin >> a[i];
        }
        p[n] = a[n];
        for (i = n - 1; i >= 1; i--)
        {
            p[i] = (p[i + 1] + a[i]) % mod;
        }
        for (i = 1; i <= n - 1; i++)
        {
            count = (count + (a[i] * p[i + 1]) % mod) % mod;
        }
        cout << count << " " << endl;
    }
    return 0;
}

Measured memory_bytes: 6700
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	ll sum = 0,lsum=0;
	ll mi = INT_MAX;
	int n;
	cin>>n;
	vi arr(n);
	for(int &i:arr)cin>>i,sum+=i;
	for(int i=0;i<n;i++) {
		lsum+=arr[i];
		sum-=arr[i];
		mi=min(mi,abs(lsum-sum));
	}
	cout<<mi;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3992
<?php

function fget_array($dlmt = null) {
    $input = trim(fgets(STDIN));
    return $dlmt ? explode($dlmt, $input) : str_split($input);
}

list($n) = fget_array(' ');
$d = fget_array(' ');

$sum = 0;
$w = 0;
foreach ($d as $v) {
    $sum += $v * $w;
    $w += $v;
}
echo $sum;
?>


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
int main() {
int A,B,C;
cin >>A>>B>>C;
if(A>C&&C>B){
    cout<<"Yes"<<endl;
}
else if(B>C&&C>A){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;
#define MAX 200000

int main(void){

	int R[MAX];
	int i,n;
	int maxv = -2000000000;
	int minv;

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

	for(i=1;i<n;i++){
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	printf("%d\n",maxv);

return 0;

}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    ll n, k;
    cin >> n >> k;
    vl p(n);
    rep(i, n) cin >> p[i];
    vl cusum(n);
    cusum[0] = p[0];
    ll ma = 0;
    repeat(i, 1, n) cusum[i] = cusum[i - 1] + p[i];
    repeat(i, k, n) ma = max(ma, cusum[i] - cusum[i - k]);
    if (n == k)
        ma = cusum[n - 1];
    // debug(ma);
    SPC(12);
    double ans = (ma + k) / 2.0;
    out(ans);
    return 0;
}


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

namespace AtCoderBeginnerContest155
{
	class Program
	{
		static void Main(string[] args)
		{
			var number = ReadInt();
			var numbers = ReadIntArray();

			for (var i = 0; i < number; i++)
			{
				if (numbers[i] % 2 == 0 && numbers[i] % 3 != 0 && numbers[i] % 5 != 0)
				{
					Console.Write("DENIED");
					return;
				}
			}
			Console.Write("APPROVED");
		}

		public static int ReadInt()
			=> int.Parse(Console.ReadLine());

		public static int[] ReadIntArray()
			=> Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

		public static long ReadLong()
			=> long.Parse(Console.ReadLine());

		public static long[] ReadLongArray()
			=> Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

		public static string ReadString()
			=> Console.ReadLine();

		public static string[] ReadStringArray()
			=> Console.ReadLine().Split();
	}
}


Measured memory_bytes: 13652
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int N=2005;
const int MOD=924844033;
int n,m;
bool ok[N*2];
int tot=0;
int f[N*2][N][2];
int JC[N];
int add (int x,int y)	{x=x+y;if (x>=MOD) x-=MOD;return x;}
int mul (int x,int y)	{return (LL)x*y%MOD;}
int dec (int x,int y)	{x=x-y;if (x<0) x=x+MOD;return x;}
int main()
{
	memset(ok,false,sizeof(ok));
	scanf("%d%d",&n,&m);
	JC[0]=1;for (int u=1;u<=n;u++) JC[u]=mul(JC[u-1],u);
	for (int u=1;u<=m;u++)
		for (int i=u;i<=n;i+=m)
		{
			tot++;
			if (u!=i) ok[tot]=true;
		}
	for (int u=1;u<=m;u++)
		for (int i=u;i<=n;i+=m)
		{
			tot++;
			if (u!=i) ok[tot]=true;
		}
	f[0][0][0]=1;
	for (int u=1;u<=tot;u++)
		for (int i=0;i<=n;i++)
		{
			f[u][i][0]=add(f[u-1][i][1],f[u-1][i][0]);
			if (ok[u+1]&&i>0) f[u][i][1]=f[u-1][i-1][0];
		}
	int ans=0;
	for (int u=0;u<=n;u++)
	{
		if (u&1) ans=dec(ans,mul(add(f[tot][u][1],f[tot][u][0]),JC[n-u]));
		else ans=add(ans,mul(add(f[tot][u][1],f[tot][u][0]),JC[n-u]));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 62976
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		List<String> list = new ArrayList<String>();
		String str = sc.next();
		for(int i = 0; i < str.length(); i++){
            for (int j = i+1; j<=str.length(); j++){
                list.add(str.substring(i,j));
            }
        }
		
		int max = Integer.MIN_VALUE;
		for(int i=0; i<list.size(); i++) {
			String tmp = list.get(i);
			int cnt = 0;
			for(int j=0; j<tmp.length(); j++) {
				if(tmp.charAt(j)=='A'||tmp.charAt(j)=='C'
						||tmp.charAt(j)=='G'||tmp.charAt(j)=='T') {
					cnt++;
				}else {
					break;
				}
			}
			max = Math.max(max, cnt);
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 25172
def multiple_of_ten(number):
    while number % 10 != 0:
        number += 1
    return number


def max_difference_between_two_lst(lst1, lst2):
    difference_lst = []
    for i in range(len(lst1)):
        number1 = lst1[i]
        number2 = lst2[i]
        difference_lst.append(abs(number1 - number2))
    max_difference = max(difference_lst)
    return max_difference


def main():
    time_lst = []
    for _ in range(5):
        time_lst.append(int(input()))

    new_time_lst = []
    for i in range(5):
        time = time_lst[i]
        new_time_lst.append(multiple_of_ten(time))

    max_difference = max_difference_between_two_lst(time_lst, new_time_lst)
    fastest = sum(new_time_lst) - max_difference
    print(fastest)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
n=int(input())
w=[input() for i in range(n)]
s=set(w)

if len(s)!=n:
  print("No")
else:
  for j in range(n-1):
    if w[j][-1]!=w[j+1][0]:
      print("No")
      break
  else:
    print("Yes")

Measured memory_bytes: 3060