akhauriyash/Code-Regression huggingface dataset:
from bisect import bisect_left, bisect_right
N = int(input())
S = list(input())
Q = int(input())
D = {chr(ord('a') + i): [] for i in range(26)}
for i, s in enumerate(S):
    D[s].append(i)

for q in range(Q):
    query = list(input().split())
    if query[0] == '1':
        i, x = int(query[1]), query[2]
        i -= 1
        s = S[i]
        if s == x:
            continue
        D[s].remove(i)
        ni = bisect_left(D[x], i)
        D[x].insert(ni, i)
        S[i] = x
    else:
        l, r = int(query[1]), int(query[2])
        l -= 1
        r -= 1
        ans = 0
        for i in range(26):
            s = chr(ord('a') + i)
            li = bisect_left(D[s], l)
            ri = bisect_right(D[s], r)
            if ri - li > 0:
                ans += 1
        print(ans)


Measured memory_bytes: 134972
N, Q = map(int,input().split())
S = list(input())
lr = [list(map(int,input().split())) for i in range(Q)]
ans = ''
a = [0]
count = 0
for i in range(N-1):
  if S[i] + S[i+1] == 'AC':
    ans += '1'
  else:
    ans += '0'
  if i == N - 2:
    ans += '0'
else:
  for i in range(N):
    if ans[i] == '1':
      count += 1
      a.append(count)
    else:
      a.append(count)
  else:
    for i in range(Q):
      l = lr[i][0]
      r = lr[i][1]
      print(a[r-1]-a[l-1])

Measured memory_bytes: 31568
N,K=map(int, input().split())
stopf = True
wari = N // K
N = N - K*wari
def exchangeK():
    global stopf
    global N
    if N > abs(N-K):
        N = abs(N-K)
    else:
        stopf = False
while stopf:
    exchangeK()
print(N)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int dp[1007][1007] = {};
char table[1007][1007];

int main() {
	
	int i,j;
	int H,W;
	
	cin >> H >> W;
	for( i=1; i<=H; i++) {
		scanf("%s", table[i]+1);
	}
	
	if( table[1][1] == '.')
		dp[1][1] = 1;
	for( i=1; i<=H; i++) {
		for( j=1; j<=W; j++) {
			if( table[i][j] == '#' || dp[i][j])
				continue;
			dp[i][j] = ( dp[i][j-1] + dp[i-1][j] ) % MOD;
		}
	}
	
	printf("%d\n", dp[H][W]);
	
	return 0;
} 

Measured memory_bytes: 8680
N,M = [int(i) for i in input().split()]
transferlist = []
for i in range(M):
    transferlist.append([int(i)-1 for i in input().split()])

#print(transferlist)

box = [[1,0] for i in range(N)] #ボールの数、1つ赤い球があるか
box[0][1] = 1

for x,y in transferlist:
    box[x][0] -=1
    box[y][0] += 1
    if box[x][1] == 1:
        box[y][1] = 1
    if box[x][0] == 0:
        box[x][1] = 0

ans = sum(i[1] for i in box)
print(ans)

Measured memory_bytes: 31372
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;

bool T[1000001];

string kakezan(string s)
{
  int m = -1;
  for(int i = 1; i < s.size(); i++){
    m = max(m, atoi(s.substr(0,i).c_str()) * atoi(s.substr(i).c_str()));
  }
  ostringstream ostr;
  ostr << m;
  return ostr.str();
}

