akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

string ten_to_two(lint N) {
	//10進数から2進数
	string ans;
	while (1) {
		ans.push_back(char('0' + N % 2));
		N /= 2;
		if (N == 0) {
			break;
		}
	}
	while (1) {
		if (ans.size() == 32) {
			break;
		}
		ans.push_back('0');
	}
	reverse(ans);
	return ans;
}

int main() {
	lint A, B;
	cin >> A >> B;
	cout << ten_to_two(A & B) << endl;
	cout << ten_to_two(A | B) << endl;
	cout << ten_to_two(A ^ B) << endl;
}




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

int main(){
  
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  
  set< string > ss;
  
  for(int i = 0; i < n; i++){
    for(int j = 1; j <= k; j++){
      string tmp = s.substr(i, j);
      ss.insert(tmp);
    }
  }
  
  auto itr = ss.begin();
  for(int i = 0; i < k - 1; i++) itr++;
  cout << *itr << endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,d;
  cin >>n>>m>>d;
  char ma[n][m];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >>ma[i][j];
    }
  }

  int count1=0;
  for(int i=0;i<n;i++){
    int count2=0;
    for(int j=0;j<m;j++){
      if(ma[i][j]!='#'){
        count2++;
        if(count2>=d){
          count1++;
        }
      }else count2=0;
    }
  }
  for(int j=0;j<m;j++){
    int count2=0;
    for(int i=0;i<n;i++){
      if(ma[i][j]!='#'){
        count2++;
        if(count2>=d){
          count1++;
        }
      }else count2=0;
    }
  }
  cout <<count1<<endl;
  return 0;
}

Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {
    private static Scanner sc;

    public Main() {
    }

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

    }

    private void solve() {
        String s = sc.next();
        int cnt = 0;
        for (int i = 0; i < 3; i++) {
            if (s.charAt(i) == '1') {
                cnt++;
            }
        }
        
        System.out.println(cnt);
    }
}


