akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define mod 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, j, k, L[101], ans=0;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> L[i];
    }

    if(N<3) cout << 0 << endl;

    else{
        for(i=1; i<=N-2; i++){
            for(j=i+1; j<=N-1; j++){
                for(k=j+1; k<=N; k++){
                    if(L[i]!=L[j] && L[i]!=L[k] && L[j]!=L[k] && 
                    L[i]+L[j]>L[k] && L[j]+L[k]>L[i] & L[k]+L[i]>L[j]){
                        ans++;
                    }
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000000007;
vel par;
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
int root1(int ser, vel &path) {
	if (par[ser] == -1) {
		for (int i = 0; i < path.size(); i++) {
			par[path[i]] = ser;
		}
		return ser;
	}
	path.push_back(ser);
	return root1(par[ser], path);
}
int root(int ser) {
	vel emp(0);
	return root1(ser, emp);
}
bool uni(pin a) {
	int x = root(a.first);
	int y = root(a.second);
	if (x != y) {
		par[y] = x;
	}
	return (x != y);
}
signed main() {
	int n, m; cin >> n >> m;
	V<V<bool>> way(n,V<bool>(n,true));
	rep(i, m) {
		int a, b; cin >> a >> b;
		a--; b--;
		way[a][b] = false;
		way[b][a] = false;
	}
	rep(i, n) { way[i][i] = false; }
	vel color(n, -1);
	V<bool> can_use(2 * n, false); can_use[0] = true;
	rep(i, n) {
		if (color[i] == -1) {
			queue<int> q;
			q.push(i);
			color[i] = 0;
			int b = 0;
			int w = 0;
			while (!q.empty()) {
				int st = q.front(); q.pop();
				b += color[st];
				w += 1 - color[st];
				rep(to, n) {
					if (way[st][to]) {
						if (color[st] == color[to]) { cout << -1 << endl; return 0; }
						else if (color[to] == -1) {
							color[to] = (color[st] + 1) % 2;
							q.push(to);
						}
					}
				}
			}
			V<bool> n_use(2 * n, false);
			rep(j, n) {
				n_use[j + b] = n_use[j + b] || can_use[j];
				n_use[j + w] = n_use[j + w] || can_use[j];
			}
			can_use = n_use;
		}
	}
	int ans = n * n;
	rep(i, n) {
		if (can_use[i]) {
			int ans1 = (i*i - i) / 2;
			int j = n - i;
			int ans2 = (j*j - j) / 2;
			mmin(ans, ans1 + ans2);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
typedef long long ll;

int num[maxn];
bool cmp(const int &a,const int &b){
	return a>b;
}
int main(int argc, char const *argv[])
{
	int n;
	while(cin>>n){
		for(int i=0;i<n;i++){
			cin>>num[i];
		}
		sort(num,num+n,cmp);
		if(n<=3){
			printf("0\n");
			continue;
		}
		else{
			ll a=0,b=0;
			ll ans=0;
			int i=0;
			for(i=0;i<n;i++){
				if(num[i]==num[i+1]){
					a=num[i];
					i+=2;
					break;
				}
			}
			for(;i<n;i++){
				if(num[i]==num[i+1]){
					b=num[i];
					i+=2;
					break;
				}
			}
			ans=a*b;
			printf("%lld\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
class Main{


	static char[][] map;

	static long[][] c;
	static int ans;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		if(n >= 82){
			System.out.println("No");
			return;
		}else{
			for(int i = 1;i <= 9;i++){
				if(n % i == 0){
					if(n/i <= 9){
						System.out.println("Yes");
						return;
					}
				}
			}
		}
		System.out.println("No");



	}
	
//	static void dfs(int y,int x,int num,int count){
//		if((y+1)*(x+1) > num){
//			return;
//		}
//		if((y + 1)*(x+1) == num){
//			ans = Math.min(ans, count);
//			return;
//		}
//		
//		if(y + 1 <= )
//		dfs(y+1, x, num, count);
//		
//	}

	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}






Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100000;
int N;
int A[MAX_N], B[MAX_N], C[MAX_N];
ll tmp[MAX_N];
ll sum[MAX_N];

int main() {
  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  rep(i, N) cin >> C[i];
  sort(A, A+N);
  sort(B, B+N);
  sort(C, C+N);

  for (int i = 0; i < N; ++i) {
    tmp[i] = N - int(upper_bound(C, C+N, B[i]) - C);
  }

  sum[0] = tmp[0];
  for (int i = 1; i < N; ++i) sum[i] = sum[i-1] + tmp[i];

  ll ans = 0;
  for (int i = 0; i < N; ++i) {
    int ub = upper_bound(B, B+N, A[i]) - B;
    if (ub == 0) ans += sum[N-1];
    else ans += sum[N-1] - sum[ub-1];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2944
// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll MOD=1000000007;

#define fast_cin() ios_base::sync_with_stdio(false)
#define pb push_back
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug1(x) cerr << x << endl;
#define debug2(x,y) cerr << x << " " << y << endl;
#define debug3(x,y,z) cerr << x << " " << y << " " << z << endl;
#define FOR(i, a, b) for (ll i=a; i<(b); i++)
#define FORR(i, a, b) for (ll i=a; i>=(b); i--)
ll INF = 2000000000000000001;
double EPS = 1e-9;
ll nextll(){ll inp; cin>>inp; return inp;}
string nextStr(){string inp; cin>>inp; return inp;}
double nextDouble(){double inp; cin>>inp; return inp;}
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	ll t;
	cin>>t;
	FOR(i,0,t){
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		if(d<b || a<b){
			cout<<"No"<<endl;
		}
		else{
			a=a%b;
			if(c>=b-1){
				cout<<"Yes"<<endl;
			}
			else{
				ll val = gcd(d,b);
				ll c1 = (b-a-1)/val;
				ll c2 = (c+1-a)/val;
				if(c+1-a<=0){
					cout<<"No"<<endl;
				}
				else{
					if(c1==c2 && (c+1-a)%val!=0 && (b-a-1)%val!=0){
						cout<<"Yes"<<endl;
					}
					else{
						cout<<"No"<<endl;
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,K,sum;
  sum = 0;
  cin >> N >> K;
  for(int i=0;i<N;i++){
  	int x,b;
    cin >> x;
    b=x-K;
    if(b>=0){
      sum+=b;
    }
    else if(b<0){
      if(-b>x){
        sum+=x;
      }else{
      	sum=sum-b;
      }
    }
  }
  cout << sum*2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int qtosPares(int n){
    return (n*(n-1))/2;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(nullptr);
    int pares, impares, total = 0;
    cin>>pares>>impares;
    total += qtosPares(pares);
    total += qtosPares(impares);
    cout<<total<<'\n';
}

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

const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;


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

  if (a >= 3200) {
    cout << s << endl;
    return 0;
  }

  cout << "red" << endl;

}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int n, k;
vector<int> w;

bool ok(int P);

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int wi;
        cin >> wi;
        w.push_back(wi);
    }

    int l = 0, h = 1000000000;
    while (l + 1 < h) {
        int m = (l + h) / 2;
        if (ok(m))
            h = m;
        else
            l = m;
    }
    printf("%i\n", h);
}

bool ok(int P)
{
    int cnt = 1;
    int Pl = P;
    for (int a : w) {
        if (P < a)
            return false;
        if (Pl >= a) {
            Pl = Pl - a;
        } else {
            Pl = P - a;
            cnt++;
        }
    }
    return k >= cnt;
}


Measured memory_bytes: 3432
import qualified Data.IntMap as M
import Data.Maybe (fromJust)
import Data.Array.IO
import Data.List
import Control.Monad

main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  input <- (\[x,y] -> zip x y) . transpose . map (map read . words) . lines <$> getContents :: IO [(Int, Int)]
  let graph = foldl makeGraph M.empty input
      ne = fromJust $ M.lookup 1 graph
  count <- newArray (0, 0) 0 :: IO (IOUArray Int Int)
  mark <- newArray (1, n) False :: IO (IOUArray Int Bool)
  writeArray mark 1 True
  foldM (search graph count (n-1) 1 1) mark ne
  print =<< head <$> getElems count

--key:頂点番号, value:隣接点集合
type Graph = M.IntMap [Int]

--隣接リスト
makeGraph :: Graph -> (Int, Int) -> Graph
makeGraph graph (x, y) =
  let nX = M.lookup x graph
      nY = M.lookup y graph
      vX = if nX == Nothing
             then M.insert x [y] graph
             else M.insert x (y:(fromJust nX)) graph
  in if nY == Nothing
       then M.insert y [x] vX
       else M.insert y (x:(fromJust nY)) vX

--DFS : 前pre 現在i
search :: Graph -> IOUArray Int Int -> Int -> Int -> Int -> IOUArray Int Bool -> Int -> IO (IOUArray Int Bool)
search graph count n k pre mark i = do
  isMark <- readArray mark i
  case isMark of
    True -> do
      return mark
    False -> do
      c <- readArray count 0
      let c' = if n == k then c+1 else c
      writeArray count 0 c'
      writeArray mark i True
      let ne = fromJust $ M.lookup i graph
      foldM (search graph count n (k+1) i) mark ne
      writeArray mark i False
      return mark


Measured memory_bytes: 892
MOD = 10**9 + 7

Ss = input()

N = len(Ss)

dp = [[0]*(13) for _ in range(N+1)]
dp[0][0] = 1
for d, Sd in enumerate(Ss):
#    print(d, Sd)
    for mod13 in range(13):
        if Sd != '?':
            x = int(Sd)
            mod13n = (10*mod13 + x) % 13
            dp[d+1][mod13n] += dp[d][mod13]
            dp[d+1][mod13n] %= MOD
        else:
            for x in range(10):
                mod13n = (10*mod13 + x) % 13
                dp[d+1][mod13n] += dp[d][mod13]
                dp[d+1][mod13n] %= MOD

print(dp[-1][5])


Measured memory_bytes: 61916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 2e9 + 55;

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

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

    stack<pair<char, ll> > stak;

    ll fRes = 0;
    for(int i = n - 1; i >= 0; i--){
        if(s[i] == 'W'){
            stak.push(make_pair(s[i], 1));
        } else {
            ll cnt = 0;
            while(!stak.empty() && (stak.top().first == 'W')){
                cnt += stak.top().second;
                stak.pop();
            }
            fRes += cnt;
            stak.push(make_pair('B', 1));
            if(cnt){
                stak.push(make_pair('W', cnt));
            }
        }
    }
    cout << fRes << '\n';

    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    int n, l; cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    sort(all(s));
    rep(i, n) cout << s[i];
    cout << endl;
}

Measured memory_bytes: 3644
import math


class Solution:
    def solve(self, N: int, M: int, S, T):

        mod = 10**9 + 7

        N_MAX = 2005

        dp = [[0] * N_MAX for _ in range(N_MAX)]
        s = [[0] * N_MAX for _ in range(N_MAX)]

        for i in range(1, N + 1):
            for j in range(1, M + 1):
                dp = 0
                if S[i - 1] == T[j - 1]:
                    dp = s[i - 1][j - 1] + 1
                s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + dp
                s[i][j] %= mod

        return (s[N][M] + 1)


if __name__ == '__main__':

    # standard input
    N, M = map(int, input().split())
    S = list(map(int, input().split()))
    T = list(map(int, input().split()))

    # solve
    solution = Solution()
    print(solution.solve(N, M, S, T))


Measured memory_bytes: 104540
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <stack>
#include <string>
#include <deque>
#include <map>

using namespace std;

void func(string source) {
    int a[4] = {0, 0, 0, 0};
    for (int i = 0; i < 4; ++i) {
        a[i] = source[i] - '0';
    }
    int first = a[0] * 10 + a[1];
    int second = a[2] * 10 + a[3];

    if ((first > 12 && second > 12) || (first == 0 && second == 0)) {
        cout << "NA" << endl;
        return;
    }
    if (first == 0 || second == 0) {
        if (first == 0 &&  second <= 12) {
            cout << "YYMM" << endl;
            return;
        }
        if (second == 0 && first <= 12) {
            cout << "MMYY" << endl;
            return;
        }
        cout << "NA" << endl;
        return;
    }

    if (first <= 12 && second <= 12) {
        cout << "AMBIGUOUS" << endl;
        return;
    }
    if (first >= 12) {
        cout << "YYMM" << endl;
        return;
    }
    cout << "MMYY" << endl;
    return;
}

int main() {
    string source;
    cin >> source;
    func(source);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
     long long int ans = 0;

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


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

const static int MAX = 25;

class Node {
public:
    int parent, left, right;
    Node(int parent = -1, int left = -1, int right = -1) : parent(parent), left(left), right(right) {}
};

Node T[MAX];
int H[MAX], D[MAX];


void preOrder(int node) {
    if (node == -1) return;
    std::printf(" %d", node);
    preOrder(T[node].left);
    preOrder(T[node].right);
}

void inOrder(int node) {
    if (node == -1) return;
    inOrder(T[node].left);
    std::printf(" %d", node);
    inOrder(T[node].right);
}

void postOrder(int node) {
    if (node == -1) return;
    postOrder(T[node].left);
    postOrder(T[node].right);
    std::printf(" %d", node);
}

int main()
{
    int N, node, left, right, root = 0;
    std::scanf("%d", &N);

    for (int i = 0; i < N; i++) {
        std::scanf("%d %d %d", &node, &left, &right);
        if (left != -1) T[left].parent = node;
        if (right != -1) T[right].parent = node;
        T[node].left = left; T[node].right = right;
    }

    for (int i = 0; i < N; i++) {
        if (T[i].parent == -1) {
            root = i;
            break;
        }
    }
    std::printf("Preorder\n");
    preOrder(root);
    std::printf("\n");
    std::printf("Inorder\n");
    inOrder(root);
    std::printf("\n");
    std::printf("Postorder\n");
    postOrder(root);
    std::printf("\n");


    return 0;
}



Measured memory_bytes: 3216
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N,ans=1; cin >> N;
	VLL d(N);
	for (int i = 0;i < N;i++) {
		cin >> d[i];
	}
	sort(all(d));
	for (int i = 1;i < N;i++) {
		if(d[i]!=d[i-1])ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef pair <lli,lli> pr;



int frogjump(vector <lli> &stone, lli N,vector <lli> &jumps,lli K){
    //base condition
    if(N == 1){
        return jumps[N-1] = 0;
    }

    
    else if(N == 2){
        return jumps[N-1] = abs(stone[N-1]-stone[N-2]);
    }

    //choice diagram
    if(jumps[N-1] != -1){
        return jumps[N-1];
    }

    else{
        lli ans = INT_MAX;
        for(lli i=1;i<=K;i++){

            if(N-1-i < 0)
            break;
            ans = min(ans,abs(stone[N-1]-stone[N-1-i])+frogjump(stone,N-i,jumps,K));
            //cout << ans << endl;
        }
        return jumps[N-1] = ans;
    }
    
}

int main(){
    lli N,K;
    cin >> N >> K;

    vector <lli> stone(N);
    vector <lli> jumps(N,-1);

    for(int i=0;i<N;i++){
        cin >> stone[i];
    }

    reverse(stone.begin(),stone.end());

    cout << frogjump(stone,N,jumps,K) << endl;

    /*for(int i=0;i<N;i++){
        cout << jumps[i] << " ";
    }*/
    //cout <<endl;
}

Measured memory_bytes: 12744
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int x; cin >> x;
    if (x == 7 || x == 5 || x == 3) cout << "YES" << '\n';
    else cout << "NO" << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int ar[200005];
int br[200005];
int main()
{
    ll r,s,i,j,mx,m,ans=0,a,b,c;
    while(cin>>a>>b>>c){
    ans=(b+c)-a;
    if(ans<=0)cout<<"0"<<endl;
    else
        cout<<ans<<endl;
    }


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll n,m;cin>>n>>m;ll r;ll b,c;
    map <ll,ll> omp;ll sum=0;
    for(ll i=0;i<n;++i)
    {
        cin>>r;sum+=r;
        auto it=omp.find(r);
        if(it!=omp.end()){it->second++;}
        else
        {
            omp.insert(make_pair(r,1));
        }
    }
    //map <ll,ll> omp(mp.begin(),mp.end());
    for(ll i=0;i<m;++i)
    {
        cin>>b>>c;
        for(auto it=omp.begin();it!=omp.end();++it)
        {
            if(it->first>=c){break;}
            ll ran=min(b,it->second);
            sum+=((c-it->first)*ran);
            auto it1=omp.find(c);
            if(it1!=omp.end()){it1->second+=ran;}
            else{omp.insert(make_pair(c,ran));}
            b=b-ran;
            it->second=it->second-ran;
            if(it->second==0){omp.erase(it->first);}
            if(b<=0){break;}
        }
    }
    cout<<sum;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
int main()
{
    double l;
    cin >> l;
    cout << setprecision(20) << l * l * l / 27.0 << endl;
}

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

using ll = long long;

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

    int n,k;
    cin>>n>>k;

    ll ans=k;

    for(int i=1;i<n;i++)ans*=(k-1);

    cout<<ans<<"\n";

    return 0;
}


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

int main(){
  int n, a[100000], cnt;
  long long ans[2] = {};
  
  cin >> n;
  for(int i = 0;i < n;i++) cin >> a[i];
  
  sort(a, a + n);
  
  cnt = 0;
  for(int i = n - 1;i > 0;i--){
    if(a[i] == a[i - 1]){
      ans[cnt++] = a[i];
      i--;
    }
    if(cnt == 2) break;
  }
  
  cout << ans[0] * ans[1] << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>

using namespace std;

int main(){

    string s;
    cin >> s;

    int cnt = 0;
    long long ans = 0;
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == 'A'){
            cnt++;
        }
        else if(s[i] == 'B' && i < (int)s.size() - 1 && s[i + 1] == 'C'){
            ans += cnt;
            i++;
        }
        else{
            cnt = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

#define N 8
#define NOTFREE -1
#define FREE 1

void putQueen(int);
void printBoard(void);

int r,c;
int k[N][N];
int row[N];
int col[N];
int dpos[15];
int dneg[15];

int main() {
  int i,j,n;

  for(i=0;i<N;i++){
    row[i]=FREE;
    col[i]=FREE;
    for(j=0;j<N;j++){
      k[i][j]=0;
    }
  }
  for(i=0;i<15;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&r,&c);
    k[r][c] = NOTFREE;
  }

  putQueen(0);

  return 0;
}

void putQueen(int i){
  int j;

  if(i==N){
    printBoard();
    return;
  }

  for(j=0;j<N;j++){
    if(col[j]==NOTFREE||dpos[i+j]==NOTFREE||dneg[i-j+N-1]==NOTFREE) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOTFREE;
    putQueen(i+1);
    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

void printBoard(void){//printf("in\n");
  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(k[i][j]==NOTFREE&&row[i]!=j) return;
    }
  }

//printf("here\n");
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
  //printf("\n");
}

Measured memory_bytes: 572
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[4],ans=0;
	cin>>a[1]>>a[2]>>a[3];
	while(a[1]!=a[2]||a[2]!=a[3]||a[1]!=a[3])
	{
		sort(a+1,a+4);
		if(a[2]!=a[3]){a[1]++;a[2]++;}
		else a[1]+=2;
		ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 3576
N = int(input())

def f(n):
    res = []
    i = 1
    while i <= n**0.5:
        if n%i == 0:
            res.append(n)
            if N//i > i:
                res.append(N//i)
        i += 1
    return res

num = 4
if N%4 == 0:
    num = 1
    N //= 4
elif N%2 == 0:
    num = 2
    N //= 2

P = f(N)
P.sort(reverse=True)
ans = []
for p in P:
    i = 1
    while p*i <= 3500:
        Q = f(N//p)
        for q in Q:
            j = 1
            while q*j <= 3500:
                if num*p*i*q*j-(p*i+q*j)*N > 0 and ((p*i)*(q*j)*N)%(num*p*i*q*j-(p*i+q*j)*N) == 0:
                    ans = [p*i, q*j, ((p*i)*(q*j)*N)//(num*p*i*q*j-(p*i+q*j)*N)]
                    i = 4000
                    j = 4000
                j += 1
            if len(ans) > 0:
                break
        i += 1
    if len(ans) > 0:
        break

print(*ans)

Measured memory_bytes: 9564
#include <iostream>
#include <string>

std::string str, t;

int main(){
    std::cin >> str >> t;

    int k = -1;
    for(int i = str.size() - 1; i >= t.size() - 1; i--){
        bool flag = true;
        for(int j = t.size() - 1; j >= 0; j--){
            if((str[i + j - t.size() + 1] != t[j]) &&
                str[i + j - t.size() + 1] != '?'){

                flag = false;
                break;
            }
        }

        if(flag){
            k = i - t.size() + 1;
            break;
        }
    }

    if(k == -1){
        std::cout << "UNRESTORABLE\n";
    }else{
        int c = 0;
        for(int i = 0; i < str.size(); i++){
            if(k <= i && i < k + t.size()){
                str[i] = t[c++];
            }else if(str[i] == '?'){
                str[i] = 'a';
            }
        }

        std::cout << str << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N,Z,W;
    cin >> N >> Z >> W;
    auto A = InputVec(N);
    if(N == 1){
        cout << abs(A[0] - W) << endl;
    }else{
        cout << max(abs(A[N-1]-A[N-2]),abs(A[N-1]-W)) << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int n;
    double x1, x2, x3, y1, y2, y3;
    double a, b, c, sinA, xa, ya, r;
    double cosA, cosB, cosC;

    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

        a = sqrt(pow(x2 - x3, 2) + pow(y2 - y3,2));
        b = sqrt(pow(x1 - x3, 2) + pow(y1 - y3,2));
        c = sqrt(pow(x2 - x1, 2) + pow(y2 - y1,2));

        cosA = (pow(b, 2) + pow(c, 2) - pow(a, 2)) / (2 * b * c);
        cosB = (pow(c, 2) + pow(a, 2) - pow(b, 2)) / (2 * c * a);
        cosC = (pow(a, 2) + pow(b, 2) - pow(c, 2)) / (2 * a * b);

        sinA = sqrt(1.0 - pow(cosA, 2));

        xa = (a * cosA * x1 + b * cosB * x2 + c * cosC * x3) / (a * cosA + b * cosB + c * cosC);
        ya = (a * cosA * y1 + b * cosB * y2 + c * cosC * y3) / (a * cosA + b * cosB + c * cosC);
        r = a / (2.0 * sinA);

        cout << fixed << setprecision(3) << xa << " " << ya << " " << r << endl;
    }
}


Measured memory_bytes: 3204
n,y = map(int,input().split())
y //= 1000
flag = False

for k in range(0,n+1):
  a = n-k
  b = y-10*k-a
  if b%4 == 0 and b <= 4*a and b>=0:
    flag = True
    break
    
if flag:
  print(k,b//4,a-b//4)
else:
  print(-1,-1,-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 500'001;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  string s;
  cin >> n >> s;
  int64 ans = 1;
  int c = 1;
  int mode = 0;
  int cnt = 0;
  for (int i = 1; i < n + n; ++i) {
    if (s[i - 1] == s[i]) {
      mode ^= 1;
    }
    cnt += mode;
    if (!mode) {
      ++c;
    }
    else {
      ans *= c;
      ans %= mod;
      --c;
    }
  }
  if (s.front() == 'W' || s.back() == 'W' || cnt != n) {
    cout << "0\n";
    return;
  }
  for (int i = 1; i <= n; ++i) {
    ans *= i;
    ans %= mod;
  }
  cout << ans << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 720
#include <vector>
#include <cmath>
#include <algorithm>
#include <iostream>

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

const string YES = "YES";
const string NO = "NO";


bool check(vector<ll> &p, ll i, ll j){

  swap(p[i], p[j]);

  for(ll k=0; k<p.size()-1; k++){
    if(p[k] >= p[k+1]) {
      swap(p[i], p[j]);
      return false;
    }
  }

  swap(p[i], p[j]);
  return true;
}

void solve(long long N, std::vector<long long> p){
  for(ll i =0; i<p.size(); i++){
    for(ll j =0; j<p.size(); j++){
      if(check(p, i, j)){
        cout << YES << endl;
        return;
      }
    }
  }
  cout << NO << endl;
}

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


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int,input().split())
dx = x2 - x1
dy = y2 - y1
x3 = x2 - dy
y3 = y2 + dx
x4 = x1 - dy
y4 = y1 + dx
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

ll a[(ll)1e5+5];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        ll d;cin>>d;sum+=d;a[d]++;
    }
    ll q;cin>>q;
    for(int i=0;i<q;i++){
        ll c,d;cin>>c>>d;
        sum+=a[c]*(d-c);
        a[d]+=a[c];a[c]=0;
        cout<<sum<<"\n";
    }

}


Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
const int inf = 1001001001;
int dist[1000005][3];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, M;
    cin >> N >> M;
    vvec<int> to(N);
    rep(i,M){
        int a, b;
        cin >> a >> b;
        a--;b--;
        to[a].push_back(b);
    }
    int sv, tv;
    cin >> sv >> tv;
    sv--;tv--;
    queue<pair<int, int>> q;
    q.push({sv,0});
    rep(i,N)rep(j,3){
        dist[i][j] = inf;
    }
    dist[sv][0] = 0;
    while(!q.empty()){
        int v = q.front().first;
        int l = q.front().second;
        q.pop();
        for(int u: to[v]){
            int nl = (l+1)%3;
            if(dist[u][nl] != inf)continue;
            dist[u][nl] = dist[v][l] + 1;
            q.push({u, nl});
        }
    }
    int ans = dist[tv][0];
    if(ans == inf)ans = -1;
    else ans /= 3;
    cout << ans << endl;
}

Measured memory_bytes: 6912
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.*;

public class Main {
	int w, h, cnt, k;
	char[][] map;
	Point2D.Double[][] p;
	boolean check;
	boolean[] f;
	
	
	Point2D.Double dfs(int n){
		f[n] = true;
		boolean flag;
		LinkedList<Point2D.Double> list = new LinkedList<Point2D.Double>();
		double minx = Integer.MAX_VALUE;
		double maxx = 0;
		
		if(n==0){
			for(int i=0;i<4;i++){
				if(p[n][i].y==0){
					minx = Math.min(minx, p[n][i].x);
					maxx = Math.max(maxx, p[n][i].x);
				}
			}
		}else{
			for(int i=0;i<4;i++){
				for(int s=0;s<cnt;s++){
					if(s!=n){
						for(int t=0;t<4;t++){
							if(p[n][i].x==p[s][t].x && p[n][i].y-1==p[s][t].y){
								minx = Math.min(minx, p[n][i].x);
								maxx = Math.max(maxx, p[n][i].x);
							}
						}
					}
				}
			}
		}
	
		for(int i=0;i<4;i++){
			flag = false;
			for(int j=0;j<4;j++) if(p[n][i].x==p[n][j].x && p[n][i].y+1==p[n][j].y) flag=true;
			if(flag==false){
				for(int s=0;s<cnt;s++){
					for(int t=0;t<4;t++){
						if(f[s]==false && p[n][i].x==p[s][t].x && p[n][i].y+1==p[s][t].y){
							list.add(dfs(s));
							s = cnt;
							t = 4;
						}
					}
				}
			}
		}
		
		double sumw = 4;
		double sumx = 0;
		for(int i=0;i<list.size();i++){
			sumx += list.get(i).x * list.get(i).y;
			sumw += list.get(i).y;
		}
		for(int i=0;i<4;i++) sumx += p[n][i].x;
		sumx/=sumw;
		if(minx-0.5>=sumx || maxx+0.5<=sumx) check = false;
		
		return new Point2D.Double(sumx,sumw);
	}
	
	void search(int y, int x, char c){
		k++;
		p[cnt][k] = new Point2D.Double(x,y);
		map[y][x] = '.';
		if(y!=h-1 && map[y+1][x]==c) search(y+1,x,c);
		if(x!=w-1 && map[y][x+1]==c) search(y,x+1,c);
		if(x!=0 && map[y][x-1]==c) search(y,x-1,c);
	}
	
	void setP(){
		cnt = 0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(map[i][j]!='.'){
					k = -1;
					search(i,j,map[i][j]);
					cnt++;
				}
			}
		}
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w==0 && h==0) break;
			
			map = new char[h][w];
			p = new Point2D.Double[(w*h)/4][4];
			for(int i=h-1;i>=0;i--) map[i] = sc.next().toCharArray();
			setP();
			check = true;
			f = new boolean[cnt];
			dfs(0);
			if(check==true) System.out.println("STABLE");
			else System.out.println("UNSTABLE");
		}	
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}	
}

Measured memory_bytes: 27204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c; cin>>a>>b>>c;
    cout << a*b/2 <<endl;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;

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

	int a;
	cin >> a;
	string s;
	cin >> s;

	if(a  >= 3200){
		cout << s << endl;
	}else{
		cout << "red" << endl;
	}




    return 0;
}



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

int main() {
   
  long long int n,i;
  int flag=0;
  cin>>n;
  long double a;
  long double pro=1;
  long double max=1000000000000000000;
  vector<long double> v;
  for(i=0;i<n;++i)
      { cin>>a;
        v.push_back(a);
        if(a==0)
           flag=1;
      }
      
    if(flag==1)
       cout<<"0";
       
    else
    {
      
    sort(v.begin(),v.end());
    
    for(i=v.size()-1;i>=0;--i)
      {
          pro*=v[i];
          if(pro>max)
             break;
             
      }
      if(i<0)
        cout<<(long long int )pro;
        
      else
        cout<<"-1";
        
      
    }
      
  
      
       
	return 0;
}


Measured memory_bytes: 5440
// B - Collatz Problem
#include <bits/stdc++.h>
using namespace std;

int bit_count(int a){
	int c = 0;
	while(a>0){
		if(a&1) c++;
		a>>=1;
	}
	return c;
}

int bit_size(int a){
	int c = 0;
	while(a>0){
		c++;
		a>>=1;
	}
	return c;
}

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

	int ans = 0;

	int a = S;
	while(bit_count(a)>1){
		if(a%2) a=3*a+1;
		else a/=2;
		ans++;
	}

	if(a<4) ans += 4;
	else ans += bit_size(a) + 1;

	cout<< ans <<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define endl '\n'
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
using namespace std;
using namespace __gnu_pbds;

bool cmp(pair<int, string> a, pair<int, string> b) {
	if(a.f != b.f)
		return a.f > b.f;
	return a.s < b.s;
}

int32_t main() {

	int n;
	cin >> n;
	map<string, int> mapa;
	while(n--) {
		string s;
		cin >> s;
		mapa[s]++;
	}
	vector<pair<int, string>> v;
	for(auto i : mapa) 
		v.push_back({i.s, i.f});
	
	sort(v.begin(), v.end(), cmp);

	cout << v[0].s << endl;
	for(int i = 1; i < v.size(); i++) {
		if(v[i].f != v[i-1].f) break;
		cout << v[i].s << endl;

	}
}

Measured memory_bytes: 29284
#include<iostream>

int main(){
  int r;
  std::cin >> r;

  if(r < 1200){
    std::cout << "ABC" << std::endl;
  } else if(r < 2800){
    std::cout << "ARC" << std::endl;
  } else {
    std::cout << "AGC" << std::endl;
  }
}


Measured memory_bytes: 256
s=input()
t=input()
e=0
for i in range(len(s)):
    if s==t:
        print("Yes")
        e=e+1
        break
    else:
        s=s[len(t)-1]+s[0:len(s)-1]
        #print(t)
if e==0:
    print("No")


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(c-(a-b) >= 0){
    cout << c-(a-b) << endl;
  }else{
    cout << 0 << endl;
  }

  return(0);
}

Measured memory_bytes: 3588
#!/usr/bin/env python3
#ABC42 C

n,k = map(int,input().split())
d = list(map(int,input().split()))

for i in range(n,100000):
    s = list(map(int,list(str(i))))
    for j in s:
        if j in d:
            break
    else:
        print(i)
        break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

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

    int a, b, c;
    cin >> a >> b >> c;
    if (c-(a-b) <= 0) cout << 0 << endl;
    else cout << c-(a-b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int N, a[110], A=0, B=0;

  cin >> N;
  for(int i = 0; i < N; i++) cin >> a[i];

  sort(a, a+N);
  reverse(a, a+N);

  for(int i = 0; i < N; i++){
    if(i%2==0) A += a[i];
    else B += a[i];
  }

  int ans = A - B;

  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end();++it)
#define MOD 1000000007
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = 2147493647;
const double pi = acos(-1);
const double EPS = 1e-9;

int main()
{
    ll n;
    cin >> n;
    vi B(n-1);
    rep(i,0,n-1){
        cin >> B[i];
    }
    ll sm = B[0]+B[n-2];
    rep(i,0,n-2){
        sm += min(B[i],B[i+1]);
    }
    cout << sm << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{ int n,x,t;
  scanf("%d %d %d",&n,&x,&t);
  int time;
 time=n/x;
 if(n%x==0)
 time=(time)*t;
 else
   time=(time+1)*t;
 printf("%d",time);
  
  
  
  
  
  
}


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

int main()
{
	int n;

	while(true){
		int x,x0=0,x10=0,x20=0,x30=0,x40=0,x50=0,x60=0;
		cin >> n;

		if(n==0)
			break;

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

			if(0<=x && 10>x)
				x0++;
			else if(10<=x && 20>x)
				x10++;
			else if(20<=x && 30>x)
				x20++;
			else if(30<=x && 40>x)
				x30++;
			else if(40<=x && 50>x)
				x40++;
			else if(50<=x && 60>x)
				x50++;
			else if(60<=x)
				x60++;
		}

		cout << x0 << endl;
		cout << x10 << endl;
		cout << x20 << endl;
		cout << x30 << endl;
		cout << x40 << endl;
		cout << x50 << endl;
		cout << x60 << endl;
	}

	return 0;
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

int main(){
    ll x;
    cin >> x;
    ll ans = (x / 11) * 2;
    if(x % 11 > 6) ans += 2;
    else if(x % 11 > 0) ans ++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//Awwawa! Dis cold yis ratten buy waxberry!
#include <bits/stdc++.h>
#define ll long long
#define maxn 200005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
char inp[maxn];
int main() {
	int a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	ll dis = abs(a - b);
	ll to = 1ll * t * (v - w);
	if (to >= dis) cout << "YES" << endl;
	else cout << "NO" << endl; 
	return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
     
    using namespace std;
     
    const int MX = 200 * 1000 + 7;
     
    int a[MX];
     
    int main() {
    #ifdef BZ
        freopen("input.txt", "r", stdin);
    #endif
        ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
        int n;
        cin >> n;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            if (a[i] > i) {
                cout << "-1\n";
                return 0;
            }
          	if (i > 0 && a[i] - a[i - 1] > 1) {
              cout << "-1\n";
              return 0;
            }
        }
        int ptr = n - 1;
        long long ans = 0;
        while (ptr >= 0) {
            int go = ptr;
            while (go - 1 >= 0 && a[go - 1] == a[go] - 1) {
                go--;
            }
            ans += a[ptr];
            ptr = go - 1;
        }
        cout << ans << "\n";
    }
     

Measured memory_bytes: 1024
using System;
class Prpgram
{
    static void Main(string[] args)
    {
        string color = Console.ReadLine();
        string boru = Console.ReadLine();
        string away = Console.ReadLine();

        string[] colorlist = color.Split(' ');
        //string S = colorlist[0];
        //string T = colorlist[1];

        string[] borulist = boru.Split(' ');
        int A = int.Parse(borulist[0]);
        int B = int.Parse(borulist[1]);

        if (colorlist[0] == away) A--;
        else B--;

        Console.Write(A + " " + B);

    }
}

Measured memory_bytes: 13140