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

using namespace std;

int main() {
	int K, A, B,hantei=0;

	cin >> K;
	cin >> A >> B;

	for (int i = 1; i < 1000; i++) {
		if (K*i >= A && K*i <= B) {
			hantei++;
		}
		if (K > 1000) {
			break;
		}
	}
	if (hantei >= 1) {
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}

	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include <math.h>
#include <map>
using namespace std;


int main(){
	long long x;
	long long money=100;
	double rate=1.01;
	int cnt=0;
	cin>>x;
	for(int i=0;money<x;i++){
		money=money*rate;
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,d;
  cin>>n>>d;
  int cnt = 0;
  REP(i,n) {
    ll x,y;
    cin>>x>>y;
    if (x*x+y*y <= d*d) {
      ++cnt;
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
#define par pair<pair<int,int>, int>
#define f first
#define s second


    
int main()
{
    char c;
    scanf("%c",&c);
    printf("%c",c+1);
    return 0;
}

Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
         for(int x: arr)
         {
            if(!map.containsKey(x))
               map.put(x,0);
            map.put(x,map.get(x)+1);
         }
         int res = 0;
         for(int k: map.keySet())
         {
            if(map.get(k) < k)
               res += map.get(k);
            else
               res += map.get(k)-k;
         }
         System.out.println(res);
      }
   }

Measured memory_bytes: 42356
n = int(input())
p = list(map(int,input().split()))

res = 0
for i in range(1,n-1):
    if p[i] > p[i-1] and p[i] < p[i+1]:
        res += 1
    elif p[i] > p[i+1] and p[i] < p[i-1]:
        res += 1
print(res)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
#define N 4000011
const int p=1e9+7;
int n,k,dp[2002][2002],inv[N],f[N],finv[N];
inline int C(int nn,int mm)
{
	if(mm==nn||mm==0)return 1;if(nn<mm)return 0;
	return 1ll*f[nn]*finv[mm]%p*finv[nn-mm]%p;
}
int main()
{
	f[1]=finv[1]=inv[1]=1;
	for(int i=2;i<=4000000;i++)
	{
		inv[i]=1ll*(p-p/i)*inv[p%i]%p;
		f[i]=1ll*f[i-1]*i%p;finv[i]=1ll*finv[i-1]*inv[i]%p;
	}
	scanf("%d%d",&n,&k);
	if(k==1){puts("1");return 0;}
	dp[0][0]=1;
	for(int i=1;i<=n;i++)for(int j=0;j<=i;j++)
	{
		dp[i][j]=dp[i-1][j];
		if(j)(dp[i][j]+=1ll*C(n-i+(n-j+1)*(k-1)-1,k-2)*dp[i][j-1]%p)%=p;
	}
	printf("%d\n",1ll*dp[n][n]*f[n]%p);
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repab(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define pb push_back
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
#define endl "\n"

typedef pair<int, int> P;

const int MOD = 1e9 + 7;
const int INF = 1001001001;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

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

int main() {
    string s, t;
    cin >> s >> t;
 
    int ans = t.size();
 
    for (int start = 0; start <= s.size() - t.size(); start++){
        int diff = 0;
        for (int i = 0; i < t.size(); i++){
            if (t[i] != s[start + i]){
                diff++;
            }
        }
        ans = min(ans, diff);
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
int main(){
string x;
  cin >> x;
  if(x[0] == x[1] && x[1] == x[2] && x[0] == 'R') cout << 3 << endl;
  else if((x[0] == x[1]&& x[1] == 'R') || (x[1] == x[2] && x[1] == 'R')) cout << 2 << endl; 
  else if(x[0] == 'R' || x[1] == 'R' || x[2] == 'R') cout << 1 << endl;
  else cout << 0 << endl;

}

Measured memory_bytes: 3592
N, P = map(int, input().split())

if N == 1:
    ans = P
else:
    ans = 1
    p = 2
    while p * p <= P:
        e = 0
        while P % p == 0:
            P //= p
            e += 1  # 素数のカウント
        if e // N > 0:
            ans *= p ** (e // N)
        p += 1

print(ans)


Measured memory_bytes: 2940
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a * b % 2 == 0){
			System.out.println("Even");
		}else{
			System.out.println("Odd");
		}
	}
}


Measured memory_bytes: 22996
#define _USE_MATH_DEFINES // M_PIなどの定義を使用するのに必要
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>

using namespace std;

int main()
{
  int64_t N, M;
  vector<int64_t> H;
  vector<pair<int64_t, int64_t>> path;

  cin >> N >> M;

  H.resize(N);
  path.resize(M);

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

  for (int i = 0; i < M; i++) {
    cin >> path[i].first >> path[i].second;
    path[i].first--;
    path[i].second--;
  }

  vector<bool> good_peak_flag_array;
  good_peak_flag_array.resize(N, true);

  for (auto &&i : path) {
    if (H[i.first] == H[i.second]) {
      good_peak_flag_array[i.first] = false;
      good_peak_flag_array[i.second] = false;
    }
    else if (H[i.first] > H[i.second]) {
      good_peak_flag_array[i.second] = false;
    }
    else {
      good_peak_flag_array[i.first] = false;
    }
  }

  cout << accumulate(good_peak_flag_array.begin(), good_peak_flag_array.end(), 0LL) << endl;

  return 0;
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ
int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1);
}

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

int main(){
	long long int n,a[10],cast,b,c,input;
	while(cin >> n){
		for(int j=0;j<n;j++){
			b = 0;
			c = 0;
			cast = 10;
			cin >> input;
			for(int i=0;i<8;i++){
				a[i] = input % cast;
				input /= cast;
			}
			sort(a,a+8);
			cast = 1;
			for(int i=0;i<8;i++){
				b += a[i] * cast;
				cast *= 10;
			}
			sort(a,a+8,greater<int>());
			cast = 1;
			for(int i=0;i<8;i++){
				c += a[i] * cast;
				cast *= 10;
			}
			cout << b-c << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	for (int i = 1; i <= b; i++) {
		if ((a * i) % b == c) {
			cout << "YES" << endl;
			return (0);
		}
	}
	cout << "NO" << endl;

	return (0);
}

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

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

  vector<bool> ans(3, true);
  ans[A - 1] = false;
  ans[B - 1] = false;

  rep(i, 3) {
    if (ans[i]) cout << i + 1 << endl;
  }
}

Measured memory_bytes: 3560
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 1500

const int INF = 1 << 30;
const int MOD = 1e9 + 7;

template<typename T>
T histArea(vector<T>& h) {

	T N = h.size();
	h.push_back(0);
	N++;

	T ans = 0;
	stack<pii> st;

	for (T i = 0; i < N; i++)
	{
		if (st.empty())
		{
			//スタックが空の場合は長方形を追加
			st.push(pii(h[i], i));
		}
		else if (st.top().first < h[i])
		{
			//今見ている長方形がスタックの頂点の長方形の高さより高い場合はスタックに追加
			st.push(pii(h[i], i));
		}
		else if (st.top().first > h[i])
		{
			//今見ている長方形がスタックの頂点の長方形の高さより低い場合はスタックから取り出す作業を行う
			int lastpos = 0;

			while (!st.empty() && st.top().first >= h[i]) {
				//スタックが空でなく、スタックの頂点にある長方形の高さが今見ている長方形の高さ以上
				//の場合はスタックから長方形を取り出してその都度面積を計算して最大値を更新する
				lastpos = st.top().second;
				ans = max(ans, st.top().first * (i - lastpos));
				st.pop();
			}
			//取り出す作業が終わったら今見ている長方形をスタックに追加する
			//追加位置は最後に取り出した長方形の位置
			st.push(pii(h[i], lastpos));
		}
	}
	return ans;
}
int main() {

	ll n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	cout << histArea(a) << endl;

	return 0;
}


Measured memory_bytes: 4456
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    int ans=-1;
    char preC;
    rep(i,0,S.size()){
        char c=S.at(i);
        if(preC!=c){
            preC=c;
            ans++;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//cout<<fixed<<setprecision(15);

signed main(){
    int l,r; cin >> l >> r;
    if(r-l>=2019){
        cout<<0<<endl;
        return 0;
    }
    int res=INF;
    FOR(i,l,r){
        FOR(j,i+1,r+1){
            chmin(res,i*j%2019);
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
//package Round613;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author sguar <shugangcao@gmail.com>
 * welcome to kuaishou
 * Created on 2020-01-12
 */
public class Main {
    private static final long MOD = 1_000_000_007;

    long[] factorial;
    long[] inverseFactorial;
    

    public void init(int n) {
        factorial = new long[n + 1];
        inverseFactorial = new long[n + 1];

        factorial[0] = 1;
        for (int i = 1; i <= n; i++) {
            factorial[i] = factorial[i - 1] * i % MOD;
        }
        inverseFactorial[n] = inv(factorial[n]);
        for (int i = n - 1; i >= 0; i--) {
            inverseFactorial[i] = inverseFactorial[i + 1] * (i + 1) % MOD;
        }
    }

    public void run() {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int k = cin.nextInt();
        init(n);
        //debug();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = cin.nextLong();
        }
        Arrays.sort(a);

        long ans = 0;
        for (int i = 1; i <= n; i++) {
            ans = (ans
                    + getC(n - i, k - 1)
                    * ((a[n - i] - a[i - 1] + MOD + MOD) % MOD)
                    % MOD)
                    % MOD;
        }
        System.out.println(ans);

    }

    public long getC(int i, int j) {
        if (i < j) return 0;
        return factorial[i] * inverseFactorial[j] % MOD * inverseFactorial[i - j] % MOD;
    }

    public long inv(long x) {
        return pow(x, MOD - 2);
    }

    public long pow(long x, long n) {
        long ans = 1;
        while (n > 0) {
            if ((n & 1) == 1) {
                ans = ans * x % MOD;
            }
            n >>= 1;
            x = x * x % MOD;
        }
        return ans;
    }

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



Measured memory_bytes: 59516
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int R = sc.nextInt();

        System.out.println(solve(R));
    }

    private static double solve(int R) {
        return 2 * Math.PI * R;
    }
}

Measured memory_bytes: 35924
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    t = 0
    mt = 0
    for i in range(n):
        if s[i] == "I":
            t += 1
        else:
            t -= 1
        mt = max(mt, t)
    print(mt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,i,j,n;
	float x;
	scanf("%d",&n);
	a=0;
	b=0;
	c=0;
	d=0;
	e=0;
	f=0;
	for(i=1;i<=n;i++) {
		scanf("%f",&x);
		if(x<165.0) {
			a+=1;
		}
		if(165.0<=x && x<170.0) {
			b+=1;
		}
		if(170.0<=x && x<175.0) {
			c+=1;
		}
		if(175.0<=x && x<180.0) {
			d+=1;
		}
		if(180.0<=x && x<185.0) {
			e+=1;
		}
		if(185.0<=x) {
			f+=1;
		}
	}
	if(a!=0) {
		printf("1:");
		for(j=1;j<=a;j++) {
			printf("*");
		}	
		printf("\n");
	}
	else {
		printf("1:\n");
	}
	if(b!=0) {
		printf("2:");
		for(j=1;j<=b;j++) {
			printf("*");
		}	
		printf("\n");
	}
	else {
		printf("2:\n");
	}
	if(c!=0) {
		printf("3:");
		for(j=1;j<=c;j++) {
			printf("*");
		}	
		printf("\n");
	}
	else {
		printf("3:\n");
	}
	if(d!=0) {
		printf("4:");
		for(j=1;j<=d;j++) {
			printf("*");
		}	
		printf("\n");
	}
	else {
		printf("4:\n");
	}
	if(e!=0) {
		printf("5:");
		for(j=1;j<=e;j++) {
			printf("*");
		}	
		printf("\n");
	}
	else {
		printf("5:\n");
	}
	if(f!=0) {
		printf("6:");
		for(j=1;j<=f;j++) {
			printf("*");
		}	
		printf("\n");
	}
	else {
		printf("6:\n");
	}
	return 0;
}

Measured memory_bytes: 620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		if(n<1200) {
			System.out.println("ABC");

		}else {
			System.out.println("ARC");
		}
	}

}


Measured memory_bytes: 21844
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
#include <tuple>
 
using namespace std;

typedef long long ll;

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

    int N;

    cin >> N;

    vector<string> s(N);

    for(int i = 0; i < N; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        //cerr << s[i] << endl;
    }

    sort(s.begin(), s.end());

    ll count = 0;

    ll c = 1;

    string re = s[0];

    for(int i = 1; i < N; i++) {
        if(re == s[i]) {
            c++;
        } else {
            count += c * (c - 1) / 2;
            re = s[i];
            c = 1;
        }
    }

    count += c * (c - 1) / 2;
    c = 1;

    cout << count << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vs = vector<string>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  ll N, left = 0, right = 0, ans = 0;
  cin >> N;
  vll intervals(N);

  for (int i = 0; i < N; i++) {
    cin >> intervals.at(i);
    right += intervals.at(i);
  }
  
  if (N == 2) ans = intervals.at(1) - intervals.at(0);
  
  else {
    for (int i = 0; i < N - 1; i++) {
      if (right - left > intervals.at(i) * 2) {
        left += intervals.at(i);
        right -= intervals.at(i);
        continue;
      }
      else if (right - left > intervals.at(i)) {
        left += intervals.at(i);
        right -= intervals.at(i);
        ans = right - left;
        if (ans < 0) ans = 0 - ans;
        break;
      }
      else {
        ans = right - left;
        if (ans < 0) ans = 0 - ans;
        break;
      }
    }
  }

  cout << ans << endl;
 
}

Measured memory_bytes: 1792
# coding:utf-8
# 找第二大的数的个数
n = input()
array = map(int, raw_input().split())
e_list = [array[i] for i in range(0, n, 2)]
o_list = [array[i] for i in range(1, n+1, 2)]


def process(arr):
    arr.sort()
    num = arr[0]
    counter = 0
    amt_arr = []
    arr.append(0)
    max = 0
    max_amt_num = []
    for i in arr:
        if i == num:
            counter += 1
        else:
            if counter > max:
                max_amt_num = [num]
                max = counter
            elif counter == max:
                max_amt_num.append(num)
                max = counter
            num = i
            amt_arr.append(counter)
            counter = 1
    if len(amt_arr) == 1:
        amt_arr.append(0)
    if len(max_amt_num) > 1:
        max_amt_num = "haha"
    amt_arr.sort()

    return amt_arr[-1], amt_arr[-2], max_amt_num
v1, v2, a1 = process(e_list)
v3, v4, a2 = process(o_list)
if a1 != a2 and a1 != "haha":
    result = len(array) - v1 - v3
else:
    result = len(array) - max(v1+v4, v2+v3)
print result


Measured memory_bytes: 11328
def takoyaki():
    amount = int(input())
    inStr = input().split()
    takoyakis = []
    sumEnergy = 0

    for i in range(amount):
       takoyakis.append(int(inStr[i]))

    for i in range(amount):
        for j in range(i + 1, amount):
            sumEnergy += takoyakis[i] * takoyakis[j]

    print(sumEnergy)

takoyaki()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int x,y;
  cin >> x >> y;
  bool ok = false;
  rep(i,101){
    rep(j,101){
      if(i+j==x && 2*i+4*j==y)ok=true;
    }
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

#define _debug(fmt, ...) fprintf(stderr, "%s: " fmt "\n", __func__, ##__VA_ARGS__)
#define rep(i, n) for (int i=0; i<(n); i++)
#define Rep(i, n) for (int i=1; i<=(n); i++)
#define range(x) (x).begin(), (x).end()
typedef long long LL;
typedef unsigned long long ULL;

int a, b;

char g[105][105];

int main() {
  cin >> a >> b;
  a--;
  b--;
  for (int i=0; i<50; i++)
    for (int j=0; j<100; j++)
      g[i][j] = '#';
  for (int i=50; i<100; i++) 
    for (int j=0; j<100; j++) 
      g[i][j] = '.';
  
  for (int i=0; i<a; i++) {
    int r = i / 50, c = i % 50;
    c = c*2 + (r&1);
    g[r*2][c] = '.';
  }
  for (int i=0; i<b; i++) {
    int r = i / 50, c = i % 50;
    c = c*2 + (r&1);
    g[99-r*2][c] ='#';
  }
  cout << "100 100" << endl;
  for (int i=0; i<100; i++) cout << g[i] << endl;
  return 0;
}



Measured memory_bytes: 384
import Data.List.Split
import Data.Maybe
import qualified Data.ByteString.Char8 as B
main = mapM_ (putStrLn . solve) . chunksOf 2 . map (map readInt . B.words) . B.lines =<< B.getContents
readInt = fst . fromJust . B.readInt
solve [_,as] = if a then "YES" else "NO" where
  a = even . length . filter odd $ as

Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    lint h, w;
    cin >> h >> w;

    lint res;

    if (h == 1 || w == 1) {
        cout << 1 << endl;
        exit(0);
    }

    if (h % 2 == 1 && w % 2 == 1) {
        res = (w * h + 1) / 2;
    }
    else {
        res = w * h / 2;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;

ll mod=1000000007;

ll mul(ll a,ll b, ll c){
	ll ans=0;
	while(b>0){
		if(b&1) ans=(ans+a)%c;
		a=(a+a)%c;
		b>>=1;
	}
	return ans;
}

ll ex2(ll a,ll b,ll c){
	ll ans=1;
	while(b>0){
		if(b&1) ans=mul(ans,a,c);
		a=mul(a,a,c);
		b>>=1;
	}
	return ans;
}

int main(){
	int n,k; cin>>n>>k;
	vector<ll> a(n);
	
	for(int i=0;i<n;i++) cin>>a[i];
			
	sort(all(a));
	
	ll c[n+5];
	
	c[k-1]=1ll;
	
	for(int i=k; i<=n-1; i++){
		c[i]=mul(c[i-1],(ll) i, mod);
		c[i]=mul(c[i],ex2(i-k+1, mod-2, mod), mod);
	}
	
	/*for(int i=k-1;i<=n-1;i++) cout<<c[i]<<" ";
	cout<<endl;*/
	
	ll ans=0;
	
	for(int i=0; i<=n-k; i++){
		ans+=mul(a[n-1-i] - a[i], c[n-1-i], mod);
		ans%=mod;
		if(ans<0) ans+=mod;
	}
	
	cout<<ans<<endl;
			
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
int main()
{
    int x,y,i,a[4]={4,6,9,11},f=0;
    scanf("%d %d",&x,&y);
    if(x==2||y==2) puts("No");
    else{
        for(i=0;i<4;i++) if(x==a[i]||y==a[i]) f++;
        printf("%s\n", f==1?"No":"Yes");
    }
    return 0;
}

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

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

int main(){
  int x,y;
  cin >> x >> y;
  int ans = x + y - gcd(x,y) + 1;
  cout << ans << endl;
}



Measured memory_bytes: 3124
dp = [True] #i円の買い物ができるか
x = int(input())
for i in range(99):
  dp.append(False)
for i in range(100, x+1):
  if(i < 106):
    dp.append(True)
  else:
    if(dp[i-100] or dp[i-101] or dp[i-102] or dp[i-103] or dp[i-104] or dp[i-105]):
      dp.append(True)
    else:
      dp.append(False)
if(dp[x]):
  print(1)
else:
  print(0)


Measured memory_bytes: 9604
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

//????°???????????????????
//????????? v[i]+v[j] ??????????????¨???????????????????????´??????????°??????????
//??????????????????????????¨??? v[i]!=v[j]
template<class T>
T minimum_cost_sort(const vector<T> &v) {
	int n = v.size();
	T total_cost = 0;
	vector<pair<T, int>> sorted(n);
	for (int i = 0; i < n; i++)sorted[i] = make_pair(v[i], i);
	sort(sorted.begin(), sorted.end());
	T mini = sorted[0].first;
	vector<bool> is_sorted(n);
	for (int i = 0; i < n; i++) {
		if (is_sorted[sorted[i].second])continue;
		T loop_cost = 0;
		T loop_sum = 0;
		T loop_mini = sorted[i].first;
		T loop_n = 0;
		for (int j = i;;) {
			T cost = sorted[j].first;
			int dst = sorted[j].second;
			is_sorted[j] = true;
			chmin(loop_mini, cost);
			loop_sum += cost;
			loop_n++;
			j = dst;
			if (is_sorted[dst])break;
		}
		total_cost += min(
			loop_sum + (loop_n - 2)*loop_mini,
			loop_sum + loop_mini + (loop_n + 1)*mini
		);
	}
	return total_cost;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> w(n); rep(i, 0, n) { cin >> w[i]; }
	cout << minimum_cost_sort(w) << endl;
	return 0;
}

Measured memory_bytes: 3236
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    x <- getInt
    let y = x `div` 500
    print $ y * 1000 + ((x - (y * 500)) `div` 5) * 5

Measured memory_bytes: 380
from collections import deque

N = int(input())


vlist = [[] for _ in range(N)]

for i in range(N-1):
    a,b,w = map(int, input().split())
    a -= 1
    b -= 1
    vlist[a].append((b,w))
    vlist[b].append((a,w))

ans = [-1] * N
q = deque()

ans[0] = 0
q.append(0)

while q:
    new = q.popleft()
    for node, weight in vlist[new]:
        if ans[node] != -1:
            continue
        ans[node] = (ans[new] + weight) % 2
        q.append(node)
    
for i in ans:
    print(i)





Measured memory_bytes: 42932
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N,K;
  cin>>N>>K;
  ll ans=0;
  ll mod=1e9+7;
  VL L(N+2);
  VL R(N+2);
  rep(i,N+1) (L[i+1]+=L[i]+i)%=mod;
  rep(i,N+1){
    ll tmp=N-i;
    (R[i+1]+=R[i]+tmp)%=mod;
  }
  rep(i,N-K+2) (ans=ans+mod+R[K+i]-L[K+i]+1)%=mod;
  cout<<ans<<endl;
}




Measured memory_bytes: 6264
#include<bits/stdc++.h>
typedef long long LL;
typedef double dl;
#define opt operator
#define pb push_back
const LL maxn=1e6+9,mod=998244353;
LL Read(){
	LL x(0),f(1); char c=getchar();
	while(c<'0' || c>'9'){
		if(c=='-') f=-1; c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3ll)+(x<<1ll)+c-'0'; c=getchar();
	}return x*f;
}
void Chkmin(LL &x,LL y){
	if(y<x) x=y;
}
void Chkmax(LL &x,LL y){
	if(y>x) x=y;
}
LL add(LL x,LL y){
	return x+=y,x>=mod?x-mod:x;
}
LL dec(LL x,LL y){
	return x-=y,x<0?x+mod:x;
}
LL mul(LL x,LL y){
	return 1ll*x*y%mod;
}
LL n;
char s[maxn];
int main(){
    scanf(" %s",s+1);
	n=strlen(s+1);
	LL ans(0),nw(0),num(0),pre(0),l(0);
	for(LL i=1;i<=n;++i){
		if(s[i]=='>'){
			if(!l) l=i;
			++num;
		}else{
			if(l){
				if(num<=pre){
			        ans+=(num-1)*num/2;
		        }else{
			        ans+=(num-1)*num/2+(num-pre);
		        }
				l=0;
				num=0;
				nw=0;
			}
			pre=++nw;
			ans+=nw;
		}
	}
	if(l){
		if(num<=pre){
			ans+=(num-1)*num/2;
		}else{
			ans+=(num-1)*num/2+(num-pre);
		}
	}
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 4212
#include <iostream>
#include <vector>
using namespace std;
#define END 1000000001

struct node {
	int val;
	node* before;
	node* after;
};
typedef struct node* Node;

class List {
public:
	Node root;

	List();
	void insert(int x);
	void dump();

	bool empty();
};

List::List() {
	this->root = new node;
	root->val = END;
	root->after = root;
	root->before = root;
	return;
}

void List::insert(int x) {
	Node n = new node;
	root->before->after = n;
	n->before = root->before;
	n->after = root;
	root->before = n;
	n->val = x;
}

bool List::empty() {
	return (root->after == root);
}

void List::dump() {
	Node cur = root->after;
	int num = 0;
	while (cur != root) {
		cout << (num == 0 ? "" : " ") << cur->val << flush;
		cur = cur->after;
		num++;
	}
	cout << endl;
	return;
}

void splice(List s, List t) {
	if (s.empty()) return;
	if (t.empty()) {
		s.root->after->before = t.root;
		s.root->before->after = t.root;
		t.root->after = s.root->after;
		t.root->before = s.root->before;
		s.root->before = s.root;
		s.root->after = s.root;
		return;
	}
	Node s_root_after = s.root->after;
	Node s_root_before = s.root->before;
	Node t_root_after = t.root->after;
	Node t_root_before = t.root->before;
	s.root->after = s.root;
	s.root->before = s.root;
	t.root->after = t_root_after;
	t.root->before = s_root_before;
	s_root_after->before = t_root_before;
	s_root_before->after = t.root;
	t_root_after->before = t.root;
	t_root_before->after = s_root_after;
	return;
}

using namespace std;

int main(){

	int n, q;
	cin >> n >> q;
	vector< List > a(n);
	int querynum = 0;
	while (querynum < q) {
		int var1;
		cin >> var1;
		if (var1 == 0) {
			int var2, var3;
			cin >> var2 >> var3;
			a[var2].insert(var3);
		}
		else if (var1 == 1) {
			int var2;
			cin >> var2;
			a[var2].dump();
		}
		else {
			int var2, var3;
			cin >> var2 >> var3;
			splice(a[var2], a[var3]);
		}
		querynum++;
	}
	
	return 0;
}


Measured memory_bytes: 18684
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>  
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vl vector<ll>
#define mod 1000000007


int main()
{
    ll n,x,t;cin>>n>>x>>t;
    if(x!=1)
    {
        ll y=n/x;
        ll z=n%x;
        if(z==0)
        cout<<t*y<<"\n";
        else
        cout<<t*(y+1)<<"\n";
    }
    else
    cout<<n*t<<"\n";
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 210000
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> new_data_set; 

// ll a[MAX][MAX];
// ll dp[MAX][(1<<21)];
// ll f(ll index,ll n,bitset<32>& w){
	
// }

void build(ll* a,ll* tree,ll ti,ll l,ll r){
	if(l==r){
		tree[ti]=a[l];
		return;
	}
	ll mid = (l+r)/2;
	build(a,tree,2*ti,l,mid);
	build(a,tree,2*ti+1,mid+1,r);
	tree[ti] = max(tree[2*ti],tree[2*ti+1]);
}

ll query(ll* tree,ll ti,ll l,ll r,ll left,ll right){
	if(left==-1 || right==-1) return 0;
	if(l>=left && r<=right) return tree[ti];
	if(l>right || r<left) return 0;
	ll mid = (l+r)/2;
	ll first = query(tree,2*ti,l,mid,left,right);
	ll second = query(tree,2*ti+1,mid+1,r,left,right);
	return max(first,second);
}

void update(ll* tree,ll ti,ll index,ll l,ll r,ll x){
	if(l==r){
		tree[ti]=x;
		return;
	}
	ll mid = (l+r)/2;
	if(index<=mid){
		update(tree,2*ti,index,l,mid,x);
	}else{
		update(tree,2*ti+1,index,mid+1,r,x);
	}
	tree[ti] = max(tree[2*ti],tree[2*ti+1]);
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	// memset(dp,-1,sizeof(dp));
	ll n;cin>>n;
	ll h[n];For(i,0,n) cin>>h[i];
	ll a[n];For(i,0,n) cin>>a[i];
	ll tree[4*MAX];
	memset(tree,0,sizeof(tree));
	// update(tree,1,h[0],0,MAX-1,a[0]);
	For(i,0,n){
		ll c = query(tree,1,0,MAX-1,0,h[i])+a[i];
		update(tree,1,h[i],0,MAX-1,c);
	}
	ll ans=0;
	For(i,0,MAX){
		ans = max(ans,tree[i]);
	}
	cout<<ans<<endl;
}


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

typedef long long ll;
const int N = (int)1e5 + 50;
typedef pair<int, int> P;

int n, m;
int a[N];
P p[N];

int main() {
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    for(int i = 0; i < m; i++) {
        cin >> p[i].second >> p[i].first;
    }
    sort(p, p + m, greater<>());
    ll sum = 0;
    int c = 0;
    for(int i = 0; i < n; i++) {
        if(c < m && p[c].second == 0) c++;

        if(c < m) sum += max(p[c].first, a[i]), p[c].second--;
        else sum += a[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(){
int a[10],b,c,d,e,f,g;
for(b=1;b<=10;b++){
	scanf("%d",&a[b]);
}
for(d=1;d<=9;d++){
		e=d+1;
	if(a[d]>a[e]){
		c=a[d];
		a[d]=a[e];
		a[e]=c;
	}
}
for(d=1;d<=8;d++){
		e=d+1;
	if(a[d]>a[e]){
		c=a[d];
		a[d]=a[e];
		a[e]=c;
	}
}
for(d=1;d<=7;d++){
		e=d+1;
	if(a[d]>a[e]){
		c=a[d];
		a[d]=a[e];
		a[e]=c;
	}
}
printf("%d\n%d\n%d\n",a[10],a[9],a[8]);
return 0;
}



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

int main() {
	int N;
	int l, r;
	int t = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> l >> r;
		t += r - l + 1;
	}
	cout << t << endl;

	return 0;
	
}

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

int main() {
    int N;
    cin >> N;
    int sum = 30; // log_2(10^9)=29.89...

    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        int temp = 0;

        int j = 0;
        while (j == 0) {
            if (A % 2 == 0) {
                temp++;
                A /= 2;
            }
            else {
                j = 1;
            }
        }

        sum = min(temp, sum);
    }
    cout << sum << endl;
    
}


Measured memory_bytes: 3616
from collections import deque
K = int(input())
x = deque([1,2,3,4,5,6,7,8,9])
cnt = 0
while True:
    v = x.popleft()
    if cnt == K-1 :
        break
    cnt += 1
    if v % 10 == 0:
        v = v *10
        x.append(v)
        v = v + 1
        x.append(v)
    else:
        if v % 10 == 9 :
            v = v * 10 + (v%10) - 1
            x.append(v)
            v += 1
            x.append(v)
        else:
            v = v * 10 + (v%10) - 1
            x.append(v)
            v += 1
            x.append(v)
            v += 1
            x.append(v)
print(v)


Measured memory_bytes: 11988
using System;
//using System.Collections.Generic;
//using System.Collections;
using System.Linq;

namespace solution
{

  class Class1
  {
    static void Main()
    {

      int[] num = Console.ReadLine().Split().Select(int.Parse).ToArray();
      var side = new int[6][];

      side[0] = new int[] { num[1], num[2], num[4], num[3], num[1] };
      side[1] = new int[] { num[0], num[3], num[5], num[2], num[0] };
      side[2] = new int[] { num[0], num[1], num[5], num[4], num[0] };
      side[3] = new int[] { num[0], num[4], num[5], num[1], num[0] };
      side[4] = new int[] { num[0], num[2], num[5], num[3], num[0] };
      side[5] = new int[] { num[1], num[3], num[4], num[2], num[1] };

      int times = int.Parse(Console.ReadLine());

      for (int i = 0; i < times; i++)
      {
        int[] f = Console.ReadLine().Split().Select(int.Parse).ToArray();
        for (int j = 0; j < 6; j++)
        {
          if (f[0] != num[j]) continue;

          int answer = Array.IndexOf(side[j], f[1]) + 1;
          Console.WriteLine(side[j][answer]);
        }
      }
    }

  }
}





Measured memory_bytes: 10012
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
mt19937 rnd(228);
const int F = (int)1e9 + 1;
int gen() {
    ll p1 = (ll)rnd();
    ll p2 = (ll)rnd() << 30LL;
    return (p1 | p2) % F + 1;
}
const int maxN = (int)1e5 + 100;
int a[maxN];
int S;
int n, k;
int cnt() {
    unordered_map < ll, bool > mp;
    ll sm = 0;
    mp[sm] = true;
    int f = 0;
    for (int i = 1; i <= n; i++) {
        sm += a[i];
        if (mp.count(sm - S)) f++;
        mp[sm] = true;
    }
    return f;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n >> k >> S;
    for (int i = 1; i <= k; i++) a[i] = S;
    while (true) {
        for (int j = k + 1; j <= n; j++) {
            a[j] = gen();
        }
        if (cnt() == k) {
            for (int i = 1; i <= n; i++) cout << a[i] << " ";
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> Poly; 
typedef pair<Point, double> Circle;
const double EPS = 1e-10;

// 2つの円の衝突判定 (共通接線の個数)
int intersection(Circle a, Circle b){
    double d = abs(a.first - b.first);
    if(a.second + b.second + EPS < d) return 4; // outside
    if(b.second + d + EPS < a.second) return 0; // B in A
    if(a.second + d + EPS < b.second) return 0; // A in B
    if(abs(a.second + b.second - d) < EPS) return 3; // 外接
    if(abs(b.second + d - a.second) < EPS) return 1; // 内接 B in A
    if(abs(a.second + d - b.second) < EPS) return 1; // 内接 A in B
    return 2; // 2点で交わる
}

int main(){
    Circle a, b;
    double x, y, r;
    cin >> x >> y >> r;
    a = {{x, y}, r};
    cin >> x >> y >> r;
    b = {{x, y}, r};
    cout << intersection(a, b) << endl;
}


Measured memory_bytes: 3284
#include<cstdio>
#include<cstring>
#include<utility>
#include<queue>
#include<algorithm>
using namespace std;

char board[6][6],ma[6][6],tmap[6][6];
int mov[8][2] = {1,0,1,-1,0,-1,-1,-1,-1,0,-1,1,0,1,1,1};
int mark[200];
int n;
struct status
{
    int x,y;
    int ord;
    int te;
    status(int a,int b,int c){x = a, y= b, ord = c;}
};
pair < int,int > s;

int encode(char (*a)[6])
{
    int bb=0;
    int va = 1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            bb += mark[a[i][j]]*(va);
            va *= 2;
        }
    }
    return bb;
}

void decode(int p,int x,int y)
{
    int cnt = 0;
    while(cnt != n*n)
    {
        int t = p%2;
        ma[cnt/n][cnt%n] = t==1?'#':'.';
        p /= 2;
        cnt++;
    }
    ma[x][y] ='@';
}

void construct(int s,int e,int ss,int ee)
{
    memcpy(tmap,ma,sizeof(tmap));
    char newmap[6][6];
    swap(tmap[s][e],tmap[ss][ee]);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            int cnt = 0;
            for(int k=0;k<8;k++)
            {
                int tx = i + mov[k][0] , ty = j + mov[k][1];
                if(tx >= 0 && ty >= 0 && tx < n && ty < n && (tmap[tx][ty]=='#' || tmap[tx][ty]=='@'))
                    cnt++;
            }
            if(tmap[i][j] == '.')
            {
                if(cnt == 3) newmap[i][j] = '#';
                else newmap[i][j] = tmap[i][j];
            }
            else if(tmap[i][j] == '#')
            {
                if(cnt == 3 || cnt == 2) newmap[i][j]='#';
                else newmap[i][j] = '.';
            }
            else newmap[i][j] = tmap[i][j];
        }
    }
    memcpy(tmap,newmap,sizeof(tmap));
}

int bfs()
{
     struct status fir(s.first,s.second,0);
     fir.te = encode(board);
     queue <struct status> q;
     q.push(fir);
     int flag = -1;

     while(!q.empty())
     {
         struct status vi = q.front();
         decode(vi.te,vi.x,vi.y);
         q.pop();
         if(!vi.te) flag = vi.ord;
         if(vi.ord > 10) break;
         if(flag == -1)
         {
             for(int i=0;i<8;i++)
             {
                 int tx = vi.x + mov[i][0],ty = vi.y + mov[i][1];
                 if(tx >= 0 && ty >= 0 && tx < n && ty < n && ma[tx][ty]!='#')
                 {
                     construct(vi.x,vi.y,tx,ty);
                     struct status newt(tx,ty,vi.ord+1);
                     newt.te = encode(tmap);
                     q.push(newt);
                 }
             }
         }
         else break;
     }
     return flag;
}

int main()
{
    mark['#'] = 1, mark['.'] = 0, mark['@'] = 0;
    while(~scanf("%d",&n),n)
    {
        getchar();
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                scanf("%c",&board[i][j]);
                if(board[i][j] == '@') s = make_pair(i,j);
            }
            getchar();
        }
        printf("%d\n",bfs());
    }
    return 0;
}

Measured memory_bytes: 14540
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

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

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  unordered_map<string, ll> UM;
  vector<string> S(N);
  REP(i, 0, N) {
    string s;
    cin >> s;
    S[i] = s;
    if (UM.find(s) != UM.end()) {
      UM[s]++;
    } else {
      UM.emplace(s, 1);
    }
  }
  ll M;
  cin >> M;
  vector<string> T(M);
  REP(i, 0, M) {
    string t;
    cin >> t;
    T[i] = t;
    if (UM.find(t) != UM.end()) {
      UM[t]--;
    } else {
      UM.emplace(t, 1);
    }
  }

  ll max = 0;
  for (const auto& um: UM) {
    if (um.second > max) {
      max = um.second;
    }
  }
  cout << max << endl;

  return 0;
}


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

int M, A, B;
vector<long long> primes;
bool flgs[100001];

int main(){
	for(int i = 2; i <= 100000; i++){
		flgs[i] = true;
	}

	for(int i = 2; i <= 100000; i++){
		if(flgs[i]){
			primes.push_back(i);
			for(int j = i + i; j <= 100000; j+=i){
				flgs[j] = false;
			}
		}
	}
	while(cin >> M >> A >> B, M){
		long long a = 1;
		long long b = 1;

		for(int i = 0; i < primes.size(); i++){
			if(primes[i] > M) break;
			for(int j = i; j < primes.size(); j++){
				if(primes[i] * primes[j] > M) break;
				if((primes[i] * B - primes[j] * A)  >= 0 &&
					a * b < primes[j] * primes[i]){
						a = primes[i];
						b = primes[j];
				}
			}
		}
		cout << a << " " << b << endl;
	}
}

Measured memory_bytes: 3236
require 'pp'

r, g, b = gets.split.map(&:to_i)
k = gets.to_i

k.times do |i|
    if r >= g
        g *= 2
    elsif g >= b
        b *= 2
    end

    #print b, g, r
    #puts ""
end

if b > g && g > r
    puts "Yes"
else
    puts "No"
end
    

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

int main() {
    int n;
    double m;
    cin>>n>>m;
    double a[n],sum=0,ans=0;
    
    for(int i=0;i<n;++i){
        cin>>a[i];
        sum +=a[i];
    }
    
    for(int i=0;i<n;++i){
        if(a[i]>=sum/(4*m)) ans+=1;
    }
    
    if(ans>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]){
    int x, y;
    while (1) {
        scanf("%d %d", &x, &y);
        if (x == 0 & y == 0) break;
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                if ((i+j) % 2 == 0) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
}



Measured memory_bytes: 2124
N,W = map(int,input().split())
L = []
for i in range(N):
  L.append(list(map(int,input().split())))
Vmax = 0
w_1 = []
w_2 = []
w_3 = []
w_4 = []
for i in range(N):
  if L[i][0] == L[0][0]:
    w_1.append(L[i][1])
  elif L[i][0] == L[0][0]+1:
    w_2.append(L[i][1])
  elif L[i][0] == L[0][0]+2:
    w_3.append(L[i][1])
  else:
    w_4.append(L[i][1])
w_1.sort()
w_2.sort()
w_3.sort()
w_4.sort()
w_1.reverse()
w_2.reverse()
w_3.reverse()
w_4.reverse()
for i in range(1,len(w_1)):
  w_1[i] = w_1[i-1]+w_1[i]
for i in range(1,len(w_2)):
  w_2[i] = w_2[i-1]+w_2[i]
for i in range(1,len(w_3)):
  w_3[i] = w_3[i-1]+w_3[i]
for i in range(1,len(w_4)):
  w_4[i] = w_4[i-1]+w_4[i]
w_1.append(0)
w_2.append(0)
w_3.append(0)
w_4.append(0)
for j in range(len(w_1)):
  for k in range(len(w_2)):
    for l in range(len(w_3)):
      for m in range(len(w_4)):
        if j*L[0][0]+k*(L[0][0]+1)+l*(L[0][0]+2)+m*(L[0][0]+3) > W:
          continue
        else:
          if w_1[j-1]+w_2[k-1]+w_3[l-1]+w_4[m-1] >= Vmax:
            Vmax = w_1[j-1]+w_2[k-1]+w_3[l-1]+w_4[m-1]
print(Vmax)

Measured memory_bytes: 3192
#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 INF 2e9
#define ll long long

int main(){
    int h, w;
    cin>>h>>w;
    char c[h][w];

    int i, j;

    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            cin>>c[i][j];
        }
    }

    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            cout<<c[i][j];
        }
        cout<<endl;
        for(j=0; j<w; j++){
            cout<<c[i][j];
        }
        cout<<endl;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256