akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

vector<string> grid;
vector<vector<int>> count_left;
vector<vector<int>> count_right;
vector<vector<int>> count_up;
vector<vector<int>> count_down;

void setup(const int H, const int W) {
    // left
    for (int i = 0; i < H; i++) {
        int count = 0;
        for (int j = 0; j < W; j++) {
            if (grid[i][j] == '#') {
                count = 0;
            } else {
                count++;
            }
            count_left[i][j] = count;
        }
    }

    // right
    for (int i = 0; i < H; i++) {
        int count = 0;
        for (int j = W - 1; j >= 0; j--) { 
            if (grid[i][j] == '#') {
                count = 0;
            } else {
                count++;
            }
            count_right[i][j] = count;
        }
    }

    // up
    for (int i = 0; i < W; i++) {
        int count = 0;
        for (int j = 0; j < H; j++) {
            if (grid[j][i] == '#') {
                count = 0;
            } else {
                count++;
            }
            count_up[j][i] = count;
        }
    }

    // down
    for (int i = 0; i < W; i++) {
        int count = 0;
        for (int j = H - 1; j >= 0; j--) {
            if (grid[j][i] == '#') {
                count = 0;
            } else {
                count++;
            }
            count_down[j][i] = count;
        }
    }
}

/*
 * solution based on the editiorial.pdf
 */
int main(void) {
    int H, W;
    cin >> H >> W;

    grid.resize(H);
    for (int i = 0; i < H; i++) {
        string S;
        cin >> S;
        grid[i] = S;
    }

    count_left.resize(H, vector<int>(W, 0));
    count_right.resize(H, vector<int>(W, 0));
    count_up.resize(H, vector<int>(W, 0));
    count_down.resize(H, vector<int>(W, 0));

    setup(H, W);

    int maximum = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            // printf("i = %d, j = %d, left: %d, right: %d, up: %d, down: %d\n",
            //         i, j, count_left[i][j], count_right[i][j], count_up[i][j], count_down[i][j]);
            chmax(maximum, count_left[i][j] + count_right[i][j] + count_up[i][j] + count_down[i][j] - 3);
        }
    }

    cout << maximum << endl;

    return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll INF=1LL<<60;
const int MOD=1e9+7;

int main(){
    vector<set<int>> id(26);
    string s, t; cin >> s >> t;
    for(int i=0; i<s.size(); i++){
        id[s[i]-'a'].insert(i);
    }
    bool ans=true;
    ll res;
    ll len=s.size(), cnt=0;
    for(int i=0; i<t.size(); i++){
        if(id[t[i]-'a'].empty()) ans=false;
        else if(i == 0) res=*begin(id[t[i]-'a']);
        else{
            int val=res-len*cnt;
            auto it=id[t[i]-'a'].upper_bound(val);
            if(it != id[t[i]-'a'].end()) res=len*cnt+*it;
            else{
                cnt++;
                res=len*cnt+*begin(id[t[i]-'a']);
            }
        }
    }
    res++;
    cout << (ans ? res:-1) << endl;
    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __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(...)
#endif

const ll N = 109;
ll n,i,j,a;
ll dp[2][N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,0,2) rep(j,0,n){
        cin>>a;
        if(i == 0) dp[i][j] = (j == 0 ? a : dp[i][j - 1] + a);
        else
            dp[i][j] = (j == 0 ? dp[i - 1][j] + a : max(dp[i - 1][j],dp[i][j - 1]) + a);
    }
    cout<<dp[1][n - 1];
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val sr = new StdinReader
  val h, w, d = sr.nextInt
  val table: Map[Int, (Int, Int)] = (for {
        y <- 0 until h
        x <- 0 until w
      } yield sr.nextInt -> (x, y)).toMap

  val tbl = new Array[Int](h * w + 1)
  (1 to d).flatMap{dd =>
    ((dd + d) to (h * w) by d).map {p => 
      val lPos = table(p - d)
      val rPos = table(p)
      val mp = Math.abs(lPos._1 - rPos._1) + Math.abs(lPos._2 - rPos._2)
      tbl(p) = mp + tbl(p - d)
    }
  }

  println(
    (1 to sr.nextInt).map{i =>
      val l, r = sr.nextInt
      tbl(r) - tbl(l)
    }.mkString("\n"))


class StdinReader {
  val is = System.in
  val buffer = new Array[Byte](1024 * 1024)
  var size = 0
  var pos = 0

  private def readByte: Byte = {
    if (pos >= size) {
      pos = 0;
      size = is.read(buffer);
    }
    if (size < 0) -1
    else {
      val ret = buffer(pos)
      pos += 1
      ret
    }
  }

  // support single byte char only
  def next: String = {
    val sb = new StringBuilder
    var reading = false
    var completed = false
    while(!completed) {
      val b = readByte

      if ('!' <= b && b <= '~') {
        sb.append(b.asInstanceOf[Char])
        reading = true
      } else {
        if (reading) completed = true
      }
    }
    sb.toString
  }

  def nextInt: Int = {
    var i = 0
    var reading = false
    var completed = false
    while(!completed) {
      val b = readByte

      if (b == '-') {
        reading = true
        i *= -1
      } else if ('0' <= b && b <= '9') {
        reading = true
        i = i * 10 + (b - '0')
      } else if (reading) completed = true
    }
    i
  }
}
}

