akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  string S;
  cin >> S;
  int N = S.length();

  int cnt =0;
  rep(i,N)
  {
    if(S[i] == (i%2 ==0 ? '0' :'1'))cnt ++;
  }
  cout << min(N-cnt,cnt) <<endl;

  
}


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

#define SE second
#define FI first
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int) (x).size())

#define _ << " " <<
#define TR(x) if ( 1 ) cout << #x _ x << endl

using namespace std;
using ii = pair<int, int>;

const int INF = (int) 1e9 + 5;

int n, m;

int main() {
    cin >> n >> m;
    
    cout << (n-1) * (m-1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double pi = acos(-1);

int get_high(int n)
{
    while (true)
    {
        if (n / 10 == 0)
        {
            return n;
        }
        else
        {
            n /= 10;
        }
    }
}

int get_low(int n)
{
    return n % 10;
}

int get_digit(int n)
{
    int ans = 0;
    while (n != 0)
    {
        ans++;
        n /= 10;
    }

    return ans;
}

int main()
{
    int n;
    cin >> n;
    int HIGH = get_high(n);
    int LOW = get_low(n);
    int DIGIT = get_digit(n);
    vector<int> a(DIGIT);
    int tmp = n;
    for (int i = 0; i < DIGIT; i++)
    {
        a[i] = tmp % 10;
        tmp /= 10;
    }
    if (DIGIT == 1)
    {
        cout << n << endl;
        return 0;
    }
    ll ans = 0;
    vector<int> vec(n + 1, 0);
    vector<vector<int>> table(10, vector<int>(10, 0));
    for (int i = 1; i <= n; i++)
    {
        int high, low, digit;
        low = get_low(i);
        high = get_high(i);
        table[low][high]++;
    }
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            ans += table[i][j] * table[j][i];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		int[] DP = new int[H+10001];
		for(int i = 0;i < N;i++){
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
		}
		sc.close();

		for(int i = 1;i < H+1;i++){
			int cnt = i + 10000;
			DP[cnt] = Integer.MAX_VALUE;
			for(int j = 0;j < N;j++){
				DP[cnt] = Math.min(DP[cnt], DP[cnt - A[j]] + B[j]);
			}
		}
		System.out.println(DP[H+10000]);
	}
}

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

int main(){
  int k;
  int A, B;
  cin >> A >> B;
  for(int i=A; i<=B; i++){
    int A1 = i%10; //一桁目
    int A2 = (i/10)%10; //2
    int A3 = (i/100)%10; //3
    int A4 = (i/1000)%10; //4
    int A5 = (i/10000)%10; //5
    if(A1 == A5 && A2 == A4){
      k++;
    }
  }
  cout << k << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    
    map<string, int> mp;
    for (int i = 0; i < n; ++i){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << mp.size() << endl;
    return 0;
}

Measured memory_bytes: 19100
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=(a);i<=(b);++i)
int n,a,b;
int main(){
	cin>>n>>a>>b;
	int d=b/n;
	int s=d*n;
	if(s>=a)cout<<"OK";
	else cout<<"NG";
	return 0;
} 

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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 1000 * 1000 + 17, mod = 998244353;

int pw(int a, int b) {
	if (b == 0)
		return 1;
	int res = 1;
	while (b) {
		if (b & 1)
			res = (1LL * a * res) % mod;
		a = (1LL * a * a) % mod;
		b >>= 1;
	}
	return res;
}

int n, a[MAXN], c[MAXN], ans = 1, mx;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		c[a[i]]++, mx = max(mx, a[i]);
	if (a[1] != 0 || c[0] != 1)
		return cout << 0 << endl, 0;
	for (int i = 1; i <= mx; i++) {
		if (c[i] == 0)
			return cout << 0 << endl, 0;
		ans = (1LL * pw(c[i - 1], c[i]) * ans) % mod;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int n;
  map<string,int> m;
  cin>>n;
  for(int i=0;i<n;i++) {
    string x;
    cin>>x;
    m[x]++;
  }
  int f = INT_MIN;
  string ans;
  map<string,int>::iterator it;
  for (it = m.begin(); it != m.end(); ++it) {
    if(f<it->second)
      f = it->second;
  }
  map<string,int>::iterator it1;
  for (it1 = m.begin(); it1 != m.end(); ++it1) {
    if(it1->second == f)
      cout<<it1->first<<endl;
  }
  return 0;
}

Measured memory_bytes: 25216
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n; cin >> n;
    int res[n]; rep(i,n) res[i]=0;
    vector<int> v;
    
    for(int x=1; x<100; x++){
        for(int y=1; y<100; y++){
            for(int z=1; z<100; z++){
                ll sum = 0;
                sum = x*x + y*y + z*z + x*y + y*z + z*x;
                if(sum<=10000) v.push_back(sum);
            }
        }
    }
    sort(all(v));
    
    for(int i=1; i<=n; i++){
        cout << count(all(v), i) << ln;
    }
    return 0;
}

