akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  ll a, b;
  cin >> a >> b;
  
  // 最大公約数をとる
  ll g = __gcd(a, b);
  
  // 素因数分解
  map<ll, ll> factor;
  for(ll i = 2; i * i < g; i++) while(g % i == 0){
    factor[i]++;
    g /= i;
  }
  if(g != 1) factor[g]++;
  
  // 素数全てと1を選べば良い
  cout << factor.size() + 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

int extgcd(int a,int b,int&x,int&y){
	int d=a;
	if(b){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	else{
		x=1,y=0;
	}
	return d;
}

int modinv(int base){
	int x,y;
	extgcd(base,mod,x,y);
	x%=mod;
	return (x<0?x+mod:x);
}

int modpow(int base,int n){
	int res=1;
	while(n){
		if(n&1)res=1L*res*base%mod;
		base=1L*base*base%mod;
		n>>=1;
	}
	return res;
}

int comb(int n,int a){
	int up=1,lo=1;
	for(int i=0;i<a;++i){
		up=1L*up*(n-i)%mod;
		lo=1L*lo*(i+1)%mod;
	}
	return 1L*up*modinv(lo)%mod;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,a,b; cin>>n>>a>>b;
	cout<<(0L+mod+mod+modpow(2,n)-1-comb(n,a)-comb(n,b))%mod<<"\n"s;
}


Measured memory_bytes: 3640
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
     mut   sp:[(String,i64);n],
    }
    let mut ss = vec![];
    let mut mp = BTreeMap::new();
    for (ind, (city, point)) in sp.iter().cloned().enumerate() {
        ss.push((city.clone(), point, ind + 1));
        mp.entry(city.clone())
            .or_insert(Vec::new())
            .push((point, ind + 1));
    }
    // dbg!(&ss);
    // // ss.sort();
    // // ss.reverse();
    // for (city, point, ind) in ss.iter() {
    //     println!("{}", ind);
    // }
    for (key, value) in mp {
        let mut v = value.clone();
        v.sort_by_key(|&x| -x.0);
        for &x in v.iter() {
            println!("{}", x.1);
        }
    }
}


Measured memory_bytes: 2176
using System;
using System.Linq;

namespace joi2019_yo_d
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();

            bool[] land = new bool[n + 2];
            for (int i = 0; i < n; i++) 
                if (x[i] > 0) 
                    land[i + 1] = true;

            int now = 0;
            for (int i = 1; i <= n + 1; i++) 
                if (land[i - 1] == false && land[i] == true) 
                    now++;
            int ans = now;

            int[] count = new int[n]; 
            for (int i = 0; i < n; i++) 
                count[i] = i + 1;
                
            Array.Sort(x, count);
            
            for (int i = 0; i < n; i++)
            {
                if (x[i] == 0) 
                    continue;
                int idx = count[i]; 
                land[idx] = false;
                if (land[idx - 1] && land[idx + 1]) 
                    now++;
                else if (!land[idx - 1] && !land[idx + 1]) 
                    now--;
                if (i == n - 1 || x[i] != x[i + 1]) 
                    ans = Math.Max(ans, now);
            }
            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 26960
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

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


class AAbcOfABC {
public:
	void solve(std::istream& in, std::ostream& out) {
    string s;
    in >> s;
    sort(s.begin(),s.end());
    if(s == "abc"){
      out << "Yes" << endl;
    }
    else{
      out << "No" << endl;
    }
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	AAbcOfABC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int N,ans;
vector<long int>  A,B,D;
long int tmp;
long int Am, Bm;
long int d;

void vecpr(vector<long int> v){
        for (int i =0; i<v.size(); i++){
                cout << v[i] << " ";
        }
        cout << endl;
}

int main(){
     cin >> N;
     for (int i=0; i<N; i++){
             cin >> tmp;
             A.push_back(tmp);
             Am += tmp;
     }
     for (int i=0; i<N; i++){
             cin >> tmp;
             B.push_back(tmp);
             Bm += tmp;
             D.push_back(A[i]-tmp);
     }
     if (Am < Bm){
             cout << -1 << endl;
             return 0;
     }
     sort(D.begin(),D.end());
     //vecpr(D);
     int i=0;
     long int msum=0;
     for (i=0; D[i]<0; ++i){
             msum += D[i];
     }
     if (msum==0){
             cout << 0 << endl;
             return 0;
     }
     //cout << msum << endl;
     int size=D.size();
     for (int j=size-1; j >= i; --j){
             msum += D[j];
             ans++;
             if (msum >= 0) break;
     }
     cout << i+ans << endl;

     return 0;
}



Measured memory_bytes: 3444
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
    cout << '\n';
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.next();
		char[] s = ("/" + sc.next()).toCharArray();
		System.out.println(IntStream.range(1, s.length).filter(i -> s[i - 1] != s[i]).count());
	}
}


