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

int main(){
  char x;
  for(int i=0;i<3;i++){
    char y;
    cin >> y;
    x=y;
    if(x=='7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  
}

Measured memory_bytes: 3652
from math import gcd
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    K = int(readline())

    ans = 0
    for i in range(1,K+1):
        for j in range(1,K+1):
            for k in range(1,K+1):
                ans += gcd(gcd(i, j), k)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 67784
N = int(input())
S = list(input())
allW = S.count('W')
allE = S.count('E')
numW = S.count('E')
numE = 0
ans = 3*10**5
for i in range(N):
    if S[i] == 'E':
        numW -= 1
    ans = min(ans,numW + numE)
    if S[i] == 'W':
        numE += 1   
print(ans)

Measured memory_bytes: 11588
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N;
    vector<int> p(25);
    cin >> N;
    for (int i=0;i<N;i++) cin >> p[i];
    int cnt=0;
    for (int i=1;i<N-1;i++) {
        if ((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <ctype.h>

using namespace std;

int main(){
  string str;

  getline(cin, str);
  for( auto &i : str){
    if(isupper(i) ){
      i = tolower(i);
    }else{
      i = toupper(i);
    }
  }
  cout << str << endl;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
struct Edge {
    int p,q;
    double c;
    Edge(int p,int q,double c) {
        this->p=p;
        this->q=q;
        this->c=c;
    }
    bool operator<(const Edge &a) const {
        return (this->c)<a.c;
    } 
};
struct UnionFind {
    int *par;
    int *rank;
    UnionFind(int n) {
        par=new int[n];
        rank=new int[n];
        for(int i=0;i<n;i++) {
            par[i]=i;
            rank[i]=0;
        }
    }
    int find(int x) {
        if(x==par[x]) {
            return x;
        }else {
            return par[x]=find(par[x]);
        }
    }
    void unite(int a,int b) {
        a=find(a);
        b=find(b);
        if(a==b) return;
        if(rank[a]<rank[b]) {
            par[a]=b;
        }else {
            par[b]=a;
            if(rank[a]==rank[b]) {
                rank[a]++;
            }
        }
    }
    bool same(int a,int b) {
        return find(a)==find(b);
    }
};
int x[10000],y[10000];
int main() {
    int N,M;
    scanf("%d %d",&N,&M);
    for(int i=0;i<N;i++) {
        scanf("%d %d",&x[i],&y[i]);
    }
    priority_queue<Edge> Q;
    double sum=0;
    for(int i=0;i<M;i++) {
        int p,q;
        scanf("%d %d",&p,&q);p--;q--;
        double len=sqrt(pow(x[p]-x[q],2)+pow(y[p]-y[q],2));
        sum+=len;
        Q.push(Edge(p,q,len));
    }
    UnionFind U(N);
    double ans=0;
    while(!Q.empty()) {
        Edge e=Q.top();Q.pop();
        if(!U.same(e.p,e.q)) {
            U.unite(e.p,e.q);
            ans+=e.c;
        }
    }
    printf("%lf\n",sum-ans);
}

Measured memory_bytes: 1728
def main():
    n, m = map(int, input().split())
    num_list = list(map(int, input().split()))
    m_list = []
    for _ in range(m):
        m_list.append(list(map(int,input().split())))

    good_num = n

    list2 = [[] * 1 for i in range(n)]

    for i in range(m):
        list2[m_list[i][0]-1].append(m_list[i][1])
        list2[m_list[i][1]-1].append(m_list[i][0])

    for i in range(n):
        for j in range(len(list2[i])):
            if num_list[i] <= num_list[list2[i][j]-1]:
                good_num -= 1
                break

    print(good_num)

if __name__ == '__main__':
    main()

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll sum =0,max = 0;
    vll v(3);
    rep(i,3){
        cin >> v[i];
        sum+=v[i];
        if(v[i] >= max)max = v[i];
    } 
    if(max == sum-max)cout << "Yes" << endl;
    else cout << "No" << 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);
		// 整数の入力
		int N = sc.nextInt();
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			int Ai = sc.nextInt();
			while (Ai % 2 == 0) {
				Ai /= 2;
				cnt++;
			}
		}
		System.out.println(cnt);

	}
}


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

int main() {
    int N, K;
    cin >> N >> K;

    vector<int> data(N, 0);
    for (int i = 0; i < N; i++){
        cin >> data[i];
    }
    
    for (int i = K; i < N; i++){
        if (data[i - K] < data[i])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

}

Measured memory_bytes: 4048
n, x = map(int, raw_input().split())
if n == 2:
    if x == 2:
        print 'Yes'
        print 1
        print 2
        print 3
    else:
        print 'No'
    quit()
if x == 1 or x == 2 * n - 1:
    print 'No'
else:
    print 'Yes'
    a = range(1, 2 * n)
    k = x - n
    a = a[k:] + a[:k]
    for x in a:
        print x


Measured memory_bytes: 12036
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 1502;

int h[MAX_N],w[MAX_N];
int n,m;

int main()
{
    while(1){
        scanf("%d%d",&n,&m);
        if(n == 0 && m == 0){
            break;
        }
    	rep(i,n){
    		scanf("%d",&h[i]);
    	}
        rep(i,m){
            scanf("%d",&w[i]);
        }
        int hoge = 0;
        vector<int> sumh,sumw;
        sumh.push_back(0),sumw.push_back(0);
        rep(i,n){
            hoge += h[i];
            sumh.push_back(hoge);
        }
        hoge = 0;
        rep(i,m){
            hoge += w[i];
            sumw.push_back(hoge);
        }
        map<int,int> mp;
        rep(i,n+1){
            for(int j = i+1; j < n+1; j++){
                mp[sumh[j] - sumh[i]]++;
            }
        }
        ll ans = 0;
        rep(i,m+1){
            for(int j = i+1; j < m+1; j++){
                ans += mp[sumw[j] - sumw[i]];
            }
        }
        printf("%lld\n",ans);
    }
	return 0;
}

Measured memory_bytes: 20756
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int64_t INF = 1LL << 60;


int main() {
  int n;
  cin>>n;
  vector<int>v(n);
  vector<int>c(n);
  for(int i=0;i<n;i++){
     cin>>v[i];
  }
  for(int i=0;i<n;i++){
     cin>>c[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
   if(v[i]>c[i]){ans+=v[i]-c[i];}
  }
  cout<<ans<<endl;
  return 0;
  }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<math.h>

using namespace std;



int getSdigit(int test, int s, int N) {
    int altS;
    altS = N + 1 - s;
    for (int i = 0; i < altS - 1; i++) {
        test = test / 10;
    }
    return (test % 10);
}


bool check(int test, int s, int c, int N) {
    if (getSdigit(test, s, N) == c) {
        return true;
    }
    else {
        return false;
    }
}
int main()
{

    int N, M;
    cin >> N >> M;
    vector<int> s, c;
    for (int i = 0; i < M; i++) {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        s.push_back(tmp1);
        c.push_back(tmp2);
    }

    bool flag2 = false;

    if (N != 1) {
        for (int test = (int)pow(10, (N - 1)); test < (int)pow(10, N); test++) {
            bool flag = true;
            for (int i = 0; i < M; i++) {
                if (check(test, s[i], c[i], N) == false) {
                    flag = false;
                    continue;
                }
            }
            if (flag == true) {
                cout << test << endl;
                flag2 = true;
                break;
            }
        }
        if (flag2 == false) {
            cout << -1 << endl;
        }
        return 0;
    }
    else {
        for (int test = 0; test < (int)pow(10, N); test++) {
            bool flag = true;
            for (int i = 0; i < M; i++) {
                if (check(test, s[i], c[i], N) == false) {
                    flag = false;
                    continue;
                }
            }
            if (flag == true) {
                cout << test << endl;
                flag2 = true;
                break;
            }
        }
        if (flag2 == false) {
            cout << -1 << endl;
        }
        return 0;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  map<int64_t,int64_t> mp;
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
    if(mp.count(vec.at(i))){
      mp[vec.at(i)]++;
    }
    else{
      mp[vec.at(i)] = 1;
    }
  }
  int64_t ans = 0;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    int64_t x = itr->second;
    ans += (x*(x-1))/2;
  }
  for(int i=0; i<N; i++){
    cout << ans - (mp[vec.at(i)] - 1) << endl;
  }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int n, k, r, s, p;
string t;
vector<int> hand, score;

int game(int r) {
    if (r < k) {
        if (t[r] == 'r') hand[r] = 2;
        else if (t[r] == 's') hand[r] = 0;
        else hand[r] = 1;
    } else {
        if (t[r] == 'r') {
            if (hand[r - k] == 2) hand[r] = 3;
            else hand[r] = 2;
        } else if (t[r] == 's') {
            if (hand[r - k] == 0) hand[r] = 3;
            else hand[r] = 0;
        } else {
            if (hand[r - k] == 1) hand[r] = 3;
            else hand[r] = 1;
        }
    }
    
    return score[hand[r]];
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    cin >> n >> k >> r >> s >> p >> t;
    hand.resize(n, -1);
    score.resize(4);
    score[3] = 0, score[2] = p, score[1] = s, score[0] = r;
    int res = 0;
    rep (i, t.size()) res += game(i);
    
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 848
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
  int n,mincount;
  double sum,ave,min,kyori;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int x:a){
  	sum+=x;
  }
  ave=sum/n;
  for(int i=0;i<n;i++){
  	kyori=abs(a[i]-ave);
    if(i==0){
      min=kyori;
      mincount=i;
    }
    if(min>kyori){
      min=kyori;
      mincount=i;
    }
  }
  cout<<mincount<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main( int argc, char *argv[] )
{
    int x, y, z;
    int t;

    scanf( "%d %d %d", &x, &y, &z );

    t = x;
    x = y;
    y = t;

    t = x;
    x = z;
    z = t;

    printf( "%d %d %d\n", x, y, z );
}


Measured memory_bytes: 128
# AOJ Volume6 0652
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0641

import math

N, A, B, C, D = list(map(int, input().split()))

k1 = math.ceil(N / A)
k2 = math.ceil(N / C)

m1 = B * k1
m2 = D * k2
print(min(m1, m2))



Measured memory_bytes: 5660
// ABC113_B
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll N;
    double T, A;
    cin >> N >> T >> A;
    vector<double> vec(N);
    REP(i, N) cin >> vec[i];
    REP(i, N) {
        vec[i] = abs((T - vec[i]*0.006) - A);
    }
    
    // calculation
    cout << IDX(vec, MIN(vec)) + 1 << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e16;
const ll mod=1000000007;
typedef pair<ll,ll> pi;

void solve()
{
ll n;
cin>>n;
vector<ll>a(n);
for(ll i=0;i<n;i++)
    cin>>a[i];
    sort(a.begin(),a.end());
    ll ans=0;
for(ll i=0;i<n;i++)
{
    for(ll j=i+1;j<n;j++)
    {
        for(ll k=j+1;k<n;k++)
        {
            if((a[k]<a[i]+a[j] ) && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k]) ans++;
        }
    }
}
cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    t=1;
    for(ll i=1;i<=t;i++)
    {
        solve();
        cout<<endl;

    }
    return 0;
}

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

#A
def A():
    n, a, b = LI()
    print(min(n*a,b))
    return

#B
def B():
    a = S()
    print(a.count("1"))
    return

#C
def C():
    n = II()
    a = list(str(n))
    a = list(map(int,a))
    if not n % sum(a):
        print("Yes")
    else:
        print("No")
    return

#D
def D():
    n = II()
    a = LI()
    ans = 0
    while True:
        for i in range(n):
            if a[i] % 2:
                print(ans)
                return    
            a[i] /= 2
        ans += 1
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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


Measured memory_bytes: 38896
//============================================================================
// Name        : wLbtT
// Author      : Afify
// Description : AtCoder Beginner Contest 074
//============================================================================
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,n) for(int i = x;i<n;i++)
#define ll long long
#define ld long double
#define all(v) v.begin(),v.end()
//============================================================================


int main() {
	ll x, y;
	cin >> x >> y;
	x *= x;
	cout << x - y << endl;


	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

typedef pair<int, int> P;

int n, a[100002]{}, ans = 0;

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        a[x]++;
    }
    for(int i=0;i<=100000;i++){
        if(a[i]>2){
            if(a[i]%2){
                n -= a[i]-1;
                a[i]=1;
            }
            else{
                n -= a[i]-2;
                a[i]=2;
            }
        }
    }
    int l=0, r=100000;
    while(l<=r){
        if(a[l]<2){
            ans += a[l];
            n -= a[l];
            l++;
        }
        else if(a[r]<2){
            ans += a[r];
            n -= a[r];
            r--;
        }
        else{
            if(l==r){
                break;
            }
            if(n>4){
                ans += 2;
                n -= 2;
                l++;
                r--;
            }
            else{
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}
/*
同じ数が3つ以上ある場合そこから3枚選べば2枚ずつ減らせる
結果的にすべての数を2枚以下にすることができる
離れている2枚カードのペアを探したいので上下からみていく
間に他の数がない場合と同じカードを指している場合に注意
*/

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b, c, d;
  std::cin >> a >> b;
  std::cin >> c >> d;
  if(a!=c) std::cout << 1 << '\n';
  else std::cout << 0 << '\n';
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
using namespace std;
class day{
public:
    int p;
    int dp[8];
};
int main(){
    int n;
    cin>>n;
    day *line;
    line=new day[n];
    char dummy;
    for(int i=0;i<n;++i){
        cin>>dummy;
        if(dummy=='J'){
            line[i].p=0;
        }else if(dummy=='O'){
            line[i].p=1;
        }else{
            line[i].p=2;
        }
        for(int j=0;j<8;++j){
            line[i].dp[j]=0;
        }
    }
    if(line[0].p==0){
        for(int i=0;i<4;++i){
            line[0].dp[i*2+1]=1;
        }
    }else if(line[0].p==1){
        for(int i=0;i<2;++i){
            line[0].dp[3+i*4]=1;
        }
    }else{
        for(int i=0;i<2;++i){
            line[0].dp[5+2*i]=1;
        }
    }
    for(int i=1;i<n;++i){
        for(int j=1;j<8;++j){
            if(j&(1<<line[i].p)){
            for(int k=1;k<8;++k){
                if(j&k){
                    line[i].dp[j]=(line[i].dp[j]+line[i-1].dp[k])%10007;
                    }
                }
            }
        }
    }
    int ans=0;
    for(int i=1;i<8;++i) {
        ans+=line[n-1].dp[i];
    }
    cout<<ans%10007<<endl;
    return 0;
}

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

int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a == b)
        printf("%d\n", c);
    else if(a == c)
        printf("%d\n", b);
    else
        printf("%d\n", a);
    return 0;
}


Measured memory_bytes: 256
import itertools
N, M, Q = [int(n) for n in input().split()]
data = [[int(n) for n  in input().split()] for _ in range(Q)]

As = itertools.combinations_with_replacement(range(1, M+1),N)

max_val = 0
for A in As:
    val = 0
    for abcd in data:
        if A[abcd[1]-1] - A[abcd[0]-1] == abcd[2]:
            val += abcd[3]
    if val > max_val:
        max_val = val

print(max_val)

Measured memory_bytes: 9204
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int mod = 1e9+7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int main()
{
    ll a , b , n;
    cin >> a >> b >> n;
    cout << a * min(b-1, n) / b << endl;
    
}

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    
    vector<vector<int>> ans(H, vector<int>(W, 0));
    int now_x = 0, now_y = 0;
    rep(i, N) rep(j, a[i]) {
        ans[now_y][now_x] = i + 1;
        if (now_y % 2) {
            --now_x;
            if (now_x < 0) {
                now_x = 0;
                ++now_y;
            }
        } else {
            ++now_x;
            if (now_x >= W) {
                now_x = W - 1;
                ++now_y;
            }
        }
    }
    
    rep(i, H) {
        rep(j, W) {
            cout << ans[i][j];
            if (j == W - 1) cout << endl;
            else cout << ' ';
        }
    }
    return 0;
}


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

#define INF 1000000007
#define mem(dp,a) memset(dp,a,sizeof dp)
#define flash ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define f(i,n) for (ll i=0;i<n;i++)
#define sieve(j,mp) for(ll j=2*i ; j<=mp ; j+=i)
#define pb(x) push_back(x)
#define mp(x,y) push_back(make_pair(x,y))
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ll t=1;  while(t--)
#define F first
#define S second
main()
{
    flash
    clock_t launch=clock();
    test
    {
        ll n,k; cin>>n>>k;
        ll a[n],dp[k+1]; mem(dp,0);
        bool fs=false;
        f(i,n) cin>>a[i],dp[a[i]]=1;
        rep(i,1,k+1)
        {
            f(j,n)
            if(i-a[j]>0)
            {
                if(dp[i-a[j]]==2)
                {
                    dp[i]=1;
                    break;
                }
            }
            if(!dp[i]) dp[i]=2;
        }
        if(dp[k]==1) cout<<"First"<<endl;
        else cout<<"Second"<<endl;
    }
    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
    return 0;
}


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

int exp(int a, int b, int mod) {
	long long res{1}, z{a};
	while (b) {
		if (b&1) res = (res*z)%mod;
		z = (z*z)%mod;
		b /= 2;
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n;
	string s;
	cin >> n >> s;
	int z = count(s.begin(), s.end(), '1');
	int l{}, g{};
	for (int i = 0; i < n; i++) {
		if (s[i] == '1') {
			if (z != 1) l = (l + exp(2, n - i - 1, z - 1))%(z - 1);
			g = (g + exp(2, n - i - 1, z + 1))%(z + 1);
		}
	}
	
	for (int i = 0; i < n; i++) {
		int k{}, ans{1};
		if (s[i] == '0') {
			k = (0ll + g + exp(2, n - i - 1, z + 1))%(z + 1);
		} else {
			if (z != 1) k = (0ll + l - exp(2, n - i - 1, z - 1) + z - 1)%(z - 1);
			else ans = 0;
		}
		while (k) {
			k %= __builtin_popcount(k);
			ans++;
		}
		cout << ans << '\n';
	}
}

Measured memory_bytes: 3736
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

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

		Scanner cin = new Scanner(System.in);
		while (cin.hasNext()) {
			String[] str = cin.nextLine().split(" ");
			int rundex = Integer.parseInt(str[0]);
			int step = Integer.parseInt(str[1]);
			Queue<node> qu = new LinkedList<node>();
			int time =0;
			for (int i = 1; i <= rundex; i++) {
				str = cin.nextLine().split(" ");
				qu.add(new node(str[0], Integer.parseInt(str[1]),0));
			}
			while (!qu.isEmpty()) {
				node temp = qu.poll();
				if (temp.value <= step) {
					time+=temp.value;
					System.out.println(temp.point +" "+time);
				}
				else{
					time+=step;
					temp.value-=step;
					qu.add(temp);
				}
			}
		}
	}

	static class node {
		String point;
		int value;
		int usetime;
		public node(String point, int value,int usetime) {
			this.point = point;
			this.value = value;
			this.usetime=usetime;
		}
	}
}



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