Measured memory_bytes: 80768
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    public static void Main()
    {
        int[] ab = SpIntRead(' ');
        Console.WriteLine((ab[0]*ab[1] %2 == 0? "Even" : "Odd"));
    }
}

public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#include <atcoder/convolution>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

const int MAXN = 1e5 + 5;

typedef modint998244353 M;

struct cmp {
    bool operator () (const vector<M> &a, const vector<M> &b) {
        return a.size() > b.size();
    }
};

M fact[MAXN], inv[MAXN], power[MAXN];

M choose(int n, int k) {
    return fact[n] * inv[k] * inv[n-k];
}

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

    int n;
    cin >> n;
    vector<int> cnt(MAXN);
    for (int i=0; i<2*n; i++) {
        int h;
        cin >> h;
        cnt[h]++;
    }

    fact[0] = inv[0] = power[0] = 1;
    for (int i=1; i<=2*n; i++) {
        fact[i] = fact[i-1] * i;
        inv[i] = fact[i].inv();
        power[i] = power[i-1] / 2;
    }

    priority_queue<vector<M>, vector<vector<M>>, cmp> pq;
    for (int i=1; i<MAXN; i++)
        if (cnt[i] >= 2) {
            vector<M> cur{1};
            for (int j=1; j*2<=cnt[i]; j++)
                cur.push_back(cur.back() * choose(cnt[i] - (j - 1) * 2, 2) / j);
            pq.emplace(cur);
        }

    while (pq.size() > 1) {
        vector<M> a = pq.top();
        pq.pop();
        vector<M> b = pq.top();
        pq.pop();
        pq.emplace(convolution(a, b));
    }

    M ret = 0;
    vector<M> cur = pq.empty() ? vector<M>{1} : pq.top();
    for (int i=0; i<(int)cur.size(); i++)
        ret += cur[i] * (i % 2 ? -1 : 1) * fact[2 * n - 2 * i] * power[n - i] * inv[n - i];
    cout << ret.val() << "\n";

    return 0;
}

Measured memory_bytes: 6676
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;

ll mod = 1e9 + 7;
ll dp[103][13];

int main() {
	ll h, w, k; cin >> h >> w >> k;
	dp[0][1] = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 1; j <= w; j++) {
			for (int b = 0; b < (1 << (w - 1)); b++) {
				bool flag = true;
				for (int t = 0; t < w - 1; t++) {
					flag &= !((b >> t)&1 && (b >> (t + 1))&1);
				}
				if (!flag)continue;
				if (j > 1 && (b >> (j - 2)) & 1) {
					dp[i + 1][j - 1] += dp[i][j];
					dp[i + 1][j - 1] %= mod;
				}
				else if (j < w && (b >> (j - 1)) & 1) {
					dp[i + 1][j + 1] += dp[i][j];
					dp[i + 1][j + 1] %= mod;
				}
				else {
					dp[i + 1][j] += dp[i][j];
					dp[i + 1][j] %= mod;
				}
			}
		}
	}
	cout << dp[h][k] << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# coding:utf-8
# abc127_b

"""
2019年5月25日の AtCoder Beginnar Contest
"""