Measured memory_bytes: 27612
# -*- coding: utf-8 -*-
s = input()

if s.startswith("keyence") or s.endswith("keyence"):
    print("YES")
    exit()

c = 0
for s1, k1 in zip(s, "keyence"):
    if s1 == k1:
        c += 1
    else:
        break

for s1, k1 in zip(s[::-1], "keyence"[::-1]):
    if s1 == k1:
        c += 1
    else:
        break

if c >= 7:
    print("YES")
else:
    print("NO")


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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A * B * C == 175 && (A!=1 && B!=1 && C!=1))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{int A,B,C;
scanf("%d %d",&A,&B);
if(((A==1)||(A==2))&&((B==1)||(B==2)))
    printf("3\n");
    else if(((A==2)||(A==3))&&((B==2)||(B==3)))
    printf("1\n");
    else if(((A==1)||(A==3))&&((B==1)||(B==3)))
    printf("2\n");
return 0;


}

Measured memory_bytes: 128
function main(input){
    var A = parseInt(input.split(" ")[0], 10);
    var B = parseInt(input.split(" ")[1], 10);
    var H = parseInt(input.split(" ")[2], 10);
    var M = parseInt(input.split(" ")[3], 10);

	// 時針のrad
	rad_H = ((360/12) * H + ((360/12)/60)*M) * (Math.PI/180);
	// 分針のrad
	rad_M = (360/60)*M*(Math.PI/180);

	// 針間の距離
	console.log(Math.sqrt( (A*A)+(B*B)-2*A*B*Math.cos(rad_H-rad_M)) );
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29584
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
vector<int> g[100005];
int dfs(int v,int p){
  int cur=0;
  for(auto to:g[v]){
    if(to==p) continue;
    int tmp=dfs(to,v)+1;
    cur^=tmp;
  }
  return cur;
}
int main(){
  cin>>n;
  REP(i,n-1){
    int a,b;scanf("%d%d",&a,&b);--a;--b;
    g[a].pb(b);
    g[b].pb(a);
  }
  int r=dfs(0,-1);
  puts(r==0?"Bob":"Alice");
  return 0;
}





Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include <boost/format.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>

#ifdef DEBUG
#include "libs/debug.cpp"
#define DEBUG 1
#else
#define DEBUG 0
#endif

#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n) - 1, 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
#define all(c) (c).begin(), (c).end()

using namespace std;
namespace mp = boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = mp::cpp_int;
template<typename T>
using optional = boost::optional<T>;
const auto none = boost::none;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

int main() {
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (DEBUG) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  // 全部偶数ならウニにすれば作れる
  // 奇数は未証明
  ll N, M;
  cin >> N >> M;
  vector<ll> A, B;
  rep (i, M) {
    ll v0, v1;
    cin >> v0 >> v1;
    A.push_back(v0);
    B.push_back(v1);
  }

  unordered_map<ll, ll> counts;
  rep (i, M) {
    counts[A[i]]++;
    counts[B[i]]++;
  }
  bool ok = true;
  each (cnt, counts) {
    ok &= cnt.second % 2 == 0;
  }
  if (ok) {
    cout << "YES" << "\n";
  } else {
    cout << "NO" << "\n";
  }

}

Measured memory_bytes: 5484
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int r = scan.nextInt();
        int n = scan.nextInt();

        while (n != 0 || r != 0) {
            for (int i = 0; i < r; i++) {
                for (int t = 0; t < n; t++) {
                    if (i % 2 != 0 && t % 2 != 0 || t % 2 == 0 && i % 2 == 0) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
            r = scan.nextInt();
            n = scan.nextInt();
        }

    }
}



Measured memory_bytes: 35368
#include<cstdio>
int main()
{
	int a,b,c,s,max;
	scanf("%d%d%d",&a,&b,&c);
	s=a+b+c;
	max=a>b?a:b;
	max=max>c?max:c;
	if(2*max==s) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N, A, B;
    cin >> N >> A >> B;

    ll ans = N / (A+B) * A + min(N % (A + B) , A);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
  int n;
  char suits[52];
  int ranks[52];
  int i, j;
 
  int cards[4][14] = {{}};
 
  scanf("%d ", &n);
  for(i = 0; i < n; ++i) {
    scanf("%c %d ", &suits[i], &ranks[i]);
 
    if(suits[i] == 'S') {
      cards[0][ranks[i]] = 1;
    } else if(suits[i] == 'H') {
      cards[1][ranks[i]] = 1;
    } else if(suits[i] == 'C') {
      cards[2][ranks[i]] = 1;
    } else if(suits[i] == 'D') {
      cards[3][ranks[i]] = 1;
    }
  }
 
  for(i = 0; i < 4; ++i) {
    for(j = 1; j <= 13; ++j) {
      if(cards[i][j] == 0) {
    if(i == 0) printf("S ");
    else if(i == 1) printf("H ");
    else if(i == 2) printf("C ");
    else if(i == 3) printf("D ");
    printf("%d\n", j);
      }
    }
  }
 
  return 0;
}


Measured memory_bytes: 2036
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
    double a, b, C;
    cin >> a >> b >> C;
    double S, L, h;
    S = a * b * sin(PI*C/180) * 0.5;
    L = a + b + sqrt(a*a + b*b - 2 * a * b * cos(PI*C/180));
    h = 2 * S / a;
    printf("%.04lf\n", S);
    printf("%.04lf\n", L);
    printf("%.04lf\n", h);
}