int main()
 {
	string s;
	cin>>s;

	for(int i=0;i<s.length();i+=2)
	{
		if(s[i]=='h'&&s[i+1]=='i')
		{

		}
		else
			{
				cout<<"No"<<endl;
				return 0;
			}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
inline int read()
{
    int x=0,f=1;char c;
    c=getchar();
    while(c>'9'||c<'0'){c=getchar();if(c=='-')f=-1;}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
int r[100005];
int main()
{
    int x,n;
    x=read(),n=read();
    for(int i=1;i<=n;i++)
    {
        r[i]=read();
        //cout<<r[i]<<endl;
    }
    //r[0]=0;
    int L=0;
    int R=x;
    int tmp=0;
    int q;q=read();
    int now=1;
    while(q--)
    {
        int t,a;
        t=read(),a=read();
        while(now<=n&&t>=r[now])
        {
            L+=(r[now]-r[now-1])*(now&1==1?-1:1);
            R+=(r[now]-r[now-1])*(now&1==1?-1:1);
            tmp+=(r[now]-r[now-1])*(now&1==1?-1:1);
            if(L<0)L=0;
            if(L>x)L=x;
            if(R<0)R=0;
            if(R>x)R=x;
            now++;
        }
       // printf("%d %d %d\n",now,L,R);
        int ans=a+tmp;
        if(ans<L)ans=L;
        if(ans>R)ans=R;
        ans+=(t-r[now-1])*(now&1==1?-1:1);
        if(ans<0)ans=0;
        if(ans>x)ans=x;
        printf("%d\n",ans);
    }
}


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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n;
long long iter;
int s[200005], jump[200005];
int occ[200005];

int loop[200005];

void simulate_till_end(int cur_pos, int cur_iter){
	int stk[200005], p = 0;
	int appear[200005];
	
	memset(appear, 0, sizeof(appear));
	
	while(cur_iter <= iter){
		while(cur_pos <= n){
			int elem = s[cur_pos];
			if(appear[elem]){
				int til = appear[elem];
				while(p >= til){
					appear[stk[p]] = 0;
					p--;
				}
			}else{
				appear[elem] = ++p;
				stk[p] = elem;
			}
			cur_pos++;
		}
		cur_pos = 1;
		cur_iter++;
	}
	
	for(int i = 1; i <= p; i++){
		printf("%d%c", stk[i], i == p ? '\n':' ');
	}
	return;
}

int main(){
	scanf("%d %lld", &n, &iter);
	for(int i = 1; i <= n; i++){
		scanf("%d", &s[i]);
		if(occ[s[i]] != 0){
			jump[occ[s[i]]] = i + 1;
		}
		occ[s[i]] = i;
	}
	for(int i = 1; i <= n; i++){
		if(jump[occ[s[i]]] == 0){
			jump[occ[s[i]]] = i + n + 1;
		}
	}
	
	int cur_pos = 1, cur_iter = 1;
	loop[1] = 1;
	while(true){
	//	printf("%d %d [%lld]\n", cur_pos, cur_iter, iter);
		int nx = jump[cur_pos];
		int nx_pos = (nx - 1) % n + 1;
		int nx_iter = cur_iter + (nx - 1) / n;
		if(nx_iter > iter){
			// don't do this! Simulate the rest
			simulate_till_end(cur_pos, cur_iter);
			return 0;
		}
		else{
			cur_pos = nx_pos;
			cur_iter = nx_iter;
			if(loop[cur_pos] != 0){
				// visited before, skip ahead!
				int cycle = cur_iter - loop[cur_pos];
				assert(cycle > 0);
				iter -= (iter - cur_iter) / cycle * cycle; // the key trick
			}else{
				loop[cur_pos] = cur_iter;
			}
		}
	}
}

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

void f1(float a,float b,float c,float d,float e,float f)
{
    float x,y;
    y=(c*d-a*f)*1.0/(b*d-a*e);
    x=(c-b*y)*1.0/a;
    cout<<fixed<<setprecision(3)<<x<<" "<<y<<endl;
}

int main()
{
    float a,b,c,d,e,f;
    while(cin>>a>>b>>c>>d>>e>>f){
        f1(a,b,c,d,e,f);
    }
    return 0;
}



Measured memory_bytes: 3220
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
    int n,p,i,j,s,a[60],ji,ou;ji=ou=0;
    ll f,ans;f=ans=1;
    scanf("%d%d",&n,&p);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        a[i]=a[i]%2;
        if(a[i]==0)
            ou+=1;
        else
            ji+=1;
    }
    for(i=1;i<=ou;i++)
            ans=ans*2;
    for(i=1;i<=ji;i++)
        f=f*2;
    f=f/2;

    if(ji!=0)
        printf("%lld",ans*f);
   else  if(ji==0)
    {
        if(p==1)
            printf("0");
        else
            printf("%lld",ans);
    }

     return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int smax(int x,int y) {return x>y?x:y;}
inline int smin(int x,int y) {return x<y?x:y;}
inline int sabs(int x) {return x>0?x:-x;}
int n,a[200005],b[200005],c[200005],dp[200005][4];
inline int read() {
	int x=0,neg=1;char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') neg=-1;ch=getchar();}
	while(isdigit(ch)) {x=x*10+(ch-'0');ch=getchar();}
	return neg*x;
}
int main() {
	n=read();
	for (int i=1;i<=n;++i) 
		a[i]=read(),b[i]=read(),c[i]=read();
	for (int i=1;i<=n;++i) {
		dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
		dp[i][3]=max(dp[i-1][1],dp[i-1][2])+c[i];
	}
	cout<<max({dp[n][1],dp[n][2],dp[n][3]})<<endl;
	return 0;
}

Measured memory_bytes: 4480
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;
 
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int N,X,D;
	cin>>N>>X>>D;

	if(D==0)
	{
		if(X==0)
		{
			cout<<1<<endl;
		}
		else
		{
			cout<<N+1<<endl;
		}
	}
	else
	{
		map<int,vector<pii>> pmap;
		if(D<0)
		{
			D=-D,X=-X;
		}
		rep(i,0,N+1)
		{
			int m=(((i*X)%D)+D)%D;
			int b=(i*X)/D;
			int s=(i-1)*(i)/2;
			int t=(N-1)*(N)/2-(N-1-i)*(N-i)/2;
			s+=b,t+=b;
			pmap[m].push_back(mp(s,0));
			pmap[m].push_back(mp(t+1,1));
		}
		int ans=0;
		for(auto& p:pmap)
		{
			sort(all(p.second));
			int cnt=0;
			int pre=-INF;
			for(auto e:p.second)
			{
				if(e.second==0)
				{
					cnt++;
					if(pre==-INF)pre=e.first;
				}
				else
				{
					cnt--;
					if(cnt==0)
					{
						ans+=e.first-pre;
						pre=-INF;
					}
				}
				
			}
		}
		cout<<ans<<endl;
	}
 
	return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>

#define LL long long
using namespace std;

int main(void) {
  int n, a, b;
  cin >> n >> a >> b;

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

  LL ans=0;
  for(int i=0; i<n-1; i++) {
    LL dis = (x[i+1] - x[i]);
    dis *= a;
    if(dis < b) {
      ans += dis;
    } else {
      ans += b;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int N, X, m[110];

  cin >> N >> X;
  for(int i = 0; i < N; i++) cin >> m[i];

  sort(m, m+N);

  int a = X, ans = N;
  for(int i = 0; i < N; i++) a -= m[i];

  if(a != 0) ans += a / m[0];

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		int a = sc.nextInt();
        int b = sc.nextInt();
		int c = -1;
        for(int i=1;i<=1000;i++){if((i*8)/100==a && (i*10)/100==b){c=i;break;}}
		System.out.println(c);
	}
}


Measured memory_bytes: 23764
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int a = 0;
		for(int i = 0 ; i < 4 ; i++) a = Integer.parseInt(sc.next());
		if(a == 1) ou.println(1);
		else ou.println(0);
		ou.flush();
	}
}

Measured memory_bytes: 35700
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
int MOD = 1000000007;

using namespace std;

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

    int a[n] = {0};
    REP(i,n) cin >> a[i];

    int c[h][w] = {0};
    int x = 0;
    REP(i,h) REP(j,w){
        while(a[x] == 0) x++;
        c[i][j] = x+1;
        a[x]--;
    }

    REP(i,h){
        REP(j,w){
            if(i%2 == 0){
                cout << c[i][j];
            }else{
                cout << c[i][w-j-1];
            }
            if(j != w-1) cout << " ";
        }
        cout << endl;
    }
    

    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int arr[100010];
int cost[100010];
int val[1000010];
int main()
{int n,i,j,k,l;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);	
	}
		cost[n-1]=0;
       for(i=n-2;i>=0;i--)
       {      j=0;
	       for(l=i+1;l<n && j<k ;l++)
	       {
			val[j]=cost[l]+abs(arr[i]-arr[l]);
			j++;  
	       }
	       cost[i]=*(min_element(val,val+j));
       }
		
