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

int64_t mod = 1000000007;

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

	string ans = "Good";
	for (int i = 0; i < 3; i++) {
		if (s[i] == s[i + 1]) {
			ans = "Bad";
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key){
    int left = 0;
    int right = n;
    int mid;

    while(left < right){
        mid = ( left + right) / 2;
        if(A[mid] == key){
            return 1;
        }else if(key > A[mid] ){
            left = mid + 1;
        }else{
            right = mid;
        }
    }
    return 0;
}

int main(){
    int i, q, k, sum = 0;

    scanf("%d", &n);
        for(i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d", &k);
        if(binarySearch(k)){
            sum++;
        }
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 2960
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

#define INF  -10000000000

int main()
{
    long long a,b;
    long long v,w;
    long long t;
    
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    
    if (v >= w && abs(a-b) <= (v-w)*t){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 3636
#include <cstdio>
long long n, m, a, x, y, M=1e9+7;
int main() {
	int i;
	scanf("%lld%lld", &n, &m);
	for(i=0; i<n; i++) {
		scanf("%lld", &a);
		x += a * (i-(n-1-i));
	}
	x %= M;
	for(i=0; i<m; i++) {
		scanf("%lld", &a);
		y += a * (i-(m-1-i));
	}
	y %= M;
	printf("%lld", x*y%M);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>

char str[][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int num[] = {7, 6, 5, 4, 3, 2, 1};

int main(){
    char c[4];
    scanf("%s", c);
    for(int i = 0; i < 7; i++){
        if(strcmp(c, str[i]) == 0) printf("%d", num[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    ll a,b,k;
    cin>>a>>b>>k;
    if(a>=k){
        a=a-k;
        k=0;
    }else{
        k=(k-a);
        a=0;
    }
    b=b-k;
    if(b<0){
        b=0;
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}

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

#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
ll mygcd(ll m,ll n){
    return n ? mygcd(n,m%n) : m;
}
ll mylcm(ll c,ll d){
    return c/mygcd(c,d) * d;
}
//gcd : 最大公約数

int main(){
  int N;cin >> N;
  vector<ll> vec(N);
  rep(i,N) cin >> vec[i];
  ll ans = vec[0];
  for(int i=1;i<N;i++){
    ans = mylcm(ans,vec[i]);
  }
  cout << ans << endl;
}

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

int main()
{
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    for (int i = 0; i < A; i++)
        cin >> a[i];
    for (int i = 0; i < B; i++)
        cin >> b[i];
    int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
    for (int i = 0; i < M; i++)
    {
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans << endl;
    return 0;
}

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

int main( void ) {
	int i, n, sum;
	char ch[ 10 ][ 61 ] = { "", ".,!? .,!? .,!? .,!? .,!? .,!? .,!? .,!? .,!? .,!? .,!? .,!? ", "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc", "defdefdefdefdefdefdefdefdefdefdefdefdefdefdefdefdefdefdefdef", "ghighighighighighighighighighighighighighighighighighighighi", "jkljkljkljkljkljkljkljkljkljkljkljkljkljkljkljkljkljkljkljkl", "mnomnomnomnomnomnomnomnomnomnomnomnomnomnomnomnomnomnomnomno", "pqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrs", "tuvtuvtuvtuvtuvtuvtuvtuvtuvtuvtuvtuvtuvtuvtuvtuvtuvtuvtuvtuv", "wxyzwxyzwxyzwxyzwxyzwxyzwxyzwxyzwxyzwxyzwxyzwxyzwxyzwxyzwxyz" }, key, tmp;

	scanf( "%d%*c", &n );


	for ( i = 0; i < n; i++ ) {
		while ( 1 ) {
			scanf( "%c", &key );

			if ( key == '\n' )
				break;
			else if ( key == '0' )
				continue;

			for ( sum = 0; scanf( "%c", &tmp ), tmp != '0'; sum++ ) ;

			putchar( ch[ key - '0' ][ sum % 60 ] );
		}

		putchar( '\n' );
	}

	return 0;
}

Measured memory_bytes: 568
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
 
using namespace std;
 
void North(int* dice){
  int predice[7];
  for(int i = 0 ; i < 7 ; i++) predice[i] = dice[i];
  dice[1] = predice[2];
  dice[2] = predice[6];
  dice[5] = predice[1];
  dice[6] = predice[5];
}

void East(int* dice){
  int predice[7];
  for(int i = 0 ; i < 7 ; i++) predice[i] = dice[i];
  dice[1] = predice[4];
  dice[3] = predice[1];
  dice[4] = predice[6];
  dice[6] = predice[3];
}

void West(int* dice){
  int predice[7];
  for(int i = 0 ; i < 7 ; i++) predice[i] = dice[i];
  dice[1] = predice[3];
  dice[3] = predice[6];
  dice[4] = predice[1];
  dice[6] = predice[4];
}

void South(int* dice){
  int predice[7];
  for(int i = 0 ; i < 7 ; i++) predice[i] = dice[i];
  dice[1] = predice[5];
  dice[2] = predice[1];
  dice[5] = predice[6];
  dice[6] = predice[2];
}

void Right(int* dice){
  int predice[7];
  for(int i = 0 ; i < 7 ; i++) predice[i] = dice[i];
  dice[2] = predice[3];
  dice[3] = predice[5];
  dice[4] = predice[2];
  dice[5] = predice[4];
}

void Left(int* dice){
  int predice[7];
  for(int i = 0 ; i < 7 ; i++) predice[i] = dice[i];
  dice[2] = predice[4];
  dice[3] = predice[2];
  dice[4] = predice[5];
  dice[5] = predice[3];
}

int main(){

  int dice[7];
  int n,score;

  while(1){

    for(int i = 1; i <= 7 ; i++) dice[i] = i; //initialize
    score = 1;

    scanf("%d",&n);

    if(n == 0) break;

    for(int i = 0 ; i < n ; i++){

      std::string s;
      cin >> s;

      if(s[0] == 'N') North(dice);
      else if(s[0] == 'E') East(dice);
      else if(s[0] == 'W') West(dice);
      else if(s[0] == 'S') South(dice);
      else if(s[0] == 'R') Right(dice);
      else if(s[0] == 'L') Left(dice);

      score += dice[1];

    }
    cout << score << endl;
  }
    return 0;
}

Measured memory_bytes: 1240
#include <iostream>

using namespace std;

class Dice {
    public:
    int face[6];
    Dice() {}
    void rotateX () {
        rotate(0, 1, 5, 4);
    }
    void rotateY () {
        rotate(0, 2, 5, 3);
    }
    void rotateZ () {
        rotate(1, 2, 4, 3);
    }
    void rotate (int a, int b, int c, int d) {
        int t = face[a];
        face[a] = face[b];
        face[b] = face[c];
        face[c] = face[d];
        face[d] = t;
    }
};

int getRight (Dice d, int face1, int face2) {
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 4; j++) {
            if (d.face[0] == face1 && d.face[1] == face2) return d.face[2];
            d.rotateZ();
        }
        if (i % 2 == 0) d.rotateY();
        else d.rotateX();
    }
    return -1;
}

int main () {
    Dice d;
    
    for (int i = 0; i < 6; i++) cin >> d.face[i];

    int q;
    cin >> q;

    int face1, face2;
    for (int i = 0; i < q; i++) {
        cin >> face1 >> face2;
        cout << getRight(d, face1, face2) << endl;
    }
}


Measured memory_bytes: 3084
N = input()
L = len(N)
K = int(input())
dp = [[[0 for k in range(2)]for j in range(K+1)]for i in range(L+1)]
dp[0][0][0] = 1
for i in range(L):
    p = int(N[i])
    ni = i+1
    for j in range(K+1):
        for k in range(2):
            for d in range(10):
                nk = k
                nj = j
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if nk == 0:
                    if d > p:
                        continue
                    if d < p:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k]
print(dp[L][K][0]+dp[L][K][1])


Measured memory_bytes: 41328
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int f(int N){
    while(N >= 10) N /= 10;
    return N;
}

int main()
{
    int N;
    cin >> N;
    
    Vvec<ll> a(9, vector<ll>(9, 0));
    for(int i=1; i<=N; i++){
        int j = i%10;
        int k = f(i);
        // cout << j << " " << k << endl;
        if(j != 0) a[j-1][k-1]++;
    }

    ll ans = 0;
    for(int i=0; i<9; i++){
        for(int j=0; j<9; j++){
            ans += a[i][j]*a[j][i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) 
{
  int a,b;
  scanf("%d %d",&a,&b);
  
  if(a>b){
    printf("a > b\n");
  }else if(a<b){
    printf("a < b\n");
  }else{
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
l=list(input())
a,b,c,d=map(str,l)
x=0
y=0
z=0
for i in range(2**3):
    if (i>>0)&1:
        x="+"
    else:
        x="-"
    if (i>>1)&1:
        y="+"
    else:
        y="-"
    if (i>>2)&1:
        z="+"
    else:
        z="-"
    ans=a+x+b+y+c+z+d
    if eval(ans)==7:
        print(ans+"=7")
        exit()


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

using namespace std;

const int N = 1e5+1;

int n;
int a[N], b[N];

int main(){
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n+1; ++i)
        cin >> a[i];
    long long ans = 0;
    for(int i = 0; i < n; ++i){
        cin >> b[i];
        int mn = min(a[i], b[i]);
        a[i] -= mn;
        b[i] -= mn;
        ans += mn;
        mn = min(a[i+1], b[i]);
        a[i+1] -= mn;
        b[i] -= mn;
        ans += mn;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1024
n, m = gets.split.map(&:to_i)
sum = 0
arr = gets.split.map do |x|
  t = x.to_i
  sum += t
  t
end
count = 0
n.times do |i|
  if arr[i] >= sum * (1.to_f / (4 * m))
    count += 1
  end
  if count == m
    puts "Yes"
    exit
  end
end
puts "No"


Measured memory_bytes: 1788
#include<bits/stdc++.h> 
using namespace std ;
typedef long long ll ;
#define int long long
const int maxn = 2e5 + 5 ;
int n ;
ll k , a[maxn] , b[maxn] ;
signed main()
{	
	//freopen("in.txt","r",stdin);
	scanf("%d%lld" , &n , &k) ;
	for(int i = 1 ; i <= n ; i ++) scanf("%lld" , &a[i]) ;
	sort(a + 1 , a + n + 1) ;
	int x = 0 , y = 0 , z = 0 ;
	for(int i = 1 ; i <= n ; i ++) 	 if(a[i] < 0) x ++ ;
		else if(a[i] > 0) y ++ ;
		else z ++ ;
	if(x * y >= k)
	{
		ll l = -1e18 , r = -1 , ans = -1 ;
		while(l <= r)
		{
			ll mid = (l + r) / 2 ;
			int p = n - y + 1 ;
			ll sum = 0 ;
			for(int i = 1 ; i <= x ; i ++)
			{
				while(a[i] * a[p] > mid && p <= n) p ++ ;
				if(p <= n && a[i] * a[p] <= mid)  sum += n - p + 1 ;
			}
			if(sum >= k) r = mid - 1 , ans = mid ;
			else l = mid + 1 ;
		}
		printf("%lld\n" , ans) ;
	}
	else if(x * y + x * z + y * z + z * (z - 1) / 2 >= k) printf("0\n") ;
	else
	{
		k -= x * y + x * z + y * z + z * (z - 1) / 2 ;
		ll l = 1 , r = 1e18 , ans = 1e18 ;
		while(l <= r)
		{
			ll mid = (l + r) / 2 ;
			int nxt = x ;
			ll sum = 0 ;
			for(int i = 1 ; i <= x ; i ++) 	b[i] = -a[x - i + 1] ;
			for(int i = 1 ; i <= x ; i ++)
			{
				if(b[i] * b[i] <= mid) sum -- ;
				while(nxt >= 1 && b[nxt] * b[i] > mid) nxt -- ;
				if(nxt >= i && b[nxt] * b[i] <= mid) sum += nxt - i + 1;
			}
			nxt = y ;
			for(int i = 1 ; i <= y ; i ++) b[i] = a[n - y + i] ;
			for(int i = 1 ; i <= y ; i ++)
			{
				if(b[i] * b[i] <= mid) sum -- ;
				while(nxt >= 1 && b[nxt] * b[i] > mid) nxt -- ;
				if(nxt >= i && b[nxt] * b[i] <= mid) sum += nxt - i + 1;
			}
			//assert(sum % 2 == 0) ;
			//cout << sum/2 << endl;
			if(sum >= k) r = mid - 1 , ans = mid ;
			else l = mid + 1 ;
		}
		printf("%lld\n" , ans) ;
	}
	return 0 ;
}



Measured memory_bytes: 3072
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
    ll N, A, B;
    cin >> N >> A >> B;

    if(A>B)cout<< "0" << endl;
    else if(A<B && N==1)cout<< "0" << endl;
    else if(A==B && N==1)cout<< "1" << endl;
    else cout << (N-2)*(B-A)+1 << endl;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	if (n & 1) {
		vvi ans(n);
		REP(i, n) {
			FOR(j, i + 1, n) {
				if (i != j && i + 1 + j + 1 != n) {
					ans[i].push_back(j);
				}
			}
		}
		int cnt = 0;
		REP(i, n)cnt += ans[i].size();
		cout << cnt << endl;
		REP(i, n)REP(j, ans[i].size()) {
			cout << i + 1 << " " << ans[i][j] + 1 << endl;
		}
	}
	else {
		vvi ans(n);
		REP(i, n) {
			FOR(j, i + 1, n) {
				if (i != j && i + 1 + j + 1 != n + 1) {
					ans[i].push_back(j);
				}
			}
		}
		int cnt = 0;
		REP(i, n)cnt += ans[i].size();
		cout << cnt << endl;
		REP(i, n)REP(j, ans[i].size()) {
			cout << i + 1 << " " << ans[i][j] + 1 << endl;
		}
	}
}

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

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}


#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main() 
{
    fast();
    ll n,k;
    cin>>n>>k;
    vi a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    sort(all(a));
    ll ans=0;
    for(ll i=0;i<k;i++)
        ans+=a[i];
    cout<<ans<<nl;
}


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

using namespace std;

const int num_sticks[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    vector<int> dp(N + 10, -1e9);
    dp.at(0) = 0;
    for (auto& a : A) {
        cin >> a;
        dp.at(num_sticks[a]) = 1;
    }
    for (int i = 1; i <= N; i++) {
        for (auto a : A) {
            int j = i + num_sticks[a];
            if (j <= N) {
                dp.at(j) = max(dp.at(j), dp.at(i) + 1);
            }
        }
    }
    sort(A.begin(), A.end(), greater<>());
    int remaining = N;
    while (remaining > 0) {
        for (auto a : A) {
            int sticks = num_sticks[a];
            if (sticks > remaining) {
                continue;
            } else if (dp.at(remaining) == dp.at(remaining - sticks) + 1) {
                cout << a;
                remaining -= sticks;
                break;
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
    
    Scanner sc = new Scanner(System.in);
    
    //変数a, bを宣言と入力を同時に行う。
    int a = sc.nextInt(), b = sc.nextInt();
    
    //大小関係の比較
    if(a > b) System.out.println("a > b");
    else if(a < b) System.out.println("a < b");
    else System.out.println("a == b");
    
    }
}

/*覚えよう！！

・関係を比較する：if(条件式)
　例：if(2 < 3) この条件は｢真（成立）｣　→　何か命令があれば実行する
　　　if(5 < 3) この条件は｢偽（不成立）｣　→　何か命令があれば実行しない
　　　
・比較の条件式：等しいか比較｢==｣、等しくないか比較｢!=｣ 
　　　　　　　　大きいか比較｢<｣、小さいか比較｢>｣
　　　　　　　　以上の比較｢<=｣、以下の比較｢>=｣


・else；ifの条件以外の場合に使用する。
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else System.out.println("傘を持って行かない");
　

・else if：詳細な場合分けしたいときに使用
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else if(雨 == 午後から降るかも) System.out.println("念のため傘を持って行く");
　　　else System.out.println("傘を持って行かない");

*/
 
 
/*前回の内容！！

・変数に計算結果を代入する：面積　＝　縦　×　横
　※計算は変数名でも数値でもいける
 
・四則演算：足し算｢＋｣、引き算｢－｣、掛け算｢＊｣、割り算｢／｣
　1 + 2 = 3;
　4 - 3 = 1;
　2 * 5 = 10;
　8 / 2 = 4;
 
・余りの計算：割り算の余り｢％｣
  5 % 3 = 2;
   
   
・printlnの複数表示：｢＋｣を使用
　例：println("Kobe" + "Kagikou"); = KobeKajikou
　　　println("明治 + 20 + "年"); = 明治20年　数値が入ってもOK！
 
 
 
・変数の宣言は｢型｣と｢変数名｣の２つ必要
　例：型＿変数名　→　int x;
　
・キーボードから入力するときは・・・｢ import java.util.Scanner; ｣ と ｢  Scanner sc = new Scanner(System.in) ; ｣が必要
 
・入力するとき・・・変数名 = sc.nextInt(); nextの後は型を書く、頭文字は大文字　
　※  scは変更しても大丈夫しかし全て変更後の文字に統一　例：nyuryoku
 
・println・・・画面に出力するときに使用
 
・文字列の表示・・・"〇〇〇の間に入力"ことが約束
 
*/


Measured memory_bytes: 26204
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x - a) < abs(x - b)) {
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }
    return 0;
}

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

typedef std::set<int>::iterator iter;
std::set<int> s[26];
const int maxn = 5e5 + 5;
char str[maxn];
int n, q;
int main(){
	scanf("%d",&n);
	scanf("%s",str+1);
	for(int i=1;i<=n;i++) s[str[i]-'a'].insert(i);
	for(int i=0;i<26;i++) s[i].insert(n+1);
	scanf("%d",&q);
	for(int i=1;i<=q;i++){
		int op;
		scanf("%d",&op);
		if(op == 1){
			int x; char y;
			scanf("%d",&x);
			y = getchar();
			while(y < 'a' || y > 'z') y = getchar();
			int tmp1 = str[x] - 'a', tmp2 = y - 'a';
			iter it = s[tmp1].lower_bound(x);
			s[tmp1].erase(it);
			s[tmp2].insert(x);
			str[x] = y;
		}
		else{
			int x, y, ret = 0;
			scanf("%d%d",&x,&y);
			for(int i=0;i<26;i++){
				iter it = s[i].lower_bound(x);
				if((*it) <= y) ret ++;
			}
			printf("%d\n", ret);
		}
	}
	return 0;
}

Measured memory_bytes: 26240
n,k,c=map(int,input().split())
s=input()

i=0
counter=0
fslist=[]

while counter < k:
	if s[i] == "o":
		fslist.append(i)
		i += c+1
		counter += 1
	else:
		i += 1

i=-1
counter=0
felist=[]

while counter < k:
	if s[i] == "o":
		felist.append(i+n)
		i -= c+1
		counter += 1
	else:
		i -= 1

felist.reverse()

for i in range(k):
	if fslist[i] == felist[i]:
		print(fslist[i]+1)



Measured memory_bytes: 25340
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  int Q;
  cin >> Q;
  ll B[Q],C[Q];
  map<ll,ll> mp;
  for (int i = 0; i < Q; i++) cin >> B[i] >> C[i];
  for (int i = 0; i < N; i++) {
    mp[A[i]]++;
  }
  ll res = 0;
  for (auto x : mp) {
    res += x.first * x.second;
  }
  for (int i = 0; i < Q; i++) {
    res += C[i] * mp[B[i]];
    res -= B[i] * mp[B[i]];
    mp[C[i]] += mp[B[i]];
    mp[B[i]] = 0;
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 11796
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(){
    int ans = 0;
    string s;
    cin >> s;
    if(s[0]=='1')ans++;
    if(s[1]=='1')ans++;
    if(s[2]=='1')ans++;
    cout << ans << endl;
}



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

int main() {
    int w, h, n, x, y, a;
    cin >> w >> h >> n;
    
    int minX = 0, maxX = w, minY = 0, maxY = h;
    rep(i, n) {
        cin >> x >> y >> a;
        if (a == 1) minX = max(minX, x);
        if (a == 2) maxX = min(maxX, x);
        if (a == 3) minY = max(minY, y);
        if (a == 4) maxY = min(maxY, y);
    }
    int width  = max(maxX - minX, 0);
    int height = max(maxY - minY, 0);
    cout << width * height << endl;
}

Measured memory_bytes: 256
#include<iostream>//入出力
#include<string>//文字列

using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int a[200000];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;cin>>n;
    REP(i,n)cin>>a[i];
    int b=0;REP(i,n)b^=a[i];
    string ans="";
    REP(i,n){ans+=to_string(a[i]^b);ans+=" ";}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7864
#include<stdio.h>
#include<string.h>
#define min(a,b) (a<=b?a:b)
#define max(a,b) (a<=b?b:a)
#define lim(a) (min(max(a,0),255))

int N,M,S[17],I[20005],i,j,k,R,e;
int dp[20005][256];
int main()
{
	for(;scanf("%d%d",&N,&M),N;)
	{
		for(i=0;i<M;i++)scanf("%d",&S[i]);
		for(i=1;i<=N;i++)scanf("%d",&I[i]);
		memset(dp,-1,sizeof(dp));
		dp[0][128]=0;
		for(i=0;i<=N;i++)
			for(j=0;j<=255;j++)
			{
				if(dp[i][j]!=-1)
					for(k=0;k<M;k++)
					{
						e=lim(j+S[k])-I[i+1];
						if(dp[i+1][lim(j+S[k])]==-1||dp[i+1][lim(j+S[k])]>dp[i][j]+e*e)
							dp[i+1][lim(j+S[k])]=dp[i][j]+e*e;
					}
			}
		for(i=0,R=-1;i<=255;i++)
			if(dp[N][i]!=-1&&(R==-1||R>dp[N][i]))
				R=dp[N][i];
		printf("%d\n",R);
	}
	return 0;
}

Measured memory_bytes: 20688
#include<stdio.h>
#include<math.h>
int a[105];
int main ()
{   long long  n,sum=0;
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
      {
	  scanf("%d",&a[i]);
	  sum+=a[i];
     }
    long long  y=floor(sum*1.0/n+0.5);
    //printf("y:%d:sum %d:",y,sum);
     long long  SUM=n*y*y-2*y*sum;
     for(int i=1;i<=n;i++)
        SUM+=a[i]*a[i];
        printf("%lld",SUM);
        return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 50;
const int mod = 1e9 + 7;
ll fac[maxn];
ll qpow(ll a,ll b){
    ll ans = 1;a %= mod;
    for(ll i = b;i;i >>= 1,a = a * a % mod)
        if(i & 1) ans = ans * a % mod;
    return ans % mod;
}
ll C(ll n,ll m){
    if(m > n || m < 0) return 0;
    ll s1 = fac[n],s2 = fac[n - m] * fac[m] %mod;
    return s1 * qpow(s2,mod - 2) % mod;
}
void init(){
    fac[0] = 1;
    for(int i = 1;i < maxn;i++)
    fac[i] = fac[i-1] * i % mod;
}
int main()
{
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    init();
    ll cnt = 1;
    ll ans = C(n, 0) * qpow(8, n) % mod;
    for(int i = 1;i <= n;i++){
        cnt *= 10;
        cnt %= mod;
        ans += (C(n, i) * qpow(8, n - i) % mod * 2);
        ans %= mod;
    }
    cout << (cnt + mod - ans) % mod << endl;
    return 0;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int N;
  cin >> N;
  int ans = N*N*N;
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
class Data:
    def __init__(self,n,p):
        self.name = str(n)
        self.price = int(p)
        self.recipe = []

    def minCost(self):
        if self.recipe == []:
            return self.price
        else:
            return min(self.price,
                       sum(list(map(lambda x: Data.minCost(index[x]), self.recipe))))
    def str(self):
        return "{}:{}:{}".format(self.name, self.price, self.recipe)

    
i_str = input()
n = int(i_str)
index = {}
while n != 0:
    for i in range(n):
        i_str = input()
        name,price = i_str.split()
        index[name] = Data(name,price)

    i_str = input()
    m = int(i_str)
    for i in range(m):
        i_str = input()
        data = i_str.split()    
        index[data[0]].recipe = data[2:]
            
    q = input()
    print(index[q].minCost())
       
    i_str = input()
    n = int(i_str)
    index = {}


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll m;cin >> m;
    ll ans=0;
    vl v;
    rep(i,m){
        ll a,n;cin >> a >>n;
        ll x;
        if(a==0){ans+=n-1;v.pb(0);}
        else{
            while(n){
                ll p=(10+a-1)/a;
                ans+=(p-1)*(n/p);
                rep(i,n%p)v.pb(a);
                ll v=a*p;
                v=v/10+v%10;
                ans+=n/p;
                n=n/p;
                a=v;
            }
        }
    }
    ll z=v[0];
    rep(i,v.size()-1){
        z+=v[i+1];
        ans++;
        if(z>9){
            z=z/10+z%10;
            ans++;
        }
    }
    cout << ans <<endl;
}


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

mod = 1000000007
set_non_exist_0 = pow(9, n, mod)
set_non_exist_9 = pow(9, n, mod)
set_non_exist_both = pow(8, n, mod)
print((pow(10, n, mod) - (set_non_exist_0 + set_non_exist_0 - set_non_exist_both)) % mod)

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

using namespace std;
int main() {
  string s;
  cin >> s;
  bool isNotEasy = false;
  for (int i = 0; i < 3; i++) {
    if (s[i] == s[i + 1]) {
      isNotEasy = true;
    }
  }
  cout << (isNotEasy ? "Bad" : "Good") << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  ArrayList<Integer>po=new ArrayList<>();
  for(int i=0;i<n;i++)po.add(sc.nextInt());
  for(int i=0;i<po.size()-1;i++){
  for(int j=i+1;j<po.size();j++){
  if(po.get(i).equals(po.get(j))){po.remove(j);j--;}
  }
  }
  System.out.println(po.size());
}}


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

int main() {
  int n;
  cin >>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  long long kotae=a[0];
  for(int i=1;i<n;i++){
    if(a[i]-a[i-1]>0)kotae+=a[i]-a[i-1];
  }
  cout<<kotae<<endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}


int main(void) {

	lli n;
	cin >> n;

	int bef_b = 100000000,sum = 0;

	for (int i = 0; i < n - 1; i++) {
		int b;
		cin >> b;

		sum += min(b,bef_b);


		bef_b = b;
	}
	sum += bef_b;

	cout << sum << endl;
	

	return 0;
}

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

using namespace std;

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

    if(N==25){
        cout<<"Christmas"<<endl;
    }else if(N==24){
        cout<<"Christmas Eve"<<endl;
    }else if(N==23){
        cout<<"Christmas Eve Eve"<<endl;
    }else if(N==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }


}

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

#define endl '\n'

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

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    long long resp = 0, p[a], q[b], r[c];
    vector<long long> sla;
    for (int i=0; i<a; i++) cin >> p[i];
    for (int i=0; i<b; i++) cin >> q[i];
    for (int i=0; i<c; i++) cin >> r[i];
    sort(p, p+a);
    sort(q, q+b);

    for (int i=a-1, ct=0; ct < x; i--, ct++) sla.push_back(p[i]);
    for (int i=b-1, ct=0; ct < y; i--, ct++) sla.push_back(q[i]);
    for (int i=0; i<c; i++) sla.push_back(r[i]);
    sort(sla.begin(), sla.end());

    int i = sla.size()-1;
    int ct = x+y;
    while(ct){
        ct--;
        resp += sla[i--];
    }
    cout << resp << endl;

}

Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

struct dat {
    int y, x, dist, rem, dir;
};

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

    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<bool>> G(H, vector<bool>(W));
    int x1, y1, x2, y2;
    cin >> y1 >> x1 >> y2 >> x2;
    x1--, y1--, x2--, y2--;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            char c;
            cin >> c;
            G[i][j] = (c == '.');
        }
    }

    vector<vector<vector<int>>> dist(H, vector<vector<int>>(W, vector<int>(4, INT_MAX)));
    deque<dat> que;
    dist[y1][x1][0] = 0;
    que.push_back({y1, x1, 0, 0});
    int dy[] = {0, 1, 0, -1};
    int dx[] = {1, 0, -1, 0};
    while (!que.empty()) {
        dat top = que.front();
        que.pop_front();
        if (dist[top.y][top.x][top.dir] < top.dist)
            continue;
        for (int i = 0; i < 4; ++i) {
            int ny = top.y + dy[i];
            int nx = top.x + dx[i];

            if (ny < 0 || ny >= H || nx < 0 || nx >= W)
                continue;
            if (!G[ny][nx])
                continue;

            if (top.rem > 0 && top.dir == i && dist[ny][nx][i] > top.dist) {
                dist[ny][nx][i] = top.dist;
                que.push_front({ny, nx, dist[ny][nx][i], top.rem - 1, i});
                continue;
            }

            if (dist[ny][nx][i] > top.dist + 1) {
                dist[ny][nx][i] = top.dist + 1;
                que.push_back({ny, nx, dist[ny][nx][i], K - 1, i});
            }
        }
    }

    int ans = INT_MAX;
    for (int i = 0; i < 4;++i)
        ans = min(ans, dist[y2][x2][i]);
    cout << (ans == INT_MAX ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 112756
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7
    #あいうえお
    N,M,C = LMIIS()
    B = LMIIS()
    A = [LMIIS() for _ in range(N)]

    ans = 0
    for i in range(N):
        dot = C
        for a,b in zip(A[i],B):
            dot += a*b
        if dot > 0:
            ans += 1
    print(ans)

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 64108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    ll n,m,ans=0;cin>>n>>m;
    vector<PL> v(n);
    rep(i,n){
        cin>>v[i].fi>>v[i].se;
    }
    sort(all(v));


    ll ind=0;
    priority_queue<ll> q;

    for(int i=1;i <= m;i++)
    {
        while(v[ind].fi==i && ind<n){
            q.push(v[ind].se);
            ind++;
        }
        
        if(!q.empty()){
            ans+=q.top();
            q.pop();
        }
    }
    cout<<ans<<endl;

}

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

void solve(){
    ll n, cnt = 0;
    cin >> n;
    for(ll i = 1; i <= n; i++)
        for(ll j = i; j <= n; j+=i) cnt += j;
    cout << cnt << endl;
}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //ll t;cin>>t;while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main() {
    long long int N;
    cin >> N;
    long long int l, r, pow;
    string ans;
    if(N>0) {
        l=0;
        r=1;
        pow=1;
        ans = "1";
        while(N>r) {
            l += pow;
            pow *= 4;
            r += pow;
        }
        bool flag=true;
        while(r-l>1) {
            long long int mid=(r+l)/2;
            if(mid<N) {
                if(flag) {
                    ans += '0';
                    flag=false;
                } else {
                    ans += '1';
                    flag=true;
                }
                l = mid;
            } else {
                if(flag) {
                    ans += '1';
                    flag=false;
                } else {
                    ans += '0';
                    flag=true;
                }
                r = mid;
            }
        }
    } else if (N==0) {
        cout << 0 << endl;
    } else {
        l=-2;
        r=0;
        pow=-2;
        ans = "1";
        while(N<l) {
            r += pow;
            pow *= 4;
            l += pow;
        }
        bool flag=true;
        while(r-l>1) {
            long long int mid=(r+l)/2;
            if(mid>N) {
                if(flag) {
                    ans += '0';
                    flag=false;
                } else {
                    ans += '1';
                    flag=true;
                }
                r = mid;
            } else {
                if(flag) {
                    ans += '1';
                    flag=false;
                } else {
                    ans += '0';
                    flag=true;
                }
                l = mid;
            }
        }
    }

    cout << ans << endl;

    return 0;
    
}

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

int main()
{
	int sx, sy;
	int tx, ty;

	cin >> sx >> sy >> tx >> ty;

	int dx = tx - sx;
	int dy = ty - sy;

	// first outbound
	for (int i = 0; i < dx; i++)
	{
		cout << "R";
	}
	for (int i = 0; i < dy; i++)
	{
		cout << "U";
	}

	// first inbound
	for (int i = 0; i < dx; i++)
	{
		cout << "L";
	}
	for (int i = 0; i < dy; i++)
	{
		cout << "D";
	}

	// second outbound
	cout << "D";
	for (int i = 0; i < dx + 1; i++)
	{
		cout << "R";
	}
	for (int i = 0; i < dy + 1; i++)
	{
		cout << "U";
	}
	cout << "L";

	// second inbound
	cout << "U";
	for (int i = 0; i < dx + 1; i++)
	{
		cout << "L";
	}
	for (int i = 0; i < dy + 1; i++)
	{
		cout << "D";
	}
	cout << "R";

	return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void DEBUG(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

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

template <typename T>
void ADD(T &a, const T &b) {
    T val = ((a % MOD) + (b % MOD)) % MOD;
    a = val;
}

template <typename T>
struct BIT {
    vector<T> array;
    T UNITY_SUM = 0;

    BIT(int n) { init(n); }

    void init(int n) {
        array.resize(n + 1);
        for (int i = 0; i < array.size(); i++) {
            array[i] = UNITY_SUM;
        }
    }

    void add(int a, T x) {
        a += 1;
        for (int i = a; i < array.size(); i += i & -i) {
            array[i] = array[i] + x;
        }
    }

    T _sum(int a) {
        a += 1;
        T res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) {
            res = res + array[i];
        }

        return res;
    }

    T sum(int a, int b) {
        return _sum(b - 1) - _sum(a - 1);
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    BIT<long long> bit(n);
    REP(i, q) {
        long long com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            bit.add(x - 1, y);
        } else {
            cout << bit.sum(x - 1, y) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

void Main(){
    ll N,K;
    cin >> N >> K;
    vll A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(),A.end());
    ll sum=0;
    for (ll i = 0; i < K; i++)
    {
        sum+=A[i];
    }
    cout << sum <<endl;
    
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a=0,b=0,c;
  cin>>c;
  rep(i,c){
    string d,e;
    cin>>d>>e;
    if(d<e){b+=3;}
    else if(d==e){a++;b++;}
    else {a+=3;}
  }
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 1212
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#define BIT(nr) (1ULL << (nr))
#define int long long
//#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;

int N;
void proc(int v[], int target, int count) {
    rep(i, N) {
        if (i == target) {
            v[i] -= N * count;
        }
        else {
            v[i] += count;
        }
    }
}

bool isEnd(vector<int>& v) {
    int N = v.size();
    bool end = true;
    for (int i : v) {
        if (i >= N) {
            end = false;
        }
    }
    return end;
}

int a[51];

signed main() {

    cin >> N;
    rep(i, N) {
        cin >> a[i];
    }

    int ans = 0;
    rep(i, 15000000) {
        rep(j, N) {
            if (a[j] >= N) {
                int count = a[j] / N;
                ans += count;
                a[j] -= count*N;
                rep(k, N) {
                    if (j != k) a[k] += count;
                }
            }
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
import sys
import math

cnt = 0

S = input()
S_list = list(S)

if S_list[0] == 'R':
    SB = 'R'
else:
    SB = 'S'

for s in S_list:
    if SB == s and s == 'R':
        cnt += 1
    elif s == 'R':
        cnt = 1

    SB = s

print(cnt)

Measured memory_bytes: 9040
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int calc(int N, vector<int> &A)
{
    int max = 1000000;
    vector<bool> div(max + 1, true);
    vector<bool> exist(max + 1, false);
    for (auto val : A)
    {
        if (exist[val])
        {
            div[val] = false;
            continue;
        }
        else
        {
            exist[val] = true;
        }

        if (!div[val])
        {
            continue;
        }

        for (int j = val * 2; j <= max; j += val)
        {
            div[j] = false;
        }
    }

    int ret = 0;
    for (auto val : A)
    {
        if (div[val])
        {
            ret++;
        }
    }

    return ret;    
}

int main()
{
    int N;
    cin >> N;
    vector<int> A;
    for (int i = 0; i < N; i++)
    {
        int num;
        cin >> num;
        A.push_back(num);
    }

    cout << calc(N, A) << endl;    
    return 0;
}

Measured memory_bytes: 4312
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,n,i,c,d,e,f,g,sum;
    sum=0;
      cin >> n >> a >> b;
  	for(i=1;i<=n;i++){
        c=i/10000;
		d=(i-10000*c)/1000;
        e=(i-10000*c-1000*d)/100;
        f=(i-10000*c-1000*d-100*e)/10;
        g=i-10000*c-1000*d-100*e-10*f;
        
        if(c+d+e+f+g>=a && c+d+e+f+g<=b){
          sum += i;
        }
    }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#include<cctype>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

int a, b, c, d;
int main(void) {
	cin >> a >> b >> c >> d;
	ct(max(a*b,c*d));
	return 0;
}

Measured memory_bytes: 256