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

int main() {
	int N, X, T;
  	cin >> N >> X >> T;
  
  	int a1=N/X;
  	int a2=N%X;
  	int a3=0;
    if (a2!=0) a3=1;
  
	cout << (a1+a3)*T << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,q;
    cin >> n >> k >> q;
    vector<int>a(n);
    for(int i=0;i<n;i++)a[i]=k-q;
    for(int i=0;i<q;i++){
        int ans;
        cin >> ans;
        a[ans-1]++;

    }
    for(int i=0;i<n;i++){
        if(a[i]<=0)cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long A = Long.parseLong(sc.next());
		Long B = Long.parseLong(sc.next());
		int K = Integer.parseInt(sc.next());
		sc.close();
		ArrayList<Integer> list = new ArrayList<Integer>();

		for(int i = 1; i <= 100 ; i++) {
			if(A % i == 0 && B % i == 0) {
				list.add(i);
			}
		}
		Collections.sort(list, Collections.reverseOrder());
		System.out.println(list.get(K - 1));
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define m 1000000007
int main()
{
  ll i,j,a[1001][1001],dp[1001][1001]={0},h,w;
char ch;
  cin>>h>>w;
  for(i=0;i<h;i++)
  {
    for(j=0;j<w;j++)
    {
      cin>>ch;
      if(ch=='.')
        a[i][j]=1;
 else
        a[i][j]=0;
    }
  }
  dp[0][0]=1;
for(j=1;j<w;j++)
{
if(a[0][j]==1)
dp[0][j]+=dp[0][j-1];
}
for(i=1;i<h;i++)
{
if(a[i][0]==1)
dp[i][0]+=dp[i-1][0];
}
  for(i=1;i<h;i++)
  {
    for(j=1;j<w;j++)
    {
      if(a[i][j-1]==1)
        dp[i][j]+=dp[i][j-1];
      if(a[i-1][j]==1)
        dp[i][j]+=dp[i-1][j];
      dp[i][j]%=m;
}
  }
  cout<<dp[h-1][w-1];
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] str = br.readLine().split(" ");
    int aButton = Integer.parseInt(str[0]);
    int bButton = Integer.parseInt(str[1]);
    int sum = 0;
    
    for (int i = 0; i < 2; i++) {
      if (aButton > bButton) {
        sum += aButton;
        aButton--;
      } else {
        sum += bButton;
        bButton--;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 21204
#include <stdio.h>
#include <string.h>

#define FOR(i, a, b) for(i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define comp(a, b) comp(const void *a, const void *b)
#define N 100000

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;

void yes_or_no(char boolean){
    if(boolean){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}


void substr(char str[], char sub[], int num, int end){
    int i;
    REP(i, num){
        sub[i] = str[i - num + end];
    }
    sub[num] = '\0';
}


int main(){
    char str[N], sub[10];
    char* list[] = {"dream", "dreamer", "erase", "eraser"};
    int length[] = {5, 7, 5, 6};
    int sublen = 0;
    char boolean = 1, flag = 0;
    int i;
    scanf("%s", str);

    uint len = strlen(str);

    while(len > 0){
        REP(i, 4){
            substr(str, sub, length[i], len);
            if(strcmp(sub, list[i]) == 0){
                sublen = length[i];
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            boolean = 0;
            break;
        }
        flag = 0;
        len -= sublen;
    }
    yes_or_no(boolean);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  char str[4];
  int r = 0;
  for(;scanf("%s", str) != EOF;)
  {
    r = 0;
    if(str[1] == 'S' && (str[0] == 'R' || str[2] == 'R')) r = 1;
    if(str[1] == 'R' && str[0] == 'S' && str[2] == 'S') r = 1;
    if(str[1] == 'R' && (str[0] == 'R' || str[2] == 'R')) r = 2;
    if(str[0] == 'R' &&str[1] == 'R' && str[2] == 'R') r = 3;
    printf("%d\n", r);
  }
  return 0;
}

Measured memory_bytes: 3812
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
const int MOD = 1000000007,N = 200010;
long long n,a[N],b[N];
int main(){
//	freopen("1.txt","r",stdin);
	long long s=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		s+=a[i];
		s%=MOD; 
		b[i+1]=s;
	}
	b[0]=0;
	long long sum=0;
	for(int i=0;i<n;i++){
		sum+=b[i]*a[i]%MOD;
		sum%=MOD;
	}
	cout<<sum<<endl;
	return 0;
}




Measured memory_bytes: 6744
#include<iostream>
#include<algorithm>

using namespace std;


int main(){
	int size, A[100], k = 0;
	
	cin >> size;
	
	for(int i=0;i<size;i++)
	cin >> A[i];

	for(int j = size-1; j > 0; j--) 
		for(int i = 0; i < j; i++)
			if(A[i] > A[i + 1]) {
				
				swap(A[i], A[i + 1]);
				k++;
				
		}
			 
	for(int i=0;i<size-1;i++)
	cout << A[i] << " ";
	
	cout << A[size-1] <<"\n";
	cout << k << "\n";
	
	return 0;
	
}



Measured memory_bytes: 3088
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
using namespace std;

typedef long long ll;

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

void solve(){
}

int c, b, a;
int main(){
  while(true){
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    c = b - a;
    cout << (c % 500)/100 << " " << (c%1000>=500) << " " << c / 1000 << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

bool isEight(int n){
    int cnt = 0;
    for(int i=1; i<=n; i++) if(n%i == 0) cnt++;

    if(cnt == 8) return true;
    else return false;
}

int main(){
    int n; cin >> n;
    int ans = 0;

    for(int i=1; i<=n; i+=2){
        if(isEight(i)) ans++;
    }

    cout << ans << endl;
}

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

#define sz 100005
#define nl printf("\n");
#define ll long long int

char f,g;
bool flag;
pair < int ,int > pi;
map < int , int > mp;
vector < int > v,va,vb;
int arr[sz],brr[sz],crr[sz];



int main(){

    int ans=INT_MAX;
    int n,m, i,j,k, x=0,y=0,z=0, a,b,c;

    cin>>n>>m;
    for(i=1; i<=n; i++){
        cin>>a>>b;
        if(b<=m and a<ans)
            ans=a;
    }
    if(ans==INT_MAX)cout<<"TLE"<<endl;
    else cout<<ans<<endl;


    return 0;

}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main(){
	string s;
	cin>>s;
	int n = s.size();

	int cnt = 0;
	for(int i=0;i<n;i++){
		cnt += (s[i] == 'o');
	}

	if(cnt + (15-n) >= 8){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}

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

const int INF = 1e9;

bool comp(pair<int, int> p1, pair<int, int> p2) {
  return p2.second > p1.second;
}
int main() {
  int n,m;
  cin>>n>>m;
  int x[m];
  for (int i=0;i<m;i++) cin>>x[i];
  sort(x, x+m);

  pair<int, int> dist[m-1];
  for (int i=0;i<m-1;i++) dist[i]=make_pair(i, x[i+1]-x[i]);
  sort(dist, dist+m-1, comp);

  int koma[m];
  for(int i=0;i<m;i++) koma[i]=1;

  for (int i=0;i<m-n;i++) {
    int j = dist[i].first;
    koma[j+1] = 0;
  }

  int ans = 0;
  for (int i=1;i<m;i++) {
    if (koma[i]==0) {
      ans += x[i] - x[i-1];
    }
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
vector<int> dp(100010,-1),x(100010);
int n;

int ans(int curr){
    if(curr == n-1){
        return 0;
    }
    if(dp[curr] != -1){
        return dp[curr];
    }
    int ret = abs(x[curr] - x[curr+1]) + ans(curr+1);
    if(curr != n-2){
        ret = min(ret , abs(x[curr] - x[curr+2]) + ans(curr+2));
    }
    dp[curr] = ret;
    return ret;
}

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

Measured memory_bytes: 5760
/*

 Remember, Hope is a good thing... May be the best of things... And No Good thing ever Dies !!!

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cout.tie(0);
#define endl "\n"
#define MOD 1000000007
const ll inf=(1LL<<60)-1;
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
ll stringtonum(string s)
{
    ll d=0;
    for(ll i=0;i<s.size();i++)
    {
        d=d*10+(s[i]-'0');
    }
    return d;
}
void solve()
{
  ll n,c=0;
  cin>>n;
  if(!(n&1) || n%5==0)
    cout<<-1<<endl;
  else
  {
      ll x=7;
      while(1)
      {
          if(x%n==0)
          {
              cout<<c+1<<endl;
              //cout<<x<<endl;
              break;
          }
              x=(x%n)*10+7;
              c++;
              //cout<<x<<endl;
              //s.push_back('7');
      }
  }
}
int main()
{
    IOS;
    //ll t;
    //cin>>t;
    //while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll x,k,d;

int main(){
  cin>>x>>d>>k;
  x=llabs(x);
  if(x/k>=d)cout<<x-k*d<<'\n';
  else{
    d-=x/k,x%=k;
    if(d%2==0)printf("%lld\n",x);
    else printf("%lld\n",k-x);
  }
  return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,d,e=0,f,i,g[100000001],h=100000000000,j,m,n,x=0,k,y=1,y1,y2,y3,y4,y5,y6,y7,y8,y9,y10,y11,y12,y13,y14,y15,y16,y17,y18,y19,y20,y21,y22,y23,y24,y25,x1;
    string s,s2="Yes";
    cin>>a;
    if(a%10==3){
        cout<<"bon";
        return 0;
    }
    if(a%10==2||a%10==4||a%10==5||a%10==7||a%10==9){
        cout<<"hon";
        return 0;
    }
    if(a%10==0||a%10==1||a%10==6||a%10==8){
        cout<<"pon";
        return 0;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

#define int long long

vector<int>v[200009];
int dp[300003];
int ans[300003];
int n , mod=1000000007  , m ;

void dfs( int now , int pre ) {
  dp[now] = 0;
  r(i,v[now].size()){
    int nex = v[now][i];
    if( pre == nex )continue;
    dfs( nex , now );
    dp[now] = max( dp[now] , dp[nex] + 1 ) % mod;
  }
}

void dfs2( int now , int pre , int x ) {

  ans[now] = max( dp[now] , x) % mod;

  vector<int> l , r;
  int N = v[now].size() + 1;

  l.push_back( 0 );

  r( i , v[now].size() ){
    int nex = v[now][i];
    int w = nex==pre ? x : dp[nex]+1 ;
    l.push_back( w );
    r.push_back( w );
  }

  r.push_back( 0 );

  for( int i = 1 ; i < N ; i++ ){
    l[i] = max( l[i] , l[i-1] ) % mod;
  }

  for( int i = N-2 ; i >= 0 ; i-- ){
    r[i] = max( r[i] , r[i+1] );
  }

  for( int i = 0 ; i < v[now].size() ; i++ ){
    if( v[now][i] == pre )continue;
    dfs2( v[now][i] , now ,  max(l[i],r[i+1])+1 );
  }

}



signed main(){
  cin>>n;

  r(i,n-1){
    int a,b;
    cin>>a>>b;a--;b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  dfs(0,0);
  dfs2(0,0,0);

  r(i,n) cout<<(n-1)*2-ans[i]<<endl;
}


Measured memory_bytes: 37524
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;
 
int main(){
    cout << fixed << setprecision(20);
    int x; cin >> x;
    int cnt = 1;
    while(1){
        if(cnt * (cnt+1) / 2 >= x){
            cout << cnt << endl;
            return 0;
        }
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while(cin >> n && n) {
    int ans = 0;
    for(int i=0; i<n; i++) {
      int x, y, h, w;
      cin >> x >> y >> h >> w;
      x += y + h;
      if(x<=60 && w<=2) ans += 6;
      else if(x<=80 && w<=5) ans += 8;
      else if(x<=100 && w<=10) ans += 10;
      else if(x<=120 && w<=15) ans += 12;
      else if(x<=140 && w<=20) ans += 14;
      else if(x<=160 && w<=25) ans += 16;
    }
    cout << ans*100 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
r,c=gets.split(" ").map(&:to_i)
h = Array.new(r+1).map{Array.new(c+1,0)} 

for i in 1..r                                       # 変数 i を1からrまで増やして繰り返し処理する。
    
a= gets.split.map(&:to_i)
    for j in 1..c                                   # 変数 i を1からcまで増やして繰り返し処理する。
    h[i-1][j-1] = a[j-1]
    h[i-1][c] += a[j-1]
    h[r][j-1] += a[j-1]
    h[r][c] += a[j-1]
    end
end
for i in 0..r
    for j in 0..c
      print " " unless j == 0
      print h[i][j]
    end
    puts
  end



Measured memory_bytes: 7028
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, c = rm()
if a<c<b or a>c>b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 27116
#include <iostream>
 
int main() {
	int a,b,d,r;
    std::cin>>a;
    std::cin>>b;
    d=a/b;
    r=a%b;
    std::cout << d << " " << r << " ";
    printf("%.8lf\n", (double)a/(double)b );
    return 0;
}

Measured memory_bytes: 3216
P = [1 for _ in range(1000)]
P[0] = 0
P[1] = 0
for i in range(2,int(1000**0.5)+1):
    for j in range(i*i,1000,i):
        P[j] = 0
Q = []
for i in range(1000):
    if P[i]==1:
        Q.append(i)
INFTY = 10**9+7
N = int(input())
F = {q:0 for q in Q}
for i in range(2,N+1):
    for q in Q:
        while True:
            if i%q==0:
                F[q] += 1
                i = i//q
            else:break
prod = 1
for q in F:
    prod = (prod*(F[q]+1))%INFTY
print(prod)

Measured memory_bytes: 39408
#include<bits/stdc++.h> 
using namespace std;
long long i,j,k,a[200005],n,l,r,sum,sum3;
int main()
{
	cin>>n;sum3=0;
	for(i=1;i<=n;i++) 
	cin>>a[i];
	l=1;r=0;sum=0;
		while(r+1<=n)
		{r++;
		while((sum+a[r])!=(sum^a[r])) 
		{sum=sum^a[l];l++;}
		sum=sum^a[r];//cout<<l<<" "<<r<<"**"<<endl; 
	    sum3=sum3+r-l+1;
		}  
	cout<<sum3;
	return 0;}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <string>


using namespace std;
int main(){
    int A, B;
    int plug = 1;
    cin >> A >> B;
    for(int i = 0; ; ++i){
        if(B <= plug){
            cout << i << endl;
            return 0;
        }
        plug += A - 1;
    }
    return 0;
}


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


int main() {
    int n, l, k;
    cin >> n >> l;

    vector<int> v(n);

    for (int i = 0; i < n; i++){
    v[i] = l + i;
    }

    int sum = 0;

    for (int i = 0; i < n; i++){
        sum += v[i];
    }

    if (v[0] > 0){
        sum -= v[0];
    }

    if (v[n - 1] < 0){
        sum -= v[n - 1];
    }

    cout << sum << endl;
}

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

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

    int n; cin>>n;
    int ans=0;
    while(n>=500){
        n-=500;
        ans+=1000;
    }
    while(n>=5){
        n-=5;
        ans+=5;
    }
    cout<<ans;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	long long sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		if(i%3&&i%5)
			sum+=i;
	cout<<sum<<"\n";
	return 0;
}


Measured memory_bytes: 3612
import numpy as np
from copy import deepcopy

S = str(input())
K = int(input())

if S[0] != '1': # 最初の文字が1以外の場合
  ans = S[0]
elif S == '1'*len(S): # 全ての文字が1の場合
  ans = '1'
else: # 1から始まる文字列で1以外の文字も含む場合
  n_1 = 0
  for i in range(len(S)):
    if S[i] == '1':
      n_1 += 1
    else:
      first_num = S[i]
      break
  if n_1 >= K:
    ans = '1'
  else:
    ans = first_num
    
print(ans)

Measured memory_bytes: 21904
#include <iostream>
using namespace std;
int main(){
	int n,x;
	while(1){
		int y=0;
              cin >> n >> x;
                if(n==0 && x==0){
                   break;
                   }
	 for(int i=1;i<=n-2;i++){
		 for(int j=i+1;j<=n-1;j++){
			 for(int k=j+1;k<=n;k++){
				 if(i+j+k==x && i!=j && j!=k && i!=k){
                     y++;
				    }
		     	}
		    }
	    }
	    cout << y << endl;
	}
return 0;
}


Measured memory_bytes: 3108
N = int(input())
W = [int(x) for x in input().split()]
ans = 100000000000

for i in range(N-1):
    if ans > abs(sum(W[:i+1]) - sum(W[i+1:])):
        ans = abs(sum(W[:i+1]) - sum(W[i+1:]))

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
ll dp[100001];
int main(){
    ll n;
    cin>>n;
    ll h[n];
    h[0]=0;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    dp[0]=0;dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        dp[i]=min((dp[i-1]+abs(h[i]-h[i-1])),(dp[i-2]+abs(h[i]-h[i-2])));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  cin >> N >> M;

  vector<int> A(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());

  using P = pair<int, int>;  
  priority_queue<P> Q;  
  for ( int i = 0; i < M; i++ ) {
    int b, c;
    cin >> b >> c;
    Q.push(P(c, b));    
  }

  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    int a = A[i];
    if ( Q.size() == 0 ) {
      ans += a;
      continue;
    }
    P p = Q.top(); 
    if ( a < p.first ) {
      ans += p.first;
      Q.pop();
      if ( p.second > 1 ) Q.push(P(p.first, p.second-1));
    } else {
      ans += a;      
    }
  }

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


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

pair<long long int,long long int> ar[200005];
long long int fi[200005],se[200005],n,k,maxn=0;;

bool check(long long int lim){
	long long int t=k;
	bool can=1;
	for(int i=0;i<n;i++){
		if(t-max(ar[i].first-lim/ar[i].second,0LL)<0){
			can=0;
		}else t-=max(ar[i].first-lim/ar[i].second,0LL);
	}
	return can;
}

int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>fi[i];
	for(int i=0;i<n;i++)
		cin>>se[i];
	sort(fi,fi+n);
	sort(se,se+n,greater<long long int>());
	for(int i=0;i<n;i++)
		ar[i]={fi[i],se[i]},maxn=max(maxn,fi[i]*se[i]);
	long long int l=0,r=maxn;
	while(l!=r){
		long long int mid=l+(r-l)/2;
		if(check(mid)){
			r=mid;
		}else l=mid+1;
	}
	cout<<l<<'\n';
}

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

typedef long long int ll;


ll dp[102][11][1001];

int main(){
  int n,s;

  while(cin >> n >> s,n || s){
    for(int i = 0 ; i < 102 ; i++){
      for(int j = 0 ; j < 11 ; j++){
	for(int k = 0 ; k < 1001 ; k++){
	  dp[i][j][k] = 0;
	}
      }
    }

    dp[0][0][0] = 1;

    for(int i = 0 ; i <= 100 ; i++){
      for(int j = 0 ; j <= n ; j++){
	for(int k = 0 ; k <= s ; k++){	  
	  dp[i+1][j][k] += dp[i][j][k];
	  if(k + i > s)continue;
	  dp[i+1][j+1][k+i] += dp[i][j][k];
	}
      }
    }

    cout << dp[101][n][s] << endl;

  }

  return 0;
}

Measured memory_bytes: 9928
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a+b==15)
		printf("+");
	else if(a*b==15)
		printf("*");
	else
		printf("x");
	return 0;
}

Measured memory_bytes: 256
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
f = gets.to_i
if a-b > f || a-b < -f
  puts ":("
elsif b-c > f || b-c < -f
  puts ":("
elsif c-d > f || c-d < -f
  puts ":("
elsif d-e > f || d-e < -f
  puts ":("
elsif e-a > f || e-a < -f
  puts ":("
else
  puts "Yay!"
end

Measured memory_bytes: 1788
mod=998244353
n=int(input())
S=input()
ans=1
Cnt={'R':0,'G':0,'B':0}
for s in S:
    Tmp=sorted(Cnt.values())
    if Cnt[s]==Tmp[2]:
        ans*=n-Cnt[s]
    elif Cnt[s]==Tmp[1]:
        ans*=Tmp[2]-Tmp[1]
    else:
        ans*=Tmp[1]-Tmp[0]
    ans%=mod
    Cnt[s]+=1
print(ans)

Measured memory_bytes: 42984
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e9;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
      	cout << (char)(s[i]+n>'Z'?s[i]-'Z'+'A'+n-1:s[i]+n);
    }
    return 0;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <time.h>
#include <stdio.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}

struct UnionFind{
    int size;
    vector<int> par;
    vector<int> rank;
    UnionFind(int x){
        size=x;
        par=vector<int> (x);
        rank=vector<int> (x,1);
        for (int i=0;i<x;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        else return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y) return;
        if(rank[x]<rank[y]) par[x]=y;
        else par[y]=x;
        if(rank[x]==rank[y]) rank[x]++;
    }
    bool check(int x,int y){
        return root(x)==root(y);
    }
    void initialize(){
        for (int i=0;i<size;i++){
            par[i]=i;rank[i]=1;
        }
    }
	void all_gather(map<int,vector<int>> &mp){
		rip(i,size,0){
			if(mp.count(root(i))){
				mp[root(i)].push_back(i);
			}
			else{
				mp[root(i)] = vector<int>(1,i);
			}
		}
	}
};

ll counter(vector<P> &da, vector<int> &li){
	ll ret = 0;
	set<int> x, y;
	rip(i,li.size(),0){
		x.insert(da[li[i]].first);
		y.insert(da[li[i]].second);
	}
	return (ll) x.size() *y.size() - li.size();
}

int main(){
	int n; cin >> n;
	vector<P> da(n);
	map<int,int> mpx, mpy;
	UnionFind uf(n);
	rip(i,n,0){
		cin >> da[i].first >> da[i].second;
		if(mpx.count(da[i].first)) uf.unite(i, mpx[da[i].first]); else mpx[da[i].first] = i;
		if(mpy.count(da[i].second)) uf.unite(i, mpy[da[i].second]); else mpy[da[i].second] = i;
	}
	map<int, vector<int>> mp;
	uf.all_gather(mp);
	ll ans = 0;
	for(auto i:mp){
		//cout << i.first << endl;
		ans += counter(da, i.second);
	}
	cout << ans << endl;
}

Measured memory_bytes: 12024
#include<stdio.h>
long long int ds(long long int n, long long int b){
	long long int s=0;
	while(n>0){
		s=s+n%b;
		n=n/b;
	}
	return s;
}

int main(){
	long long int n,s,i, b;
	scanf("%lld %lld",&n, &s);
	if(n-s<0) {
		printf("-1");
		return 0;
	}
	if(n-s==0){
		printf("%lld",n+1);
		return  0;
	} 
	for(i=2;i*i<=n;i++){
		if(ds(n,i)==s){
			printf("%lld",i);
			return 0;
		} 
	}
	for(;i>0;i--){
		b=(n-s)/i+1;
		if(b>1&&b>s-i&&b>i){
			if(ds(n,b)==s){
				printf("%lld",b);
				return 0;
			}
		}
	}
	printf("-1");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

struct UnionFind
{
  vector<int> d;
  UnionFind(int n = 0) : d(n, -1) {}
  int find(int x)
  {
    if (d[x] < 0)
      return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if (x == y)
      return false;
    if (d[x] > d[y])
      swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> p(N);
  vector<int> value_to_index(N);

  rep(i, N)
  {
    cin >> p[i];
    p[i]--;
    value_to_index[p[i]] = i;
  }
  UnionFind uf(N);
  rep(i, M)
  {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    uf.unite(x, y);
  }

  rep(i, N)
  {
    int swap_index = value_to_index[i];
    if (i == swap_index)
      continue;

    if (uf.same(i, swap_index))
    {
      swap(value_to_index[p[i]], value_to_index[p[swap_index]]);
      swap(p[i], p[swap_index]);
    }
  }

  int ans = 0;
  rep(i, N)
  {
    if (p[i] == i)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        int choice = 2;
        if(a.length() != b.length()){
            if(a.length() > b.length()){
                choice = 1;
            } else {
                choice = 3;
            }
        } else {
            for(int i = 0; i < a.length(); i++){
                if(a.charAt(i) != b.charAt(i)){
                    if(a.charAt(i) > b.charAt(i)){
                        choice = 1;
                        break;
                    } else {
                        choice = 3;
                        break;
                    }
                }
            }
        }
        if(choice == 1){
            System.out.print("GREATER");
        } else if(choice == 3){
            System.out.print("LESS");
        } else {
            System.out.print("EQUAL");
        }
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>

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


int main() {
	char c;
	cin >> c;
	cout << char(c + 1) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import bisect
from collections import defaultdict
import math

def main():
    #N = map(int, input().split())
    N = int(input())

    edges = defaultdict(list)
    for _ in range(N-1):
        u, v, w = map(int, input().split())
        edges[u-1].append((v-1, w))
        edges[v-1].append((u-1, w))

    colors = [None]*N
    colors[0] = 0
    colored = [(0, 0)]
    while colored:
        new_colored = []
        for n, d in colored:
            nodes = edges[n]
            for m, w in nodes:
                if colors[m] is None:
                    dist = d + w
                    if dist % 2 == 0:
                        colors[m] = 0
                    else:
                        colors[m] = 1
                    new_colored.append((m, dist))
        colored = new_colored

    for n in range(N):
        print(colors[n])

if __name__ == '__main__':
    main()


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

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

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);

        if (A < B) {
            Console.WriteLine(B+(B-1));
        } 
        else if (A > B) {
            Console.WriteLine(A+(A-1));
        }
        else if (A == B) {
            Console.WriteLine(A+B);
        }
    }
}


Measured memory_bytes: 13140
using System;
class Program
{
	static void Main(string[] args)
	{
		//int n = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int k = int.Parse(input[1]);
 
        string[] input2 = Console.ReadLine().Split(' ');
        long max = 0;
        long tmpSum = 0;
        for(int i = 0; i < n; i++)
        {
           tmpSum += int.Parse(input2[i]);
           if(i >= k)
           {
             tmpSum -= int.Parse(input2[i - k]);
           }
           if(max < tmpSum) max = tmpSum;

        }
        double ans = (max + k) / 2d;

        Console.WriteLine(ans);                  
	}
}

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

int main() {
    int x;
    cin >> x;
    if (x == 0) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define lson rt<<1
#define rson rt<<1|1
#define scd(x) scanf("%d",&x)
#define scdd(x,y) scanf("%d%d",&x,&y)
const int maxn=1000+10;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
map<pii,int>mp;
int arr[maxn][maxn],in[maxn*maxn];
vector<int>G[maxn*maxn];
pii get_pii(int i,int j) {
    int mn=min(i,arr[i][j]),mx=max(i,arr[i][j]);
    return pii(mn,mx);
}
int topo(int n) {
    queue<int>q;
    for(int i=1; i<=n; i++) {
        if(in[i]==0)q.push(i);
    }
    int ans=0;
    while(!q.empty()) {
        int u=q.front();
        q.pop();
        ans++;
        for(int i=0; i<G[u].size(); i++) {
            int v=G[u][i];
            in[v]--;
            if(in[v]==0)q.push(v);
        }
    }
    return ans;
}
int dp[maxn*maxn];
int dfs(int u){
    if(~dp[u])return dp[u];
    int mx=0;
    for(int i=0;i<G[u].size();i++){
        mx=max(mx,dfs(G[u][i]));
    }
    return dp[u]=mx+1;
}
int main() {
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif // LOCAL
    int n;
    scd(n);
    int cnt=0;
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=n-1; j++) {
            scd(arr[i][j]);
            pii no=get_pii(i,j);
            if(mp[no]==0) {
                mp[no]=++cnt;
            }
        }
    }
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=n-2; j++) {
            pii one=get_pii(i,j),two=get_pii(i,j+1);
            int on=mp[one],tw=mp[two];
            G[on].push_back(tw);
            in[tw]++;
        }
    }
    int ans=topo(cnt);
    if(ans==cnt) {
            memset(dp,-1,sizeof(dp));
            ans=0;
            for(int i=1;i<=cnt;i++){
                ans=max(ans,dfs(i));
            }
            cout<<ans<<endl;
    } else cout<<-1<<endl;
}


Measured memory_bytes: 82944
<?php

fscanf(STDIN, "%d", $N);

$S = explode(' ', trim(fgets(STDIN)));

$flag = 0;

for ( $i = 0; $i < $N; $i++) {
    if($S[$i] == 'Y'){
        $flag = 1;
    }
}

if($flag == 1){
    out::println('Four');
}else{
    out::println('Three');
}


class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}



?>


Measured memory_bytes: 3828
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
        boolean ans = true;
        List<String> list = new ArrayList<String>();
        for(int i = 0;i < n;i++){
          list.add(sc.next());
        }
        
        

        ans = (list.size() == new HashSet<>(list).size());
        if(ans == false){
          System.out.println("NO");
          return;
          }
        System.out.println("YES");
    }
}

Measured memory_bytes: 77184
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <set>
#include <cmath>
#include <cstring>
#include <stdio.h>
#include <string.h>
#include <sstream>
#include <stdlib.h>
#include <vector>
#include <iomanip>
#include <ctime>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdlib>
#include <cassert>

#define nl "\n"
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define p_un(a) ((void)a)
#define p_st(a) string(a)
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define naj ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define NL cout << endl;
#define sqr(x) (sqrt(x) * 1LL)
#define pcnt(i) __builtin_popcount(i)
#define lcm(a,b) (a * b) / __gcd(a, b)
#define E 2.718281828459045
#define PI 3.141592653589793
#define up_b upper_bound
#define low_b lower_bound
#define FILE_NAME "A"
#define show(x) cout << (#x) << ": " << x << endl

using namespace std;

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;
typedef vector <llong> vl;
typedef vector <bool> vb;
typedef vector <char> vc;
typedef vector <int> vi;
typedef vector <string> vs;
typedef pair <llong, llong> pll;
typedef map <llong, llong> mll;
typedef set <llong> sl;
typedef set <char> sc;
typedef map <string, llong> msl;
typedef map <string, bool> msb;
typedef map <char, llong> mcl;
typedef map <string, string> mss;

const llong MXN = 1e6 + 1;
const llong MOD = 1e9 + 7;
const llong INF = 1e18;
const ldouble EPS = 1e-9;

#define int int64_t

//int dx[]= {1,0,-1,0}; int dy[]= {0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1}; int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2}; int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={-1,-1,+0,+1,+1,+0}; int dy[]={-1,+1,+2,+1,-1,-2}; //Hexagonal Direction

signed main() {

    naj;
#ifdef LOL
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
    int a, b;
    cin >> a >> b;
    if(b % a)
        cout << b - a;
    else
        cout << a + b;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S,T;
    cin >> S >> T;
    ll ans =0;
    for(int i=0;i<S.size();i++){
        if(S[i]!=T[i])ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
int main(){
  #define int long long
  int N,D,A,B;
  B=0;
  cin>>N>>D;
  vector<int>x(N);
  vector<int>y(N);
  for(int i=0;i<N;i++){
    cin>>x[i]>>y[i];
    A=x[i]*x[i]+y[i]*y[i];
    if(A<=D*D)
    B++;
  }
  cout<<B<<endl;
}

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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n) 
#define FFI(n) FORI(j, n)
#define IN(x) cin<<(x);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x, v) lower_bound((x).begin(), (x).end(), (v))
#define uboundv(x, v) upper_bound((x).begin(), (x).end(), (v))
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	ll ans=0, l, r;
	F(n) {
		cin>>l>>r;
		ans+=(r-l+1);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(){
  int m[128];
  m['J']=0;
  m['O']=1;
  m['I']=2;
  int n;
  char s[1001];
  cin>>n>>s;
  int dp[1001][8]={};
  dp[0][1]=1;
  for(int i=0;i<n;i++){
    for(int j=0;j<8;j++){
      for(int k=0;k<8;k++){
	if(j&k&&k>>m[s[i]]&1){
	  dp[i+1][k]=(dp[i+1][k]+dp[i][j])%10007;
	}
      }
    }
  }
  int sum=0;
  for(auto e:dp[n]){
    sum=(sum+e)%10007;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
int main(){
    int c=1,n;
    std::cin >> n;
    VEC(int,a,n);
    if(n==1){
        std::cout << 1 << std::endl;
        exit(0);
    }
    bool b=1;
    int m;
    rep(i,n-1){
    //    if(b)std::cout << a[i] << std::endl;
        if(b){
          if(a[i]<a[i+1]){
              m=0;
              b=0;
              continue;
          }
          if(a[i]>a[i+1]){
              m=1;
              b=0;
              continue;
          }
          
          
        }
        else {
            if(m==0){
                if(a[i]>a[i+1]){
                    c++;
                    b=1;
                  //  i++;
                }
            }
            if(m==1){
                if(a[i]<a[i+1]){
                    c++;
                    b=1;
              //      i++;
                }
            }
        }
        
    }
    std::cout << c << std::endl;
}

Measured memory_bytes: 640
//ABC152-E Flatten より
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int gcdi(int a, int b) {
	if(a<0) a=b;
	if(b<0) b=a;
    if (b == 0) return a;
    return gcdi(b, a%b);
}

int main(){
  
  	int a, b, c, d, x, y;
  	cin>> a >> b >> c >> d;
  
  	x=abs(a-c);
  	y=abs(b-d);
  
  	if(x==0 || y==0){
      	cout<< "0" <<endl;
      	return 0;
    }
  
  	cout<< x+y-gcdi(x, y) <<endl;
  
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    string s, t;
    bool check = false;
    int now = 0;
    cin >> s >> t;
    reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());
    while (now < s.size()){
        if (s[now] == '?' || s[now] == t[0]){
            if (check){
                if (s[now] == '?') s[now] = 'a';
            }else {
                for (int j = 0; j < t.size(); j++){
                    if (s[now + j] == '?' || s[now + j] == t[j]){
                        check = true;
                        continue;
                    }else {
                        check = false;
                        break;
                    }
                }
                if (check){
                    for (int j = 0; j < t.size(); j++){
                        s[now + j] = t[j];
                    }
                    now += t.size() - 1;
                }else s[now] = 'a';
            }
        }
        now += 1;
    }
    reverse(s.begin(), s.end());
    if (check) cout << s << endl;
    else cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
N,M=map(int,input().split())
picN=[]
picM=[]

for i in range(N):
    L=list(input())
    picN.append(L)

for i in range(M):
    L=list(input())
    picM.append(L)

K=N-M

for i in range(K+1):
    for j in range(K+1):
        flg=True
        for a in range(M):
            for b in range(M):
                if picN[a+i][b+j]!=picM[a][b]:
                    flg=False
        if flg:
            break
    if flg:
        break

if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 69072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;


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

    int m, d; cin >> m >> d;

    int ans = 0;
    for(int tuki=1; tuki<=m; ++tuki){
        for(int day=20; day<=d; ++day){
            if(day%10 >= 2 && day/10 >= 2 && (day%10)*(day/10)==tuki) ++ans; 
        }
    }
    cout << ans << endl;
    
    
    return 0;
}

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

int main(void)
{
	int w, h;
	int x, y, r;
	int ct;
	
	ct = 0;
	cin >> w >> h >> x >> y >> r;
	
	x += r;
	y += r;
	
	if (x > w || y > h){
		ct++;
	}
	
	x -= r * 2;
	y -= r * 2;
	
	if (x < 0 || y < 0){
		ct++;
	}
	
	if (ct != 0){
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	
	cout << endl;
	
	return (0);
}

Measured memory_bytes: 1156
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
#include <ctype.h>
using namespace std;
int n,debt=100000;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
	debt/=20;debt*=21;
	if(debt%1000!=0){debt-=debt%1000;debt+=1000;}}
	cout<<debt<<endl;
    return 0;}


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

using namespace std;

#define int long long
#define M 1000000007

signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	int n;
	cin >> n;
	int ans=0;
	int sum=0;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum=(sum+a[i])%M;
	}
	for(int i=0;i<n;i++){
		sum=(sum-a[i]+M)%M;
		ans=(ans+(a[i]*sum)%M)%M;
	}
	cout << ans << endl;
} 

Measured memory_bytes: 5204
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;

string S;

ll N, K;

ll ans;
bool flag;
int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);


	cin >> S;
	char a, b;
	int cnta, cntb;

	if (S[0] == S[1] && S[2] == S[3] && S[0] != S[2])flag = true;
	if (S[0] == S[2] && S[1] == S[3] && S[0] != S[1])flag = true;
	if (S[0] == S[3] && S[1] == S[2] && S[0] != S[1])flag = true;

	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import itertools
import math

d,g=list(map(int,input().split()))
PC=[list(map(int,input().split())) for _ in range(d)]
ans=[]

for i in range(d+1):
  for j in itertools.combinations(range(d),i):
    score,pro1=0,0
    for k in j:
      score += (PC[k][1] + (k+1) * 100 * PC[k][0])
      pro1 += PC[k][0]
    for k in range(d):
      pro2 = pro1
      if score >= g:
        ans.append(pro2)
      elif k in j:
        continue
      p=math.ceil((g-score) / ((k+1) * 100))
      if 0 < p < PC[k][0]:
        pro2 += p
        ans.append(pro2)
        
print(min(ans))

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

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

    ll cnt = 0;
    ll ans = -1;
    rep(i,s.size()){
        if(s[i] == 'R') cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616