Measured memory_bytes: 4240
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<iomanip>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    
    }
    sort(begin(v), end(v));
    double ans = (v[0] + v[1]) / 2.0;
    for(int i = 2; i < n; i++){
        ans = (ans + v[i]) / 2.0;
    }
    cout << setprecision(9) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
#define fast_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll dp[1005][1005];
ll a[1005];
bool vis[N],vis1[N];
vector<ll>v[N];
ll mem[10005][10005];
pair<ll,ll>p[N],p1[N];
set<int>s;
map<string,ll>mp;
queue<ll>q;
ll mod=1e9+7,n,m;
main()
{
    fast_IO
    int n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++) cin>>a[i];

    for(int i=a[0]; i<=k; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(i-a[j]>=0&&!vis[i-a[j]])
                vis[i]=1;

        }

    }
    if(vis[k]) cout<<"First";
    else cout<<"Second";

}










Measured memory_bytes: 8464
def read_input():
    n = int(input())
    alist = list(map(int, input().split()))

    return n, alist

def submit():
    n, alist = read_input()

    mostleft = max(alist)
    mostright = min(alist)

    print(mostleft - mostright)

if __name__ == '__main__':
    submit()

Measured memory_bytes: 38256
class Node:
    def __init__(self, value, next, prev):
        self.value = value
        self.next = next
        self.prev = prev


class Que:
    def __init__(self):
        self.head = None
        self.last = None

    def add(self, value):
        new_node = Node(value, None, self.last)
        if not self.head:
            self.head = new_node
        else:
            self.last.next = new_node
        self.last = new_node

    def popleft(self):
        if not self.head:
            return -1
        v = self.head.value

        self.head = self.head.next
        return v

    def isempty(self):
        return not self.head


n, q = map(int, input().split())
a = []
for i in range(n):
    p, t = input().split()
    a.append([p, int(t)])

que = Que()

for e in a:
    que.add(e)

sum_t = 0
while not que.isempty():
    p, t = que.popleft()
    if t > q:
        que.add([p, t - q])
        sum_t += q
    else:
        sum_t += t
        print(p, sum_t)








Measured memory_bytes: 59036
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


ll powmod(ll n,ll k){
    n %= mod;
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}

ll gcd(ll x,ll y){
    return y?gcd(y,x%y):x;
}
int main(){
    ll h, w, t;
    cin >> h >> w >> t;
    ll g1 = gcd(h, t), g2 = gcd(w, t);
    h /= g1; w /= g2;
    ll ans = 1 + (powmod(2, h) - 1) + (powmod(2, w) - 1) + (powmod(2, gcd(h, w)) - 2);
    cout << powmod(ans, g1 * g2) << endl;
    return 0;
}

Measured memory_bytes: 256
gets
sticks = gets.chomp.split(" ").map!(&:to_i).sort!.reverse!

h = Hash.new(0)
first = nil
second = nil

