akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    int n; cin >> n;
    int a[n];
    for ( int i = 0; i < n; i++ ) cin >> a [ i ];
    int ans = -1;
    /* 順番に並んでいる要素の個数 */
    int filledCount = 0;
    int currentIndex = -1;
    bool isExist = true;
    while( isExist ) {
        bool isFound = false;
        for ( int i = currentIndex+1; i < n; i++ ) {
                if( a [ i ] == filledCount + 1 ){
                    filledCount++;
                    currentIndex = i;
                    isFound = true;
                    break;
                }
        }
        if ( isFound ) continue;
        isExist = false;
    }
    if( filledCount == 0) 
        ans = -1;
    else
        ans = n - filledCount;
    cout << ans << endl;
    return 0;
}

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

using namespace std; 
const int MAX_N = 21; 
const long long MOD = 1000000007; 
long long dp[(1 << MAX_N) + 5];
int fact[MAX_N]; 
int a[MAX_N][MAX_N];
int n;
vector <int> V[(1 << MAX_N) + 5];   
vector <int> save[MAX_N];

int main () {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> n; 
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
	  	cin >> a[i][j]; 
		}
	}

	dp[0] = 1; 
	for (int mask = 1; mask < (1 << n); mask++) {
		int r = __builtin_popcount(mask); 
		for (int i = 0; i < n; i++) {
			if ((mask & (1 << i)) > 0) {
				if (a[r - 1][i] == 1) {
					(dp[mask] += dp[mask - (1 << i)]) %= MOD; 
				}
			}
		}
	}

	cout << dp[(1 << n) - 1]; 
	return 0; 
}

Measured memory_bytes: 65920
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef double db;
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define SZ(x) (int)(x.size())
#define sci(x) scanf("%d",&(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
ll modpow(ll x,ll n,ll mod){ll res=1;for(;n;n>>=1,x=x*x%mod)if(n&1)res=res*x%mod;return res;}
const db eps=1e-8,PI=acos(-1.0);
const int N=1e6+10,M=1e6+10,INF=0x3f3f3f3f,mod=1e9+7;//998244353
int k,n,a[N],ans; 
int main(){
	sci(k),sci(n);
	rep(i,0,n-1){
		sci(a[i]); 
	}
	rep(i,1,n-1){
		ans=max(ans,a[i]-a[i-1]);
	}
	ans=max(ans,k+a[0]-a[n-1]);
	printf("%d\n",k-ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}


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

int main() {
	int S,P,w,x,y,z,a,b,c,d;
	cin>>w>>x>>y>>z;
	S=w+x+y+z;
	cin>>a>>b>>c>>d;
	P=a+b+c+d;
	if(S==P){
		cout<<S<<endl;
	}
	else
	{int q = max(S,P);
	cout<<q<<endl;
	}
	return 0;
}

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

const int INF=99999999;


void get_network(int N,vector<vector<int>>& A){
    int s;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
                cin>>s;
                A[i][j]=s;
        }
    }
}

int main(){
        int n;
        scanf("%d\n",&n);
        vector<vector<int>> array(n,vector<int>(n,0));
        get_network(n,array);

        // flag
        vector<int> flag(n,-1);
        // parent nodes
        vector<int> p(n,0);
        // mincost
        vector<int> d(n,INF);

        p[0]=-1;
        d[0]=0;

        int mincost,u;
        while(true){
                // search mincost
                mincost=INF;
                for(int i=0;i<n;i++){
                        if(flag[i]!=1 && d[i]<mincost){
                                mincost=d[i];
                                u=i;
                        }
                }

                if(mincost==INF)break;

                flag[u]=1;

                for(int i=0;i<n;i++){
                        if(flag[i]!=1 && array[u][i]!=-1){
                                if(array[u][i]<d[i]){
                                        d[i]=array[u][i];
                                        p[i]=u;
                                        flag[i]=0;
                                }
                        }
                }
        }

        int w=0;
        for(int i=0;i<p.size();i++){
                if(p[i]!=-1){
                        w+=array[p[i]][i];
                }
        }
        printf("%d\n",w);


        return 0;
}


Measured memory_bytes: 3264
N, S = map(int, input().split())

*A, = map(int, input().split())

mod = 998244353

sumT = [0]*6005
sumT[0] = 1
sumT[A[0]] = 1

for a in A[1:]:
    for j in range(3001):
        sumT[j] *= 2

    for j in range(3000, -1, -1):
        sumT[j+a] += sumT[j] // 2
        sumT[j+a] %= mod
        sumT[j] %= mod

    sumT[0] += 1
    sumT[0] %= mod

    sumT[a] += 1
    sumT[a] %= mod


print(sumT[S] % mod)


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