def main():
    a, b = map(int, input().split())
    if 0 <= a <= 5:
        print(0)
    elif a <= 12:
        print(int(b / 2))
    else:
        print(b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<iostream>
using namespace std;
long long int gcd(long long int x,long long int y)
{
    if(y==0)return x;
    return gcd(y,x%y);
}
long long int lcm(long long int x,long long int y)
{
    return x/gcd(x,y)*y;
}
int main()
{
    long long int ans,a,n;
    while(scanf("%lld",&n)==1)
    {
        ans=1;
        for(int i=1;i<=n;i++)
        {
            scanf("%lld",&a);
            ans=lcm(ans,a);
        }
        printf("%lld\n",ans);
    }
}


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

int main(){
  int a;
  cin >> a;
  long long ans = 1;
  for(int i = 1; i <= a; i++){
    ans *= i;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
N, *A = map(int, open(0).read().split())

cnt = [0] * (N + 1)
cnt[0] = 1
for i in range(N):
    cnt[i + 1] = (cnt[i] - A[i]) * 2

ans = 0
cur = 0
for i in reversed(range(N + 1)):
    cur += A[i]
    ans += min(cnt[i], cur)
        
if all(cnt[i] >= A[i] for i in range(N + 1)):
    print(ans)
else:
    print(-1)


Measured memory_bytes: 701824
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 19;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	vector<ll> dp(n + 1,0);
	dp[0] = 1000;
	rep(i, n) {
		dp[i + 1] = max(dp[i + 1], dp[i]);
		for (int j = i + 1; j < n; j++) {
			ll d = dp[i] / a[i];
			ll nex = d * a[j] + dp[i] % a[i];
			dp[j + 1] = max(dp[j + 1], nex);
		}
	}
	cout << dp[n] << "\n";
}




signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//cout << grandy(2, 3, false, false) << "\n";
	//init();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


Measured memory_bytes: 11832
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
  char str[1000];

  scanf("%s", str);
  
  for (int i = 0; i < strlen(str); i++){
    if (str[i] >= 'A' and str[i] <= 'C') printf("%c", str[i] + 23);
    else printf("%c", str[i] - 3);
  }
  printf("\n");

  return (0);
}

Measured memory_bytes: 932
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

std::map<int, int> count_map;
std::map<int, bool> existence_map;
std::vector<int> vec;
int n, x, ans;

int main() {
    std::cin >> n;
    int ans = 0;
    vec.assign(n, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> x;
        vec[i] = x;
        count_map[x]++;
        existence_map[x] = true;
    }
    std::sort(vec.begin(), vec.end());
    int max_v = vec[vec.size()-1];
    for (int i = 0; i < n; i++) {
        int t = vec[i];
        if (count_map[t] >= 2) {
            existence_map[t] = false;
        }
        long long p = t;
        long long e = 2;
        long long x;
        while ((x = (p*e)) <= max_v) {
            if (existence_map[x]) {
                existence_map[x] = false;
            }
            e++;
        }
    }
    for (auto &v: existence_map) {
        if (v.second) {
            ans++;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 57828
#include <bits/stdc++.h>
using namespace std;
using i64=int_fast64_t;
using i32=int_fast32_t; 
using P=pair<i64,i64>;
const i64 MOD=1000000007;
const i64 INF=1000000010;
const i64 LINF=4000000000000000010;
int main(){
    struct edge{i32 to;i64 cost;};
    vector<vector<edge>> G;
    vector<i64> di;
    i32 n,m,st;cin>>n>>m>>st;
    G.resize(n);
    di.resize(n);
    for(i32 i=0;i<m;i++){
        i32 u,v,d;cin>>u>>v>>d;
        G[u].push_back({v,d});
    }
    priority_queue<P,vector<P>,greater<P>> q;
    fill(di.begin(),di.end(),LINF);
    di[st]=0;
    q.push(P(0,st));
    while(!q.empty()){
        i32 v=q.top().second;q.pop();
        for(auto e:G[v]){
            if(di[e.to]<=di[v]+e.cost)continue;
            di[e.to]=di[v]+e.cost;
            q.push(P(di[e.to],e.to));
        }
    }
    for(i32 i=0;i<n;i++){
        if(di[i]==LINF){
            cout<<"INF"<<endl;
            continue;
        }
        cout<<di[i]<<endl;
    }
    return 0;
}   


Measured memory_bytes: 19520
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    t = list(map(int,input().split()))
    m = int(input())
    p = [list(map(int, input().split())) for i in range(m)]
    ans = sum(t)
    for i in range(m):
        print(ans-t[p[i][0]-1]+p[i][1])

if __name__ == '__main__':
    main()


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

using namespace std;

long long solve(long long h) {
    if (!h)
        return 0;
    return 1 + 2 * solve(h / 2);
}

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

    long long h;
    cin >> h;
    cout << solve(h) << '\n';

    return 0;
}

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

const int N=2e6+100;
int mod=1e9+7;
typedef long long ll;
int a[N];
int main()
{
    string s,k;
    cin>>s>>k;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=k[i]) ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3852
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    // freopen("inputf.txt","r",stdin);
    // freopen("outputf.txt","w",stdout);
    
    int n;
    string data;

    cin>>n>>data;

    int i=0,j=n-1;

    bool f1=true,f2=true;
    int ans=0;

   
    while(i<j){
        if(f1){
            if(data[i]=='W')
                f1=false;
            else
                i++;
        }
        if(f2){
            if(data[j]=='R')
                f2=false;
            else
                j--;
        }

        if(!f1 && !f2){
            ans++;
            f1=true;
            f2=true;

            i++;
            j--;
        }
    }

    cout<<ans<<"\n";
}

Measured memory_bytes: 3680
(n, m) = [int(i) for i in input().split()]

matrix = []
vector = []
product = [0 for d in range(n)]

for nc in range(n):
    matrix.append([int(i) for i in input().split()])

for mc in range(m):
    vector.append(int(input()))

for nc in range(n):
    for mc in range(m):
        product[nc] += matrix[nc][mc] * vector[mc]

[print(product[nc]) for nc in range(n)]

Measured memory_bytes: 7016
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk)
{
  var text = chunk.trim();
  var out = "";
  for (i = 0; i < text.length; i++) {
    var c = text.charAt(i);
    if (c == c.toLowerCase()) {
      out += c.toUpperCase();
    } else {
      out += c.toLowerCase();
    }
  }
  console.log(out);
});

