akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
//小さい順にソート
int c[50002];
void merge(int i,int j,int *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]<s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}

int main(){
  int i,n;
  scanf("%d",&n);
  int odd[n/2+1],even[n/2+1];
  for(i=0;i<n;i++)
    if(i%2==0)
      scanf("%d",&even[i/2]);
    else
      scanf("%d",&odd[i/2]);
  merge(0,n/2-1,even);
  merge(0,n/2-1,odd);
  int omax=0,osec=0,omnum,emax=0,esec=0,emnum,count=1;
  for(i=0;i<n/2-1;i++){
    if(odd[i]==odd[i+1])
      count++;
    else{
      if(omax<count){
        osec=omax;
        omax=count;
        omnum=odd[i];
      }
      else if(osec<count)
        osec=count;
      count=1;
    }
  }
  if(omax<count){
    osec=omax;
    omax=count;
    omnum=odd[i];
  }
  else if(osec<count)
    osec=count;

  count=1;
  for(i=0;i<n/2-1;i++){
    if(even[i]==even[i+1])
      count++;
    else{
      if(emax<count){
        esec=emax;
        emax=count;
        emnum=even[i];
      }
      else if(esec<count)
        esec=count;
      count=1;
    }
  }
  if(emax<count){
    esec=emax;
    emax=count;
    emnum=even[i];
  }
  else if(esec<count)
    esec=count;

  if(emnum==omnum){
    if(esec+omax>osec+emax)
      printf("%d\n",n-esec-omax);
    else
      printf("%d\n",n-emax-osec);
  }
  else
    printf("%d\n",n-emax-omax);
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,bool> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int w,h;
  cin>>w>>h;
  vector<P> cnt(w+h);
  rep(i,w){
    cin>>cnt[i].fi;
    cnt[i].se=true;
  }
  FOR(i,w,h+w){
    cin>>cnt[i].fi;
    cnt[i].se=false;
  }
  sort(begin(cnt),end(cnt));
  //rep(i,h+w) cout<<cnt[i].fi<<endl;
  int a=w+1,b=h+1;
  ll ans=0;
  ll now=0;
  rep(i,w+h){
    //cout<<cnt[i].fi<<' ';
    if(cnt[i].se){//(i,j)と(i+1,j)をつなげる
      ans+=cnt[i].fi*b;
      now+=b;
      a--;
    }else{
      ans+=cnt[i].fi*a;
      now+=a;
      b--;
    }
    //now++;
    //cout<<now<<' '<<ans<<endl;
    if(now==(h+1)*(w+1)-1) break;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3456
h, w = map(int, input().split())
n = int(input())
a = [int(i) for i in input().split()]

color = [[None] * w for _ in range(h)]


def zigzag(h, w):
    ih, iw = 0, 0

    while ih < h:
        yield (ih, iw)

        if ih % 2 == 0:
            if iw == w - 1:
                ih += 1
            else:
                iw += 1
        else:
            if iw == 0:
                ih += 1
            else:
                iw -= 1


ia = 0
ic = 0

for ih, iw in zigzag(h, w):
    ia += 1
    if ia > a[ic]:
        ic += 1
        ia = 1

    color[ih][iw] = ic + 1


for row in color:
    print(' '.join(map(str, row)))


Measured memory_bytes: 3568
N, M = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(N)]

ans = 0
l = sorted(k, key=lambda l: l[0])
small = l[0]
others = l[1:]

for i in small[1:]:
    if all([i in o[1:] for o in others]):
        ans += 1

print(ans)


Measured memory_bytes: 38256
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    long long i,n,x,a[100005],y,sum=0;
    scanf("%lld%lld",&n,&x);
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    for(i=0;i<n-1;i++)
    {
        y=a[i]+a[i+1];
        if(y>x)
        {
            sum+=y-x;
            if(a[i+1]>y-x)
                a[i+1]-=y-x;
            else a[i+1]=0;
        }
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){

int l,r,d;

cin >> l >> r >> d;

int count=0;

for(int i=l;i<=r;i++){
  if(i%d==0){
    count++;
  }
}

cout << count << endl;

}


Measured memory_bytes: 3616
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int k;
int dis;
int main(){
	while(cin>>n,n){
		int cnt = 1;
		bool flag = false;
		for(int i = 0;i < n;i++){
			cin>>k;
			if(k>=2){
				flag =true;
			}
			if(k>=1){
				cnt++;
			}
		}
		if(flag){
			cout <<cnt<<endl;
		}else{
			cout <<"NA"<<endl;
		}
	}
	return 0;
}

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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    long long sum = 0;
    int x;
    while (M--) {
        cin >> x;
        sum += x;
    }
    cout << (sum > N ? -1 : (N - sum)) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int Merge(int A[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int i,j,k;
  int L[n1+1],R[n2+1];
  
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=1000000001;
  R[n2]=1000000001;
  
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
    }
  }
  return right-left;
}