int main()
{
  int Q;
  cin >> Q;
  REP(i,Q){
    fill(T, T+1000001, false);
    string N;
    cin >> N;
    if(N.size() == 1){
      cout << "0" << endl;
      continue;
    }
    int ans = 0;
    string s = N;
    while(s.size() != 1){
      s = kakezan(s);
      if(T[atoi(s.c_str())]){
        cout << "-1" << endl;
        break;
      }
      T[atoi(s.c_str())] = true;
      ans++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 2212
#include <cstdio>
#include <cmath>
#include <limits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric> // 最大公約数が使える
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; //10^9

int main(){
    ll n,m;
    cin >> n >> m;
    pair<char,ll> N[n];
    int ans=0;
    for (ll i = 0; i < n; i++)
    {
        ll H;
        cin >> H;
        N[i] = make_pair('T',H);
    }
    for (ll i = 0; i < m; i++)
    {
        ll A,B;
        cin >> A >> B;
        A = A-1;
        B = B-1;
        if(N[A].second<N[B].second){
            N[A].first = 'F';
        }else if(N[A].second==N[B].second){
            N[A].first = 'F';
            N[B].first = 'F';
        }else
        {
            N[B].first = 'F';
        }
    }
    for (ll i = 0; i < n; i++)
    {
        if(N[i].first=='T'){
            ans++;
        }
    }
    cout << ans <<  endl;
    
    /*
    vector<ll> N(n);
    for (ll i = 0; i < n; i++)
    {
        ll H;
        cin >> H;
        N.push_back(N);
    }
    for (ll i = 0; i < M; i++)
    {
        ll A,B;
        if(N[A])
    }
    */
    
}

Measured memory_bytes: 5196
#include<iostream>
using namespace std;
#include<algorithm>
#include<cstring>
#include<string>
#include<stdio.h>
#include<map>
#include<vector>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#include<set>
#define maxn 1000005
#define INF 1e9
#define ll long long
char ch[maxn];
stack<int> sta;
int main()
{
	cin >> ch;
	int ans = 0,len=strlen(ch);
	for (int i = 0; i < len; i++) {
		if (ch[i] == 'S')
			sta.push(i);
		else {
			if (!sta.empty()) {
				ans += 2;
				sta.pop();
			}
			else continue;
		}
	}
	cout << len - ans << endl;
	return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

const int N = 1e5 + 5;

vi adj[N];
int col[N], ed[N];

int main(){
    fIO

    int n;
    cin >> n;

    int x, y;
    map<pii, int> edge;
    for(int i = 0; i < n - 1; i++){
        cin >> x >> y;
        edge[{min(x, y), max(x, y)}] = i;
        adj[x].pb(y);
        adj[y].pb(x);
    }

    queue<int> q;
    col[1] = -1;
    q.push(1);

    int maxi = 1;
    while(!q.empty()) {
        int nd = q.front(); q.pop();

        int use = 1;
        for(auto ch : adj[nd]) {
            if(col[ch] == 0) {
                pair<int, int> p = make_pair(min(ch, nd), max(ch, nd));
                int idx = edge[p];
                if(col[nd] == use) use++;
                col[ch] = use++;
                ed[idx] = use - 1;
                q.push(ch);
                maxi = max(maxi, use - 1);
            }
        }
    }
    cout << maxi << "\n";

    for(int i = 0; i < n - 1; i++) cout << ed[i] << "\n";



}











Measured memory_bytes: 13184
ans=chk=0
a=[0,2,5,3]
b=[0,1,5,4]
c=[1,2,4,3]

def sortdice(dice1,dice2,p,q,r):
    for i in range(4):
        dice1[p[0]],dice1[p[1]],dice1[p[2]],dice1[p[3]]=dice1[p[1]],dice1[p[2]],dice1[p[3]],dice1[p[0]]
        for j in range(4):
            dice1[q[0]],dice1[q[1]],dice1[q[2]],dice1[q[3]]=dice1[q[1]],dice1[q[2]],dice1[q[3]],dice1[q[0]]
            for k in range(4):
                dice1[r[0]],dice1[r[1]],dice1[r[2]],dice1[r[3]]=dice1[r[1]],dice1[r[2]],dice1[r[3]],dice1[r[0]]
                if dice1==dice2:
                    print 'Yes'
                    exit()
    return 0
 
l1=map(int,raw_input().split())
l2=map(int,raw_input().split())
sortdice(l1,l2,a,b,c)
print 'No'

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

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

int main() {
#ifdef BZ
    freopen("in", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    for (int a = 1; a <= n; a++) {
        int l = k, r = a - 1;
        if (l > r) continue;
        while (l <= n) {
            int cl = l, cr = r;
            cl = max(1, cl);
            cr = min(n, cr);
            ans += cr - cl + 1;
            l += a;
            r += a;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
int main()
{
	cin >>n>>m;
	cout <<max(max(n+m,n-m),n*m);
	return 0;
} 

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

//FILE *fin = freopen("d.in", "r", stdin);

/* ---------------------- */
int n;
vector < int > V[maxN];
/* ---------------------- */
bool vis[maxN];

bool dfs(int nod)
{
    int nr = 0, ans = 0;
    vis[nod] = 1;
    for (int son : V[nod])
        if (!vis[son])
        {
            ++ nr;
            ans += dfs(son);
        }
    if (nr == 0)
        return 0;
    if (nr != 1 && ans < nr - 1)
    {
        printf("First\n");
        exit(0);
    }
    return (ans == nr - 1);
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i)
    {
        int x, y;
        scanf("%d %d", &x, &y);
        V[x].push_back(y);
        V[y].push_back(x);
    }
    if ((n & 1) || !dfs(1))
        printf("First\n");
    else
        printf("Second\n");
    return 0;
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%mod)
#define mod 1000000007
#define pb push_back
#define STREAM_FAST ios::sync_with_stdio(false)
using namespace std;
const int maxn = 2e6 + 10;
int n, a[maxn], cnt[maxn], vis[maxn];
vector<int>pos[maxn];
LL cal(int x)
{
	LL dpzero = 1, dpx = 0;
	int now = 0, lastp = 1;
	while (now < (int)pos[x].size())
	{
		int thisp = pos[x][now];
		dpzero = MOD(dpzero + MOD(dpx * (cnt[thisp] - cnt[lastp - 1])));
		dpx = MOD(dpx + dpzero);
		lastp = thisp;
		now++;
	}
	if (a[n] == 0) return dpx;
	else return dpzero;
}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		a[i] ^= a[i - 1];
		pos[a[i]].pb(i);
		cnt[i] = cnt[i - 1] + (a[i] == 0);
	}
	LL ans = 0;
	if (a[n] != 0)
	{
		ans = MOD(ans + cal(a[n]));
	}
	else
	{
		for (int i = 1; i <= n; i++)
		{
			if (vis[a[i]] || a[i] == 0) continue;
			vis[a[i]] = 1;
			ans = MOD(ans + cal(a[i]));
		}
		LL anszero = 1;
		for (int i = 1; i < cnt[n]; i++) anszero = MOD(anszero * 2);
		ans = MOD(ans + anszero);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 69236
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main{

	public static void main(String[] args) throws Exception
	{
		String[] strRing = {"24532453","64136413","56215621","51265126","63146314","54235423"};

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		String[] strDice = br.readLine().split(" ");
		int q = Integer.parseInt(br.readLine() );

		HashMap<String,String> map = new HashMap<String,String>();

		for(int i=1; i<=6; i++) map.put(strDice[i-1],Integer.toString(i) );

		for(int i=0; i<q; i++)
		{
			String[] str = br.readLine().split(" ");

			String strB = Integer.toString(7 - Integer.parseInt(map.get(str[0]) )  );
			String strBST = strB + map.get(str[1]) + map.get(str[0]);

			for(int j=0; j<6; j++) if(-1 < strRing[j].indexOf(strBST) ) System.out.println(strDice[j]);
		}

	}
}

Measured memory_bytes: 24212
W, H, x, y = [int(i) for i in input().strip().split()]

S = (W*H) / 2

if (W % 2 == 0) and (H % 2 == 0) and (W // 2 == x) and (H // 2 == y):
  print(str(S) + " " + str(1))
else:
  print(str(S) + " " + str(0))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  long amax=0,amin=1000000000000;
  vector<long>a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
   for(int i=0;i<n;i++)
   {
     amax=max(amax,a.at(i));
     amin=min(amin,a.at(i));
   }
  cout<<amax-amin<<endl;
}
       


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

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include<iostream>
#include<stack>
using namespace std;
#define ll long long
const ll maxn = 1005;
const ll mod = 1e9 + 7;
const ll inf = 1 << 30;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	printf("%d %d %d",c,a,b);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <climits>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int INF = INT_MAX;


int count(unordered_map<int, int>& c, int v) {
  int count = 0;
  for (auto kv : c) {
    if (kv.first != v) {
      count += kv.second;
    }
  }
  return count;
}

int main(void) {
  int n; cin >> n;
  vector<int> evenC(100010, 0);
  vector<int> oddC(100010, 0);
  int emaxC = 0, omaxC = 0, emaxE = 0, omaxE = 0;
  for (int i = 0; i < n; i++) {
    int v; cin >> v;
    if (i % 2 == 0) {
      evenC[v]++;
      if (emaxC < evenC[v]) {
        emaxC = evenC[v];
        emaxE = v;
      }
    } else {
      oddC[v]++;
      if (omaxC < oddC[v]) {
        omaxC = oddC[v];
        omaxE = v;
      }
    }
  }
  sort(evenC.begin(), evenC.end(), greater<int>());
  sort(oddC.begin(), oddC.end(), greater<int>());

  if (emaxE != omaxE) {
    cout << n - emaxC - omaxC << endl;
  } else {
    cout << min(n - evenC[0] - oddC[1], n - evenC[1] - oddC[0]) << endl;
  }
}


Measured memory_bytes: 1024
s = input()

left = 0
right = len(s) - 1
x_cnt = 0

while left < right:
    if s[left] == s[right]:
        left += 1
        right -= 1
    else:
        if s[left] == 'x':
            x_cnt += 1
            left += 1
        elif s[right] == 'x':
            x_cnt += 1
            right -= 1
        else:
            print(-1)
            exit()

print(x_cnt)

Measured memory_bytes: 9144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int c1 = sc.nextInt();
		int c2 = sc.nextInt();

		int c3 = c1 + c2;

		System.out.println(c3%24);

		sc.close();
	}

}


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
	int n;
	cin >> n;
	int zero = 0;
	map<pair<ll,ll>,P> mp;
	rep(i,n) {
		ll x,y;
		cin >> x >> y;
		if (x == 0 && y == 0) {
			zero++;
			continue;
		}
		ll g = gcd(x,y);
		x /= g;
		y /= g;
		if (y < 0) x = -x, y = -y;
		if (y == 0 && x < 0)  x = -x, y = -y;
		bool rot90 = (x <= 0);
		if (rot90) {
			ll tmp = x;
			x = y; y = -tmp;
		}
		if (rot90) mp[{x,y}].first++;
		else mp[{x,y}].second++;
	}

	mint ans = 1;
	for (auto p : mp) {
		int s = p.second.first;
		int t = p.second.second;
		mint now = 1;
		now += mint(2).pow(s) - 1;
		now += mint(2).pow(t) - 1;
		ans *= now;
	}
	ans -= 1;

	ans += zero;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 16048
#include<stdio.h>

void insertionSort(int *A, int N){ // N個の要素を含む0-オリジンの配列A
    for(int i = 1; i < N; i++){
        int v = A[i];
        int j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for(int k = 0; k < N-1; k++){
            printf("%d ",A[k]);
        }
        printf("%d\n",A[N-1]);
    }
}

int main(void){
    int N;
    scanf("%d",&N);
    int A[N];
    for(int i = 0; i < N; i++){
        scanf("%d",&A[i]);
    }
    for(int i = 0; i < N-1; i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[N-1]);
    insertionSort(A, N);
    
}


Measured memory_bytes: 2140
#include <stdio.h>

int main(void)
{
	int A_life, B_atk;
	int C_life, D_atk;
	int i;

	scanf("%d%d%d%d", &A_life, &B_atk, &C_life, &D_atk);

	for (i = 0; A_life > 0 && C_life > 0; i++)
	{
		C_life -= B_atk;
		A_life -= D_atk;
	}

	if (C_life <= 0)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 1732
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

type Card struct {
	b, c int
}

type ByC []Card

func (a ByC) Len() int           { return len(a) }
func (a ByC) Less(i, j int) bool { return a[i].c < a[j].c }
func (a ByC) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M := sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(N)
	C := make([]Card, M)
	for i := 0; i < M; i++ {
		C[i] = Card{sc.nextInt(), sc.nextInt()}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	sort.Sort(sort.Reverse(ByC(C)))
	ans := []int{}
	cntA := 0
	cntC := 0
	for i := 0; i < N; i++ {
		a := A[cntA]
		if cntC >= M {
			ans = append(ans, a)
			cntA++
		} else {
			if a < C[cntC].c {
				ans = append(ans, C[cntC].c)
				C[cntC].b -= 1
				if C[cntC].b == 0 {
					cntC++
				}
			} else {
				ans = append(ans, a)
				cntA++
			}
		}
	}

	sum := 0
	for i := 0; i < N; i++ {
		sum += ans[i]
	}
	fmt.Fprintln(wtr, sum)
}


Measured memory_bytes: 8192
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  str s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  int cnt = 0;
  REP(i,n){
    if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
      cnt++;
    }else{
      ans = max(ans,cnt);
      cnt = 0;
    }
  }
  ans = max(ans,cnt);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
using namespace std;
const int N = 1e5+4;
int link[4*N],size[4*N];
int n;
vector <pair<ll, pair<int,int> > > edge;

struct point
{
	int x,y,pos;
} coor[N];

bool cmp1(point a,point b)
{
	if(a.x != b.x)
		return (a.x < b.x);

	return (a.y < b.y);
}

bool cmp2(point a,point b)
{
	if(a.y != b.y)
		return (a.y < b.y);

	return (a.x < b.x);
}

void init(int V)
{
	for(int i=1;i<=n;i++) link[i] = i;
	for(int i=1;i<=n;i++) size[i] = 1;
}

int find(int x)
{
	while(x != link[x]) x = link[x];
	return x;
}

bool same(int a,int b)
{
	return find(a) == find(b);
}

void unite(int a,int b)
{
	a = find(a);
	b = find(b);
	if(size[a] < size[b]) swap(a,b);
	size[a] += size[b];
	link[b] = a;
}


int main()
{
	cin>>n;
	init(n);
	for(int i=1;i<=n;i++)
	{
		scanf("%I64d %I64d",&coor[i].x,&coor[i].y);
		coor[i].pos = i;
	}

	sort(coor+1,coor+1+n,cmp1);
	for(int i=2;i<=n;i++)
	{
		edge.pb({coor[i].x - coor[i-1].x, {coor[i].pos, coor[i-1].pos}});
	}
	
	sort(coor+1,coor+1+n,cmp2);
	for(int i=2;i<=n;i++)
	{
		edge.pb({coor[i].y - coor[i-1].y, {coor[i].pos, coor[i-1].pos}});
	}
	sort(edge.begin(),edge.end());
	ll cost = 0;

	for(auto i:edge)
	{
		//cout<<i.fi<<' ';
		if(!same(i.se.fi, i.se.se))
		{
			unite(i.se.fi, i.se.se);
			cost += i.fi;	
		}
	}

	cout<<cost<<'\n';
}

Measured memory_bytes: 10096
def solve():
    N = int(input())
    A = list(map(int,input().split()))

    xor = A[0]
    for i in range(1,N):
        xor ^= A[i]
    
    ans = []
    for i in range(N):
        ans.append(xor ^ A[i])
    
    print(*ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 114516
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,c,d=0;
	cin>>a>>c;
	int b[a+1];
	for(int i=1;i<=a;i++)
	cin>>b[i];
	sort(b+1,b+a+1);
	for(int i=1;i<=c;i++)
	d+=b[i];
	cout<<d<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll N, M;
	cin >> N >> M;
	vvll g(N + 1);
	vll in(N + 1, 0);
	repn(i, M) {
		ll x, y;
		cin >> x >> y;
		g[x].push_back(y);
		in[y]++;
	}

	vll dis(N + 1, 0);
	queue<ll> q;
	repn(v, N) {
		if (in[v] == 0) { q.push(v); }
	}

	while (!q.empty()) {
		ll v = q.front();
		q.pop();
		for (ll w : g[v]) {
			dis[w] = max(dis[w], dis[v] + 1);
			in[w]--;
			if (in[w] == 0) { q.push(w); }
		}
	}

	ll ans = 0;
	repn(v, N) ans = max(dis[v], ans);

	cout << ans << endl;

}

Measured memory_bytes: 10216
lines = []
while line = gets
  lines << line.chomp.split(' ').map(&:to_i)
end

# pp lines

def draw_chess_board(height, width)
  return if (height == 0 or width == 0)

  current_height = 1
  current_width = 1

  odd_row = "#."
  even_row = ".#"

  while current_height <= height
    if current_height % 2 == 0
      draw_columns(width, even_row)
    else
      draw_columns(width, odd_row)
    end
    current_height += 1
  end

  puts "\n"
end

def draw_columns(width, given_row)
  str = ""
  times = width / 2.0
  times.floor.times do
    str += given_row
  end

  if times.to_s[-2, 2] == ".5"
    str += given_row[0]
  end

  puts str
end

lines.each do |l|
  height = l[0]
  width = l[1]
  draw_chess_board(height, width)
end




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

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class T> ostream& operator<<(ostream &os, set<T> S){os << "{ "; for(auto s:S) os<<s<<" "; return os<<"}";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}";}
#ifdef np
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>void __f(const char *name, Arg1 &&arg1) { cout<<name<<" : "<<arg1<<endl;}
template<typename Arg1, typename ... Args>void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,','); cout.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif


int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

	string a  ;
	cin>>a;
	string b = a; 
	reverse(a.begin(),a.end());
	int cnt= 0;
	int n =sz(a);
	for(int i = 0  ; i<n ;++i){
		if(b[i] != b[n-1-i]) cnt++;
	}
	cout<<cnt/2;

#ifdef np
    cerr <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
 return 0; 
 }


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
c=[]
ans="No"
for i in range(n-m+1):
    if ans=="Yes":
        break
    else:
        for j in range(n-m+1):
            if ans=="Yes":
                break
            else:
                for k in range(m):
                    c.append(a[i+k][j:j+m])
                if b==c:
                    ans="Yes"
                c=[]
print(ans)

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


using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[0] == s[2]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

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

#define MAX 4002

long long int a[MAX];

int n;

long long int ans[MAX];

long long int dp[MAX][MAX];

int main(){
	cin >> n; 
	long long int x;
	scanf("%lld", &x);
	for (int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
		ans[i] = a[i];
		ans[i + n] = a[i];
		a[i + n] = a[i];
	}
	for (int i = 0; i < n*2; i++){
		dp[i][i] = a[i];
	}
	for (int i = 0; i < n*2; i++){
		for (int j = i; j < n*2; j++){
			if (j + 1 < n*2){
				dp[i][j + 1] = min(a[j+1], dp[i][j]);
			}
		}
	}
	long long int ans = LLONG_MAX;
	for (int j = 0; j < n; j++){
		long long int tmp = 0;
		for (int i = n; i < n * 2; i++){
			tmp += dp[i-j][i];
		}
		ans = min(ans, tmp+(long long int)(j)*x);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 77824
#include <bits/stdc++.h>
using namespace std;
#define WHITE 0
#define GRAY 1
#define BLACK 2

int M[101][101];
int d[101];
int searchPos[101];
int color[101];
int n;
queue<int> q;

/*int nextPoint(int curPoint){
    for(int i=searchPos[curPoint];i<n;++i){
        searchPos[curPoint] += 1;
        if(M[curPoint][i]==1 && color[i] == WHITE){
            return i;
        }
    }
    return -1;
}*/

void bfs(int point){
    q.push(point);
    d[point] = 0;
    color[point] = GRAY;
    int cur, next;
    while(q.size()>0){
        cur = q.front();
        q.pop();
        color[cur] = BLACK;
        for(int i=0;i<n;++i){
            if(M[cur][i] != 0 && color[i] == WHITE){
                q.push(i);
                color[i] = GRAY;
                d[i] = d[cur]+1;
            }
        }
    }
}

int main(){
    int u, z, y;
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        searchPos[i] = 0;
        color[i] = WHITE;
        d[i] = 0;
        for(int j=0;j<n;++j){
            M[i][j] = 0;
        }
    }
    for(int i=0;i<n;++i){
        cin >> u >> z;
        for(int j=0;j<z;++j){
            cin >> y;
            M[u-1][y-1] = 1;
        }
    }

    bfs(0);
    for(int i=0;i<n;++i){
        if(color[i]==WHITE){
            // can't reach
            d[i] = -1;
        }
    }
    for(int i=0;i<n;++i){
        printf("%d %d\n",i+1,d[i]);
    }
    return 0;
}



Measured memory_bytes: 3232
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
char D[1002][1002]={};

int main() {
	int M,N;
	char E[2][2];
	char b[4]={'S','J','O','I'};
	cin>>M>>N;
	for(int i=1;i<M+1;i++){
		for(int j=1;j<N+1;j++){
			cin>>D[i][j];
		}
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			cin>>E[i][j];
		}
	}
	int a=0;
	for(int i=1;i<M;i++){
		for(int j=1;j<N;j++){
			if(D[i][j]==E[0][0]&&D[i][j+1]==E[0][1]&&D[i+1][j]==E[1][0]&&D[i+1][j+1]==E[1][1]){
				a+=1;
			}
		}
	}
	int c[4];
	char C;
	int R=0;
	for(int i=1;i<M+1;i++){
		for(int j=1;j<N+1;j++){
			b[0]=D[i][j];
			for(int k=0;k<4;++k){
				D[i][j]=b[k];
				c[k]=0;
				if(D[i][j]==E[0][0]&&D[i][j+1]==E[0][1]&&D[i+1][j]==E[1][0]&&D[i+1][j+1]==E[1][1])c[k]+=1;
				if(D[i][j-1]==E[0][0]&&D[i][j]==E[0][1]&&D[i+1][j-1]==E[1][0]&&D[i+1][j]==E[1][1])c[k]+=1;
				if(D[i-1][j-1]==E[0][0]&&D[i-1][j]==E[0][1]&&D[i][j-1]==E[1][0]&&D[i][j]==E[1][1])c[k]+=1;
				if(D[i-1][j]==E[0][0]&&D[i-1][j+1]==E[0][1]&&D[i][j]==E[1][0]&&D[i][j+1]==E[1][1])c[k]+=1;
				C=D[i][j];
			}
			D[i][j]=b[0];
			R=max(R,a+c[1]-c[0]);
			R=max(R,a+c[2]-c[0]);
			R=max(R,a+c[3]-c[0]);
		}
	}


	cout<<R<<endl;
	return 0;
}

Measured memory_bytes: 4064
#include "bits/stdc++.h"
using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define debug(x) cout << #x << ": " << x << endl
using ll = long long;
//#define int ll

//**********

signed main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, a;
    cin >> n;
    int ans = 0;
    n += 1;
    a = n;
    while(a/10){
        ans += 9;
        a /= 10;
        }
    ans += a%10;
    ans -= 1;
    
    
    printf("%d\n",ans);;
    
    return 0;
    
}






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

int du[100003] , N , M;
vector < int > nxt[100003];

bool vis[100003];
bool check(){
	queue < int > q; int x = 0 , y , num = 0;
	for(int i = 1 ; i <= N ; ++i)
		if(du[i] == 4) !x ? x = i : y = i;
	q.push(x); vis[x] = 1;
	while(!q.empty()){
		int t = q.front(); q.pop();
		for(auto p : nxt[t])
			if(p == y) ++num;
			else if(!vis[p]){vis[p] = 1; q.push(p);}
	}
	return num != 4;
}

int main(){
	ios::sync_with_stdio(0); cin >> N >> M;
	for(int i = 1 ; i <= M ; ++i){
		int x , y; cin >> x >> y; ++du[x]; ++du[y];
		nxt[x].push_back(y); nxt[y].push_back(x);
	}
	for(int i = 1 ; i <= N ; ++i) if(du[i] & 1){puts("No"); return 0;}
	int cnt = 0; for(int i = 1 ; i <= N ; ++i) cnt += max(0 , du[i] - 3);
	puts(cnt <= 1 || (cnt == 2 && !check()) ? "No" : "Yes"); return 0;
}

Measured memory_bytes: 6272
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int lastT = 0;
        int lastX = 0;
        int lastY = 0;
        for (int i = 0; i < n; i++) {
            int t = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();

            int diffT = t - lastT;
            int distance = Math.abs(x - lastX) + Math.abs(y - lastY);
            if (distance > diffT || diffT % 2 != distance % 2) {
                System.out.println("No");
                return;
            }

            lastT = t;
            lastX = x;
            lastY = y;
        }

        System.out.println("Yes");
    }
}