Measured memory_bytes: 8696
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Scanner;

import javax.xml.crypto.Data;
public class Main{
	static int INF = 2 << 28;
	static int[] vxL = {0,0,1,-1};
	static int[] vxR = {0,0,-1,1};
	static int[] vyL = {1,-1,0,0};
	static int[] vyR = {1,-1,0,0};
	static int w;
	static int h;
	static int Lx;
	static int Ly;
	static int Rx;
	static int Ry;
	static char[][] mapL;
	static char[][] mapR;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0 && h == 0) break;
			mapL = new char[h][];
			mapR = new char[h][];
			for(int i = 0; i < h; i++) {
				mapL[i] = sc.next().toCharArray();
				mapR[i] = sc.next().toCharArray();
			}
			Lx = 0;
			Ly = 0;
			Rx = 0;
			Ry = 0;
			
			for(int i = 0; i < h; i++) {
				for(int j = 0; j < w; j++) {
					if(mapL[i][j] == 'L') {
						Ly = i;
						Lx = j;
						mapL[i][j] = '.';
					}
					if(mapR[i][j] == 'R') {
						Ry = i;
						Rx = j;
						mapR[i][j] = '.';
					}
				}
			}
			boolean ans = BFS();
			if(ans) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
			System.gc();
		}
	}	
	static boolean BFS() {
		boolean[][][][] use = new boolean[w][h][w][h];
		ArrayDeque<Data> queue = new ArrayDeque<Data>();
		queue.add(new Data(Lx,Ly,Rx,Ry));
		while(!queue.isEmpty()) {
			Data tmp = queue.poll();
			if(use[tmp.Lx][tmp.Ly][tmp.Rx][tmp.Ry]) continue;
			use[tmp.Lx][tmp.Ly][tmp.Rx][tmp.Ry] = true;
			for(int i = 0; i < 4; i++) {
				
				int Ltx = tmp.Lx + vxL[i];
				int Lty = tmp.Ly + vyL[i];
				int Rtx = tmp.Rx + vxR[i];
				int Rty = tmp.Ry + vyR[i];
				
				int  L = Rcheck(Ltx,Lty,mapL);
				int  R = Rcheck(Rtx,Rty,mapR);
				
				if(L == 2 && R == 2) return true;
				if(L == 2 && R != 2) continue;
				if(L != 2 && R == 2) continue;
				if(L == 0 && R == 0) continue;
				if(L == 0) {
					Ltx = tmp.Lx;
					Lty = tmp.Ly;
				}
				if(R == 0) {
					Rtx = tmp.Rx;
					Rty = tmp.Ry;
				}
				queue.addLast(new Data(Ltx,Lty,Rtx,Rty));
			}
		}
		return false;
		
	}
	static int Rcheck(int x,int y,char[][] map) {
		if(x < 0 || y < 0 || x >= w || y >= h) return 0;
		if(map[y][x] == '#') return 0;
		if(map[y][x] == '.') return 1;
		if(map[y][x] == '%') return 2;
		return -1;
	}
	
	static class Data {
		int Lx;
		int Ly;
		int Rx;
		int Ry;
		Data(int a, int b, int c, int d) {
			Lx = a;
			Ly = b;
			Rx = c;
			Ry = d;
		}
		public boolean equals(Object o) {
			Data c = (Data)o;
			if(this.Lx != c.Lx) return false;
			if(this.Ly != c.Ly) return false;
			if(this.Rx != c.Rx) return false;
			if(this.Ry != c.Ry) return false;
			return true;
		}
	}
}

