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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);
const ll MOD = (ll)(1e9 + 7);

/////////////////////////////////////////////////////////////
class ModuloOperator {
 public:
  ll modulo;

  ModuloOperator(ll modulo) {
    this->modulo = modulo;
  }

  ll add(ll a, ll b) {
    ll ret = a + b;
    ret %= modulo;
    return ret;
  }

  ll sub(ll a, ll b) {
    ll ret = a - b;
    if (ret < 0)
      ret += modulo;
    else
      ret %= modulo;
    return ret;
  }

  ll mul(ll a, ll b) {
    ll ret = a * b;
    ret %= modulo;
    return ret;
  }

  ll div(ll a, ll b) { return mul(a, pow(b, modulo - 2)); }

  ll pow(ll x, ll y) {
    ll res = 1LL;

    x %= modulo;

    while (y > 0) {
      if (y & 1) {
        res = mul(res, x);
      }

      y = y >> 1;
      x = mul(x, x);
    }

    return res;
  }
};
/////////////////////////////////////////////////////////////

string s;

int n;
ll cnt_a[MAX_N];
ll cnt_c[MAX_N];
ll cnt_q[MAX_N];

ModuloOperator mo(MOD);

ll ans;

int main(void) {
  // Here your code !
  cin >> s;

  n = s.size();

  for (int i = 1; i <= n; ++i) {
    if (s[i - 1] == 'A') cnt_a[i] = 1LL;
    if (s[i - 1] == 'C') cnt_c[i] = 1LL;
    if (s[i - 1] == '?') cnt_q[i] = 1LL;
  }

  for (int i = 1; i <= n; ++i) {
    cnt_a[i] += cnt_a[i - 1];
    cnt_c[i] += cnt_c[i - 1];
    cnt_q[i] += cnt_q[i - 1];
  }


  // for (int i = 0; i <= n; ++i) {
  //   printf("%lld ", cnt_a[i]);
  // }
  // printf("\n");


  // for (int i = 0; i <= n; ++i) {
  //   printf("%lld ", cnt_c[i]);
  // }
  // printf("\n");


  // for (int i = 0; i <= n; ++i) {
  //   printf("%lld ", cnt_q[i]);
  // }
  // printf("\n");


  ans = 0LL;

  for (int i = 2; i < n; ++i) {
    int ind = i - 1;
    if (s[ind] == 'A' || s[ind] == 'C') continue;

    ll left_a = cnt_a[i - 1];
    ll right_c = cnt_c[n] - cnt_c[i];
    ll left_q = cnt_q[i - 1];
    ll right_q = cnt_q[n] - cnt_q[i];

    ll tmp_left= 0LL;
    tmp_left += mo.mul(left_a, mo.pow(3LL, left_q));
    tmp_left += mo.mul(left_q, mo.pow(3LL, max(left_q - 1LL, 0LL)));

    ll tmp_right = 0LL;
    tmp_right += mo.mul(right_c, mo.pow(3LL, right_q));
    tmp_right += mo.mul(right_q, mo.pow(3LL, max(right_q - 1LL, 0LL)));

    ans = mo.add(ans, mo.mul(tmp_left, tmp_right));
  }

  printf("%lld\n", ans);

  return 0;
}


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

prev = A[0]
isUp = True
isDown = True

ans = 0
for a in A[1:]:
  if prev == a:
    pass
  elif prev < a:
    isDown = False
    if not isUp:
      isUp = True
      isDown = True
      ans += 1
  elif a < prev:
    isUp = False
    if not isDown:
      isUp = True
      isDown = True
      ans += 1
      
  prev = a
  
print(ans+1)

  
  


Measured memory_bytes: 14224
#include <stdio.h>

int m, n;
int sq, ttry;
int max;

void kan()
{
    max = 0;
    for (n = 0; n * n * n <= m; n++)
    {
        sq = n * n * n;
        for (int i = 0; sq + i * (i - 1) * (i - 2) / 6 <= m; i++)
        {
            ttry = i * (i - 1) * (i - 2) / 6;
            if (max < sq + ttry)
            {
                max = sq + ttry;
            }
        }
    }
    printf("%d\n", max);
}

int main()
{
    for (;;)
    {
        scanf("%d", &m);
        if (m == 0)
            return 0;
        kan();
    }
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// trueで初期化した配列pが必要です 遅め
vector<bool> p(1000010, true);
void eratos(int n) {
  p[0] = p[1] = false;
  for (int i = 2; i <= sqrt(n); i++)
    if (p[i])
      for (int j = i * 2; j < n; j += i) p[j] = false;
}

// ====================================================================

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

  eratos(1000000);

  for (int i = 0; i < 1000000; i++) {
    if (p[i] == true && x <= i) {
      cout << i << endl;
      return 0;
    }
  }
}


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

int main() {
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	long long f[n];
	f[0]=0;
	for(int i=1;i<=min(n,k);i++) f[i]=abs(a[i]-a[0]);
	//for(int i=0;i<=k;i++) cout<<f[i]<<" ";
	//cout<<endl;
	for(int i=k+1;i<n;i++){
		f[i]=f[i-1]+abs(a[i]-a[i-1]);
		for(int j=2;j<=k;j++) f[i]=min(f[i-j]+abs(a[i]-a[i-j]),f[i]);
	}
	cout<<f[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int cnt = 0;
		n = n - k;
		cnt++;
		if (n % (k - 1) == 0) {
		}else {
			cnt++;
		}
		n = n / (k - 1);
		cnt += n;
		System.out.println(cnt);
	}
}