int main(){
	ios::sync_with_stdio(0);
	int D,N;
	cin>>D>>N;
	int S=1;
	for(int i=0;i<D;++i)S*=100;
	if(N<=99){
		cout<<S*N<<"\n";
	}else{
		cout<<S*101<<"\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
    char s[124] = {'\0'};
    int len_s = 0;
    scanf("%s", s);
    while(s[len_s] != '\0') len_s++;
    printf("%c%d%c\n", s[0], len_s - 2, s[len_s - 1]);
    return 0;
}


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

int main() {
	string deck;
	int m, h;

	while(cin>>deck) {
		if(deck=="-") break;
		cin >> m;
		for(int i=0; i<m; i++) {
			cin >> h;
			deck =  deck.substr(h,deck.size()) + deck.substr(0, h);
		}
		cout << deck << endl;
	}

	return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    Fast;
    long long t,n,m,i,j,k,x=0,y=0,z=0,zz=0;
    cin>>n>>m;
    for(int i=1;i<=100000;i++)
    {
        x=i*0.08;
        y=i*0.1;
        if(x==n && y==m)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	string s; cin >> s;
	int ans=INF;
	REP(i,s.size()-2){
		ans=min(ans,abs(753-(100*(s[i]-'0')+10*(s[i+1]-'0')+(s[i+2]-'0'))));
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main(){
    
    int n,slime_num;
    cin >> n;
    slime_num = 1 << n;
    vi s(slime_num),tree,temptree;
    rep(i,slime_num)cin >> s[i];

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

    int index=slime_num-1;
    
    tree.push_back(s[index]);
    s[index] = -1;
    index--;
 
    rep(i,n){
        temptree = tree;
        sort(temptree.begin(),temptree.end());
        index = slime_num - 1;
        while(temptree.size() > 0 && index >= 0){
            if(s[index] == -1){
                index--;
                continue;
            }
            if(s[index] < temptree.back()){
                tree.push_back(s[index]);
                temptree.pop_back();
                s[index] = -1;
            }
            index--;
        }
        if(temptree.size() > 0){
            cout << "No" << endl;
            return 0;
        }
    }
 
    cout << "Yes" << endl;
 
    return 0;
}

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

#define N 1000
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define fastio ios::sync_with_stdio(false); cin.tie(0)

int main(){
    fastio;
    int n, m, l, r, maxi, mini;
    cin >> n >> m;
    for(int i = 0 ; i < m ; i++){
    	cin >> l >> r;
    	if(i == 0){
    		maxi = l;
    		mini = r;
    	} else {
    		maxi = max(l, maxi);
    		mini = min(r, mini);
    	}
    }

    cout << max(0, mini - maxi + 1) << endl;

    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    for(auto& i : a) cin >> i;
    for(auto& i : b) cin >> i;
    for(auto& i : c) cin >> i;
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());
    ll ans = 0;
    for(auto& i : b){
        ans += (lower_bound(a.begin(), a.end(), i) - a.begin()) * (c.end() - upper_bound(c.begin(), c.end(), i));
    }
    cout << ans << endl;
}



Measured memory_bytes: 2688
#include <bits/stdc++.h>
#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 pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N,M;
  cin>>N>>M;
  vector<pair<ll,string>> a(M);
  bool judge[N];
  rep(i,N) judge[i]=true;
  ll ac=0;
  ll ans=0;
  vl wa(N,0);
  for(int i=0;i<M;i++){
    cin>>a[i].first>>a[i].second;
  }
  for(int i=0;i<M;i++){
    if(a[i].second=="WA"&&judge[a[i].first-1]){
      wa[a[i].first-1]++;
    }
    else if(a[i].second=="AC"&&judge[a[i].first-1]){
      judge[a[i].first-1]=false;
      ac++;
      ans+=wa[a[i].first-1];
    }
  }
  cout<<ac<<" "<<ans<<endl;
}


Measured memory_bytes: 7888
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int R;
  cin >> R;
  if(R<1200)
    cout << "ABC" << endl;
  else if(R>=1200 && R<2800)
    cout << "ARC" << endl;
  else 
    cout << "AGC" << endl;
}


Measured memory_bytes: 256
N = int(input())

# x, y
start = [0, 0]

def get_tile(x, y):
    if x%2 == 0:
        if y %2 == 0: return 0
        else: return 1
    else:
        if y %2 == 0: return 1
        else: return 0


for i in range(N):
    t, x, y = map(int, input().split())
    tile_start = get_tile(start[0], start[1])
    tile_now = get_tile(x, y)

    if t % 2 == 0:
        if tile_start != tile_now:
            print('No')
            exit()
    else:
        if tile_start == tile_now:
            print('No')
            exit()

    if abs(x-start[0]) + abs(y-start[1]) > t:
        print('No')
        exit()

print('Yes')

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

long long dp[3100][3100];

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

    fill(dp[0], dp[N], 0);
    
    for (int k = 1; k <= N; k++) {
        for (int i = 0; i + k <= N; i++) {
            int j = i + k;
            
            if((N-k)%2==0){
                dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);
            }else{
                dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
            }
        }
    }

    cout << dp[0][N] << endl;
}

Measured memory_bytes: 73984
//	Totally unrelated and not AT ALL stolen from hohohaha's template
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/rope>

using namespace std;

#pragma GCC optimize("03")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define arctan atan
#define arccos acos
#define arcsin asin
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define vt vector
#define pr pair
#define u_map unordered_map
#define endl "\n"
//	Until next time, remember:
//			You are closer than you think.
//						_Dan Lok_

typedef double db;			typedef long long ll;		typedef long double ld;			typedef string str;
typedef pr<int, int> pii;	typedef pr<ll,ll> pll;		typedef pr<ld,ld> pdd;
typedef vt<int> vi;			typedef vt<ll> vll;			typedef vt<bool> vb;
typedef vt<str> vs;			typedef vt<pii> vpii;		typedef vt<pll> vpll;
typedef map<int, int> mii;	typedef map<int, bool> mib;	typedef map<int, str> mis;		typedef map<int, char> mic;
typedef complex<db> cpx;	typedef vt<cpx> vcpx;
//const int mod = 1e9+7;		const ll inf = 9223372036854775807;
#define pi 3.1415926535897932	//faster than pi = acos(-1); but sometimes doesn't work
//	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//	srand(chrono::steady_clock::now().time_since_epoch().count());
//	freopen("input.txt","r",stdin);