Measured memory_bytes: 191148
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  if (a + b <= c*2) {
    cout << a*x + b*y << endl;
    return 0;
  }
  if (x == y) {
    cout << 2*c*x << endl;
  } else if (x > y) {
    cout << 2*c*y + (x-y) * min(a,2*c) << endl;
  } else if (x < y) {
    cout << 2*c*x + (y-x) * min(b,2*c) << endl;
  }
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <chrono>
using namespace std::chrono;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
#define pb push_back
#define int long long
#define ios std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define fill(x, v) memset(x, v, sizeof(x))
const ll mod = 1000000007;
const double pi = 3.14159265359; // PI
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
/*
std::cout << std::setprecision(9) << f << '\n';//3.141590000;
map<char,int>::reverse_iterator rit;
for(rit = mp.rbegin(); rit!=mp.rend(); rit++)
    auto start = high_resolution_clock::now();
    // Call the function, here
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << "Time taken by function: "<< duration.count() << " milliseconds" << endl;
*/
map<int, int> mp;
void primeFactors(int n)
{

    while (n % 2 == 0)
    {
        mp[2]++;
        n = n / 2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {

        while (n % i == 0)
        {
            mp[i]++;
            n = n / i;
        }
    }

    if (n > 2)
        mp[n]++;
}

int32_t main()
{

    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    if (n % 2)
    {
        cout << b[n / 2] - a[n / 2] + 1 << endl;
    }
    else
    {
        cout << (b[n / 2] - a[n / 2] + b[n / 2 - 1] - a[n / 2 - 1]) + 1 << endl;
    }
}


Measured memory_bytes: 6784
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect

setrecursionlimit(10**7)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

T, X = reads()
print(T/X)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    int ans = 0;
    sort(arr.begin(), arr.end());
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            for (int k = j + 1; k < n; k++)
            {
                if (arr[k] < arr[i] + arr[j])
                {
                    if (arr[i] != arr[j] and arr[j] != arr[k])
                    {
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3600
def main():
    n, k = map(int, input().split())

    cnt = 0
    for b in range(k+1, n+1):
        p = (n-k) // b + 1
        cnt += p * (b-k)

        if p * b > n + 1:
            cnt -= p * b - n - 1

        if k == 0:
            cnt -= 1

    print(cnt)


if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    int l,r,k;
    cin>>k>>l>>r;
    l = (l/k+(l%k!=0))*k;
    if(l>r)
    {
        cout<<"NG"<<"\n";
    }
    else
        cout<<"OK";
    return 0;
}


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

int main()
{
	int N, D;
	cin >> N >> D;

	int count = 1;

	while(1){
		if (((D * 2 + 1) * count) < N) {
			count++;
		}
		else
			break;
	}

	cout << count << endl;
}

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

using ll = long long;
vector<ll> nums(100010);

int main() {
  int n; cin >> n;
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    ll a; cin >> a;
    nums[a] += 1;
    ans += a;
  }
  int q; cin >> q;
  for (int i = 0; i < q; ++i) {
    ll b, c; cin >> b >> c;
    ans -= nums[b]*b;
    ans += nums[b]*c;
    nums[c] += nums[b];
    nums[b] = 0;
    cout << ans << endl;
  }
}



Measured memory_bytes: 3900
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
    
    int ans = c - (a - b);
    
    if(ans < 0){
        ans = 0;
    }
    cout << ans;
    
    
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
  
	int n; cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; ++i) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).ToList();

        List<int> operation = new List<int>();
        if (a.All(x => x < 0))
        {
            var max = a.Max();
            Console.WriteLine(max);
            int maxInd = a.IndexOf(max);
            for (int i = 0; i < maxInd; i++)
            {
                a.RemoveAt(0);
                operation.Add(0);
            }
            while (1 < a.Count)
            {
                var last = a.Count - 1;
                a.RemoveAt(last);
                operation.Add(last);
            }
            goto end;
        }

        var shouldKeep = Enumerable.Repeat(false, n).ToList();
        var oddSum = a.Where((elem, index) => index % 2 == 1 && 0 <= elem).Sum();
        var evenSum = a.Where((elem, index) => index % 2 == 0 && 0 <= elem).Sum();
        Console.WriteLine(Max(oddSum, evenSum));
        for (int i = (oddSum < evenSum ? 0 : 1); i < n; i += 2)
            if (0 < a[i]) 
                shouldKeep[i] = true;
        while (!shouldKeep[0])
        {
            shouldKeep.RemoveAt(0);
            operation.Add(0);
        }
        while (!shouldKeep.Last())
        {
            var ind = shouldKeep.Count - 1;
            shouldKeep.RemoveAt(ind);
            operation.Add(ind);
        }
        for (int i = 0; i < shouldKeep.Count; i += 2)
        {
            while (!shouldKeep[i])
            {
                shouldKeep.RemoveAt(i + 1);
                shouldKeep.RemoveAt(i - 1);
                operation.Add(i);
            }
        }
        while (1 < shouldKeep.Count)
        {
            shouldKeep.RemoveAt(2);
            shouldKeep.RemoveAt(1);
            operation.Add(1);
        }
        end:;
        Console.WriteLine(operation.Count);
        Console.WriteLine(string.Join("\n", operation.Select(x => x + 1)));
    }
}


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

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

  int64_t r = 0;
  int64_t g = 0;
  int64_t b = 0;
  for(int i=0; i<n; i++) {
    if(s[i]=='R') r++;
    if(s[i]=='G') g++;
    if(s[i]=='B') b++;
  }

  int64_t sum = r*g*b;

  int64_t out = 0;
  for(int i=1; i<=(n-1)/2; i++) {
    for(int j=0; j<n-2*i; j++) {
      if(s[j]!=s[j+i] && s[j]!=s[j+2*i] && s[j+i]!=s[j+2*i]) out++;
    }
  }

  cout<<sum-out<<endl;

  return 0;
}