Measured memory_bytes: 3388
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
 
	
	ll N;
	cin >> N;
	string an = "second";
	
	for (ll i = 0; i < N; i++) {
		ll a;
		cin >> a;
		if (a % 2 != 0) {
			an = "first";
		}
		
	}
	
	cout <<an<< endl;
}

Measured memory_bytes: 256
#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;
  cin >> N;
  
  int seat = 0;
  rep(i, N)
  {
	int l, r;
    cin >> l >> r;
    
    seat += r - l + 1;
  }
  
  cout << seat << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <memory.h>
#include <cmath>
#include <array>

void re(int& x);

void pr(int x);

void pr(const char *x);

void ps();
template<class T, class... Ts> void ps(const T& t, const Ts&... ts);

#ifdef FFDBG

#else
#define dbg(x...) dsfdsfsdfasd
#endif

#define rep(i, a, b) for(int i = a; i < (b); ++i)

char b[1100000];
int x[1100000];
int a[1100000];

int n;

int calc(int* a, int n) {
    int ans = 0;
    rep(i,0,n) {
        if ( ((n-1)&i) == i ) ans ^= a[i];
    }
    return ans;
}

void solve()
{
    re(n);
    scanf("%s", b);

    rep(i,0,n-1) x[i] = abs(b[i]-b[i+1]);
    n--;

    if (n==1) {
        ps(x[0]);
        return;
    }

    // is it 1?
    rep(i,0,n) a[i] = (x[i]==1);
    if (calc(a,n)) {
        ps(1);
        return;
    }

    // is it 2?
    bool left = true, right = true;
    rep(i,0,n-1) {
        if (x[i] == 1) left = false;
        a[i] = (x[i]==2);
    }
    if (left) left = (calc(a,n-1) == 1);

    rep(i,1,n) {
        if (x[i] == 1) right = false;
        a[i-1] = (x[i]==2);
    }
    if (right) right = (calc(a,n-1) == 1);

    if (left ^ right) {
        ps(2);
        return;
    }

    ps(0);
}

int main() {

    solve();
}

void re(int& x) { scanf("%d", &x); }

void pr(int x) { printf("%d", x); }

void pr(const char *x) { printf("%s", x); }

void ps() { pr("\n"); }
template<class T, class... Ts> void ps(const T& t, const Ts&... ts) { 
    pr(t); if (sizeof...(ts)) pr(" "); ps(ts...); 
}



Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define ms(x, a) memset(x, a, sizeof(x))
#define oo 100000000
#define ll  long long int
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    vector<int>v;
    cin >> n;
    int mini= oo;
    int ans=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a<mini){
            ans++;
        }
        mini = min(a,mini);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        int k =sc.nextInt();
        ArrayList<Integer> array=new ArrayList<Integer>();
        int cnt=0;
        for(int i =0;i<k;i++) {
        		int d =sc.nextInt();
        		for(int j=0 ;j<d ;j++) {
                  int work = sc.nextInt();
                 array.add(work);
        		}
        }
        for(int i = 1 ;i<n+1;i++) { 
          if(array.contains(i) ==false) {
           cnt+=1; 
          }
        }
System.out.println(cnt);
	}
}

Measured memory_bytes: 46236
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int n, k; cin >> n >> k;
	vi cnt(n + 1, 0);

	while (k--)
	{
		w(d)
		{
			int x; cin >> x;
			cnt[x]++;
		}
	}

	int ans = 0;

	for (int i = 1; i <= n; ++i)
		if (!cnt[i])
			ans++;

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3656
# -*- coding: utf-8 -*-

