akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<map>
using namespace std;
const int N=1e5+50;
const int INF=0x3f3f3f3f;
typedef long long ll;
char s[N];
int main()
{
    scanf("%s",s);
    int len=strlen(s);
    int s1=0,s2=0,s3=0,s4=0;
    if(len%2==0)
    {
        s1=len/2;
        s2=len/2;
    }
    else
    {
        s1=len/2+1;
        s2=len/2;
    }
    for(int i=0;i<len;i++)
    {
        if(s[i]=='g')
            s3++;
        else
            s4++;
    }
    if(s2==s4)
        printf("0\n");
    else if(s2>s4)
    {
        int win=s2-s4;
        printf("%d\n",win);
    }
    else
    {
        int win=s2-s4;
        printf("%d\n",win);
    }
    return 0;
}

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

int N;
vector<int> A;

long long f(long long b) {
  long long ret = 0;
  for (int i = 0; i < N; i++) {
    ret += abs(A[i] - (b + i + 1));
  }
  return -ret;
}

double search(double left, double right)
{
  int maxLoop = 1e3;
  for (int loop = 0; loop < maxLoop; ++loop){
    if (f((left * 2 + right) / 3) > f((left + right * 2) / 3)){
      right = (left + right * 2) / 3;
    } else {
      left = (left * 2 + right) / 3;
    }
  }
  return (right + left) * 0.5;
}

