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

int N;
long long L[100010];
long long ans = 0;

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%lld",&L[i]);
    sort(L,L + N);
    for(int i = N - 2; i >= 0; i--)
    {
        if(L[i] == L[i + 1])
        {
            if(ans == 0)
            {
                ans = L[i];
                i--;
            }
            else
            {
                printf("%lld\n",ans * L[i]);
                return 0;
            }
        }
    }
    printf("0\n");
    return 0;
}


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

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

    int num = round(sum/(double)n);

    int cost = 0;
    for(int i = 0; i < n; i++) cost += (num-a[i])*(num-a[i]);

    cout << cost << endl;
}

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

int main(void)
{
  int a; cin>>a;
  int b; cin>>b; int x = abs(a-b);
  int c; cin>>c; int y = abs(b-c);
  int l = max(x,y); int z = abs(c-a);
  l = max(l,z);
  int ans = x+y+z-l;
  cout << ans << endl;

  return 0;
}


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

#define ll long long

int main()
{
    ll K, N;
    std::cin >> K >> N;

    std::vector<ll> A(N);
    for(ll i=0; i < N; i++) {
        std::cin >> A[i];
    }

    ll max_len = 0;
    for(ll i=1; i < N; i++) {
        max_len = max_len > (A[i]-A[i-1]) ? max_len : (A[i]-A[i-1]);
    }
    max_len = max_len > (K - A[N-1] + A[0]) ? max_len : (K-A[N-1]+A[0]);
    std::cout << K - max_len << std::endl;
}

Measured memory_bytes: 4788
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

ll res[10] = {};
set< P > st;

