akhauriyash/Code-Regression huggingface dataset:
/**
*    created: 09.07.2020 01:27:41
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int w, a, b;
    cin >> w >> a >> b;
    if (abs(a-b) <= w) cout << 0 << endl;
    else cout << min(abs(b-a-w),abs(a-b-w)) << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string str;
  int k;
  cin >> str >> k;
  int n = str.length();
  vector<vector<vector<ll> > > dp(n+5, vector<vector<ll> >(2, vector<ll>(k+5,0)));
  dp[0][0][0] = 1;
  rep(i,n) {
    rep(j,k+1) { //0以外の個数
      dp[i+1][1][j+1] += dp[i][1][j]*9; //0以外
      dp[i+1][1][j] += dp[i][1][j]; //0

      int x = str[i]-'0';
      if (x > 0) {
       dp[i+1][1][j+1] += dp[i][0][j]*(x-1); //0以外
       dp[i+1][1][j] += dp[i][0][j]; //0
      }

      if (x == 0) dp[i+1][0][j] += dp[i][0][j]; //0をつける
      else dp[i+1][0][j+1] += dp[i][0][j]; //0以外がつく
    }
  }
  cout << dp[n][1][k] + dp[n][0][k] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n, a[3];
	scanf("%d",&n);
	for(int i=0;i<3;i++){
		a[i]=n%10;
		n/=10;
		if(a[i]==7){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
} 

Measured memory_bytes: 3688
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll N;
    cin>>N;
    v a(N+1);
    rep(i,1,N+1)cin>>a[i];

    v ans(N+1);
    for(int i=N;i>0; i--){
        ll sum = a[i], now = 2;
        while(now * i <= N){
            sum += ans[now*i];
            now++;
        }
        sum %= 2;
        ans[i] = sum;
    }
    ll sum = 0;
    rep(i,1,N+1)sum += ans[i];

    cout<<sum<<endl;
    rep(i,1,N+1)if(ans[i])cout<<i<<" ";
    return 0;
}

Measured memory_bytes: 3968
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define M 100000007
void addSelf(ll &a,ll b)
{
    a+=b;
    while(a>=M)a-=M;
}
 
void subSelf(ll &a,ll b)
{
    a-=b;
    while(a<0)a+=M;
}

void solve()
{
    int n,m,q;
    cin >> n >> m >> q;
    int k = q;
    map<int,int> mp1,mp2;
    map<pair<int,int>,int> mp;
    int row[n]={};
    int col[m]={};
    while(q--){
        int x,y;
        cin >> x >> y;
        x--;y--;
        row[x]++;
        col[y]++;
        mp[{x,y}]++;
    }

    int mxx=0,mxy=0;
    for(int i=0;i<n;i++) mxx = max(mxx,row[i]);
    for(int i=0;i<m;i++) mxy = max(mxy,col[i]);

    vector<int> r,c;
    int ans = mxx+mxy;
    for(int i=0;i<n;i++){
        if(mxx==row[i]) r.push_back(i);
    }
    for(int i=0;i<m;i++){
        if(mxy==col[i]) c.push_back(i);
    }
    
    bool flag = true;
    for(int i=0;i<r.size();i++){
        for(int j=0;j<c.size();j++){
            if(!mp[{r[i],c[j]}]){
                flag = false;
            }
            if(!flag) break;
        }
        if(!flag) break;
    }
    if(flag){
        ans--;
    }
    cout << ans << endl;

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

   /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif */

    clock_t start, end; 
    start = clock(); 
  
    solve(); 
  
    end = clock(); 
  
    /* double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    cout << "Time taken by program is : " << fixed  
         << time_taken << setprecision(5); 
    cout << " sec " << endl;  */
}



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

int main() {
  int N,K;
  cin>>N>>K;
  int Z=N+1-K,A=-1;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  deque<int> MIN;
  deque<int> MAX;
  for(int i=0;i<N;i++){
    while(!MIN.empty()){
      if(p[MIN.back()]<p[i]){
        break;
      }
      MIN.pop_back();
    }
    MIN.push_back(i);
    while(!MAX.empty()){
      if(p[MAX.back()]>p[i]){
        break;
      }
      MAX.pop_back();
    }
    MAX.push_back(i);
    if(i>=K){
      if(MIN.size()==K+1){
        Z++;
      }
      if(MIN.front()==i-K&&MAX.front()==i){
        Z--;
      }
      if(MIN.front()==i-K){
        MIN.pop_front();
      }
      if(MAX.front()==i-K){
        MAX.pop_front();
      }
    }
    if(i>=K-1){
      if(MIN.size()==K){
        A++;
      }
    }
  }
  cout<<Z-max(0,A)<<endl;
}

Measured memory_bytes: 4680
N = int(input())
A = dict()

