akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

void solve() {
    vector<int> A(5);
    for (int i = 0; i < 5; i++)
        cin >> A[i];
    int p = find(A.begin(), A.end(), 0) - A.begin();
    cout << p + 1 << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3568
#include <cstdio>

int main(void){
    // Here your code !
    int a, b;
    char op;
    while (1){
        scanf("%d %c %d", &a, &op, &b);
        if (op == '?') break;
        else if (op == '+') printf("%d\n", a + b);
        else if (op == '-') printf("%d\n", a - b);
        else if (op == '*') printf("%d\n", a * b);
        else if (op == '/') printf("%d\n", a / b);
        
    }
    
    return 0;
}

Measured memory_bytes: 2664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX = 1LL<<60;
ll N, K;
vector<ll> A;

ll solve(){
    sort(A.begin(), A.end());
    ll right = MAX, left = -MAX;
    while(right - left > 1){
        ll x = (right + left)/2;
        ll S = 0, T = 0;
        for (ll i = 0; i < N; i++)
        {
            ll l = -1, r = N;
            if(A[i] > 0){
                while(r-l>1){
                    ll m = (l + r)/2;
                    if(A[m]*A[i] <= x)l = m;
                    else r = m;
                }
                S += r;
            }
            else if(A[i] < 0){
                while(r-l>1){
                    ll m = (l + r)/2;
                    if(A[m]*A[i] <= x)r = m;
                    else l = m;
                }
                S += N - r;
            }
            else if(x >= 0)S += N;
            if(A[i]*A[i] <= x)T++;
        }
        if((S-T)/2LL >= K)right = x;
        else left = x;  
    }
    return right;
}

int main() {
    cin >> N >> K;
    A.resize(N);
    for (ll i = 0; i < N; i++)cin >> A[i];
    cout << solve() << endl;
    return 0;
}

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

char s[100005];

int main()
{
	scanf("%s",s);
	int len=strlen(s);
	if(len%2==1) {
		printf("No");
		return 0;
	}
	for(register int i=0;i<=len/2;i++) {
		int flag=0;
		if(s[i]=='b') if(s[len-i-1]!='d') flag=1;
		if(s[i]=='d') if(s[len-i-1]!='b') flag=1;
		if(s[i]=='p') if(s[len-i-1]!='q') flag=1;
		if(s[i]=='q') if(s[len-i-1]!='p') flag=1;
		if(flag) {
			printf("No");
			return 0;
		} 
	}
	printf("Yes");
} 

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long x[n],y[n],h[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld %ld %ld", &x[i], &y[i], &h[i]);
  }
  long height;
  long distance;
  int flag;
  for (long cx = 0; cx <= 100; cx++) {
    for (long cy = 0; cy <= 100; cy++) {
      flag = 0;
      for (long i = 0; i < n; i++) {
        if (h[i] != 0) {
          height = h[i]+labs(cx-x[i])+labs(cy-y[i]);
          flag = 1;
          break;
        }
      }
      if (flag == 0) {
        printf("%ld %ld 1\n", cx, cy);
        return 0;
      }
      flag = 1;
      for (long i = 0; i < n; i++) {
        distance = labs(cx-x[i])+labs(cy-y[i]);
        if (height-distance > 0 && h[i] != height-distance) {
          flag = 0;
          break;
        } else if (height-distance <= 0 && h[i] != 0) {
          flag = 0;
          break;
        }
      }
      if (flag == 1) {
        printf("%ld %ld %ld\n", cx, cy, height);
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 128
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    import copy


    n, m = map(int, input().split())

    all_list = []
    for i in range(n):
        i = str(i)
        for j in copy.deepcopy(all_list):
            all_list.append(j+i)
        all_list.append(i)
    all_list.append('')

    connects = [None]*m

    for i in range(m):
        connects[i] = list(input().split())[1:]

    leaves = list(map(int, input().split()))

    ans = 0

    for pattern in all_list:
        for connect, leave in zip(connects, leaves):
            count = 0
            for num in connect:
                if str(int(num)-1) in pattern:
                    count += 1
            if count%2 != leave:
                break
        else:
            ans += 1

    print(ans)


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

int main(){
  vector<int> x(4,0);
  REP(i,4) cin>>x.at(i);
  if(abs(x.at(0)-x.at(2))<=x.at(3) || (abs(x.at(0)-x.at(1))<=x.at(3))&&(abs(x.at(1)-x.at(2))<=x.at(3))) cout<<"Yes";
  else cout<<"No";
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    cout << (H * W) - (W * h) - (H - h) * w << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const ll INF = 1LL << 40;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, K;
vector<ll> A;

ll calc(ll b)
{
  ll res = 0;
  for (int i = 0; i < N; i++)
  {
    res += abs(A[i] - (b + i + 1));
  }
  return res;
}

template <class Function>
double ternarySearch(ll l, ll r, Function f)
{
  for (int i = 0; i < 200; i++)
  {
    // cerr << "l = " << l << " r = " << r << endl;
    ll a = (l + l + r) / 3;
    ll b = (l + r + r) / 3;
    if (f(a) > f(b))
      l = a;
    else
      r = b;
  }
  return l;
}
int main()
{
  cin >> N;
  A.resize(N);
  for (auto &val : A)
  {
    cin >> val;
  }
  ll left = -INF;
  ll right = INF;
  ll b = ternarySearch(left, right, calc);
  // cerr << "b = " << b << endl;
  cout << calc(b + 1) << endl;
  return 0;
}


Measured memory_bytes: 1792
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = ((int)(n) - 1); i >= 0; i--)
#define repn(i, n) for(int i = 1; i <= (int)(n); i++)
#define reprn(i, n) for(int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
using llint = long long int;
using lint = long int;

#include <iostream>
#include <array>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	string s;
	if (a < c && c < b) {
		s = "Yes";
	} else if (b < c && c < a) {
		s = "Yes";
	} else {
		s = "No";
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
B = [0]*N
count = dict()
for i in range(1,N):
    B[i] = i-A[i]
    if B[i] in count:
        count[B[i]] += 1
    else:
        count[B[i]] = 1
total = 0
for i in range(N):
    if A[i]+i in count:
        total += count[A[i]+i]
    if i!= 0:
        count[B[i]] -= 1
print(total)

Measured memory_bytes: 41828
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
struct Tower{
      int w,s,v;
      Tower(int a,int b,int c){
            w=a;s=b;v=c;
      }
      bool operator<(Tower& X){
            return s+w<X.s+X.w;
      }
};
vector<Tower>arr(1,Tower(-INF,-INF,0));
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n;
      cin>>n;
      for(int i=0;i<n;i++){
            int a,b,c;
            cin>>a>>b>>c;
            arr.pb(Tower(a,b,c));
      }
      sort(all(arr));
      vector<vector<int>>dp(n+1,vector<int>(20004,-100));
      dp[0][0]=0;
      for(int i=1;i<=n;i++){
            int w=arr[i].w;
            int s=arr[i].s;
            int v=arr[i].v;
            for(int j=0;j<dp[i].size();j++)dp[i][j]=max(dp[i][j],dp[i-1][j]);
            for(int j=0;j<=s;j++){
                  dp[i][j+w]=max(dp[i][j+w],dp[i-1][j]+v);
            }
      }
      int ans=0;
      for(int i=0;i<dp[n].size();i++)ans=max(ans,dp[n][i]);
      cout<<ans;
}


Measured memory_bytes: 160640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _001_FindingMissingCards
{

    class Program
    {
        static void Main()
        {
            string line1 = Console.ReadLine();
            char[] ca1 = line1.ToCharArray();

            string line2 = Console.ReadLine();
            char[] ca2 = line2.ToCharArray();
            Boolean ans = true;


            for (int i = 0; i < ca1.Length; i++)
            {
                ans = true;
                for (int j = 0; j < ca2.Length; j++)
                {
                    if (ca1[(i + j) % ca1.Length] != ca2[j])
                    {
                        ans = false;
                    }
                }
                if (ans == true)
                {
                    break;
                }

            }

            if (ans == true)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }


        }
    }
}

Measured memory_bytes: 8876
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

N=I()
a=LI()

M=0
index=0
for i in range(N):
    if abs(M)<abs(a[i]):
        M=a[i]
        index=i
        
ans=[]
cnt=0
if M>0:
    for i in range(N-1):
        if a[i]>a[i+1]:
            ans.append([index+1,i+2])
            ans.append([index+1,i+2])
            a[i+1]+=M*2
            cnt+=2
            M=a[i+1]
            index=i+1
            
else:
    for i in range(N-1):
        if a[N-i-2]>a[N-i-1]:
            ans.append([index+1,N-i-1])
            ans.append([index+1,N-i-1])
            a[N-i-2]+=M*2
            cnt+=2
            M=a[N-i-2]
            index=N-i-2
            
print(cnt)
for i in range(len(ans)):
    print(' '.join(map(str, ans[i])))
            




Measured memory_bytes: 38256
#include<cstdio>

using namespace std;

const int MAX = 100005;
int res[MAX];

int main(){

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

  while(n--){
    int a,b;
    scanf("%d %d",&a,&b);
    res[a-1]++;
    res[b]--;
  }

  int now = 0;
  int ans = 0;
  for(int i = 0; i < MAX; i++){
    now += res[i];
    if(now >= i) ans = i;
  }

  printf("%d\n",ans);
  return 0;
}

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

int used[10][10];
int main(void){
	int H,W;
	cin >> H >> W;
	vector<string> a(H);
	for(int i=0;i<H;i++){
		cin >> a[i];
	}

	if(a[H-1][W-1] == '.'){
		cout << "Impossible" << endl;
		return 0;
	}

	bool ok = true;
	int y,x;
	y = x = 0;
	while( y != H-1 || x != W-1 ){
		a[y][x] = '.';
		if(y+1 < H && a[y+1][x] == '#'){
			y++;
			a[y][x] = '.';
		}
		else if(x+1 < W && a[y][x+1] == '#'){
			x++;
			a[y][x] = '.';
		}
		else{
			ok = false;
			break;
		}
	}

	for(int i=0;i<H;i++){
		// cerr << a[i] << endl;
		for(int j=0;j<W;j++){
			if(a[i][j] == '#')ok = false;
		}
	}
	if(ok)cout << "Possible" << endl;
	else cout << "Impossible" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define endl "\n"
typedef long long ll;
using namespace std;

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll cum[n];
    ll sum=0;
    ll mod=1000000007;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
        cum[i]=sum;
    }

    ll temp=cum[n-1];
    ll ans=0;
    ll x;
    for(int i=0;i<n;i++)
    {

        x=((a[i]%mod)*((temp-cum[i])%mod))%mod;
       
      ans=(ans+x)%mod;
    }

    cout<<ans<<endl;

 return 0;
}


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

int main() {
	int a;
	cin >> a;
	if (a < 1200) {
		cout << "ABC";
	}
	else if (a < 2800) {
		cout << "ARC";
	}
	else {
		cout << "AGC";
	}
}

Measured memory_bytes: 256
using System;

namespace abc167_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int[] value = new int[4];
            for(int i = 0; i < 4; ++i)
            {
                value[i] = int.Parse(str[i]);
            }
            if (value[3] <= value[0] + value[1])
            {
                if (value[3] <= value[0])
                {
                    Console.WriteLine(value[3] * 1);
                }
                else
                {
                    Console.WriteLine(value[0]);
                }
            }
            else
            {
                Console.WriteLine(value[0]-(value[3]-value[0]-value[1]));
            }
        }
    }
}