printf("%d\n",cost[0]);
}


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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 300001;
const ll MOD = 998244353;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif


    function<void(int)> solve = [](int t) {
        string s;
        cin >> s;
        for (auto &c:s) {
            if (c == '?') {
                c = 'D';
            }
        }
        cout<<s;
    };


    fast_io();
    cout.precision(9);
    cout << fixed;
    auto start = chrono::steady_clock::now();
//    int t;
//    cin >> t;
    for (int i = 1; i <= 1; ++i)solve(i);
    auto end = chrono::steady_clock::now();

    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}


Measured memory_bytes: 3776
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
S = LS2()
for i in range(N):
    S[i] = ord(S[i])-97

# Rolling Hash

mod = 10**9+7
base = 1234


def f(n):  # 長さnで条件を満たす部分列が存在するか
    A = []
    a = 0
    for i in range(n):
        a += S[i]*pow(base,i,mod)
        a %= mod
    A.append(a)
    for i in range(n,N):
        a -= S[i-n]
        a *= pow(base,mod-2,mod)
        a %= mod
        a += S[i]*pow(base,n-1,mod)
        a %= mod
        A.append(a)
    for i in range(N-n+1):
        for j in range(i+n,N-n+1):
            if A[i] == A[j]:
                return True
    return False


left = 0  # 可能
right = N+1  # 不可能
while left + 1 < right:
    mid = (left + right)//2
    if f(mid):
        left = mid
    else:
        right = mid