Measured memory_bytes: 86216
from bisect import bisect_left

Q = int(input())

prime = [2, 3]
for i in range(5, 10 ** 5 + 1, 2) :
    flg = True
    for p in prime :
        if p * p > i :
            break
        if i % p == 0 :
            flg = False
            break
    if flg :
        prime.append(i)
        
like2017 = []
for p in prime :
    if (p + 1) // 2 in prime :
        like2017.append(p)
        
for _ in range(Q) :
    l, r = map(int, input().split())
    print(bisect_left(like2017, r + 1) - bisect_left(like2017, l))

Measured memory_bytes: 55388
import java.util.*;

public class Main {
    static long[] bit;
    static int len;

    static void add(int x, long y) {
        while (x<=len) {
            bit[x] += y;
            x += x&(-x);
        }
    }

    static long sum(int x) {
        long tmp = 0L;
        while (x>0) {
            tmp += bit[x];
            x -= x&(-x);
        }
        return tmp;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] a = new int[N];
        for (int i=0;i<N;i++) {
            a[i] = sc.nextInt();
            a[i] -= K;
        }
        long[] ruiseki = new long[N+1];
        TreeSet<Long> set = new TreeSet<Long>();
        set.add(0L);
        for (int i=0;i<N;i++) {
            ruiseki[i+1] = ruiseki[i]+a[i];
            set.add(ruiseki[i+1]);
        }
        ArrayList<Long> list = new ArrayList<Long>(set);
        int[] ruiseki_new = new int[N+1];
        for (int i=0;i<N+1;i++) {
            ruiseki_new[i] = Collections.binarySearch(list, ruiseki[i])+1;
        }

