akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t t;
    cin >> t;

    for (auto _ : irange(0L, t)) {
        int64_t n;
        cin >> n;

        array<vector<pair<int64_t, int64_t>>, 2> camels;
        int64_t s = 0;
        for (auto _ : irange(0L, n)) {
            int64_t k, l, r;
            cin >> k >> l >> r;

            auto d = l - r;
            if (d > 0) {
                s += r;
                camels[0].emplace_back(k, d);
            } else {
                s += l;
                camels[1].emplace_back(n - k, -d);
            }
        }

        sort(camels[0].begin(), camels[0].end());
        sort(camels[1].begin(), camels[1].end());

        for (const auto& camel : camels) {
            int64_t sp = 0;
            priority_queue<int64_t, vector<int64_t>, std::greater<>> q;
            for (const auto& c : camel) {
                int64_t np = q.size() + 1;
                if (c.first == 0) {
                    // NOP
                } else if (np > c.first) {
                    if (q.top() < c.second) {
                        sp += -q.top() + c.second;
                        q.pop();
                        q.push(c.second);
                    }
                } else {
                    q.push(c.second);
                    sp += c.second;
                }
            }

            s += sp;
        }

        cout << s << "\n";
    }
}

Measured memory_bytes: 8316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    int x, y;
    cin >> x >> y;

    rep(i, x + 1)
    {
        if (2 * i + 4 * (x - i) == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 3652
n=int(input())
if 400<=n<=599:
    print(8)
elif 600<=n<=799:
    print(7)
elif 800<=n<=999:
    print(6)
elif 1000<=n<=1199:
    print(5)
elif 1200<=n<=1399:
    print(4)
elif 1400<=n<=1599:
    print(3)
elif 1600<=n<=1799:
    print(2)
elif 1800<=n<=1999:
    print(1)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vi>;
using pii = pair<int, int>;

using vc = vector<char>;
using vcc = vector<vc>;
using vb = vector<bool>;
using vbb = vector<vb>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using vd = vector<double>;
using vdd = vector<vd>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;

vector<pii> prime_factorization(int n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pii> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}
vector<pli> prime_factorization(ll n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pli> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}

// n は 2以上の素数表を返す
vb Primes(int n){
  vector<bool> res(n + 1, true);
  res.at(0) = false; res.at(1) = false;
  for(int i = 2; i <= sqrt(n); i++){
    if(res.at(i)){
      for(int j = 2 * i; j <= n; j += i){
        res.at(j) = false;
      }
    }
  }
  return res;
}
// ===================================================


int main(){
  int a, b, c, n; cin >> n;
  vii A(n + 1, vi(3, 0));
  for(int i = 0; i < n; i++){
    cin >> a >> b >> c;
    A[i + 1][0] = MAX(A[i][1], A[i][2]) + a;
    A[i + 1][1] = MAX(A[i][0], A[i][2]) + b;
    A[i + 1][2] = MAX(A[i][0], A[i][1]) + c;
  }
  int res = MAX(A[n][0], A[n][1]); res = MAX(res, A[n][2]);
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
using P = pair<ll, ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((ll)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((ll)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

const ll M = 1000005;
ll N;
ll Main() {
    cin >> N;
    
    vl A(N, 0);
    vl cnt(M, 0);

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

    for(ll x: A) {
        if(cnt[x] != 0) {
            cnt[x] = 2;
            continue;
        }
        for(ll i=x; i<M; i+=x) {
            cnt[i]++;
        }
    }
    
    ll ans = 0;
    for(ll x: A) {
        if (cnt[x] == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 12684
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    M, D = map(int, input().split())
    ans = 0
    for m in range(1, M+1):
        for d in range(10, D+1):
            d_1 = d % 10
            d_10 = d // 10
            if d_1 >= 2 and d_10 >= 2 and d_1 * d_10 == m:
                ans += 1
    print(ans)

input = lambda: stdin.readline().rstrip()
main()

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                for (int k = 0; k < W; k++) {
                    if ((i + k) % 2 == 1) {
                        System.out.printf(".");
                    } else {
                        System.out.printf("#");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 65416
lst = []

while True:
    p, s = map(int, input().split(','))

    if p == 0 :
        break

    lst.append(s)

s = list(set(lst))
s.sort(reverse = True)

while True:
    try:
        num = int(input())
        print(s.index(lst[num-1]) +1)

    except EOFError:
        break



Measured memory_bytes: 5600
def main():
    A = int(input()) # 500
    B = int(input()) # 100
    C = int(input()) # 50
    X = int(input())
    
    answer = []
    for i in range(A+1):
        for j in range(B+1):
            for k in range(C+1):
                if (i*500)+(j*100)+(k*50) == X: answer.append([i,j,k])
    print(len(answer))

if __name__ == "__main__":
    main()

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

int main() {
	ll a,b,x;
	cin>>a>>b>>x;
	const int mod=1000000007;
	ll ans=x;
	if(x>=a){
		ans+=((x-a)/(a-b)+1)%mod*(b%mod)%mod;
	}
	ans%=mod;
	cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		int count1 = 0;

		for(int i = 0; i < n; i++) {
			int b = sc.nextInt();
			if(b%4 == 0) {
				count++;
			}else if(b%2 == 0) {
				count1++;
			}else {
				count--;
			}
		}
		System.out.println(count >= 0|| (count == -1 && count1 == 0) ? "Yes" : "No");
		sc.close();
	}
}

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

#define F first
#define S second

using ll = long long;
using pii = pair <int, int>;

const int oo = 1e9 + 4;
const int SZ = 2e5 + 4;

int r;

void read() {
    cin >> r;
}

void solve() {
    cout << 2 * r * acos(-1);
}

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

    read();
    solve();
}


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

const int INF = 1 << 28;
int d[800][800];
string b[800];
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

struct S {
	int x, y;
};
int H, W, K;

bool goal(int x, int y) {
	return x == 0 || x == W - 1 || y == 0 || y == H - 1;
}

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

	cin >> H >> W >> K;

	int sx = -1, sy = -1;
	for(int i = 0; i < H; i++) {
		cin >> b[i];
		for(int j = 0; j < W; j++) {
			if(b[i][j] == 'S') sx = j, sy = i;
		}
	}

	fill((int*)begin(d), (int*)end(d), INF);
	d[sy][sx] = 0;

	int ans = INF;
	queue<S> q;
	q.push({ sx, sy });
	while(q.size()) {
		S s = q.front();
		q.pop();
		int mind = min({ s.x, s.y, W - 1 - s.x, H - 1 - s.y });
		ans = min(ans, (mind + K - 1) / K + 1);

		if(d[s.y][s.x] >= K) continue;
		for(int k = 0; k < 4; k++) {
			int nx = s.x + dx[k], ny = s.y + dy[k];
			if(b[ny][nx] == '#') continue;
			if(goal(nx, ny)) {
				cout << 1 << endl;
				return 0;
			}
			if(d[ny][nx] > d[s.y][s.x] + 1) {
				d[ny][nx] = d[s.y][s.x] + 1;
				q.push({ nx, ny });
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3456
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length = 2*(a + b);
        System.out.println(area+" "+length);
    }
}


Measured memory_bytes: 26352
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        int k = scanner.nextInt();

        int max = a;
        if(max<b) {
        	max=b;
        }
        if(max<c) {
        	max=c;
        }

        int sabun = a + b + c - max;

        System.out.println((int)((double)sabun + (max * Math.pow(2, (double)k))));


    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ld long double
#define int long long
const int N = 200500;

void SOLVE(){
    int n, D, A;
    cin >> n >> D >> A;
    vector <pii> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i].first >> a[i].second;
    }
    sort(all(a));
    int ct = 0;
    int lst = 0;
    queue <pii> q;
    for (int i = 0; i < n; i++){
        while (!q.empty() && q.front().first < a[i].first){
            lst -= q.front().second;
            q.pop();
        }
        a[i].second -= lst;
        if (a[i].second > 0){
            int cur = (a[i].second + A - 1) / A;
            ct += cur;
            lst += cur * A;
            q.push({a[i].first + D + D, cur * A});
        }
    }
    cout << ct << '\n';
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int Q = 1;
    //cin >> Q;
    while (Q--){
        SOLVE();
    }

    return 0;
}


Measured memory_bytes: 4992
import re
s = input().replace('?', '.')
t = input()

for i in range(len(s)-len(t),-1,-1):
    if re.match(s[i:i+len(t)], t):
        s = s[:i] + t + s[i+len(t):]
        s = s.replace('.', 'a')
        print(s)
        exit(0)
print('UNRESTORABLE')


Measured memory_bytes: 3188
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int c[3][3];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	rep(i,3)rep(j,3) cin >> c[i][j];
	for(int a1 = 0; a1 <= 100; a1++){
		for(int a2 = 0; a2 <= 100; a2++){
			for(int a3 = 0; a3 <= 100; a3++){
				int b1 = c[0][0] - a1;
				if(b1 < 0 || b1 > 100) continue;
				int b2 = c[0][1] - a1;
				if(b2 < 0 || b2 > 100) continue;
				int b3 = c[0][2] - a1;
				if(b3 < 0 || b3 > 100) continue;
				if(a2 + b1 != c[1][0]) continue;
				if(a2 + b2 != c[1][1]) continue;
				if(a2 + b3 != c[1][2]) continue;
				if(a3 + b1 != c[2][0]) continue;
				if(a3 + b2 != c[2][1]) continue;
				if(a3 + b3 != c[2][2]) continue;
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();
        string t = sc.Next();

        int ans = int.MaxValue;
        for (int b = 0; b + t.Length <= s.Length; b++)
        {
            int cnt = 0;
            for (int i = 0; i < t.Length; i++)
            {
                if (t[i] != s[b + i])
                {
                    cnt++;
                    continue;
                }
            }
            ans = Math.Min(ans, cnt);
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 25876
char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c!=d[i]?putchar(c),*G++:r[i++];exit(0);}

Measured memory_bytes: 524
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    int N;cin >> N;
    I vec;
    REP(a,pow(2,N)){
        CIN(b);
        vec.push_back(b);
    }
    I ins;
    while(vec.size() != 1){
        ins.clear();
    for(int a = 0;a < vec.size();a++){
        if(a%2 == 0){
        if(vec.at(a) > vec.at(a+1)){
            ins.push_back(vec.at(a)-vec.at(a+1));
            continue;
        }
        if(vec.at(a) < vec.at(a+1)){
            ins.push_back(vec.at(a+1)-vec.at(a));
            continue;
        }
        if(vec.at(a)==vec.at(a+1)){
            ins.push_back(vec.at(a));
            continue;
        }
        }
    }
    vec = ins;
    }
    COUT(vec.front());
    return 0;
}


Measured memory_bytes: 2292
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a.at(i);
    int check = 0;
	for (int i = 0; i < n; i++) {
        if (a.at(i) % 2 != 0) { 
            ++check;
            continue;
        }
		if (a.at(i) % 3 == 0 || a.at(i) % 5 == 0) ++check;
	}
    if (check == n) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec;
  for (int i = 0; i < M; i++) {
    int tmp = 0;
    cin >> tmp;
    vec.push_back(tmp);
  }
  sort(vec.begin(), vec.end());

  vector<int> diffs;
  for (int i = 1; i < M; i++) {
    int diff = abs(vec[i] - vec[i - 1]);
    diffs.push_back(diff);
  }
  sort(diffs.begin(), diffs.end());

  for (int i = 1; i < N; i++) {
    if (diffs.size() == 0) {
      break;
    }
    diffs.pop_back();
  }

  int ans = 0;
  for (auto &d : diffs) {
    ans += d;
  }

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

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-12;
constexpr double pi=3.14159265358979323846264338;
//int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,siz[200010],dp[200010],dp2[200010];
vector<int>v[200010];
bool used[200010];
void dfs(int x){
    used[x]=true;
    siz[x]=1;
    for(int i:v[x]){
        if(!used[i]){
            dfs(i);
            siz[x]+=siz[i];
        }
    }
}
void dfs2(int x){
    used[x]=true;
    dp[x]=1;
    for(int i:v[x]){
        if(!used[i]){
            dfs2(i);
            dp[x]*=dp[i];
            dp[x]%=mod;
            dp[x]*=invkaijo[siz[i]];
            dp[x]%=mod;
        }
    }
    dp[x]*=kaijo[siz[x]-1];
    dp[x]%=mod;
}
void dfs3(int x,int prop=1){
    used[x]=true;
    dp2[x]=1;
    for(int i:v[x]){
        if(!used[i]){
            dp2[x]*=dp[i];
            dp2[x]%=mod;
            dp2[x]*=invkaijo[siz[i]];
            dp2[x]%=mod;
        }
    }
    dp2[x]*=prop;
    dp2[x]%=mod;
    dp2[x]*=invkaijo[n-siz[x]];
    dp2[x]%=mod;
    dp2[x]*=kaijo[n-1];
    dp2[x]%=mod;
    for(int i:v[x]){
        if(!used[i]){
            dfs3(i,dp2[x]*invkaijo[n-1]%mod*kaijo[siz[i]]%mod*inv(dp[i])%mod*kaijo[n-siz[i]-1]%mod);
        }
    }
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    init_fact(200000);
    dfs(0);
    fill(used,used+n,false);
    dfs2(0);
    fill(used,used+n,false);
    dfs3(0);
    rep(i,n)cout<<dp2[i]<<endl;
    return 0;
}


Measured memory_bytes: 22768
#include <bits/stdc++.h>
#define x first
#define y second
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define mem(i) memset((i), (-1), (sizeof(i)))
#define all(i) (i).begin(), (i).end()
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

const int MN = 1e5 + 5;
int n, m;
vector<int> adj[MN];
bool visited[MN];
int dp[MN];

void dfs(int cur)
{
	visited[cur] = true;
	for (auto &next : adj[cur])
	{
		if (!visited[next]) dfs(next);
		dp[cur] = max(dp[next] + 1, dp[cur]);
	}
}

int main()
{
	fastio;
	cin >> n >> m;
	rep(i, 0, m)
	{
		int u, v; cin >> u >> v;
		adj[u].pb(v);
	}

	rep(i, 1, n + 1)
		if (!visited[i]) dfs(i);
	cout << *max_element(dp + 1, dp + n + 1) << '\n';
}

Measured memory_bytes: 7552
X,N = map(int,input().split())
p = list(map(int,input().split()))
diff = 1
if(X not in p):
    print(X)
    exit()
while(diff < 200):
    if(X-diff not in p):
        print(X-diff)
        exit()
    elif(X+diff not in p):
        print(X+diff)
        exit()
    diff += 1

Measured memory_bytes: 9088
import sys

def is_palindrome(s):
    return s == s[::-1]

s = sys.stdin.readline().rstrip()
n = len(s)

def main():
    res = is_palindrome(s[:n//2]) and is_palindrome(s[n//2+1:])
    return 'Yes' if is_palindrome(s) and res else 'No'

if __name__ == "__main__":
    ans = main()
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
string mp[100];
int d[100][100][4],inf=1e8,dh[4]={-1,0,1,0},dw[4]={0,1,0,-1};
int main(){
	while(true){
		int h,w;
		ll l;
		cin >> h >> w >> l;
		if(h==0) break;
		rep(i,h) cin >> mp[i];
		int sw,sh,di;
		rep(i,h) rep(j,w) if(mp[i][j]!='.' && mp[i][j]!='#') sh=i,sw=j;
		if(mp[sh][sw]=='N') di=0;
		if(mp[sh][sw]=='E') di=1;
		if(mp[sh][sw]=='S') di=2;
		if(mp[sh][sw]=='W') di=3;
		rep(i,h) rep(j,w) rep(k,4) d[i][j][k]=inf;
		d[sh][sw][di]=0;
		int now=1;
		while(true){
			int nh,nw;
			while(true){
				nh=sh+dh[di],nw=sw+dw[di];
				if(!(0<=nh && nh<h && 0<=nw && nw<w) || mp[nh][nw]=='#'){
					di=(di+1)%4;
					continue;
				}
				break;
			}
			sh=nh,sw=nw;
			if((ll)now==l){
				cout << sh+1 << " " << sw+1 << " ";
				if(di==0) cout << "N\n";
				if(di==1) cout << "E\n";
				if(di==2) cout << "S\n";
				if(di==3) cout << "W\n";
				break;
			}
			if(d[sh][sw][di]==inf){
				d[sh][sw][di]=now;
				now++;
			}else{
				int dd=d[sh][sw][di];
				l=dd+(l-dd)%(now-dd);
				rep(i,h) rep(j,w) rep(k,4) if(d[i][j][k]==l){
					cout << i+1 << " " << j+1 << " ";
					if(k==0) cout << "N\n";
					if(k==1) cout << "E\n";
					if(k==2) cout << "S\n";
					if(k==3) cout << "W\n";
					goto label;
				}
				label:
				break;
			}
		}
	}
}

Measured memory_bytes: 1396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

int main(){
	int n, ans = 0; 
	cin >> n;
	vector<int>d(n, 0);
	for(int i = 0; i < n; i++)cin >> d[i];
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			ans += d[i]*d[j];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      s: chars,
    }

    let mut ans = vec![0; s.len()+1];
    let mut cur = 0;

    for i in 1..s.len() {
        if s[i] != s[i-1] {
            if s[i-1] == '<' {
                let mut v = 0;
                for j in cur..i+1 {
                    ans[j] = v;
                    v += 1;
                }
            } else {
                let mut v = 0;
                for j in (cur..i+1).rev() {
                    if v > ans[j] {
                        ans[j] = v;
                    }
                    v += 1;
                }
            }
            cur = i;
        }
    }

    let idx = s.len()-1;
    if s[idx] == '<' {
        let mut v = 0;
        for j in cur..idx+2 {
            ans[j] = v;
            v += 1;
        }
    } else {
        let mut v = 0;
        for j in (cur..idx+2).rev() {
            if v > ans[j] {
                ans[j] = v;
            }
            v += 1;
        }
    }

    let ans = ans.iter().sum::<usize>();
    puts!("{}\n", ans);
}


Measured memory_bytes: 11512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

std::random_device seed_gen;
std::mt19937 engine(seed_gen());
constexpr int prob = 26;
const double TL = 1.970;
// const double TL = 0.100;

vector<ll> c,l;
vector<vector<int>> s;
int d;

ll score(vector<int> &t) {
    ll sat = 0;
    rep (i, prob) l[i] = -1;
    rep (dy, d) {
        int k = t[dy];
        sat += s[dy][k];
        l[k] = dy;
        rep (i, 26) sat -= c[i] * (dy - l[i]);
    }
    return sat;
}

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    clock_t start = clock(), end;
    cin >> d;
    c.resize(prob); l.resize(prob);
    s.resize(d); rep (i, s.size()) s[i].resize(prob);
    rep (i, c.size()) cin >> c[i];
    rep (i, s.size()) { rep (j, s[0].size()) { cin >> s[i][j]; }}

    vector<int> t(d), tmp;
    vector<int> sum(prob + 1);
    rep (i, prob) sum[i + 1] = sum[i] + c[i];
    rep (i, d) {
        int k = i % sum[prob], ng = -1, ok = prob;
        while (ok - ng > 1) {
            int med = (ok + ng) / 2;
            if (sum[med] >= k) ok = med;
            else ng = med;
        }
        clamp(ok, 0, prob - 1);
        t[i] = ok;
    }
    tmp = t;
    ll max_score = -(ll)1e18;
    int count = 1, k;
    while (true) {
        // write here
        
        do {
            k = engine() % d;
            tmp[k] = engine() % prob;
        } while (tmp[k] == t[k]);
        if (chmax(max_score, score(tmp))) t = tmp;

        if (count % 100 == 0) {
            end = clock();
            if (static_cast<double>(end - start) / CLOCKS_PER_SEC > TL) break;
        }
        count++;
    }
    
    rep (i, d) cout << t[i] + 1 << "\n";
    return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n, q; cin >> n >> q;
  string s; cin >> s;

  int size = s.size();
  vector<int> ac(size, 0);
  bool f = 0;
  int c = 0;
  rep(i, size){
    if(s[size - i - 1] == 'C') f = 1;
    else if(s[size - i - 1] == 'A' && f){
      c++;
      f = 0;
    }else f = 0;
    ac[size - i - 1] = c;
  }

  vector<int> ans(q);

  rep(i, q){
    int l, r; cin >> l >> r;
    ans[i] = ac[l - 1] - ac[r - 1];
  }
  rep(i, q)
  cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int x; cin >> x;
  bool check = true;

  for (int i = x; ; i ++) {
    for (int j = 2; j * j <= x; j ++) {
      if (i % j == 0) {
        check = false;
        break;
      }
    }
    if (check) {
      cout << i << endl;
      return 0;
    }
    check = true;
  }
}

Measured memory_bytes: 256
import java.util.*;

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

        int sum = 0;
        for(int i=0; i<s.length(); i++){
            sum += Character.getNumericValue(s.charAt(i));
        }

        if(sum == 1){
            System.out.println("10");
        }else{
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 21844
n = int(input())
h = [int(i) for i in input().split()]

j = 0
for i in range(n):
    if h[i] == j:
        pass
    elif h[i] > j:
        j = h[i] - 1
    else:
        if h[i] == j:
            pass
        else:
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 63984
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  string s;
  cin>>s;
  int num_1=0,num_0=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='1') num_1++;
    else num_0++;
  }
  cout<<2*min(num_1,num_0)<<endl;
  return 0;
}


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

int main() {
  int DIV = 2019;
  string S; cin >> S;
  reverse(S.begin(), S.end());
  int N = S.size();
  int R[N+1]; R[0] = 0;
  int p = 1;
  for (int i = 0; i < N; i++) {
    R[i+1] = (R[i] + ((int)S[i] - 48) * p) % DIV;
    p = p * 10 % DIV;
  }
  int C[DIV]; for (int r = 0; r < DIV; r++) C[r] = 0;
  for (int i = 0; i <= N; i++) C[R[i]]++;
  long sum = 0;
  for (int r = 0; r < DIV; r++) {
    sum += (long)C[r] * (C[r] - 1) / 2;
  }
  cout << sum << endl;
}

Measured memory_bytes: 4448
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        String s = sc.next();
        String t = sc.next();

        long len = lcd(n, m);
        Map<Long, Character> posMap = new HashMap<>();
        for(int i = 0; i < n; i++) {
        	long idx = 1 + i * (len / n);
        	posMap.put(idx, s.charAt(i));
        }

        for(int i = 0; i < m; i++) {
        	long idx = 1 + i * (len / m);
        	if(posMap.containsKey(idx)) {
        		if(posMap.get(idx) != t.charAt(i)) {
        			System.out.println(-1);
        			return;
        		}
        	}
        }
        System.out.println(len);
    }

    private static long lcd(long a, long b) {
    	return a / gcd(a, b) * b;
    }
    private static long gcd(long a, long b) {
    	if(b == 0) return a;
    	return gcd(b, a % b);
    }
}
 

Measured memory_bytes: 32548
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>

int main(){
  int l;
  double a,b,c;

  scanf("%d", &l);

  a = b = c = l/3;

  printf("%f", (double)l*l*l/27);

  return 0;
}


Measured memory_bytes: 128
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
bool my_compare(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    vector<ll> v(n+1);
    rep(i,n) cin>>v[i+1];
    ll now=1;
    rep(i,n) {
        now=v[now];
        f++;
        if(now==2) {sum=1;break;}
    }
    if(sum==0) cout<<-1<<endl;
    else cout<<f<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

struct punct
{
    int x,y;
    long long poz;
};

punct v[100010],v1[300010];
int vaz[100010],rad[100010];
map<pair<int,int>, char> vaz1;

int cmp1(punct a,punct b)
{
    return a.x<b.x;
}

int cmp2(punct a,punct b)
{
    return a.y<b.y;
}

int cmp3(punct a,punct b)
{
    return a.poz<b.poz;
}

int radacina(int x)
{
    int y=x;
    while(rad[y]!=y) y=rad[y];
    while(x!=y)
    {
        int aux=rad[x];
        rad[x]=y;
        x=aux;
    }
    return y;
}

void reuneste(int x,int y)
{
    int a=radacina(y),b=radacina(x);
    rad[b]=a;
}

int query(int x,int y)
{
    if(radacina(x)==radacina(y)) return 1;
    else return 0;
}

int main()
{
    int n;
    long long sol=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&v[i].x,&v[i].y);
        v[i].poz=i;
        rad[i]=i;
    }
    int l=0;
    sort(v+1,v+n+1,cmp1);
    for(int i=1;i<n;i++)
        v1[++l]={v[i].poz,v[i+1].poz,v[i+1].x-v[i].x};
    sort(v+1,v+n+1,cmp2);
    for(int i=1;i<n;i++)
        v1[++l]={v[i].poz,v[i+1].poz,v[i+1].y-v[i].y};
    sort(v1+1,v1+l+1,cmp3);
    int c=1;
    for(int i=1;i<=l;i++)
    {
        if(query(v1[i].x,v1[i].y)==0) {sol+=v1[i].poz;reuneste(v1[i].x,v1[i].y);}
    }
    printf("%lld",sol);
    return 0;
}


Measured memory_bytes: 7040
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

S, T = raw_input().split()
A, B = map(int, raw_input().split())
U = raw_input()
if S == U:
    print A - 1, B
else:
    print A, B - 1

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int X, Y;
	cin >> X >> Y;

	if (X%Y == 0)cout << -1 << endl;
	else
	{
		cout << X << endl;
	}

	return 0;
}

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

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

Measured memory_bytes: 19124
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  string s;
  cin>>s;
  int ret = 0;
  int cnt = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='R'){
      cnt++;
      ret = max(ret,cnt);
    } else cnt = 0;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 3624
S = input()

may_YYMM = False
may_MMYY = False
months = ["{:02}".format(i) for i in range(1, 12+1)]

if S[:2] in months:
    may_MMYY = True
if S[2:] in months:
    may_YYMM = True

if may_MMYY and may_YYMM:
    print("AMBIGUOUS")
elif may_YYMM and not may_MMYY:
    print("YYMM")
elif not may_YYMM and may_MMYY:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3060
//abc169_e.cpp
//Sun May 31 20:45:40 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

bool compare_by_b(P a, P b) {
	if(a.second != b.second){
		return a.second < b.second;
	}else{
		return a.first > b.first;
	}
}

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

	P a[n];
	for (int i=0;i<n;i++){
		ll tmp1,tmp2;
		cin >> tmp1 >> tmp2;
		a[i].first = tmp1;
		a[i].second = tmp2;
	}

	ll upper,lower;
	if (n%2==1){
		ll ind = (n-1)/2;
		sort(a,a+n);
		lower = a[ind].first;
		sort(a,a+n,compare_by_b);
		upper = a[ind].second;
	}else {
		sort(a,a+n);
		ll ind1 = n/2-1;
		ll ind2 = ind1+1;
		lower = (a[ind1].first+a[ind2].first);
		sort(a,a+n,compare_by_b);
		upper = (a[ind1].second+a[ind2].second);
	}

	cout << abs(upper-lower)+1<< endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 6648
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int N; long long L; string s[100009];
long long solve(int d, int l, int r) {
	if (s[l].size() == d) l++;
	int pl = l;
	while (l != r && s[l][d] == '0') l++;
	int f1 = (pl != l ? 1 : 0);
	int f2 = (l != r ? 1 : 0);
	if (f1 + f2 == 0) return 0;
	if (f1 + f2 == 1) {
		long long rem = L - d;
		long long cr = 1;
		while (rem % 2 == 0) rem /= 2, cr *= 2;
		long long res = -1;
		if (f1 == 1) res = solve(d + 1, pl, l);
		if (f2 == 1) res = solve(d + 1, l, r);
		return cr ^ res;
	}
	long long res1 = solve(d + 1, pl, l);
	long long res2 = solve(d + 1, l, r);
	return res1 ^ res2;
}
int main() {
	cin >> N >> L;
	for (int i = 0; i < N; i++) cin >> s[i];
	sort(s, s + N);
	long long ret = solve(0, 0, N);
	cout << (ret != 0 ? "Alice" : "Bob") << endl;
	return 0;
}

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


int main(){
int v,e;
cin>>v>>e;
vector<vector<mypair> > g(v);
int s,t,d;
rep(i,e){
	cin>>s>>t>>d;	
	g[s].push_back(mypair(t,d) );
	g[t].push_back(mypair(s,d) );
}
priority_queue<mypair,vector<mypair> ,greater<mypair> > q;
vector<bool> used(v,true);
int passpoint = 0;
int ans = 0;
used[0] = false;
passpoint ++;
rep(i,g[0].size())q.push(mypair(g[0][i].second,g[0][i].first) ); 
while(!q.empty()){
mypair now = q.top();
q.pop();
if(used[now.second]){
used[now.second] = false;
passpoint++;
ans+=now.first;
	rep(i,g[now.second].size()){
		q.push(mypair(g[now.second][i].second,g[now.second][i].first));
	}
}
else continue;
if(passpoint == v)break;
}
//cout<<passpoint<<endl;
cout<<ans<<endl;



	return 0;
}



Measured memory_bytes: 7836