Measured memory_bytes: 50724
x = input()
a = {}
a = [int(i) for i in x.split()]

y = {1, 2, 3}

c = y.difference(a)
a = list(a)

mult = a[0] * a[1]
c = list(c)[0]
flag = False
for i in y:
    if (mult * i) % 2:
        flag = True
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

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


int main(){
    string t; cin >> t;
    rep(i, t.size()){
        if (t[i] == '?') cout << 'D';
        else cout << t[i];
    }
    cout << "\n";
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    int n = (int)s.size();
    auto fir = s.substr(0,n/2);
    auto sec = s.substr((n+2)/2);
    auto frev = fir;
    auto srev = sec;
    reverse(frev.begin(),frev.end());
    reverse(srev.begin(),srev.end());
    if( fir == frev and srev == sec and fir == sec){
        cout << "Yes" << endl;
    }else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            var prediction = Console.ReadLine();
            var real = Console.ReadLine();
            var count = 0;

            for(var i = 0; i < 3; i++)
            {
                if(prediction[i] == real[i])
                {
                    count += 1;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>

void swap(int *a, int *b);

int main(void)
{
    int i, j, n;
    int count = 0;
    int data[100];
    int flag;

    scanf("%d", &n);

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

    flag = 1;

    for (i = 0; flag; i++) {
        flag = 0;
        for (j = n - 1; j > i; j--) {
            if (data[j - 1] > data[j]) {
                swap(&data[j - 1], &data[j]);
                count++;
                flag = 1;
            }
        }
    }
    for (i = 0; i < n; i++) {
        printf("%d", data[i]);
        if (i < n - 1) printf(" ");
    }
    printf("\n");
    printf("%d\n", count);

    return 0;
}

void swap(int *a, int * b)
{
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

void bubble_sort(int data[], int n)
{

}



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

using namespace std;

using ll=long long;
constexpr ll MOD=1e9+7;

ll kai(int n){
	ll res=1;
	for(int i=2;i<=n;++i){
		res*=i;
		res%=MOD;
	}
	return res;
}

int main(){
	int n,m;
	cin>>n>>m;
	if(abs(n-m)>1){
		cout<<"0"<<endl;
	}else if(abs(n-m)){
		int mx=max(n,m);
		int mi=min(n,m);
		ll ans=kai(mx)%MOD;
		ans*=kai(mi);
		ans%=MOD;
		cout<<ans<<endl;
	}else{
		ll ans=kai(n)%MOD;
		ans*=kai(n);
		ans%=MOD;
		ans*=2;
		ans%=MOD;
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int K = keyboard.nextInt();
		int S = keyboard.nextInt();
		int ans =0;
		
		for(int i = 0; i<=K; i++) {
			for(int j =0; j<=K; j++) {
				if(0 <= S-(i+j) && S-(i+j)<= K) {
					ans++;
				}
			}
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
}


Measured memory_bytes: 21716
//


#pragma GCC optimize ("O3")


#pragma GCC optimize("Ofast")

/* 
   *********************************************************
    Code_Blooded Human == @{{ samrat_12   [  0_0  ^_^  ] }}
   *********************************************************
*/
#include <bits/stdc++.h>
#include<algorithm>
#include<queue>
#include<list>
#include<map>
#include <math.h>
#include<numeric>
using namespace std;
#define endl '\n'
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ipfile    ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define pb(x) push_back(x)
#define int long long int
#define ull unsigned long long int
#define db long double
#define mod 1000000007
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define REVVEC(v) reverse(v.begin(),v.end())
#define REVARR(a) reverse(a,a+n)
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define inputarr(a,n) for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define outputarr(a,n) for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define rep(i,m, n)    for(int i = m; i < (n); ++i)
#define sp setprecison(10)

clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}

bool ispalin(string s)
{
    int len=s.length();
    for(int i=0;i<len/2;i++)
    {
        if(s[i]!=s[len-i-1])
        return false;
    }
    return true;
}

void Block()
{
    string s;
    cin>>s;
    int len=s.length(),cnt=0;
    if(ispalin(s))
    cout<<0<<endl;
    else{
        for(int i=0;i<len/2;i++)
        if(s[i]!=s[len-i-1])
            cnt++;
    
    cout<<cnt<<endl;}
}

signed main()
{
    FAST
    
    Block();
    time();
    return 0;
}

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

const ll maxs = 1e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){

}

const ll N = 2003;

ll dp[N][2*N];
bool vis[N][2*N];
pair<ll,ll> a[N];
ll n;

ll go(ll ind,ll i,ll j){
    if(ind >= n )
        return 0;
    ll& ans = dp[ind][i-1+j-1];
    if(vis[ind][i-1+j-1])
        return dp[ind][i-1+j-1];
    vis[ind][i-1+j-1] = true;
    ans = a[ind].ff*abs(i - a[ind].ss) + go(ind+1,i+1,j);
    ans = max( ans , a[ind].ff*abs(j - a[ind].ss) + go(ind+1,i,j-1) );
    return ans;
}

void solve(){ 
    cin >> n;
    for(ll i=0;i<n;i++){
        ll val;
        cin >> val;
        a[i].ff = val;
        a[i].ss = i;
    }
    sort(a,a+n);
    reverse(a,a+n);
    ll ans = go(0,0,n-1);
    cout << ans << endl;
}


int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;   
    //cin>>T;
    while(T--){  
        solve();
    }
    return 0;
}

Measured memory_bytes: 50368
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	long long N, M;
	cin >> N >> M;

	long long ans = 0;
	if(N == 1){
		if( M == 1){
			ans = 1;
		}
		else if(M == 2){
			ans = 0;
		}
		else{
			ans = M - 2;
		}
	}
	else if(N == 2){
		ans = 0;
	}
	else if(N > 2){
		if( M == 1 ){
			ans = N - 2;
		}
		else if(M == 2){
			ans = 0;
		}
		else{
			ans = (N - 2) * (M - 2);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
	int n, t;
	long long cnt = 0;
	long long ans = 0;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> a_t(n);
	vector<int> b_t(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	for(int i=0; i<n; i++){
		cin >> b[i];
	}

	int keta = 1;
	for(int i=0; i<29; i++){
		cnt = 0;
		for(int j=0; j<n; j++){
			a_t[j] = a[j]%(keta * 2);
			b_t[j] = b[j]%(keta * 2);
		}
		sort(b_t.begin(), b_t.end());
		for(int j=0; j<n; j++){
			cnt += lower_bound(b_t.begin(), b_t.end(), keta*2 - a_t[j]) - lower_bound(b_t.begin(), b_t.end(), keta - a_t[j]);
			cnt += b_t.end() - lower_bound(b_t.begin(), b_t.end(), keta*2 + keta - a_t[j]);
		}
		//cout << cnt << endl;
		if(cnt%2 == 1){
			ans += keta;
		}
		keta *= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
s = sorted(input())
# lowercase の ascii (a-z) 辞書を生成
dct = {chr(i):0 for i in range(97, 97+26)}
result = ''

for c in s:
    if c in dct:
        dct[c] += 1

for i in range(97, 97+26):
    c = chr(i)
    if c in dct and dct.get(c) == 0:
        result = c
        break

print(result if result != '' else 'None')

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

int main(){
    int n, m;
    scanf("%d", &n);
    scanf("%d", &m);

    int E[n][n], F[n][n];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j) E[i][j] = 0;
            else E[i][j] = 1e9;
        }
    }
    
    for(int i = 0; i < m; i++){
        int a, b, c, d;
        scanf("%d,%d,%d,%d", &a, &b, &c, &d);
        a--; b--;
        E[a][b] = c;
        E[b][a] = d;
    }

    int s, g, v, p;
    scanf("%d,%d,%d,%d", &s, &g, &v, &p);
    s--; g--;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                E[j][k] = min(E[j][k], E[j][i] + E[i][k]);
            }
        }
    }

    int t = 1e9;
    for(int i = 0; i < n; i++){
        t = min(t, E[s][g] + E[g][s]);
    }

    cout << v - p - t << endl;

    return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include<algorithm>
#define INF (1<<29)

using namespace std;

int main(void){

  vector<int>v;
  for(int i=1;i*(i+1)*(i+2)/6<1000000;i++)
    v.push_back(i*(i+1)*(i+2)/6);

  int dp1[1000001],dp2[1000001];
  fill(dp1,dp1+1000001,INF);
  fill(dp2,dp2+1000001,INF);
  
  dp1[0]=dp2[0]=0;

  for(int i=0;i<v.size();i++){
    for(int j=0;j<1000000;j++){
      if(j+v[i]<1000000){
	dp1[j+v[i]]=min(dp1[j+v[i]],dp1[j]+1);
	if(v[i]%2==1)dp2[j+v[i]]=min(dp2[j+v[i]],dp2[j]+1);
      }
    }
  }

  int n;
  while(cin >> n,n){
    cout << dp1[n] << " " << dp2[n] << endl;
  }
  
  return 0;
}

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

public class Main {

	static Scanner scanner;
	static long[][] dp;
    static int ind=1;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int n=gi();
	    int m=gi();
        boolean[] f=new boolean[n+1];
        int[] a=new int[m];
        dp=new long[2][n+1];
        dp[0][1]=1;
        dp[1][1]=1;
        f[0]=true;
        f[n]=true;

        for (int i=0; i<m;i++) {
            a[i]=gi();
            f[a[i]]=true;
            f[a[i]-1]=true;
            f[a[i]+1]=true;
            if(i!=0 && a[i]-a[i-1] == 1) {
            	System.out.println(0);
            	return;
            }
        }

        long c=0;
        List<Long> l = new ArrayList<Long>();
        for (int i=0; i<n+1;i++) {
            if(c!=0 && f[i]) {
            	l.add(c);
            	c=0;
            } else if(!f[i]) {
            	c++;
            }
        }

        long ans=1;
        for (int i=0; i<l.size();i++) {
        	long j=l.get(i);
        	ans = (ans*gv(j)) % 1000000007l;
        }

        System.out.println(ans);
	}

	public static long gv(long v) {
		if(ind>=v) {
			return (dp[0][(int)v]+dp[1][(int)v]) % 1000000007l;
		}

		for (int i=ind+1; i<=v; i++) {
			dp[0][i]=dp[1][i-1];
			dp[1][i]=(dp[0][i-1] +dp[1][i-1]) % 1000000007l;
		}
		ind=(int)v;
		return (dp[0][(int)v]+dp[1][(int)v]) % 1000000007l;
	}

	// a^nをmodで割ったあまり
	public static long modpow(long a, long n, long mod) {
		long res=1;
		while(n>0) {
			if((n & 1) == 1) res=res*a%mod;
			a=a*a%mod;
			n=n>>1;
		}

		return res;
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

int p[1000001];
int main(void){
    int a, d, n;
    p[0] = p[1] = -1;
    for(int i=2; i<=sqrt(1000000); ++i) {
        if(p[i] == 0) {
            for(int j=2; i*j<=1000000; ++j) {
                p[i*j] = -1;
            }
        }
    }
    while(cin >> a >> d >> n && a) {
        int cnt = 0;
        for(int i=a; ; i+=d) {
            if(p[i] == 0) cnt++;
            if(cnt==n) {
                cout << i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 5064
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>
#include <cfenv>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


ll pow5(ll x)
{
	return x * x * x * x * x;
}

int main()
{
	ll x;
	cin >> x;

	for (ll i = 1;  i < 200; i ++)
	{
		for (ll j = 0; j < 200; j++)
		{
			for (ll k = 0; k < 200; k++ )
			{
				if (pow5(j) - pow5(k - i) == x)
				{
					println(j << " " << k - i);
					return 0;
				}
			}
		}
	}
}


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

int main() {
	int n, l;

	cin >> n >> l;

	vector<int> vec;

	int ans = 0;

	for (int i = 0; i < n; i++) {
		ans += l + i;
		vec.push_back(l + i);
	}

	int minimum = abs(vec[0]-0);
	int idx = 0;

	for (int i = 1; i < n; i++) {
		if (abs(vec[i] - 0) < minimum) {
			idx = i;
			minimum = abs(vec[i] - 0);
		}
	}

	cout << ans - vec[idx] << endl;
}

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

int main() {
  int N, M; cin >> N >> M;
  bool p[N]; int n[N];
  for (int i = 0; i < N; i++) {
    p[i] = false; n[i] = 1;
  }
  p[0] = true;
  for (int i = 0; i < M; i++) {
    int x, y; cin >> x >> y; x--; y--;
    if (n[x] > 1 && p[x]) {
      p[y] = true; n[x]--; n[y]++;
    } else if (n[x] == 1 && p[x]) {
      p[x] = false; p[y] = true; n[x]--; n[y]++;
    } else {
      n[x]--; n[y]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (p[i]) {ans++;}
  }
  cout << ans << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int Mod=1e9+7;
const int MAX_N=200005;
int F[MAX_N];
int bin_pow(int a,int b)
{
	int ret=1;
	while(b>0)
	{
		if(b%2)ret=ret*a%Mod;
		a=a*a%Mod;
		b/=2;
	}
	return ret;
}
int inverse(int x)
{
	return bin_pow(x,Mod-2);
}
int C(int n,int m)
{
	return F[n]*inverse(F[m])%Mod*inverse(F[n-m])%Mod;
}
int calc(int x1,int y1,int x2,int y2)
{
	return C(x2-x1+y2-y1,x2-x1);
}
int x[MAX_N],y[MAX_N];
int dp[MAX_N];
int H,W,n;
void init()
{
	F[0]=1;
	for(int i=1;i<MAX_N;i++)F[i]=F[i-1]*i%Mod;
}
signed main()
{
	init();
	cin>>H>>W>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i];
	}
	x[n]=H;
	y[n]=W;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(x[j]>x[j+1] || x[j]==x[j+1] && y[j]>y[j+1])
			{
				swap(x[j],x[j+1]);
				swap(y[j],y[j+1]);
			}
		}
	}
	for(int i=0;i<=n;i++)
	{
		dp[i]=calc(1,1,x[i],y[i]);
		for(int j=0;j<i;j++)
		{
			if(x[j]<=x[i] && y[j]<=y[i])
			{
				dp[i]-=dp[j]*calc(x[j],y[j],x[i],y[i])%Mod;
				dp[i]=(dp[i]+Mod)%Mod;
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 4480
s = input()
ans = 0
if (s[0]=='R' and s[1]=='R') and s[2]=='R':
    ans = 3
elif (s[0]=='R' and s[1]=='R')or(s[1]=='R' and s[2]=='R'):
    ans = 2
if ans == 0:
    for i in range(3):
        if s[i]=='R':
            ans = 1
print(ans)


Measured memory_bytes: 9032
/****************************************

	LostMartian

****************************************/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for(ll i=m; i<n; i++)
#define repr(i,m,n) for(ll i=m; i>=n; i--)
#define vll vector<ll >
#define vvl vector<vector<ll > >
#define pi pair<ll, ll >
#define pb push_back
#define mk make_pair
#define sz size()
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define d(x) cout<<"Value of "#x" = "<<x<<"\n";
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define LOCAL #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
	clock_t z = clock();
	FAST
	//LOCAL
	string s1, s2;
	cin>>s1>>s2;
	ll c=0;
	rep(i,0,s1.length()) {
		if(s1[i]!=s2[i]) {
			c++;
		}
	}
	cout<<c<<"\n";

	debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}


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

void fnInput(int &rnElmCnt, vector<int> &rvnElm, int &rnTrgCnt , vector<int> &rvnTrg )
{
  cin >> rnElmCnt;

  rvnElm.resize(rnElmCnt);
  for (int i = 0; i < rnElmCnt; i++)
    cin >> rvnElm[i];

  cin >> rnTrgCnt;

  rvnTrg.resize(rnTrgCnt);
  for (int i = 0; i < rnTrgCnt; i++)
    cin >> rvnTrg[i];
}

int fnRcsSch(int nPos, int nTrg, const vector<int> &cnrvnElm, vector<vector<int>> &rvvnOK)
{
  if (!nTrg)                    return 1;
  if (nTrg < 0)                 return 0;
  if (nPos == cnrvnElm.size())  return 0;
  if (rvvnOK[nPos][nTrg] != -1) return rvvnOK[nPos][nTrg];

  int nRtn;
  nRtn = fnRcsSch(nPos + 1, nTrg, cnrvnElm, rvvnOK);
  rvvnOK[nPos + 1][nTrg] = nRtn;
  if (nRtn)  return nRtn;

  nRtn = fnRcsSch(nPos + 1, nTrg - cnrvnElm[nPos], cnrvnElm, rvvnOK);
  if (nTrg - cnrvnElm[nPos] >= 0)
    rvvnOK[nPos + 1][nTrg - cnrvnElm[nPos]] = nRtn;
  return nRtn;
}

void fnExhSch(const vector<int> &cnrvnElm, const vector<int> &cnrvnTrg)
{
  vector<vector<int>> vvnOK(21, vector<int>(2001, -1));
  
  for (int i = 0; i < cnrvnTrg.size(); i++)
  {
    int nTrg = cnrvnTrg[i];
    int nRtn;

    if (nRtn = fnRcsSch(0, nTrg, cnrvnElm, vvnOK))
      cout << "yes" << endl;
    else
      cout << "no" << endl;

    vvnOK[0][nTrg] = nRtn;
  }
}

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

  int nElmCnt, nTrgCnt;
  vector<int> vnElm, vnTrg;

  fnInput(nElmCnt, vnElm, nTrgCnt, vnTrg);
  fnExhSch(vnElm, vnTrg);

  return 0;
}

Measured memory_bytes: 1340
unittest
{
	assert( [ "3", "4980", "7980", "6980" ].parse.expand.solve == 15950 );
	assert( [ "4", "4320", "4320", "4320", "4320" ].parse.expand.solve == 15120 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	auto as = new long[ n ];
	foreach( ref a; as )
	{
		input.popFront;
		a = input.front.strip.to!( long );
	}
	return tuple( as );
}

auto solve( long[] as )
{
	return as.sum - as.reduce!( max ) / 2;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	if (k > n) k = n;
	vector<int> h(n);
	ll total = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		total += h[i];
	}
	sort(h.rbegin(), h.rend());
	for (int i = 0; i < k; i++) {
		total -= h[i];
	}
	
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys, math
from functools import lru_cache
from collections import defaultdict, Counter
import bisect
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    K, A, B = mi()

    if B <= A+2:
        print(K+1)
        return

    x = max(0, (K-(A-1))//2)
    y = K-2*x

    print((B-A)*x+y+1)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 9528
//朴素版dijkstra算法 
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;


int main()
{
//	freopen("input.txt","r",stdin);
	
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a) cout<<k;
	else if(k<=b+a) cout<<a;
	else cout<<2*a+b-k;
	
	return 0;
}














Measured memory_bytes: 3164
def main():
    N = int(input())
    S = input()
    h_left, h_min, h_cur = 0, 0, 0
    for c in S:
        if c == '(':
            h_cur += 1
        else:
            h_cur -= 1
        h_min = min(h_min, h_cur)
    h_right = h_cur
    if h_min < 0:
        h_left -= h_min
        h_right -= h_min
    print('(' * h_left + S + ')' * h_right)


if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<ll,int> li;
#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b,c) for(int i=a;i<b;i+=c)
#define REPN(i,a,b,c) for(int i=a;i<=b;i+=c)
#define reset(a,b) memset(a,b,sizeof(a))

int arr[2020];
int n;

int main(void) {
  std::ios::sync_with_stdio(false);

  cin >> n >> arr[0] >> arr[1];
  FOR(i,n) {
    cin >> arr[i + 2];
  }

  if(n == 1) {
    cout << abs(arr[1] - arr[2]);
  } else {
    cout << max(abs(arr[1] - arr[n + 1]), abs(arr[n] - arr[n + 1]));
  }

  cout << endl;



  return 0;
}


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

#define FASTIO1 ios_base::sync_with_stdio(false)
#define FASTIO2 cin.tie(NULL),cout.tie(NULL)
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll power(ll x,ll y,ll p);
const ll inf=999999999;
const ll mod=1e9+7;
bool tc=false;

unordered_map <ll,ll> freq;
bool div(ll n) 
{
    for(ll i=1;i<=sqrt(n);i++)
        if (n%i == 0) 
        {
            if(n/i==i) 
            {
            	if(freq.find(i)!=freq.end() && i!=1)
            		return true;
            	freq[i]++;
            }
            else
            {
            	if(freq.find(i)!=freq.end() && i!=1)
            		return true;
            	freq[i]++;
            	if(freq.find(n/i)!=freq.end() && n/i!=1)
            		return true;
            	freq[n/i]++;
            }
        }
    return false;
}

void solve()
{
	ll n; cin>>n;
	bool pairwise=true,setwise=true;
	ll oddc=0,evenc=0,primec=0,pc2=0,cur;
	for(ll i=0;i<n;i++)
	{
		cin>>cur;
		pc2=__gcd(pc2,cur);
		if(pairwise && div(cur)) pairwise=false;
	}
	if(pc2!=1) setwise=false;
	if(pairwise)
		cout<<"pairwise coprime";
	else if(setwise)
		cout<<"setwise coprime";
	else
		cout<<"not coprime";
}

int main() 
{
    FASTIO1;
    FASTIO2;
    clock_t start=clock();
    ll t=1; 
    if(tc) cin>>t;
    while(t--)
        solve();
    cerr<<fixed<<setprecision(6);
    cerr<<(double)(clock()-start)/CLOCKS_PER_SEC<<endl;
    return 0;
}

ll power(ll x,ll y,ll p)  
{  
    ll res=1; x=x%p;
    if(x==0) return 0;
    while(y>0)  
    {
        if(y&1) res=(res*x)%p;
        y=y>>1; x=(x*x)%p;  
    }
    return res;  
}  


Measured memory_bytes: 6852
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int solve() {
    int n; cin >> n;
    vector<int> nums(n);
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    int total = accumulate(nums.begin(), nums.end(), 0);
    int left{0},right{total};
    
    int res = right - left;
    for (int i = 0; i <n; ++i) {
        left += nums[i];
        right -= nums[i];
        res = min(res, abs(right - left));
    }

    return res;
}

int main() {
    cout << solve() << endl;
}

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

int main(){
    int n;
    cin >> n;
    if (n < 1200) cout << "ABC" << endl;
    else if (n < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;

}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N int
	fmt.Scan(&N)
	fmt.Println(f(N, "", true, true, true))
}

func f(N int, s string, r7, r5, r3 bool) int {
	n, _ := strconv.Atoi(s)
	if n > N {
		return 0
	}
	ret := 0
	if !r7 && !r5 && !r3 {
		ret++
	}
	ret += f(N, s+"7", false, r5, r3)
	ret += f(N, s+"5", r7, false, r3)
	ret += f(N, s+"3", r7, r5, false)
	return ret
}


Measured memory_bytes: 3108
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		scan.close();
		int max = 10 * A + B + C;
		max = Math.max(max, 10 * B + A + C);
		max = Math.max(max, 10 * C + A + B);
		System.out.println(max);
	}
}

Measured memory_bytes: 22612
from collections import Counter
n=int(input())
b=[tuple(map(int,input().split())) for _ in range(n)]
r=[(x[0]-y[0],x[1]-y[1]) for x in b for y in b if x!=y]
c=Counter(r).most_common(1)
print(n-c[0][1] if c else n)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    int even = 0;
    rep(i, n)
    {
        if (a[i] % 2 == 0)
        {
            even++;
        }
    }
    cout << (int)pow(3, n) - (int)pow(2, even) << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> buttons(n);

  for(int i = 0; i < n; i++) {
    cin >> buttons.at(i);
  }

  int curBtn = 1;
  int moves = -1;
  for(int i = 0; i < n; i++) {
    curBtn = buttons.at(curBtn - 1);
    if(curBtn == 2) {
      moves = i + 1;
      break;
    }
  }
  cout << moves << endl;
  return 0;
}

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

int  main()
{
	int a ,b, k;
	cin >> a >> b >> k;
	int i = min(a,b);
	int cnt = 0;
	while (i > 0)
	{
		if (a % i == 0 && b % i == 0)
			cnt++;
		if (cnt == k)
			break ;
		i--;
	}
	cout << i << endl;
	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vi t(n);
  string x;
  int ans = 0;
  rep(i,n){
    cin >> s[i] >> t[i];
    ans +=t[i];
  }
  cin >>x;
  rep(i,n){
    ans -=t[i];
    if(x  == s[i]) break;
  }
  cout<<ans<<endl;


  return 0;
}






















Measured memory_bytes: 256
n = int(input())
li = []
for a in range(1, n):
    b = n - a
    a_sum = sum([int(x) for x in str(a)])
    b_sum = sum([int(y) for y in str(b)])
    total_sum = a_sum + b_sum
    li.append(total_sum)
print(min(li))

Measured memory_bytes: 48216
def Minkowski(x,y,n,p):
    s = 0
    for i in range(n):
        s += abs(x[i] - y[i])**p
    
    D = s**(1/p)
    print("{:.9}".format(D))
    
    return D

def Minkowski_inf(x,y,n):
    ma = 0

    for i in range(n):
        m = abs(x[i]-y[i])
        if(ma < m):
            ma = m
    
    D = ma
    print("{}".format(D))

    return D


n = int(input())

    
x = [int(i) for i in input().split(" ")]
y = [int(i) for i in input().split(" ")]
    
Minkowski(x,y,n,1)
Minkowski(x,y,n,2)
Minkowski(x,y,n,3)
Minkowski_inf(x,y,n)



Measured memory_bytes: 5648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
vector<vector<int>> bb(4010, vector<int>(4010));
vector<vector<int>> ww(4010, vector<int>(4010));
vector<vector<int>> bacc(4010, vector<int>(4010));
vector<vector<int>> wacc(4010, vector<int>(4010));
// 累積和から指定した範囲の合計を取り出す
int bsum(int x1, int y1, int x2, int y2 ) {
    return bacc[y2][x2] - bacc[y2][x1] - bacc[y1][x2] + bacc[y1][x1];
}
int wsum(int x1, int y1, int x2, int y2 ) {
    return wacc[y2][x2] - wacc[y2][x1] - wacc[y1][x2] + wacc[y1][x1];
}
int main() {
    int n, k;
    cin >> n >> k;
    int K2 = k * 2;
    rep(i, n) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        x %= K2;
        y %= K2;
        if ( c == 'B' ) {
            bb[y][x]++;
            bb[y+K2][x]++;
            bb[y][x+K2]++;
            bb[y+K2][x+K2]++;
        }
        else {
            ww[y][x]++;
            ww[y+K2][x]++;
            ww[y][x+K2]++;
            ww[y+K2][x+K2]++;
        }
    }
    rep(y, K2*2) rep(x, K2*2) {
        bacc[y+1][x+1] += bb[y][x] + bacc[y+1][x] + bacc[y][x+1] - bacc[y][x];
        wacc[y+1][x+1] += ww[y][x] + wacc[y+1][x] + wacc[y][x+1] - wacc[y][x];
    }
    int ans = 0;
    rep(y1, K2) rep(x1, K2) {
        int x2 = x1 + k, y2 = y1 + k;
        int sum = bsum(x1, y1, x2, y2) + bsum(x2, y2, x2+k, y2+k);
        sum += wsum(x2, y1, x2+k, y2) + wsum(x1, y2, x2, y2+k);
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 252032
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
int aa[N+2],dp[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int a,b;cin>>a>>b;
  if(b==1)cout<<0<<endl,exit(0);

  int cnt=1;
  for(int i=1; ;i++)
  {
    cnt+=(a-1);
    if(cnt>=b)cout<<i<<endl,exit(0);
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;
const int INF = 1000000000;

int main(){
    int n, m;
    cin >> n >> m;
    int a[m];
    int c[m];
    fill(c, c + m, 0);
    rep(i, m){
        int b;
        cin >> a[i] >> b;
        rep(j, b){
            int d;
            cin >> d;
            d--;
            c[i] += (1 << d);
        }
    }

    int dp[m+1][1<<n];
    rep(i, m+1)rep(j, 1<<n) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, m){
        rep(j, 1<<n){
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][j|c[i]] = min(dp[i+1][j|c[i]],min(dp[i][j|c[i]], dp[i][j] + a[i]));
        }
    }
    // rep(i, m+1){
    //     rep(j, 1<<n){
    //         cout << dp[i][j] << " ";
    //     }cout << endl;   
    // }
    if(dp[m][(1<<n)-1] == INF){
        cout << -1 << endl;
    }else{
        cout << dp[m][(1<<n)-1] << endl;
    }
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a;
vector<int> v;

main() {
    rep(i,3) {
        cin >> a;
        v.pb(a)
    }
    sort(all(v));
    vdelete(v)
    ct(v.size())
}



Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<=n;i++)
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;


/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
string S;
cin >> S;
cout << S.front() << S.size()-2 << S.back() << endl;
}

Measured memory_bytes: 256
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define Yup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007
#include "bits/stdc++.h"
using namespace std;
#define int long long

int32_t main(){
    int n;
    cin >> n;
    int x[n], y[n];
    int pp[n], nn[n]; 
    for( int i = 0; i < n; i++ ){
        cin >> x[i] >> y[i];
        pp[i] = x[i]+y[i];
        nn[i] = x[i]-y[i];
    }
    sort(pp, pp+n);
    sort(nn, nn+n);
    cout << max(pp[n-1]-pp[0], nn[n-1]-nn[0]); 
}

Measured memory_bytes: 9816
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort()

res = 0
cnt = 0
for a, b in AB:
    tmp = M - cnt
    if tmp <= b:
        res += a * tmp
        break
    res += a * b
    cnt += b

print(res)


Measured memory_bytes: 16988
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mpr make_pair
#define MX 100010
#define ui unsigned int
#define ll long long
#define ld long double 
#define fi first
#define se second
#define endl '\n'
#define debug(bug) cout<<"akshat"<<" "<<bug<<endl
#define printarray(Aneveruse,neverusen) for(int neveruse=0;neveruse<neverusen;neveruse++) cout<<Aneveruse[neveruse]<<" "; cout<<endl
#define printvector(Aneveruse,neverusen) for(int neveruse=0;neveruse<neverusen;neveruse++) cout<<Aneveruse[neveruse]<<" "; cout<<endl
#define dd long double 
#define timetaken cerr<<clock()/double(CLOCKS_PER_SEC)<<endl
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL)
const ll inf=1000000000000;
const int mod=1000000007;
// priority_queue <int, vector<int>, greater<int> > pq; //minimum priority queue
int n;
ll A[MX][3];
ll dp[MX][3];
int main()
{
  fast_io;
  cin>>n;
  for(int i=0;i<n;i++)
  {
     cin>>A[i][0]>>A[i][1]>>A[i][2];
  }
  memset(dp,0,sizeof(dp));
  dp[0][0]=A[0][0];
  dp[0][1]=A[0][1];
  dp[0][2]=A[0][2];
  
  for(int i=1;i<n;i++)
  {
    for(int j=0;j<3;j++)
    {
      for(int k=0;k<3;k++)
      {
        if(j==k)
         continue;
        dp[i][j]=max(dp[i][j],dp[i-1][k]+A[i][j]);
      }
    }
  }

 // cout<<dp[1][1]<<endl;

  cout<<max(dp[n-1][1],max(dp[n-1][0],dp[n-1][2]))<<endl;

 
  return 0;
}


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

unsigned long long int ans;

int N;
vector<pair<long long int, pair<long long int, pair<long long int, long long int> > > > a;
int b[200002];
set<long long int> poi;

int main(){
    cin >> N;
    b[0] = 0;
    b[N + 1] = 0;
    for(int i = 0; i < N; i++){
        scanf("%d", b + i + 1);
        a.push_back(make_pair(b[i + 1], make_pair(i, make_pair(0, 0))));
    }
    poi.insert(-1);
    poi.insert(N);
    sort(a.begin(), a.end());
    //reverse(a.begin(), a.end());
    set<long long int>::iterator it, it2;
    int beg, edn;
    for(int i = 0; i < N; i++){
        int beg = 0, edn = 0;
        it = poi.insert(a[i].second.first).first;
        it2 = it;
        it++;
        it2--;
        beg = *it;
        edn = *it2;
        //cout << ans << " " << a[i].first << " " << a[i].second.first << " " << edn << " " << beg << endl;
        ans += (a[i].second.first - edn) * (beg - a[i].second.first) * a[i].first;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16744
#include<bits/stdc++.h>
main(){
long long ans;
int n,k,b;
std::cin>>n>>k;
for (b=k+1;b<=n;++b)ans+=(b-k)*(n/b+1)-std::min(b-k,b-n%b-1)-!k;
std::cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <tuple>
#include <cassert>

void solve() {
    int k, x, y;
    std::cin >> k >> x >> y;

    if (k % 2 == 0 && (x + y) % 2 != 0) {
        std::cout << -1 << std::endl;
        return;
    }

    bool xneg = false, yneg = false;
    if (x < 0) {
        xneg = true;
        x = -x;
    }
    if (y < 0) {
        yneg = true;
        y = -y;
    }

    std::vector<std::pair<int, int>> ans{{x, y}};
    while (x >= k) {
        x -= k;
        ans.emplace_back(x, y);
    }
    while (y >= k) {
        y -= k;
        ans.emplace_back(x, y);
    }
    if (ans.size() > 1 && x + y < k) {
        ans.pop_back();
        std::tie(x, y) = ans.back();
    }

    if (x + y != k) {
        bool iyneg = false;
        if ((x + y) % 2 == 1) {
            y -= k;
            ans.emplace_back(x, y);

            if (y < 0) {
                iyneg = true;
                y = -y;
            }
        }

        assert(x >= 0 && y >= 0 && x + y <= k * 2);

        int nx, ny;
        if (x >= y) {
            ny = -(k - (x + y) / 2);
            nx = k + ny;
        } else {
            nx = -(k - (x + y) / 2);
            ny = k + nx;
        }

        if (iyneg) ny = -ny;
        ans.emplace_back(nx, ny);
    }

    std::reverse(ans.begin(), ans.end());
    std::cout << ans.size() << std::endl;
    for (auto p : ans) {
        std::cout << p.first * (xneg ? -1 : 1) << " "
                  << p.second * (yneg ? -1 : 1) << std::endl;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 4464
fun main(args: Array<String>) {
    val s = readInputLine().toLong()
    
    val y2 = if (s % 1000000000L == 0L) s / 1000000000L else s / 1000000000L + 1L
    val x2 = 1000000000L * y2 - s
    
    println("0 0 1000000000 1 $x2 $y2")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 29952
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            m, n = map(int, raw_input().split())
            if m == 0 and n == 0:
                break
            board = [[None for j in range(m)] for i in range(n)]
            for i in range(n):
                line = map(int, raw_input().split())
                for j in range(len(line)):
                    board[i][j] = line[j]
            ans = 0
            for i in range(n):
                for j in range(m):
                    if board[i][j] == 1:
                        stack = [(i, j)]
                        d = [(0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1)]
                        ans += 1
                        while len(stack) != 0:
                            y, x = stack.pop()
                            board[y][x] = 2
                            for dy, dx in d:
                                if 0 <= y + dy < n and 0 <= x + dx < m and board[y+dy][x+dx] == 1:
                                    stack.append((y + dy, x + dx))
            print ans

        
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 5256
n=int(input())
if n==1:
    print(1)
elif n==2 or n==3:
    print(2)
elif 4<=n<=7:
    print(4)
elif 8<=n<=15:
    print(8)
elif 16<=n<=31:
    print(16)
elif 32<=n<=63:
    print(32)
else:
    print(64)

Measured memory_bytes: 3060