ll f(ll x)
{
	if (x < 1) return 0LL;
	ll res[] = {x,1,x+1,0};
	return res[x%4LL];
}

ll xor_range(ll a, ll  b)
{
	return (f(b) ^ f(a-1));
}
void input()
{
	ll l,r;
	cin >> l >> r;
	cout << xor_range(l,r);
}

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//	freopen("FILE.inp","r",stdin); freopen("FILE.out","w",stdout);
//	freopen("input.txt","r",stdin);
	input();
	return 0;
}
// with the aura of Dora, AC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1!!!!!!!!!!!!!!!!!!!!!!!!!
// Why is there node one in my row of exclamation marks?



Measured memory_bytes: 256
/*
   Username : moondancer
   Name : Moon Dancer
*/


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

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    int m1a=1e18, m2a=-1e18;
    int m1b=1e18, m2b=-1e18;
    set<pair<int,int>> s;
    for (int i = 0; i < n; ++i)
    {
        int x,y;
        cin>>x>>y;
        m1a=min(m1a,x+y);
        m2a=max(m2a,x+y);
        m1b=min(m1b,x-y);
        m2b=max(m2b,x-y);
    }
    int ans=max((-m1a+m2a), (-m1b+m2b));
    cout<<ans;
    // cout<<abs(m1-m2);
    return 0;
}

Measured memory_bytes: 3652
#include <string>
#include <math.h>
#include <iostream>

using namespace std;

int main()
{
  int wqwq;
  cin >> wqwq;
  string x;
  cin >> x;
    int a;
  cin >> a;
  int n = x.size();
  for (int i =0; i < n; i++) {
    if (x[i] == x[a - 1])
      cout << x[a - 1];
    else
      cout << '*';
  }
}

Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for(int i=0; i<n; i++){
        cout << s[i] << t[i];
    }
    cout << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <cmath>
using namespace std;

typedef long long ll;

int main(void){
    ll n , d;
    cin >> n >> d;
    vector<vector<ll> > x(n,vector<ll> (d,0));
    for(ll i = 0;i < n;i++){
        for(ll j = 0;j < d; j++){
            cin >> x[i][j];
        }
    }
    ll ans = 0;
    for(ll i = 0;i < n; i++){
        for(ll j = 0;j < n;j++){
            if(i != j){
                ll dis = 0;
                for(ll k = 0;k < d;k++){
                    dis += pow(x[i][k] -  x[j][k],2);
                }
                if(sqrt(dis) == (int)sqrt(dis)){
                    // cout << i << j << sqrt(dis) << " : " << (int)sqrt(dis) << endl;
                    ans++;
                }
            }
        }
    }
    cout << ans / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(m)]
class Unionfind():
    def __init__(self,n):
        self.n = n
        self.parents = [-1]*n
        
    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return 
                
        if self.parents[x] > self.parents[y]:
            x ,y = y,x
            
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        
    def size(self,x):
        return -self.parents[self.find(x)]
      
    def same(self,x,y):
        return self.find(x) == self.find(y)
 
ans = [n*(n-1)//2]
island = Unionfind(n)
for a,b in reversed(AB[1:]):
  if island.same(a-1,b-1):
    cnt = ans[-1]
  else:
    cnt = ans[-1]-island.size(a-1)*island.size(b-1)
    island.union(a-1,b-1)
  ans.append(cnt)
        
for a in reversed(ans):
    print(a)
    
    
    

Measured memory_bytes: 34632
use v5.18;
use warnings;
use Data::Dumper;
use List::Util qw( reduce sum );
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }
sub unique { my %u; $u{$_} = 1 for @_; keys %u; }