Measured memory_bytes: 27528
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = iterator.map(|x| x.parse().unwrap()).collect();

    let mut b: Vec<usize> = vec![0; n];

    counting_sort(&a, &mut b, 10_000);

    return b.iter().map(|x| x.to_string()).collect::<Vec<String>>().join(" ");
}

fn counting_sort(a: &Vec<usize>, b: &mut Vec<usize>, k: usize) {
    let mut c = vec![0; k + 1];

    for j in 0..a.len() {
        c[a[j]] += 1;
    }

    for i in 1..(k + 1) {
        c[i] += c[i - 1];
    }

    for j in (0..a.len()).rev() {
        b[c[a[j]] - 1] = a[j];
        c[a[j]] -= 1;
    }
}



Measured memory_bytes: 119692
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
int main(){
  int n;cin>>n;
  string s[100000];
  rep(i,n){
    cin>>s[i];
    sort(s[i].begin(),s[i].end());
  }
  sort(s,s+n);
  ll a=0,c=0;
  rep(i,n-1){
    if(s[i]==s[i+1])c++;
    else c=0;
    a+=c;
  }
  cout<<a;
}

Measured memory_bytes: 7296
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;

bool ch(ll n, ll m, ll v, ll p, const vector<int>& a, int id) {
    ll x = a[id] + m;
    v -= p;
    v = max((ll)0, v);
    vector<ll> b;
    for (int i = p - 1; i < n; ++i) {
        if (i == id)
            continue;
        if (a[i] > x) {
            return 0;
        }
        b.push_back(max(x - a[i], (ll)0));
    }
    if (v == 0)
        return 1;
    ll ad = 0;
    for (int i = 0; i < b.size(); ++i) {
        ad += min(b[i], m);
    }
    if (ad >= v * m)
        return 1;
    return 0;
}