def main():
    s,t = input().split()
    a,b = map(int, input().split())
    u = input()

    if u == s:
        print("{} {}".format(a-1, b))
    else:
        print("{} {}".format(a, b-1))

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;
int main(void){
	string s;
	int i,front,rear,size;
	int n[17];
	
	cin >> s;
	size = s.size();
	for(i = 0; i < size; i++)
		n[i] = s[i] - '0';
	n[i] = '\0';
	
	if(size == 1){
		cout << n[0] <<"\n";
		return 0;
	}
	for(front = 0; front < size && n[front] == 9; front++){}
	if(front == size){
		cout << 9*size << "\n";
		return 0;
	}
	for(rear = size -1; rear >=0 && n[rear] == 9; rear--){}
	if(front != rear)
		n[front] -= 1;
	else{
		if(front > 0){
			if(rear == (size - 1))
				front--;
			n[front] -= 1;
		}
	}
	
	cout << 9*front + n[front] + (rear - front)*9 + (size - rear-1)*9 <<"\n";
	
}

Measured memory_bytes: 256
const main = (input) => {
  input = input.trim().split('\n')
  const [h, w, m] = input[0].split(' ').map(Number)

  const hs = new Array(h+1).fill(0)
  const ws = new Array(w+1).fill(0)
  const bomb = new Map()

  for (let i=1; i<=m; i++) {
    const [hi, wi] = input[i].split(' ').map(Number)
    hs[hi-1]++
    ws[wi-1]++
    bomb.set(`${hi-1}:${wi-1}`, true)
  }

  let hmx = 0
  let wmx = 0

  let topH = []
  let topW = []

  for (let i=0; i<Math.max(hs.length, ws.length); i++) {
    if (hs[i] && hs[i] > hmx) {
      hmx = hs[i]
      topH = [[i, hs[i]]]
    } else if (hs[i] && hs[i] === hmx) {
      topH.push([i, hs[i]])
    }

    if (ws[i] && ws[i] > wmx) {
      wmx = ws[i]
      topW = [[i, ws[i]]]
    } else if (ws[i] && ws[i] === wmx) {
      topW.push([i, ws[i]])
    }
  }

  // const hs = {}
  // const ws = {}
  //
  // const bomb = new Map()
  //
  // for (let i=1; i<=m; i++) {
  //   const [hi, wi] = input[i].split(' ').map(Number)
  //   hs[hi-1] = ~~hs[hi-1] + 1
  //   ws[wi-1] = ~~ws[wi-1] + 1
  //   bomb.set(`${hi-1}:${wi-1}`, true)
  // }

  // const ascH = [...Object.entries(hs)].sort((a, b) => b[1] - a[1])
  // const ascW = [...Object.entries(ws)].sort((a, b) => b[1] - a[1])
  //
  // const topH = [ascH.shift()]
  // const topW = [ascW.shift()]
  // while (ascH[0] && topH[0][1] === ascH[0][1]) topH.push(ascH.shift())
  // while (ascW[0] && topW[0][1] === ascW[0][1]) topW.push(ascW.shift())

  for (let x=0; x<topH.length; x++) {
    for (let y=0; y<topW.length; y++) {
      if (!bomb.has(`${topH[x][0]}:${topW[y][0]}`)) return console.log(hmx + wmx)
    }
  }

  return console.log(hmx + wmx - 1)
  // return console.log(topH[0][1] + topW[0][1] - 1)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

num = 100001
#num = 10

even = [[0,i] for i in range(num)]
odd = [[0,i] for i in range(num)]

for i in range(n):
    if i%2 == 0:
        even[v[i]][0] += 1
    else:
        odd[v[i]][0] += 1
        
odd.sort(key=lambda x: -x[0])
even.sort(key=lambda x: -x[0])

if even[0][1] != odd[0][1]:
    print(n-even[0][0]-odd[0][0])
else:
    print(min(n-even[0][0]-odd[1][0], n-even[1][0]-odd[0][0]))


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

int main(){
  map<int,bool> memo;
  int N;
  cin>>N;
  int cnt=0;
  for(int i=0;i<N;i++){
    int p[3];
    cin>>p[0]>>p[1]>>p[2];
    sort(p,p+3);
    int k=((p[0]-1)*1000+p[1]-1)*1000+p[2]-1;
    if(memo.find(k)!=memo.end()){
      cnt++;
    }
    else{
      memo[k]=true;
    }
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long K, long long X){
  FOR(i,X-K+1,X+K){
    cout<<i;
    if(i==X+K-1){
      cout<<endl;
    }else{
      cout<<" ";
    }
  }
}

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


Measured memory_bytes: 256
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    for(int i=1;i<=9;i++)
    {
      if(n%i==0)
      {
        if(n/i<=9)
        {
          System.out.println("Yes");
          System.exit(0);
        }
      }
    }
    System.out.println("No");
  }
}