my $n = read_line;
my @nums = splited_read_line;
my @counter;
my ($before_num, $continuous) = ($nums[0], 0);
for my $i (1 .. $#nums) {
  my $num = $nums[$i];
  if ($num == $before_num) {
    $continuous = $continuous + 1;
  } else {
    push @counter, $continuous;
    $continuous = 0;
  }
  $before_num = $num;
}
push @counter, $continuous if $continuous > 0;
say( sum( map { int( ($_ + 1) / 2 ) } @counter ) // 0 );


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

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
ll cnt[27];
int main(){
	string str;
	cin>>str;
	ll n = str.size();
	ll ans = n * (n-1) / 2;
	for(int i=0;i<n;i++){
		cnt[ str[i] - 'a' ] ++;
	}
	for(int i=0;i<27;i++){
		ans -= cnt[i] * (cnt[i]-1) /2;
	}
	cout<<ans+1<<endl;
	return 0;
}

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

int a, b, c;

int main() {
	cin >> a >> b >> c;
	if(a > b)
		swap(a, b);
	if(a > c)
		swap(a, c);
	if(b > c)
		swap(b, c);
	int ans = 0;
	while(b != c) {
		a++, b++;
		ans++;
	}
	while(a < c) {
		ans++;
		a += 2;
	}
	if(a > b)
		ans++;
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define lp(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1 << (x))
using namespace std;

int N;
int M;
vector<vector<PLL>> roads;
vector<vector<LL>> fasts;

void dijkstra(int sp){
	fasts[sp][sp]=0;
	priority_queue<PLL, vector<PLL>, greater<PLL> > que;
	que.push({0, sp});
	while(!que.empty()){
		PLL d = que.top();
		que.pop();
		if(d.first != fasts[sp][d.second])continue;
		foreach(i, roads[d.second]){
			LL nf = i.second + d.first;
			if(fasts[sp][i.first]>nf){
				fasts[sp][i.first]=nf;
				que.push({nf, i.first});
			}
		}
	}
}

void culfasts(){
	fasts.resize(N, vector<LL>(N, INFLL));
	REP(i, N)dijkstra(i);
}

int main(){
	int R;
	cin >> N >> M >> R;
	vector<int> order(R);
	foreach(i, order){
		cin>>i;
		--i;
	}
	roads.resize(N);
	REP(i, M){
		LL a, b, c;
		cin>>a>>b>>c;
		--a;
		--b;
		roads[a].push_back({b, c});
		roads[b].push_back({a, c});
	}
	culfasts();
	sort(ALL(order));
	LL ans = INFLL;
	do{
		LL sum=0;
		REPA(i, R)sum+=fasts[order[i-1]][order[i]];
		ans=min(ans, sum);
	}while(next_permutation(ALL(order)));
	cout << ans << endl;
	return 0;
}


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

typedef pair<long long, long long> P;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int h,w;
string s[400];
bool b[400][400];

P f(int y, int x){
    long long c=0,d=0;
    b[y][x]=true;
    if(s[y][x]=='#'){
        c++;
    }else{
        d++;
    }
    for(int i=0;i<4;i++){
        int nx=x+dx[i],ny=y+dy[i];
        if(ny>=0&&ny<h&&nx>=0&&nx<w){
            if(!b[ny][nx]&&s[y][x]!=s[ny][nx]){
                P p=f(ny,nx);
                c+=p.first;
                d+=p.second;
            }
        }
    }
    return P(c,d);
}

int main(void){
    long long t=0;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>s[i];
        for(int j=0;j<w;j++){
            b[i][j]=false;
        }
    }
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(!b[i][j]){
                P p=f(i, j);
                t+=p.first*p.second;
            }
        }
    }
    
    cout<<t<<endl;
}


Measured memory_bytes: 20608
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int n, k;
  cin >> n >> k;
  int sum = 1;
  REP(i, k - 1) {
    sum += 2;
  }
  // cout << sum << endl;
  if (n >= sum) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


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

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif  

      long double a,b,h,m;
      cin>>a>>b>>h>>m;
      int tot=h*60+m;
      long double x=tot%(12*60);
      x*=(360.0)/(12*60);
      long double y=(tot%60);
      y*=(360.0)/(60);
      x*=(pi/180);
      y*=pi/180;
      x=abs(x-y);
      long double ans=sqrt(a*a+b*b-2*a*b*cos(x));
      cout<<fixed<<setprecision(12)<<ans;
}


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
vector<int>A;
void insertionSort(int g){
  for(int i=g;i<n;i++){
    int v=A[i];
    int j=i-g;
    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }
    A[j+g]=v;
  }
}
void shellSort(){
  int r=1;
  vector<int>G;
  while(r<=n){
    G.push_back(r);
    r*=2;
  }
  int m=G.size();
  reverse(G.begin(),G.end());
  cout<<m<<endl;
  for(int i=0;i<m;i++)cout<<G[i]<<" \n"[i==m-1];
  for(int i=0;i<m;i++)insertionSort(G[i]);
  cout<<cnt<<endl;
}
int main(){
  cin>>n;
  A.resize(n);
  for(int i=0;i<n;i++)cin>>A[i];
  shellSort();
  for(int i=0;i<n;i++)cout<<A[i]<<endl;
  return 0;
}



Measured memory_bytes: 6704
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		if ( k >= n ) {
			System.out.println(0);
			System.exit(0);
		}

		int[] h = new int[n];
		for ( int i=0; i<n; i++ ) {
			h[i] = sc.nextInt();
		}
		Arrays.sort(h);

		long t = 0;
		// 出力
		for ( int i=0; i<n-k; i++ ) {
			t = t + (long)h[i];
		}
		System.out.println(t);

	}
}

Measured memory_bytes: 86248
#include <iostream>
#include <sstream>
#include <stack>
#include <string>

void out(int n, int* a);