int main(void){
  int h,w,n;
  cin >> h >> w >> n;
  for(int i = 0;i < n;++i){
    int ai,bi;
    cin >> ai >> bi;
    --ai;--bi;
    st.insert(P(ai,bi));
  }
  for(set< P >::iterator itr = st.begin();
      itr != st.end();++itr){
    for(int s = -1; s <= 1;++s){
      for(int t = -1; t <= 1;++t){
	int cnt = 0;
	int cy = (itr -> first) + s;
	int cx = (itr -> second) + t;
	if(cx <= 0 || cy <= 0 ||
	   cx >= w-1 || cy >= h-1){
	  continue;
	}
	for(int a = -1; a <= 1;++a){
	  for(int b = -1; b <= 1;++b){
	    int x = cx + a;
	    int y = cy + b;
	    if(st.find(P(y,x)) != st.end())++cnt;
	  }
	}
	++res[cnt];
	//cout << cx << " " << cy << " " << cnt << endl;
      }
    }
  }
  ll z = (ll)(h-2)*(ll)(w-2);
  for(int i = 1;i < 10;++i){
    res[i] /= i;
    z -= res[i];
  }
  res[0] = z;
  for(int i = 0;i < 10;++i){
    cout << res[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007


signed main(){

	lli a,b,c;
	cin>>a>>b>>c;

	lli now = a-b;

	cout << max(0LL,c-now) <<endl;


	return 0;
}

Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)

n = ip()                                     #入力整数1つ
#a,b,t= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#k = ip()                      #入力セット(整数改行あり)(1/2)
#v=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
if n%2==0:
    for i in range(n-1,-1,-2):
        print(a[i],end=' ')
    for i in range(0,n,2):
        print(a[i],end=' ')
else:
    for i in range(n-1,-1,-2):
        print(a[i],end=' ')
    for i in range(1,n,2):
        print(a[i],end=' ')

Measured memory_bytes: 35176
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin >> n;
    long tmp = sqrt(n);
    long ans = 0;
    for(long i=tmp;i>=1;i--){
        if(n%i==0){
            ans = (i-1)+(n/i -1);
            break;
        }        
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    let nums = input.split('\n')[1].split(' ').map(i => parseInt(i))
    nums = nums.sort((a, b) => a - b)
    const first = nums.shift()
    const last = nums.pop()
    console.log('%d', last - first)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7500
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

bool pair_comp(const pair<ll, ll> & p1, const pair<ll, ll> & p2)
{
	// sort(item.begin(), item.end(), throw_comp)のように使う
	if (p1.first != p2.first) {
		return p1.first < p2.first;
	}
	else {
		return p1.second > p2.second;
	}
}


// main function
int main()
{
	ll M, N = 0;
	ll ans = 0;

	cin >> N >> M;
	vector<ll> x(M);
	vector<ll> diff(M - 1);
	Rep(i, M) {
		cin >> x[i];
	}
	sort(x.begin(), x.end());
	Rep(i, M - 1) {
		diff[i] = x[i + 1] - x[i];
	}
	sort(diff.begin(), diff.end(), greater<ll>());
	Rep(i, M - 1) {
		if(i >= N - 1) ans += diff[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import sys
n = int(input())
t_ls = []
for i in range(n):
    t_ls.append(int(sys.stdin.readline().strip()))

def gcd(a, b):
    while a and b:
        if a < b:
            b %= a
        else:
            a %= b
    return max(a, b)

def scm(a, b):
    _gcd = gcd(a, b)
    return a * b // _gcd

res = 1
for t in t_ls:
    res = scm(res, t)
print(res)

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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  
  if(A+B>C+D)
    cout<<"Left"<<endl;
  else if(A+B==C+D)
    cout<<"Balanced"<<endl;
  else
    cout<<"Right"<<endl;
}


Measured memory_bytes: 256
s = input()
# s = "01B0"
# print(s[0])

ans = []
for key in range(len(s)):

    if s[key] == "0" or s[key] == "1":
        ans.append(s[key])
    if s[key] == "B" and len(ans) > 0:
        ans.pop(-1)
print("".join(ans))

Measured memory_bytes: 3060
a,b,c=map(int,input().split())
if a<b:
	if a<c and c<b:
		print("Yes")
	else:
		print("No")
elif b<a:
	if b<c and c<a:
		 print("Yes")
	else:
		 print("No")
else:
	 print("No")


Measured memory_bytes: 2940
//==================================================================================================
// Name        : Noragami.cpp
// Author      : lotus.eater086
// Copyright   : If you're reading this then this warning is for you. Every word you read of this 
//               useless fine print is another second of your life. Don't you've other things to do?
//               Is your life so empty that you honestly can't think of a better way to spend these
//               moments ? Or are you so impressed with authority that you give respect and 
//               credence to all who claim it ? Do you read everything you're supposed to read ? Do
//               you think everything you're supposed to think ? Buy what you're told you should 
//               want ? Get out of your apartment . Meet a member of the opposite sex. Stop the 
//               excessive shopping and self-improvement . Quit your boring job.
//               Start a fight. Prove you're alive. If you don't claim your humanity you'll become a
//               statistic. You've been warned !

// Description : 
// Date        : 2019-10-03
// Time        : 11:56:15
// Directory   : C:\Users\Lenovo\cpPractise\deliberatePractise\code_folder\.vscode
// FilePath    : C:\Users\Lenovo\cpPractise\deliberatePractise\code_folder\.vscode\Noragami.cpp
//==================================================================================================
    

#include <bits/stdc++.h>
#define LL long long
#define endl "\n"

using namespace std ;
    
//
template < typename T >

inline T read( T &x )
{

    x = 0 ;

    int f = 0 ;

    char ch = getchar() ;

    while( ch < '0' || ch > '9' )  {

        f |= ( ch == '-' ) , ch = getchar() ;

    }

    while( ch >= '0' && ch <= '9' )  {

        x = ( x << 1 ) + ( x << 3 ) + ch - '0' , ch = getchar() ;

    }

    return x = f ? -x:x ;

}
//

void solve( void )
{

    int n ;

    cin >> n ;

    vector<int> v(n) ;

    for( int i = 0 ; i < n ; i++ )  cin >> v[i] ;

    int boro = v[1] - v[0] , choto = v[0] ;

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

        boro = max( boro , v[i]-choto ) ;

        choto = min(choto,v[i]) ;

    }

    cout << boro << endl ;

}

int main( void )

{

    ios_base::sync_with_stdio( false ) ;  cin.tie( NULL ) ;  cout.tie( NULL ) ;

   

    if( 0 )  {

        int t = 100 ;

        for( int i = 1 ; i <= t ; i++ )  solve() ;

    }

    else  {

        solve() ;

    }

    

    return 0 ;

}



Measured memory_bytes: 3592
def gcd(a, b):
    if b == 1:
        return 1
    # a > b　を仮定
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)

#def lcm(A, n):
#    if n == 2:
#        return A[0]*A[1] // gcd(A[0], A[1])
#    #lcm(A, n)はA[0]-A[n-1]までの最小公倍数を求める
#    a = lcm(A, n-1)
#    return a* A[n-1] // gcd(a, A[n-1])

n = int(input())
#a = []
T1 = int(input())
for i in range(n-1):
    T2 = int(input())
    T1 = T1*T2 // gcd(T1, T2)
    #a.append(int(input()))
#a.sort(reverse = True)
#ans = lcm(a, n)
print(str(T1))

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;




int main(){
    
    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<int>> choco(h,vector<int>(w,0));
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w){
        if (s[j]=='1')  choco[i][j] = 1;
        }
    }
    int ans = (int)1e8;
    for(int i = 0; i < (1<<(h-1));i++){
        
        
        
        vector<int> rowcut;
        rowcut.pb(0);
        for(int j = 0; j < h-1; j++){
            int cut = (((i>>j)&1));
            if (cut) rowcut.push_back(j+1);
        }
        rowcut.pb(h);
        
        int cuts = (int) rowcut.size();
        int cand = 0;
        
//        rep(j,cuts){
//            cout << rowcut[j];
//        }
//        cout << endl;
        
        map<int,int> counter;
        int col = 0;
        int looping = 0;
        int CUT = 0;
        int prev = 0;
        
        while(col < w){
            if (col == prev) looping = 1;
            prev = col;
            rep(j,cuts-1){
                for(int r = rowcut[j]; r < rowcut[j+1];r++){
                    counter[j] += choco[r][col];
                }
                if(counter[j] > k){
                    CUT = 1;
                }
            }
            if (CUT == 0) {col++; looping = 0;}
            else{
                if (looping) {cand = (int) 1e9;break;}
                map<int,int> tmp;
                counter = tmp;
                cand++;
                CUT = 0;
            }
        }

        cand += cuts-2;
        //cout << "            CAND " << cand << endl;
        ans = min(ans,cand);
    }
    cout << ans;
}



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

int main(){
    int A, B;
    cin >> A >> B;
    if (A == 2 || B == 2) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter
n, p = [int(i) for i in sys.stdin.readline().split()]
s = sys.stdin.readline().strip()
if p == 2:
    ans = 0
    for i, _s in enumerate(s, 1):
        if int(_s) % 2 == 0:
            ans += i
    print(ans)
elif p == 5:
    ans = 0
    for i, _s in enumerate(s, 1):
        if int(_s) in {0, 5}:
            ans += i
    print(ans)
else:
    us = Counter([])
    cur = ""
    ans = 0
    mod = 0
    keta_mod = 1
    for i, _s in enumerate(s[::-1]):
        keta_mod = keta_mod * 10 % p
        mod = (keta_mod * int(_s) + mod) % p
        if mod == 0:
            ans += us[mod] + 1
        else:
            ans += us[mod]
        us.update([mod])
    print(ans)

Measured memory_bytes: 47932
#include<bits/stdc++.h>
#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define print(a, n) for(LL e=0; e<n; e++) cout<<a[e]<<" "; cout<<endl
#define read(a, n) for(LL e=0; e<n; e++) cin>>a[e];
using namespace std;

int main()
{
	fastio;
	string s;
	cin>>s;
	if(s=="ABC")
		cout<<"ARC"<<"\n";
	else
		cout<<"ABC"<<"\n";
	
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string str;
	while(getline(cin, str))
	{
		if(str == "END OF INPUT")
		{
			break;
		}
		int count = 0;
		for(int i = 0; i < str.size(); ++i)
		{
			if(str[i] == ' ')
			{
				cout << count;
				count = 0;
			}
			else
			{
				++count;
			}
		}
		cout << count << endl;
	}
}

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

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)

signed main(){
  int n;
  cin>>n;
  vector<int> v;
  lp(i,n){
    int a;
    cin>>a;
    v.push_back(a);
  }
  vector<int> fa,minu;
  lp(i,n){
    if(v[i]>=2) fa.push_back(v[i]);
    if(v[i]<0) minu.push_back(v[i]);
  }
  sort(minu.begin(),minu.end());
  //cout<<minu[0]<<endl;
  for(int i=1;i<minu.size();i+=2){
    if(minu[i-1]==-1) break;
    fa.push_back(minu[i]);
    fa.push_back(minu[i-1]);
  }
  cout<<fa.size()<<endl;
  int done[100];
  lp(i,100) done[i]=0;
  lp(i,fa.size()){
    int lkf=fa[i];
    lp(j,v.size()){
      if(v[j]==lkf){
	if(done[j]==0){
	  done[j]=1;
	  break;
	}
	else continue;
      }
    }
  }
  lp(i,100){
    if(done[i]==1) cout<<i+1<<endl;
  }
  return 0;
}




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

using namespace std;

vector<int> a;

int partitionSort(int p,int r)
{
	int x = a[r];
	int i = p - 1;

	for (int j = p; j != r; ++j)
	{
		if (a[j] <= x)
		{
			++i;
			swap(a.at(i), a.at(j));
		}
	}

	swap(a.at(i + 1), a.at(r));

	return i + 1;
}




int main()
{
	int n,t;

	ios::sync_with_stdio(false);

	cin >> n;

	for (int i = 0; i != n; ++i)
	{
		cin >> t;
		a.push_back(t);
	}

	int q=partitionSort(0,n-1);

	for (int i = 0; i != a.size(); ++i)
	{
		if (i)
		{
			cout << " ";
		}
		if (i == q)
		{
			cout << "["<<a.at(i)<<"]";
		}
		else
		{
			cout << a.at(i);
		}
		
	}
	cout << endl;

	return 0;

}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int a[105],b[105];
int n; 
long long ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n-1;i++)
	{
		cin>>b[i];
	}
	for(int i=1;i<=n;i++)
	{
		a[i]=1e9;//将a初始化为最大值 
	}
	for(int i=1;i<=n-1;i++)//有n-1个b控制a 
	{
		a[i]=min(a[i],b[i]);//每个a都取最大时和最大 
		a[i+1]=min(a[i+1],b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		ans+=a[i];
	}
	cout<<ans;
	return 0; 
} 

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c;
	
	scanf("%d",&a);
	if(a==5)b++;
	else if(a==7)c++;
	
	scanf("%d",&a);
	if(a==5)b++;
	else if(a==7)c++;
	
	scanf("%d",&a);
	if(a==5)b++;
	else if(a==7)c++;
	
	if(b==2&&c==1)puts("YES");
	else puts("NO");
	
	return 0;
}

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