void solve() {
    int n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    int low = p - 1, up = n;
    while (up - low > 1) {
        int mid = (up + low) / 2;
        if (ch(n, m, v, p, a, mid)) {
            low = mid;
        }
        else {
            up = mid;
        }
    }
    cout << up << endl;
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> s(1 << n);
  for (int i = 0; i < (1 << n); ++i) cin >> s[i];
  multiset<int> ms(s.begin(), s.end());
  vector<int> t(1, *max_element(s.begin(), s.end()));
  bool ok = true;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < (1 << i); ++j) {
      auto it = ms.lower_bound(t[j]);
      if (it == ms.begin()) {
        cout << "No\n";
        return 0;
      }
      t.push_back(*prev(it));
      ms.erase(prev(it));
    }
    sort(t.begin(), t.end(), greater<int>());
  }
  cout << "Yes\n";
}


Measured memory_bytes: 14716
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#include <map>
#include <vector>
#include <algorithm>
#include <functional>

#include <sstream>
#include <iostream>

using namespace std;
typedef long long llint;
const llint inf = 1000000000000000000LL;

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

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

const int MAXN = 105;

string a[MAXN];
int freq[26];

void no() {
  puts("No");
  exit(0);
}

int main(void) 
{
  int N, M;
  cin >> N >> M;
  REP(i, N) cin >> a[i];

  REP(i, N) REP(j, M) 
    ++freq[a[i][j] - 'a'];

  int ones = (N % 2) * (M % 2);

  REP(i, 26) {
    if (freq[i] % 2) {
      --freq[i];
      --ones;
    }
  }

  if (ones < 0 || ones == 1) no();

  int twos = (N / 2) * (M % 2) + (M / 2) * (N % 2);

  REP(i, 26) {
    if (freq[i] % 4 == 2) {
      freq[i] -= 2;
      --twos;
    }
  }

  if (twos < 0 || twos % 2) no();

  puts("Yes");

  return 0;
}




