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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

// a^n % mod を計算する O(log n)
ll powmod(ll a, ll n, ll mod) {
  ll ret = 1;
  while (n > 0) {
    if (n % 2 == 1) { ret = ret * a % mod; }
    a = a * a % mod;
    n /= 2;
  }
  return ret;
}

int calc(ll num, int depth)
{
  if (num == 0LL) return depth;

  int p_count = __builtin_popcount(num);
  return calc(ll(num % p_count), depth + 1);
}

void solve()
{
  ll n;
  char s[200005];
  cin >> n >> s;

  ll p_count = 0;
  for(int i = 0; i < n; ++i) p_count += (s[i] == '1');
  ll rem_p1 = 0;
  ll rem_m1 = 0;

  for(int i = 1; i <= n; ++i)
  {
    if (s[n - i] == '1')
    {
      rem_p1 += powmod(2LL, i - 1, p_count + 1);
      rem_p1 %= (p_count + 1);

      if (p_count > 1)
      {
        rem_m1 += powmod(2LL, i - 1, p_count - 1);
        rem_m1 %= (p_count - 1);
      }
    }
  }

  for(int i = 0; i < n; ++i)
  {
    if (s[i] == '1')
    {
      if (p_count == 1)
      {
        cout << 0 << endl;
        continue;
      }
      ll rem = rem_m1 - powmod(2, n - i - 1, p_count - 1);
      rem = (rem + (p_count - 1)) % (p_count - 1);
      cout << calc(rem, 1) << endl;
    }
    else if (s[i] == '0')
    {
      if (p_count == 0)
      {
        cout << 1 << endl;
      }
      else
      {      
        ll rem = rem_p1 + powmod(2, n - i - 1, p_count + 1);
        rem = rem % (p_count + 1);
        cout << calc(rem, 1) << endl;
      }
    }
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3796
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
L = LI()
print('Yes' if max(L) < sum(L)-max(L) else 'No')


Measured memory_bytes: 61948
n = int(input())
a = list(map(int,input().split()))
9753102468
na = n-1
if na%2 == 0:
    nl = na-1
    nr = na
else:
    nl = na
    nr = na-1

b = []
for i in range(nl,0,-2):
    b.append(i)
for i in range(0,nr+1,2):
    b.append(i)

ans = [0 for i in range(n)]
for i,k in enumerate(b):
    if n%2 == 0:
        ans[i] = a[k]
    else:
        ans[n-1-i] = a[k]
print(" ".join(list(map(str,ans))))

Measured memory_bytes: 121776
/*  Bismillahir Rahmanir Rahim
    Author  : Md. Sajjat Hosen
    Created : 06-July,2020  07:42:10 AM
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long               ll;
typedef long double             ld;
typedef unsigned long long      ull;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> pbds_multiset;

inline int Int() { int x; scanf("%d", &x); return x; }
inline ll Long() { ll x; scanf("%lld", &x); return x; }

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

const int N       = (int) 2e5 + 5;
const int maxN    = (int) 1e6 + 6;
const int Mod     = (int) 1e9 + 7;

#define     debug(x)    cerr << #x << " = " << x << '\n';
#define     all(x)      x.begin(), x.end()
#define     szof(x)     (int) x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     mp          make_pair
#define     PI          acos(-1.0)
#define     TN          typename
#define     nl          '\n'
#define     Fast_IO     ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

inline int add(int a, int b) { a += b; return a >= Mod ? a - Mod : a < 0 ? a + Mod : a; }
inline int mult(int a, int b) { return (ll) a * b % Mod; }

template <TN T> T gcd(T a, T b) { return !b ? a : gcd(b, a % b); }
template <TN T> T lcm(T a, T b) { return a * (b / gcd(a, b)); }

int main() {
    //Fast_IO
    //clock_t tStart = clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int test = 1, tc = 0;
    while (test--) {
        int n = Int();
        int cnt = (n + 999) / 1000;
        printf("%d\n", cnt * 1000 - n);
    }
    //fprintf(stderr, "\nRuntime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 3792
#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pi;
typedef pair<Pi,int> P;
P a[300000];
P b[300000];
bool used[300000];
int num[300000];
int max(int a,int b){return a>b?a:b;}
int main(){
    int n;
    int i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        a[i]=P(Pi(y,x),i);
        b[i]=P(Pi(x,y),i);
    }
    sort(a,a+n);
    sort(b,b+n);
    for(i=0;i<n;i++)num[b[i].second]=i;
    int l=0,r=n;
	int mid;
    bool pos;
    int m;
    int ans=0;
    for(i=0;i<20;i++){
        mid=(l+r)/2;
        memset(used,true,n);
        pos=false;
        ll s=0;
        for(j=0;j<mid;j++)s+=(ll)b[j].first.first;
        m=mid-1;
        if(s<=(ll)mid*(ll)a[0].first.first)pos=true;
        for(j=1;j<=n-mid;j++){
            used[a[j-1].second]=false;
            if(num[a[j-1].second]<=m){
                m++;
                while(m<n&&!used[b[m].second])m++;
                if(m==n)break;
            	s+=(ll)(b[m].first.first-a[j-1].first.second);
            }
            if(s<=(ll)mid*(ll)a[j].first.first){
            	pos=true;
                break;
            }
        }
        if(pos){
            ans=max(ans,mid);
            l=mid+1;
        }
        else r=mid;
    }
    printf("%d\n",ans);
    return 0;  
}

Measured memory_bytes: 9536
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
#define enld endl
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N; cin >> N;
    string s = "";
    while(N > 0){
        N--;
        int t = N % 26;
        s += (char)('a' + t);
        N /= 26;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3628
n, t = map(int, input().split())
T = [list(map(int, input().split())) for i in range(n)]

ans = 10000

for i in range(n):
    if T[i][1] > t:
        continue
    else:
        ans = min(ans, T[i][0])

if ans == 10000:
    print("TLE")
else:
    print(ans)

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

int main() {
    int m, k;
    cin >> m >> k;
    int pow_m = 1 << m;
    if (pow_m <= k)
        cout << "-1" << endl;
    else if (m == 1) {
        if (k == 0)
            cout << "1 0 0 1" << endl;
        else 
            cout << "-1" << endl;
    } else {
        for (int i = 0; i < pow_m; i++) {
            if (k == i) {
                continue;
            }
            cout << i << ' ';
        }
        cout << k << ' ';
        for (int i = pow_m - 1; i >= 0; i--) {
            if (k == i) {
                continue;
            }
            cout << i << ' ';
        }
        cout << k << endl;
    }

    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
public class Main{
 public static void main(String agrs[])
 {
   Scanner in = new Scanner(System.in);
   PrintWriter out = new PrintWriter(System.out);
   int n = Integer.parseInt(in.nextLine());
   int a = 0;
   int b = 0; 
   int c = 0;
   int d = 0;
   for(int i = 0; i < n; i++)
   {
     String temp = in.nextLine();
     if(temp.equals("AC"))
     {
      	a++; 
     }
     else if(temp.equals("WA"))
     {
      	b++; 
     }
     else if(temp.equals("TLE"))
     {
       c++;
     }
     else
     {
       d++;
     }
   }
   out.println("AC x " + a);
   out.println("WA x " + b);
	out.println("TLE x " + c);
	out.println("RE x " + d);
   out.close();
 }
}

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

int main() {
  int n,a,cnt;
  cin>>n;
  for (int i=0; i<n; i++) {
    scanf("%d",&a);
    if(a%2==1)
      cnt++;
  }

  if (cnt%2==1)
    cout<<"NO"<<endl;
  else
    cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

LL f[10000007];
LL is_p[10000007];
LL firdiv[10000007];

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

    for (LL i = 2; i <= n; i++) {
        is_p[i] = true;
    }
    for (LL i = 2; i <= n; i++) {
        if (is_p[i]) {
            for (LL j = 2; j * i <= n; j++) {
                if (is_p[i * j]) {
                    is_p[i * j] = false;
                    firdiv[i * j] = i;
                }
            }
        }
    }


    LL ans = 1;
    f[1] = 1;
    for (LL k = 2; k <= n; k++) {
        LL t = k;
        int c = 0;
        if (firdiv[k] > 0) {
            while (t % firdiv[k] == 0) {
                t /= firdiv[k];
                c++;
            }
        }
        if (t == k) {
            // printf("%d is prime\n", k);
            f[k] = 2;
        } else {
            f[k] = (c + 1) * f[t];
            // printf("c = %d, t = %lld, f[k] = %lld\n", c, t, f[k]);
        }
        // printf("k * f[k] = %lld\n", k * f[k]);
        ans += (k * f[k]);
    }
    cout << ans << endl;;
}


Measured memory_bytes: 237952
n = int(input())
 
a = int(n/1000)
b = int(n/100) -a*10
c = int(n/10)-a*100 - b*10
d = n -a*1000-b*100-c*10
 
if a == b  or b ==c or c == d :
  print("Bad")
else:
  print("Good")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
string S[8]={"!","SAT","FRI","THU","WED","TUE","MON","SUN"};
int main()
{
  string T;
  cin>>T;
  for(int i=0;i<8;i++)
    if(T==S[i])
    {
      cout<<i<<endl;
      return 0;
    }
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = map(int,input().split())
uf = UnionFind(n)
for _ in range(m):
  a,b = map(int,input().split())
  uf.union(a-1,b-1)
root = [0]*n
for i in range(n):
  root[uf.find(i)] += 1
print(max(root))

Measured memory_bytes: 16112
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    from collections import deque
    d = deque()
    lc = [3,5,7]
    cnt = 0
    #nya = 0
    d.append(0)
    LIST = []
    n = int(input())
    flag = False
    while True:

        a = d.popleft()
        #print(a)
        if a > n:
            #print(a,nya)
            print(cnt)
            exit()        #print(n,a)
        if len(str(a)) == 3 and (not flag):

            flag = True
        if flag and (str(a).count('3') >= 1 and str(a).count('5') >= 1 and str(a).count('7') >= 1):
            cnt += 1
        for i in range(3):
            nya = a * 10 + lc[i]
            d.append(nya)
if __name__ == '__main__':
  main()


Measured memory_bytes: 6132
from bisect import bisect_left, bisect_right

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

ans = 0
for b in B:
    ans += bisect_left(A, b) * (N - bisect_right(C, b))

print(ans)

Measured memory_bytes: 23232
#include <string>
#include <map>
#include <iostream>
using namespace std;
int main(){
  int n; cin >> n;
  map<string,int> cnt;
  for(int i=0;i<n;i++){string s; cin >> s; cnt[s]++;}
  int m; cin >> m;
  for(int i=0;i<m;i++){string s; cin >> s; cnt[s]--;}
  int ans=0;
  for(auto c:cnt) ans=max(ans,c.second);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);

  vector<int> st(n);
  rep(i, n) { st.at(a.at(i) - 1) = i; }
  rep(i, n) cout << st.at(i) + 1 << " ";
  return 0;
}


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}


string a , b , c ;


int main() {
  cin >> a >> b >> c ;
  if( a.back() == b.front() && b.back() == c.front() ){
    cout << "YES\n" ;
  } else cout << "NO\n" ;




   cerr << "\n\n" << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
   return 0 ;
}


Measured memory_bytes: 256
from collections import defaultdict

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

s = [0 for i in range(n+1)]
nums = {}
nums = defaultdict(int)
for i in range(0,n):
	s[i+1] = s[i] + a[i]

for i in range(0,n+1):
	nums[s[i]]+=1

res = 0
for key in nums:
	#print("key ",key," value ",nums[key])
	res += nums[key] * (nums[key] - 1) / 2

print(int(res))

Measured memory_bytes: 41752
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<string,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    map<pair<string,ll>,ll> mp1,mp2;
    for(ll i=0;i<(1<<n);i++){
        string x,y,z,w;
        ll cnt=0;
        for(ll j=0;j<n;j++){
            if(i>>j&1){
                x+=s[j];
                z+=s[j+n];
                cnt++;
            }else{
                y+=s[j];
                w+=s[j+n];
            }
        }
        reverse(all(y));
        x+=y;
        reverse(all(w));
        w+=z;
        mp1[make_pair(x,cnt)]++;
        mp2[make_pair(w,cnt)]++;
    }
    for(auto p:mp1){
        ans+=p.sc*mp2[make_pair(p.ft.ft,n-p.ft.sc)];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 87168
#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;
  string S;
  cin >> N >> S;

  int ans = 0;
  rep(i, 1000) {
    int num[3] = {i / 100, (i / 10) % 10, i % 10};
    int b = 0;
    rep(j, N) {
      if (S[j] == ('0' + num[b])) b++;
      if (b == 3) break;
    }
    if (b == 3) ans++;
  }

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

Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int K, A, B;
	bool ans = false;

	cin >> K >> A >> B;

	repc(i, A, B) if (i % K == 0) ans = true;

	cout << (ans ? "OK" : "NG") << endl;

	return 0;
}


Measured memory_bytes: 3572
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){

 long N, H, W;
 long A[1024], B[1024];
 int ans = 0;
 scanf("%ld %ld %ld", &N, &H, &W);
 for(int i=0; i<N; i++){
   scanf("%ld %ld", &A[i], &B[i]);
 }

 for(int j=0; j<N; j++){
  if(A[j] >= H && B[j] >= W) ans++;
}

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

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

int main() {
  int H, W;
  cin >> H >> W;
  
  for (int i = 0; i < W+2; i++) cout << '#';
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    string tmp;
    cin >> tmp;
    cout << '#' << tmp << '#' << endl;
  }
  
  for (int i = 0; i < W+2; i++) cout << '#';
  cout << endl;
}


Measured memory_bytes: 256
def solve(N, As):
    n = 1

    def gcd(a, b):
        a, b = min(a, b), max(a, b)
        while a > 0:
            a, b = b % a, a
        return b

    def lcm(a, b):
        return a * b // gcd(a, b)

    for a in As:
        n = lcm(a, n)
    return n


if __name__ == "__main__":
    N = int(input())
    As = [int(input()) for _ in range(N)]
    print(solve(N, As))


Measured memory_bytes: 3060
input_list = [int(input()) for i in range(4)]
number_of_coins = [input_list[0],input_list[1],input_list[2]]

price = input_list[3]

pattern = 0 

for i in range(number_of_coins[0]+1):
  for j in range(number_of_coins[1]+1):
    for k in range(number_of_coins[2]+1):
      if(500 * i + 100 * j + 50 * k == price):
          pattern += 1

print(pattern)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int X; cin >> X;
    array<int, 100001> dp = {};
    dp[0] = 1;
    for (int i = 0; i < 6; i++) {
        int p = 100 + i;
        for (int j = 0; j <= 100000; j++) {
            if (dp[j] && j + p <= 100000) dp[j + p] = 1;
        }
    }
    cout << dp[X] << '\n';
    return 0;
}

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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;


int main() {
	fast;
	cin.tie(0);
	lld n;
	cin>>n;
	cout<<1-n<<endl;

}








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

int main(){
  int N;
  cin >> N;
  
  bool flag = false;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(4*i + 7*j == N){
        flag = true;
      }
    }
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n;cin >> n;
	cout << "ABC" << n << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c[]=new int[a];
	long one=0;
	long zero=0;
	for(int i=0;i!=a;i++) {
		c[i]=scan.nextInt()%2;
	}
	for(int i=0;i!=a;i++) {
		if(c[i]==0) {
			zero++;
		}
		else {
			one++;
		}
	}
	long ans=1;
	if(one==0) {
		if(b==1) {
			System.out.println(0);
			return;
		}
		else {
			for(int i=0;i!=a;i++) {
				ans*=2;
			}
			System.out.println(ans);
			return;
		}
	}
	else {
		for(int i=1;i<a;i++) {
			ans*=2;
		}
		System.out.println(ans);
		return;
	}
	}
}


Measured memory_bytes: 21716
P = input().split()
stack = []
for p in P:
    if p == '+' or p == '-' or p == '*':
        a, b = stack.pop(), stack.pop()
        if p == '+':
            stack.append(b+a)
        elif p == '-':
            stack.append(b-a)
        else:
            stack.append(b*a)
    else:
        stack.append(int(p))
print(stack.pop())


Measured memory_bytes: 5600
Sixes = [0, 6, 36, 216, 1296, 7776, 46656].reverse
Nines = [0, 9, 81, 729, 6561, 59049].reverse

Draws = [0, 1, 2, 3, 4, 5, 1, 2, 3, 1, 2, 3,
         2, 3, 4, 2, 3, 4, 2, 3, 4, 3, 4, 5,
         3, 4, 5, 3, 4, 5, 4, 5, 6, 4, 5, 6, 1]


def count_draw(d)
  return Draws[d] if d <= 36

  s = Sixes.find do |i|
    i <= d
  end
  sn = count_draw(d - s) + 1

  n = Nines.find do |i|
    i <= d
  end
  nn = count_draw(d - n) + 1

  [sn, nn].min
end

def main

  # 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
  # 1 1 1          2  2  2  1  1  1           2  2  2  1  1  1           2  2  2  1  1  1 *1
  #       1  1  1           1  1  1  2  2  2  1  1  1  2  2  2  3  3  3  2  2  2  3  3  3
  #   1 2    1  2     1  2     1  2     1  2     2  1     1  2     1  2     1  2     1  2

  #
  draw = ARGF.gets.chomp.to_i

  d = count_draw(draw)

  puts d
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 1788
import static java.lang.System.out;
import java.lang.Math;
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Collections;

public class Main {
    public static void main(String args[]) {
        new Main().run();
    }

    MyInput in = new MyInput();
    public void run() {
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();
        if(A == B) out.println(C);
        else if(B == C) out.println(A);
        else out.println(B);
    }
}

class MyInput {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr= 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if(ptr < buflen) {
            return true;
        }else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch(IOException e) {
                e.printStackTrace();
            }
            if(buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    public int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <=126;
    }

    private void skipUnprintable() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        if(!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if(!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if(b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
        if('0' <= b && b <= '9') {
            n *= 10;
            n += b - '0';
        }else if(b == -1 || !isPrintableChar(b)) {
            return minus ? -n : n;
        }else {
            throw new NumberFormatException();
        }
            b = readByte();
        }
	}

    public int nextInt() {
        long nl = nextLong();
        if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

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



Measured memory_bytes: 23124
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
#define NIL -1
//#define INFTY 1000000000000000000

vector<LL> num_div={1,3,5,15,25,75};
vector<LL> num_list;
LL num_lim;

LL dfs(LL idx, LL x){
    if(x==1){
        return 1;
    }else if(idx==num_lim){
        return 0;
    }
    LL ans=0;
    for(LL i=0; i<num_div.size(); i++){
        if(num_list[idx]+1<num_div[i]){
            continue;
        }
        if(x%num_div[i]==0){
            LL tmp=dfs(idx+1, x/num_div[i]);
            //cout << idx << " " << x << " " << num_div[i] << endl;
            ans+=tmp;
        }
    }

    return ans;
}

int main(){
    LL n;
    map<LL, LL> num;
    cin >> n;
    for(LL i=2; i<=n; i++){
        LL tmp=i;
        LL idx=2;
        while(tmp!=1){
            while(tmp%idx==0){
                num[idx]++;
                tmp/=idx;
            }
            idx++;
        }
    }

    for(auto i=num.begin(); i!=num.end(); i++){
        if(i->second>=2){
            num_list.push_back(i->second);
        }
    }
    num_lim=num_list.size();
    //for(LL i=0; i<num_lim; i++){
    //    cout << num_list[i] << endl;
    //}

    cout << dfs(0,75) << endl;

    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    vector<vector<bool>> c(n,vector<bool>(n));
    for(int i=0;i<m;i++){
        int a,b;cin >> a >> b;
        a--,b--;
        c[a][b]=true;
        c[b][a]=true;
    }
    vector<int> p(n);
    for(int i=0;i<n;i++){
        p[i]=i;
    }
    int ans=0;
    do{
        bool f=true;
        if(p[0]!=0){
            break;
        }
        for(int i=0;i<n-1;i++){
            if(!c[p[i]][p[i+1]]){
                f=false;
            }
        }
        if(f){
            ans++;
        }
    }while(next_permutation(p.begin(),p.end()));
    cout << ans << endl;
}

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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/(b))
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const LL LL_INF = LL(999999999999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;
const int RUN_SOLVE = 1;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    for(int do_solve_time = 0;do_solve_time < RUN_SOLVE;do_solve_time++){
        void solve();
        if(DO_BENCHMARK){
            clock_t clock_start = clock();
            solve();
            clock_t clock_end = clock();
            const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
            cout << "\n------------------------------------\n" << time << "[ms]\n";
        }
        else solve();
    }
}

/*------------------------------↓ここからコード↓----------------------------------*/
void solve(){
    int N;
    cin >> N;
    vector<LL> vec (N);
    for(int i = 0;i < N;i++){
        cin >> vec[i];
    }
    int ans = 0;
    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            for(int k = 0;k < N;k++){
                if(vec[i] < vec[j] && vec[j] < vec[k] && vec[i]+vec[j] > vec[k]){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


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

const int maxn = 2e5 + 10;
int p[maxn];

set<int>st;

int main() 
{
    int n, k; cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> p[i];
    int inc = 1;
    int tmp = 0;
    for (int i = 0; i < k; i++) {
        st.insert(p[i]);
        if (i > 0) 
            inc = p[i] > p[i - 1] ? inc + 1 : 1;
    }
    int ans = inc >= k ? 0 : 1;
    tmp = inc >= k ? 1 : tmp;
    for (int i = k; i < n; i++) {
        inc = p[i] > p[i - 1] ? inc + 1 : 1;
        
        tmp = inc >= k ? 1 : tmp;
        int j = i - k;
        st.erase(p[j]);
        if (p[i] > *st.rbegin() && p[j] < *st.begin()) {
        } else ans += inc >= k ? 0 : 1;
        st.insert(p[i]);
    }
    cout << ans + tmp << endl;
}

Measured memory_bytes: 10368
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d  long double
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (int)1e18
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;

 
 
 
 
signed main()
{
    haha
    int h;
    cin>>h;
    int n=1;
    int s=0;
    int p=0;
    while(h)
    {
        s+=pow(2,p);
        p++;
        h/=2;
      
    }
    cout<<s;
    
    
    
    
}

Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

dd cal(ll n,ll d){
    if(d==0)return 1.0/(dd)n;
    return (dd)(n-d)*2/n/n;
}

int main(){fastio
    ll n,m,d;cin>>n>>m>>d;
    dd ans=(m-1)*cal(n,d);
    cout<<setprecision(20)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int a=0,b=0;
  if(s.size() %2 ) a=1;
  if(s[0]==s[s.size() -1]) b=1;
  if((a+b)%2) cout<<"First"<<endl;
  else cout<<"Second"<<endl;
    

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+6;
typedef long long ll;
const int mod=1e9+7;
int a,b,k;
int cnt;
int ans[maxn];
int main()
{
    scanf("%d%d%d",&a,&b,&k);
    for(int i=1;i<=max(a,b);i++)
    {
        if(a%i==0 && b%i==0)ans[cnt++]=i;
    }
    printf("%d\n",ans[cnt-k]);
    return 0;
}


Measured memory_bytes: 256
import itertools

N=input()
if N==1:
	print 1
	quit()

XY=[ map(int, raw_input().split())  for _ in range(N) ]
XY.sort(key=lambda x:(x[0],x[1]) )

D={}

C=list( itertools.combinations( range(1,N+1), 2) )

for b1, b2 in C:
	x1=XY[b1-1][0]
	y1=XY[b1-1][1]
	x2=XY[b2-1][0]
	y2=XY[b2-1][1]

	dx=x2-x1
	dy= y2-y1
	if (dx,dy) not in D:
		D[(dx,dy)]=1
	else:
		D[(dx,dy)]+=1

print N-max( D.values() )



Measured memory_bytes: 30956
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<int>> A(M,vector<int>(2));
  REP(i, M){
    REP(j, 2){
      cin >> A.at(i).at(j);
    }
  }
  
  int a = A.at(0).at(0);
  int b = A.at(0).at(1);
  int flag = 0;
  REP(i,M){
    if(A.at(i).at(0)>b){
      cout << 0 << endl;
      flag = 1;
      break;
    }else{
      a = max(a,A.at(i).at(0));
      b = min(b,A.at(i).at(1));
    }
  }
  if(flag == 0){
    cout << b-a+1 << endl;
  }
}

Measured memory_bytes: 5760
#include<stdio.h>
#define N 1000 
int main (void){
	int n,a[N],i,j,k,max,min;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	min=max=a[0];
	for(i=1;i<n;i++){
		if(a[i]>max) max=a[i];	
	}
	for(i=1;i<n;i++){
		if(a[i]<min) min=a[i];	
	}
	printf("%d",max-min);
	return 0;
}

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

using namespace std;

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

    vector<int> A(N), B(N), C(N);
    long long count_A = 0, count_C = 0;
    long long count = 0;

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

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

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

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    for(int i = 0; i < N; i++) {
        count_A = 0;
        count_C = 0;

        auto iter1 = lower_bound(A.begin(), A.end(), B[i]);
        count_A += iter1 - A.begin();

        auto iter2 = upper_bound(C.begin(), C.end(), B[i]);
        count_C += C.end() - iter2;

        count += count_A * count_C;
    }

    cout << count << endl;
	return 0;
}

Measured memory_bytes: 4556
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ins insert
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rev(i,a,b) for(int i=b;i>=a;i--)
#define boost ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL)
#define nl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int N=101;
const int M=1001;
const int MXN=1000001;
const int inf=1e9;
const ll INF=1e18;
const ll mod=1e9+7;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x=0,m=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<n;++i){
    x+=(s[i]=='I'?1:-1);
    m=max(m,x);
  }
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var S, T string
	fmt.Scan(&S, &T)
	mp1, mp2 := make(map[string]string), make(map[string]string)
	for i := 0; i < len(S); i++ {
		s, t := string(S[i]), string(T[i])
		v1, ok1 := mp1[s]
		v2, ok2 := mp2[t]
		if (ok1 && ok2) || (!ok1 && !ok2) {
			if ok1 && ok2 {
				if !(v1 == t && v2 == s) {
					fmt.Println("No")
					return
				}
			} else {
				mp1[s] = t
				mp2[t] = s
			}
		} else {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

Measured memory_bytes: 3840
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<x86intrin.h>
#include<math.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nBuf,int N){
    char *buf,*ptr;

    buf=(char*)malloc(nBuf*sizeof(char));
    my_gets(buf,nBuf,stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}

int CmpInt(const void* a, const void* b){
    return (*((int*)a)) - (*((int*)b));
}

int main(){
    int N;
    int d[100000];

    scanf("%d%*c",&N);
    InputIntAry(d, N*8, N);

    qsort(d, N, sizeof(int), CmpInt);
    printf("%d\n",d[N/2] - d[N/2 -1]);
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int L(int a,int b){
  if(a>b)swap(a,b);
  if(b%a==0)return a*(2*(b/a)-1);
  else return 2*a*(b/a)+L(a,b%a);
}

signed main(){
  int n,x;
  cin>>n>>x;
  cout<<n+L(x,n-x)<<endl;
  return 0;
}


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

Int n, k, ans;
vector<Int> p;
vector<Int> q;
using P = pair<Int, Int>;
class st{
public:
	size_t N;
	vector<P> V;
	st(vector<Int> v){
		size_t sz = v.size();
		N = 1;
		while(N < sz) N <<= 1;
		V.resize(2*N, P(1e9, -1));
		for(size_t i=0; i<sz; ++i) V[N+i] = P(v[i], v[i]);
		for(size_t i=N-1; i>0; --i) V[i] = P(min(V[2*i].first, V[2*i+1].first), max(V[2*i].second, V[2*i+1].second));
	}

	P get(size_t l, size_t r){ // [l, r)
		P res = P(1e9, -1);
		l += N;
		r += N;
		while(l < r){
			if(l % 2 == 1){
                res = P(min(res.first, V[l].first), max(res.second, V[l].second));
				++l;
			}
			if(r % 2 == 1){
				--r;
                res = P(min(res.first, V[r].first), max(res.second, V[r].second));
			}
			l >>= 1;
			r >>= 1;
		}
		return res;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	p.resize(n);
	for(auto &i:p) cin >> i;
	q.resize(n);
	q[0] = 1;
	for(Int i=1; i<n; ++i){
		if(p[i] > p[i-1]){
			q[i] = q[i-1] + 1;
		}else{
			q[i] = 1;
		}
	}
	st s(p);
	ans = 1;
    bool f = (q[k-1] < k);
	for(Int i=k; i<n; ++i){
//      cout << i << " " << ans << "\n";
		if(q[i] >= k){
			if(f) ++ans;
			f = false;
			continue;
		}
		if(p[i-k] > s.get(i-k, i).first || p[i] < s.get(i-k+1, i+1).second) ++ans;
//		cout << i << " " << s.get(i-k, i).first << " " << s.get(i-k+1, i+1).second << "\n";
//      cout << i << " " << ans << "\n";
	}
	cout << ans << "\n";
}

Measured memory_bytes: 13184
#include<stdio.h>
#include<string.h>
int main()
{
    int k;
    scanf("%d",&k);
    char str[100];
    scanf("%s",str);

    if(strlen(str)<=k)
    {
        printf("%s",str);
    }else{
    for(int i=0;i<k;i++)
    {
        printf("%c",str[i]);

    }
    printf("...");
    }
}


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

int main()
{
	string s;
	cin>>s;
	
	int minv=700;
	for(int i=0;s[i+2]!='\0';i++){
		int num=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
		minv=min(minv,abs(num-753));
	}
	
	cout<<minv<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define p 3.14159265358979323846L

using namespace std;

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

    string s;
    cin>>s;
    
    if(s=="ABC")
       cout<<"ARC";
       else
        cout<<"ABC";
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using LL = long long;
LL mod = 1e9 + 7;

typedef long long ll;



vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n) { //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll comb(ll a, ll b) { //aCbをmod計算
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % mod;
	return tmp * fac[a] % mod;
}

int main()
{
	LL S;
	cin >> S;


	//大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 300000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % mod; // n!(mod M)
		ifac[i + 1] = ifac[i] * mpow(i + 1, mod - 2) % mod; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}


	ll ans = 0;
	LL N = S / 3;

	for (LL i = 1; i <= N; i++) {
		LL temp = S - 3 * i;
		LL t_ans = comb(temp + i - 1, i-1) % mod;

		ans = (ans+ t_ans)%mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int max = 0;
		int nmax = 0;
		for (int i = 1; i <= n; i++) {
			int count = 0;
			boolean f = true;
			int a = i;
			while (f) {
				if (a%2==0) {
					count++;
					a = a/2;
					continue;
				}
				if (a%2==1) {
					if (max <= count) {
						max = count;
						nmax = i;
					}
					f = false;
				}
			}
		}
		System.out.println(nmax);
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,count=0;
  cin >> n;
  for ( int i = 0 ; i < n ; i++ ) {
    int a;
    cin >> a;
    if ((1+i)%2==1 && a%2==1) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

string setup(string s){
  string ns = "";
  for(int i=0; i<s.length(); i++){
    if(s[i] == '(' || s[i] == ')' || s[i] == '[' || s[i] == ']'){
      ns += s[i];
    }
  }
  return ns;
}

int main(void){
  
  while(1){
    string line;
    getline(cin,line);
    
    if(line == ".") break;
    
    // remove other chars
    line = setup(line);
    int a, b;
    
    while((a=line.find("()")) != -1 || (b=line.find("[]")) != -1){
      if(a != -1){
        line.erase(a, 2);
      } else if(b != -1){
        line.erase(b, 2);
      }
    }
    
    if(line.length() != 0){
      cout << "no" << endl;
    } else {
      cout << "yes" << endl;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(void)
{
	int a, b, c, res = 0, tt = 0;
	scanf("%d%d%d", &a, &b, &c);
	tt = min(c, a);
	c -= tt; a -= tt;
	res += tt;
	tt = min(b, c);
	c -= tt; b -= tt;
	res += 2*tt;
	printf("%d\n", res+bool(c)+b);
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;

  cout << (A[A.size() - 1] == B[0] &&
	   B[B.size() - 1] == C[0] ? "YES" : "NO") << endl;

  return 0;
}


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

typedef complex<double> Point;

int n, m;
Point p[200];
double v[200];

vector<vector<int> > g;
vector<int> match;
vector<bool> used;

bool dfs(int v)
{
	used[v] = true;
	for (int u : g[v]){
		int w = match[u];
		if (w < 0 || !used[w] && dfs(w)){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int solve()
{
	int res = 0;
	match.assign(n + m, -1);
	for (int v = 0; v < m + n; v++){
		if (match[v] < 0){
			used.assign(n + m, false);
			if (dfs(v)) res++;
		}
	}
	return res;
}

bool check(double x)
{
	g.assign(n + m, vector<int>());
	
	for (int i = 0; i < n; i++){
		for (int j = n; j < n + m; j++){
			double dist = abs(p[i] - p[j]);
			if (dist <= x * v[i]){
				g[i].push_back(j);
				g[j].push_back(i);
			}
		}
	}
	
	return solve() == m;
}

int main()
{
	while (scanf("%d %d", &n, &m), n){
		for (int i = 0; i < n + m; i++){
			double x, y;
			scanf("%lf %lf", &x, &y);
			p[i] = Point(x, y);
			if (i < n) scanf("%lf", v + i);
		}
		
		double l = 0.0, r = 20000.0;
		for (int i = 0; i < 100; i++){
			double m = (l + r) / 2;
			if (check(m)) r = m;
			else l = m;
		}
		
		printf("%.20f\n", l);
	}
}

Measured memory_bytes: 1412