akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

public class Main{
  public static void main(String[] args)throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    int numVote = Integer.parseInt(br.readLine());
    String data;
    Map<String, Integer> voteNumList = new HashMap<>();
    Set<String> nameSet = new HashSet<>();
    
    
    for(int i=0; i<numVote; i++){
      String name = br.readLine();
      if(voteNumList.containsKey(name)){
        voteNumList.put(name, voteNumList.get(name) + 1);
      } else {
        voteNumList.put(name, 1);
        nameSet.add(name);
      }
    }
    
    Set<String> result = new HashSet<>();
    int max = 0;
    
    for(String s: nameSet){
      int n = voteNumList.get(s);
      if(n > max){
        result = new HashSet<>();
        max = n;
        result.add(s);
      } else if (n == max){
        result.add(s);
      }
    }
  
    Object[] resultList = result.stream()
        .sorted()
        .toArray();
    
    StringBuilder str = new StringBuilder();
    for(Object s: resultList){
      str.append(s);
      str.append("\n");
    }
    System.out.println(str);
  }
}


Measured memory_bytes: 100408
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
char g[1010][1010];
int root[1010][1010];
const int mod = 1000000007;

int main(){
  int h,w;
  cin >> h >> w;
  rep(i,h){
    rep(j,w){
      cin >> g[i+1][j+1];
    }
  }
  rep(i,h+1){
    rep(j,w+1){
      if(i==0||j==0) g[i][j]=='#';
    }
  }
  root[1][1]=1;
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if(g[i-1][j]=='.') root[i][j]+=root[i-1][j];
      root[i][j]%=mod;
      if(g[i][j-1]=='.') root[i][j]+=root[i][j-1];
      root[i][j]%=mod;
    }
  }
  cout << root[h][w];
}

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

#define int long long int
#define main signed main()
#define bye return 0

#define rep(i, n) for (int i = 0; i < (n); i++)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define sum(v) accumulate(all(v), 0)
#define cinv(v, n) rep(i, n) cin >> v[i]
#define prec(n) fixed << setprecision(n)
#define odd(n) ((n) % 2)
#define even(n) (!((n) % 2))

#define INF 1e9
#define MOD (1e9 + 7)

#define pb push_back
#define mt make_tuple
#define fi first
#define se second
#define str string
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<str>

using namespace std;

main {
  bool n = 0, w = 0, s = 0, e = 0;
  str t;
  cin >> t;
  rep(i, t.size()) {
    n |= t[i] == 'N';
    w |= t[i] == 'W';
    s |= t[i] == 'S';
    e |= t[i] == 'E';
  }
  cout << (((n == s) && (e == w)) ? "Yes" : "No") << endl;
  bye;
}


Measured memory_bytes: 256
/**
 *      purpose : Tenka1 Programmer Beginner Contest B
 *      author  : kyomukyomupurin
 *      created : 2018-11-10 00:33:57
**/

#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define print(x) cout << (x) << '\n'

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; scanf("%d", &N);
    int a = -1; int b = 1e9 + 5;
    for (int i = 0; i < N; ++i) {
        int ta, tb;
        scanf("%d %d", &ta, &tb);
        a = max(a, ta); b = min(b, tb);
    }
    print(b + a);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



int chk(ll A,ll B,ll C,ll D) {
	if (A<B||D<B) return 0;
	if (B<=C+1) return 1;
	A %= B;
	if (C+1<=A) return 0;
	ll L = C+1-A, R = B-1-A, g = gcd(B,D);
	if (L%g) L = (L+g-1)/g*g;
	if (R%g) R = R/g*g;
	return L>R;
}

int main() {
	int t=rd();
	while (t--) {
		ll A,B,C,D;
		scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
		puts(chk(A,B,C,D)?"Yes":"No");
	}
}








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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n; cin >> n;
	vector<ll> F(n+1, 0);
	for (int i=1; i<n+1; i++) {
		for (int j=1; j*i<=n; j++) {
			F[i*j]++;
		}
	}
	ll ret = 0;
	for (int i=1; i<n+1; i++) {
		ret += i * F[i];
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 81404
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,K,ans = 0;
	cin >> N >> K;
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		if(a>=K)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int c[n];int s[n-1];int f[n];
  for(int i=0;i<n-1;i++){
    cin >> c[i]>> s[i]>> f[i];
  }
  long long int ti,t;
  for(int i=0;i<n-1;i++){
    ti=0;
    ti+=s[i]+c[i];
    for(int j=i+1;j<n-1;j++){
      if(ti>=s[j]){
    if((ti-s[j])%f[j]==0){
       ti+=c[j];
    }
    else{
      t=(ti-s[j])/f[j];
      ti+=(((t+1)*f[j])+s[j]-ti)+c[j];
    }
    }
    else{
       ti+=c[j]+(s[j]-ti);
    }
  }
    cout << ti<<endl;
  }
  cout << 0<<endl;
}


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