class BIT {
public:
	vector<int> bit;
	int size_ = 0;

	void init(int sz) {
		size_ = sz + 2;
		bit.resize(size_ + 2, 0);
	}
	void add(int pos, int x) {
		pos++;
		while (pos <= size_) {
			bit[pos] += x;
			pos += (pos&-pos);
		}
	}
	int sum(int pos) {
		pos++; int s = 0;
		while (pos >= 1) {
			s += bit[pos];
			pos -= (pos&-pos);
		}
		return s;
	}
};

string S, T; long long K;
vector<int> C[26]; int cnt[26];
BIT Z; bool used[1 << 19];

int main() {
	cin >> S >> K;
	for (int i = 0; i < S.size(); i++) C[S[i] - 'a'].push_back(i);

	Z.init(S.size() + 2);
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < 26; j++) {
			if (cnt[j] == (int)C[j].size()) continue;
			int pos = C[j][cnt[j]];
			int v = pos - Z.sum(pos);

			if (K >= v) {
				K -= v; cnt[j]++;
				T += ('a' + j);
				Z.add(pos, 1);
				break;
			}
		}
	}
	cout << T << endl;
	return 0;
}


Measured memory_bytes: 5156
from collections import Counter as Ct
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n,k=INTM()
    a=LIST()
    a=sorted(a,reverse=True)
    if n<=k:
        ans=0
    else:
        ans=sum(a[k:])

    print(ans)