        len = list.size();
        bit = new long[len+1];
        for (int i=0;i<N+1;i++) {
            add(ruiseki_new[i], 1);
        }
        long ans = 0L;
        for (int i=0;i<N+1;i++) {
            add(ruiseki_new[i], -1);
            ans += (N-i-sum(ruiseki_new[i]-1));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 94176
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; string S;
  cin >> N >> S;

  int black[N+1]; black[0] = 0;
  rep(i, N)
    black[i+1] = black[i] + (S[i] == '#');
  int ans = N;
  rep(i, N+1)
    ans = min(ans, 2 * black[i] + N - i - black[N]);
  out(ans);

  return 0;
}


Measured memory_bytes: 1300
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S[510];
    // if(N > 3) exit(1);
    rep(i,0,N) cin >> S[i];
    ll nn = 0;
    rep(i,0,N){
        rep(j,0,N){
            if(S[i][j] == '#') nn++;
        }
    }
    if(nn == 0){
        print(-1);
        return 0;
    }
    // if(nn == 2) exit(1);

    ll cnt[510] = {};
    rep(i,0,N){ //縦
        rep(j,0,N){
            if(S[i][j] == '#') cnt[i]++;
        }
    }
    ll min_val = INF;
    rep(i,0,N){
        rep(j,0,N){
            if(S[i][j] == '#'){
                min_val = min(min_val, N - cnt[j]);
            }
        }
    }
    rep(i,0,N){
        min_val = min(min_val, N - cnt[i] + 1);
    }

