akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main(){
    char s[100000];
    scanf("%s",s);

    int n =strlen(s);
    s[n] = 'e';
    int i=0;
    int j=1;
    int count;
    int a[100000];
    for(i=0;i<n;i++){
        a[i] = -1;
    }
    int fcheck=0,bcheck;
    int rcheck,lcheck;
    for(i=0;i<n;i++){
        if(s[i]=='R' && s[i+1]=='L'){ //ここが0じゃない
            rcheck = i;
            lcheck = i+1;
        }
        else if(s[i]=='L' && s[i+1]=='R' || s[i]=='L' && s[i+1]=='e'){//ここで切れる。
            
            bcheck = i;
            if((bcheck-fcheck+1) % 2 ==0 ){
            a[rcheck] = (bcheck-fcheck+1)/2;
            a[lcheck] = (bcheck-fcheck+1)/2;
            }
            else if((lcheck-fcheck)%2==0){ //Rが一個勝ち
                a[rcheck] = (bcheck-fcheck+1)/2;
                a[lcheck] = (bcheck-fcheck+1)/2+1;
            }
            else{
                a[rcheck] = (bcheck-fcheck+1)/2+1;
                a[lcheck] = (bcheck-fcheck+1)/2;
            }
            fcheck = i+1;
            if(i!=lcheck){
                a[i] =0;
            }
        } 
        else{
            a[i] = 0;
        }
    }
    for(i=0;i<n;i++){
        printf("%d ",a[i]);
    }
    return 0;
}

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