print(left)


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

main()
{
        int n; cin>>n;
        vector<pair<string,pair<int,int>>> v;
        for(int i=0;i<n;i++)
        {
                string s; int p; cin>>s>>p;
                v.push_back(make_pair(s,make_pair(p*(-1),i+1)));
        }
        sort(v.begin(),v.end());
        for(auto &it : v)cout<<it.second.second<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,x,arr[100009];
long long mini[200009];
int main(){
    cin>>n>>x;
    for(int i=0;i<n;i++){cin>>arr[i];mini[i] = 100000000009;}
    long long ans = 10000000000009;
    int itr = 0;
    for(int mxt = 0;mxt < n ;mxt ++){
        long long curr = 0;
        for(int i=0;i<n;i++){
            if(i-itr >= 0)
                mini[i] = min(mini[i],arr[i-itr]);
            else
                mini[i] = min(mini[i],arr[n-(itr-i)]);
            curr += mini[i];
        }
        ans = min(ans,curr + (long long)mxt*x);
        itr ++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
s=input()
b=0
for i in range(len(s)):
    if (i+1)%2==0 and s[i]=='R':
        b=1
    elif (i+1)%2==1 and s[i]=='L':
        b=1
print('No' if b else 'Yes')


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD = 1e9+7;
map<ll,int> mp;
vector<P> vec[200000];
int main()
{
	int n;
	ll x,d;
	ll ans=0;
	cin>>n>>x>>d;
	if(d==0)
	{
		if(x==0)
			cout<<1<<endl;
		else
			cout<<n+1<<endl;
		return 0;
	}
	if(d<0)
	{
		d*=-1;
		x*=-1;
	}
	int cnt=0;
	for(ll i=0;i<n+1;i++)
	{
		ll l=(i-1)*i/2*d+x*i;
		ll r=(ll)(n-i+n-1)*i/2*d+x*i;
		//cerr<<r<<endl;
		ll md=(x*i)%d;
		if(md<0)
			md+=d;
		if(mp.count(md))
			vec[mp[md]].push_back(P(l,r));
		else{
			mp[md]=cnt;
			cnt++;
			vec[mp[md]].push_back(P(l,r));
		}
	}
	for(int i=0;i<cnt;i++)
	{
		sort(vec[i].begin(),vec[i].end());
		ll l=vec[i][0].first;ll r=vec[i][0].second;
		for(int j=1;j<vec[i].size();j++)
		{
			if(r<vec[i][j].first)
			{
				ans+=(r-l)/d+1;
				l=vec[i][j].first;
				r=vec[i][j].second;
			}else{
				r=max(r,vec[i][j].second);
			}
		}
		ans+=(r-l)/d+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb(s) push_back(s)
#define SZ(x) ((int)(x).size())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    string s; cin >> s;
    if(s.substr(0, 4)=="YAKI"){
      p_yes();
    }else{
      p_no();
    }
    
    return 0;
}

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


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,val) memset(A,val,sizeof(A))
#define ITER(it,a) for(__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define DBG1(a) cerr<<#a<<"="<<(a)<<"\n"
#define DBG2(a,b) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"

#define ALL(V) V.begin(),V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000*1000*1000 + 7;
const LL LINF = 1LL*INF*INF;

const LL MOD = 1000000007;

const int MAX = 200005;




int main()
{
	//freopen("in.txt","r",stdin);
	//ios::sync_with_stdio(false);cin.tie(0);

	string s;
	cin>>s;

	int bal = 0;
	int ans = 0;
	FOR(i,0,SZ(s))
	{
		if(s[i] == 'S')
		{
			bal++;
		}
		else
		{
			if(bal)bal--;
			else ans++;
		}
	}

	cout<<ans*2;
	return 0;
}


Measured memory_bytes: 640
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def itoa(n):
    if n == 0:
        return "z"
    else:
        return chr(n + 96)


n = I()

ans = []
mod = 1
while n // 26 != 0:
    n, mod = divmod(n, 26)
    if mod == 0:
        n -= 1
    ans.append(itoa(mod))

if n == 0 and mod == 0:
    print("".join(ans[::-1]))
else:
    print(str(itoa(n % 26)) + "".join(ans[::-1]))


Measured memory_bytes: 9064
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=1e5+5;
//const int MOD=1e9+7;

int main(){
	int N,H,W;
	cin>>N>>H>>W;
	int ans=0;
	rep(i,N){
		int a,b;
		cin>>a>>b;
		if(a>=H&&b>=W)ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,j,c,d,a,b;
    scanf("%lld%lld",&n,&d);
    double x,y;
    c=0;
    for(i=0;i<n;i++){
        scanf("%lld%lld",&a,&b);
        j=a*a+b*b;
        x=sqrt(j);
        if(x<=d)
          c++;
    }
    printf("%lld\n",c);
    return 0;
}


Measured memory_bytes: 3744