Measured memory_bytes: 3636
fun main(array: Array<String>) {
    val n = readLine()!!.toInt()
    val arr = readLine()!!.split(" ").map { it.toInt() }
    var cnt = 0
    var min = n  + 1
    arr.forEach { 
        if(it < min) {
            cnt++
            min = it
        }
    }
    print(cnt)
}

Measured memory_bytes: 83148
H, W = map(int,input().split())
S = list([list(input()) for _ in range(H)])

padding = ['.']*(W+2)
S.insert(0, padding)
S.append(padding)
for i in range(1, H+1):
    S[i].insert(0, '.')
    S[i].append('.')

for i in range(1, H+1):
    for j in range(1,W+1):
        if S[i][j]=='.':
            S_part= S[i-1][j-1:j+2]+S[i][j-1:j+2]+S[i+1][j-1:j+2]
            S_cnt = S_part.count('#')
            S[i][j]=S_cnt
for i in range(1,H+1):
    print(*S[i][1:W+1],sep='')



Measured memory_bytes: 3444
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    A_ = []
    for a_ in A:
        A_ += [[a__, False] for a__ in a_]
    for b_ in b:
        for a__ in A_:
            if a__[0] == b_:
                a__[1] = True
    if (A_[0][1] and ((A_[1][1] and A_[2][1]) or \
                        (A_[3][1] and A_[6][1]) or \
                        (A_[4][1] and A_[8][1]))) or \
            (A_[1][1] and A_[4][1] and A_[7][1]) or \
            (A_[2][1] and A_[5][1] and A_[8][1]) or \
            (A_[3][1] and A_[4][1] and A_[5][1]) or \
            (A_[6][1] and A_[7][1] and A_[8][1]) or \
            (A_[2][1] and A_[4][1] and A_[6][1]):
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9220
import sys
import numpy as np
import numba
from numba import njit
from numba.types import Omitted
i4 = numba.int32
i8 = numba.int64

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8[:], i8), cache=True)
def get_sum(bit, i):
    s = 0
    while i:
        s += bit[i]
        i -= i & -i
    return s