Measured memory_bytes: 36004
/// d.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll unsigned long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < pll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int D;
    fi>>D;
    static int D1[55];
    static int D2[55];
    static ll p10[55];
    p10[0] = 1;
    for (int i = 1;i <= 18;++i)
        p10[i] = p10[i - 1] * 10;
    for (int i = 0;i <= 9;++i)
        for (int j = 0;j <= 9;++j)
            ++D1[i - j + 20];
    for (int i = 1;i <= 9;++i)
        for (int j = 1;j <= 9;++j)
            ++D2[i - j + 20];
    ll ans = 0;
    for (int len = 1;len <= 19;++len)
    {
        const int len1 = len / 2;
        const int ln = len1 / 2;
        static map < ll , int > s1,s2,tmp;
        s1.clear();s2.clear();tmp.clear();
        ++s1[0];++s2[0];
        for (int i = 0;i < ln;++i)
        {
            for (int j = -9;j <= 9;++j)
                for (auto it : s1)
                    tmp[(p10[len - i - 1] - p10[i]) * j + it.x] += it.y * (!i ? D2[j + 20] : D1[j + 20]);
            s1 = tmp;
            tmp.clear();
        }
        for (int i = ln + (len1 & 1);i < len1;++i)
        {
            tmp.clear();
            for (int j = -9;j <= 9;++j)
                for (auto it : s2)
                    tmp[(p10[len - i - 1] - p10[i]) * j + it.x] += it.y * (!i ? D2[j + 20] : D1[j + 20]);
            s2 = tmp;
            tmp.clear();
        }
        if (!(len1 & 1))
        {
            for (auto it : s1)
                if (s2.count(D - it.x))
                    ans += p10[len & 1] * s2[D - it.x] * it.y;
        }
        else
        for (int i = -9;i <= 9;++i)
        {
            const ll offset = (p10[len - ln - 1] - p10[ln]) * i;
            for (auto it : s1)
                if (s2.count(D - it.x - offset))
                    ans += p10[len & 1] * s2[D - it.x - offset] * (!ln ? D2[i + 20] : D1[i + 20]) * it.y;
        }
    }
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

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

Measured memory_bytes: 4368
<?php

function input_and_explode() {
    return explode(' ', trim(fgets(STDIN)));
}

list( , , $X, $Y) = input_and_explode();
$xn = input_and_explode();
$ym = input_and_explode();

$max_x = max($xn);
$min_y = min($ym);

$war = true;
foreach (range($X + 1, $Y) as $Z) {
    if ($max_x < $Z && $min_y >= $Z) {
        $war = false;
    }
}

echo ($war ? 'War' : 'No War') . "\n";

Measured memory_bytes: 4728
import itertools as it

num = int(input())

item_number = num//100

if item_number>= 20:
    item_number = 20

res_list = []
candi_list = list(it.combinations_with_replacement([100, 101, 102, 103, 104, 105], item_number))
candi_ans_list = [sum(item) for item in candi_list]

if num >= 2000:
    print(1)
else:

    if num in candi_ans_list:
        print(1)
    else:
        print(0)


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