int Merge_Sort(int A[],int left,int right){
  int mid,res=0;
  if(left+1<right){
    mid=(left+right)/2;

    res+=Merge_Sort(A,left,mid);
    res+=Merge_Sort(A,mid,right);
    res+=Merge(A,left,mid,right);
    
  }
  return res;
}

int main(){
  int i,x,n,S[500000];

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

  x=Merge_Sort(S,0,n);
  
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%d",S[i]);
  }
  printf("\n%d\n",x);
  return 0;
}

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

int main(){
  int N;
  string S,T,U;
  cin >> N >> S;
  T=S.substr(0,N/2);
  U=S.substr(N/2,N/2);
 
  if(N%2==0 && T==U){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
	
	
	int n;
	cin>>n;
	set<string> s;
	for(int i=0;i<n;i++)
	{
	    string s1;
	    cin>>s1;
	    s.insert(s1);
	}
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 19264
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 1e6, mo = 998244353 ;
using namespace std ;

int n, m, fac[N + 5], inv[N + 5] ;

int mul(int a, int b) {
	int ans = 1, w = a % mo ;
	for ( ; b; b /= 2) {
		if (b & 1) ans = (ll) ans * w % mo ;
		w = (ll) w * w % mo ;
	}
	return ans ;
}

void upd(int &x, int y) {
	x = (x + y) % mo ;
}

int main() {
	scanf("%d%d", &n, &m) ; if (n < m) swap(n, m) ;
	fac[0] = inv[0] = 1 ;
	rep(i, 1, N) fac[i] = (ll) fac[i - 1] * i % mo ;
	inv[N] = mul(fac[N], mo - 2) ;
	for (int i = N - 1 ; i ; -- i) inv[i] = (ll) inv[i + 1] * (i + 1) % mo ;
	int res = 0 ;
	rep(i, 1, m) upd(res, (ll) fac[2 * i] * inv[i] % mo * inv[i] % mo * fac[n + m - 2 * i] % mo * inv[n - i] % mo * inv[m - i] % mo) ;
	res = (ll) res * inv[2] % mo * inv[n + m] % mo * fac[n] % mo * fac[m] % mo ;
	printf("%d\n", (res + n) % mo) ;
	return 0 ; 
}

Measured memory_bytes: 8064
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String args[]) throws IOException {
        FastReader s = new FastReader();
        int n = s.nextInt();
        int a = 0, b =0, ot = 0;
        for(int i=0;i<n;i++){
            int t = s.nextInt();
            t = t - ot;
            ot = ot + t;
            int x = s.nextInt();
            int y = s.nextInt();
            int l = Math.abs(x-a);
            int u = Math.abs(y-b);
//            System.out.println(i+" "+l+" "+u);
            if(l+u>t){
//                System.out.println(i+"a");
                System.out.println("No");
                return;
            }
            int k = t - l - u;
            if(k%2==1){
//                System.out.println("b");
                System.out.println("No");
                return;
            }
            a = x;
            b = y;
        }
        System.out.println("Yes");
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 37736
#include <stdio.h>

int main(){

  int x,y,s,i,ans1=0,ans2=0,a,b,j,T,max=0,d;


  for(;;){

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

    if(x==0&&y==0&&s==0){
      break;
    }
    for(i=1;i<=s-1;i++){
      for(j=1;j<=s-1;j++){
	if(s==i*(100+x)/100+j*(100+x)/100){

	  ans1=i*(100+y)/100+j*(100+y)/100;
	  if(max<ans1){
	    max=ans1;
	    a=i;
	    b=j;
	  }
	}
      }
    }
  ans2=a*(100+y)/100+b*(100+y)/100;
    printf("%d\n",ans2);
    ans1=0;
    ans2=0;
    max=0;
  }
  return 0;
}

Measured memory_bytes: 1028
#include <iostream>
using namespace std;
long long gcd(long long a, long long b) {
    if (a < b) swap(a, b);
    while (b > 0) { long long t = a; a = b; b = t % b; }
    return a;
}
int main() {
    int t; cin >> t;
    while (t--) {
        long long A, B, C, D; cin >> A >> B >> C >> D;
        if (A < B || B > D) cout << "No\n";
        else if (B-1 <= C) cout << "Yes\n";
        else {
            long long g = gcd(B, D);
            cout << (C + 1 > A % B + (B - A % B - 1) / g * g ? "Yes\n" : "No\n");
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	ll n, x;
	cin >> n >> x;
	V a(n);
	rep(i, n) {
		cin >> a[i];
		a[i] = abs(a[i] - x);
	}
	if (n == 1) {
		cout << a[0] << endl;
		return 0;
	}
	ll gcds = gcd(a[0], a[1]);
	REP(i, 2, n) {
		gcds = gcd(gcds, a[i]);
	}
	cout << gcds << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    REP(i, N) { cin >> p[i]; }
    vector<int> q = p;
    sort(q.begin(), q.end());
    long long cnt = 0;
    REP(i, N) {
        if(q[i] != p[i]) {
            cnt++;
        }
    }
    if(cnt <= 2) {
        cout << "YES" << endl;
        return 0;
    } else {
        cout << "NO" << endl;
        return 0;
    }
}

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

int main() {
  int H,A;
  int n;
  
  cin>>H>>A;
  
  if(H%A != 0){
    n = H/A + 1;
  }else{
    n= H/A;
  }
  cout<< n<< endl;
}


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

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

    sort(a, a+n, greater<long>());

    vector<long> sides;
    for (int i = 1; i < n; i++) {
        if (a[i] == a[i-1]) {
            sides.push_back(a[i]);
            i++;
        }
    }

    if (sides.size() < 2) {
        cout << 0 << endl;
    } else {
        cout << sides[0] * sides[1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1660
MOD = 10 ** 9 + 7


def prime_factorization(n):
    i = 2
    res = []
    while i * i <= n:
        cnt = 0
        while n % i == 0:
            n /= i
            cnt += 1
        if cnt > 0:
            res.append(cnt)
        i += 1
    if n > 1:
        res.append(1)
    return res


def comb(a, b):
    b = min(b, a - b)
    if b < 0:
        return 0
    elif b == 0:
        return 1
    elif b == 1:
        return a
    else:
        return (a % MOD) * pow(b, MOD - 2, MOD) % MOD * comb(a - 1, b - 1) % MOD


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

ans = 1
for power in prime_factorization(M):
    ans *= comb(N - 1 + power, power)
    ans %= MOD

print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
inline int rd(){
	char c=getchar();int x=0,flag=1;
	for(;c<'0'||c>'9';c=getchar())if(c=='-')flag=-1;
	for(;c>='0'&&c<='9';c=getchar())x=x*10+c-'0';
	return x*flag;
}
struct shop{
	int l,r,len;
	friend bool operator < (shop a,shop b){
		return a.len>b.len;
	}
}a[300010];
int n,m,st[100010]={0};
inline void add(int x,int v){
	for(;x<=m;x+=x&-x)
		st[x]+=v;
	return;
}
inline int ask(int x){
	int res=0;
	for(;x;x-=x&-x)
		res+=st[x];
	return res;
}
int main(){
	n=rd();m=rd();
	for(int i=1;i<=n;i++){
		int l=rd(),r=rd();
		a[i]=(shop){l,r,r-l+1};
	}
	sort(a+1,a+n+1);
	for(int i=1,j=n;i<=m;i++){
		for(;j&&a[j].len<i;j--)
			add(a[j].l,1),add(a[j].r+1,-1);
		int ans=j;
		for(int k=i;k<=m;k+=i)
			ans+=ask(k);
		printf("%d\n",ans);
	}
	return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  int a,p;

  cin >> a >> p;

  cout << (3*a+p)/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
#define all(v) ((v).begin()),((v).end())
#define clr(v,val) memset(v,val,sizeof v)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
void Run() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
}
const int N = 1e5 + 20;
/***You***Can***Do***It***/
int main()
{	
	//Run();
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
}


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

int main(){
  string s;
  cin >> s;
  int count=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='o'){
      count++;
    }
  }
  if(s.size()<=6){
      if(count+7>=s.size()){
    cout << "YES" <<endl;
  }
  else{
    cout << "NO" <<endl;
  }
  }
  else if(count>=s.size()-7){
    cout << "YES" <<endl;
  }
  else{
    cout << "NO" <<endl;
  }
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>

long long gcd(long long a,long long b){
    while(a&&b){
        if(a>b) a %= b;
        else b %= a;
    }
    return a+b;
}

long long lcm(long long a,long long b){
    return a*b/gcd(a,b);
}


int main()
{
    long long a,b,c,d;
    std::cin>>a>>b>>c>>d;
    long long lcmcd = lcm(c,d);
    long long div_c = b/c-(a-1)/c;
    long long div_d = b/d-(a-1)/d;
    long long div_lcm = b/lcmcd - (a-1)/lcmcd;
    std::cout<<b-a+1-(div_c+div_d-div_lcm)<<std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#include <atcoder/segtree>
#include <cstdio>
#include <vector>

using namespace std;
using namespace atcoder;

int op(int a, int b) { return max(a, b); }

int e() { return 0; }

int main() {
    int n, k; cin >> n >> k;
    segtree<int, op, e> seg(300001);
    int len = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        len = seg.prod(max(0,a-k), min(a+k+1,300001))+1;
        ans = max(ans, len);
        seg.set(a, len);
    }
    cout << ans << endl;
} 



Measured memory_bytes: 8468
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
	int n, cnt = 0;
	cin>>n;
	for (int i = 1; i <= n/2; ++i)
	{
		if (i + (n - i) == n && i != (n - i))
		{
			cnt++;
		}
	}
	cout<<cnt;
	cin>>n;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x)
#define CMIN(m, x)  m = min(m,x)
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;

vector<int> dy{-1,0,1,0};
vector<int> dx{0,-1,0,1};
int main(){
    int h,w;
    cin >> h >> w;
    h += 2;
    w += 2;
    int kuro = 0;
    int siro = 0;
    vector<vector<char>> map(h,vector<char>(w));
    queue<pair<int,int>> que;
    vector<vector<int>> keiro(h,vector<int>(w,-1));
    FOR(i,1,h - 1){
        FOR(j,1,w - 1){
            cin >> map[i][j];
            if(map[i][j] == '.') siro++;
            else kuro++;
        }
    }
    REP(i,w){
        map[0][i] = '#';
        map[h - 1][i] = '#';
    }
    REP(i,h){
        map[i][0] = '#';
        map[i][w - 1] = '#';
    }
    keiro[1][1] = 0;
    que.push(make_pair(1,1));
    while(!que.empty()){
        int y = que.front().first;
        int x = que.front().second;
        que.pop();
        if(y == h - 2 && x == w -2) break;
        REP(i,dx.size()){
            if(keiro[y + dy[i]][x + dx[i]] == -1 && map[y + dy[i]][x + dx[i]] == '.'){
                keiro[y + dy[i]][x + dx[i]] = keiro[y][x] + 1;
                que.push(make_pair(y + dy[i],x + dx[i]));
            }
        }
    }
    if(keiro[h - 2][w - 2] == -1)
        cout << -1 << endl;
    else
        cout << siro - (keiro[h - 2][w - 2] + 1) <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
using namespace std;
using ll = long long int;

int main() {
	int N, x;
	cin >> N >> x;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < N; i++) {
		if (x < a[i]) {
			cout << i;
			return 0;
		}
		else if (x == a[i]) {
			cout << i + 1;
			return 0;
		}else{
			x -= a[i];
		}
	}
	cout << N - 1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ar array

string s = "#abcdefghijklmnopqrstuvwxyz";

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

    ll n;
    cin >> n;
    string ans;
    while (n > 0) {
        if (n % 26 != 0) ans += s[n % 26];
        else {
            ans += 'z'; n--;
        }
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
}

Measured memory_bytes: 3632
N = int(input())
L = [0] * (N + 1)
L[0] = 2
L[1] = 1

if N ==1:
    print(L[1])
    exit()
for i in range(2, N + 1):
    L[i] = L[i - 2] + L[i - 1]

print(L[i])


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int k;
// 頂点i : kで割って(i-1)余る整数
vector<vector<pair<int, int>>> g;

void construct() {
	g.resize(k + 1);
	g[0].push_back(make_pair(2, 1));
	for (int i = 1; i <= k; ++i)
		g[i].push_back(make_pair(i % k + 1, 1));
	for (int i = 1; i <= k; ++i) 
		g[i].push_back(make_pair((i - 1) * 10 % k + 1, 0));
	return;
}

template<typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>>& G) {
	const int n = G.size();
	vector<T> d(n, numeric_limits<T>::max());
	vector<int> b(n, -1);
	priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q;
	d[s] = 0;
	q.emplace(d[s], s);
	while (!q.empty()) {
		pair<T, int> p = q.top();
		q.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (auto& e : G[v]) {
			int u = e.first;
			T c = e.second;
			if (d[u] > d[v] + c) {
				d[u] = d[v] + c;
				b[u] = v;
				q.emplace(d[u], u);
			}
		}
	}
	return d;
}

int main() {
	cin >> k;
	construct();
	vector<int> res = dijkstra(0, g);
	cout << res[1] << endl;
	return 0;
}

Measured memory_bytes: 7164
#include<bits/stdc++.h>
using namespace std;
char a;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>a;
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')cout<<"vowel";
	else cout<<"consonant";
	
	 return 0;
}





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

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

using namespace std;

int main(){
	int w,a,b; cin>>w>>a>>b;
	if     (a+w<b) cout<<b-(a+w)<<'\n';
	else if(b+w<a) cout<<a-(b+w)<<'\n';
	else           cout<<0<<'\n';
	return 0;
}


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

int n;
double f[310][310][310];

double solve(int a, int b, int c) {
	if (a + b + c == 0) return 0.0;
	if (f[a][b][c] > -0.5) return f[a][b][c];
	double ret = 0;
	
	if (a)
		ret += (solve(a-1, b, c) + (double)n/(a+b+c))*a/(a+b+c);
	
	if (b)
		ret += (solve(a+1, b-1, c) + (double)n/(a+b+c))*b/(a+b+c);
	
	if (c)
		ret += (solve(a, b+1, c-1) + (double)n/(a+b+c))*c/(a+b+c);
	
	return f[a][b][c] = ret;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);

	cin >> n;
	int c1 = 0, c2 = 0, c3 = 0;
	for (int i = 1; i <= n; ++i) {
		int x; cin >> x;
		c1 += (x == 1);
		c2 += (x == 2);
		c3 += (x == 3);
	}
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= n; ++j)
			for (int k = 0; k <= n; ++k)
				f[i][j][k] = -1.0;
	/*
	for (int k = 0; k <= n; ++k) {
		for (int j = 0; j <= n; ++j) {
			for (int i = 0; i <= n; ++i) {
				if (!i and !j and !k) {
					continue;
				}
				if (i + j + k > n) {
					continue;
				}
				double wait = (double) n / (i + j + k);
				double pi = (double) i / (i + j + k);
				double pj = (double) j / (i + j + k);
				double pk = (double) k / (i + j + k);
				
				if (i > 0) {
					f[i][j][k] += pi * f[i - 1][j][k];
				}

				if (j > 0) {
					f[i][j][k] += pj * f[i + 1][j - 1][k];
				}
				
				if (k > 0) {
					f[i][j][k] += pk * f[i][j + 1][k - 1];
				}
				f[i][j][k] += wait;
			}
		}
	}
	*/
	cout << setprecision(10);
	cout << fixed;
	//cout << f[c1][c2][c3] << "\n";
	cout << solve(c1,c2,c3) << "\n";
}


Measured memory_bytes: 227584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
cin >> N;
vector<int> num(N);
for(int i = 0; i < N; i++){
cin >> num.at(i);
}

reverse(num.begin(), num.end());

for(int i = 0; i < N; i++){
if(i != 0){
cout << " ";
}
cout << num.at(i);



}
cout << endl;
}