for i in range(N):
    a = int(input())
    if a in A.keys():
        A[a] += 1
    else:
        A[a] = 1

ans = 0

for i in A.keys():
    if A[i] % 2 == 1:
        ans += 1

print(ans)

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

int digitSum(int x) {
  int s = 0;
  while (0 < x) {
    s += x % 10;
    x /= 10;
  }
  return s;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int x = digitSum(i);
    if (A <= x && x <= B) ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b,c,d,sqr1,sqr2;
cin >> a >>  b >> c >> d;
sqr1 = a * b;
sqr2 = c * d;
if(sqr1 > sqr2){
cout << sqr1 << endl;
}
else{
cout << sqr2 << endl;
}
return 0;
}
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
int main()
{
    nfs;
    ll n,k;
    cin >> n >> k ;
    ll arr[n];
    ll i;
    for(i=0;i<n;i++)
    {

        cin >> arr[i] ;
    }
    ll j;
    ll inv = 0;
    for(i=0;i<n;i++)
    {

        for(j=i+1;j<n;j++)
        {

            if(arr[i]>arr[j])
            {

                inv++;

            }
        }
    }
    if(inv==0)
    {

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

        cout << inv << endl;
        return 0;
    }
    ll lol = 0;
    for(i=0;i<n;i++)
    {

        for(j=0;j<n;j++)
        {

            if(arr[i]>arr[j])
            {

                lol++;
            }
        }
    }
    ll ans = 0;
    ll bige = k*(k-1);
    bige /= 2;
    ll modo = 1000000007;
    bige %= modo;
    ans = lol * bige;
    ans %= modo;
    ans += ((k*(inv))%modo);
    ans %= modo ;
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
#include <iostream>


int main(){
	int number;
	std::cin >> number;
	int* array;
	array = new int[number];
	for(int i=0;i<number;i++){
		std::cin >> array[i];
		}
	for(int j=number-1; j>=0; j--){
		std::cout << array[j];
		if( j != 0){
			std::cout << " ";
		}
	}
std::cout << std::endl;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cmath>

using namespace std;

int limit=0,T[3][3];

int evaluate(){
  int cx[]={2,0,1,2,0,1,2,0,1},cy[]={2,0,0,0,1,1,1,2,2};
  int ret=0;
  for (int i=0;i<3;i++){
    for (int j=0;j<3;j++){
      int ti = T[i][j];
      if (ti==0)continue;
      ret+=abs(cx[ti]-j);
      ret+=abs(cy[ti]-i);
      // if (cx[ti]!=j||cy[ti]!=i)ret++;
    }
  }
  return ret;
}

bool trymove(int c,int zx,int zy,int pzx,int pzy){
  int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
  if (evaluate()==0)return true;
  if (c+evaluate()>limit)return false;
  for (int i=0;i<4;i++){
    if (0>zx+dx[i]||zx+dx[i]>2||0>zy+dy[i]||zy+dy[i]>2)continue;
    if (zx+dx[i]==pzx&&zy+dy[i]==pzy)continue;
    swap(T[zy][zx],T[zy+dy[i]][zx+dx[i]]);
    if (trymove(c+1,zx+dx[i],zy+dy[i],zx,zy)) return true;
    swap(T[zy][zx],T[zy+dy[i]][zx+dx[i]]);
  }
  return false;
}

int main(){
  int zx,zy;
  for (int i=0;i<3;i++){
    for (int j=0;j<3;j++){
      cin >> T[i][j];
      if (T[i][j]==0){
	zx=j;
	zy=i;
      }
    }
  }
  
  while (evaluate()){
    limit++;
    if (trymove(0,zx,zy,zx,zy))break;
  }
  
  cout << limit << endl;
  
  return 0;
}

Measured memory_bytes: 3084
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;
int main() {
  int n;
  cin >> n;
  auto p = vector<int>(n);
  auto q = vector<int>(n);
  for (auto &pi : p)
    cin >> pi;
  for (auto &qi : q)
    cin >> qi;

  for (int i = 0; i < n; ++i) {
    if (p[i] < q[i])
      break;
    if (p[i] > q[i]) {
      swap(p, q);
      break;
    }
  }

  int count = 0;
  while (p != q) {
    std::next_permutation(p.begin(), p.end());
    count++;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fio() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
#define MOD 998244353
using namespace std;
int32_t main()
{
	fio();
	int n;
	cin>>n;
	string s;
	cin>>s;
	int a[7]={0};
    //  0: no color, 1: R, 2: B, 3: G, 4: RB, 5: GB, 6: RG
	memset(a,0,sizeof(a));
	a[0]=n;
	int ans=1;

	for(int i=0;i<3*n;i++)
	{
		if(s[i]=='R')
		{
			if(a[5]>0)
			{
				ans*=a[5];
				ans%=MOD;
				a[5]--;
			}
			else if(a[2]>0)
			{
				ans*=a[2];
				ans%=MOD;
				a[2]--;
				a[4]++;
			}
			else if(a[3]>0)
			{
				ans*=a[3];
				ans%=MOD;
				a[3]--;
				a[6]++;
			}
			else
			{
				ans*=a[0];
				ans%=MOD;
				a[0]--;
				a[1]++;
				//cout<<ans<<endl;
			}
		}
		else if(s[i]=='B')
		{
			if(a[6]>0)
			{
				ans*=a[6];
				ans%=MOD;
				a[6]--;
			}
			else if(a[1]>0)
			{
				ans*=a[1];
				ans%=MOD;
				a[1]--;
				a[4]++;
			}
			else if(a[3]>0)
			{
				ans*=a[3];
				ans%=MOD;
				a[3]--;
				a[5]++;
			}
			else
			{
				ans*=a[0];
				ans%=MOD;
				a[0]--;
				a[2]++;
			}
		}
		else
		{
			if(a[4]>0)
			{
				ans*=a[4];
				ans%=MOD;
				a[4]--;
			}
			else if(a[1]>0)
			{
				ans*=a[1];
				ans%=MOD;
				a[1]--;
				a[6]++;
			}
			else if(a[2]>0)
			{
				ans*=a[2];
				ans%=MOD;
				a[2]--;
				a[5]++;
			}
			else
			{
				ans*=a[0];
				ans%=MOD;
				a[0]--;
				a[3]++;
			}
		}
		//cout<<ans<<endl;
	}

	cout<<ans;
}


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  if((a==b || b==c || a==c) && !(a==b&&b==c&&c==a)){
    cout << "Yes" <<endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    char img[h+10][w+10];
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> img[i][j];
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cout << img[i][j];
        }
        cout << endl;
        for(int j=1;j<=w;j++){
            cout << img[i][j];
        }
        cout << endl;
    }
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}
typedef pair<ll, ll> pll;

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	vector<vector<pii>> r(n);
	rep(i, m){
		int a, b; cin >>a >>b;
		r[a-1].emplace_back(b-1, i);
		r[b-1].emplace_back(a-1, i);
	}

	VI vis(n);
	auto rec=[&](auto rec, int s, int pth)->void{
		vis[s] = 1;
		for(auto v: r[s]){
			if(vis[v.first]==1 || v.second ==pth) continue;
			rec(rec, v.first, pth);
		}
	};
	int ans = 0;
	rep(i, m){
		fill(all(vis), 0);
		rec(rec, 0, i);
		if(count(all(vis), 1) != n) ans++;
	}
	
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner; 
 public class Main {
   public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
       
    int h ;
    int w ;
       while(true){
           
            h = sc.nextInt();
            w = sc.nextInt();
           
           if(h==0&&w==0)break;
       for(int i=0;i<h;i++){
         for(int j=0;j<w;j++){
           System.out.print("#");
         }
           System.out.println(); 
       }
           System.out.println();
       }
   }
 }


Measured memory_bytes: 34312
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int n,a,b;
int main(){
	scanf("%d%d%d",&n,&a,&b);
	if((b-a)%2==1) printf("Borys\n");
    else printf("Alice\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[100005];
char b[100005];
int main()
{
    scanf("%s",a);
    int len=strlen(a);
    //printf("%c\n",a[0]);
    int flag;
    while(len)
    {
        //printf("%d\n",len);
        flag=1;
        len-=2;
        if(len%2==1)
            continue;
        else
        {
            int l=len/2;
            for(int i=0;i<l;i++)
            {
                //printf("%c\n",a[i]);
                if(a[i]==a[i+l])
                    continue;
                else
                {
                    flag=0;
                }
            }
        }
        if(flag)
            break;
    }
    printf("%d\n",len);
}


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

int main()
{
  long long int input;
  long long int i,j;
  scanf("%lld",&input);
  
  long long int minimum = 10000000000000;
  long long int i_min=0;
  long long int j_min=0;
  for(i=1;i<=sqrt(input);i++){
    if( (input%i)==0 ){
      j = input/i;
      //printf("%lld %lld\n",i,j);
      if( (i+j)<minimum ){
        
        minimum = i+j;
        i_min = i;
        j_min = j;
        //printf("%lld %lld %lld\n",i_min,j_min,minimum);
        
      }
    }
    else{
      continue; 
    }
  }

  
 
  
  printf("%lld\n",i_min+j_min-2);
             
  
  
  return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main()
{
    int n;
    cin >> n;
    int vals[n];
    for (int i = 0; i < n; i++)
    {
        cin >> vals[i];
    }
    int dp[n];
    dp[0]=0;
    dp[1]=vals[1]-vals[0];
    if (dp[1]<0)
    {
        dp[1]*=-1;
    }
    for (int i = 2; i < n; i++)
    {
        int q = vals[i]-vals[i-2];
        if (q<0)
        {
            q *= -1;
        }
        int w = vals[i]-vals[i-1];
        if (w < 0)
        {
            w *= -1;
        }
        dp[i]=min(dp[i-2]+q, dp[i-1]+w);
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """Sunny"""
        output = """Cloudy"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """Rainy"""
        output = """Sunny"""
        self.assertIO(input, output)

def resolve():
    dic={'Sunny':'Cloudy',"Cloudy":'Rainy','Rainy':'Sunny'}
    print(dic[input()])
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 51824
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int dy[] = {-1, 0, 0, 1};
const int dx[] = {0, -1, 1, 0};
int w, h;
string s[20];
int sy, sx;

void dfs(int y, int x) {
    s[y][x] = '@';
    REP (i, 4) {
        int ny = y + dy[i];
        int nx = x + dx[i];
        if (ny >= 0 && ny < h && nx >= 0 && nx < w && s[ny][nx] == '.') {
            dfs(ny, nx);
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    while (cin >> w >> h, w) {
        REP (i, h) {
            cin >> s[i];
            REP (j, w) {
                if (s[i][j] == '@') sy = i, sx = j;
            }
        }
        dfs(sy, sx);
        int ans = 0;
        REP (i, h) REP (j, w) ans += (s[i][j] == '@');
        cout << ans << endl;
    }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int n, m;
  cin >> n >> m;

  int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 3604
N, M = map(int, input().split())
R = []
for i in range(M):
    R.append(list(map(int, input().split())))
ans = []

for country in range(1,N+1):
    count = 0
    for road in R:
        if country in road:
            count += 1
    ans.append(count)

for j in ans:
    print(j)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, S):
    ans = 0
    ph = [[0] * W for _ in range(H)]
    for i in range(H):
        tmp = []
        for j in range(W):
            if S[i][j] == '.':
                tmp.append(j)
            else:
                p = len(tmp)
                for t in tmp:
                    ph[i][t] = p
                tmp = []
        if tmp:
            p = len(tmp)
            for t in tmp:
                ph[i][t] = p
            tmp = []

    pv = [[0] * W for _ in range(H)]
    for i in range(W):
        tmp = []
        for j in range(H):
            if S[j][i] == '.':
                tmp.append(j)
            else:
                p = len(tmp)
                for t in tmp:
                    pv[t][i] = p
                tmp = []
        if tmp:
            p = len(tmp)
            for t in tmp:
                pv[t][i] = p
            tmp = []

    ans = 0
    for i in range(H):
        for j in range(W):
            ans = max(ans, ph[i][j] + pv[i][j])

    return ans - 1


def main():
    H, W = read_int_n()
    S = [read_str() for _ in range(H)]
    print(slv(H, W, S))

    # H = 2000
    # W = 2000
    # S = [random.choices('.#', k=W) for _ in range(H)]
    # print(slv(H, W, S))


if __name__ == '__main__':
    main()


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

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

    string S;
    cin >> S;

    int used[26] = {};
    if (S.length() < 26) {
        for (char s : S) {
            used[(int) s - 97] = 1;
        }
        for (int i = 0; i <= 25; ++i) {
            if (used[i] == 0) {
                S += char (i + 97);
                cout << S << '\n';
                return 0;
            }
        }
    } else {
        for (int i = 25; i >= 0; --i) {
            int num = S[i] - 97;
            S.pop_back();
            for (int j = num + 1; j <= 25; ++j) {
                if (used[j] == 1) {
                    S += char (j + 97);
                    cout << S << '\n';
                    return 0;
                }
            }
            used[num] = 1;
        }
    }

    cout << -1  << '\n';
    return 0;
}
                                              ;

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 1e5+10;

int N, M;
map<int, int> num_count[MAX];

ll sub1(int n) { // modで同じ数字同士でペアになる
    map<int, int> nums = num_count[n];
    ll sm = 0;
    for (auto iter = nums.begin(); iter != nums.end(); iter++) {
        sm += iter->second;
    }
    return sm / 2;
}

ll sub2(int n) {
    map<int, int> x = num_count[n], y = num_count[M-n];
    ll x_sum = 0, y_sum = 0;
    for (auto iter = x.begin(); iter != x.end(); iter++) x_sum += iter->second;
    for (auto iter = y.begin(); iter != y.end(); iter++) y_sum += iter->second;
    ll ret = min(x_sum, y_sum);
    if (x_sum < y_sum) {
        swap(x_sum, y_sum);
        swap(x, y);
    }
    ll count_pair = 0;
    for (auto iter = x.begin(); iter != x.end(); iter++) {
        count_pair += iter->second / 2;
    }
    return ret + min((x_sum - ret) / 2, count_pair);
}

ll solve() {
    ll ans = sub1(0);
    if (M%2 == 0) ans += sub1(M/2);
    FOR (i, 1, (M+1)/2) ans += sub2(i);
    return ans;
}

int main() {
    cin >> N >> M;
    REP (i, N) {
        int x;
        cin >> x;
        num_count[x%M][x]++;
    }
    cout << solve() << endl;
}

Measured memory_bytes: 11904
a,b,c = input().split()
a = int(a)
b = int(b)
c = int(c)
tmp = 0

if c < b:
  tmp = b
  b = c 
  c = tmp

if b < a:
  tmp = a
  a = b
  b = tmp

if c < b:
  tmp = b
  b = c
  c = tmp

print (str(a) + " " + str(b) + " " + str(c))



Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int hoge(int i,int j) {

  if(i < 0) 
    return 0;
  else {
    if(i % j==0) 
      return i/j;
    else
      return i/j+1;
  }
}


int main() {

  int N,K;

  cin >> N >> K;

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

  int mini;
  for(int i=0; i<N; i++) {
    if (array[i] == 1) {
      mini = i+1;
      break;
    }
  }


  int answer[K];
  for(int i=0; i<K; i++){

    answer[i] = hoge(mini-(i+1), K-1) + hoge(N-mini-(K-i-1),K-1)+1;
  }
  /*answer[0]= hoge(mini-1, K-1)+hoge(N-mini-2, K-1)+1; // (i+3) => N
    answer[1] = hoge(mini-2, K-1) + hoge(N-mini-1, K-1)+1;
    answer[2] = hoge(mini-3, K-1) + hoge(N-mini, K-1)+1;
    */
  int minn = N;
  for(int i=0; i<K; i++) {
    if(answer[i] < minn) {
      minn = answer[i];
    }
  }

  cout << minn << endl;

  return 0;
}



Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		char c=s.charAt(0);
		if(Character.isUpperCase(c))
		{
			System.out.println("A");
		}
		else
		{
			System.out.println("a");
		}
	}

}

Measured memory_bytes: 35708
fun main(args: Array<String>) {
    val s = readString()

    var cnt = 0L
    var ans = 0L
    for (i in s.indices) {
        if (s[i] == 'W') {
            ans += cnt
        } else {
            cnt++
        }
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!

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

int main(void)
{
    int N, M, C;
    cin >> N >> M >> C;
    int B[M];
    int ans = 0;
    for (int i = 0; i < M; i++)
    {
        cin >> B[i];
    }
    for (int i = 0; i < N; i++)
    {
        int A[M];
        int sum = C;
        for (int j = 0; j < M; j++)
        {
            cin >> A[j];
            sum += A[j] * B[j];
        }
        if (sum > 0)
            ans += 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=2e5+5;
char s[N];
int n,i;
ll ans,sum,cnt[30];
int main()
{
//	freopen("reverse.in","r",stdin);
//	freopen("reverse.out","w",stdout);
	scanf("%s",s); n=strlen(s);
	rep(i,0,n-1) cnt[s[i]-'a']++;
	rep(i,0,25) ans+=cnt[i]*sum,sum+=cnt[i];
	printf("%lld\n",ans+1);
	return 0;
}

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

int n;
bool b=true;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
    	cin>>arr[i];
	}
	sort(arr,arr+n);
	for(int i=0;i<n-1;i++)
	{
		if(arr[i]==arr[i+1])
		{
			cout<<"NO"<<endl;
			b=0;
			break;
		}
		
	}
	if(b)
    cout<<"YES"<<endl;
    
    
    
	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
n = int(input())

c = [[0]*10 for _ in range(10)]

for i in range(1,n+1):
    sn = str(i)
    for ci in range(10):
        for cj in range(10):
            if sn[0]==str(ci) and sn[-1]==str(cj):
                c[ci][cj] += 1

res = 0
for i in range(10):
    for j in range(10):
        res += c[i][j]*c[j][i]
print(res)

Measured memory_bytes: 41964
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	if(a%c!=0){
		a = a + c - a%c;
	}
	if(b%c!=0){
		b = b - b%c;
	}
	if(a>b){
		cout<<"0";
	}
	else{
		cout<<(b-a)/c+1;
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  int yo=0,ki=0;
  for(int i=0;i<n;i++){
    if(a.at(i)%4==0)
      yo++;
    if(a.at(i)%2==1)
      ki++;
  }
  bool ans=false;
  if(yo>=ki)
    ans=true;
  if(yo+ki==n&&ki-yo==1)
    ans=true;
  cout << (ans?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3728
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        boolean[] aaaaa = new boolean[scan.nextInt()];
        Arrays.fill(aaaaa,false);
        int k = scan.nextInt();
        for(;k>0;k--){
            int d = scan.nextInt();
            for(;d>0;d--){
                aaaaa[scan.nextInt()-1] = true;
            }
        }
        int aa = 0;
        for(boolean b:aaaaa){
            if(!b)aa++;
        }
        System.out.println(aa);
    }
}

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

const int MAX = 100;
int main() {
	int N, a[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> a[i];
	int med = 0;
	for (int i = 0;i < N;i ++) med += a[i];
	if (med >= 0) med = (med + (N >> 1)) / N;
	else med = (med - (N >> 1)) / N;
	int cost = 0;
	for (int i = 0;i < N;i ++) {
		cost += (a[i] - med) * (a[i] - med);
	}
	cout << cost;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

二乗最小は平均値です
*/

Measured memory_bytes: 256
A, B, C = map(int, input().split())
K = int(input())

while K > 0 and B <= A:
    B *= 2
    K -= 1

while K > 0 and C <= B:
    C *= 2
    K -= 1

if C > B > A:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 61824
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int main() {
    int n; cin >> n;
    vector<int> a(n+1);
    repf(i,1,n+1) cin >> a[i];
    int m = 0;
    vector<int> ans(n+1);
    for (int i = n; i >= 1; i--) {
        int tmp = a[i];
        int pos = i+i;
        while (pos <= n) {
            tmp += ans[pos];
            pos += i;
        }
        if (tmp%2) ans[i] = 1, m++;
    }

    cout << m << endl;
    repf(i,1,n+1) {
        if (ans[i]) cout << i << endl;
    }
    return 0;
}


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

using namespace std;

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

    vector<int> a(5);
    for(int i = 0; i < 5; i++)
        cin >> a[i];
    for(int i = 0; i < 5; i++)
    {
        if(a[i] == 0)
        {
            cout << i + 1;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define lp(i, a, b) for (int i=a;i<=(int)b;++i)
#define lp2(i, a, b) for (ll i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define re return
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define clr(c, x) memset(c,x,sizeof(c));
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = (int) 1e6 + 5, INF = 0x3f3f3f3f, ALPHA = 26;
const ll mod = 998244353;
int main() {
#ifdef ONLINE_JUDGE
    FAST;
#endif
	string s;
	ll k, add = 0, n;
	cin >> s >> k;
	n = s.size();
	string ss = s;
	if ((int) s.size() == 1)
		f(k / 2);
	s += ss;
	s += ss;
	s.pb(s[0]);
	lp(i,1,s.size()-2)
	{
		if (s[i] == s[i - 1]) {
			for (char a = 'a'; a <= 'z'; ++a) {
				if (a != s[i + 1] && a != s[i - 1]) {
					s[i] = a;
					break;
				}
			}
		}
	}
	s.pop_back();
	int add1 = 0;
	lp(i, 0,n-1)
		if (s[i] != ss[i])
			add1++;
	ll ans = 0;
	add = 0;
	lp(i,n,2*n-1)
		if (s[i] != ss[i - n])
			add++;
	ans += ((k / 2) * add);
	add = 0;
	lp(i,2*n,3*n-1)
		if (s[i] != ss[i - 2 * n])
			add++;
	if (add == add1) {
		ans += ((k + 1) / 2) * add;
		f(ans);
	}
	ans += add1;
	k--;
	ans += ((k / 2) * add);
	f(ans);
	return 0;
}


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

int main(){
  long long a,b,k;

  scanf("%lld %lld %lld", &a, &b, &k);

  if(a > k) a = a - k;

  else{
    k = k - a;
    a = 0;
    if(b > k) b = b - k;

    else b = 0;
  }

  printf("%lld %lld\n", a, b);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int N, count = 0;
	long long A[100000];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}
	sort(A, A + N);
	for (int i = 0; i < N-1; i++) {
		if (A[i] == A[i + 1]) {
			A[i] = 0;
			A[i + 1] = 0;
		}
	}
	for (int i = 0; i < N; i++) {
		if (A[i] != 0) {
			count++;
		}
	}
	printf("%d", count);
	return 0;
}

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

int main(){
  int k,n;
  cin >> k >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  int ans=0;
  vector<int> b(n);
  for(int i=0;i<n-1;i++){
    b.at(i)=a.at(i+1)-a.at(i);
  }
  b.at(n-1)=a.at(0)+k-a.at(n-1);
  sort(b.begin(),b.end());
  cout << k-b.at(n-1) << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
	int N, i , A, P, count, min;
	scanf("%d",&N);
	count = 0;
	min = 300;
	for(i=0;i<N;i++){
		scanf("%d",&A);
		P = A;
		while(1){
			
			
			if(P%2==1){
				break;
			}
			P /=2;
			count++;	
		}
		if(count<min){
				min=count;
		}	
		count=0;
		
	}
	printf("%d\n",min);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){
  int ax,bx;
  double a,b;
  cin >> a >> b;
  bool can=false;
  int ans=-1;
  for(int i=13;i<1250;i++){
    ax=i*0.08;
    bx=i*0.1;
    if((int)bx==b && (int)ax==a){
      can=true;
      ans=i;
      break;
    }
  }
  if(can) cout << ans << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,r; cin >> n >> r;
    if (n >= 10) {
        cout << r << endl;
    } else {
        cout << r+100*(10-n) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int  n, k ; 
    cin >> n >> k ; 
    vector <pii> v(n+2);
    for (int i=1;i<=n;i++){
        int a,b; 
        cin>>a>>b;
        v[i].ff=a;
        v[i].ss=b;
    }
    v[n+1].ff=10000000;
    v[n+1].ss=10000000000000;
    v[0].ff=0; v[0].ss=0; 
    sort(v.begin()+1, v.end()); 
    for (int i=2;i<=n;i++){ 
        v[i].ss += v[i-1].ss; 
    } 
    int  l=1, r = n ; 
    while (l<=r){ 
        int mid=(l+r)/2; 
        if (v[mid].ss>=k and v[mid-1].ss < k and v[mid+1].ss > k){
            cout << v[mid].ff << endl;
            return;
        }
        if (v[mid].ss>k) r=mid-1;
        else l=mid+1;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4816
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
using namespace std;

#define is_uruu leapyear
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,a) for(int i=0;i<(a);++i)

int main() {
	
	vector<int> V;
	long long n, x, hw[2]={0}, hwi=0;
	cin >> n;
	REP(i, n){
		cin >> x; 
		V.push_back(x);
	}
	sort(V.begin(),V.end());
	
	while(hw[1] == 0){
		if(V.size() == 0){
			cout << 0 << endl;
			return 0;
		}
		if(V[V.size()-1] == V[V.size()-2]){
		hw[hwi] = V[V.size()-1];
		REP(i, 2) V.pop_back();
		hwi++;
		} else {
			V.pop_back();
		}
	}
	
	cout << hw[0]*hw[1] << endl;
	
    return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define size 3000
#define ll long long int
ll arr[size];


int main()
{
	int n;
	cin>>n;
	ll sum[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		if(i==0)
			sum[0]=arr[0];
		else
			sum[i]=sum[i-1]+arr[i];
	}
	ll dp[n][n];
	//ll dp2[n][n];
	for(int t=0;t<n;t++)
	{
		for(int j=t;j<n;j++)
		{
			int i=j-t;
			if(i==j)
				dp[i][j]=arr[i];
			else
			{
				if(i!=0)
					dp[i][j]=sum[j]-sum[i-1]-min(dp[i+1][j],dp[i][j-1]);
				else
					dp[i][j]=sum[j]-min(dp[i+1][j],dp[i][j-1]);
			}
		}
	}
	// for(int i=0;i<n;i++)
	// {
	// 	for(int j=0;j<n;j++)
	// 	{
	// 		cout<<dp[i][j]<<"  ";
	// 	}
	// 	cout<<endl;
	// }
	cout<<(2*dp[0][n-1])-sum[n-1]<<endl;



}


Measured memory_bytes: 70528
n=int(input())
a=list(map(int,input().split()))
a=a[::-1]
a+=[-1]
ans=0;cnt=0
for i in range(n):
  if a[i]<=a[i+1]:
    cnt+=1
  if a[i]>a[i+1]:
    if cnt>ans:
      ans=cnt
      cnt=0
    else:
      cnt=0
print(ans)

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int a = x2 -x1;
  int b = y2 -y1;
  
  cout << x2 -b << " " << y2 +a << " " << x2 -a -b << " " << y2 +a -b << "\n";

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        string s = Console.ReadLine();
        int N = int.Parse(s.Split(' ')[0]);
        int K = int.Parse(s.Split(' ')[1]);


        //検証


        //出力
        Console.WriteLine(N - K + 1);


    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];

    int ans = 0;
    while(1){
        int tmp;
        for(int i = 0; i < n; i++){
            tmp = 1e9;
            if(a[i]%2 == 0){
                tmp = i;
                a[i] /= 2;
                break;
            }
        }
        if(tmp == 1e9) break;
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int k,x,num=1000000;
	cin>>k>>x;
	for(int i=x-k+1;i<x+k;i++){
		if(i<-num||num<i){
			continue;
		}else{
			cout<<i<<" ";
		}
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n, m, x = 0;
  int i, j, k, l;
  char s[101][11], t[101][11];

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    scanf("%s", t[i]);
  }

  for (i = 0; i < n; i++) {
    l = 1;
    for (j = i + 1; j < n; j++) {
      for (k = 0; s[i][k] == s[j][k]; k++) {
        if (s[i][k] == '\0') {
          l++;
          break;
        }
      }
    }
    if (l <= x) {
      continue;
    }
    for (j = 0; j < m; j++) {
      if (l <= x) {
        break;
      }
      for (k = 0; s[i][k] == t[j][k]; k++) {
        if (s[i][k] == '\0') {
          l--;
          break;
        }
      }
    }
    if (l > x) {
      x = l;
    }
  }

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

  return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

## ダイクストラ

import heapq
def dijkstra_heap(s, edge):
    #始点sから各頂点への最短距離
    ###edge=[[e[0]:コスト, e[1]：目的地]...]
    #O(ElogV)
    d = [float("inf")] * N      #各頂点への最小距離を記憶
    used = [True] * N           #True:未確定
    d[s] = 0                    #スタート地点は0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist, e)         #スタート地点につながった頂点をプッシュ
    while len(edgelist):
        minedge = heapq.heappop(edgelist)   #一番距離が小さいものを取り出す
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:            #既に最短距離確定済みだったらスルー
            continue
        v = minedge[1]  
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                if e[0]+d[v] > d[e[1]]:                     #既に求まってる最短距離以上なら枝刈り
                    continue
                heapq.heappush(edgelist, [e[0]+d[v], e[1]]) #最小値更新した頂点につながった頂点をプッシュ
    return d

N, M = mi()
memo = []
rel = [[] for i in range(N)]

for i in range(M):
    s, t = mi()
    s, t = s-1, t-1
    memo.append((s, t))
    rel[s].append([1, t])
    rel[t].append([1, s])

cnt = 0
for x in range(M):
    s, t = memo[x][0], memo[x][1]
    rel[s].remove([1, t])
    rel[t].remove([1, s])

    l = sorted(dijkstra_heap(0, rel))
    ind = bisect.bisect_left(l, float('inf'))
    if ind != N:
        cnt += 1

    rel[s].append([1, t])
    rel[t].append([1, s])

print(cnt)

Measured memory_bytes: 3192
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long long int>c(26);
	for (auto &i : c)cin >> i;
	vector<vector<int>>v(N, vector<int>(26));
	for (auto &i : v)for (auto &j : i)cin >> j;
	vector<long long int>bef(26, -1);
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> M;
		M--;
		ans += v[i][M];
		bef[M] = i;
		for (int j = 0; j < 26; j++) {
			ans -= c[j] * (i - bef[j]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  string S; cin >> S;
  map<char,int> mp;
  int answer=INF;
  rep(i,S.size()){
    mp[S[i]]++;
  }
  fore(g,mp){
    char c=g.first;
    int ans=0;
    string s=S;
    while(1){
      int cnt=0;
      rep(i,s.size()){
        if(s[i]==c) cnt++;
      }
      if(cnt==s.size()){
        //cout << ans << endl;
        chmin(answer,ans);
        break;
      }
      for(int i=1;i<s.size();i++){
        if(s[i]==c){
          s[i-1]=c;
        }
      }
      s.pop_back();
      ans++;
    }
  }
  cout << answer << endl;
  return 0;
}


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

int main()
{
	unsigned long n;
	std::vector<unsigned long> d(n);
	std::cin >> n;
	d.resize(n);
	for (size_t i = 0; i < d.size(); i++)
	{
		std::cin >> d[i];
	}
	
	std::sort(d.begin(), d.end());
	auto half_1 = d[(d.size() / 2 - 1)] + 1;
	auto half_2 = d[d.size() / 2];
	
	unsigned long cnt_up = 0;
	unsigned long cnt_down = 0;
	unsigned long pattern;
	std::for_each(d.begin(), d.end(), [&cnt_up, &cnt_down, half_1](unsigned long x){
		if(x >= half_1)
			cnt_up++;
		else
			cnt_down++;
	});
	pattern = cnt_up == cnt_down ? half_2 - half_1 + 1 : 0;

	std::cout << pattern << std::endl;	

	return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

int main()
{
    ll n;
    cin >> n;
    vll h(n);
    rep(i,n)cin >> h[i];

    vll dp(n,0);
    dp[1] = abs(h[0] - h[1]);
    REP(i,2,n){
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[n-1] << endl;

    /*cout << endl;
    rep(i,n)cout << dp[i] << " ";
    cout << endl;
    */return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

string s1,s2,s3,s4,s5;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    s1.resize((n-1)/2);
    s2.resize((n-1)/2);
    s3.resize((n-1)/2);
    s4.resize((n-1)/2);
    for (int i = 0; i < (s.size()-1)/2; ++i) {
        s1[i] = s[i];
        s2[i] = s[i];
    }
    reverse(s2.begin(),s2.end());
    for (int i = (s.size()-1)/2+1; i < s.size(); ++i) {
        s3[i-(n+1)/2] = s[i];
        s4[i-(n+1)/2] = s[i];
    }
    reverse(s4.begin(),s4.end());
    s5 = s;
    reverse(s5.begin(),s5.end());
    if(s1 == s2 && s3 == s4 && s5 == s){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256