int main() {
	std::stack<int> s;
	std::string e;
	while (std::cin >> e) {
		if (e == "+") {
			int a = s.top();
			s.pop();
			int b = s.top();
			s.pop();
			s.push(b + a);
		} else if (e == "-") {
			int a = s.top();
			s.pop();
			int b = s.top();
			s.pop();
			s.push(b - a);
		} else if (e == "*") {
			int a = s.top();
			s.pop();
			int b = s.top();
			s.pop();
			s.push(b * a);
		} else {
			// s.push(std::stoi(e));
			std::stringstream ss;
			int d;
			ss << e;
			ss >> d;
			s.push(d);
		}
	}
	std::cout << s.top() << std::endl;
	return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mx,n,i,j,now,ha,len,m,b[1010],c[1010],fac[1010];
int main(){
	scanf("%lld",&n);
	fac[0]=1;
	for(i=1;i<=50;i++)fac[i]=fac[i-1]*2;
	mx=50;
	while(fac[mx]>n)mx--;
	n-=fac[mx];
	m=mx;
	//printf("%lld\n",mx);
	len=m*2;
	now=m;
	c[++ha]=now+1;
	c[++ha]=now+1;
	now++;
	len+=2;
	while(n){
		while(fac[mx]>n)mx--;
		n-=fac[mx];
		b[mx]=++now;
		c[++ha]=now;
		len+=2;
	}
	printf("%lld\n",len);
	for(i=0;i<=m;i++){
		if(i)printf("%lld ",i);
		if(b[i])printf("%lld ",b[i]);
	}
	for(i=1;i<=m;i++)printf("%lld ",i);
	for(i=1;i<=ha;i++)printf("%lld ",c[i]);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b;

    scanf("%d", &a);
    scanf("%d", &b);

    int ans = 0;
    for(int i=0; i<2; i++){
        if(a < b){
            ans += b;
            b--;
        }
        else{
            ans += a;
            a--;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>

using namespace std;

int Partition(int *A, int p, int r){
	int x = A[r];
	int i = p-1;
	for(int j=p; j<r; j++){
		if(A[j]<=x){
			i = i+1;
			int k = A[j];
            A[j] = A[i]; A[i] = k;
		}
	}
	int k = A[r];
	A[r] = A[i+1]; A[i+1] = k;
	return i+1;
}


int main(){
	int n;
	cin >> n;
	
	int *A;
	A = new int[n];
	for(int i=0;i<n;i++){
		scanf(" %d",&A[i]);
	}
	int p = Partition(A,0,n-1);
	for(int i=0;i<n;i++){
		if(i == p){
			printf("[%d]",A[p]);
		} else {
			printf("%d",A[i]);
		}
		if(i!=n-1) printf(" ");
		else printf("\n");
	}
	return 0;
}

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

bool is_square(int n) {
    int route = (int)sqrt((double)n);
    if (route * route == n) return true;
    return false; 
}

int main() {
    int64_t n, ans;
    cin >> n;
    for (int64_t i = n; i > 0; i--) {
        if (is_square(i)) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
g++ -std=c++14 E.cpp && ./a.out <<< "2 2
1 2
3 4
3 4
2 1"
*/

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

#define rep(i, a, b) for (int i = a; i < (b); i++)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

// Source: https://codeforces.com/blog/entry/62393
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int H, W; cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W, 0));
    vector<vector<int>> B(H, vector<int>(W, 0));
    rep(r, 0, H) rep(c, 0, W) cin >> A[r][c];
    rep(r, 0, H) rep(c, 0, W) cin >> B[r][c];

    vector<vector<vector<bool>>> Diffs(H, vector<vector<bool>>(W, vector<bool>(13000 * 2, false)));

    int a0 = A[0][0]; int b0 = B[0][0];
    Diffs[0][0][13000 + a0 - b0] = true;
    Diffs[0][0][13000 + b0 - a0] = true;

    rep(r, 0, H)
        rep(c, 0, W) {
            if (r == 0 && c == 0) continue;

            int a = A[r][c]; int b = B[r][c];
            int ab = a - b;

            auto& set = Diffs[r][c];

            if (r > 0) {
                auto& prev = Diffs[r - 1][c];
                rep(i, 0, 2 * 13000)
                    if (prev[i]) {
                        set[i + ab] = true;
                        set[i - ab] = true;
                    }
            }
            if (c > 0) {
                auto& prev = Diffs[r][c - 1];
                rep(i, 0, 2 * 13000)
                    if (prev[i]) {
                        set[i + ab] = true;
                        set[i - ab] = true;
                    }
            }
        }

    int ans = INT_MAX;
    auto& last = Diffs[H - 1][W - 1];
    rep(i, 0, 2 * 13000)
        if (last[i])
            ans = min(ans, abs(i - 13000));

    cout << ans << endl;
}

Measured memory_bytes: 23040
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000000007
#define MOD 1000000007
#define ARRAY_MAX 3005

int main(){

    string s;
    cin >> s;
    string str = "keyence";
    for(int i = 0;i <= 7;i++){
        string tmp = s.substr(0,i) + s.substr(s.length()-(7-i),7-i);
        if(tmp == str){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;



    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long[] ans=new long[n];
		PriorityQueue<Integer> q=new PriorityQueue<>();
		int[][] a=new int[n][2];
		for(int i=0; i<n; i++){
			a[i][0]=sc.nextInt();
			a[i][1]=i;
		}
		Arrays.sort(a,(x,y)->(x[0]-y[0]));
		int index=n-1;
		for(int i=n-1; i>=0; i--){
			while(index>=0 && a[i][0]==a[index][0]){
				q.add(a[index][1]);
				index--;
			}
			if(index<0){
				break;
			}
			ans[q.peek()]+=(long)(n-index-1)*(a[index+1][0]-a[index][0]);
			i=index+1;
		}
		ans[q.peek()]+=(long)n*a[0][0];
		for(int i=0; i<n; i++){
			System.out.println(ans[i]);
		}
	}
}


Measured memory_bytes: 74160
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll m; cin >> m;
    vector <bool> ac(n, false);
    vector <ll> wa(n, 0);
    REP(i, m){
        ll p; cin >> p; p--;
        string s; cin >> s;
        dump(p)
        dump(s)
        if (ac[p]){
            continue;
        }
        if (s == "AC"){
            ac[p] = true;
        } else {
            wa[p]++;
        }
    }
    ll acs = 0;
    REP(i, n){
        acs += ac[i];
    }
    cout << acs << " ";
    ll was = 0;
    REP(i, n){
        was += wa[i] * ac[i];
    }
    cout << was << endl;
    return 0;
}

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

using namespace std;

const int N = 200010;

int n, m;
int p[N], cnt[N];

int find(int x)
{
    if (p[x] != x) p[x] = find(p[x]);
    return p[x];
}
int sz[N];
bool st[N];
int main()
{
    cin >> n >> m;

    for (int i = 1; i <= n; i ++ )
    {
        p[i] = i;
        cnt[i] = 1;
    }

    while (m -- )
    {

        int a, b;
        cin >> a >> b;
      	a = find(a), b = find(b);
        if (a != b)
        {
                p[a] = b;
                cnt[b] += cnt[a];
         }
    }
  	int k = 0;
  	for(int i = 1; i <= n; i++)
    {
      	int r = find(i);
      	if(!st[r])
    		sz[k++] = cnt[r], st[r] = true; 
    }
  
  	sort(sz,sz+k);
  	int ans = 0;
  int sum = 0;
  //cout << sz[0] << endl;
  	for(int i = 0; i < k; i++)
    {
      //cout << sz[i] << endl;
    	ans += sz[i] - ans;
    }
  	cout << ans << endl;

    return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = 998244353;


inline void add(ll &x, ll y) {
	x += y;
	if (x >= MOD) {
		x -= MOD;
	}
}

const int B = 100010;
const int maxs = B * 2 + 100;

ll dp[2][4][maxs];

int main() {
	int N; cin >> N;
	vi a(N);
	rep(i, N) cin >> a[i];

	dp[0][0][B] = 1;
	int c = 0, f = 1;

	rep(i, N) {
		rep(j, maxs) rep(k, 4) dp[f][k][j] = 0;

		rep(j, maxs) {
			rep(b, 4) {
				if (dp[c][b][j] == 0) continue;
				add(dp[f][b][j + a[i]], dp[c][b][j]);
				add(dp[f][b | 1][j - a[i]], dp[c][b][j]);
				add(dp[f][b | 2][j - a[i]], dp[c][b][j]);
			}
		}

		swap(c, f);
	}

	ll ans = 0;
	for (int i = B; i < maxs; ++i) {
		add(ans, dp[c][3][i]);
	}

	ans = ans * 3 % MOD;

	ll all = 1;
	rep(i, N) all = all * 3 % MOD;
	ll dec = 1;
	rep(i, N) dec = dec * 2 % MOD;
	all = (all - dec * 3 + 3) % MOD;
	all -= ans;
	while (all < 0) all += MOD;

	cout << all << endl;

	return 0;
}

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

int main () {
    int a, b;
    cin >> a >> b;
    bool s = a > 9 || b > 9;
    if (s == 1) {
        cout << -1 << endl;
    }
    else if (s == 0) {
        cout << a * b << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// 二つの値の最大値を求める関数
Int Max(const Int a, const Int b) {
    if (a >= b) {
        return a;
    } else {
        return b;
    }
}
// 分数の Ceil を求める関数
UInt Ceil(const UInt a, const UInt b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return a / b + 1;
    }
}

int main(void) {
    double l;
    cin >> l;
    l /= 3.0;
    cout << fixed << setprecision(10) << l * l * l << endl;
    return 0;
}



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

int main(void) {
  double xa, ya, xb, yb, xc, yc, xd, yd;
  bool check;
  int BABC, CACD, DADB, CBCD, DBDA, ABAC, DCDA, ACAB, BCBD, ADAB, BDBC, CDCA;
  
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd) != EOF) {
    check = false;
    // AがBCDの内部にあるかどうかを調べる。
    BABC = (ya - yb)*(xc - xb) - (yc - yb)*(xa - xb);
    CACD = (ya - yc)*(xd - xc) - (yd - yc)*(xa - xc);
    DADB = (ya - yd)*(xb - xd) - (yb - yd)*(xa - xd);
    if((BABC > 0 && CACD > 0 && DADB > 0) || (BABC < 0 && CACD < 0 && DADB < 0)) {
      check = true;
    }
    // BがCDAの内部にあるかどうかを調べる。
    CBCD = (yb - yc)*(xd - xc) - (yd - yc)*(xb - xc);
    DBDA = (yb - yd)*(xa - xd) - (ya - xd)*(xb - xd);
    ABAC = (yb - ya)*(xc - xa) - (yc - ya)*(xb - xa);
    if((CBCD > 0 && DBDA > 0 && ABAC > 0) || (CBCD < 0 && DBDA < 0 && ABAC < 0)) {
      check = true;
    }
    // CがDABの内部にあるかどうかを調べる。
    DCDA = (yc - yd)*(xa - xd) - (ya - yd)*(xc - xd);
    ACAB = (yc - ya)*(xb - xa) - (yb - ya)*(xc - xa);
    BCBD = (yc - yb)*(xd - xb) - (yd - yb)*(xc - xb);
    if((DCDA > 0 && ACAB > 0 && BCBD > 0) || (DCDA < 0 && ACAB < 0 && BCBD < 0)) {
      check = true;
    }
    // DがABCの内部にあるかどうか調べる。
    ADAB = (yd - ya)*(xb - xa) - (yb - ya)*(xd - xa);
    BDBC = (yd - yb)*(xc - xb) - (yc - yb)*(xd - xb);
    CDCA = (yd - yc)*(xa - xc) - (ya - yc)*(xd - xc);
    if((ADAB > 0 && BDBC > 0 && CDCA > 0) || (ADAB < 0 && BDBC < 0 && CDCA < 0)) {
      check = true;
    }
    
    if(check) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
    }
  }
}


Measured memory_bytes: 3208
using System;
using System.Linq;
using System.Collections.Generic;
class P{
    class S{
        public long A=0,B=0;
        public S(long[] a){
            A=a[0];
            B=a[1];
        }
    }
    static void Main(){
        var l=Console.ReadLine().Split().Select(long.Parse).ToArray();
        long ans=0,count=0;
        var g=new S[l[0]];
        for(int i=0;i<l[0];i++)g[i]=new S(Console.ReadLine().Split().Select(long.Parse).ToArray());
        g=g.OrderBy(x=>x.A).ToArray();
        for(int i=0;count<l[1];count++){
            ans+=g[i].A;
            g[i].B--;
            if(g[i].B==0)i++;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27704
#include <fstream>
#include <iostream>
#include <vector>
#define nmax 100005
const int mod = 1000 * 1000 * 1000 + 7;

using namespace std;
vector <int> v[nmax];
int viz[nmax];
int dp[nmax][2];

void dfs(int x)
{
    viz[x] = 1;
    int p_alb = 1;
    int p_negru = 1;
    for (auto y : v[x])
        if (viz[y] == 0) {
            dfs(y);
            p_alb = (1LL * p_alb * (1LL * dp[y][0] + dp[y][1]) % mod) % mod;
            p_negru = (1LL * p_negru * dp[y][0]) % mod;
        }
    dp[x][0] = p_alb;
    dp[x][1] = p_negru;
}
int main()
{
    int i, n, a, b;
    cin >> n;
    for (i = 1; i < n; i++) {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(1);
    cout << (dp[1][0] + dp[1][1]) % mod;

    return 0;
}

Measured memory_bytes: 12416
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
    long long n, m;
    cin >> n >> m;

    if (n < m) {
        swap(n, m);
    }

    long long res = (n == m ? 2 : (n - 1 == m ? n : 0));
    if (res > 0) {
        for (long long i = m; i > 0; i--) {
            res *= i;
            res %= 1000000007;
            res *= i;
            res %= 1000000007;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  int N, K;
  int ans=0;

  cin >> N >> K;

  if(N >= 13){
    ans += K;
  }else if(N >= 6 && N <= 12){
    ans += K/2;
  }else{
    ans = 0;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    string s;
    cin >> s;
    for(int i = 0; i < (int)s.size(); i++) cout << 'x';
    cout << endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  vector<ll> l(n);
  rep(i, n)cin>>l[i];
//  l.erase(unique(l.begin(),l.end()), l.end());
//  n=l.size();

  int result=0;
  for(int i=0; i<n; i++)for(int j=i+1; j<n; j++)for(int k=j+1; k<n; k++){
//cout<<i<<' '<<j<<' '<<k<<endl;
    if(l[i]!=l[j] && l[i]!=l[k] && l[j]!=l[k] && l[i] < l[j]+l[k] && l[j] < l[k]+l[i] && l[k] < l[i]+l[j])result++;
//    if(l[i] < l[j]+l[k] && l[j] < l[k]+l[i] && l[k] < l[i]+l[j])cout<<i<<' '<<j<<' '<<k<<endl;
  }

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 3632
from collections import deque
n,x,y = map(int, input().split())
INF=1001001001001
x-=1
y-=1
mp=[list() for _ in range(n)]
for i in range(1,n-1):
    mp[i] = [i-1,i+1]

mp[0]=[1]
mp[-1]=[n-2]
mp[x].append(y)
mp[y].append(x)

ans=[0]*n

for i in range(n):
    dist=[INF]*n
    dist[i]=0
    d=deque()
    d.append(i)
    while d:
        s = d.popleft()
        for g in mp[s]:
            if dist[g]==INF:
                dist[g]=dist[s]+1
                d.append(g)

    for j in range(n):
        ans[dist[j]]+=1

for i in range(1,n):
    print(ans[i]//2)


Measured memory_bytes: 48476
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
  int n,k;
  cin >> n >> k;
  int x[n];
  for(int i=0;i<n;i++) cin >> x[i];
  int ans[n+1];
  for(int i=0;i<n+1;i++) ans[i] = 0;
  for(int i=1;i<=n;i++){
    vector<int> y(k);
    fill(y.begin(),y.end(),0);
    for(int j=1;j<=k;j++){
    	y[j-1] = ans[max(i-j,0)] + abs(x[i-1]-x[max(i-1-j,0)]);
    }
    ans[i] = *min_element(y.begin(),y.end());
  }
  cout << ans[n] << endl;
  return 0;
}
      
  


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long s[365][26]; 
int main() {
  int d;
  cin >>d;
  //int d=365;
  vector<int>c(26);
  vector<int>last(26,0);
  //vector<int>hinichi(26,0);
  long long wa=0;
  for(int i=0;i<26;i++){
    cin>>c[i];
    wa+=c[i];
  }
  for(int i=0;i<d;i++){
    for(int j=0;j<26;j++){
      cin>>s[i][j];
      s[i][j]-=c[i];
    }
  }
  //vector<int>t(d);
  //for(int i=0;i<d;i++)cin>>t[i];
  long long kotae=0;
  int hinichi=0;
  long long hikukazu=0;
  for(int i=0;i<d;i++){
    long long atai=0;
    for(int j=0;j<26;j++){
      if(atai<s[i][j]){
        atai=s[i][j];
        hinichi=j;
      }
    }
    hikukazu+=wa-c[hinichi]*(i+1-last[hinichi]);
    last[hinichi]=i+1;
    kotae+=atai-hikukazu;
    //cout<<wa<<" "<<c[hinichi]<<" "<<hikukazu<<" "<<s[i][hinichi]<<endl;
    cout<<hinichi+1<<endl;
  }
  return 0;
}
  


Measured memory_bytes: 3704
#include<stdio.h>
#include<string.h>

int main(){
    int i,change=0;
    char s[200001], t[200001];
    scanf("%s%s",s,t);
    for(i=0;i<200000;i++){
        if(s[i] == '\0'){
            break;
        }else if(s[i] != t[i]){
            change++;
        }
    }
    printf("%d\n", change);
    return 0;
}

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

int main() {
  int h, r;
  cin >> h >> r;

  if      ( h+r > 0 ) cout << 1 << endl;
  else if ( h+r < 0 ) cout << -1 << endl;
  else                cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <math.h>
#define y1 y11111

double x1,y1,x2,y2;
int main(){
	scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
	x2-=x1;
	y2-=y1;
	int q;
	scanf("%d",&q);
	while(q--){
		double x,y;
		scanf("%lf%lf",&x,&y);
		x-=x1;
		y-=y1;
		int c=x2*y-y2*x;
		if(c>0)puts("COUNTER_CLOCKWISE");
		else if(c<0)puts("CLOCKWISE");
		else{
			int r=x*x2+y*y2;
			if(r<0)puts("ONLINE_BACK");
			else if(r>x2*x2+y2*y2)puts("ONLINE_FRONT");
			else puts("ON_SEGMENT");
		}
	}
}


Measured memory_bytes: 2112
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main() {
	int X,k=0,ans=1,c=0;
	bool flag=false;
	cin>>X;
	for(int i=2;i<32;i++)
	{
		k=i;
		while(k<=X){
			k*=i;
			c++;
		}
		if(c>1)
		{
			ans=max(ans,k/i);
			c=0;
		}
	}
	cout<<ans;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define priority_queue pq
#define pu push
#define int long long int
#define loop for(int i=0;i<n;i++)
 int unitSum(int n)
{
    return (n*(n+1))/2;
}
int32_t main() 
{ 
int n;
cin>>n;
 int k=3*(unitSum(n/3))+5*unitSum(((n/5)))-15*unitSum((n/15));
int ans=(n*(n+1))/2;
cout<<ans-k;
}



Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
using namespace std;
int n,m,x,y,pos,ans,a[200005],cnt[200005],cc[200005];
int main()
{
	scanf("%d%d",&n,&m);
	ans=n;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)cnt[a[i]]++;
	for(int i=1;i<=n;i++)
	{
		pos=max(1,i-cnt[i]+1);
		for(int j=pos;j<=i;j++)
		{
			if(!cc[j])ans--;
			cc[j]++;
		}
	}
	while(m--)
	{
		scanf("%d%d",&x,&y);
		pos=a[x]-cnt[a[x]]+1;
		if(pos>0)
		{
			cc[pos]--;
			if(!cc[pos])ans++;
		}
		cnt[a[x]]--;
		a[x]=y;
		cnt[a[x]]++;
		pos=a[x]-cnt[a[x]]+1;
		if(pos>0)
		{
			if(!cc[pos])ans--;
			cc[pos]++;
		}
		printf("%d\n",ans);
	}
	return 0;
} 

Measured memory_bytes: 3712
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <tr1/unordered_set>
using namespace std;

int n , v[20] , ans = 0;

tr1::unordered_set<int> memo[20];

int X[421] , Y[421] , top;
 
int main(){
	while(scanf("%d\n",&n)&& n){
		int dp2[21] = {0};
		for(int i = 0 ; i < n ; i++) scanf("%d",&v[i]) , memo[i].clear();
		sort(v,v+n);
		for(int i = n-1 ; i >= 0 ; i--) dp2[i] = dp2[i+1] + v[i];
		ans = 99999999;
		top = 0;
		X[top] = 0;
		Y[top] = 0;
		while(~top){
			int pos = X[top] , sum = Y[top]; top--;
			if(pos==n) ans = min(ans,sum);
			else{
				if( sum >= dp2[pos] && ans <= sum-dp2[pos] ) continue;
				X[++top] = pos+1;
				Y[top]   = sum+v[pos];
				X[++top] = pos+1;
				Y[top]   = abs(sum-v[pos]);
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 932
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define LONGMAX 1e18
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define endl "\n"
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define INF 1e9
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll powe(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){ll mid=(low+high)/2;if(low>high)return;if(ar[mid]>=x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
int main()
{
	fastio();
    ll N;
    cin>>N;
    vector <pair<string,ll>> v(N);
    for(ll i=0;i<N;i++)
    {
        string s;
        ll a;
        cin>>s>>a;
        v[i]={s,a};
    }
    ll ans=0;
    string s;
    ll f=0;
    cin>>s;
    for(ll i=0;i<N;i++)
    {
        if(f==1)
            ans+=v[i].ss;
        if(s==v[i].ff)
            f=1;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a) for(int i = 0; i < (a); i++)
using namespace std;
signed main()
{
    int i = 1;
    while(true)
    {
        int x; cin >> x;
        if(x == 0) break;
        cout << "Case " << i << ": " << x << endl;
        i++;
    }
}


Measured memory_bytes: 3092
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

if N >= M:
    print(0)
else:
    Y = []
    for i in range(M-1):
        Y.append(X[i+1]-X[i])
    Y.sort()
    print(sum(Y[:M-N]))

Measured memory_bytes: 13968