int main()
{
	long long n,d,s;
	cin>>n>>d;
	d=2*d+1;
	s=0;
	while(n>0)
	{
		n-=d;
		s++;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())

def getMN():
    return list(map(int, input().split()))

def getlist():
    return list(map(int, input().split()))

n = input()
MOD = 1000000007

dp0 = [0 for i in range(len(n))]
dpsmall = [0 for i in range(len(n))]
dp0[0] = 2
dpsmall[0] = 1

for ii, c in enumerate(n[1:]):
    # i starts from 0 -> 1
    i = ii + 1
    if c == "1":
        dpsmall[i] = (dpsmall[i-1] * 3 + dp0[i-1]) % MOD
        dp0[i] = (dp0[i-1] * 2) % MOD

    else:
        dpsmall[i] = (dpsmall[i-1] * 3 ) %MOD
        dp0[i] = dp0[i-1]

print((dp0[len(n)-1] + dpsmall[len(n)-1]) % MOD)






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

using namespace std;

int main(void) {
    string s, t;
    cin >> s >> t;
    bool ok = true;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != t[i]) {
            ok = false;
            break;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3628
N = gets.to_i

schedules = []
N.times do
  schedules << gets.chomp.split.join.to_i(2)
end

costs = []
N.times do
  costs << gets.chomp.split.map(&:to_i)
end

ans = -(1 << 30)
(1...(1 << 10)).each do |i|
  sum = 0
  N.times do |n|
    p = (schedules[n] & i).to_s(2).chars.count("1")
    sum += costs[n][p]
  end
  ans = [ans, sum].max
end

p ans

Measured memory_bytes: 1916
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,n,c,d;
int k1,k2;
string s;

int main(){
  cin >> n >> a;
  if(a>= (n%500)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
Graph g;
vector<int> dir;

void dfs(int now, int prev, int color){
	dir[now] = color;
	for(auto next:g[now]){
		if(next.first == prev)	continue;
		if(next.second & 1)	dfs(next.first, now, 1-color);
		else					dfs(next.first, now, color);
	}
}


int main(){
	int n; cin >> n;
	dir.assign(n,0);
	g.assign(n,vector<Edge>());
	for(int i=0;i<n-1;i++){
		int u,v;
		long long w;
		cin >> u >> v >> w;
		u--, v--;
		int b = w & 1;
		g[u].push_back(Edge(v,b));
		g[v].push_back(Edge(u,b));
	}
	dfs(0,-1,0);
	for(auto ans:dir)	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N, Y;
    cin >> N >> Y;

    REP(i, Y / 10000 + 1) {
        int res = Y - i * 10000;
        REP(j, res / 5000 + 1) {
            int res2 = res - j * 5000;
            int k = res2 / 1000;
            if (i + j + k == N) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


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

using namespace std;

char s[1005], t[1005];

int main() {

    scanf("%s%s", s, t);
    int n = strlen(s), m = strlen(t), ans = 1E9;
    for (int i = 0; i <= n - m; i++) {
        int cnt = 0;
        for (int j = 0; j < m; j++)
            if (s[i + j] != t[j])
                cnt++;
        ans = min(ans, cnt);
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 3824
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  long long n,m,d;cin>>n>>m>>d;
	//((n-d)*2)/(n*n)
	cout << fixed << setprecision(10) << (long double)(n-d)*(d?2:1)/(n*n)*(m-1) << endl;
}

Measured memory_bytes: 256
# Trick or Treat
import numpy
N, K = map(int, input().split())

sweets = [0] * N

for i in range(K):
    input()
    for j in list(map(int, input().split())):
        sweets[j - 1] += 1

print(len(list(filter(lambda x : x == 0, sweets))))

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

int main(){
  int r,g,b,n; cin>>r>>g>>b>>n;
  int count=0;
  for(int i=0;i<=n/r;i++){
    for(int j=0;j<=n/g;j++){
      if((n-i*r-j*g)%b==0){
        int k=(n-i*r-j*g)/b;
        if(i==0 && j==0 && k==0)
          continue;
        else if(k<0)
          continue;
        else
          count++;
      }
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3600
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
long double ans[700];
long double cnt[700];
int vertexs[700][700];
int n, m;
long double calc() {
	for (int q = n - 2; q >= 0; --q) {
		ans[q] = cnt[q];
		for (int j = q + 1; j < n; ++j) {
			ans[q] += ans[j] * vertexs[q][j];
		}
		ans[q] /= cnt[q];
	}
	return ans[0];
}
int target_au[700];
int main() {
	iostream::sync_with_stdio(false);
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		vertexs[a][b] = 1;
		cnt[a]++;
	}
	long double answer = calc();
	REP(i, n) {
		long double now_max = -1.0;
		for (int q = i + 1; q < n; ++q) {
			if (vertexs[i][q] == 1 && now_max < ans[q]) {
				now_max = ans[q];
				target_au[i] = q;
			}
		}
	}
	REP(i, n) {
		if (cnt[i] <= 1) continue;
		cnt[i] -= 1.0;
		for (int q = i+1; q < n; ++q) {
			if (target_au[i] != q) continue;
			vertexs[i][q] = 0;
			answer = min(answer, calc());
			vertexs[i][q] = 1;
		}
		cnt[i] += 1.0;
	}
	cout << fixed << setprecision(20);
	cout << answer << endl;
}


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

int main(){
    int a,b,c,i;
    cin >> a >> b;
    c = 0;
    for (i=2; i>0; i=i - 1){
        if (a >= b){
            c = c + a;
            a = a-1;
        }else if (b > a){
            c = c + b;
            b =b-1;
        }if (i == 1){
            break;
        }
    }    
    cout << c << endl;
return 0;
}

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

long long N, Q, K[100009], num_M, num_C, sum; string S;

void add(int pos) {
	if (pos == 0) num_M++;
	else { sum += num_M; num_C++; }
}
void lose(int pos) {
	if (pos == 0) { sum -= num_C; num_M--; }
	else num_C--;
}

long long query(long long pos) {
	num_M = 0; num_C = 0; sum = 0;
	for (int i = 0; i < pos; i++) {
		if (S[i] == 'M') add(0);
		if (S[i] == 'C') add(1);
	}
	long long ans = 0;
	for (int i = pos; i < N + pos; i++) {
		if (S[i - pos] == 'D') ans += sum;
		if (S[i - pos] == 'M') lose(0);
		if (S[i - pos] == 'C') lose(1);
		if (i < N) {
			if (S[i] == 'M') add(0);
			if (S[i] == 'C') add(1);
		}
	}
	return ans;
}

int main() {
	cin >> N >> S >> Q;
	for (int i = 0; i < Q; i++) cin >> K[i];

	for (int i = 0; i < Q; i++) {
		cout << query(K[i]) << endl;
	}
	return 0;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void dk()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    //dk();
    int n;
    cin >> n;
    int a[3];
    int dp[3];
    int t[3];
    memset(dp, 0, sizeof dp);
    memset(t, 0, sizeof t);
    for (int i = 0; i < n; i++)
    {
        cin >> a[0] >> a[1] >> a[2];
        for (int k = 0; k < 3; k++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (k != j)
                {
                    t[j] = max(t[j], dp[k] + a[j]);
                }
            }
        }
        dp[0] = t[0];
        dp[1] = t[1];
        dp[2] = t[2];
    }
    cout << max(dp[0], max(dp[1], dp[2]));
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        long Bombc = scan.nextInt();
        long Bombs = scan.nextInt();
        long exdmg = Bombc - Bombs;
        long mnstrhp[] = new long[num];
        long cpy[] = new long[num];

        for (int i = 0; i < num; i++) {
            mnstrhp[i] = scan.nextLong();
        }

        for(int i = 0;i<num;i++) {
            cpy[i] = mnstrhp[i];
        }

        int l = 0;
        int r = 1000000001;

        long  dmgcount = 0;

        while (l < r - 1) {

            for(int i = 0;i<num;i++){
                mnstrhp[i] = cpy[i];
            }

            int m = (l+r)/2;
            long o = m;


            for(int i = 0;i<num;i++){
                mnstrhp[i] -= (Bombs*m);
            }

            for(int i = 0;i<num;i++){
                if(mnstrhp[i]>0){
                    dmgcount = ((mnstrhp[i] % exdmg) ==0) ? (mnstrhp[i]/exdmg) : (mnstrhp[i]/exdmg) + 1;
                        o -= dmgcount;
                }
            }



            if (o>=0) {
                r = m;
            } else {
                l = m;
            }

        }
        System.out.println(r);
    }
}


Measured memory_bytes: 62720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S >> T;
  
  int hit, hitmax=0;
  for (int i=0; i<=(int)(S.size()-T.size()); i++) {
    hit = 0;
    for (int j=0; j<(int)T.size(); j++) {
      if (S.at(i+j) == T.at(j)) hit++;
    }
    if (hitmax < hit) hitmax = hit;
    if ((int)T.size() == hitmax) break;
  }
  cout << (int)T.size() - hitmax << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)








int main() {
    ll n, q;
    cin >> n >> q;
    vector<ll> a(n + 1), r1(n + 1), r2(n + 1);
    REP(i, n){
        cin >> a[i + 1];
        r1[i + 1] = r1[i] + a[i + 1];
        r2[i + 1] = a[i + 1];
        if(i > 0) r2[i + 1] += r2[i - 1];
    }
    
    REP(_, q){
        ll x;
        cin >> x;
        
        ll le = 0, ri = n;
        while(ri - le > 1){
            ll ce = (le + ri) / 2;
            if(a[ce] < x){
                le = ce;
            }
            else{
                ll takahashi = n - ce;
                ll aoki = ce - (lower_bound(a.begin(), a.end(), max(1LL, 2 * x - a[ce])) - a.begin()) + 1;
                if(takahashi >= aoki){
                    le = ce;
                }
                else{
                    ri = ce;
                }
            }
        }
        
        ll ans = r1[n] - r1[ri - 1];
        ll p = n - (n - ri + 1) * 2;
        if(p > 0) ans += r2[p];
        cout << ans << endl;
    }
}

Measured memory_bytes: 4096
import fractions
a,b,c,d=map(int,input().split())

def lcm(x, y):
    return (x*y)//fractions.gcd(x, y)

def div(a, b, x):
    if a%x!=0:
        return b//x-a//x
    else:
        return b//x-(a//x-1)

print(int(b-a+1-(div(a,b,c)+div(a,b,d)-div(a,b,lcm(c,d)))))

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

int main() {
  long n, tmp, _max = -1000000, _min = 1000000;
  double _sum = 0;
  cin >> n;
  while (n--) {
    cin >> tmp;
    if (_max < tmp) _max = tmp;
    if (_min > tmp) _min = tmp;
    _sum += tmp;
  }
  cout << _min << ' '
       << _max << ' '
       << fixed << setprecision(0) << _sum << endl;
  return 0;
}

Measured memory_bytes: 1240
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		long n = ir.nextLong();
		out.println((n - 1) * n / 2);
	}

	public static void main(String[] args) {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}

	static void tr(Object... o) {
		out.println(Arrays.deepToString(o));
	}
}


Measured memory_bytes: 22864
#include <bits/stdc++.h>
#define max 1000000
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define lli long long int
#define endl '\n'
#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
using namespace std;


int solution(lli a, lli b, lli c) {
	lli result = floor((a * c) / b) - a * floor(c / b);
	return result;
}

int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif
	lli a, b, n;
	cin >> a >> b >> n;

	lli result = solution(a, b, min(b - 1, n));
	cout << result << endl;

	cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m = t.length();
    vector<char> sd(n);
    vector<char> td(m);
    rep(i,n){
        sd[i]=s[i];
    }
    rep(i,m){
        td[i]=t[i];
    }
    sort(sd.begin(),sd.end());
    sort(td.begin(),td.end());
    reverse(td.begin(),td.end());
    string S,T;
    rep(i,n){
        S += sd[i];
    }
    rep(i,m){
        T += td[i];
    }
    //cout<<S<<endl;
    //cout<<T<<endl;
    if(S<T){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(Math.abs(x-a) < Math.abs(x-b)) {
      System.out.println("A");
    } else {
      System.out.println("B");
    }
  }
}

Measured memory_bytes: 22740
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;


//??????
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int p = 1; p < N; p++) cout << ", " << v[p]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()

// time, num
typedef pair<int, int> pii;

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int s, t;
		cin >> s >> t;

		vector<int> ans;
		if (s <= 5 && t <= 5) {
			if (s < t) {
				for (int j = s; j <= t; j++) ans.push_back(j);
			}
			else {
				for (int j = s; j >= t; j--) ans.push_back(j);
			}
		}
		if (s <= 5 && t > 5) {
			for (int j = s; j <= t; j++) ans.push_back(j);
		}
		if (s > 5 && t <= 5) {
			for (int j = s; j <= 9; j++) ans.push_back(j);
			for (int j = 5; j >= t; j--) ans.push_back(j);
		}
		if (s > 5 && t > 5) {
			if (s < t) {
				for (int j = s; j <= t; j++) ans.push_back(j);
			}
			else {
				for (int j = s; j <= 9; j++) ans.push_back(j);
				for (int j = 5; j >= 0; j--) ans.push_back(j);
				for (int j = 1; j <= t; j++) ans.push_back(j);
			}
		}

		cout << ans[0];
		for (int j = 1; j < ans.size(); j++) {
			cout << " " << ans[j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 2972
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
 
int32_t main() 
{
    IO;
    int n;
    cin>>n;
    int sum = 0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum += __gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<sum;
	return 0;
}


Measured memory_bytes: 3624
using System;

namespace ABC114
{
    class B
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            int res = int.MaxValue;
            for (int i = 0; i < S.Length - 2; i++)
            {
                string X = S.Substring(i, 3);
                res = Math.Min(res, Math.Abs(int.Parse("753") - int.Parse(X)));
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13140
#C
n,m=map(int,input().split())
f=False
ps=[]
AC=[0]*n
WA=[0]*n
for i in range(m):
    ps.append(list(input().split()))
for i in range(m):
    if ps[i][1]=='AC'and AC[int(ps[i][0])-1]==0:
        AC[int(ps[i][0])-1]=1
    if ps[i][1]=='WA'and AC[int(ps[i][0])-1]==0:
        WA[int(ps[i][0])-1]+=1
wasum=0
for i in range(n):
    if AC[i]==1:
        wasum+=WA[i]
print(sum(AC),wasum)

Measured memory_bytes: 27456
#include <iostream>
#include <cstring>
#include <map>
using namespace std;

#define SIZE (200000)
int uni_road[SIZE];
int uni_rail[SIZE];

int root(int a, bool type)
{
	if(type){
		if(uni_road[a] < 0) return a;
		return uni_road[a] = root(uni_road[a], type);
	}else{
		if(uni_rail[a] < 0) return a;
		return uni_rail[a] = root(uni_rail[a], type);
	}
}

bool connect(int a, int b, bool type)
{
	if(type){
		a = root(a, type);
		b = root(b, type);
		if(a == b) return false;
		if(uni_road[a] > uni_road[b]){
			a ^= b;
			b ^= a;
			a ^= b;
		}
		uni_road[a] = uni_road[a] + uni_road[b];
		uni_road[b] = a;
	}else{
		a = root(a, type);
		b = root(b, type);
		if(a == b) return false;
		if(uni_rail[a] > uni_rail[b]){
			a ^= b;
			b ^= a;
			a ^= b;
		}
		uni_rail[a] = uni_rail[a] + uni_rail[b];
		uni_rail[b] = a;
	}
	return true;
}

bool isConnected(int a, int b, bool type)
{
	return root(a, type) == root(b, type);
}

int size(int a, bool type)
{
	if(type){
		return -uni_road[root(a, type)];
	}else{
		return -uni_rail[root(a, type)];
	}
}

int main()
{
	memset(uni_road, -1, sizeof(uni_road));
	memset(uni_rail, -1, sizeof(uni_rail));
	int N, K, L;
	cin >> N >> K >> L;
	for(int i = 0; i < K; i++){
		int p, q;
		cin >> p >> q;
		connect(p, q, true);
	}
	for(int i = 0; i < L; i++){
		int r, s;
		cin >> r >> s;
		connect(r, s, false);
	}

	map<pair<int, int>, int> count;
	for(int i = 1; i <= N; i++){
		count[make_pair(root(i, true), root(i, false))]++;
	}
	for(int i = 1; i <= N; i++){
		cout << count[make_pair(root(i, true), root(i, false))];
		if(i != N) cout << " ";
	}
	cout << endl;


	return 0;
}

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

const ll INF = 1ll << 60;
ll MOD = 998244353;

int main()
{

    int n;
    cin >> n;
    vector<int> a(n + 1), b(n);

    REP(i, n + 1)
    cin >> a[i];
    REP(i, n)
    cin >> b[i];

    int c = 0;
    ll ans = 0;
    for (int i = 0; i < n; ++i)
    {
        int left = min(a[i], b[i]);
        ans += left;
        a[i] -= left;
        b[i] -= left;

        int right = min(a[i + 1], b[i]);

        ans += right;
        a[i + 1] -= right;
        b[i] -= right;
    }
    cout << ans;

    return 0;
}

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

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strNum = br.readLine();
		Integer num = Integer.parseInt(strNum);
		System.out.println(num*num*num);
	}

}

Measured memory_bytes: 16932
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

int result = 0;

void dfs(int N, int M, int Q, vector<int> A, map<int, vector<int> > m){
	if (A.size() == N+1) { // 最初に入っている [1] は除いた数列で判定するため
		int temp = 0;
		rep(i, Q) {
			int a = m[i][0];
			int b = m[i][1];
			int c = m[i][2];
			int d = m[i][3];
			if ((A[b] - A[a]) == c) temp += d; // Aは 1番目から参照しているため、添字は -1 しなくて良い
		}

		if (temp > result) result = temp;
		return;
	}
	A.push_back(A.back()); // 直前の数を push（A1 <= A2 <= A3 ... An のため）
	while(A.back() <= M) {
		dfs(N, M, Q, A, m);
		A.back()++;
	}
}

int main() {
	int N;
	cin >> N;
	int n = N;
	n %= 10;

	if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon" << endl;
	else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
	else if (n == 3) cout << "bon" << endl;
  return 0;
}


Measured memory_bytes: 3568
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

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


void solve() {
	int n;
	string s;
	cin>>n>>s;
	int open=0,ans=1;
	for(int i=0; i<2*n; i++) {
		if(s[i]=='B') {
			if(open&1) {
				ans=(ans*open)%mod;
				open--;
			} else {
				open++;
			}
		} else {
			if(open&1) {
				open++;
			} else {
				ans=(ans*open)%mod;
				open--;
			}
		}
	}
	if(open)
		ans=0;
	fr(i,1,n) {
		ans=(ans*i)%mod;
	}
	cout<<ans<<endl;


}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(2);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
//	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[100010][3];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[100010][3];
    rep(i, N) {
        rep(j, 3) cin >> a[i][j];
    }
    rep(i, 100010) rep(j, 3) dp[i][j] = -INF;
    rep(j, 3) dp[0][j] = 0;
    rep(i, N) {
        dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i][0];
        dp[i + 1][1] = max(dp[i][2], dp[i][0]) + a[i][1];
        dp[i + 1][2] = max(dp[i][0], dp[i][1]) + a[i][2];
    }
    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;


    return 0;
}


Measured memory_bytes: 5968
a,b = map(int,input().split())
if (a != 0) and (b != 0):
    print(str(int(a*(a-1)/2 + b*(b-1)/2)))
elif (a == 0) and (b == 0):
    print("0")      
elif (a == 0) and (b != 0):
    print(str(int(b*(b-1)/2)))
else:
    print(str(int(a*(a-1)/2)))

Measured memory_bytes: 9200
n = int(input())
a_s = [int(v) for v in input().split()]
b_s = [int(v) for v in input().split()]
c_s = [int(v) for v in input().split()]

ans = 0
prev_a = n
for i in range(n):
  a = a_s[i]
  b = b_s[a - 1]
  ans += b
  if prev_a + 1 == a:
    c = c_s[a - 2]
    ans += c
  prev_a = a
  
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++)
    {
        sum+=s[i]-'0';
    }
    if(sum%9==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
    cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
char s[110000];
int num[110000];
int main()
{
    int n,q;
    cin>>n>>q;
    int k=0;
    for(int i=1;i<=n;i++)
    {
        cin>>s[i];
        if(s[i]=='C'&&s[i-1]=='A')
            k++;
        num[i]=k;
    }
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        cout<<num[r]-num[l]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;
typedef vector<int> vecI;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}



int main() {
	int i, j, k;
	int N, M, K;

	cin >> N;
	cout << (N >= 30 ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 3588
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    if(s.substr(0, 4) == "YAKI"){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

int main()
{
  int a,b;
  cin>>a>>b;
  cout<<(a^b)<<endl;

  return 0;
}


Measured memory_bytes: 3552
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int X = sc.nextInt();
		int A = sc.nextInt();
		if (X < A) {
			System.out.println(0);
		} else if (X >= A) {
			System.out.println(10);
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main() {
    fastio
    int n, k;
    cin>>n>>k;
    int dp[n+1] = {0};
    for(int i = 0; i<k; ++i) {
        int d;
        cin>>d;
        while(d--) {
            int p;
            cin>>p;
            dp[p] = 1;
        }
    }

    int ans = 0;
    for(int i = 1; i<=n; ++i) {
        ans += dp[i]==0;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <map>
#include <string>
using namespace std;
int N, mx; string S; map<string, int> m;
int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) {
    cin >> S;
    if(mx < ++m[S]) mx = m[S];
  }
  for(auto itr = m.begin(); itr != m.end(); ++itr) {
    // mapはkeyで昇順
    if(itr->second == mx) cout << itr->first << endl;
  }
}

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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> X(N), Y(N);
    vector<char> U(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> X[i] >> Y[i] >> U[i];
    }
    vector<ll> dy = {0, 1, 0, -1}, dx = {1, 0, -1, 0};
    map<char,ll> md = {{'R',0},{'U',1},{'L',2},{'D',3}};
    vector<map<ll,vector<ll>>> m1(4);   // u, y/x, x/y
    vector<vector<map<ll,vector<ll>>>> m2(4,vector<map<ll,vector<ll>>>(2));   // u, +-, x+y/x-y, x
    for ( int i = 0; i < N; i++ ) {
        ll d = md[U[i]];
        if ( d % 2 == 0 ) m1[d][Y[i]].push_back(X[i]*10);
        else m1[d][X[i]].push_back(Y[i]*10);
        m2[d][0][X[i]+Y[i]].push_back(X[i]*10);
        m2[d][1][X[i]-Y[i]].push_back(X[i]*10);
    }
    for ( int d = 0; d < 4; d++ ) {
        for ( auto& p : m1[d]) {
            sort(p.second.begin(),p.second.end());
        }
        for ( int k = 0; k < 2; k++ ) {
            for ( auto& p : m2[d][k]) {
                sort(p.second.begin(),p.second.end());
            }
        }
    }
    ll INF = 1LL<<60;
    ll ans = INF;
    for ( int d = 0; d < 2; d++ ) {
        for ( auto& p : m1[d] ) {
            ll y = p.first;
            auto& v = p.second;
            if ( m1[d+2].count(y) > 0 ) {
                auto& vr = m1[d+2][y];
                for ( int i = 0; i < v.size(); i++ ) {
                    auto p1 = upper_bound(vr.begin(), vr.end(), v[i]);
                    if ( p1 != vr.end() ) ans = min(ans, (*p1-v[i])/2) ;
                }
            }
        }
    }
    vector<vector<int>> param = {{0,1,0},{0,3,1},{2,1,1},{2,3,0}}; // u1,u2,+-
    for ( int ii = 0; ii < param.size(); ii++ ) {
        int d1 = param[ii][0], d2 = param[ii][1], sg = param[ii][2];
        for ( auto& p : m2[d1][sg] ) {
            ll xy = p.first;
            auto& v = p.second;
            if ( m2[d2][sg].count(xy) ) {
                auto& vr = m2[d2][sg][xy];
                for ( int i = 0; i < v.size(); i++ ) {
                    if ( d1 == 0 ) {
                        auto p1 = upper_bound(vr.begin(), vr.end(), v[i]);
                        if ( p1 != vr.end() ) ans = min(ans, *p1-v[i]);
                    } else {
                        auto p1 = upper_bound(vr.rbegin(), vr.rend(), v[i], greater<>());
                        if ( p1 != vr.rend() ) ans = min(ans, v[i]-*p1);
                    }
                }
            }
        }
    }
    if ( ans == INF ) return -1;
    return ans;
}

int main() {
    auto ans = solve();
    if ( ans < 0 ) cout << "SAFE"  << "\n";
    else cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 72060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;string S;
	for(int i=0;i<n;i++){
		cin>>S;bool OK=true;
		for(int j=0;j<S.size()-1;j++){
			if(S[j]==S[j+1])OK=false;
		}
		if(OK==true)cout<<"Yes"<<endl;else cout<<"No"<<endl;
	}
}

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

d = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for _ in range(n):
    s = str(input())
    d[s] += 1

print('AC x {}\nWA x {}\nTLE x {}\nRE x {}\n'.format(d['AC'], d['WA'], d['TLE'], d['RE']))


Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

lint powmod(lint x, lint n){
    lint ret = 1;
    while(n > 0){
        if(n&1) ret *= x, ret %= mod, n -= 1;
        else x *= x, x %= mod, n >>= 1;
    }
    return ret;
}

int main(){
        int n;
        scanf("%d", &n);
        int a[n];
        rep(i, n) scanf("%d", &a[i]);
        map<lint, lint> mp;
        rep(i, n){
                int t=a[i];
                for(int j=2; j*j<=t; ++j)if(t%j==0){
                        lint cnt=0;
                        while(t%j==0){
                                t/=j;
                                ++cnt;
                        }
                        chmax(mp[j], cnt);
                }
                if(t>1) chmax(mp[t], 1LL);
        }
        lint lcm=1;
        for(auto p: mp) (lcm*=powmod(p.fi, p.se))%=mod;
        lint ans=0;
        rep(i, n) (ans+=lcm*powmod(a[i], mod-2)%mod)%=mod;
        printf("%lld\n", ans);
}

Measured memory_bytes: 896
#include<cstdio>
#include<queue>
#include<iostream>
#include<algorithm>
#include<list>
using namespace std;
list<int>li[1000];
list<int>::iterator it;
int main() {
	long long a,b,c;
	scanf("%lld%lld%lld", &a, &b,&c);
	printf("%lld %lld\n", min(min(a, b), c), max(max(a, b), c));
	
}




Measured memory_bytes: 3244
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, t;
  cin >> n >> t;
  int imos[100005];
  CLR(imos);
  FOR(i,0,n) {
    int l, r;
    cin >> l >> r;
    imos[l]++;
    imos[r]--;
  }
  int ans = imos[0];
  FOR(i,1,100005) {
    imos[i] += imos[i-1];
    ans = max(ans, imos[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628