    rep(i,0,N){
        if(cnt[i] == N) min_val = 0;
    }
    ll num = 0;
    rep(j,0,N){
        bool ok = true;
        rep(i,0,N){
            if(S[i][j] == '.') ok = false;
        }
        if(ok) num++;
    }
    ll ans = N - num + min_val;
    print(ans);
    


    

}

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

int main()
{
    string A,B;
    cin>>A>>B;
    if(A.length() > B.length())
        cout<<"GREATER"<<endl;

    else if ( A.length() < B.length())
        cout<<"LESS"<<endl;

    else
    {
        for ( int i =0 ; i < A.length() ; i++)
        {
            if(A[i] > B[i])
            {
                cout<<"GREATER"<<endl;
                return 0;
            }
            else if(A[i] < B[i])
            {
                cout<<"LESS"<<endl;
               return 0;
            }
        }
        cout<<"EQUAL"<<endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll a,b,c;cin>>a>>b>>c;
  if(a<b&&b<c)out("Yes");
  else out("No");


  return 0;
}



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

typedef long long ll;

// a > b
ll solve(ll a, ll b) {
	if(a % b == 0) return a*2-b;
	return solve(b, a % b) + (a/b)*b*2;
}

int main() {
	ll N, X;
	cin >> N >> X;
	cout << solve(max(N-X,X), min(N-X,X)) + N << endl;
}


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

int n;
vector<char> a;

void mainmain(){
    cin >> n;
    for (int i = 0;i < n; i++){
        char m;
        cin >> m;
        a.push_back(m);
    }

    int kakko = 0;
    int toji = 0;

    int tmpKakko = 0;

    for (int i = 0; i< a.size(); i++){
        if (a[i] == '('){ ++tmpKakko;}
        else {
            if(tmpKakko <= 0){
                kakko++;
            }else{
                tmpKakko--;
            }
        }
    }

    toji = tmpKakko;
    string str = string(a.begin(), a.end());

    string kakkoStr = "";
    string tojiStr = "";
    for(int i = 0; i < kakko;i++){
        kakkoStr += "(";
    }
    for(int i = 0; i < toji;i++){
        tojiStr += ")";
    }

    cout << kakkoStr + str + tojiStr << endl;
}

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

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;
int n, d[101], f[101]; vector<int> v[101];
int dfs(int c, int x) {
  if(d[c] > 0) return x;
  d[c] = x++;
  for(int i = 0; i < v[c].size(); ++i) {
    x = dfs(v[c][i], x);
  }
  f[c] = x++;
  return x;
}
int main() {
  scanf("%d", &n);
  for(int i = 0, u, k; i < n; ++i) {
    scanf("%d %d", &u, &k);
    for(int j = 0, vj; j < k; ++j) {
      scanf("%d", &vj);
      v[u].push_back(vj);
    }
  }
  for(int i = 1, s = 1; i <= n; ++i) {
    s = dfs(i, s);
  }
  for(int id = 1; id <= n; ++id) {
    printf("%d %d %d\n", id, d[id], f[id]);
  }
}


Measured memory_bytes: 2740
N = int(input())
A = [None]*N
x = [[None]*N for _ in range(N)]
y = [[None]*N for _ in range(N)]

for i in range(N):
    A[i] = int(input())
    for j in range(A[i]):
        x[i][j],y[i][j] = map(int, input().split())
        

ans =0
for num in range(2**N):
    #bit = bin(num)#正直者リスト
    flag = 1 #これが1のままならOK
    
    #N人を順に見る
    for i in range(N):
        #下からi桁目を取り出す
        if (num>>i & 1)==1:#正直者なら検討
            
            #各発言に対して，NGケースを調査
            for j in range(N):
                #xijの対応に注意，文章では1から
                if x[i][j] != None and y[i][j]!=(num>>(x[i][j]-1) & 1):
                    flag = 0
        if flag ==0:
            break
    if flag ==1:
        ans = max(ans,bin(num).count("1"))
print(ans)

Measured memory_bytes: 42608
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

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

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  int ans = 0;
  int p = 1;
  repl(i,1,n+1){
    int l = 0;
    int tmp = i;
    while(1){
      if(tmp % 2 ==0){
        l++;
      }else{
        break;      
      } 
      tmp/=2;
    }
    if(l >= ans) {
      ans = l;
      p = i;
    }
    // i = tmp;
  }
  cout<<p<<endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 100000

int main() {
	static char used[N];
	static int aa[N];
	int n, k, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]), aa[i]--;
	k = 0;
	for (i = 0; !used[i] && i != 1; i = aa[i]) {
		used[i] = 1;
		k++;
	}
	printf("%d\n", i == 1 ? k : -1);
	return 0;
}


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

int main() {
	
	char n;
	cin >> n;
	char ans = n + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    char W[10], T[13];
    int count = 0, i;
    scanf("%s", W);
    while (scanf("%s", T) != EOF && strcmp(T, "END_OF_TEXT")) {
        for (i = 0; T[i]; i++) {
            T[i] = tolower(T[i]);
        }
        if (!strcmp(W, T)) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> h(n);
	vector<bool> ok(n, true);
	rep(i,n) cin >> h.at(i);
	rep(i,m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		if(h[a] <= h[b]) ok[a] = false;
		if(h[b] <= h[a]) ok[b] = false;
	}
	int ans = 0;
	rep(i,n) if(ok[i]) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
using namespace std;
int main(void){
    long int n,a;
    cin>>n;
    a=0;
    for(long int i=1;i<=n;++i){
        if(i%3!=0&&i%5!=0&&i%15!=0) a=a+i;
    }
    cout<<a;
}


Measured memory_bytes: 3616