int main(){
  int H,W,A,B;
  cin>>H>>W>>A>>B;
  vector<vector<int>> s(H,vector<int>(W,0));
  if(H!=1&&W!=1){
  for(int i=0;i<B;i++){
    for(int j=0;j<A;j++){
      s.at(i).at(j)=1;
    }
  }
  for(int i=B;i<H;i++){
    for(int j=A;j<W;j++){
      s.at(i).at(j)=1;
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<s.at(i).at(j);
    }
    cout<<endl;
  }}else {
    if(H==1){
        for(int j=0;j<A;j++){
          s.at(0).at(j)=1;
        }
    }else if(W==1){
      for(int j=0;j<B;j++){
        s.at(j).at(0)=1;
      }
    }
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        cout<<s.at(i).at(j);
      }
      cout<<endl;
  }


  }



}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <math.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;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  int n,m;
  cin >> n >> m;
  int A[n][m];
  int b[m];
  int c[n] = {0};
  REP(i,n) {
    REP(j,m) {
      cin >> A[i][j];
    }
  }
  REP(i,m) {
    cin >> b[i];
  }

  REP(i,n) {
    REP(j,m) {
      c[i] += A[i][j]*b[j];
    }
  }
  REP(i,n) {
    cout << c[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3132
var
	s:String;
	i,j,k:Longint;
	a,b,c,d,e,f:String[5];
begin
	readln(s);
	read(k);
	a:='zzzzz';
	b:=a;
	c:=b;
	d:=c;
	e:=d;
	for i:=1 to length(s)do begin
		for j:=1 to k do begin
			if i+j-1>length(s)then break;
			f:=copy(s,i,j);
			if a>f then begin
				e:=d;
				d:=c;
				c:=b;
				b:=a;
				a:=f;
			end else if a<>f then begin
				if b>f then begin
					e:=d;
					d:=c;
					c:=b;
					b:=f;
				end else if b<>f then begin
					if c>f then begin
						e:=d;
						d:=c;
						c:=f;
					end else if c<>f then begin
						if d>f then begin
							e:=d;
							d:=f;
						end else if d<>f then begin
							if e>f then begin
								e:=f;
							end;
						end;
					end;
				end;
			end;
		end;
	end;
	if k=1 then writeln(a)else if k=2 then writeln(b)else if k=3 then writeln(c)else if k=4 then writeln(d)else writeln(e);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ll=long long;
const ll INF=1e+10;

ll w[110];
int v[110];
ll dp[110][100010];

int main(){ _;
  int n,wMax;cin>>n>>wMax;
  int vMax=n*1000;
  REP(i,n)cin>>w[i]>>v[i];
  REP(i,n+1)REP(j,vMax+1)dp[i][j]=INF;
  dp[0][0]=0;
  REP(i,n){
    REP(j,vMax+1){
      dp[i+1][j]=dp[i][j];
      if(j>=v[i])
	dp[i+1][j]=min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
    }
  }
  int result=0;
  for(int j=vMax;j>=0;j--){
    if(dp[n][j]<=wMax){
      result=j;
      break;
    }
  }
  cout<<result<<endl;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i=0; i<n; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  
  double answer = a.at(0) / pow(2.0, n - 1);
  
  for(int i=1; i<n; i++)
    answer += a.at(i) / pow(2.0, n - i);
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef int64_t Int;
const double pi = M_PI;

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

    if (N < 10)
    {
        cout << K + 100 * (10 - N) << endl;
    }
    else
    {
        cout << K << endl;
    }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1500)

def f(x, y):
    if x == 0:
        return 0
    if y % x == 0:
        return 2 * (y // x) * x - x
    return 2 * (y // x) * x + f(y % x, x)

N, X = list(map(int, input().split()))
print(f(X, N-X) + N)


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>

namespace IO {
    template <typename _T>
    inline bool read (_T& x) {
        x = 0;
        _T y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return false;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return true;
    }

    template <typename _T>
    inline _T input () {
        _T x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return 0;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return x;
    }
};
using namespace IO;

#define reg register
#define MAX_N 200007
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define lep(i, l, r) for(int i = l; i < r; ++i)
#define irep(i, r, l) for(int i = r; i >= l; --i)
#define ilep(i, r, l) for(int i = r; i > l; --i)
typedef long long ll;

int N, K, bg;
char s[MAX_N];
int q[MAX_N];

int main () {
#ifdef LOCAL
    FIN("in");
#endif
    read(N), read(K);
    scanf("%s", s);
    bg = 0;
    lep (i, 0, N) q[i] = s[i] - 'A';
    int now = 0;
    rep (i, 1, K) {
        if (now == q[bg]) {
            q[bg] = now ^ 1;
        } else {
            q[bg] = now ^ 1;
            (bg += 1) >= N ? bg = 0 : 0;
            now ^= 1;
        }
    }
    rep (i, 1, N) {
        putchar((q[bg] ^ now) + 'A');
        (bg += 1) %= N;
    } puts("");
    return 0;
}



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

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T>T&get(){T a;cin>>a;return a;}
template<typename T>T&rev(T&a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>a){sort(all(a));return a;}

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int inf = 1e9;
const ll linf = 3e18;

int J[1001][1001];
int O[1001][1001];
int I[1001][1001];

signed main()
{
    int N, M, K; scanf("%d %d %d", &N, &M, &K);

    rep1(i, N) rep1(j, M) {
        char c; scanf("\n%c", &c);
        if (c == 'J') J[i][j] = 1;
        if (c == 'O') O[i][j] = 1;
        if (c == 'I') I[i][j] = 1;
    }

    rep1(i, N) rep1(j, M) {
        J[i][j] += J[i][j - 1];
        O[i][j] += O[i][j - 1];
        I[i][j] += I[i][j - 1];
    }

    rep1(i, M) rep1(j, N) {
        J[j][i] += J[j - 1][i];
        O[j][i] += O[j - 1][i];
        I[j][i] += I[j - 1][i];
    }

    rep(ii, K) {
        int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d);
        int j = J[c][d] - J[a - 1][d] - J[c][b - 1] + J[a - 1][b - 1];
        int o = O[c][d] - O[a - 1][d] - O[c][b - 1] + O[a - 1][b - 1];
        int i = I[c][d] - I[a - 1][d] - I[c][b - 1] + I[a - 1][b - 1];
        printf("%d %d %d\n", j, o, i);
    }
}

Measured memory_bytes: 12888
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

def lcm(a,b):
  return (a*b)//gcd(a,b)

n,m=map(int,input().split())
arr=list(map(int,input().split()))
if n==1:
  l=arr[0]
else:
  l=lcm(arr[0],arr[1])
for i in range(2,n):
  l=lcm(l,arr[i])
  if l//2>m:
    print(0)
    exit()
for i in range(n):
  if (l//arr[i])%2==0:
    print(0)
    exit()
ans=(m-l//2)//l+1
print(ans)

Measured memory_bytes: 14244
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#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>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int n,l,a[300010],t[300010];
long long ans;
int main()
{
	int s0,s1,s2;
	s0=s1=s2=0;
	scanf("%d%d",&n,&l);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&t[i]);
	}
	ans=1;
	for (int i=1;i<=n;i++)
	{
		ans+=t[i]/(2*l);
		t[i]%=2*l;
		if (!t[i])
		{
			continue;
		}
		ans++;
		bool f1,f2;
		f1=(t[i]<=a[i]*2);
		f2=(t[i]<=(l-a[i])*2);
		if (i==n)
		{
			if (f2)
			{
				ans--;
			}
			break;
		}
		if (f1)
		{
			s0++;
			if (f2)
			{
				s2++;
			}
		}
		else if (f2)
		{
			s1++;
		}
		while (s0-s2<s1+s2)
		{
			if (s2)
			{
				s2--;
			}
			else
			{
				s1--;
			}
		}
	}
	ans-=s1+s2;
	ans*=2*l;
	printf("%lld\n",ans);
    return 0;
}
//你还不来，我怎敢老去。
//——张爱玲

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

template <typename TYPE>
class my_stack{
public:
	my_stack(){};
	void push(TYPE x){
		vec.push_back(x);
		return;
	};
	TYPE pop(){
		TYPE x = vec.back();
		vec.pop_back();
		return x;
	};

private:
	vector<TYPE> vec;
};

int main()
{
	my_stack<int> stack;
	int n;
	while (cin >> n){
		if (n) stack.push(n);
		else cout << stack.pop() << "\n";
	}
	cout << flush;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Y cout<<"YES"<<endl
#define N cout<<"NO"<<endl
#define mp make_pair
#define pb push_back
#define mx 1000005
string ch="qwertyuioplkjhgfdsazxcvbnm";

int main(){


   ll a,b;

   cin>>a>>b;

   cout<<a*b<<endl;
}




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


int main(void){
	char s[4];
	int i;

	scanf("%s",s);

	if(strlen(s)==2){
		printf("%s",s);
	}else{
		printf("%c%c%c\n",s[2],s[1],s[0]);
	}
	return 0;
}

Measured memory_bytes: 128
using System;

public class Hello{
    public static void Main(){
        string[] InputSize;
        int Height;
        int Width;
        char[][] Map;
        bool[][] FootSteps;
        int CurrentX, CurrentY;
        string Result;
        
        while(true){
            
            InputSize = Console.ReadLine().Split(' ');
            Height = int.Parse(InputSize[0]);
            Width = int.Parse(InputSize[1]);

            if(Height == 0 && Width == 0) break;
            
            Map = new char[Height][];
            FootSteps = new bool[Height][];
            CurrentX = CurrentY = 0;
            Result = "";
            
            for(int h = 0; h < Height; h++){
                Map[h] = Console.ReadLine().ToCharArray();
                FootSteps[h] = new bool[Width];
            }
            
            while(true){
                FootSteps[CurrentY][CurrentX] = true;
                switch(Map[CurrentY][CurrentX]){
                    case '>':
                        CurrentX++;
                        break;
                    case '<':
                        CurrentX--;
                        break;
                    case '^':
                        CurrentY--;
                        break;
                    case 'v':
                        CurrentY++;
                        break;
                    case '.':
                        Result = CurrentX + " " + CurrentY;
                        break;
                }
                
                if(Result != "") break;
                else if(FootSteps[CurrentY][CurrentX] == true){
                    Result = "LOOP";
                    break;
                }
            }
            Console.WriteLine(Result);
        }
    }
}

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

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%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;
  }
  
  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;
  }
};

int main() {
  ll n, k;
  cin >> n >> k;
  mint sum;
  for (ll i=k; i<n+2; i++) {
    sum += n*i - i*i + i + 1;
  }
  cout << sum.x << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>

typedef long long ll;

int main(){
	int n;
	std::cin >> n;
	std::vector<ll> a(n+1);
	for(int i=0; i<=n; i++){
		std::cin >> a[i];
	}
	// 下から頂点数の上界を求める
	std::vector<ll>  up(n+1);
	std::vector<ll> error(n+1);
	up[n] = a[n];
	error[n] = a[n];
	//std::cout << "error[n]: " << error[n] << std::endl;
	for(int i=n-1; i>=0; i--){
		up[i] = up[i+1] + a[i];
		error[i] = (error[i+1] + 1)/2 + a[i];
		//std::cout << error[i] << std::endl;
	}
	if(error[0] > 1){
		std::cout << -1 << std::endl;
		return 0;
	}
	//上から頂点数の上界を求める
	std::vector<ll> down(n+1);
	ll res = 0;
	down[0] = 1;
	for(int i=1; i<=n; i++){
		down[i] = std::min(down[i-1]*2, up[i]);
		res += down[i];
		down[i] -= a[i];
	}
	res += 1;
	std::cout << res << std::endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

string acgt = "ACGT";

int main(int argc, char const *argv[]) {
	int n,q;
	std::cin >> n >> q;
	string s;
	std::cin >> s;

	// i文字目までにACの文字列が何回現れるかを考える
	std::vector<int> v(n,0);
	bool flag_A;
	if (s[0] == 'A') {
		flag_A = true;
	}
	else {
		flag_A = false;
	}
	for (size_t i = 1; i < v.size(); i++) {
		if (flag_A && s[i] == 'C') {
			v[i] = v[i-1] + 1;
		}
		else {
			v[i] = v[i-1];
		}

		if (s[i] == 'A') {
			flag_A = true;
		}
		else {
			flag_A = false;
		}
	}


	std::vector<int> ans(q);
	for (size_t i = 0; i < q; i++) {
		int l,r;
		std::cin >> l >> r;
		ans[i] = v[r-1] - v[l-1];
	}

	// for (size_t i = 0; i < v.size(); i++) {
	// 	std::cout << v[i] << '\n';
	// }

	for (size_t i = 0; i < q; i++) {
		std::cout << ans[i] << '\n';
	}
	return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

const int maxn = 2e5 + 7;
const int mod = 998244353;

char s[maxn];
deque<char> str;
int Q;
int T,F;
char opt[5];
int rev;

int main()
{
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i++)
		str.push_back(s[i]);
	scanf("%d",&Q);
	while(Q--)
	{
		scanf("%d",&T);
		if(T==1)
		{
			rev^=1;
		}
		else
		{
			scanf("%d",&F);
			scanf("%s",opt);
			if(F==1)
			{
				if(rev)
				{
					str.push_back(opt[0]);
				}
				else
				{
					str.push_front(opt[0]);
				}
			}
			else
			{
				if(rev)
				{
					str.push_front(opt[0]);
				}
				else
				{
					str.push_back(opt[0]);
				}
			}
		}
	}
	if(rev)
	{
		while(!str.empty())
		{
			printf("%c",str.back());
			str.pop_back();
		}
	}
	else
	{
		while(!str.empty())
		{
			printf("%c",str.front());
			str.pop_front();
		}
	}
	printf("\n");
	return 0;
}




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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
// vll x(n); x[i]=a;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

ll extgcd(ll a, ll b, ll &x, ll &y){
    if (b == 0){
        x = 1;
        y = 0;
        return a;
    }
    ll g = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return g;
}

ll gcd(ll a, ll b){
    ll x, y;
    return extgcd(a, b, x, y);
}

vpll prime_fac(ll x){
    vpll ans;
    ll tmp = 0;
    ll s = sqrt(x);
    if (x % 2 == 0){
        while(x % 2 == 0){
            x /= 2;
            tmp++;
        }
        ans.emplace_back(pll{2, tmp});
    }
    for(ll y = 3; y <= s; y += 2){
        tmp = 0;
        if (x % y == 0){
            while(x % y == 0){
                x /= y;
                tmp++;
            }
            ans.emplace_back(pll{y, tmp});
        }
    }
    if (x>1) ans.emplace_back(pll{x, 1});
    return ans;
}

int main(){
    ll a, b, g, ans;
    cin >> a >> b;
    g = gcd(a, b);
    vpll pf = prime_fac(g);
    ans = pf.size()+1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,k = map(int, input().split())

cur = (n - 1) * (n - 2) // 2
if k > cur:
    print(-1)
    exit()

# 中心1のウニグラフ
res = []
for i in range(2, n + 1):
    res.append([1, i])

l, r = 2, 3
while cur > k:
    cur -= 1
    res.append([l, r])
    r += 1
    if r > n:
        l += 1
        r = l + 1

print(len(res))
for i in res:
    print(*i)

Measured memory_bytes: 4120