sticks.each do |length|
  h[length] += 1
  if h[length] == 2 and first.nil?
    first = length.to_i
  elsif h[length] == 2 and second.nil?
    second = length.to_i
  end

  if h[length] == 4 and second.nil?
    second = length.to_i
  end

  break if first and second
end

print (first and second) ? first * second : 0

Measured memory_bytes: 14320
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
using namespace std;

int main() {
    char s[100];
    rep(i, 100) s[i] = '\0';
    scanf("%s", s);
    int count = 0;
    while (s[count] != '\0') {
        count++;
    }
    int sublen = (count - 1) / 2;
    char a[sublen], b[sublen];
    rep(i, sublen) {
        a[i] = s[i];
        b[i] = s[count - 1 - i];
    }
    rep(i, sublen) {
        if (a[i] != b[i]) {
            printNo();
            return 0;
        }
    }
    rep(i, sublen/ 2) {
        if (a[i] != a[sublen- 1 - i] ||
            b[i] != b[sublen -1 - i]) {
            printNo();
            return 0;
        }
    }
    printYes();
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>

using namespace std;

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

    unordered_map<int, vector<int>> CG;

    for (int i = 1; i <= 10; i++) {
        CG[i].push_back(0);
    }

    for (int i = 0; i < N; i++) {
        int C, G;
        cin >> C >> G;
        CG[G].push_back(C);
    }

    for (int i = 1; i <= 10; i++) {
        sort(CG[i].begin() + 1, CG[i].end(), greater<>());
        for (int j = 1; j < CG[i].size(); j++) {
            CG[i][j] += CG[i][j - 1] + (j - 1) * 2;
        }
    }

    int dp[11][K + 1];
    fill(dp[0], dp[10] + K + 1, 0);

    for (int i = 1; i <= 10; i++) {
        for (int j = 0; j < CG[i].size(); j++) {
            for (int k = j; k <= K; k++) {
                dp[i][k] = max(dp[i][k], dp[i - 1][k - j] + CG[i][j]);
            }
        }
    }

    cout << dp[10][K] << endl;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  int S;
  cin >>S;
  vector<int> judge(100000,0);
  judge[S]++;
  int ans=1;
  while(1){
    ans++;
  if(S%2==0){
  S/=2;
    judge[S]++;
  }
  else{
  S=3*S+1;
    judge[S]++;
  }
  
    if(judge[S]==2){
    cout << ans << endl;
      return 0;
    }
  
  }
}

Measured memory_bytes: 640
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i*i<=n;i++){
        ll k=n-i;
        if(k%i!=0 || k/i<=i){continue;}
        k/=i;
        if(n/k==i && n%k==i){ans+=k;}
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
a = [input() for _ in range(h)]
dp = [[0 for _ in range(w)]for __ in range(h)]
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        if i == 0 and j == 0: continue
        if a[i][j] == '#':continue
        if i == 0:
            dp[i][j] = dp[i][j-1]
        elif j == 0:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = dp[i-1][j] + dp[i][j-1]
            dp[i][j] %= 1000000007
print(dp[h-1][w-1])

Measured memory_bytes: 54108
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        boolean[] ary = new boolean[102];
        for(int i=0; i<n; i++){
            int temp = sc.nextInt();
            ary[temp] = true;
        }
        int i = 0;
        while(true){
            if(x-i >= 0 && !ary[x-i]){
                System.out.println(x-i);
                break;
            }
            if(x + i < 102 && !ary[x+i]){
                System.out.println((x+i));
                break;
            }
            i++;
        }
    }
}