Measured memory_bytes: 256
perl -M"List::Util=min" -nale 'BEGIN{$_=<>;($N,$M)=split;} print min(
    map { $a=$F[$_]; $b=$F[$_+$M-1]; 
        $b <=0 ?abs($a):
        $a>=0 ? $b:
         (abs($a)*2+$b,abs($a)+$b*2) } (0..($N-$M))
    );' 

Measured memory_bytes: 17960
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(x) cout<<x<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,j,N,D,ans;
  vec v(3);
  rep(i,3)cin>>v[i];
  vrsort(v);
  cin>>N;
  while(N--)v[0]*=2;
  print(accumulate(all(v),0LL));
  return 0;
}

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

#define SIZE (long long)1000000000
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long S;
	scanf("%lld", &S);

	long long h = (S - 1) / SIZE + 1;
	long long w = h * SIZE - S;
	// printf("h = %lld w = %lld\n", h, w);
	printf("%lld %lld %lld %lld %lld %lld", (long long)0, (long long)0, w, h,
	       SIZE, (long long)1);

	return 0;
}

Measured memory_bytes: 256
#line 1 "template.cpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  string s;
  cin >> s;
  bool a = false;
  bool b = false;
  bool c = false;

  REP(j, 3) {
    if (s[j] == 'a') {
      a = true;
      break;
    }
  }

  REP(j, 3) {
    if (s[j] == 'b') {
      b = true;
      break;
    }
  }
  REP(j, 3) {
    if (s[j] == 'c') {
      c = true;
      break;
    }
  }
  if (a && b && c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/


int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
       int n;
       cin>>n;
       string s;
       cin>>s;
       int ans=0;
       for(int i=1;i<=n-2;i++){
         if(s[i-1]=='A' && s[i]=='B' && s[i+1]=='C'){
            ans++;
         }
       }
       cout<<ans<<endl;
    }
}















Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
vector<bool> is_prime(N, true);
void sieve()
 {
    int n=N;
    is_prime[0] = is_prime[1] = false;
    for (ll i = 2; i <= n; i++) {
        if (is_prime[i] && (long long)i * i <= n) {
            for (ll j = i * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
}
int32_t main() {
    fast();
    int n;
    cin >> n;
    sieve();
    vec re;
    f(i,1,N){
        if(is_prime[i]){
            re.pb(i);
        }
    
    }  
    int r=lower_bound(all(re),n)-re.begin();
    cout<<re[r];

}
 

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

class Program {
    static void Main(string[] args) {
        int[] counts = new int[26];
        string w = cin.next();

        foreach (var item in w) {
            counts[item - 'a']++;
        }

        bool isBeautiful = counts.All(c => c % 2 == 0);
        Console.WriteLine(isBeautiful ? "Yes" : "No");
    }
}


public class cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public static int ni() {
        return int.Parse(next());
    }

    public static long nextLong() {
        return long.Parse(next());
    }

    public static double nextDouble() {
        return double.Parse(next());
    }

}


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


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

    string s, t;

    cin >> s >> t;

    int z = s.length();

    int v = t.length();

    int mn = INT_MAX;

    for(int i=0; i<z-v+1; i++)
    {
        int cnt = 0;

        int k = 0;

        for(int j=i; j<v+i; j++)
        {
            if(s[j] != t[k++])
            {
                cnt++;
            }
        }

        mn = min(mn, cnt);

        //cout << mn << " ";
    }


    cout << mn;

}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e5 + 666;
const int INF = 1e9 + 222;

int dp[SIZE];
int tab[SIZE];
int n, k;

    void input(){
        cin >> n >> k;
        for(int i = 0; i < n; i++)
            cin >> tab[i];
    }

    void infiniti(){
        for(int i = 0; i <= n; i++)
            dp[i] = INF;
    }

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    input();
    infiniti();

    dp[0] = 0;
    dp[1] = abs(tab[0] - tab[1]);

    for(int i = 2; i < n; i++)
        for(int j = 1; j <= k && i - j >= 0; j++)
            dp[i] = min(dp[i - j] + abs(tab[i - j] - tab[i]), dp[i]);
        
    return cout << dp[n - 1], 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
int main()
{
    using namespace std;
    int n;
    cin >> n;
    int t = 7, i = 1;
    bitset<1000001> b;
    while (t % n != 0)
    {
        if (b[t])
        {
            cout << -1;
            return 0;
        }
        b[t] = 1;
        t *= 10;
        t += 7;
        t %= n;
        i += 1;
    }
    cout << i;
}

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

#define n 100005

vector<int>prime;
void sieve()
{
    vector<long long >v(n,0);
    for(long long i=4; i<n; i+=2)
    {
        v[i-1]=1;
    }
    for(long long i=3; i*i<n; i+=2)
    {
        for(long long j=i*i; j<n; j+=2*i)
        {
            v[j-1]=1;
        }
    }
    for(long long i=2; i<n; i++)
    {
        if(v[i-1]==0)
        {
            prime.push_back(i);
        }
    }
}
int main()
{
    sieve();
    int x;
    cin>>x;
    int y=lower_bound(prime.begin(),prime.end(),x)-prime.begin();
    if(x==y)
    {
       cout<<x<<endl;
    }
    else{
        cout<<prime[y]<<endl;
    }

    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  vector<vector<long>> data(N, vector<long> (20));
  vector<long> sub(20);
  long A, count;
  for(int i = 0; i < N; i++){
    cin >> A;
    count = 0;
    while(A != 0){
      data.at(i).at(count) = A % 2;
      A /= 2;
      count++;
    }
  }
  for(int i = 0; i < 20; i++)sub.at(i) = data.at(0).at(i);
  long front = 0, back = 0, ans = 1, flag;
  count = 1;
  while(front != N - 1){
    flag = 1;
    for(int i = 0; i < 20; i++){
      if(data.at(front + 1).at(i) + sub.at(i) == 2){
        flag = 0;
        break;
      }
    }
    if(flag == 0){
      for(int i = 0; i < 20; i++){
        sub.at(i) -= data.at(back).at(i);
      }
      count--;
      back++;
    } else {
      front++;
      for(int i = 0; i < 20; i++){
        sub.at(i) += data.at(front).at(i);
      }
      count++;
      ans += count;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 39424
// CODE © by 𝕌𝕥𝕜𝕒𝕣𝕤𝕙 𝔾𝕒𝕣𝕘
// Copying or sharing of this code without permission of the Author is strictly prohibited!!!
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Speed ios::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define endl "\n"
int power(int x, int n, int mod) {int res = 1; x %= mod; while (n) {if (n & 1)res = (res * x) % mod; x = (x * x) % mod; n >>= 1;} return res;}
signed main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
#endif
	int a = 0, b = 0, c = 0, d = 0, i = 0, j = 0, k = 0, t = 0, n = 0, q = 0;
	cin >> n;
	int arr[n][3], dp[n][3];
	for (i = 0; i < n; i++) {
		for (j = 0; j < 3; j++)cin >> arr[i][j];
	}
	dp[0][0] = arr[0][0]; dp[0][1] = arr[0][1]; dp[0][2] = arr[0][2];
	for (int i = 1; i < n; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i][0];
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + arr[i][2];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + arr[i][1];
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}

Measured memory_bytes: 8256
import sys
from fractions import gcd
import math

N,M = map(int, input().split())
AA = list(map(int, input().split()))

A = []
for a in AA:
    A.append(a//2)

def f(x):
    c = 0
    while x%2 == 0:
        c += 1
        x //= 2
    return c

a0 = f(A[0])
for a in A:
    if f(a) != a0:
        print(0)
        sys.exit()

def lcm(x,y):
    return x*y//gcd(x,y)

l = A[0]
for a in A:
    l = lcm(l,a)

ans = M//l
print((ans+1)//2)

Measured memory_bytes: 16232
S = input()
res = 0
l = ['A', 'C', 'G', 'T']
for i in range(len(S)):
  sub = 0
  for j in range(i, len(S)):
    if S[j] in l:
      sub += 1
    else:
      break
  if sub > res: res = sub
print(res)
  
  

Measured memory_bytes: 8800
a,b,c = map(int, input().split())

if(b < a):
    if(a <= c):
        print(b,a,c)
    else:
        print(min(b,c),max(b,c),a)
elif( a < b):
    if(b <= c):
        print(a,b,c)
    else:
        print(min(a,c),max(a,c),b)
    
elif(a < c): # a == b である
    print(a,b,c)
    if(a > c):
        print(c,a,b)


Measured memory_bytes: 5596
#include<stdio.h>
int main(){
  int x,a,b;
  scanf("%d %d %d",&x,&a,&b);
  
  int ans1,ans2;
  ans1=a>b?b:a;
  ans2=x>a+b?0:a+b-x;
  printf("%d %d",ans1,ans2);
  return 0;
}
    
  

Measured memory_bytes: 128
//ALDS1_2_A
#include<iostream>
using namespace std;

//flag
int bubblesort(int A[], int N){
    int sw = 0;
    bool flag = 1;
    for ( int i = 0; flag; i++){
        flag = 0;
        for (int j = N - 1; j >= i + 1 ; j--){
            if( A[j] < A[j - 1]){
            swap(A[j], A[j - 1]);
            flag = 1;
            sw++;
            }
        }
    }
 return sw;
}

int main(){
    int A[100], N, sw;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    
    sw = bubblesort(A, N);
    
    for (int i = 0; i < N; i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;
    
    return 0;
    
}





Measured memory_bytes: 3080
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define POW_10_5 100000
#define POW_10_9 1000000000
#define MOD 1000000007
#define INF (numeric_limits<int>::max()/2)
#define int long long

typedef pair<int, int> Pair;
typedef unordered_map<int, int> Hash;

// ---
int N;

int Ans() {
  int ans = 0;
  int r = 1;
  while ((N-r)/r > r) {
    if ((N-r)%r == 0) {
      ans += (N-r)/r;
    }
    ++r;
  }
  return ans;
}

signed main() {
  cin >> N;

  auto ans = Ans();

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


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

int main(){
    string s, t;
    cin >> s >> t;
    int n, m;
    n = s.length(),  m = t.length();

    vector<vector<int>> dp;
    dp = vector<vector<int>>(n+1, vector<int>(m+1, 0));
    
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else{
                if(dp[i][j-1] >= dp[i-1][j]){
                    dp[i][j] = dp[i][j-1];
                }else{
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
    }
    
    string ans = "";
    while(n >= 1 && m >= 1){
        if(s[n-1]==t[m-1]){
            ans = s.substr(n-1,1) + ans;
            n--;  m--;
        }else{
            if(dp[n][m-1] > dp[n-1][m]) 
                m--;
            else
                n--;
        }
    }
    cout << ans << endl;
}

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

int x[10003]={};

int main(){
	int a,b;
	while (1){
		cin>>a>>b;
		if (a==0 && b==0)return 0;
		for (int i=1;i<=a;i++){
			if (i&1)for (int j=1;j<=b;j++){
				if (j&1)cout<<"#";else cout<<".";
			}
			else for (int j=0;j<b;j++){
				if (j&1)cout<<"#";else cout<<".";
			}
		
			cout<<endl;
		}
		cout<<endl;
	}
	
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define alpha_size 26
const int maxn = 2e5 + 10;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr); 
    int k, n; 
    cin >> k >> n;
    int curr;
    cin >> curr;
    int ans = 0;
    int ret = curr;
    int a[n];
    for (int i = 1; i < n; i++){
        cin >> a[i];
        ans = max(ans, a[i] - ret);
        ret = a[i];
    }
    ans = max(ans, curr + (k - ret));
    cout << k - ans << endl;
}


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

using namespace std;

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

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long
#define vi vector<int>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())

int main(){
	llong int a;
	llong int b1,b2;
	int n;
	b1=1;b2=2;
	a=1;
	cin>>n;
	REP(i,n-1){
		a=b1+b2;
		b2=b1;b1=a;
	}
	cout<<a<<"\n";
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int p,s,q;
char t;
vi S,ans(50);
map<int,int> M;

int main(){
	while(1){
		cin>>p>>t>>s;
		if(!p&&!s) break;
		S.push_back(-s);
		M[p]=s;
	}
	sort(S.begin(),S.end());
	S.erase(unique(S.begin(),S.end()),S.end());
	for(int i=0;i<S.size();i++) ans[-S[i]]=i+1;
	while(cin>>q) cout<<ans[M[q]]<<endl;
}

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

using namespace std;
typedef long long int ll;

const ll mod = 1e9 + 7;

void solve()
{
	ll n;
	cin >> n;
	ll x, m;
	cin >> x >> m;
	vector <ll> s;
	ll ele = 1;
	map <ll,int> mp1;
	while(1)
	{
		if(mp1.find(x) != mp1.end())
		{
			ele = x;
			break;
		}
		mp1[x] = 1;
		s.push_back(x);
		x = (x%m)*(x%m);
		x %= m;
	}
	ll sum = 0;
	vector <ll> v;
	int ok = 0;
	for(auto i : s)
	{
		if(!n) break;
		if(i == ele) ok = 1;
		if(ok)
		{
			v.push_back(i);
		}
		else
		{
			sum += i;
			n--;
		}
	}
	for(int i = 1; i < v.size(); i++)
	{
		v[i] += v[i - 1];
	}
	if(v.size())
	{
		ll p = n / ((int)v.size());
		sum += (p*v[(int)v.size()-1]);
		ll c = n % ((int)v.size());
		if(c > 0) sum += v[c - 1];
	}
	cout << sum << "\n";
	
}

int main()
{
//	cin.sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
	int t = 1;
//	cin >> t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 7564
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >>n;
vector<int> a(n-1);
long long ans =0;
for(int i=0;i<n-1;i++){
    cin >> a.at(i);
}
vector<int>che (n);

che.at(0)=a.at(0);
for(int i=1;i<n-1;i++){
    if(a.at(i-1)>a.at(i)){
        che.at(i)=a.at(i);
    }
    else{
        che.at(i)=a.at(i-1);
    }
}
che.back()=a.back();
for(int i=0;i<n;i++){
    ans+=che.at(i);
}
cout << ans << endl;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let x: usize = iterator.next().unwrap().parse().unwrap();

    if x <= 6 {
        return "1".to_string();
    }

    if x <= 11 {
        return "2".to_string();
    }

    let mut ans = x / 11 * 2;
    if x % 11 != 0 {
        if x % 11 > 6 {
            ans += 2;
        } else {
            ans += 1;
        }
    }
    return ans.to_string();
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<math.h>
#include<vector>
using namespace std;
int N,D,X;
int main(){
    cin>>N>>D>>X;
    int A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int x[N];
    for(int i=0;i<N;i++){
        x[i]=0;
        int day1=0;
        int day2=0;
        while(day2<=D){
            day2=day1*A[i]+1;
            day1++;
            x[i]++;
        }
        x[i]--;
    }
    int sum=0;
    for(int i=0;i<N;i++){
        sum+=x[i];
    }
    cout<<X+sum<<"\n";
    return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,int>s;
char s1[105];
int main()
{
	int n;
	char ch;
	scanf("%d",&n);
	scanf("%s",s1);
	s[s1]++;
	ch=s1[strlen(s1)-1];
	for(register int i=2;i<=n;i++)
	{
		scanf("%s",s1);
		if(s1[0]!=ch||s[s1]!=0)
		{
			cout<<"No\n";
			exit(0);
		}
		ch=s1[strlen(s1)-1];
		s[s1]++;
	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdint>

using namespace std;

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main() {
  int n, d1, d2;
  int count = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> d1 >> d2;
    if (d1 == d2) {
      count++;
      if (count == 3) {
        cout << "Yes" << endl;
        return EXIT_SUCCESS;
      }
    } else {
      count = 0;
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 3612
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    #距離が最大を通らないようにする
    K,N=MI()
    A=LI()
    dist = []
    for i,a in enumerate(A):
        if(i!=N-1):
            dist.append(A[i+1]-a)
        else:
            dist.append(A[0]+K-a)
    dist.sort()
    print(sum(dist[:-1]))
if __name__ == '__main__':
    main()

Measured memory_bytes: 28520
S = input()
MOD = 10**9 + 7
M = 13

dp = [0] * M
dp[0] = 1

for s in S:
    newDp = [0] * M
    if s == '?':
        for s in range(10):
            for i in range(M):
                newDp[(i * 10 + s) % M] += dp[i]
    else:
        s = int(s)
        for i in range(M):
            newDp[(i * 10 + s) % M] = dp[i]
    for i in range(M):
        dp[i] = newDp[i] % MOD

print(dp[5])


Measured memory_bytes: 42988
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

if A+B+C+D==7:
    print(str(A)+"+"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif A+B+C-D==7:
    print(str(A)+"+"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A+B-C+D==7:
    print(str(A)+"+"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A-B+C+D==7:
    print(str(A)+"-"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif A+B-C-D==7:
    print(str(A)+"+"+str(B)+"-"+str(C)+"-"+str(D)+"=7")
elif A-B+C-D==7:
    print(str(A)+"-"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A-B-C+D==7:
    print(str(A)+"-"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A-B-C-D==7:
    print(str(A)+"-"+str(B)+"-"+str(C)+"-"+str(D)+"=7")

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);

using namespace std;

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

const int MOD = 1000000007;


void add_self(int& a, int b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

void sub_self(int& a, int b) {
	a -= b;
	if (a < 0) {
		a += MOD;
	}
}


int main() {

	// fast input/output
	FAST_IO;

	int n;
	cin>>n;
	vector<int> dp(3);
	// dp[i] the total cost such that we did activity i on the last day 
	for (int i = 0 ; i < n; ++i) {
		vector<int> c(3);
		vector<int> new_dp(3, INT_MIN);
		for (int j = 0; j < 3; ++j)
			cin >> c[j];
		for (int j = 0; j  < 3; ++j) {
			for (int k = 0; k <  3; ++k) {
				if (j != k)
					new_dp[j] = max(new_dp[j], dp[k] + c[j]);
			}
		}
		dp = new_dp;
	}
	cout << max(dp[0], max(dp[1], dp[2]));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int a, b, c;
    string ans = "NO";
    cin >> a >> b >> c;
    int i = 1;
    int n=0;
    int sum = a;
    while(n < 100000000){
        if(sum % b == c){
            ans = "YES";
            break;
        }
        sum+=a;
        n++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d;
  e=a+b;
  f=c+d;
  if(e>f){
    cout<<"Left"<<endl;
  }
    if(e==f){
    cout<<"Balanced"<<endl;
  }
    if(e<f){
    cout<<"Right"<<endl;
  }
}


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

int main(){
    int n;
    cin >> n;
    vector <long long> a(n);
    rep(i,n) cin >> a[i];

    if(n == 1){
        cout << 0 << endl;
        return 0;
    }

    long long cur = a[0];
    long long ans = 0; 
    for(int i=1; i<=n-1 ; i++){
        if(cur > a[i]){
            ans = ans + cur - a[i];
        }
        else{
            cur = a[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4784