typedef long long ll;
typedef long double ld;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define rev_all( x ) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;
const int mod = 1e9 + 7;
const int inf = 1e12 + 5;
const long double PI = 3.141592653589793;

void solve(){
  int n, x, t;
  cin >> n >> x >> t;
  int ans = (n / x + int(n%x!=0))*t;
  cout << ans << endl;
  return;
}
signed main(){
  fast;
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 3648
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {

        Scanner sc = new Scanner(System.in);
        int n1 = sc.nextInt();
        int sp1[] = new int[n1];
        for (int i = 0; i < n1; i++) {
            sp1[i] = sc.nextInt();
        }
        int n2 = sc.nextInt();
        int sp2[] = new int[n1];
        for (int i = 0; i < n2; i++) {
            sp2[i] = sc.nextInt();
        }
        int sum = 0;
        for (int j = 0; j < n2; j++) {
            if ( Arrays.binarySearch(sp1, sp2[j])>0) {
                sum++;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 81576
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

inline void solve(){

  int n,a[1005];
  cin >> n;
  cinf(n,a);
  sort(a,a+n);
  cout <<abs(a[0]-a[n-1]) fin;



}


struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;
signed main(){solve();return 0;}


Measured memory_bytes: 256
from scipy.sparse.csgraph import dijkstra
import sys
def main():
	input = sys.stdin.readline

	n,x,y = map(int,input().split())

	route = [[0 for _ in range(n)]for _ in range(n)]
	for i in range(n-1):
		route[i][i+1] = 1

	route[x-1][y-1] = 1
	route[y-1][x-1] = 1
	route = tuple(route)
	#res = shortest_path(route, unweighted=False,directed=False)
	res = tuple(dijkstra(route, directed=False))

	ans = [0 for _ in range(n)]
	for i in range(n):
		for j in range(i,n):
			ans[int(res[i][j])] += 1

	for i in range(1,n):
		print(ans[i])
if __name__ == '__main__':
    main()

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

void solve(long long N, std::vector<long long> X)
{
    int min = INF;
    int point = 1;
    int sum = 0;
    rep(i, 101)
    {
        sum = 0;
        rep(j, N) { sum += (X[j] - point) * (X[j] - point); }
        if (min > sum)
        {
            min = sum;
        }
        point++;
    }
    cout << min << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> X(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
int main(void){
    long long a,b,x;
    cin>>a>>b;
    if(a*b%2==0) cout<<"Even"<<endl;
    else cout<<"Odd"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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



#define rep(p) for(int i=0;i<(p);i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;




int main() {
	
	
	int a, b;
	cin >> a >> b;
	if (a <= 9 && b <= 9)cout << a * b << endl;
	else cout << -1 << endl;


	return 0;
}


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

int main() {
	string S,T;
	bool b=0;
	cin >> S >> T;

	rep(i,S.size()-T.size()+1) {
		string p = S.substr(S.size()-T.size()-i, T.size());
		bool ok=1;

		rep(j,T.size()) {
			if(p.at(j) == '?')
				continue;
			if(p.at(j) != T.at(j)) {
				ok = 0;
				break;
			}
		}

		if(ok) {
			rep(j,T.size())
				S.at(S.size()-T.size()-i+j) = T.at(j);
			b = 1;
			break;
		}
	}

	if(b) {
		rep(i,S.size())
			if(S.at(i) == '?')
				S.at(i) = 'a';
		cout << S;
	} else
		cout << "UNRESTORABLE";
	cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
  int i, n, s[1000];
  double x, a;

  while(1){
    scanf("%d", &n);
    if(n == 0){
      break;
    }
    x = 0;
    a = 0;
    for(i = 0; i < n; i++){
      scanf("%d", &s[i]);
      x += s[i];
    }
    x /= n;
    for(i = 0; i < n; i++){
      a += (s[i]-x) * (s[i]-x);
    }
    a = sqrt(a/n);
    printf("%f\n", a);
  }
  return 0;
}

Measured memory_bytes: 636
//最後に1数だけ残るのはそれが偶数の場合のみだと試せばわかる
//例えば最後に3だけ残せない n >= 2
//奇数は全てペアになれば良い
#include<iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n];
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX
#include <iomanip>
 
using namespace std;
int MOD = 998244353;
const int mxN = 2e5 + 9;
 
int ar[mxN];
 
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int R;
	cin >> R;
	double ans = 2*3.14159265358979323846*R;
	cout << fixed;
	cout << setprecision(10);
	cout << ans;
 
 
}

Measured memory_bytes: 3780
#include <stdio.h>

int main(void){
    int H, W;
    while (1){
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0){
            break;
        }
        else{
            char S[H][W];
            int i, j;
            for (i = 0; i < H; i++){
                for (j = 0; j < W; j++){
                    if (i == 0 || i == H - 1 || j == 0 || j == W - 1){
                        S[i][j] = '#';
                    }
                    else{
                        S[i][j] = '.';
                    }
                    printf("%c", S[i][j]);
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 588
n,m = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(m)]
#入力
AB.reverse()
ans = [0]*(m+1)
ans[m] = n*(n-1)//2
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.count = [1]* (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.count[y] += self.count[x]
            self.count[x] = 0
        else:
            self.par[y] = x
            self.count[x] += self.count[y]
            self.count[y] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 属している集合の要素数
    def search(self,x):
        q = UnionFind.find(self,x)
        return self.count[q]

uf = UnionFind(n)

for i in range(m):
    a = AB[i][0]
    b = AB[i][1]
    #print(a,b)
    if uf.same_check(a,b):
        ans[m-i-1] = ans[m-i]
        continue
    else:
        s = uf.search(a)
        t = uf.search(b)
        #print(s,t)
        uf.union(a,b)
        ans[m-i-1] = ans[m-i] + s*(s-1)//2 + t*(t-1)//2 - (s+t)*(s+t-1)//2
for i in range(1,m+1):
    print(ans[i])

Measured memory_bytes: 120920
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,k,t,d,ret,yum,kind;
vi neta;
priority_queue<pi,vpi,greater<pi>> eat;
priority_queue<pi> sug;

signed main(){
    I(n); I(k);
    neta.resize(n+1);

    REP(i,n){
        I(t); I(d);
        sug.emplace(d,t);
    }
    REP(i,k){
        auto p = sug.top();
        sug.pop();
        eat.push(p);
        yum += p.first;
        if(!neta[p.second]) kind++;
        neta[p.second]++;
    }
    ret = max(ret, yum + kind*kind);
    while( !sug.empty() && !eat.empty() ){
        auto p = sug.top();
        sug.pop();
        if (neta[p.second]) continue;
        yum += p.first;
        neta[p.second]++;
        kind++;

        auto q = eat.top();
        eat.pop();
        while ( neta[q.second] == 1 && !eat.empty() ) {
            q = eat.top();
            eat.pop();
        }
        if (eat.empty() && neta[q.second] == 1 ) break;
        neta[q.second]--;
        yum -= q.first;

        ret = max(ret, yum + kind*kind);
    }
    cout << ret << endl;
}


Measured memory_bytes: 5616
from collections import deque
n, q = input().rstrip().split(" ")
n = int(n)
q = int(q)

processes = deque()
now_time = 0

for i in range(n):
    name, time = input().rstrip().split(" ")
    time = int(time)
    processes.append([name, time])

while len(processes) >= 1:
    current_processes = processes.popleft()
    if current_processes[1] > q:
        current_processes[1] -= q
        now_time += q
        processes.append(current_processes)
    else:
        now_time += current_processes[1]
        print(current_processes[0] + " " + str(now_time))
        

    


Measured memory_bytes: 13300
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){

    string s;
    cin >> s;
    int cnt=0;
    vector<char> str;

    for(int j=s.size()-1; j>=0; j--) str.pb(s[j]); //逆順で受け取る

    while(str.size() >= 5){
        if(str[0] == 'e' && str[1] == 's' && str[2] == 'a' && str[3] == 'r' && str[4] == 'e'){
            //erase
            for(int i=0; i<5; i++) str.erase(str.begin());
        }else if(str[0] == 'm' && str[1] == 'a' && str[2] == 'e' && str[3] == 'r' && str[4] == 'd'){
            //dream
            for(int i=0; i<5; i++) str.erase(str.begin());
        }else if(str[0] == 'r' && str[1] == 'e' && str[2] == 's' && str[3] == 'a' && str[4] == 'r' && str[5] == 'e'){
            //eraser
            for(int i=0; i<6; i++) str.erase(str.begin());
        }else if(str[0] == 'r' && str[1] == 'e' && str[2] == 'm' && str[3] == 'a' && str[4] == 'e' && str[5] == 'r' && str[6] == 'd'){
            //dreamer
            for(int i=0; i<7; i++) str.erase(str.begin());
        }else{
            break;
        }
    }

    bool flag = false;
    if(str.size() == 0) flag = true;

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	string S;
	cin >> S;
	int K;
	cin >> K;
	int N = S.size();

	if (S[0] != S[N - 1]) {
		int mae = 0;
		int kotae = 0;
		rep(i, N) {
			if (mae == S[i]) {
				kotae++;
				mae = 0;
			}
			else mae = S[i];
		}
		co((ll)kotae * K);
	}
	else {
		int mae = 0;
		int kotae = 0;
		rep(i, N) {
			if (mae == S[i]) {
				kotae++;
				mae = 0;
			}
			else mae = S[i];
		}

		if (mae == 0) {
			co((ll)kotae* K);
		}
		else {
			int kotae2 = 0;
			rep(i, N) {
				if (mae == S[i]) {
					kotae2++;
					mae = 0;
				}
				else mae = S[i];
			}
			cesp(kotae); ce(kotae2);


			if (mae == 0) {
				co((ll)kotae * ((K + 1) / 2) + (ll)kotae2 * (K / 2));
			}
			else {
				co((ll)kotae + (ll)kotae2 * (K - 1));
			}
		}
	}



	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);
int find(vector<int>& grp, int x) {
    if (grp[x] != x)
        return grp[x] = find(grp, grp[x]);
    return x;
}
int main() {
    int n, m, k, a, b;
    cin >> n >> m >> k;
    set<pair<int, int>> conn;
    set<pair<int, int>> ban;
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        if (a > b) swap(a, b);
        conn.insert({a, b});
    }
    for(int i = 0; i < k; i++) {
        cin >> a >> b;
        if (a > b) swap(a, b);
        ban.insert({a, b});
    }
    vector<int> grp(n+1, -1);
    for(int i = 0; i <= n; i++)
        grp[i] = i;
    for(auto p: conn) {
        int r1 = find(grp, p.first);
        int r2 = find(grp, p.second);
        if (r1 != r2)
            grp[r1] = grp[r2] = min(r1, r2);
    }
    // cout << "hello";
    unordered_map<int, int> cnt;
    for(int i = 1; i <= n; i++) {
        cnt[find(grp, i)] += 1;
    }
    vector<int> ans(n+1, 0);
    for(int i = 1; i <= n; i++) {
        ans[i] = cnt[find(grp, i)];
    }
    for(auto p: conn) {
        ans[p.first] -= 1;
        ans[p.second] -= 1;
    }
    for(auto p: ban) {
        int r1 = find(grp, p.first);
        int r2 = find(grp, p.second);
        if (r1 == r2) {
            ans[p.first] -= 1;
            ans[p.second] -= 1;
        }
    }
    for(int i = 1; i <= n; i++)
        cout << ans[i]-1 << " ";
    cout << endl;
    return 0;
}




Measured memory_bytes: 14756
use proconio::{input, fastout, marker::Chars};

#[fastout]
fn main() {
    input! {
        s: Chars,
    }

    let count = s.iter().filter(|&&c| c == 'R').count();

    if count == 2 && s[1] != 'R' {
        println!("1");
    } else {
        println!("{}", count);
    }
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long X){
    if(X >= 30) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3764
#include<iostream>
using namespace std;
int h,w,n;
int a[1002][1002],b[1002][1002]={0};

pair<int,int> walk(int x,int y){
	if(a[x][y]==0)x++;
	else y++;
	if(x<h&&y<w)return walk(x,y);
	pair<int,int>ret; ret.first=x+1; ret.second=y+1; return ret;
}

int main(){
while(1){
	scanf("%d%d%d",&h,&w,&n);
	if(h==0)break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			scanf("%d",&a[i][j]);
			b[i][j]=0;
		}
	}
	b[0][0]=n-1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			b[i][j+1]+=b[i][j]/2;
			b[i+1][j]+=b[i][j]/2;
			if(b[i][j]%2==1){
				if(a[i][j]==0)b[i+1][j]++;
				else b[i][j+1]++;
			}
			a[i][j]+=b[i][j];
			a[i][j]%=2;
		}
	}
	pair<int,int> ret=walk(0,0);
	printf("%d %d\n",ret.first,ret.second);
}
}

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

int main(){
  int a,b,m,mina,minb,ans;
  mina=1000000;
  minb=1000000;

  
  cin>>a>>b>>m;
  int A[a],B[b];
  
  rep(i,a){cin>>A[i]; mina=min(A[i],mina);}
  rep(i,b){cin>>B[i]; minb=min(B[i],minb);}
  ans=mina+minb;

  int x,y,c;
  rep(i,m){
    cin>>x>>y>>c;
    ans=min(ans,A[x-1]+B[y-1]-c);
  }
  cout<<ans; 
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
			Scanner sc = new Scanner(System.in);
			int A = sc.nextInt();
			int B = sc.nextInt();
			int C = sc.nextInt();
			
			if(A <= C && B >= C){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int x,y;cin>>x>>y;
  int res=x;
  if(x%y==0)res=-1;
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;

long long MOD = 1000000007;
long long dp[100005][4];

int c[10][10];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int H, W;
	cin >> H >> W;

	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> c[i][j];
		}
	}

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

	int ans = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int a;
			cin >> a;
			if (a != -1) {
				ans += c[a][1];
			}
		}
	}
	cout << ans << endl;
}


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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

ll point[8][2];

int main()
{
	fastio;

	int n;
	cin >> n;

	ll x, y;
	cin >> x >> y;

	ll min1 = x+y;
	ll max1 = x+y;
	ll min2 = x-y;
	ll max2 = x-y;

	for (int i = 1; i < n; ++i)
	{
		cin >> x >> y;
		min1 = min(min1, x+y);
		max1 = max(max1, x+y);
		min2 = min(min2, x-y);
		max2 = max(max2, x-y);
	}
	cout << max(max1 - min1, max2 - min2) << '\n';

	/*
	ll x, y;
	cin >> x >> y;
	for (int i = 0; i < 8; ++i)
	{
		point[i][0] = x;
		point[i][1] = y;
	}

	for (int i = 1; i < n; ++i)
	{
		cin >> x >> y;

		if (x < point[0][0] || (x == point[0][0] && y < point[0][1])) point[0][0] = x, point[0][1] = y;
		if (x < point[1][0] || (x == point[1][0] && y > point[1][1])) point[1][0] = x, point[1][1] = y;
		if (x > point[2][0] || (x == point[2][0] && y < point[2][1])) point[2][0] = x, point[2][1] = y;
		if (x > point[3][0] || (x == point[3][0] && y > point[3][1])) point[3][0] = x, point[3][1] = y;

		if (y < point[4][1] || (y == point[4][1] && x < point[4][0])) point[4][0] = x, point[4][1] = y;
		if (y < point[5][1] || (y == point[5][1] && x > point[5][0])) point[5][0] = x, point[5][1] = y;
		if (y > point[6][1] || (y == point[6][1] && x < point[6][0])) point[6][0] = x, point[6][1] = y;
		if (y > point[7][1] || (y == point[7][1] && x > point[7][0])) point[7][0] = x, point[7][1] = y;
	}

	ll res = 0;
	for (int i = 0; i < 8; ++i)
		for (int j = i+1; j < 8; ++j)
	{
		res = max(res, abs(point[i][0] - point[j][0]) + abs(point[i][1] - point[j][1]));
	}
	cout << res << '\n';
	*/

	return 0;
}


Measured memory_bytes: 3616
n, m = map(int, input().split())
valists = [10**9 for _ in range(1<<n)]
valists[0] = 0
for i in range(m):
	values, b = map(int, input().split())
	c = list(map(int, input().split()))
	cnt = 0
	for j in range(b):
		cnt += 2**(c[j]-1)
	for j in range(len(valists)):
		x = j|cnt
		valists[x] = min(valists[x], valists[j]+values)
		#print(j, cnt, x, valists)

#print(valists)
ans = valists[2**n-1]
if ans != 10**9:
	print(ans)
else:
	print(-1)

Measured memory_bytes: 3188
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
using namespace std;
using Data = pair<long long, vector<int> >;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;
typedef long long int ll;
const int mod = 1e9+7;

int main() {
    int m,k; cin >> m >> k;

    if(k>=pow(2,m)){
        pl(-1)
        return 0;
    }

    if(m==1){
        if(k==1){
            pl(-1)
        } else {
            pl("0 0 1 1")
        }
        return 0;
    }

    p(k)
    for(int i=0;i<pow(2,m);i++){
        if(i == k) continue;
        p(" ")
        p(i)
    } 
    p(" ")
    p(k)
    for(int i=pow(2,m)-1;i>=0;i--){
        if(i == k) continue;
        p(" ")
        p(i)
    }
    pl("")
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define reps(i, s, n) for(int i = (s); i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, s, n) for(int i = (n) - 1; i >= (s); i--)
#define INF ~(1 << 31)
#define INFL ~(1LL << 63)

int main()
{
    int K;
    cin >> K;
    rep(i, K){
        cout << "ACL";
    }
    cout << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
 
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
 
int run_test(){
    ll a;
    cin >> a;
    string s;
    cin >> s;
    ll b = (s[0] -  '0') * 100;
    ll d = (s[2] - '0')*10 + (s[3] - '0');
    b +=d;
    ll c = a * b;
    cout << c / 100;
    return 0;
}
 
int main(){
    FAST;
    ll t;
    t = 1;
 
    while(t--){
        run_test();
    }
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

using namespace std;

int main() {

	int m, d, cnt = 0;

	cin >> m >> d;

	int d10, d1;

	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= d; j++) {
			d10 = j / 10;
			d1 = j % 10;

			if (d10 < 2 || d1 < 2) continue;

			if (d10 * d1 == i) {
				cnt++;
				//cout << j << " " << d10 << " " << d1 << " " << i << endl;
			}
		}
	} 

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
N = input()
_list = input().split(" ")
_list = [int(x) for x in _list]
even = [x for x in _list if x % 2==0]
answer = []
for x in even:
    if x % 3 == 0 or x % 5 == 0:
        answer.append(True)
if len(even) == len(answer):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(solve(a, b));

        sc.close();
    }

    static int solve(int a, int b) {
        return (b - a + 1) * (b - a) / 2 - b;
    }
}

Measured memory_bytes: 22608
n = int(input())
l = list(map(int, input().split()))

max_suffix = 0
for i in range(n):
    if l[max_suffix] < l[i]: max_suffix = i

total = 0
for i in range(n):
    if i == max_suffix: continue
    else: total += l[i]
    
if total > l[max_suffix]: print("Yes")
else: print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define N 300005
using namespace std;
int a[N],n;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	ll sum=a[1],xro=a[1],ans=0;
	for (int i=1,j=2;i<=n;i++){
		while ((sum+a[j]==(xro xor a[j]))&&j<=n) sum+=a[j],xro=xro xor a[j],j++;
		ans+=j-i;
		sum-=a[i],xro=xro xor a[i];
		//printf("%d %d\n",i,j);
	}
	printf("%lld\n",ans);
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Enum various numbers
//-------------------------------------------------
namespace Enum
{
    using fint = ::std::int_fast64_t;
    //素因数分解(素因数列挙)
    ::std::map<fint,int> factor(fint n)
    {
        ::std::map<fint,int> ret;
        for(fint i=2; i*i<=n; i++){
            while(n%i==0){
                ret[i]++;
                n/=i;
            }
        }
        if (n!=1) ret[n]++;
        return ret;
    }
    //約数列挙
    ::std::vector<fint> divisor(fint n)
    {
        ::std::vector<fint> ret;
        for(fint i=1; i*i<=n; i++){
            if (n%i==0){
                ret.push_back(i);
                if (i*i!=n) ret.push_back(n/i);
            }
        }
        return ret;
    }
    //商列挙(割る最小の数と商のペア)
    ::std::vector<::std::pair<fint,fint> > quotient(fint n)
    {
        ::std::vector<::std::pair<fint,fint> > ret;
        fint i=0;
        for(i=1; i*i<=n; i++){
            ret.emplace_back(i,n/i);
        }
        for(; i<=n; i++){
            fint d = n/i;
            ret.emplace_back(i,d);
            i+=(n-d*i)/d;
        }
        return ret;
    }
    //素数判定(おまけ)
    bool isprime(fint n)
    {
        for(fint i=2; i*i<=n; i++){
            if (n%i==0) return false;
        }
        return true;
    }
}

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N; cin>>N;
    auto div = Enum::divisor(N);
    int ans=10;
    for(auto d:div){
        ll op = N/d;
        string s = to_string(d);
        string t = to_string(op);
        chmin(ans, (int)max(s.size(),t.size()));
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())

t = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    t[L][R] += 1

for i in range(N + 1):
    for j in range(N):
        t[i][j + 1] += t[i][j]

result = []
for _ in range(Q):
    p, q = map(int, input().split())
    result.append(sum(t[i][q] - t[i][i - 1] for i in range(p, q + 1)))
print('\n'.join(str(v) for v in result))


Measured memory_bytes: 84056
#include<iostream>
#include<queue>
#include<utility>

typedef std::pair<int, int> P;

int W, H;
// field[y][x]
bool field[102][102];
bool visited[102][102];

int bfs()
{
	static const int dx[2][6] = { { -1, 0, 1, 0, -1, -1 }, { 0, 1, 1, 1, 0, -1 } }, 
					 dy[2][6] = { { -1, -1, 0, 1, 1, 0 }, { -1, -1, 0, 1, 1, 0 } };
	int ret = 0;

	std::queue<P> que;
	que.push( P( 0, 0 ) );

	while( !que.empty() )
	{
		P p = que.front(); que.pop();
		int x = p.first, y = p.second;

		if( visited[y][x] )
			continue;

		visited[y][x] = true;

		for( int d = 0; d != 6; ++d )
		{
			int nx = x + dx[y & 1][d], ny = y + dy[y & 1][d];

			if( nx < 0 || nx > W + 1 || ny < 0 || ny > H + 1 || visited[ny][nx] )
				continue;

			if( field[ny][nx] )
				++ret;
			else
				que.push( P( nx, ny ) );
		}
	}

	return ret;
}

int main()
{
	std::cin >> W >> H;
	for( int i = 1; i <= H; ++i )
		for( int j = 1; j <= W; ++j )
			std::cin >> field[i][j];

	std::cout << bfs() << std::endl;

	return 0;
}

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

const ll modulo = 1000000007;
const int inf = 0x3f3f3f3f;
const ll ll_inf = 0x3f3f3f3f3f3f3f3f;

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

    string s; cin >> s;
    vector<ll> vals;
    bool increasing = s[0] == '<';
    ll runningval = 1;
    for(int i = 1; i < s.size(); i++) {
        if((s[i] == '<') == increasing) {
            runningval++;
        } else {
            if(increasing) vals.push_back(runningval);
            else vals.push_back(-runningval);
            runningval = 1;
            increasing = !increasing;
        }
    }
    if(increasing) vals.push_back(runningval);
    else vals.push_back(-runningval);

    ll total = 0;
    int start = 0;
    if(vals[0] < 0) {
        total += ((- vals[0]) * (-vals[0] + 1)) / 2;
        start = 1;
    }
    for(int i = start; i < vals.size(); i+=2) {
        if(i == vals.size() - 1) {
            total += ((vals[i]) * (vals[i] + 1)) / 2;
        } else {
            ll other = -vals[i + 1];
            ll cur = vals[i];
            if(other >= cur) {
                total += (other * (other - 1)) / 2;
                total += ((cur * (cur + 1))) / 2;
                total += other - cur;
            } else {
                total += ((cur) * (cur + 1)) / 2;
                total += (other * (other - 1)) / 2;
            }
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define UN unsigned int
#define mod 1000000007
#define F first
#define S second
#define mk make_pair
#define B(v) v.begin(), v.end()
#define BS binary_search
#define int ll
main()
{
	//cout<<'1'-48<<endl;
	string s;
	cin>>s;
	int n=(int)s.size();
	n--;
	int re=0;
	for(int i=0;i<(1<<n);i++)
	{
		int aa=0;
		int qq=s[0]-48;
		for(int j=0;j<n;j++)
		{
			if(!(i&(1<<j)))
			{
				aa+=qq;
				qq=s[j+1]-48;
			}
			else
			{
				int qw=s[j+1]-48;
				qq=(qq*10)+qw;
			}
		}
		aa+=qq;
		re+=aa;
		//cout<<aa<<endl;
	}
	cout<<re<<endl;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			String inp = br.readLine();
			String chrp[] = inp.split(" ");
			int a = Integer.parseInt(chrp[0]);
			int b = Integer.parseInt(chrp[1]);
			String u = br.readLine();
			if (chr[0].equals(u)) {
				a--;
			} else {
				b--;
			}
			System.out.println(a + " " + b);
		}
	}
}

Measured memory_bytes: 25392
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using Int = int64_t;
using pint = pair<Int, Int>;
using vint = vector<Int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<class T>void put_double(T a){cout<<setprecision(12);cout<<a<<"\n";}
template<class T,class U>void put_pair(pair<T,U>p){cout<<p.first<<" "<<p.second<< endl;}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);


int n;
vint a;
vector<vpint> xys;

bool judge(const vint &v) {
    vint res(n, -1);
    rep(i, n) {
        if(v[i] > 0) {
            rfor(p, xys[i]) {
                int x = p.first, y = p.second;
                if(res[x] == -1) res[x] = y;
                else if(res[x] != y) {
                    return false;
                }
            }
        }
    }
    rep(i, n) {
        if(res[i] != -1 && res[i] != v[i]) return false;
    }
    return true;
}

void dfs(vint &v, int &res) {
    if(v.size() == n) {
        if(judge(v)) {
            int cnt = 0;
            rfor(x, v) if(x) cnt++;
            chmax(res, cnt);
        }
    } else {
        v.push_back(0);
        dfs(v, res);
        v.pop_back();
        v.push_back(1);
        dfs(v, res);
        v.pop_back();
    }
}

int main(void) {
    cin >> n;
    a.resize(n);
    xys.resize(n);
    rep(i, n) {
        cin >> a[i];
        xys[i].resize(a[i]);
        rep(j, a[i]) {
            cin >> xys[i][j].first >> xys[i][j].second;
            xys[i][j].first--;
        }
    }
    vint v;
    int ans = 0;
    dfs(v, ans);
    println(ans);
    return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> a(3 * N);
  for(int i = 0; i < 3 * N; i++) cin >> a[i];
  
  vector<long long> s_f(N + 1, 0);
  vector<long long> s_b(N + 1, 0);
  
  priority_queue<int> q_f;
  for(int i = 0; i < N; i++){
    s_f[0] += a[i];
    q_f.push(-a[i]);
  }
  
  for(int i = 0; i < N; i++){
    s_f[i + 1] = s_f[i];
    if(-q_f.top() < a[i + N]){
      s_f[i + 1] += q_f.top();
      s_f[i + 1] += a[i + N];
      q_f.pop();
      q_f.push(-a[i + N]);
    }
  }
  
  priority_queue<int> q_b;
  for(int i = 0; i < N; i++){
    s_b[0] += a[3 * N - i - 1];
    q_b.push(a[3 * N - i - 1]);
  }
  
  for(int i = 0; i < N; i++){
    s_b[i + 1] = s_b[i];
    if(q_b.top() > a[2 * N - i - 1]){
      s_b[i + 1] -= q_b.top();
      s_b[i + 1] += a[2 * N - i - 1];
      q_b.pop();
      q_b.push(a[2 * N - i - 1]);
    }
  }
  
  long long s = s_f[0] - s_b[N];
  for(int i = 1; i <= N; i++){
    s = max(s, s_f[i] - s_b[N - i]);
  }
  
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 4088
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i < n; i++){
        for(int j = 1; j * j <= i; j++){
            if(i % j == 0){
                if(i / j == j)
                    ans++;
                else ans += 2;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
   int n; cin>>n;
   vector<int> a(n);
   rep(i,n) cin>>a[i];
   int ans=0;
   int cnt=1;
   rep(i,n){
      if(a[i]==cnt) cnt++;
      else ans++;
   }
   if(ans==n) cout<<-1<<endl;
   else cout<<ans<<endl;
   return 0;
}


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

#define endl '\n'
#define left aba
#define right abc
#define oo if(LOG)
#define pb push_back
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#ifdef LOCAL
#define LOG 1
#else
#define LOG 0
#endif

using namespace std;

const int N = 103, MOD = (int)(1e9) + 7, K = (int)(1e5)+3;

int n, k;

int a[N];

inline void add(int &aa, int bb) {
    aa += bb;
    if(aa >= MOD) aa -= MOD;
}

inline void subt(int &aa, int bb) {
    aa -= bb;
    if(aa < 0) aa += MOD;
}

int dp[2][K];

int main() {
    FIO;

    cin >> n >> k;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    dp[0][0] = 1;
    bool fl = 0;
    for(int i = 0; i < n; ++i) {
        fl ^= 1;
        int sum = 0;
        for(int j = 0; j <= k; ++j) {
            add(sum, dp[fl ^ 1][j]);
            dp[fl][j] = sum;
            if(j >= a[i]) subt(sum, dp[fl ^ 1][j - a[i]]);
        }

    }
    cout << dp[fl][k] << endl;

    oo cout << "Time: " << (double)clock() / CLOCKS_PER_SEC << "s" << endl;
    return 0;
}


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


int main() 
{
	int N = 0;
	cin >> N;
	vector<int> dVec(N);
	for (int i = 0; i < dVec.size(); i++)
	{
		cin >> dVec.at(i);
	}
	sort(dVec.begin(), dVec.end());
	dVec.erase(unique(dVec.begin(), dVec.end()), dVec.end());

	cout << dVec.size() << endl;

}

Measured memory_bytes: 256
// B Training Camp

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;    
    cin >> N;
    long div = pow(10, 9) + 7;
    //long div = 1000000000 + 7;

    long num = 1;     // power
    long res = 0;

    for (int i = 0; i < N; i ++)    {
        num *= (i+1);
        res = num % div;
        num = res;
    }
    // res = num % div;        
    cout << num << endl;
}


Measured memory_bytes: 3592
import sys

MOD = 10**9+7
s = int(input())

dp = [0, 0, 0, 1]
ruisekiwa = [0, 0, 0, 0]

if s < 3:
    print(0)
    sys.exit()

for i in range(4, s+1):
    dp.append(1 + ruisekiwa[i-1])
    ruisekiwa.append(dp[i-2] + ruisekiwa[i-1])

# print(dp)
# print(ruisekiwa)
print(dp[-1] % MOD)


Measured memory_bytes: 64424