Measured memory_bytes: 35836
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = Integer.MAX_VALUE;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            if(p <= min){
                ans++;
                min = p;
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 62700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int x = Integer.parseInt(str[0]);
            int a = Integer.parseInt(str[1]);
            int b = Integer.parseInt(str[2]);
            if (Math.abs(x - a) < Math.abs(x - b)) {
                System.out.println("A");
            } else {
                System.out.println("B");
            }
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int m, n; cin >> m >> n;
  vector<lint> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  vector<lint> c(n);
  vector<lint> e(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i] >> e[i];
  }

  vector<vector<lint>> dp(n + 1, vector<lint> (m + 1, INF));
  dp[0][0] = 0; 

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= m; j++) {
      if (dp[i][j] == INF) continue;
      
      // not
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);

      // take
      lint nCap = min(j + c[i], (lint)m);
      dp[i + 1][nCap] = min(dp[i + 1][nCap], dp[i][j] + e[i]);
    }
  }

  sort(RALL(p));
  vector<lint> acc(m + 1, 0);
  for (int i = 1; i <= m; i++) {
    acc[i] = p[i - 1];
    acc[i] += acc[i - 1];
  }

  lint ans = 0;
  // 饅頭 i こ販売
  
  for (int i = 1; i <= m; i++) {
    lint cost = dp[n][i];
    lint score = acc[i];
    ans = max(ans, score - cost);
  }

  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 42224
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    String   in_number_str;
    int      in_number;
    String   board_str;
    String[] board_split;
    int[]    board;

    int     cnt;
    boolean is_end;
    int     ans;

    try
    {
      in_stream    = new BufferedReader(new InputStreamReader(System.in));
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");


      in_number_str = in_str_split[0];
      in_number     = Integer.parseInt(in_number_str);

      board_str   = new String(in_stream.readLine());
      board_split = board_str.split(" ");


      board = new int[in_number];
      for(cnt=0; cnt<in_number; cnt++)
      {
        board[cnt] = Integer.parseInt(board_split[cnt]);
      }


      is_end = false;
      ans    = -1;
      while(!is_end)
      {
        ans++;
        for(cnt=0; cnt<in_number; cnt++)
        {
          if(0 == (board[cnt] % 2))
          {
            board[cnt] = board[cnt] / 2;
          }
          else
          {
            is_end = true;
            break;
          }
        }
      }

      UtilLog.ans_ln("" + ans);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}

class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

ll lr[501][501];
ll sum[501][501];