@njit((i8[:], i8, i8), cache=True)
def add(bit, i, x):
    while i < len(bit):
        bit[i] += x
        i += i & -i

@njit((i8[:], i8[:]), cache=True)
def main(A, LR):
    N = len(A)
    L, R = LR[::2], LR[1::2]
    Q = len(L)
    query_order = np.argsort(R)
    L, R = L[query_order], R[query_order]
    ind = np.searchsorted(R, np.arange(N + 2))
    right_end = np.zeros(N + 1, np.int64)
    bit = np.zeros(N + 1, np.int64)
    answers = np.empty(Q, np.int64)
    for r in range(1, N + 1):
        a = A[r - 1]
        p = right_end[a]
        if p:
            add(bit, p, -1)
        right_end[a] = r
        add(bit, r, 1)
        for i in range(ind[r], ind[r + 1]):
            l, r, i = L[i], R[i], query_order[i]
            answers[i] = get_sum(bit, r) - get_sum(bit, l - 1)
    return answers

N, Q = map(int, readline().split())
A = np.array(readline().split(), np.int64)
LR = np.array(read().split(), np.int64)

ans = main(A, LR)
print('\n'.join(map(str, ans.tolist())))

Measured memory_bytes: 193016
class GCD():
    def __init__(self,a,b):
        self.a = a
        self.b = b

    def gcd(self):
        if self.a < self.b:
            self.a, self.b = self.b, self.a
        while self.b:
            self.a, self.b= self.b, self.a % self.b

        return self.a

    def print(self):
        lcm = self.a * self.b // self.gcd()
        print(self.gcd(), lcm)

def main():
    data =[]

    while 1:
        try:
            n = input().split()

            a = int(n[0])
            b = int(n[1])

            data.append(GCD(a, b))

        except EOFError:
            break

    for array in data:
        array.print()

if __name__ == "__main__":
    main()


Measured memory_bytes: 5600
#include <iostream>
using namespace std;
string a, b;
int main() {
	int i;
	cin>>a>>b;
	if(a.size()!=b.size())
		cout<<(a.size()<b.size() ? "LESS" : "GREATER");
	else {
		for(i=0; a[i] && a[i]==b[i]; i++);
		if(i==a.size()) cout<<"EQUAL";
		else cout<<(a[i]<b[i] ? "LESS" : "GREATER");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin >> n>>k;
  int arr[100005]={0},ans[100005],i,j;
  
  for(i=1;i<=n;i++)
    cin >> arr[i];
  
  ans[1]=0;
  
  for(i=2;i<=n;i++)
  {  ans[i]=ans[i-1]+abs(arr[i-1]-arr[i]);
     if(i>2)
     {  for(j=1;j<=k&&i-j>=1;j++)
        ans[i]=min(ans[i],ans[i-j]+abs(arr[i-j]-arr[i]));
     }
  }
   cout<<ans[n];
}


Measured memory_bytes: 1152
input()
A=[0]+list(map(int,input().split()))
H=len(A)
def h(i):
 l=2*i;r,g=l+1,[i,l][l<H and A[i]<A[l]]
 if r<H and A[g]<A[r]:g=r
 if g!=i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
a=''
for s in A[1:]:a+=f' {s}'
print(a)


Measured memory_bytes: 63672
#include<bits/stdc++.h>
using namespace std;
int n,ans,a[10001],s[10001];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)s[i]=s[i-1]+a[i];
	ans=s[n];
	for(int i=1;i<=n;i++)ans=min(ans,abs(s[n]-2*s[i]));
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	ll a,b,c;
	cin >> a >> b >> c;
	ll ans = 0;
	if(c <= a+b+1) ans += b+c;
	else ans += b+(a+b+1);
	cout << ans << endl;
}

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