int main(void) {
  cin >> N;
  A = vector<int>(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  // cerr << search(-1e6, 1e9) << endl;
  long long avg = search(-1e6, 1e9);
  long long ret = 1e18;
  for (int d = -100; d <= 100; d++) {
    long long m = 0;
    for (int i = 0; i < N; i++) {
      m += abs(A[i] - (avg + i + d));
    }
    ret = min(ret, m);
  }
  cout << ret << endl;


  return 0;
}

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

using namespace std;

int main() {
  vector<string> v;
  
  int n,l;
  
  cin>>n>>l;
  
  for(int i=0;i<n;i++)
  {
    string s;
    cin>>s;
    v.push_back(s);
  }
  
for(int i=0;i<n-1;i++)
{for(int j=i+1;j<n;j++)
{if(v[j]<v[i])
{string s=v[j];
v[j]=v[i];
v[i]=s;}
}}  
  string ss;
  for(int i=0;i<n;i++)
  {ss=ss+v[i];}
  
  cout<<ss;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,x;cin>>k>>x;
    for(int i=-100000;i<=100000;i++)
    {
        if(x-k+1<=i&&i<=x+k-1)
            printf("%d ",i);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c, d, p;
	cin >> a >> b >> c >> d >> p;
	int x, y;
	x = a*p;
	if (p < c){
		y = b;
	}
	else
	{
		y = b + (p - c)*d;
	}
	cout << min(x, y) << endl;
}

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

int main() {
  int N, K;
  vector<char> S(N);
  cin >> N >> K;
  rep(i, N) cin >> S[i];
  if (S[K-1] == 'A') S[K-1] = 'a';
  else if (S[K-1] == 'B') S[K-1] = 'b';
  else if (S[K-1] == 'C') S[K-1] = 'c';
  rep(i, N) cout << S[i];
  cout << endl;
  
  
  return 0;
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#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 AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  while (A > 0 && C > 0) {
    C -= B;
    if (C <= 0)
      break;
    A -= D;
    if (A <= 0)
      break;
  }
  if (C <= 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

#ifdef LOCAL
#define show(x) cerr<<__LINE__<<": "<<#x<<(x)<<endl
#else
#define show(x) true
#endif

typedef long long ll;
template<class T> using V=vector<T>;

template<class T, class U>
void chmin(T &t, const U u) { if (t > u) t = u; }

template<class T, class U>
void chmax(T &t, const U u) { if (t < u) t = u; }

const int INF = (1 << 30) - 1;
const ll INFL = (ll) 5e15;
const int MOD = 1e9 + 7;

class Solver {
public:
    bool solve() {
        cin >> T >> D >> L;
        if (T == 0) return false;
        res.resize(3 * T);
        REP(i, T) {
            int x;
            cin >> x;
            if (x >= L) {
                res[i]++;
                res[i + D]--;
            }
        }

        rep(i, 1, T + 10) {
            res[i] += res[i - 1];
        }
        REP(i, T - 1) {
            if (res[i] > 0) ans++;
        }

        cout << ans << endl;
        return true;
    }

private:
    int T, D, L;
    V<ll> res;
    ll ans = 0;
};

int main() {

    while (Solver().solve());

    return 0;
}




Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    cout << fixed;
    if (x > (double)(a*a*b)/2.0) {
        cout << setprecision(10) << atan(2.0*(double)(a*a*b-x)/(a*a*a)) * 180. / 3.14159265358979323846 << endl;
    } else {
        cout << setprecision(10) << atan((double)(a*b*b)/(2.0*x)) * 180. / 3.14159265358979323846 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint x;
    cin >> x;
    lint ret = x / 500 * 1000;
    ret += (x % 500) / 5 * 5;
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
// m-solutions2020_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;

    int ans = 0;
    while (B <= A){
        B *= 2;
        ans++;
    }

    while (C <= B){
        C *= 2;
        ans++;
    }

    if (ans <= K){
        print("Yes");
    } else {
        print("No");
    }


    return 0;
}


Measured memory_bytes: 3636
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i=0; i < n; i++){
        string input;
        cin >> input;
        string check = input.substr(0, 2) + input.substr(input.size()-2, 2);

        bool isCorrect = true;
        if(check == ">'=~"){
            if(input.size() == 4) isCorrect = false;

            int count = 0;
            for(int j=2; input.substr(j,1) == "="; j++) count++;
            if(input.substr(count+2, 1) != "#") isCorrect = false;
            for(int j=2+count+1; j < 2+count*2+1; j++) if(input.substr(j, 1) != "=") isCorrect = false;
            if(input.size() != count*2+2+1*2) isCorrect = false;

            if(isCorrect) cout << "A" << endl;
        }else if(check == ">^~~"){
            if(input.size() == 4) isCorrect = false;
            for(int j=2; j < input.size()-2; j+=2) if(input.substr(j, 2) != "Q=") isCorrect = false;

            if(isCorrect) cout << "B" << endl;
        }else {
            cout << "NA" << endl;
        }
        if(!isCorrect) cout << "NA" << endl;
    }
}

Measured memory_bytes: 1216
#include <iostream>
using namespace std;
 
int weight, hight;
int g[101][101] = {0};
int sc;
int sx, sy, gx, gy;
bool flag = false;
const int vx[4] = {0, 0, 1, -1};
const int vy[4] = {1, -1, 0, 0};
 
void dfs(int x, int y){
    if(x == gx && y == gy){
        flag = true;
        return;
    }
    
    if(g[y][x] == 0){
        flag = false;
        return;
    }
    
    g[y][x] = -1;
    
    for(int i = 0;i < 4;i++){
        int nx = x + vx[i];
        int ny = y + vy[i];
         
        if(nx >= 0 && nx < weight && ny >= 0 && ny < hight && g[ny][nx] == sc){
            dfs(nx, ny);
        }
    }
    return;
}
 
int main(){
    while(1){
        int n, c, d, x, y;
        flag = false;
        g[101][101] = {0};
        
        cin >> weight >> hight;
        
        if(weight == 0 && hight == 0){
            break;
        }
         
        cin >> sx >> sy >> gx >> gy >> n;
        sx--; sy--; gx--; gy--;
         
        for(int i = 0;i < n;i++){
            cin >> c >> d >> x >> y;
            x--; y--;
             
            if(d == 0){
                for(int h = 0;h < 2;h++){
                    for(int w = 0;w < 4;w++){
                        g[y+h][x+w] = c;
                    }
                }
            }else{
                for(int h = 0;h < 4;h++){
                    for(int w = 0;w < 2;w++){
                        g[y+h][x+w] = c;
                    }
                }
            }
        }
         
        sc = g[sy][sx];
        dfs(sx, sy);
         
        if(flag){
            cout << "OK" << endl;
        }else{
            cout << "NG" << endl;
        }
    }
     
    return 0;
}

Measured memory_bytes: 3088
#include <cstdio>
#include <vector>
using namespace std;
int N, K, Q;

int main(){
  scanf("%d %d %d", &N, &K, &Q);
  
  vector<int> participant(N,0);
  for(int i=0; i<Q; i++){
    int A; scanf("%d", &A); 
    A--;
    participant[A]++;
  }
  
  for(int i=0; i<N; i++){
    int dmy = participant[i] + K - Q;
    if(dmy > 0){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1024
# coding:utf-8
def main():
    a,b = map(int, input().split())

    max_num = max(a,b)
    num_num = min(a,b)
    if max_num - num_num <= (16-a-b) :
        print('Yay!')
    else:
        print(':(')


if __name__ == '__main__' :
    main()

Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, K;
  cin>>N>>K;
  vector<int> arr;
  map<int, int> amap;
  int tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(amap[tmp]==0) arr.push_back(tmp);
    amap[tmp]++;
  }
  vector<int> ans;
  for(int i=0;i<arr.size();++i) {
    ans.push_back(amap[arr[i]]);
  }
  sort(ans.begin(), ans.end(), greater<int>());
  int ans1 = 0;
  for(int i=K;i<ans.size();++i) {
    ans1 += ans[i];
  }
  cout<<ans1<<endl;
}



Measured memory_bytes: 15020
import heapq

N, K = map(int, input().split())

td = []
for _ in range(N):
    t, d = map(int, input().split())
    td.append((t, d))

td.sort(reverse=True, key=lambda x: x[1])

g1 = [0] * (N + 1)
g0 = []
sumt = 0
for i in range(K):
    t, d = td[i]
    if g1[t] == 0:
        g1[t] = d
        sumt += 1
    elif g1[t] < d:
        heapq.heappush(g0, g1[t])
        g1[t] = d
    else:
        heapq.heappush(g0, d)

sumg1 = sum(g1)
sumg0 = sum(g0)
ans = sumg1 + sumg0 + sumt * sumt
for i in range(K, N):
    t, d = td[i]
    if g1[t] == 0 and len(g0) > 0:
        g1[t] = d
        sumg1 += d
        sumg0 -= heapq.heappop(g0)
        sumt += 1
        newans = sumg1 + sumg0 + sumt * sumt
        ans = max(ans, newans)

print(ans)

Measured memory_bytes: 18272
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 
int main(){
	int N, P;
	cin >> N >> P;
	string S;
	cin >> S;
	reverse(S.begin(), S.end());//*pow(10, i)したときにiがindexと一致するようにする
  //↑なんかここでreverseしたら P==2 || P==5 のときに違う答えが出てしまう
	if(P==2 || P==5){
		ll ans = 0;
		for(int i=0; i<N; i++){
			if((S[i]-'0')%P !=0) continue;
			//ans += i+1;
      ans += N-i;
		}
		cout << ans << endl;
		return 0;
	}

	

	int wa = 0;//累積和
	int pow_10_i = 1;// pow(10, i)%P
	map<int, int> mp;
	ll ans = 0;
	for(int i=0; i<N; i++){
		mp[wa]++;
		wa += (S[i]-'0')*pow_10_i;
		wa %= P;
		ans += mp[wa];
		pow_10_i = pow_10_i * 10 % P;
	}


	cout << ans << endl;


}


Measured memory_bytes: 3984
N=int(input())
s=list(input())
for i in range(2**2):
  sw=[1,1]
  ans=[1]*(N+1)
  for j in range(2):
    if (i>>j)%2==1:
      sw[j]=0
      ans[j]=0
  for j in range(1,N):
    if sw[1]== 1:
      if s[j]=="o":
        sw[0],sw[1]=sw[1],sw[0]
      else:
        sw[0],sw[1]=sw[1],(sw[0])^1
    else:
      if s[j]=="o":
        sw[0],sw[1]=sw[1],(sw[0])^1
      else:
        sw[0],sw[1]=sw[1],sw[0]
    ans[j+1]=sw[1]
  
  if ans[0]==ans[N]:
    if ans[0]==1:
      if s[0]=="o":
        if ans[N-1]!=ans[1]:
          continue
      else:
        if ans[N-1]==ans[1]:
          continue
    else:
      if s[0]=="o":
        if ans[N-1]==ans[1]:
          continue
      else:
        if ans[N-1]!=ans[1]:
          continue
    for i in range(N):
      if ans[i]==1:
        ans[i]="S"
      else:
        ans[i]="W"
    print("".join(ans[:N]))
    exit(0)
  else:
    continue
print(-1)


Measured memory_bytes: 5660
#include <stdio.h>
int main(){
int a,b;scanf("%d%d",&a,&b);
double ret=0;
for(int i=1;i<=a;i++){
double tmp=1.0/a;
int now=i;
while(now<b){
now*=2;
tmp/=2;
}
ret+=tmp;
}
printf("%.12f\n",ret);
}


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

int main() {
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<n;i++){
        if(n%i==0){
            sum=sum+(n/i)-1;
        }
        else    sum=sum+(n/i);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3636
import math
n=int(input())
station=[None]*(n-1)
for i in range(n-1):
  station[i]=list(map(int,input().split()))
for i in range(n-1):
  time=0
  for j in range(i,n-1):
    if time<station[j][1]:
      time=station[j][1]+station[j][0]
    else:
      time=math.ceil(time/station[j][2])*station[j][2]+station[j][0]
  print(time)
print(0)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

vector<int> G[200000];
ll c[200000];
ll ans[200000];

void dfs(int v, int p, ll sum) {
  ans[v] = c[v] + sum;
  REP(i, G[v].size()) {
    int ne = G[v][i];
    if (ne == p) continue;
    dfs(ne, v, ans[v]);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  REP(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  REP(i, q) {
    int p, x;
    cin >> p >> x;
    p--;
    c[p] += x;
  }
  dfs(0, -1, 0ll);
  REP(i, n) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 28672
package main

import "fmt"

func main() {
	var N, T, t, from, to, total int
	fmt.Scan(&N, &T)
	fmt.Scan(&t)
	from = t
	to = from + T
	for i := 0; i < N-1; i++ {
		fmt.Scan(&t)
		if to < t {
			total += to - from
			from = t
			to = from + T
		} else {
			to = t + T
		}
	}
	total += to - from
	fmt.Println(total)
}


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

int main (void) {
    char *week[7];
    week[0] = "SUN";
    week[1] = "MON";
    week[2] = "TUE";
    week[3] = "WED";
    week[4] = "THU";
    week[5] = "FRI";
    week[6] = "SAT";
    char s[4];
    scanf("%s", s);
    int i;
    for ( i=0; i<7; i++ ) {
        if ( !strcmp(s, week[i]) )
            break;
    }
    printf("%d\n", 7-i);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  char a,b;
  cin >> a >> b;
  if(a<b) cout <<"<\n";
  else if(a>b)cout <<">\n";
  else cout <<"=\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int x;
    int i;
    
    scanf("%d", &x);

    printf("ai1333");
    
    for (i = 0; i < x / 100; i++){
        printf("3");
    }
    
    printf("\n");
    
    return (0);
}



Measured memory_bytes: 2112
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();
        int h = sc.nextInt();
        int m = sc.nextInt();

        double a_angle = (h * 60 + m) / (12.0 * 60) * 360 ;
        double b_angle = m / (60.0) * 360;

        double angle = a_angle - b_angle;

        System.out.println(Math.sqrt((a * a) + (b * b) - (2 * a * b) * Math.cos(Math.toRadians(angle))));

    }
}


Measured memory_bytes: 35916
n = int(input())
a = [int(input()) for i in range(n)]
T = [False for i in range(n)]
tmp = 1
T[0] = True
count = 1
while True:
    tmp = a[tmp-1]
    if T[tmp -1]:
        print(-1)
        exit()
    T[tmp-1] = True
    if tmp == 2:
        print(count)
        break
    count+=1

Measured memory_bytes: 55768
/*input
2
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

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

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 1e6+1;
queue<int> q;
int vis[N];

void solve(){
  	int k;
  	cin >> k;
  	q.push(7%k);
  	vis[7%k] = 1;
  	while(!q.empty()){
  		int u = q.front();
  		q.pop();
  		int v = (u*10)+7;
  		v %= k;
  		if(vis[v])continue;
  		q.push(v);
  		vis[v] = vis[u]+1;
  	}
  	if(vis[0]){
  		cout << vis[0] << endl;
  	}
  	else{
  		cout << -1 << endl;
  	}
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 11452
N=int(input())
X=list(map(int,input().split()))
M=int(input())
A=list(map(int,input().split()))
for i in range(M):
    X[A[i]-1]+=1
    if A[i]!=N:
        if X[A[i]-1]>=X[A[i]]:
            X[A[i]-1]=X[A[i]]-1
    if X[A[i]-1]>=2019:
        X[A[i]-1]=2019

for i in range(N):
    print(X[i])


Measured memory_bytes: 5604
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, t, a, k;

int main(){
	cin >> n;

	ll nowt = 1;
	ll nowa = 1;
	for(ll i = 1; i <= n; i++){
		cin >> t >> a;
		k = max(max((nowt+t-1)/t, (nowa+a-1)/a), 1LL);
		nowt = k*t;
		nowa = k*a;
	}
	
	cout << k*(t+a) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); 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() {
    string s;
    cin >> s;
    int n = (int)s.size();
    if (n == 1) {
        cout << s << endl;
        return 0;
    }

    vector<string> t;
    for (ll mask = 0; mask < (1<<(n-1)); mask++) {
        string tmp = "";
        tmp += s[0];
        rep(i, 0, n-1) {
            if (mask & (1<<i)) {
                t.emplace_back(tmp);
                tmp = s[i+1]; 
            }
            else {
                tmp += s[i+1];
            }
            if (i == n-2) t.emplace_back(tmp);
        }
    }

    ll ans = 0;
    for(auto s : t) {
        ans += stoll(s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
N_MAX = 10**6
MOD = 10**9 + 7
fac, finv, inv = [0]*N_MAX ,[0]*N_MAX, [0]*N_MAX
def com_init():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, N_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

def com(n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


def factorization(n):
    pf_cnt = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                cnt += 1
                temp //= i
            pf_cnt[i] = cnt

    if temp != 1: pf_cnt[temp] = 1
    if not pf_cnt: pf_cnt[n] = 1

    return pf_cnt



def main():
    n,m = map(int, input().split())
    if m == 1:
        print(1)
        exit()
    facd = factorization(m)
    com_init()
    ans = 1
    for k,v in facd.items():
        comb = com(v+n-1,n-1)
        ans *= comb
        ans%=MOD

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 88896
def main():
    n = int(input())
    A = list(map(int, input().split()))

    A_tmp = []
    for i in range(n):
        A_tmp.append(A[i] - (i+1))
    A_tmp_sorted = sorted(A_tmp)
    sum1 = 0
    sum2 = 0
    if n%2 == 0:
        for i in range(n):
            sum1 += abs(A_tmp_sorted[n//2]-A_tmp[i])
            sum2 += abs(A_tmp_sorted[n//2-1]-A_tmp[i])
        print(min(sum1,sum2))
    else:
        for i in range(n):
            sum1 += abs(A_tmp_sorted[n//2]-A_tmp[i])
        print(sum1)


if __name__ == '__main__':
    main()


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

int main() {
  long N;
  cin >> N;
  vector<long> cnt(N + 1);
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= N; j += i) cnt.at(j)++;
  }
  long ans = 0;
  for (int i = 1; i <= N; i++) ans += cnt.at(i) * i;
  cout << ans << "\n";
}

Measured memory_bytes: 81372
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	private static String word=sc.next();
	private static int counter=0;
	public static void main (String[] args){
		while(true){
			String w=sc.next();
			if(w.equals("END_OF_TEXT")) break;
			if(w.equalsIgnoreCase(word)) counter++;
		}
		System.out.println(counter);
	}
}

Measured memory_bytes: 26080
import os
import heapq
import sys,threading
import math as mt
import operator
from copy import copy
from collections import defaultdict,deque
from io import BytesIO, IOBase

sys.setrecursionlimit(2*10 ** 5)
#threading.stack_size(2**27)


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


"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""


def inpt():
    return [int(k) for k in input().split()]

def main():
    a,b,c,d=inpt()
    print(max(a*c,a*d,b*c,b*d))





BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threading.Thread(target=main).start()


Measured memory_bytes: 68712
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0301
# 双方向循環リストを使用した実装
from sys import stdin


class DoublyCicularList():

    class Cell():
        def __init__(self, v):
            self.next = None
            self.previous = None
            self.value = v

    def __init__(self):
        self.pos = DoublyCicularList.Cell(0)
        self.pos.next = self.pos
        self.pos.previous = self.pos
        self.head = self.pos


def main():
    N, M, Q = map(lambda x: int(x), stdin.readline().strip().split(' '))
    a_list = map(lambda x: int(x), stdin.readline().strip().split(' '))
    q_list = map(lambda x: int(x), stdin.readline().strip().split(' '))
    dcl = DoublyCicularList()
    for i in range(1, N):
        prev = dcl.pos
        dcl.pos.next = DoublyCicularList.Cell(i)
        dcl.pos = dcl.pos.next
        dcl.pos.previous = prev
        dcl.pos.next = dcl.head
        dcl.head.previous = dcl.pos
    dcl.pos = dcl.head
    for i, a in enumerate(a_list):
        for _ in range(a % (N-i)):
            if a % 2 == 0:
                dcl.pos = dcl.pos.next
            else:
                dcl.pos = dcl.pos.previous
        dcl.pos.previous.next = dcl.pos.next
        dcl.pos.next.previous = dcl.pos.previous
        dcl.pos = dcl.pos.next
    res_list = []
    last_value = dcl.pos.previous.value
    while True:
        if dcl.pos.value == last_value:
            res_list.append(dcl.pos.value)
            break
        res_list.append(dcl.pos.value)
        dcl.pos = dcl.pos.next
    print('\n'.join(['1' if q in res_list else '0' for q in q_list]))


if __name__ == '__main__':
    main()



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

#define INF (INT32_MAX/2)
#define MAX 3000

string s;
string t;

int C[MAX + 1][MAX + 1];

int LCSLength( string &X, string &Y )
{
	int m = X.size();
	int n = Y.size();
    for( int i = 1; i <= m; i++ ) {
        for( int j = 1; j <= n; j++ ) {
            if( X[i - 1] == Y[j - 1] ) {
                C[i][j] = C[i - 1][j - 1] + 1;
			}
            else {
                C[i][j] = max( C[i][j-1], C[i-1][j] );
			}
		}
	}
    return C[m][n];
}

string backtrack( string &X, string &Y, int i, int j )
{
    if( i == 0 || j == 0 ) {
        return "";
	}
    if(  X[i - 1] == Y[j - 1] ) {
        return backtrack( X, Y, i - 1, j - 1 ) + X[i - 1];
	}
    if( C[i][j - 1] > C[i - 1][j] ) {
        return backtrack( X, Y, i, j - 1 );
	}
    return backtrack( X, Y, i - 1, j );
}

int main() {
	cin >> s;
	cin >> t;

	LCSLength( s, t );

	cout << backtrack( s, t, s.size(), t.size() ) << endl;

	return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; string s; cin>>n>>s;
	vector<int>r,g; vector<bool>b(n+1,false);
	int B=0;
	for(int i=0;i<n;++i){
		if(s.at(i)=='R')r.emplace_back(i);
		else if(s.at(i)=='G')g.emplace_back(i);
		else ++B,b.at(i)=true;
	}
	int64_t ans=0;
	for(auto&R:r){
		for(auto&G:g){
			int left=min(R,G),right=max(R,G);
			int Bleft=left-abs(R-G),Bmid=(left+right)/2,Bright=right+abs(R-G);
			ans+=B;
			if(Bleft>=0&&b.at(Bleft))--ans;
			if(b.at(Bmid)&&Bmid-left==right-Bmid)--ans;
			if(Bright<n&&b.at(Bright))--ans;
		}
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 3556
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
void solve(){
    ll a, b, k;
    cin >> a >> b >> k;
    ll d = max(a - k, 0ll);
    k -= a-d;
    cout << d << ' ' << max(0ll, b - k);
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--) solve();
}

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

using namespace std;

typedef long long int lli;

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

    int n, m, s[2001], t[2001];
    lli mod = 1000000007;
    vector<vector<lli>> lts(2001, vector<lli>(2001, 0));

    for (int i=0; i<2001; i++) lts[i][0] = lts[0][i] = 1;

    cin >> n >> m;
    for (int i=0; i<n; i++) cin >> s[i+1];
    for (int i=0; i<m; i++) cin >> t[i+1];

    for (int is=1; is<=n; is++) {
        for (int it=1; it<=m; it++) {
            lts[is][it] = (lts[is-1][it] + lts[is][it-1])%mod;
            if (s[is] != t[it]) {
                lts[is][it] += mod - lts[is-1][it-1];
                lts[is][it] %= mod;
            }
        }
    }
/*
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            cout << lts[i][j] << " ";
        }
        cout << endl;
    }
*/
    cout << lts[n][m] << endl;

    return 0;
}


Measured memory_bytes: 31616
#include<cstdio>
const int mod=1000000007;
int n,m,f[3001][3001][2];
int main()
{
	scanf("%d%d",&n,&m);
	f[0][0][1]=1;
	for(int i=1;i<=n;i++)f[0][i][0]=1;
	for(int i=0;i<m;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<2;k++)
			{
				if(j)(f[i+1][j-1][k||!(j-1)]+=f[i][j][k])%=mod;
				if(j)(f[i+1][j][k||!(j-1)]+=f[i][j][k])%=mod;
				if(n-j)(f[i+1][j][k]+=f[i][j][k])%=mod;
				if(n-j)(f[i+1][j+1][k]+=f[i][j][k])%=mod;
			}
	long long ans=0;
	for(int i=0;i<=n;i++)ans+=f[m][i][1];
	printf("%lld\n",ans%mod);
	return 0;
}


Measured memory_bytes: 70656
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int table[256];

void init_table(){
  int idx = 0;
  for(int i=0;i<=9;i++){
    table[ i + '0'] = idx;
    idx++;
  }
  for(int i='A';i<='Z';i++){
    table[i] = idx;
    idx++;
  }
  for(int i='a';i<='z';i++){
    table[i] = idx;
    idx++;
  }
}

int fast_pow(int x, int n){
  int res = 1;
  while(n > 0) {
    if (n & 1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}

int conv(int type,const string& num){
  int res = 0;
  for(int i=num.size()-1,j=0;i>=0;i--,j++){
    res += table[num[i]] * fast_pow(type,j);
  }
  return res;
}

int main(){
  init_table();

  int total_initial_subsets;
  while(~scanf("%d",&total_initial_subsets)){
      
    int nim = 0;
    for(int subset_idx=0;subset_idx < total_initial_subsets;subset_idx++){
      int type;
      string num;
      cin >> type >> num;

      int pile = conv(type,num);
      
      nim ^= pile;
    }
    printf("%s\n",nim == 0 ? "lose" : "win");
  }
}

Measured memory_bytes: 1228
using System;
class house{
    public static void Main(){
        int b,f,r,v;
        int n = int.Parse(Console.ReadLine());
        int[,] h = new int[12,10];
        for(int i=0; i<12; i++){
            for(int j=0; j<10; j++){
                h[i,j] = 0;
            }
        }
        for(int i=0; i<n; i++){
            String[] str = Console.ReadLine().Split(' ');
            b = int.Parse(str[0]);
            f = int.Parse(str[1]);
            r = int.Parse(str[2]);
            v = int.Parse(str[3]);
            h[3*(b-1)+f-1,r-1] += v;
        }
        for(int i=0; i<4; i++){
            for(int j=0; j<3; j++){
                for(int k=0; k<10; k++){
                    Console.Write(" {0}",h[3*i+j,k]);
                }
                Console.WriteLine("");
            }
            if(i!=3){
                Console.WriteLine("####################");
            }
        }
    }
}


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

long long inputs[200005];
long long oddsum[200005];
long long evensum[200005];

int main(){
   int a,b,x;
   cin >> a >> b >> x;
   if(a+b>=x && a<=x)
   {
       cout << "YES" << endl;
   }
   else cout << "NO" << endl;
}


Measured memory_bytes: 3576
D,G = map(int,input().split())
P = []
num_p = 0
for i in range(1,D+1):
    p,c = map(int,input().split())
    num_p += p
    for j in range(1,p+1):
        P += [(j,i*100*j+c*(j==p))]
dp = [0]*(num_p+1)
for k,pt in P:
    if k==1:
        t_dp = dp[:]
    for cur in range(1,num_p+1):
        if cur>=k:
            dp[cur] = max(dp[cur], t_dp[cur-k]+pt)
for i in range(num_p+1):
    if dp[i]>=G:
        print(i)
        break

Measured memory_bytes: 3188
def rename(a, b) :
    new = []
    re_a = list(reversed(a))
    re_b = list(reversed(b))
    new.append(''.join(a + b))
    new.append(''.join(re_a + b))
    new.append(''.join(a + re_b))
    new.append(''.join(re_a + re_b))
    new.append(''.join(b + a))
    new.append(''.join(re_b + a))
    new.append(''.join(b + re_a))
    new.append(''.join(re_b + re_a))
    return list(set(new))

m = int(input())
for i in range(m) :
    train = list(input())
    new_train = []
    for j in range(1, len(train)) :
        pre_train = train[:j]
        bk_train = train[j:]
        new_train = new_train + rename(pre_train, bk_train)
    print(len(list(set(new_train))))


Measured memory_bytes: 5664
# AOJ 1020: Cleaning Robot
# Python3 2018.7.5 bal4u

mv = ((-1,0),(0,1),(1,0),(0,-1))
while True:
	n = int(input())
	if n == 0: break
	t1, t2, t3 = input().split()
	s, t, b = ord(t1)-ord('A'), ord(t2)-ord('A'), ord(t3)-ord('A')
	f = [[[0.0 for a in range(3)] for c in range(3)] for r in range(17)]
	f[0][s//3][s%3] = 1
	for j in range(1, n+1):
		for r in range(3):
			for c in range(3):
				for i in range(4):
					r2, c2 = r + mv[i][0], c + mv[i][1]
					if r2 < 0 or r2 >= 3 or c2 < 0 or c2 >= 3 or 3*r2+c2 == b:
						r2, c2 = r, c
					f[j][r2][c2] += f[j-1][r][c]/4
	print(f[n][t//3][t%3])


Measured memory_bytes: 5632
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
A = [list(sys.stdin.buffer.readline().decode().rstrip()) for _ in range(N)]
A = np.array(A, dtype='U1')

col_has_black = np.any(A == '#', axis=0)
row_has_black = np.any(A == '#', axis=1)
col_all_black = np.all(A == '#', axis=0)
row_all_black = np.all(A == '#', axis=1)

# 黒がなかったら作れない
if np.all(~col_has_black):
    print(-1)
    exit()


def count_row_to_black(i):
    # 黒にする行を決めたときに何手で真っ黒にできるか
    whites = np.count_nonzero(A[i] == '.')
    # 最低でも白の数だけは手数が必要
    if col_has_black[i]:
        # 対応する列に黒があれば、その行を使って i 行目を黒くする
        return whites
    else:
        # どっかから対応する列に黒を持ってきて↑やる
        return whites + 1


# 全部黒の行を1つ以上作らないといけない
ans = INF
for i in range(N):
    cnt = count_row_to_black(i) + (N - col_all_black.sum())
    ans = min(ans, cnt)
print(ans)



Measured memory_bytes: 15612
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, K; cin >> N >> K;
  vecll FRAC(N+1);
  FRAC[0] = 1;
  RNG(i, 1, N+1) FRAC[i] = (FRAC[i-1]*i)%DVSR;
  ll res = 0;
  REP(i, min(K+1, N)) {
    ll NCI = FRAC[N], N1CI = FRAC[N-1];
    NCI *= mod_inv((FRAC[i]*FRAC[N-i])%DVSR, DVSR);
    NCI %= DVSR;
    N1CI *= mod_inv((FRAC[N-1-i]*FRAC[i])%DVSR, DVSR);
    N1CI %= DVSR;
    res += (NCI*N1CI)%DVSR;
    res %= DVSR;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    if (n%2 != 0) {
      System.out.println(n*2);
    } else {
      System.out.println(n);
    }
  }
}


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

int main(){

  int n,m,l,i,j;

cin >> n >> m >> l;

int matrixA[100][100];
int matrixB[100][100];
long matrixC[100][100];


for(i = 0; i < n; i++){
  for(j = 0; j < l; j++){
  matrixC[i][j] = 0;
  }
}

  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      cin >> matrixA[i][j];
    }
  }
  for(i = 0; i < m; i++){
    for(j = 0; j < l; j++){
      cin >> matrixB[i][j];
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < l; j++){
      for(int k = 0; k < m; k++){
        matrixC[i][j] += matrixA[i][k] * matrixB[k][j];
      }
    }
  }
  for(i = 0; i < n; i++){
    for(j = 0; j < l; j++){
      cout << matrixC[i][j];
      if(j != l-1){
         cout << ' ';
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3228
a,v = map(int,input().split())
 
b,w  = map(int,input().split())
 
t = int(input())
 
d = abs(b-a)
 
if v-w == 0:
    print("NO")

else:
    if (v-w)*t>=d:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef long double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 610;
int id[N][N], cnt, d1, d2, bel[2][N * N], num[2][2], n, rec[N * N];
int uni[N * N], dis[N * N];
int getfa(int pos) {
  if (pos == uni[pos]) return pos;
  int ret = getfa(uni[pos]);
  dis[pos] ^= dis[uni[pos]];
  return uni[pos] = ret;
}
void merge(int x,int y) {
  if (getfa(x) != getfa(y)) {
    int tmp = dis[x] ^ dis[y] ^ 1;
    x = getfa(x), y = getfa(y);
    dis[x] = tmp;
    uni[x] = y;
  }
}
void doit(int d,int *b) {
  rep (i, 1, cnt) uni[i] = i, dis[i] = 0;
  rep (i, 0, n-1) rep (j, 0, n-1) {
    rep (x, 0, n) if (x * x <= d && rec[d - x * x] != -1) {
      int y = rec[d - x * x];
      if (i+x < n && j+y < n) merge(id[i][j], id[i+x][j+y]);
      if (i+x < n && j-y >= 0) merge(id[i][j], id[i+x][j-y]);
      if (i+y < n && j+x < n) merge(id[i][j], id[i+y][j+x]);
      if (i+y < n && j-x >= 0) merge(id[i][j], id[i+y][j-x]);
    }
  }
  rep (i, 1, cnt) {
    getfa(i);
    b[i] = dis[i];
  }
}
int main() {
  read(n);
  read(d1), read(d2);
  n = n * 2;
  rep (i, 0, n-1) rep (j, 0, n-1) id[i][j] = ++ cnt;
  memset(rec, -1, sizeof rec);
  rep (i, 0, n)
    rec[i * i] = i;
  doit(d1, bel[0]);
  doit(d2, bel[1]);
  rep (i, 1, cnt) ++ num[bel[0][i]][bel[1][i]];
  rep (a, 0, 1) rep (b, 0, 1) if (num[a][b] >= n * n / 4) {
    int cur = 0;
    rep (i, 0, n-1) rep (j, 0, n-1) {
      if (bel[0][id[i][j]] == a && bel[1][id[i][j]] == b) {
	if (cur < n * n / 4) printf("%d %d\n", i, j), ++ cur;
      }
    }
    return 0;
  }
  return 0;
}


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

// input
int N;
vector<char> S;


void input() {
    cin >> N;
    S = vector<char>(N);
    rep(i, N) cin >> S[i];
}


int main() {
    input();
    set<char> s;
    rep(i, N) s.insert(S[i]);
    int n = s.size();
    string ans;
    if (n == 3) ans = "Three";
    else ans = "Four";
    cout << ans << endl;
}


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

int main() {
	int n,k=0;
	cin >> n;
	if(n>777777777)
	{
		n=777777777;
	}
	for(int i=357;i<=n;i+=2)
	{
		int a=i,a3=0,a5=0,a7=0;
		while(a>0)
		{
			if(a%10==3)
			{
				a3=1;
			}
			else if(a%10==5)
			{
				a5=1;
			}
			else if(a%10==7)
			{
				a7=1;
			}
			else
			{
				a3=0;
				break;
			}
			a/=10;
		}
		if(a3*a5*a7==1)
		{
			k++;
		}
	}
	cout << k << endl;
	return 0;
}


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

int main(){
    int N,M,X,Y; cin >> N >> M >> X >> Y;
    vector<int> x_(N);
    vector<int> y_(M);
    rep(i,N) cin >> x_[i];
    rep(i,M) cin >> y_[i];
    
    int x_max = -100, y_min = 100;
    rep(i,N){

        x_max = max(x_[i],x_max);
    }
    rep(i,M){

        y_min = min(y_[i],y_min);
    }
    if(x_max < y_min && x_max < Y && y_min > X){
       cout << "No War";
    }
    else{ cout << "War";
    }
}


Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
d = defaultdict(int)
for i in range(n):
    s = input()
    d[s] += 1

print(f'AC x {d["AC"]}')
print(f'WA x {d["WA"]}')
print(f'TLE x {d["TLE"]}')
print(f'RE x {d["RE"]}')


Measured memory_bytes: 9460