int main( void )
{
	ll n, m, q;
	cin >> n >> m >> q;

	rep( i, m ) {
		ll l, r;
		cin >> l >> r;
		lr[l][r]++;
	}

	reps( i, n ) {
		reps( j, n ) {
			sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + lr[i][j];
		}
	}

	ll ans[q] = {};
	rep( i, q ) {
		ll a, b;
		cin >> a >> b;

		ans[i] = sum[b][b] + sum[a - 1][a - 1] - sum[a - 1][b] - sum[b][a - 1];
	}

	rep( i, q ) {
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 5632
#include <algorithm>
#include <iostream>
#include <iterator>
#include <limits>
#include <sstream>
#include <vector>

using namespace std;
int main() {
  cin.ignore(numeric_limits<streamsize>::max(), '\n');
  string s;
  getline(cin, s);
  istringstream is{s};
  istream_iterator<int> ii{is}, eol;
  vector<int> v{ii, eol};
  cin.ignore(numeric_limits<streamsize>::max(), '\n');

  int b, e;
  while (cin >> b >> e) {
    reverse(v.begin() + b, v.begin() + e);
  }
  cout << v[0];
  for (auto it = ++v.begin(); it != v.end(); ++it)
    cout << " " << *it;
  cout << endl;
}


Measured memory_bytes: 3212
n = int(input())

counter = [0]*1000000
counter[n-1] += 1

m = 1

while True:
  if n % 2 == 0:
    n = n//2
    counter[n-1] += 1
    if counter[n-1] == 2:
      break
  else:
    n = 3 * n + 1
    counter[n-1] += 1
    if counter[n-1] == 2:
      break
  m += 1
  
print(m+1)

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

int main() {
  int N,K;
  cin>>N>>K;
  
  int a[60];
  for(int i=0;i<N;++i){
    cin>>a[i];
  }
  
  sort(a,a+N,greater<int>());
  
  int max=0;
  for(int i=0;i<K;++i){
    max=max+a[i];
  }
  
  cout<<max<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int dp[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
  cin >> k;
  cout<<dp[k-1];
}

Measured memory_bytes: 256
def main():
    char = input()
    count = 0
    chars_set = set()
    for c in char:
        if c not in chars_set:
            chars_set.add(c)
    if len(chars_set) > 1:
        print("Yes")
        return
    print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
def main():
    S = input()
    len_s = len(S)
    ans = 0
    for i in range(2**(len_s - 1)):
        begin = 0
        remain = i
        l = []
        for j in range(len_s):
            if (remain >> j) % 2 == 1:
                l.append(int(S[begin:j + 1]))
                begin = j + 1
        l.append(int(S[begin:len_s]))
        ans += sum(l)
    print(ans)

if __name__ == '__main__':
    main()


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

#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long

int main(){
  LL k,s;
  LL a=0,b=0,c=0;
  cin>>k>>s;
  for(LL i=0;i<=k;i++){
    if(s-i>2*k || s-i<0) continue;
    for(LL j=i;j<=k;j++){
      if(s-i-j>k || s-i-j<0) continue;
      for(LL m=j;m<=k;m++){
	if(i+j+m==s){
	  if(i==j&&j==m){
	    c++;
	  }else if(i==j || j==m || m==i){
	    b++;
	  }else{
	    a++;
	  }
	}
      }
    }
  }
      
  cout<< 6*a + 3*b + c <<endl;

  return 0;
}


Measured memory_bytes: 256
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;
typedef long double ld ;

#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define sg(a, b) (a + b - 1) / b

const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 8 * 1000 * 1000 + 200;
const int MAXN = 4 * 1000 * 100 + 20;
const int MLOG = 18;
const int NMAX = 20;

signed main(){
	IO;
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	bool p = true;
	if(n % 2){
		for(int i = 0; i < n; i++){
			if(a[i] != (i + 1) / 2 * 2) p = false;
		}
	}else{
		for(int i = 0; i < n; i++){
			if(a[i] != i / 2 * 2 + 1) p = false;
		}
	}
	int x = p;
	for(int i = 0; i < n / 2; i++) x *= 2, x %= MOD;
	cout << x;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int N;

int main() {
  while (cin >> N, N) {
    int temp, lb = -1, prev = -1;
    bool flag = false;
    rep(i,N) {
      cin >> temp;
      if (prev + 1 == temp) {
        prev = temp;
      } else {
        if (lb != -1) {
          if (flag) putchar(' ');
          if (lb == prev) { printf("%d",lb); }
          else { printf("%d-%d",lb,prev); }
          flag = true;          
        }
        lb = prev = temp;
      }
    }
    if (flag) putchar(' ');
    if (lb == prev) { printf("%d",lb); }
    else { printf("%d-%d",lb,prev); }
      
    puts("");
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N; cin >> N;
	vector <vector <P> > vec( N, vector <P>());
	rep( i, 0, N ){
		int a; cin >> a;
		rep( j, 0, a ){
			int x, y; cin >> x >> y;
			vec[ i ].push_back( P( x - 1, y ));
		}
	}
	int lim = pow( 2, N );
	int maximum = 0;
	rep( i, 1, lim ){
		vector <bool> people( N );
		int cnt = 0;
		rep( bit, 0, N ){
			if (i & ( 1 << bit )){
				people[ bit ] = true;
				cnt++;
			}
			else
				people[ bit ] = false;
		}
		bool is_correct = true;
		rep( bit, 0, N )
		if (i & ( 1 << bit ))
			for(auto v: vec[ bit ])
				if (people[ v.first ] !=  v.second )
					is_correct = false;
		if (is_correct){
			maximum = max( maximum, cnt );
		}
	}
	cout << maximum << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

int main() {
  char c;
  cin >> c;

  cout << (char)(1 + c) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int a[1000010];
int b[1000010];
int c[1000010];
bool flg[1000010];
int main(){
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	// for(int i=1;i<=n;i++){
	// 	int x=a[i],j=2;
	// 	int flg=1;
	// 	memset(c,0,sizeof c);
	// 	vector<int>cur;
	// 	while(x>1){
	// 		if(x%j==0){
	// 			if(b[j])flg=0;
	// 			x/=j;
	// 			cur.pb(j);
	// 		}else j++;
	// 	}
	// 	for(auto x:cur)b[x]++;
	// 	if(a[i]!=a[i-1]&&a[i]!=a[i+1])ans+=flg;
	// }
	// cout<<ans<<endl;
	for(int i=1;i<=n;i++){
		int x=a[i];
		if(!flg[x]&&a[i]!=a[i-1]&&a[i]!=a[i+1])ans++;
		if(!flg[x])for(int j=1;x*j<=1000000;j++)flg[x*j]=1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4920
#!/usr/bin/env python3
import sys
import math
INF = float("inf")


def solve(N: int):
    m, div = 1, 0
    for i in range(1, N+1):
        b = int(math.log2(i & -i))
        if b > div:
            m = i
            div = b
    print(m)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;

int main() {
    int k,a,b; cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b + c || b == a + c || c == b + a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3588
n = int(input())
s = list(input() for _ in range(n))
m = int(input())
t = list(input() for _ in range(m))
ans = 0

for i in range(n):
    if(s.count(s[i])-t.count(s[i]) > ans):
        ans = s.count(s[i])-t.count(s[i])
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define lnt long long int
int main()
{
   lnt n,d;
   cin>>n>>d;
   vector<vector<double> > v;
   for(int i=0;i<n;i++)
   {
       vector<double> v1;
       for(int j=0;j<d;j++)
       {

           double a;
           cin>>a;
           v1.push_back(a);
       }
       v.push_back(v1);
   }
   lnt ans=0;
   for(int i=0;i<n;i++)
   {

       for(int j=i+1;j<n;j++)
       {
           double dis=0;
           for(int k=0;k<d;k++)
           {
               dis += ((v[i][k]-v[j][k])*(v[i][k]-v[j][k]));

           }
           double dis1 = sqrt(dis);
           //cout<<i<<" "<<j<<" "<<dis<<" "<<dis1<<endl;
           if(ceil(dis1)==dis1)
           {

               ans++;
           }

       }
   }
   cout<<ans;



}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

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

  int H, A;
  cin >> H >> A;
  cout << (H + A - 1) / A << endl;

  return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
square = [list(map(int, input().split())) for i in range(H)]

dp = [[0 for i in range(W)] for j in range(H)]
max_width = 0
for i in range(H):
  for j in range(W):
    if square[i][j] == 1:
      continue
    if i-1 < 0 and j-1 < 0:
      dp[i][j] = 1
    elif i-1 < 0 or j-1 < 0:
      dp[i][j] = 1
    else:
      dp[i][j] = min(dp[i-1][j], dp[i-1][j-1], dp[i][j-1]) + 1

    max_width = max(max_width, dp[i][j])

print(max_width**2)



Measured memory_bytes: 55816
N,K = map(int,input().split())
A = list(map(int,input().split()))

for _ in range(K):
    imos = [0] * (N+1)
    for i,a in enumerate(A):
        l = max(0, i-a)
        r = min(N, i+a+1)
        imos[l] += 1
        imos[r] -= 1
    for i in range(N):
        imos[i+1] += imos[i]
    imos.pop()
    A = imos
    if all(a==N for a in A): break
print(*A)

Measured memory_bytes: 162220
def tc():
    n = int(input())
    a = list(map(int, input().split()))

    ans = 0
    for i in range(1, n):
        if a[i] < a[i - 1]:
            ans += a[i - 1] - a[i]
            a[i] = a[i - 1]

    print(ans)


tc()


Measured memory_bytes: 94068
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>


using namespace std;



int main() {

	string S;
	map<char, int> count;

	for (char i = 'a'; i <= 'z'; i++) {
		count[i] = 0;
	}

	cin >> S;

	for (int i = 0; i < S.size(); i++) {
		count[S[i]]++;
	}

	for (char i = 'a'; i <= 'z'; i++) {
		if (count[i] % 2 == 1) {
			cout << "No";
			goto end;
		}
	}

	cout << "Yes";

	end:


	return 0;

}

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

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<pair<ll, ll>> ans;

  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());

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

  ans.push_back({a[n - 1], a[0]});
  cout << a[n - 1] - a[0] << endl;
  for (auto b : ans) printf("%d %d\n", b.first, b.second);
  return 0;
}

Measured memory_bytes: 6116
#!/usr/bin/env python3

S = input()

if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
elif S == "SAT":
    print(1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define N 100
using namespace std;
int n,a[N],c[N],ans=0;
int main(){
	int i,x;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<n;i++)
	{
		cin>>x;
		ans+=x;
	}
	for(i=1;i<n;i++)
	{
		cin>>x;
		c[i]=x;
	}
	for(i=1;i<n;i++)
	{
		if(a[i]==a[i-1]+1)
		{
			ans+=c[a[i]-1];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int x,y,a,b;
	int xx,yy,aa,bb;
	int o,p;
	int i;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x>>y>>a>>b;
		if(a>=5&&b>=2){
			x*=0.8;
			y*=0.8;
			cout<<x*a+y*b<<endl;
		}
		else{
			o=x*a+y*b;
			x*=0.8;
			y*=0.8;
			if(a<5)	a+=5-a;
			if(b<2)	b+=2-b;
			p=x*a+y*b;
			//cout<<o<<" "<<p<<endl;
			cout<<min(o,p)<<endl;
		}
	}
			
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n,q;
  string s;
  vl l,r;
  cin >> n >> q >> s;
  
  rep(i,q){
    ll x,y;
    cin >> x >> y;
    l.push_back(x);
    r.push_back(y);
  }
  vl count(n,0);
  rep(i,n-1){
    if(s[i] == 'A' && s[i+1] == 'C'){
      count[i+1] = count[i]+1;
    } else {
      count[i+1] = count[i];
    }
  }
  rep(i,q){
    cout << count[r[i]-1] - count[l[i]-1] << endl;
  }
  
 return 0;
}

Measured memory_bytes: 3564
import collections

mod = 10**9+7 

def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

N = int(input())
#print(prime_factor(N))
ans = [0] * (N+1)
for i in range(2,N+1):
    L = collections.Counter(prime_factor(i))
    values,counts = zip(*L.most_common())
    for v in values:
        ans[v] += L[v]
A = 1
for i in ans:
    A *= (i+1)
    A %= mod
print(A)

Measured memory_bytes: 44136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;



int main() {
  int n;
  cin >> n;
  vector<int> a(n+1),b(0),c(n+1,0);
  for (int i=1;i<n+1;i++) cin >> a.at(i);
  for (int i=n;i>0;i--){
    int t=0;
    for (int j=2;j<n+10;j++){
      if (i*j>=n+1) break;
      if (c.at(i*j)==1) t=1-t;
    }
    if (a.at(i)!=t){
      b.push_back(i);
      c.at(i)=1;
    }
  }
  cout << b.size() << endl;
    if (b.size()==0) return 0;
  rep(i,b.size()-1){
    cout << b.at(i) << " ";
  }
  cout << b.at(b.size()-1) << endl;
  }

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

#define loop(i,n) for(int i=0;i<n;i++)
bool a[10][10000];

signed main() {
  int r,c;
  while(cin>>r>>c,r){
    loop(i,r)loop(j,c)cin>>a[i][j];
    int p=1<<r;
    int m=0;
    while(p--){
      int s=0;
      loop(j,c){
        int n=0;
        loop(i,r){
          n+=a[i][j]^((p>>i)&1);
        }
        s+=max(n,r-n);
      }
      m=max(m,s);
    }
    cout<<m<<endl;
  }
  return 0;
}

Measured memory_bytes: 3196
N=int(input())
U=0
a=0
b=0
c=0
for i in range(0,N+1):
  U+=i
for i in range(0,N+1,3):
  a+=i
for i in range(0,N+1,5):
  b+=i
for i in range(0,N+1,15):
  c+=i
S=U-a-b+c
print(S)

Measured memory_bytes: 9196
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
#include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)   (x).begin(),(x).end()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define mp       make_pair
#define eb       emplace_back
typedef pair<LL, LL> P;
typedef pair<P, P> PP;


int main() {
	int n;
	map<int,int> m;
	int a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		m[a] = (m[a] + 1) % 2;
	}
	int ans = 0;
	for (auto i = m.begin(); i != m.end();i++) {
		if (i->second == 1)ans++;
	}
	cout << ans << endl;

}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, K;
int main(){
    scanf("%lld%lld", &N,&K);
    if(K==1)
        printf("0");
    else 
        printf("%lld", N - K);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define mod 1000000007 
#define rep(i,j,l) for(int i=j;i<=l;i++)
#define dec(i,j,l) for(int i=j;i>=l;i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull; 
int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};


int main() {                                     
 int k;
 cin>>k;
 cout<<arr[k-1];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m;
    cin>>m>>n;
    char arr[m+1][n+1];    
    for(int i=0;i<m;i++){
     for(int j=0;j<n;j++){
         cin>>arr[i][j];
     }
    }

   int dp[m+1][n+1];
   dp[0][0]=1;
   for(int i=1;i<n;i++){
       if(arr[0][i]=='#'){
       dp[0][i]=-1;
       }
       else{
           dp[0][i]=dp[0][i-1];
       }
   } 

   for(int i=1;i<m;i++){
       if(arr[i][0]=='#'){
       dp[i][0]=-1;
       }
       else{
           dp[i][0]=dp[i-1][0];
       }
   }
  int mod=1e9+7;
   for(int i=1;i<m;i++){
       for(int j=1;j<n;j++){
            if(arr[i][j]=='.'){
                if(dp[i][j-1]==-1&&dp[i-1][j]==-1){
                    dp[i][j]=0;
                }
                else if(dp[i][j-1]==-1){
                    dp[i][j]=dp[i-1][j];
                }
                else if(dp[i-1][j]==-1){
                    dp[i][j]=dp[i][j-1];
                }
                else{
                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
                }
            }
            else{
                dp[i][j]=-1;
            }
       }
   }

      

   cout<<dp[m-1][n-1];

}


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

int main()
{
	int A[100][100], B[100][100];
	long long C[100][100];
	int n, m, l;

	cin >> n >> m >> l;
	for (int x = 0; x < n; x++)
	{
		for (int y = 0; y < m; y++)
		{
			cin >> A[x][y];
		}
	}
	for (int x = 0; x < m; x++)
	{
		for (int y = 0; y < l; y++)
		{
			cin >> B[x][y];
		}
	}
	for (int x = 0; x < n; x++)
	{
		for (int y = 0; y < l; y++)
		{
			C[x][y] = 0;
		}
	}
	for (int x = 0; x < n; x++)
	{
		for (int y = 0; y < l; y++)
		{
			for (int z = 0; z < m; z++)
			{
				C[x][y] += A[x][z] * B[z][y];
			}
		}
	}
	for (int x = 0; x < n; x++)
	{
		for (int y = 0; y < l; y++)
		{
			if(y!=l-1) cout << C[x][y] << " ";
			if (y == l - 1) cout<<C[x][y] << endl;
		}
	}
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin>>s;
    cout<<count(ALL(s),'1')<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    vector<int> vote(n, 0);
    while(-- m >= 0){
        int x;
        cin >> x;
        int i = 0;
        while(x < a[i])
            ++ i;
        ++ vote[i];
    }

    int ret = max_element(vote.begin(), vote.end()) - vote.begin() + 1;
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1200