if __name__=='__main__':
    do()

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

int main() {
    int a,b,c,d,e,f,g,h,i,p,q,r,s,t,u;
    cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
    if(b-a+d == e && c-a+d == f && b-a+g == h && c-a+g == i){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import math

A,B,H,M = map(int,input().split())

x = 360//12
y = 360//60

a = M*y
b = (H+M/60)*x
T = 1
if a>=b:
  if a-b>180:
    k = 360 - a+b
  elif a - b == 180:
    print(A+B)
    T = 0
  else:
    k = a-b
else:
  if b-a>180:
    k = 360 - b+a
  elif b-a == 180:
    print(A+B)
    T = 0
  else:
    k = b-a

if T == 1:
  k = math.radians(k)

  ans = A*A + B*B - 2*A*B*math.cos(k)

  print(math.sqrt(ans))

Measured memory_bytes: 9612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


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

    ll cnt = 1;
    ll num = 0;
    ll ans = 0;

    bool spec = true;
    rep(i, S.size()-1) {
        if (S[i] != S[i+1]) spec = false;
    }
    if (spec) {
        ans = S.size() * K / 2;
        print(ans);
        return 0;
    }

    ll _cnt1 = 1;
    ll _cnt2 = 1;
    ll _cnt = 0;
    rep(i, S.size()-1) {
        if (S[0] != S[i+1]) break;
        _cnt1++;
    }
    rep(i, S.size()-1) {
        if (S[S.size()-1] != S[S.size()-2-i]) break;
        _cnt2++;
    }
    _cnt = _cnt1 + _cnt2;

    rep(i, S.size()-1) {
        if (S[i] == S[i+1]) {
            cnt++;
            if (i+1 == S.size()-1) {
                num += cnt/2;
            }
        } else {
            num += cnt/2;
            cnt = 1;
        }
    }

    ll diff = _cnt/2 - _cnt1/2 - _cnt2/2;

    if (S[0] != S[S.size()-1]) ans = num * K;
    else ans = num * K + diff * (K-1);

    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,ans,k;
char a[10][10],b[10][10];
vector<int> v;
void dfs(int deep){
    for (int j=1;j<=n;j++)
         for (int k=1;k<=m;k++)
             b[j][k]=a[j][k];
    int sum=0,c=v.size();
    for (int j=0;j<c;j++)
      if (v[j]<=m)
        for (int k=1;k<=n;k++) b[k][v[j]]='.';
      else
        for (int k=1;k<=m;k++) b[v[j]-m][k]='.';
    for (int j=1;j<=n;j++)
         for (int k=1;k<=m;k++)
             if (b[j][k]=='#') sum++;
   	if (sum==k) ans++;
  for (int i=deep+1;i<=n+m;i++){ 
    v.push_back(i);
	dfs(i);
    v.erase(v.end()-1);
  }
  return ;
}
int main(){
    cin>>n>>m>>k;
    for (int i=1;i<=n;i++)
  	    for (int j=1;j<=m;j++)
      	    cin>>a[i][j];
    dfs(0);
    cout<<ans<<endl;
  return 0;
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n; cin >> n;
	for(int i=0;i<3;i++){
		int m = n%10;
		if(m==7){
			cout << "Yes" << endl;
			return 0;
		}
		n = n/10;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
struct E{
  long long t,c;
  bool operator<(const E&a)const{return c>a.c;}
};
vector<E>G[1<<17];
long long z[1<<17];
int n,a,b,c,q,k,x,y,i,j;
void dijkstra(){
  priority_queue<E>Q;
  for(int i=0;i<1<<17;)z[i++]=1ll<<60;
  z[k]=0;
  Q.push(E{k,0});
  while(Q.size()){
    E p=Q.top();Q.pop();
    if(z[p.t]<p.c)continue;
    for(i=0;i<G[p.t].size();++i){
      E e=G[p.t][i];
      if(z[e.t]>p.c+e.c)z[e.t]=p.c+e.c,Q.push(E{e.t,z[e.t]});
    }
  }
}
main(){
  for(cin>>n;++i<n;G[a].push_back(E{b,c}),G[b].push_back(E{a,c}))scanf("%d%d%d",&a,&b,&c);
  for(cin>>q>>k,dijkstra();j++<q;cout<<z[x]+z[y]<<endl)scanf("%d%d",&x,&y);
}


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

int main(){
  string N;
  cin>>N;
  if(N.at(0)==N.at(1)&&N.at(1)==N.at(2)){
    cout<<"Yes"<<endl;
  }else if(N.at(1)==N.at(2)&&N.at(2)==N.at(3)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
}

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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s;
    cin>>s;
    map<ll,ll> mp;
    mp[s] = 1;
    ll i = 1;
    while(true){
      i++;
      if(s%2==1){
        s = s*3 + 1;
        if(mp[s] == 1){
          cout<<i<<endl;
          break;
        }
        mp[s] = 1;
      }
      else{
        s = s/2;
        if(mp[s] == 1){
          cout<<i<<endl;
          break;
        }
        mp[s] = 1;
      }
    }

}


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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int MAX = 1000000;
constexpr int inf = 1<<30;

int h,w,k;
int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    cin>>h>>w>>k;
    vector<string> m(h);
    int sx,sy,gx,gy;
    cin>>sy>>sx>>gy>>gx;
    sx--;sy--;gx--;gy--;
    for(auto &a : m)cin>>a;
    vector<vector<int>> f(h+5,vector<int>(w+5,inf));
    priority_queue<tuple<int,int,int>> q;
    q.push({0,sy,sx});
    f[sy][sx] = 0;
    while(!q.empty()){
        auto cur = q.top();q.pop();
        int y = get<1>(cur);
        int x = get<2>(cur);
        int cost = -get<0>(cur);
        for(auto d : initializer_list<pair<int,int>>{{-1,0},{0,1},{1,0},{0,-1}}){
            for(int i=1;i<=k;++i){
            int dy = y + d.first*i;
            int dx = x + d.second*i;
                if(dy < 0 or dy > h-1 or dx < 0 or dx > w-1 or m[dy][dx] == '@')break;
                if(f[dy][dx] > cost + 1){
                    f[dy][dx] = cost + 1;
                    q.push({-f[dy][dx],dy,dx});
                } else if(f[dy][dx] < cost + 1)break;
            }
        }
    }

    if(f[gy][gx] == inf)cout << -1 << endl;
    else cout << f[gy][gx] << endl;
    return 0;
}

Measured memory_bytes: 31708
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cstring>
#include <climits>
using namespace std;
#define ff(i,s,n) for(int i=s;i<n;i++)
#define fr(i,s,n) for(int i=n-1;i>=s;i--)
#define llu long long int 

int main() {
	int m,n,bombs;
	cin>>m>>n>>bombs;
	set<llu> values;
	int rows[m];int cols[n];
	memset(rows,0,sizeof(rows));
	memset(cols,0,sizeof(cols));
	for(int i=0;i<bombs;i++){
		int v1,v2;
		cin>>v1>>v2;
		v1--; v2--;
		llu hash=v1*1000000001+v2;
		values.insert(hash);
		rows[v1]++; cols[v2]++;
	}
	
	vector<int> v;
	vector<int> vY;
	int max=INT_MIN;
	int maxY=INT_MIN;
	
	for(int i=0;i<m;i++)
		if(rows[i]>max)
			max=rows[i];
	
	for(int i=0;i<n;i++)
		if(cols[i]>maxY)
			maxY=cols[i];
		
	int ind=0;
	for(int i=0;i<m;i++){
		if(rows[i]==max){
			v.push_back(i);
		}
	}
	ind=0;
	for(int i=0;i<n;i++){
		if(cols[i]==maxY){
			vY.push_back(i);
		}
	}
	
	llu fin=max+maxY-1;
	int flag=1;
	for(int i:v){
		for(int j:vY){
			llu hash=i*1000000001+j;
			if(values.find(hash)==values.end()){
				fin++; flag=0;
				break;
			}
		}
		if(!flag)	break;
	}
	cout<<fin;
}

//1
//7 2
//3 5 4 5 1 1 1


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

int main() {
    int k;
    cin >> k;

    li lun;   
    queue<li> q;
    for (int i = 1; i <= 9; i++) q.push(i);
    for (int i = 1; i < k + 1; i++) {
        lun = q.front();
        int tail = lun % 10;
        if (tail != 0) q.push(10 * lun + tail - 1);
        q.push(10 * lun + tail);
        if (tail != 9) q.push(10 * lun + tail + 1);
        q.pop();
    }

    cout << lun << endl;

    return 0;
}

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

int main() {

  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  for(int i = 0; i < N; i++) cin >> m.at(i);
  
  int total = 0;
  for(int i = 0; i < N; i++) total += m.at(i);
    
  sort( m.begin(), m.end());
  
  int count = 0;  
  while ( X - total >= m.at(0)){
    total += m.at(0);
    count ++;  
  }
  
  cout << count + N << endl;
}

Measured memory_bytes: 256
H,W = gets.split.map(&:to_i)
h,w = [H,W].map{|v| v / 2}

S = H.times.map{ gets.chomp }.join
C = ('a' .. 'z').map{|c| S.count(c) }
ans = true

ans &&= (h * w).times.all? do
  i = C.index{|v| v >= 4 }
  C[i] -= 4 if i
end

if H.odd?
  ans &&= w.times.all? do
    i = C.index{|v| v >= 2 }
    C[i] -= 2 if i
  end
end

if W.odd?
  ans &&= h.times.all? do
    i = C.index{|v| v >= 2 }
    C[i] -= 2 if i
  end
end

puts ans ? :Yes : :No


Measured memory_bytes: 14380
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

from collections import defaultdict
d = defaultdict(int)
S = 0
for a in A:
   d[a] += 1
   S += a

for _ in range(Q):
   b, c = map(int, input().split())
   S += d[b] * (c - b)
   print(S)
   d[c] += d[b]
   d[b] = 0


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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>

using namespace std;
using ll = long long;


vector<int> c;
vector<vector<int>> s;
int D;
vector<int> v;
vector<set<int>> U;

ll calc(){
    ll ans = 0;
    vector<int> last(26, 0);
    for(int i = 0;i < D;i++){
        last[v[i] - 1] = i + 1;
        ans += s[i][v[i] - 1];
        //cout<<s[i][v[i] - 1]<<endl;
        for(int j = 0;j < 26;j++){
            ans -= (ll)(i + 1 - last[j]) * c[j];
        }
    }
    return ans;
}

int retrnd(int n){ //乱数生成                                    
	std::random_device rnd;
    std::mt19937 mt(rnd());
    std::uniform_int_distribution<> rand100(0, n);
    return rand100(mt);
}

int main(){
    cin >> D;
    for(int i = 0;i < 26;i++){
        int a;cin >> a;
        c.push_back(a);
    }
    for(int i = 0;i < D;i++){
        vector<int> a;
        for(int j = 0;j < 26;j++){
            int b;cin >> b;
            a.push_back(b);
        }
        s.push_back(a);
    }
    U = vector<set<int>>(26);
    for(int i = 0;i < D;i++){
        v.push_back(retrnd(25) + 1);
    }
    int now = calc();
    int try_cnt = 5000;
    for(int cnt = 0;cnt < try_cnt;cnt++){
        int rnd = retrnd(D - 1);
        for(int i = 1;i < 27;i++){
            int prev = v[rnd];
            v[rnd] = i;
            int w = calc();
            if(now > w){
                v[rnd] = prev;
            }else{
                now = w;
            }
        }
    }
    for(int i = 0;i < D;i++){
        cout<<v[i]<<endl;
    }
}


Measured memory_bytes: 3712
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
ll sousa(int X) {
    int ANS;
    if (X % 10 != 0)ANS = 10 - X % 10;
    else ANS = 0;
    return ANS;
}
ll siomusubi(int Y) {
    int ANS = Y % 10 == 0 ? Y : (Y/10+1)*10;
    return ANS;
}
signed main() {
    vi A(5); rep(i, 5)cin >> A[i];
    int sum = 0;
    rep(i, 5) sum += siomusubi(A[i]);
    int MAX = MINF;
    rep(i, 5) MAX = max(sousa(A[i]), MAX);
    cout << sum -MAX << endl;
}





Measured memory_bytes: 3692
#include <stdio.h>
#include <math.h>

int main(int argc, char const *argv[]) {
  /* code */
  int i;
  long int h;
  scanf("%ld", &h);
  
  int count =0;
  long int result =0;
  while(h/2 != 0){
    h = h/2;
    result += pow(2, count);
    count +=1;
  }
  
  result += pow(2, count);
  
  printf("%ld", result);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	ll a,b;
	cin >> a >> b;
	cout << (a*b) << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int a,b,k;
int main(){
  scan(a);scan(b);scan(k);
  int cnt=0;
  rep1(i,100){
    if(a%(101-i)==0&&b%(101-i)==0){
      cnt++;
    }
    if(cnt==k){
      prin(101-i);
      break;
    }
  }
      

  
  return 0;
}


Measured memory_bytes: 256
import heapq
n = int(input())
q = []
for i in range(n):
  heapq.heappush(q, [-int(input()), i])
mx_1, idx = heapq.heappop(q)
mx_2, _ = heapq.heappop(q)
for i in range(n):
  if i == idx:
    print(-mx_2)
  else:
    print(-mx_1)


Measured memory_bytes: 37820
/**
*    author:  Dooloper
*    created: 26.07.2020 03:32:36
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
    int A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;
    string check = "No";
    vector<int> vec(3); // [A,B,C] 作成
    vec.at(0) = A;
    vec.at(1) = B;
    vec.at(2) = C;

    for (int i = 0;i < K;i++)
    {
        if((vec.at(0)>vec.at(1) && vec.at(1)<vec.at(2) && vec.at(0)<vec.at(2)) ||(vec.at(0)>vec.at(1) && vec.at(1)<vec.at(2) && vec.at(0)>vec.at(2)))
        {
            vec.at(1) = vec.at(1)*2;
        }
        else if (vec.at(0)==vec.at(1)) //A==B
        {
            if (vec.at(0)<vec.at(2))
            {
                vec.at(1) = vec.at(1)*2;
            }
            else
            {
                vec.at(2) = vec.at(2)*2;
            }
        }
        else if (vec.at(1)==vec.at(2)) //B==C
        {
            if (vec.at(0)>vec.at(1))
            {
                vec.at(2) = vec.at(2)*2;
            }
            else
            {
                vec.at(2) = vec.at(2)*2;//0->2
            }
        }
        else if (vec.at(0)==vec.at(2)) //A==C
        {
            if (vec.at(0)>vec.at(1))
            {
                vec.at(1) = vec.at(1)*2;
            }
            else
            {
                vec.at(2) = vec.at(2);
            }
            
            
        }
        else
        {
            vec.at(2) = vec.at(2)*2;
        }
        
        
    }
    if (vec.at(0)<vec.at(1) && vec.at(1)<vec.at(2) && vec.at(0)<vec.at(2))
    {
        check = "Yes";
    }
    
    cout << check << endl;
}

Measured memory_bytes: 3632
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <cmath>
#include <limits.h>
#include <ios>
#include <iomanip>
#include <map> // pair
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b){return b? gcd(b, a%b):a;}
 
int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int P[N-1];
  for(int i = 0; i < N; i++){
    cin >> P[i];
  }

  int ans = 0;
  int min = P[0];
  for(int i = 0; i < N; i++){
    if(i==0){
      ans++;
    }else if(P[i] < min){
      ans++;
      min = P[i];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
mod=10**9+7
L=input()
N=len(L)
two=[1]*(1+N)
three=[1]*(1+N)
for i in range(1,1+N):
    two[i]=two[i-1]*2%mod
    three[i]=three[i-1]*3%mod
def freecalc(i,cnt):
    return three[i]*two[cnt]%mod
ans=0
cnt=0
for i,s in enumerate(L):
    if s=="1":
        ans=(ans+freecalc(N-i-1,cnt))%mod
        cnt+=1
print((ans+pow(2,cnt))%mod)


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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


vector<ll> divisor(ll n) {
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return ret;
}

int main() {
    ll n;
    cin >> n;

    vl div1, div2;
    div1 = divisor(n);
    div2 = divisor(n - 1);

    ll cnt = 0;

    for (auto d : div1) {
        if (d == 1) continue;

        ll t = n;
        while (true) {
            if (t % d == 0)
                t /= d;
            else {
                t %= d;
                if (t == 1)
                    cnt++;
                break;
            }

            if (t == 1) {
                cnt++;
                break;
            } else if (t < 1) {
                break;
            }
        }
    }

    cnt += div2.size() - 1;

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y;
    cin >> x >> y;
    if(a[x] == a[y])cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
an=0

for i in range(n):
    tm=0
    a=list(map(int,input().split()))
    for j in range(m):
        tm+=a[j]*b[j]
    if tm+c>0:
        an+=1

print(an)

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

#define text 1002

char *name="Hoshina";
char *wrong_name="Hoshino";

int main(void){
	int i,j,n,length,count;
	char buf[2];
	char istr[text],*next;

	scanf("%d",&n);
	fgets(buf,sizeof(buf),stdin);
	for(i=0;i<n;i++){
		fgets(istr,sizeof(istr),stdin);
		length=strlen(istr);
		istr[length-1]='\0';

		while(next=strstr(istr,wrong_name),next!=NULL){
			next[6]='a';
		}
		printf("%s\n",istr);
	}
	
	return 0;
}

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

int main(){
	long long int   N = 0 ,A, B, C, K;
	string S;
	cin >> A >> B >> C >> K;
  
  for(long long int i=0; i < K ; i++){
  	if(i < A) N++;
    else if (i+1 > A + B) N--;
  }
  cout << N << endl;
}


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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main(){
  vector<int> vec(3);
  rep(i, 3){
    cin >> vec[i];
  }
  sort(all(vec));
  if((vec[0] == vec[1] && vec[1] != vec[2]) || vec[0] != vec[1] && vec[1] == vec[2]){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
A = list(map(int, input().split()))
A.sort()

# A[cut-1] < 0 and A[cut] >= 0
cut = 0
while cut < N and A[cut] < 0:
    cut += 1

if cut == 0:
    M = sum(A[1:]) - A[0]
    print(M)
    pair = [A[0], A[N-1]]
    for i in range(N-2):
        print(' '.join(map(str, pair)))
        pair = [pair[0] - pair[1], A[N-i-2]]
    pair.reverse()
    print(' '.join(map(str, pair)))

elif cut == N:
    M = A[-1] - sum(A[:N-1])
    print(M)
    pair = [A[N-1], A[0]]
    for i in range(N-2):
        print(' '.join(map(str, pair)))
        pair = [pair[0] - pair[1], A[i+1]]
    print(' '.join(map(str, pair)))

else:
    M = sum(A[cut:]) - sum(A[:cut])
    print(M)

    B = deque(A[cut:]) # Aの正の部分
    C = deque(A[:cut]) # Aの負の部分

    while len(B) != 1:
        pair = [C[-1], B[-1]]
        print(' '.join(map(str, pair)))
        b = B.pop()
        C[-1] = C[-1] - b
    
    b = B.pop()

    while len(C) != 0:
        pair = [b, C[0]]
        print(' '.join(map(str, pair)))
        c = C.popleft()
        b = b - c

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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if((A == B && B != C) || (B == C && C != A) || (C == A && A != B)) cout << "Yes" << endl;
    else cout << "No" << endl; 
}

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

int main(){
    long long n,a,b,sum,ans;

    cin >> n >> a >> b;

    if(a==0){
        puts("0");
        return 0;
    }

    sum = n/(a+b);
    ans = sum*a;

    
    ans += min(n%(a+b),a);
    
    
    cout << ans << endl;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll N;
vector<ll> a,b;

signed main() {
  cin>>N;
  a.resize(N+1);
  b.resize(N);
  rep(i,0,N+1)
    cin>>a[i];
  rep(i,0,N)
    cin>>b[i];
  ll ans = 0;
  for (int i=N-1; i>=0; i--) {
    ll x = min(a[i+1], b[i]);
    ans += x;
    a[i+1]-=x;
    b[i]-=x;

    ll y = min(a[i], b[i]);
    ans += y;
    a[i]-=y;
    b[i]-=y;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int d[200009];
int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>d[i];
	sort(d,d+n);
	cout<<d[n/2]-d[n/2-1]<<endl;
	return 0;
}

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

int main() {

	int a, b, c, d, s, t;
	cin >> a >> b >> c >> d;

	s = a*b;
	t = c*d;

	if (s >= t) {
		cout << s << endl;
	}
	else {
		cout << t << endl;
	}
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n;
    cin >> n;
    vt<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(all(a));

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += abs(a[i] - a[n / 2]);
    }
    
    cout << ans;
}


Measured memory_bytes: 4000
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <time.h> //for clock
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
using ll = long long;

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

    cout << b * (t / a) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

set<lli> a;
lli ans = 0;
lli n,q;

int main(){
    cin >> n;
    for(lli i = 0;i < n;i++){
        lli s;
        cin >> s;
        a.insert(s);
    }
    cin >> q;
    for(lli i = 0;i < q;i++){
        lli t;
        cin >> t;
        if(a.count(t)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5012
#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
int main (){
        int N;
        long long Max=0;
        
        cin >> N;
        
        int *ptr = new int[N+1];
        
        for (int i = 0; i < N; i++) {
                cin >> ptr[i];
                int c=0;
                while(ptr[i]%2 != 1){
                    ptr[i] /=2;
                    c++;
                }
                Max +=c;
        }
        
        cout << Max << endl;
 
        return 0;
}

Measured memory_bytes: 256
s=input()
a=int(s[:2])
b=int(s[2:])

def f(x):
	if x>0 and x<13:return True
	else: return False

if f(a):
	if f(b):print('AMBIGUOUS')
	else:print('MMYY')
else:
	if f(b):print('YYMM')
	else:print('NA')

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

const int N = 200005;

char s[N];
int a[N], sum[N];
int n, m;

const int mod = 1e9 + 7;

int main() {
	scanf("%d %s", &n, s);
    m = strlen(s);
    int cur = 0;
    for (int i = m-1; i >= 0; i --) {
        int t = (s[i] == 'B');
        if (cur ^ t) a[i] = -1;
        else a[i] = 1;
        cur ^= 1;
    }
    sum[0] = a[0];
    bool flag = 0;
    flag |= (sum[0] < 0);
    for (int i = 1; i < m; i ++) {
		sum[i] = sum[i-1] + a[i];
        flag |= (sum[i] < 0);
    }
    int ans = 1, g = 0;
	for (int i = 0; i < m; i ++) {
		if (a[i] == 1) {
			g ++;
            continue;
		}
        if (g == 0) {ans = 0; break;}
        ans = 1ll * ans * g % mod;
        g --;
	}
    if (g) ans = 0;
    if (ans) {
        for (int i = 1; i <= n; i ++) ans = 1ll * ans * i % mod;
    }
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2176