Measured memory_bytes: 3100
N = int(input())
H = [int(x) for x in input().split()]
 
ans = 0
current = 0
for i in range(N):
    if(i == N-1):
        if(current > ans):
            ans = current
        break
    if(H[i] >= H[i+1]):
        current += 1
    else:
        if(ans < current):
            ans = current
        current = 0
 
print(ans)
 

Measured memory_bytes: 14252
#include <stdio.h>

const int di[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dj[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int w, h;
int c[50][50];

void delete(int i, int j) {
	int k;

	c[i][j] = 0;

	for (k = 0; k < 8; k++) {
		int ni = i + di[k], nj = j + dj[k];
		if (ni >= 0 && ni < h && nj >= 0 && nj < w && c[ni][nj])
			delete(ni, nj);
	}
}

int main(void) {
	int i, j;

	while (scanf("%d %d", &w, &h), w) {
		int cnt;

		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				scanf("%d", c[i] + j);

		cnt = 0;
		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				if (c[i][j]) {
					delete(i, j);
					cnt++;
				}

		printf("%d\n", cnt);
	}

	return 0;
}

Measured memory_bytes: 680
#include <cstdio>

const int MAXN = 5000, MOD = 1e9 + 7;
int n, ecnt, head[MAXN + 5], siz[MAXN + 5];
int g[MAXN + 5], f[MAXN + 5][MAXN + 5];

struct Edge { int to, nxt; } graph[MAXN * 2 + 5];

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

inline void link ( const int s, const int t ) {
	graph[++ ecnt] = { t, head[s] };
	head[s] = ecnt;
}

inline void solve ( const int u, const int fa ) {
	static int tmp[MAXN + 5];
	f[u][1] = siz[u] = 1;
	for ( int i = head[u], v; i; i = graph[i].nxt ) {
		if ( ( v = graph[i].to ) ^ fa ) {
			solve ( v, u );
			for ( int j = 1; j <= siz[u] + siz[v]; ++ j ) tmp[j] = 0;
			for ( int j = 0; j <= siz[v]; ++ j ) {
				for ( int k = 1; k <= siz[u]; ++ k ) {
					addeq ( tmp[j + k], 1ll * f[v][j] * f[u][k] % MOD );
				}
			}
			for ( int j = 1; j <= siz[u] + siz[v]; ++ j ) f[u][j] = tmp[j];
			siz[u] += siz[v];
		}
	}
	for ( int i = 2; i <= siz[u]; i += 2 ) addeq ( f[u][0], 1ll * f[u][i] * g[i] % MOD );
	f[u][0] = ( MOD - f[u][0] ) % MOD;
}

int main () {
	scanf ( "%d", &n );
	for ( int i = 1, u, v; i < n; ++ i ) {
		scanf ( "%d %d", &u, &v );
		link ( u, v ), link ( v, u );
	}
	g[0] = 1;
	for ( int i = 2; i <= n; i += 2 ) g[i] = ( i - 1ll ) * g[i - 2] % MOD;
	solve ( 1, 0 );
	printf ( "%d\n", ( MOD - f[1][0] ) % MOD );
	return 0;
}

Measured memory_bytes: 57820
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    ll k;
    cin >> k;

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

    ll s = 0, r = 0;
    for (int l = 60; l >= 0; l--) {
        ll m = 1LL << l;
        ll c = 0;
        for (int i = 0; i < n; i++) {
            c += a[i] >> l & 1;
        }
        if (c < n - c) {
            r ^= m;
            if (r > k) {
                r ^= m;
                s += c << l;
                continue;
            }
        }
        s += max(c, n - c) << l;
    }

    ll s2 = 0;
    int f = 0;
    for (int l = 60; l >= 0; l--) {
        ll m = 1LL << l;
        ll c = 0;
        for (int i = 0; i < n; i++) {
            c += a[i] >> l & 1;
        }
        if (c < n - c) {
            r ^= m;
            if (r > k) {
                r ^= m;
                s2 += c << l;
                continue;
            } else {
                if (f == 0) {
                    f = 1;
                    s2 += c << l;
                    continue;
                }
            }
        }
        s2 += max(c, n - c) << l;
    }

    cout << max(s, s2) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
int main(void){
    long long int d, t, s;
    cin >> d >> t >> s;
    long long int jouken = s*t;
    if(jouken >= d){
        cout << "Yes" << endl;
    } else {cout << "No" << endl;}
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int stu[100][2];
    int check[100][2];
    for(int i=1; i<=n; i++){
        cin >> stu[i][0] >> stu[i][1];
    }
    for(int i=1; i<=m; i++){
        cin >> check[i][0] >> check[i][1];
    }
    for(int i=1; i<=n; i++){
        int ans = abs(stu[i][0]-check[1][0]) + abs(stu[i][1]-check[1][1]);
        int ansP = 1;
        for(int j=2; j<=m; j++){
            if(ans > abs(stu[i][0]-check[j][0]) + abs(stu[i][1]-check[j][1])){
                ans = abs(stu[i][0]-check[j][0]) + abs(stu[i][1]-check[j][1]);
                ansP = j;
            }
        }
        cout << ansP << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/**
*    author:  boutarou
*    created: 15.08.2020 21:08:13
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    ll res = x / d;
    if (res >= k) cout << x - k * d << endl;
    else {
        if ((k - res) % 2 == 0) cout << x - res * d << endl;
        else cout << abs(x - (res + 1) * d) << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long i64;


int main(){
    int n, m;
    cin >> n >> m;
    vector<int> count(n, 1);
    vector<bool> red(n);
    red[0] = true;
    for(int i=0; i<m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        count[x]--;
        count[y]++;
        if(red[x]) {
            red[y] = true;
        }
        if(count[x]==0) {
            red[x] = false;
        }
    }
    int res = 0;
    for(int i=0; i<n; i++) {
        if(red[i]) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )

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

const int INF = 100000000;
const double PI=3.14159265358979323846;

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

    int a[M], b[M];
    set<int> s2;
    set<int> g2;
    rep(i,0,M) {
        cin >> a[i] >>  b[i];

        if (a[i]==1) {
            s2.insert(b[i]);
        }
        if (b[i]==1) {
            s2.insert(a[i]);
        }
        if (a[i]==N) {
            g2.insert(b[i]);
        }
        if (b[i]==N) {
            g2.insert(a[i]);
        }
    }

    bool ans = false;

    for (auto p :s2) {
        if (g2.count(p)) {
            ans = true;
        }
    }
    if (ans) {
        cout << "POSSIBLE" << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 11136
#include <stdio.h>
#include <queue>
using namespace std;

int tx[4] = {0,0,1,-1},ty[4] = {1,-1,0,0};
int x,y;

class gamen{
public:
	char map[12][12];
	int howcnt;
	int i,j;

	gamen(){
		howcnt = 0;
		for(i = 0; i <= x+1; i++){
			map[0][i] = 'L';
			map[y+1][i] = 'L';
		}
		for(i = 0; i <= y+1; i++){
			map[i][0] = 'L';
			map[i][x+1] = 'L';
		}
	}
	
	void colorcenge(char iro,int nx,int ny){
		int i,j;
		char temp;
		temp = map[ny][nx];
		map[ny][nx] = iro;
		for(i = 0; i < 4; i++){
			if(map[ny+ty[i]][nx+tx[i]] == temp){
				colorcenge(iro,nx+tx[i],ny+ty[i]);
			}
		}
	}

	bool allsame(){
		int i,j;
		char key = map[1][1];
		for(i = 1; i <= y; i++){
			for(j = 1; j <= x; j++){
				if(map[i][j] != key){
					return false;
				}
			}
		}

		return true;
	}

	void scan(){
		for(i = 1; i <= y; i++){
			for(j = 1; j <= x; j++){
				scanf("%c",&map[i][j]);
				if(map[i][j] == ' ' || map[i][j] == '\n'){
					j--;
				}
			}
		}
	}

	void print(){
		int i,j;
		printf("count:%d\n",howcnt);
		for(i = 0; i <= y+1; i++){
			for(j = 0; j <= x+1; j++){
				printf("%c",map[i][j]);
			}
			printf("\n");
		}
	}
};

int main()
{
	int i,j;
	char color[] = {"RGB"};
	queue<gamen> que;
	gamen now;
	gamen foo;

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

	while(x != 0 && y != 0){
		while(!que.empty())
			que.pop();
		gamen men;
		men.scan();
	
		que.push(men);
		while(!que.empty()){
			now = que.front();
			
			if(now.allsame())	break;

			now.howcnt++;

			for(i = 0; i < 3; i++){
				if(color[i] != now.map[1][1]){
					foo = now;
					foo.colorcenge(color[i],1,1);
					que.push(foo);
				}
			}
			que.pop();
		}

		printf("%d\n",now.howcnt);

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

	return 0;
}

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

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

  int dp[100010];
  for (int i = 0; i < 100010; i++) dp[i] = 100010;
  dp[0] = 0;

  for (int n = 1; n <= 100000; n++) {
    for (int power6 = 1; power6 <= n; power6 *= 6) {
      dp[n] = min(dp[n], dp[n - power6] + 1);
    }
    for (int power9 = 1; power9 <= n; power9 *= 9) {
      dp[n] = min(dp[n], dp[n - power9] + 1);
    }
  }

  cout << dp[N] << endl;
}

Measured memory_bytes: 640
import collections
from math import factorial

N =int(input())
cnts = [frozenset(collections.Counter(list(input())).items()) for _ in range(N)]
xs = collections.Counter(cnts)
ans = 0
for _,v in xs.items():
    if v>1:
        a = factorial(v) // (2*factorial(v - 2))
        ans +=a
print(ans)

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	ll N;
	cin >> N;
	vector<ll> a(3*N);
	rep(3*N) cin >> a[i];
	sort(rall(a));
	ll ans = 0;
	repp(i, N){
		ans += a[2*i+1];
	}
	printf("%lld", ans);
}


Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
  ll big, small;
  if(a > b){
    big = a;
    small = b;
  } else if(a < b){
    big = b;
    small = a;
  } else{
    return a;
  }

  int rest = 1LL;
  while(1){
    rest = big % small;
    if(rest == 0) break;
    big = small;
    small = rest;
  }

  return small;
}

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

int main(){
  ll N,M;
  string s,t;
  cin >> N >> M >> s >> t;

  ll L = N * M / gcd(N, M);
  //cout << L << endl;

  ll a = L / N;
  ll b = L / M;

  ll lcm = a * b / gcd(a, b);
  for(int i = 0 ; i * lcm < L ; i++){
    ll inda = i * lcm / a;
    ll indb = i * lcm / b;
    if(s[inda] != t[indb]){
      cout << -1 << endl;
      return 0;
    }
  }

  cout << L << endl;
  return 0;
}


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

static int factorial (int num) {
    if ( num == 0 || num == 1 )
        return 1;
    return num*factorial(num-1);
}

int main (void) {
    int n, i, j;
    scanf("%d", &n);
    int p[n], q[n];
    for ( i=0; i<n; i++ )
        scanf("%d", &p[i]);
    for ( i=0; i<n; i++ )
        scanf("%d", &q[i]);

    int p_nth=0, q_nth=0; /* p, q が何番目か */
    int count;
    for ( i=0; i<n; i++ ) {
        count = 0;
        for ( j=i+1; j<n; j++ ) {
            if ( p[i] > p[j] )
                count++;
        }
        p_nth += count*factorial(n-i-1);
    }
    for ( i=0; i<n; i++ ) {
        count = 0;
        for ( j=i+1; j<n; j++ ) {
            if ( q[i] > q[j] )
                count++;
        }
        q_nth += count*factorial(n-i-1);
    }
    printf("%d\n", abs(p_nth-q_nth));
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    string S;
    cin >>N>>S;
    ll ans = 0;
    rep(i,N){
        map<char,bool>m;
        ll now=0;
        rep(j,i){
            m[S[j]]=1;
        }
        rep3(j,i,N){
            if(m[S[j]]){
                now++;
                m[S[j]]=0;
            }
        }
        chmax(ans,now);
    }
    
    
    cout << ans << endl;


    return 0;
    

}

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

int main(){
    int n;
    cin >> n;
    vector<int> l(n), r(n);
    for(int tsumugi = 0; tsumugi < n; tsumugi++){
        cin >> l[tsumugi] >> r[tsumugi];
    }

    int ans = 0;
    for(int karen = 0; karen< n; karen++){
        int people = r[karen] - l[karen] + 1;
        ans += people;
    }

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

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static int ReadInt()
    {
        return int.Parse(Console.ReadLine());
    }

    public static int[] ReadInts()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }

    public static void Main()
    {
        var input = ReadInts();
        var a = input[0];
        var b = input[1];
        if (a >= 13)
            Console.WriteLine(b);
        else if (a >= 6)
            Console.WriteLine(b / 2);
        else
            Console.WriteLine(0);

    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int MAX_N = 330;

void solve (int n) {
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<vector<int>> dp(MAX_N, vector<int>(MAX_N, 0));
    for (int s = 2; s <= n; s++) for (int l = 0; l < n; l++) {
        int r = l + s;
        if (n < r) continue;
        if (dp[l+1][r-1] == s-2 && abs(a[l]-a[r-1]) < 2) dp[l][r] = s;
        for (int m = l; m <= r; m++) chmax(dp[l][r], dp[l][m] + dp[m][r]);
    }
    cout << dp[0][n] << endl;
    return;
}

int main() {
    int n;
    while (cin >> n) if (n) solve(n);
    return 0;
}


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

typedef long long ll;
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl '\n'
const int N = 1e5 + 10;
using namespace std;

int main() {
    IO;
    string s; cin>>s;
    if(s.back()!='s')
        s+="s";
    else s+="es";
    cout<<s;
    



}

Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>

using namespace std;

void solve() {
    int n, l; cin >> n >> l;
    vector<int> app(n);
    int minidx;
    for(int i = 0; i < n; i++){
        app[i] = l + i;
        if(i==0) minidx = i;
        else if(abs(app[minidx]) > abs(app[i])){
            minidx = i;
        }
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        if(i != minidx) sum += app[i];
    }
    cout << sum << endl;
}

int main() {
    solve();
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

vector<int> get_prime_numbers(int n){
    vector<int> table(n+1, 1);
    table[0] = 0;
    table[1] = 0;
    for (int i=0; i<=(int)sqrt(n); i++){
        if (table[i]){
            for (int j=2*i; j<=n; j+=i){
                table[j] = 0;
            }
        }
    }
    return table;
}

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

    vector<int> table = get_prime_numbers(101000);

    vector<int> t(101000,0);
    REP(i,100100){
        if(table[i]==1 && table[(i+1)/2]==1) t[i] = 1;
    }
    REP(i,100100){
        t[i+1] += t[i];
    }

    REP(i,Q){
        int l,r; cin >> l >> r;
        cout << t[r] - t[l-1] << endl;

    }
    return 0;
}

Measured memory_bytes: 4072
N = int(input())
A = list(map(int, input().split()))
A.sort()
tmp = 0
S = []
for i in range(1, N):
    if A[i] == A[i-1]:
        tmp += 1
        continue
    S.append(tmp+1)
    tmp = 0
if tmp == 0:
    S.append(1)
else:
    S.append(tmp+1)

ans = 0

for i in range(len(S)):
    while S[i] > 1:
        if S[i] >=3:
            ans += 1
            S[i] -= 2
        else:
            ans += 1
            if i+2 < len(S):
                if S[i+1] == 1 and S[i+2] > 1:
                    S[i+2] -= 1
                elif S[i+1] > 1:
                    S[i+1] -= 1
                else:
                    S[i+1] = 0
            elif i+1 < len(S):
                S[i+1] -= 1
            break
print(N-2*ans)



Measured memory_bytes: 20572
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  ll b1 = 0;
  ll b2 = 2;
  ll b3 = 1;
  rep1(i,n-1){
  b1 = b2;
  b2 = b3;
  b3 = b1 + b2;
  }
  if(n==1){
    b3=1;
  }
  pri(b3);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long LL;
LL A[100000 + 10];
int n, k;
//?¨?????£??´§????¨?
bool check(LL P) {
	int cnt = k;
	for (int i = 0; i < n; ) {
		LL t = P;
		cnt--;
		// ??????????????¨?????????????????????????????§?£??????????????£?????´§???
		if (cnt < 0)
			return false;
		while (i < n && t >= 0) {
			// ?????????????????\?£???????????´§???
			if (t >= A[i])
				t -= A[i],i++;
			//?£????????????¨???????????????????£?
			if (t < A[i])
				break;
		}
	}
	return true;
}
// ????????????P???????°????
LL BinarySearch(LL sum) {
	LL left = 0, right = sum;
	LL mid;
	while (left + 1 < right) {
		mid = (left + right) / 2;
		//?????\?£??\??´§???
		if (check(mid))
			right = mid;
		else
			left = mid;
	}

	return right;
}
int main() {
	LL sum = 0;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &A[i]);
		sum += A[i];
	}
	LL P = BinarySearch(sum);
	printf("%lld\n", P);
	return 0;
}

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

// n = \prod_k ( p_k^{e_k}) then
// \phi(n) = \prod_k (p_k^{e_k} - p_k^{e_k-1})

int main(void){
  int n,ans=1;
  int f, tmp;
  
  cin >> n;
  f=2; tmp=1;
  while (n%f==0){
    n /= f;
    tmp *= f;
  }
  ans *= (tmp - tmp/f);
  for (f=3; f*f<=n; f+=2){
    tmp = 1;
    while (n%f==0){
      n /= f;
      tmp *= f;
    }
    ans *= (tmp - tmp/f);
  }
  if (n>1){
    ans *= (n - 1);
  }
  cout << ans << endl;
  return 0;
}


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

int main(void) {
	int height[10];
	scanf("%d",&height[0]);
	scanf("%d",&height[1]);
	scanf("%d",&height[2]);
	scanf("%d",&height[3]);
	scanf("%d",&height[4]);
	scanf("%d",&height[5]);
	scanf("%d",&height[6]);
	scanf("%d",&height[7]);
	scanf("%d",&height[8]);
	scanf("%d",&height[9]);
	int i,j;
	for(i=0; i<10; i++){
		for(j=1; j<10-i; j++){
			if(height[i]>height[i+j]){}
			else{
				int temp=height[i];
				height[i]=height[i+j];
				height[i+j]=temp;
			}
		}
	}

	printf("%d\n",height[0]);
	printf("%d\n",height[1]);
	printf("%d\n",height[2]);

	return EXIT_SUCCESS;
}

Measured memory_bytes: 600