Measured memory_bytes: 23764
sx,sy,tx,ty = map(int,input().split())
print('U'*(ty-sy), end='')
print('R'*(tx-sx), end='')
print('D'*(ty-sy), end='')
print('L'*(tx-sx+1), end='')
print('U'*(ty-sy+1), end='')
print('R'*(tx-sx+1), end='')
print('D',end='')
print('R',end='')
print('D'*(ty-sy+1), end='')
print('L'*(tx-sx+1), end='')
print('U')


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  int N,K;
  long long int A[200002];
  scanf("%d %d",&N,&K);
  for(int i=1;i<=N;i++)
    scanf("%lld",A+i);
  for(int i=1;i<=N-K;i++)
    if(A[i]<A[i+K]){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    char a, b;
    cin >> a >> b;
    if(a == 'H'){
        cout << b << endl;
    }else{
        if(b == 'H'){
            cout << "D" << endl;
        }else{
            cout << "H" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll mx = min({a,b,c,d,e});
    ll ans = (n+mx-1)/mx + 4;
    cout << ans << endl;
    return 0;
}

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


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<int> ans;
    if(n&1){
        rep(i,n){
            if(i&1) ans.push_back(a[i]);
            else ans.insert(ans.begin(), a[i]);
        }
    }else{
        rep(i,n){
            if(i&1) ans.insert(ans.begin(), a[i]);
            else ans.push_back(a[i]);
        }
    }
    for(auto num : ans){
        cout << num << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3828
#include <iostream>
#include <numeric>
#include <string>

using namespace std;

int main()
{
  string S;
  cin >> S;
  int P = accumulate(S.begin(), S.end(), 0, [](int init, char c) { return init + (c == 'p'); });
  cout << (S.size() / 2) - P << endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
const int INF = 1e9;
vector<pair<int,int>> moves = {{-1,0},{1,0},{0,1},{0,-1}};
struct state
{
	int x, y, dir, hops, dist;
	state(int x, int y, int dir, int hops, int dist):x(x),y(y),dir(dir),hops(hops),dist(dist){}
};
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int h, w, k; cin >> h >> w >> k;

	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	--sx, --sy, --tx, --ty;
	auto in_bounds = [h,w](int i, int j){ return 0 <= i && i < h && 0 <= j && j < w; };

	vector<string> grid(h);
	for(int i = 0; i < h; i++)
		cin >> grid[i];

	vector<vector<int>> d[4];
	vector<vector<int>> d_hops[4];
	for(int dir = 0; dir < 4; dir++)
	{
		d[dir] = vector<vector<int>>(h);
		d_hops[dir] = vector<vector<int>>(h);
		for(int i = 0; i < h; i++)
		{
			d[dir][i] = vector<int>(w,INF);
			d_hops[dir][i] = vector<int>(w,INF);
		}
	}

	deque<state> frontier;
	for(int dir = 0; dir < 4; dir++)
		frontier.push_back(state(sx,sy,dir,0,1));

	while(!frontier.empty())
	{
		state u = frontier.front();
		frontier.pop_front();
		if(u.dist < d[u.dir][u.x][u.y] || (u.dist==d[u.dir][u.x][u.y] && u.hops < d_hops[u.dir][u.x][u.y]))
		{
			d[u.dir][u.x][u.y] = u.dist;
			d_hops[u.dir][u.x][u.y] = u.hops;
			for(int t = 0; t < 4; t++)
			{
				int x_ = u.x+moves[t].first, y_ = u.y+moves[t].second;
				if(in_bounds(x_,y_) && grid[x_][y_]!='@')
				{
					bool free_hop = t==u.dir && u.hops < k;
					if(u.dist+(!free_hop) < d[t][x_][y_] || (u.dist+(!free_hop)==d[t][x_][y_] && u.hops+1 < d_hops[t][x_][y_]))
					{
						if(free_hop)
							frontier.push_front(state(x_,y_,t,u.hops+1,u.dist));
						else
							frontier.push_back(state(x_,y_,t,1,u.dist+1));
					}
				}
			}
		}
	}
	int ans = min(min(d[0][tx][ty],d[1][tx][ty]),min(d[2][tx][ty],d[3][tx][ty]));
	cout<<(ans==INF ? -1 : ans)<<endl;
	return 0;
}

Measured memory_bytes: 143796
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i)
#define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME
#define REP(...) GET_MACRO_REP(__VA_ARGS__, REP3, REP2) (__VA_ARGS__)
#define RREP2(i, n) for (int i = (n - 1); i >= 0; --i)
#define RREP3(i, l, r) for (int i = (r - 1), i##_len = (l); i >= i##_len; --i)
#define GET_MACRO_RREP(_1, _2, _3, NAME, ...) NAME
#define RREP(...) GET_MACRO_REP(__VA_ARGS__, RREP3, RREP2) (__VA_ARGS__)
#define IN(type, n) type n; cin >> n
#define INALL(type, v) REP(i, v.size()) { IN(type, _tmp); v.at(i) = _tmp; }
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl
#else
#define DEBUG(x)
#endif

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#pragma endregion

int main() {
  IN(int, N);
  vector<int> P(N);
  INALL(int, P)
  vector<int> Q(N);
  INALL(int, Q)
  vector<int> num;

  REP(i, 1, N + 1) {
    num.push_back(i);
  }

  int count = 0;
  int idx_p = 0;
  int idx_q = 0;
  do {
    bool p_flag = true;
    bool q_flag = true;
    REP(i, N) {
      if (P.at(i) != num.at(i)) p_flag = false;
      if (Q.at(i) != num.at(i)) q_flag = false;
    }
    if (p_flag) idx_p = count;
    if (q_flag) idx_q = count;
    count++;
  } while (next_permutation(ALL(num)));

  cout << abs(idx_p - idx_q) << endl;

  return 0;
}


Measured memory_bytes: 3608
x = int(input())
count = 0
count_2 = 0
while x > 0:
    if (x >= 500):
        x -= 500
        count += 1
    else:
        break

while x > 0:
    if (x >= 5):
        x -= 5
        count_2 += 1
    else:
        break

print(1000 * count + 5 * count_2)

Measured memory_bytes: 3060
#include<stdio.h>

int main() {
   
  int H,W,i,j;

   while (1) {
      scanf("%d%d",&H,&W);
      if (H==0 && W==0) {
         break;
      }
      for (j=0; j<H; j++) {      
         for (i=0; i<W; i++) {
            printf("#");
         }
      printf("\n");
      }
   printf("\n");
   }
   
   return 0;
      
}

Measured memory_bytes: 572
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 501;

int A[N][N];

int main() {
  int H,W;
  S2(H,W);
  int h,w;
  S2(h,w);
  if(H % h == 0 && W % w == 0) {
    printf("No\n");
    return 0;
  }
  LL sm = 0;
  LL x = (1000000000 - 1) / (h * w - 1);
  rep(i,0,H) rep(j,0,W) {
    if(i % h == h - 1 && j % w == w - 1) A[i][j] = -x * h * w + x - 1;
    else A[i][j] = x;
    sm += A[i][j];
  }
  if(sm == 0) {
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  rep(i,0,H) {
    rep(j,0,W) printf("%d ",A[i][j]); printf("\n");
  }
  return 0;
}


Measured memory_bytes: 3840
#include<cstdio>
#include<algorithm>
#define maxn 2000005
using namespace std;
int a[maxn];
int main(void)
{
	int n,t;
	scanf("%d",&n);
	for(int i=0;i<n;++i)
	{
		scanf("%d",&t);
		a[t]++;
	}
	int sum=0;
	for(int i=0;i<maxn;++i)
	{
		if(a[i]==1)
		sum++;
		if(a[i]>0)
		{
			for(int j=i;j<maxn;j+=i)
			{
				a[j]=0;
			}
		}
	}
	printf("%d\n",sum);
	return 0;
}

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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll n,m;
const ll SIZE = 1e5+10;
ll a[SIZE],b[SIZE],c[SIZE];
pair<ll,ll> cb[SIZE];
ll aa[SIZE];

int main(){
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < m; i++){
        cin >> cb[i].second >> cb[i].first;
    }

    //sort(a,a+n,greater<ll>());
    sort(a,a+n);
    sort(cb,cb+m);
/*
    ll n_c = 0;
    for(int i = m-1; i > 0; i--){
        if(n_c < n){
            if(n_c+cb[i].second < n){
                n_c += cb[i].second;
            }
            else{
                cb[i].second = n - n_c;
            }
        }
        else{
            cb[i].second = 0;
        }
    }
*/
    int ind_a = n-1, ind_b = m-1;
    for(int i = 0; i < n; i++){
        aa[i] = max(a[ind_a],cb[ind_b].first);
        if(a[ind_a]>cb[ind_b].first){
            --ind_a;
        }
        else{
            if(cb[ind_b].second > 1)    cb[ind_b].second--;
            else{
                --ind_b;
            }
        }
    }
/*
    int ind = 0;
    for(int i = 0; i < m; i++){
        bool f = false;
        for(int j = 0; j < cb[i].second; j++){
            if(a[ind] < cb[i].first){
                a[ind] = cb[i].first;
                ++ind;
            }
            else{
                if(!f){
                    f = true;
                    ind = 0;
                    if(a[ind] < cb[i].first){
                        a[ind] = cb[i].first;
                        ++ind;
                    }                    
                }
                else{
                    break;
                }
            }
        }
    }
*/
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += aa[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import Counter

N, P = map(int, readline().split())
S = list(map(int, read().rstrip().decode()))

def solve_2(S):
    ind = (i for i, x in enumerate(S, 1) if x % 2 == 0)
    return sum(ind)

def solve_5(S):
    ind = (i for i, x in enumerate(S, 1) if x % 5 == 0)
    return sum(ind)

def solve(S,P):
    if P == 2:
        return solve_2(S)
    if P == 5:
        return solve_5(S)
    S = S[::-1]
    T = [0] * len(S)
    T[0] = S[0] % P
    power = 1
    for i in range(1, len(S)):
        power *= 10
        power %= P
        T[i] = T[i-1] + power * S[i]
        T[i] %= P
    counter = Counter(T)
    return sum(x * (x - 1) // 2 for x in counter.values()) + counter[0]


print(solve(S,P))


Measured memory_bytes: 14888
//20
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<utility>
#include<functional>
#include<numeric>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    typedef pair<int,int> pii;
    int m;
    cin>>m;
    vector<pii> e[100];
    while(m--){
      int a,b,d;
      ((cin>>a).ignore()>>b).ignore()>>d;
      e[a].push_back(make_pair(d,b));
      e[b].push_back(make_pair(d,a));
    }
    priority_queue<pii,vector<pii>,greater<pii> > que;
    que.push(make_pair(0,0));
    vector<int> v(100,-1);
    int r=n;
    while(r--){
      pii p;
      do{
	p=que.top();
	que.pop();
      }while(v[p.second]!=-1);
      v[p.second]=p.first;
      for(int i=0;i<e[p.second].size();i++){
	que.push(make_pair(e[p.second][i].first,e[p.second][i].second));
      }
    }
    cout<<accumulate(v.begin(),v.begin()+n,0)/100-n+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i, 0, n)cin >> a[i] >> b[i];
	if (n % 2) {
		sort(all(a));
		sort(all(b));
		printf("%d\n", b[n/ 2] - a[n / 2] + 1);
	}
	else {
		sort(all(a));
		sort(all(b));
		printf("%d\n", (b[n / 2] + b[n / 2 - 1]) - (a[n / 2] + a[n / 2 - 1]) + 1);
	}
	return 0;
}


Measured memory_bytes: 4768
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll mod=1e9+7;
ll memo[1000005]={0};
ll func(ll n){
  if(n==1) return 0;
  if(memo[n]!=-1) return memo[n];
  if(n%2==0) return memo[n]=func(n/2)+1;
  else return memo[n]=func(n*3+1)+1;
}
int main(){
  for(int i=0;i<1000005;i++) memo[i]=-1;
  while(1){
    ll n;
    cin>>n;
    if(n==0) return 0;
    cout<<func(n)<<endl;
  }
}



Measured memory_bytes: 10824
#include<bits/stdc++.h>
using namespace std;
int main ( )
{
	int n1,n2,m1,m2;
	cin>>n1>>m1>>n2>>m2;
	int k;
	cin>>k;
	int ans=n2*60+m2-n1*60-m1;
	cout<<ans-k;
}


Measured memory_bytes: 3644
# include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const long long linf = 1e18 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;

typedef long long ll;

int ans, g, p;
string s;

int main(){
      cin >> s;

      for(int i = 0; i < s.size(); i ++){
            if(s[i] == 'g') {
                  if(p + 1 <= g) p ++, ans ++;
                  else g ++;
            }
            else {
                  if(p + 1 <= g) p ++;
                  else ans --, g ++;
            }
      }

      cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	vector<string> M(H);
	REP(i, H)cin >> M[i];
	auto dir = make_v<int>(H, W, 4);
	//  1
	//2   3
	//  4
	REP(i, H) {
		int cnt = 0;
		REP(j, W) {
			if (M[i][j] == '#') {
				cnt = 0;
				continue;
			}
			dir[i][j][2] = cnt;
			cnt++;
		}
		cnt = 0;
		REPR(j, W) {
			if (M[i][j] == '#') {
				cnt = 0;
				continue;
			}
			dir[i][j][3] = cnt;
			cnt++;
		}
	}
	REP(j, W) {
		int cnt = 0;
		REP(i, H) {
			if (M[i][j] == '#') {
				cnt = 0;
				continue;
			}
			dir[i][j][1] = cnt;
			cnt++;
		}
		cnt = 0;
		REPR(i, H) {
			if (M[i][j] == '#') {
				cnt = 0;
				continue;
			}
			dir[i][j][0] = cnt;
			cnt++;
		}
	}
	int ans = 0;
	REP(i, H) {
		REP(j, W) {
			if (M[i][j] == '#')continue;
			chmax(ans, dir[i][j][0] + dir[i][j][1] + dir[i][j][2] + dir[i][j][3] + 1);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 223488
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
bool dfs(vector< vector< int > > &G, vector< bool > &done, int x, stack< int > &s) {
	done[x] = true;
	s.push(x);
	bool f = false;
	rep(i, G[x].size()) {
		int j = G[x][i];
		if (!done[j]) {
			if (dfs(G, done, j, s)) {
				return true;
			}
			f = true;
		}
	}
	if (!f)
		return true;
	s.pop();
	return false;
}
signed main() {
	cin >> N >> M;
	vector< vector< int > > G(N);
	rep(i, M) {
		int A, B;
		cin >> A >> B;
		--A;
		--B;
		G[A].push_back(B);
		G[B].push_back(A);
	}
	vector< bool > done(N, false);
	stack< int > s1, s2;
	dfs(G, done, 0, s1);
	dfs(G, done, 0, s2);
	vector< int > A, B;
	while (!s1.empty()) {
		A.push_back(s1.top());
		s1.pop();
	}
	while (!s2.empty()) {
		B.push_back(s2.top());
		s2.pop();
	}
	reverse(B.begin(), B.end());
	B.erase(B.begin());
	A.insert(A.end(), B.begin(), B.end());
	cout << A.size() << endl;
	rep(i, A.size()) {
		cout << A[i] + 1 << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 13688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define bg(a) a.begin()
#define en(a) a.end()
#define all(a) bg(a), en(a)
using namespace std;
using vi = vector<int>;
using vv = vector<vi>;

int main(void){
    vi a(3);
    rep(i,3)cin>>a[i];
    sort(all(a));
    
    cout << a[2]-a[0] << endl;
    
    return 0;
}

Measured memory_bytes: 3636
R,G,B,N = (int(x) for x in input().split())
maxr = N // R
maxg = N // G
count = 0
for i in range(maxr+1):
    for j in range(maxg+1):
        checker = N - (i*R + j*G)
        if checker // B >= 0:
            if checker % B == 0:
                count += 1
        elif checker == 0:
            count += 1
print(count)

Measured memory_bytes: 40812
n, q = list(map(int, input().split()))
a = [[] for i in range(n)]
for _ in range(q):
  q = list(map(int, input().split()))
  if q[0]==0:
    a[q[1]].append(q[2])
  elif q[0]==1:
    if len(a[q[1]])>0:
      print(a[q[1]][-1])
  elif q[0]==2:
    if len(a[q[1]])>0:
      a[q[1]].pop()


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,r;
	cin>>n>>r;
	if(n>=10){
		cout <<r;
	}
	else{
		cout << r+100*(10-n);
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	set<int> s;
	ll sum = 0;
	for(int i = 1; i <= n; i++){
		s.insert(i);
		sum += i;
		
		if(sum >= n) break;
	}
	s.erase(sum - n);
	
	for(int i : s) cout << i << endl;
	
	return 0;
}

Measured memory_bytes: 512
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))

good=[1]*N

for _ in range(M):
    a,b=list(map(int,input().split()))

    a-=1
    b-=1

    if H[a]>H[b]:
        good[b]=0
    elif H[b]>H[a]:
        good[a]=0
    else:
        good[a]=0
        good[b]=0

print(sum(good))

Measured memory_bytes: 20108
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
void input(){
    fast_io();
    cin >> N;
}

string hon(int n){
    int k = n%10;
    string ret;
    vector<int> hon={2,4,5,7,9};
    vector<int> pon={0,1,6,8};
    vector<int> bon={3};
    for(int x:hon) if(x==k) ret = "hon";
    for(int x:pon) if(x==k) ret = "pon";
    for(int x:bon) if(x==k) ret = "bon";
    return ret;
}

int solve(){
    cout << hon(N) << endl;
    return 0;
}   

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

Measured memory_bytes: 3652
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, *ABC = map(int, read().split())
    G = [[INF] * N for _ in range(N)]
    edge = [0] * M
    for i, (a, b, c) in enumerate(zip(*[iter(ABC)] * 3)):
        edge[i] = (a - 1, b - 1, c)
        G[a - 1][b - 1] = G[b - 1][a - 1] = c
    for i in range(N):
        G[i][i] = 0

    for k in range(N):
        for i in range(N):
            for j in range(N):
                if G[i][j] > G[i][k] + G[k][j]:
                    G[i][j] = G[i][k] + G[k][j]

    ans = 0
    for a, b, c in edge:
        used = False
        for i in range(N):
            if G[i][b] == G[i][a] + c or G[i][a] == G[i][b] + c:
                used = True
                break
        if not used:
            ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9424
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int a, b, k;
	cin >> a >> b >> k;

	int ans = 0, mi = min(a, b);
	for (int i = mi; i >= 1; i--) {
		if (a % i != 0 || b % i != 0) {
			continue;
		}

		ans = i;
		k--;
		if (k == 0) {
			break;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
sa=set(a)
nums=len(sa)
if nums<=k:
    print(0)
else:
    num=[0]*n
    for i in range(n):
        num[a[i]-1]+=1
    num.sort()
    ans=0
    for i in range(n-k):
        ans+=num[i]
    print(ans)


Measured memory_bytes: 32388
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

int main() {
  ll N, K;
  cin >> N >> K;
  string lst;
  cin >> lst;

  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0;
  if (lst[0] == 'R' && lst[1] == 'R') ans++;
  for (int i = 1; i < N - 1; i++) {
    if (lst[i] == 'L') {
      if (lst[i - 1] == 'L') ans++;
    } else {
      if (lst[i + 1] == 'R') ans++;
    }
  }
  if (lst[N - 1] == 'L' && lst[N - 2] == 'L') ans++;

  ll bnd = 0;
  for (int i = 0; i < N - 1; i++) {
    if (lst[i] != lst[i + 1]) bnd++;
  }

  if((bnd+1)/2 <= K){
    ans += 2 * ((bnd+1) / 2);
    if (bnd % 2 == 1) ans--;
  } else {
    ans += 2 * K;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

class UnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.length = [1 for _ in range(n)] 

    def makeSet(self, n):
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.length = [1 for _ in range(n)]

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parents[x] = y
            self.length[y] += self.length[x]
        else:
            self.parents[y] = x
            self.length[x] += self.length[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def getLength(self, x):
        x = self.find(x)
        return self.length[x]        

    def isSameGroup(self, x, y):
        return self.find(x) == self.find(y)
 
def main():
    N, M, K = map(int, readline().split())
    friend = [set() for _ in range(N)]
    block = [set() for _ in range(N)]
    uf = UnionFind(N)
    for _ in range(M):
        a, b = map(int, readline().split())
        a-=1
        b-=1
        friend[a].add(b)
        friend[b].add(a)
        uf.unite(a, b)

    for _ in range(K):
        c, d = map(int, readline().split())
        c-=1
        d-=1
        block[c].add(d)
        block[d].add(c)

    for i in range(N):
        cnt = 0
        for blk in block[i]:
            if uf.isSameGroup(i, blk):
                cnt += 1    
        ans = uf.getLength(i)-cnt-len(friend[i])-1
        if i == N-1:
            print(ans)
        else:
            print(ans, end=" ")
if __name__ == '__main__': 
    main()

Measured memory_bytes: 79172
/* no! stack */
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b; top=0; char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop(); b=pop(); push(b+a);
    }
    else if(s[0]=='-'){
      a=pop(); b=pop(); push(b-a);
    }
    else if(s[0]=='*'){
      a=pop(); b=pop(); push(a*b);
    }
    else push(atoi(s));
  }

  printf("%d\n",pop());

  return 0;
}


Measured memory_bytes: 2052
#include <math.h>

#include <algorithm>
#include <cassert>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int N = 5;
  vector<int> H(N);

  rep(i, N) { cin >> H.at(i); }

  rep(i, N) {
    if (H[i] == 0) cout << i + 1 << endl;
  }
}


Measured memory_bytes: 3624
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    ll a,b;
    long double x;
    cin>>a>>x;
    x=x*a;
    b=floor(x);
    cout<<b;
//    int n;
//    cin>>n;
//    ll a[N];
//    rep(i,1,n) cin>>a[i];
//    sort(a+1,a+n+1);
//    ll prod=1;
//    rep(i,1,n){
//        if(prod==0) break;
//        if(a[i]>1e18/prod) return cout<<-1,0;
//        prod=prod*a[i];
//    }
//    cout<<prod;
    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

double fact( double n)
{
    if (n<=1) {return 1;}
    else {return n*fact(n-1);}
}

int main() {
    double l,m,n,i,sum=0,p,q,r,j; vector<double>a,x,y; cin>>n;
    for(i=0;i<n;i++)
    { cin>>l>>m; x.pb(l); y.pb(m); a.pb(i);}
    l=fact(n);
    for(j=0;j<l;j++)
    {
        for(i=0;i<n-1;i++)
        { p=a[i];q=a[i+1];
            r=(x[p]-x[q])*(x[p]-x[q])+(y[p]-y[q])*(y[p]-y[q]);
            sum+=sqrt(r);
        }
        next_permutation(a.begin(),a.end());
    }
    cout<<fixed<<setprecision(10)<<(sum/l);
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    puts((s[2] == s[3] && s[4] == s[5] ? "Yes" : "No"));
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int bubbleSort(int *a, int n);
int main(int argc, char** argv) {
    int number;
    int readScan = scanf("%d", &number);
    int array[number];
    for(int i = 0; i< number; i++)
    {
        int reasScan = scanf("%d", &array[i]);
    }
    int count;
    count = bubbleSort(array, number);
    for(int i= 0; i< number; i++)
    {    
        if(i<number-1)
        {
            printf("%d ", array[i]);
        }
        if(i==number-1)
        {
               printf("%d", array[i]);
        }
    }
    printf("\n");
   
    printf("%d\n", count);
    return (EXIT_SUCCESS);
}

int bubbleSort(int *a, int n)
{
    int b;
    int count = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n-i-1; j++)
		{
			if (a[j]>a[j+1])
			{
                            b = a[j];
                            a[j] = a[j+1];
                            a[j+1] =b;
                            count++;
			}
                      
		}
	}
    return count;
}





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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    int a[26];
    fill(a, a + 26, inf);
    rep(i, 0, n)
    {
        string s;
        cin >> s;
        int cnt[26];
        fill(cnt, cnt + 26, 0);
        for (char c : s)
            cnt[c - 'a']++;
        rep(i, 0, 26)
            a[i] = min(a[i], cnt[i]);
    }
    rep(i, 0, 26)
        rep(j, 0, a[i])
            cout << (char)('a' + i);
    cout << endl;
    return 0;
}


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

using namespace std;
#define rep(i, j) for(int i = 0; i < (j); i++)

int main() {
    while(true) {
        int N, M, P; cin >> N >> M >> P;
        if(N == 0) break;
        vector<int> X(N); rep(i, N) cin >> X[i];
        double sum = 0;
        rep(i, N) sum += X[i] * 100;
        double sub = sum * P / 100.0;
        sum -= sub;
        cout << (X[M - 1] == 0 ? 0 : int(sum / X[M - 1])) << endl;
    }
}

Measured memory_bytes: 3056
package main

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

func main() {
	s := IOInitialize()
	A := Int(s)
	B := Int(s)
	cnt := 0
	for i := A; i < B+1; i++ {
		str := strconv.Itoa(i)
		strs := strings.Split(str, "")
		isBatch := true
		l := len(strs) / 2
		for j := 0; j < l; j++ {
			if strs[j] != strs[len(strs)-1-j] {
				isBatch = false
				break
			}
		}
		if isBatch {
			cnt++
		}
	}
	fmt.Println(cnt)
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}


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

//union-find
//グループ分けを木構造で管理する

//強み(高速)
//・xとyが同じグループかを判定する
//・xとyが同じグループでない場合にこの2グループを併合する

//小さい方を大きい方にくっつける(長さの情報が必要)
//経路縮約

struct UnionFind{
    vector<int> d;
    UnionFind(int n=0): d(n, -1) {}
    int root(int x){
        if(d[x]<0)return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y){
        x = root(x); y = root(y);
        if(x==y) return false;
        if(d[x]>d[y]) swap(x,y);
        d[x] += d[y]; d[y] = x;
        return true;
    }
    bool same(int x, int y){return root(x) == root(y);}
    int size(int x){return -d[root(x)];}
};

int main(){
    int n,m;cin>>n>>m;//n人m関係
    UnionFind uf(n);
    
    rep(i,m){
        int a,b;
        cin>>a>>b;
        --a; --b;
        uf.unite(a,b);
    }
    int ans = 0;
    rep(i,n){
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n;
	string s;
	cin>>n>>s;
	if(n%2) cout<<"No";
	else{
		int len = n/2;
		if(s.substr(0,len).compare(s.substr(len,len))==0) 
			cout<<"Yes";
		else cout<<"No";
	}
}

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

#define pb push_back

int main()
{
	int N, M;
	while (cin >> N >> M, N||M)
	{
		vector<int> in;
		in.pb(0);
		for (int i=0; i<N; i++)
		{
			int t;
			cin >> t;
			in.pb(t);
		}

		vector<int> in2;
		for (int i=0; i<=N; i++)
		for (int k=0; k<=N; k++)
		{
			in2.pb(in[i]+in[k]);
		}
		sort(in2.begin(), in2.end());
		in2.erase(unique(in2.begin(), in2.end()), in2.end());

		int ans = 0;
		for (int i=0; i<in2.size(); i++)
		{
			if (in2[i] > M) break;

			vector<int>::iterator it = upper_bound(in2.begin(), in2.end(), M-in2[i]);
			if(it != in2.begin()) {it--;}
			
			ans = max(ans, in2[i] + *it);
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 4964
def c1(S):
    N=len(S)
    if S == S[::-1]:
        return True
    else:
        return False

S=input()
N=len(S)
SS=S[:(N-1)//2]
SSS=S[(N+3)//2-1:]
if SS==SSS and c1(SS):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
H, W, N = map(int, input().split())
Sr, Sc = map(int, input().split())
S = input()
T = input()


l = 1
r = W
u = 1
d = H
#print(l, r, u, d,)
for s, t in zip(S[::-1], T[::-1]):

    if t=="L":
        r = min(r+1, W)
    elif t=="R":
        l = max(l-1, 1)
    elif t=="U":
        d = min(d+1, H)
    else:
        u = max(u-1, 1)

    #print(d)
    if s=="L":
        l+=1
    elif s=="R":
        r-=1
    elif s=="U":
        u+=1
    else:
        d-=1

    if l > r or u > d:
        print("NO")
        exit()
    #print(l, r, u, d, " st", s, t)
if u<=Sr<=d and l<=Sc<=r:
    print("YES")
else:
    print("NO")


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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> abc(N+1, vector<int>(3));
    rep(i, N) rep(j, 3) cin >> abc[i+1][j];

    vector<vector<int>> dp(N+1, vector<int>(3, 0));
    rep(i, N) rep(j, 3) rep(k, 3) {
        if(j != k) {
            dp[i+1][k] = max(dp[i+1][k], dp[i][j]+abc[i+1][k]);
        }
    }

    int res = -1;
    rep(i, 3) {
        res = max(res, dp[N][i]);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11136
#include<cstdio>

int r, g, b, n;

int main() {
	scanf("%d%d%d%d", &r, &g, &b, &n);
	int ans=0;
	for(int i=0;i*r<=n;i++)
		for(int j=0;i*r+j*g<=n;j++) {
			int rem = n-i*r-j*g;
			if(rem%b==0) ans++;
		}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll z, w, n;
    cin >> n >> z >> w;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    ll dp[n+1][2];
    for(int i = n-1; i >= 0; --i){
        if(i == 0)dp[i][0] = abs(w-a.back());
        else dp[i][0] = abs(a[i-1]-a.back());
        for(int j = i+1; j < n; ++j)dp[i][0]=max(dp[i][0], dp[j][1]);
 
        if(i == 0)dp[i][1] = abs(z-a.back());
        else dp[i][1] = abs(a[i-1]-a.back());
        for(int j = i+1; j < n; ++j)dp[i][1]=min(dp[i][1], dp[j][0]);
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int a,b;

//解法
void solve() {

	int ans = 0;
	rep(i, b - a) {
		ans += i;
	}
	cout << ans - a;

	return;
}

int main() {
	//入力
	cin >> a >> b;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
def resolve():
    a, b, c, d = map(int, input().split())
    takahashiturn = True
    while a > 0 and c > 0:
        if takahashiturn:
            c -= b
            takahashiturn = False
        else:
            a -= d
            takahashiturn = True
    print("Yes" if c <= 0 else "No")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9204
x0, y0, x1, y1 = map(int, input().split())
q = int(input())

p0, p1 = complex(x0, y0), complex(x1, y1)
p0p1 = p1 - p0

while q:
    q -= 1
    p2 = complex(*map(int, input().split()))
    p0p2 = p2 - p0
    prod_cross = p0p1.real * p0p2.imag - p0p1.imag * p0p2.real
    if abs(prod_cross) < 1e-6:
        if p0p1.real * p0p2.real >= 0 and p0p1.imag * p0p2.imag >= 0:
            print('ONLINE_FRONT' if abs(p0p1) < abs(p0p2) else 'ON_SEGMENT')
        else:
            print('ONLINE_BACK')
    else:
        print('COUNTER_CLOCKWISE' if prod_cross > 0 else 'CLOCKWISE')

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

int main () {
  char b;
  cin >> b;
  
  if (b == 'A') {
    b = 'T';
  }
  else if (b == 'T') {
    b = 'A';
  }
  else if (b == 'C') {
    b = 'G';
  }
  else if (b == 'G') {
    b = 'C';  
  }
  cout << b << endl;
}

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

using namespace std;

long long x_p[100010];

long long x_m[100010];

long long x_m_sw[100010];

int x_p_size = 0;
int x_m_size = 0;

long long calc(int p, int m)
{
	p--;
	m--;

	if (x_p_size <= p)
	{
		return LLONG_MAX;
	}
	if (x_m_size <= m)
	{
		return LLONG_MAX;
	}

	if (p == -1) return x_m[m];
	if (m == -1) return x_p[p];

	if (x_p[p] > x_m[m])
	{
		return x_m[m] * 2 + x_p[p];
	}
	else
	{
		return x_m[m] + x_p[p] * 2;
	}
}

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

	int w;
	for (int i = 0; i < N; i++)
	{
		cin >> w;
		if (w < 0)
		{
			x_m_sw[x_m_size] = w;
			x_m_size++;
		}
		else
		{
			x_p[x_p_size] = w;
			x_p_size++;
		}
	}

	for (int i = x_m_size - 1; i >= 0; i--)
	{
		x_m[x_m_size - i - 1] = - x_m_sw[i];
	}

	long long min_w = LLONG_MAX;

	for (int i = 0; i <= K; i++)
	{
		min_w = min(min_w, calc(i, K - i));
	}

	cout << min_w << endl;

	return 0;
}

Measured memory_bytes: 1792