int main(){
  int m_1,d_1,m_2,d_2;
  cin >> m_1 >> d_1 >> m_2 >> d_2;
  if(m_1 == m_2)cout << 0 << endl;
  else cout << 1 << endl;
  
}

Measured memory_bytes: 256
#75b
H,W = map(int, input().split())

S_list = [[0 for i in range(W+2)] for j in range(H+2)]

for i in range(1,H+1):
    S = list(input())
    S_list[i][1:W+1] = S
    
ans = [["#" for i in range(W+2)] for j in range(H+2)]
    
for i in range(1,H+1):
    for j in range(1,W+1):
        if S_list[i][j] != "#":            
            ans[i][j] = S_list[i-1][j-1:j+2].count("#") + S_list[i][j-1:j+2].count("#") + S_list[i+1][j-1:j+2].count("#")
            
for i in range(1,H+1):
    print(''.join(map(str, ans[i][1:-1])))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll se=0;
ll sume(vector<int> a,int n){

}
int main(){
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[a[i]]==i) ans++;
    }
    cout<<ans/2<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int n,a=0,b=0;cin>>n;
	while(n--){
		string t,h;cin>>t>>h;
		if(t>h){a+=3;}
		else if(h>t){b+=3;}
		else{a++;b++;}
	}
	cout<<a<<" "<<b<<endl;
	RE;
}


Measured memory_bytes: 3152
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N;
    cin >> N;
    vint A(N);
    rep(i, N) cin >> A[i];
    int cnt = 0;
    int max_cnt = 0;
    rep(i, N - 1) {
        if (A[i] >= A[i + 1]) {
            cnt++;
        }
        else {
            cnt = 0;
        }
        max_cnt = max(cnt, max_cnt);
    }
    cout << max_cnt << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n;
  cin >> n;
  ll c[n - 1], s[n - 1], f[n - 1];

  REP(i, n - 1) cin >> c[i] >> s[i] >> f[i];

  REP(i, n){
    if(i == n - 1){
      cout << 0 << endl;
      return 0;
    }
    ll t = 0;
    for(int j = i; j <= n - 2; j++){
      while(1){
        if(t >= s[j] && t % f[j] == 0) break;
        else t++;
      }
      t += c[j];
    }
    cout << t << endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int n, a[100000], order[100000];
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		order[a[i]] = i;
	}
	for (int i = 1; i <= n; i++)
		printf("%d ", order[i]);
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto &a : A) cin >> a;
    sort(rall(A));
    ll ans = 0;
    rep(i, n - 1) {
        ans += A[(i + 1) / 2];
    }
    cout << ans << '\n';
    return;
}

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

Measured memory_bytes: 3904
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }

// ll get_pow(ll x, ll y){
//   ll ret=0;
//   ll temp = y;
//   while(true){
//     if(x<=temp) break;
//     ret++;
//     temp *= 2;
//   }
//   return ret;
// }



int main() {
  cout<<fixed<<setprecision(10);

  ll N,M;
  cin>>N>>M;
  vint A(N);//, B(M), C(M);
  vpint cb(M);
  rep(i,N)cin>>A[i];
  rep(i,M){
    ll b,c;
    cin>>b>>c;
    c*=-1;
    cb[i] = mp(c,b);
  }

  vsort(A);
  vsort(cb);

  // rep(i,N)cout<<A[i];

  ll ans;

  // ll cnt = 0;
  ll i=0;
  ll j=0;

  while(i<N && j<M){
    if(A[i]<cb[j].fi*-1){
      A[i] = cb[j].fi*-1;
      i++;
      cb[j].se--;
    }else{
      break;
    }

    if(cb[j].se==0){
      j++;
    }
  }
  // rep(i,N)cout<<A[i];


  ans = 0;
  rep(i,N)ans+=A[i];


  cout << ans << endl;

}

















//


Measured memory_bytes: 2560
N,C=map(int,input().split())
TV=[[0]*C for i in range(10**5)]
for i in range(N):
  s,t,c=map(int,input().split())
  for i in range(s-1,t):
    TV[i][c-1]=1
print(max([sum(TV[i]) for i in range(10**5)]))

Measured memory_bytes: 112560