akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
pll fdld(ll x){
    ll lad = x % 10;
    ll c = 0;
    ll p = 1;
    ll k = x;
    while(x > 0){
        p*=10;
        x/=10;
    }
    p/=10;
    ll fd = k/p;
    return make_pair(fd, lad);
}
void solve(){
    ll n;
    cin >> n;
    map<pll, ll> m;
    foa(i, 1, n + 1){
        pll x = fdld(i);
        //cout << x.ff << " " << x.ss << nl;
        m[x]++;
    }
    ll ans = 0;
    foa(i, 1, 10){
        foa(j, 1, 10){
            ans += m[{i, j}]*m[{j, i}];
        }
    }
    cout << ans << nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    while(TC--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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

using int64 = long long;
using uint64 = unsigned long long;

#define repeat(i, x) for (int64 i = 0; (i) < (x); (i)++)
#define rev_repeat(i, x) for (int64 i = (x) - 1; (i) >= 0; (i)--)
#define countup(i, n) for (int64 i = 0; (i) <= (n); (i)++)
#define countdown(i, n) for (int64 i = (n); (i) >= 0; (i)--)
#define range(i, a, b) for (int64 i = (a); (i) < (b); (i)++)
#define traverse(it, ctn) for (auto it = begin(ctn); (it) != end(ctn); (it)++)
#define rev_traverse(it, ctn) for (auto it = rbegin(ctn); (it) != rend(ctn); (it)++)

template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec)
{
    os << "[";
    repeat (i, vec.size())
    {
        os << (i == 0 ? "" : ", ") << vec[i];
    }
    os << "]";
    return os;
}

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

template<typename T>
ostream& operator<<(ostream& os, set<T>& s)
{
    os << "{";
    traverse (it, s)
    {
        if (it != s.begin()) os << ", ";
        os << *it;
    }
    os << "}";
    return os;
}

template<typename K, typename V>
ostream& operator<<(ostream& os, map<K, V>& m) 
{
    os << "{";
    traverse (it, m)
    {
        if (it != m.begin()) os << ", ";
        os << it->first << ": " << it->second;
    }
    os << "}";
    return os;
}

//
// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//

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

    int64 N, M;
    cin >> N >> M;

    vector<int64> A(N);
    repeat (i, N)
    {
        cin >> A[i];
    }

    vector<int64> cumAModM(N, 0);
    repeat (i, N)
    {
        cumAModM[i] = A[i] % M;
        if (i - 1 >= 0) 
        {
            cumAModM[i] = (cumAModM[i] + cumAModM[i - 1]) % M;
        }
    }

    map<int64, int> counter;

    int64 ans = 0;
    rev_repeat (i, N)
    {
        counter[cumAModM[i]]++;

        int64 offset = (i > 0) ? cumAModM[i - 1] : 0;
        ans += counter[offset];
    }

    cout << ans << endl;

    return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  int n; cin >> n;
  vector<string> s(n);
  REP(i,n) cin >> s[i];

  vector<int> c(26, 50);
  for (int i=0; i<n; i++) {
    vector<int> dc(26, 0);
    for (auto& v : s[i]) {
      dc[v-'a']++;
    }
    for (int j=0; j<26; j++) {
      c[j] = min(c[j], dc[j]);
    }
  }

  for (int i=0; i<26; i++) {
    for (int j=0; j<c[i]; j++) {
      cout << (char)(i+'a');
    }
  }
  cout << endl;
}

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


Measured memory_bytes: 256
n, k = map(int, input().strip().split())
mod = 10**9 + 7

def ssum(i):
    return i*(i+1)//2

ans = 0
for i in range(k, n+2):
    l,m = ssum(i-1), ssum(n)-ssum(n-i)
    ans += (m - l + 1)
    ans %= mod

print(ans)


Measured memory_bytes: 9188
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int cmp(void const*a,void const*b)
{
    return *(int*)a-*(int*)b;
}
int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        if((a+b)%3==0||a%3==0||b%3==0)
            printf("Possible\n");
        else
            printf("Impossible\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, a, b; cin >> n >> a >> b;
  a += b;
  string s; cin >> s;
  for(int i = 0; i < n; i++){
    if(s[i] == 'a'){
      if(a > 0) cout << "Yes" << endl;
      else cout << "No" << endl;
      a--;
    } else if(s[i] == 'b'){
      if(a > 0 && b > 0) a--, cout << "Yes" << endl;
      else cout << "No" << endl;
      b--;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 896
"""

https://atcoder.jp/contests/abc137/tasks/abc137_e

辺の重みからPを引いておく
→あとはベルマンフォード？

正の閉路探索→むずくね？
閉路があったとしても、増えなきゃあっていい…

→まずゴールにたどり着ける頂点を列挙
→たどり着けない点は無意味なのでremove

→あとはベルマンフォード
"""

import sys
sys.setrecursionlimit(200000)

N,M,P = map(int,input().split())

lis = [ [] for i in range(N) ]
rev = [ [] for i in range(N) ]
exist = [False] * N

for i in range(M):

    A,B,C = map(int,input().split())
    A -= 1
    B -= 1

    lis[A].append([B , C - P])
    rev[B].append(A)

def dfs(v):

    exist[v] = True
    for nex in rev[v]:
        if not exist[nex]:
            dfs(nex)

dfs(N-1)

dis = [float("-inf")] * N
dis[0] = 0

for i in range(N+1):

    flag = False

    for v in range(N):
        for uc in lis[v]:

            if exist[uc[0]] and dis[uc[0]] < dis[v] + uc[1]:
                #print (uc[0] , dis[v] + uc[1])
                dis[uc[0]] = dis[v] + uc[1]
                flag = True

if flag:
    print (-1)
else:
    print (max( 0 , dis[N-1] ))


Measured memory_bytes: 57704
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define len(a) (int)(a.length())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)

void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.in","r",stdin);
   freopen("output.out","w",stdout); 
   #endif
} 

int main(){
   //Fast_IO();
   ll n,k,sum=0;
   cin>>n>>k;
   ll a[n];
   f(i,0,n) cin>>a[i];
   sort(a,a+n);
   f(i,0,k) sum+=a[i];
   cout<<sum;
}






Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
using namespace std;

int main(){

    int x, y;
    cin >> x >> y;

    cout << x + y/2 << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n,a,b; cin>>n>>a>>b;
ll aa[n]={};
ll a1=0,a2=0,a3=0;
rep(i,n){
cin>>aa[i];
if(aa[i]<=a) a1++;
else if(aa[i]>=b+1) a3++;
else a2++;}
ll ca = min(a1,a2);
ca = min(a3 ,ca);
cout << ca << endl;}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void){
	ll a, b;
	cin >> a >> b;
	if (a > 0 && b > 1) {
		ll ans = 0;
		ans = min(a, b / 2);
		b -= 2 * ans;
		ans += b / 4;
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

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

int main()
{
	int N, M, oc = 1;
	string us;
	cin >> N;
	vector<string> users(N,"");
	for (int i = 0; i < N; i++) {
		cin >> users[i];
	}
	cin >> M;
	for (int i = 0;i < M;i++) {
		cin >> us;
		if (find(users.begin(), users.end(), us) != users.end()) {
			if (oc) {
				cout << "Opened by " << us << endl;
				oc = 0;
			} else {
				cout << "Closed by " << us << endl;
				oc = 1;
			}
		} else {
			cout << "Unknown " << us << endl;
		}
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> in(n);
  for(int i = 0;i<n;i++){
    cin >> in[i];
    in[i]--;
  }
  int ans = 0;
  for(int i = 0;i < n;i++){
    if (i == in[i]){
      ans++;
      if (i != n-1){
	swap(in[i], in[i+1]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b,c,d,e;
	scanf("%d %d %d",&a,&b,&c);
	d=b/a;
	e=min(d,c);
	printf("%d\n",e);
	return 0;
}

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


int main()
{
    ll A,B;
    cin >> A >> B;
    ll cnt=0;
    // while(1){
    //     if(cnt==0 && B!=1){
    //         B-=A;
    //         cnt++;
    //     }else if(cnt!=0){
    //         B-=(A-1);
    //         cnt++;
    //     }
    //     if(B<=0){
    //         break;
    //     }
    //     if(B==1 && cnt==0){
    //         break;
    //     }
    // }
    cout << (B-1+A-2)/(A-1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <functional>
#include <iostream>
#include <numeric>
#include <ctype.h>
#include <cmath>

int main()
{
    // number of matrix size N * N
    int A,P = 0;
    std::cin >>  A >> P;
    std::cout << int((3*A+P)/2) << '\n';

    // input matrix
    // int count = N;
    // while (count >= 1)
    // {
    //     for (int i = 0; i < count; )
    // }

    // std::tuple<int, int> t = std::make_tuple(1,1);

    // std::cout << std::get<0>(t) << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

/* -- template -- */

int main(){
    int H, W;cin >> H >> W;
    char s[H][W];
    rep(h, H){
        rep(w, W){
            cin >> s[h][w];
        }
    }
    for(int h = 0; h < H; ++h){
        for(int w = 0; w < W; ++w){
            bool flg = false;
            if(s[h][w] == '#'){
                if(h + 1 < H)
                    if(s[h + 1][w] == '#') flg = true;
                if(w + 1 < W)
                    if(s[h][w + 1] == '#') flg = true;
                if(h - 1 >= 0)
                    if(s[h - 1][w] == '#') flg = true;
                if(w - 1 >= 0)
                    if(s[h][w - 1] == '#') flg = true;
                if(!flg){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import math
List = input().split()
HP_T = int(List[0])
AT_T = int(List[1])
HP_A = int(List[2])
AT_A = int(List[3])
result = 0

Turn_T = math.ceil(HP_A/AT_T)
Turn_A = math.ceil(HP_T/AT_A)
if Turn_T - Turn_A == 0:
  result = "Yes"  
if Turn_T - Turn_A < 0:
  result = "Yes"
if Turn_T - Turn_A > 0:
  result = "No"

print(result)

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

#define MAX_NUM (1000000000 + 7)

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

i64 modinv(i64 a, i64 m) {
  i64 b = m, u = 1, v = 0;
  while (b) {
    i64 t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

u64 My_Comb(u64 n, u64 k, i64 m) {
  if (n < k) return 0;
  if (k == 0 || n == k) return 1;
  u64 res = 1;
  k = (n / 2 < k) ? n - k : k;
  for (u64 i = 1; i <= k; ++i)
    res = (((res * (n + 1 - i)) % m) * modinv(i, m)) % m;
  return res;
}

u64 My_Pow(u64 a, u64 n, i64 m) {
  u64 tmp = n, calc = 1;
  while (tmp > 0) {
    if (tmp % 2) {
      tmp--;
      calc *= a;
      calc %= m;
    } else {
      a *= a;
      a %= m;
      tmp /= 2;
    }
  }
  return calc;
}

int main() {
  cout << setprecision(18);
  i64 A, B, C, K;
  cin >> A >> B >> C >> K;
  i64 res = 0;
  if (K <= A) {
    cout << K << endl;
    return 0;
  } else {
    res += A;
    K -= A;
  }
  if (K <= B) {
    cout << res << endl;
    return 0;
  } else {
    K -= B;
  }
  res -= K;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

template<typename T> T gcd( T x, T y )
{
	return ( y ? gcd( y, x % y ) : x );
}


int main()
{
	long N;
	std::cin >> N;
	std::vector<long> v( N );

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

	// 累積GCDを左右から求める
	std::vector<long> left( N + 1, 0 );
	std::vector<long> right( N + 1, 0 );

	for ( int i = 0; i < N; i++ )
	{
		left[i + 1] = gcd( left[i], v[i] );
	}
	for ( int i = N - 1; i >= 0; i-- )
	{
		right[i] = gcd( right[i + 1], v[i] );
	}

	// 最大値を求める
	long result = 0;
	for ( int i = 0; i < N; i++ )
	{
		long lmax = left[i];
		long rmax = right[i + 1];
		long tmp = gcd( lmax, rmax );

		if ( result < tmp )
		{
			result = tmp;
		}
	}

	std::cout << result << std::endl;

	return ( 0 );
}


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

int n,a[1000005];
bool check(){
	int i,ans=0,tmp=0;
	for (i=1; i<=n; i++) ans=max(ans,a[i]);
	for (i=1; i<=n; i++) if (ans>a[i]+1) return 0;
	for (i=1; i<=n; i++) if (ans>a[i]) tmp++;
	int x,y;
	if (tmp==n) return ans==n; else{
		if (!tmp && ans==n-1) return 1;
		x=1; y=(n-tmp)/2;
		if (x+tmp<=ans && ans<=y+tmp) return 1; else return 0;
	}
}
int main(){
	scanf("%d",&n);
	int i;
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	puts(check()?"Yes":"No");
	return 0;
}


Measured memory_bytes: 640
N,M=map(int,input().split())
H=[int(x) for x in input().split()]
l=[1 for _ in range(N)]
for _ in range(M):
  A,B=map(int,input().split())
  if H[A-1] < H[B-1]:
    l[A-1] = 0
  elif H[A-1] == H[B-1]:
    l[A-1] = 0
    l[B-1] = 0
  else:
    l[B-1] = 0
print(sum(l))

Measured memory_bytes: 20124
import java.util.*;
public class Main{
	static int X,Y;
	static int[][] field;
	static boolean[][] done;
	static final int[] dx = {1,0,-1,0};
	static final int[] dy = {0,1,0,-1};
	static int ans;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			Y = sc.nextInt();
			X = sc.nextInt();
			if(X==0 & Y==0) break;
			
			field = new int[X][Y];
			done = new boolean[X][Y];
			for(int y = 0; y < Y; y++){
				char []input = sc.next().toCharArray();
				for(int x = 0; x < X; x++){
					done[x][y] = false;					
					if(input[x] == '#'){
						field[x][y] = 0;
					}else if(input[x] == '@'){
						field[x][y] = 1;
					}else if(input[x] == '*'){
						field[x][y] = 2;
					}
				}
			}
			ans = 0;
			for(int y = 0; y < Y; y++){
				for(int x = 0; x < X; x++){
					if(!done[x][y]){
						ans++;
//						dfs(x,y,field[x][y]);
						bfs(x,y,field[x][y]);
					}					
				}
			}
			System.out.println(ans);
		}
	}
	
	private static void bfs(int x, int y, int type) {
		LinkedList<xy> ll = new LinkedList<xy>();
		ll.add(new xy(x,y));
		while(!ll.isEmpty()){
			xy p = ll.poll();
			for(int i = 0; i < 4; i++){
				if(p.x+dx[i]<0 | p.x+dx[i]>=X) continue;
				if(p.y+dy[i]<0 | p.y+dy[i]>=Y) continue;
				if(done[p.x+dx[i]][p.y+dy[i]]) continue;
				if(field[p.x+dx[i]][p.y+dy[i]] != type) continue;
				done[p.x+dx[i]][p.y+dy[i]] = true;
				ll.add(new xy(p.x+dx[i], p.y+dy[i]));
			}
		}
	}

//	private static void dfs(int x, int y, int type) {
//		done[x][y] = true;
//		for(int i = 0; i < 4; i++){
//			if(x+dx[i]<0 | x+dx[i]>=X) continue;
//			if(y+dy[i]<0 | y+dy[i]>=Y) continue;
//			if(done[x+dx[i]][y+dy[i]]) continue;
//			if(field[x+dx[i]][y+dy[i]] != type) continue;
//			dfs(x+dx[i], y+dy[i], type);
//		}
//	}
}

class xy{
	int x,y;
	xy(int x, int y){
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 28908
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
	int n,a,b;
	cin>>n>>a>>b;
	if((b-a-1)%2 == 0){
		cout<<"Borys"<<endl;
	}
	else cout<<"Alice"<<endl;
	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define ll long long int
#define f first
#define s second
#define pb push_back
#define PII pair<ll,ll>
ll const MOD = 1000000007;
ll const N = 1000005;
ll const LN = 20;
ll const inf = 8e18;
using namespace std;

ll n, m, a[N];
vector<ll>v[N];
vector<ll>ok;
int main()
{
	ios::sync_with_stdio (false);
	cin.tie (NULL);
	string str;
	cin >> str;
	ll n = str.size();
	str = " " + str;
	if (str[1] == '0' || str[n] == '1')
	{
		cout << "-1";
		return 0;
	}
	ll past = n - 1;
	for (ll i = 1; i < n; i++)
	{
		if (str[i] != str[past])
		{
			cout << "-1";
			return 0;
		}
		past--;
	}
	for (ll i = 2; i <= n; i++)
	{
		ok.pb (i);
	}
	ll ver = 1;
	for (ll i = 1; i < n; i++)
	{
		if (str[i] == '1')
		{
			ll oo = ok.back();
			ok.pop_back();
			v[oo].pb (ver);
			v[ver].pb (oo);
			ver = oo;
		}
		else
		{
			ll oo = ok.back();
			ok.pop_back();
			v[ver].pb (oo);
			v[oo].pb (ver);
		}
	}
	for (ll i = 1; i <= n; i++)
	{
		for (auto w : v[i])
		{
			if (w > i)
			{
				cout << w << " " << i << '\n';
			}
		}
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N;
ll A[200000];
ll max_n[200000];

int main(){
    cin >> N;
    for(int i=0;i<=N;i++) cin >> A[i];
    max_n[0] = 1;
    for(int i=1;i<=N;i++){
        max_n[i] = (max_n[i-1] - A[i-1]) * 2;
        if(max_n[i] > 1e18){
            max_n[i] = 1e18;
        }
    }
    for(int i=0;i<=N;i++){
        if(max_n[i] < A[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    ll n = 0;
    ll ans = 0;
    for(int i=N;i>=0;i--){
        n += A[i];
        ans += min(max_n[i], n);
    }
    cout << ans << endl;
    return 0;
}

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

ll mod_pow(ll &a, int x, int y, int mod) {
  for (int i = 0; i < y; ++i) {
    a *= x;
    a %= mod;
  }
}

int main(){
  int mod = 998244353;
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; i++) cin >> d.at(i);
  if(d.at(0) != 0){
    cout << 0 << endl;
    return 0;
  }
  map<int, int> mp;
  ll ans = 1;
  for(int i = 0; i < n; i++) mp[d.at(i)]++;
  if(mp[0] != 1){
    cout << 0 << endl;
    return 0;
  }
  for(int i = 0; i < mp.size()-1; i++) {
    mod_pow(ans, mp[i], mp[i+1], mod);
  }
  if(mp[0] == 0) cout << 0 << endl;
  else cout << ans % mod << endl;
  return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main() {

	int N;
	string S;

	cin >> N;
	S.reserve( N+1 );
	cin >> S;

    int count[26];

    for ( int i = 0; i < 26; i ++ ) count[i] = 0;

    for ( int i = 0; i < N; i ++ ) {
        for ( int j = 0; j < 26; j ++ ) {
            if ( S[i] == 'a'+j ) count[j] ++;
        }
    }

    unsigned long res = 1;
    for ( int i = 0; i < 26; i ++ ) {
        if ( count[i] == 1 ) res *= 2;
        if ( count[i] > 1 ) res *= (count[i]+1); // res *= 3;

        res --;
        if ( res > 1000000007 ) {
        	res %= 1000000007;
        }
        res ++;
    }
    res --;

    res %= 1000000007;
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 384
#include <iostream>

template<typename X>
X input() {
	X value;
	std::cin >> value;
	return value;
}

template< 
	template< typename T = int, typename A = std::allocator<T> >
		class Container >
void display(Container< > lists) {
	for(typename Container<>::itertor it = lists.begin();
		it != lists.end(); ++it) {
		if( it != lists.begin() ) std::cout << " ";
		std::cout << (*it);
	}
	std::cout << std::endl;
}

void display(int *A, int N) {
	for(int i = 0; i < N; ++i) {
		if( i != 0 ) std::cout << " ";
		std::cout << A[ i ];
	}
	std::cout << std::endl;
}

void insertionSort(int *A, int N) {
	for(int i = 0; i < N; ++i) {
		int v = A[ i ]; // A[ i ] ?????????
		int j = i-1; // A[ j+1 ] ???????????????????????¨?????????
		while( 0 <= j && A[ j ] > v ) {
			A[ j+1 ] = A[ j ]; // ?????????????????´??????????????????
			j--;
		}
		A[ j+1 ] = v; // ?????????????????´????????\??????
		display( A, N);
	}
}

int main() {

	// 1 <= N <= 100 ?????????????????´??°?????°
	static const int N = input<int>();

	// 0 <= Ai <= 1,000 (0 <= i <= N-1)  ?????????????????´??°??????
	int A[ N ];
	for(int i = 0; i < N; ++i)
		A[ i ] = 0;

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

	insertionSort(A, N);
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+3;
ll DP[103][N];

int main()
{
        int n,w;
        cin>>n>>w;
        ll a[n+2][2];
        
        for(int i=1;i<=n;i++)
        {
                cin>>a[i][0]>>a[i][1];
        }
        for(int i=1;i<=n;i++)
        {
                for(int j=1;j<=w;j++)
                {
                        DP[i][j] = max(DP[i-1][j] , DP[i][j-1]);
                        if(j-a[i][0]>=0)
                        {
                                DP[i][j] = max(DP[i][j],a[i][1]+DP[i-1][j-a[i][0]]);
                        }
                }
        }
        cout<<DP[n][w];
        
}


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

int main() {
  int time;
  
  cin >> time;
  
  int hour = time / 3600;
  int hourAmari = time % 3600;
  int minute = hourAmari / 60;
  int second = hourAmari % 60;
  
  cout << hour << ":" << minute << ":" << second << endl;
     
  return 0;
}



Measured memory_bytes: 3128
n = int(input())
A = [int(i) for i in input().split()]

if any([a == 0 for a in A]):
    print(0)
    exit()

ans = 1
b = 10 ** 18
for a in A:
    ans *= a
    if ans > b:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 21480
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c,d;
    cin>>a;
    string s;
    cin>>s;
    ll sum=0;
    ll max1=0;
    for(int i=0;i<a;i++)
    {
        if(s[i]=='I')
        {
            sum++;
        }
        else
        {
            sum--;
        }
        max1=max(sum,max1);
    }
    cout<<max1<<endl;
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    double ans = 0;
    for(int i = 1; i <= N; i++){
        if(i >= K){
            ans += (double)1/(double)N;
        }else{
            double tmp = (double)1/(double)N;
            int n = i;
            while(n < K){
                tmp = tmp/2.0;
                n*=2;
            }
            ans += tmp;
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>

class Job{
private:
    std::string name;
    int sec;
public:
    Job(std::string name,int sec);
    int set_sec(int sec);
    std::string get_name();
    int get_sec();
    std::string to_string();
};

Job::Job(std::string name,int sec){
    this->name = name;
    this->sec = sec;
}

int Job::set_sec(int sec){
    this->sec = sec;
}

int Job::get_sec(){
    return this->sec;
}

std::string Job::get_name(){
    return this->name;
}

std::string Job::to_string(){
    return name + " " + std::to_string(sec);
}

int main(){
    
    std::queue<Job> jobQueue;
    
    int input_work = 0;
    int work_sec = 0;

    std::cin >> input_work >> work_sec;

    std::string process_name = "";
    int process_per_sec = 0;

    for(int i = 0;i < input_work;i++){
        std::cin >> process_name >> process_per_sec;
        jobQueue.push(Job(process_name,process_per_sec));
    }

    int result_sec = 0;
    std::vector<Job> jobFinish;

    while(!jobQueue.empty()){
        /*
        std::cout << jobQueue.front().to_string() << std::endl;
        jobQueue.pop();
        */
        Job tmpJ = jobQueue.front();
        jobQueue.pop();
        
        if(tmpJ.get_sec() - work_sec <= 0){
            result_sec += tmpJ.get_sec();
            jobFinish.push_back(Job(tmpJ.get_name(),result_sec));
        }else{
            result_sec += work_sec;
            int sec = tmpJ.get_sec() - work_sec;
            tmpJ.set_sec(sec);
            jobQueue.push(tmpJ);
        }
    }
    
    for(Job j : jobFinish){
        std::cout << j.to_string() << std::endl;
    }

    return 0;
}

Measured memory_bytes: 7084
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        int k = sc.nextInt();

        if (a[4] - a[0] > k) {
            out.println(":(");
            return;
        }

        out.println("Yay!");
    }
}

Measured memory_bytes: 21844
def main():
    n, m = map(int, input().split())
    p = 2**n
    inf = 10**7
    dp = [inf]*p
    dp[0] = 0
    for _ in range(m):
        a, _ = map(int, input().split())
        c = sum([1<<(int(i)-1) for i in input().split()])
        for s in range(p):
                t = s|c
                new = dp[s] + a
                if dp[t] > new:
                    dp[t] = new
    ans = dp[-1]
    if ans == inf:
        ans = -1
    print(ans)

if __name__ == '__main__':
    main()


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

names = []
points = []
ans = []

for i in range(N):
    name, point = str(input()).split(" ")
    point = int(point)
    ans.append(1)
    names.append(name)
    points.append(int(point))
    if i == 0:
        continue
    if i == 1:
        if name < names[0]:
            ans[0] += 1
        elif name == names[0] and point > points[0]:
            ans[0] += 1
        else:
            ans[1] += 1
        continue
    for j in range(len(ans) - 1):
        if name < names[j]:
            ans[j] += 1
        elif name == names[j] and point > points[j]:
            ans[j] += 1
        else:
            ans[i] += 1

for i in range(N):
    print(ans.index(min(ans)) + 1)
    ans[ans.index(min(ans))] = 101


Measured memory_bytes: 3064
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    string[3] s;
    scan(s[0]);
    scan(s[1]);
    scan(s[2]);
    long[3] n;
    long p;
    while (n[p] < s[p].length)
    {
        auto x = p;
        p = s[x][n[x]] - 'a';
        n[x]++;
    }
    writeln("ABC"[p]);
}


Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <list>
#define _USE_MATH_DEFINES
#include <math.h>
//#include <cmath>
#include <random>
#include <algorithm>

using std::cout;
using std::cerr;
using std::cin;
using std::endl;

using std::vector;
using std::list;
using std::string;
using std::pair;
using std::tuple;



void func();

int main() {
	func();
}

bool henkaku3(tuple<long double, long double, long double> v1, tuple<long double, long double, long double> v2) {
	long double t1 = std::get<0>(v1);
	long double t2 = std::get<0>(v2);
	return t1 < t2;
}

void func()
{
	int N;
	vector<tuple<long double, long double, long double> > V;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x;
		cin >> y;
		if (x == 0 && y == 0) {
			continue;
		}
		else {
			//pair<long double, long double> v((long double)x, (long double)y);
			long double t = atan2l(y,x);
			V.push_back(std::make_tuple(t, x, y));
		}
	}
	N = (int)V.size();
	for (int i = 0; i < N; ++i) {
		//cerr << std::get<0>(V[i]) << ", " << std::get<1>(V[i]) << ", " << std::get<2>(V[i]) << endl;
	}
	std::sort(V.begin(), V.end(), henkaku3);
	for (int i = 0; i < N; ++i) {
		//cerr << std::get<0>(V[i]) << ", " << std::get<1>(V[i]) << ", " << std::get<2>(V[i]) << endl;
	}

	long double r_max=0;
	for (int i = 0; i < N; ++i) {
		long double t0 = std::get<0>(V[i]);

		long double x0 = 0.0;
		long double y0 = 0.0;
		long double x1 = 0.0;
		long double y1 = 0.0;
		for (int j = 0; j < N; ++j) {
			long double t1 = std::get<0>(V[j]);
			long double t = t1 - t0;
			if (t < 0) {
				t +=  2 * M_PI;
			}
			if (t > 2 * M_PI) {
				t -= 2 * M_PI;
			}
			if (t >= 0 && t < M_PI) {
				x0 += std::get<1>(V[j]);
				y0 += std::get<2>(V[j]);
			}
			if (t > M_PI && t <= 2*M_PI) {
				x1 += std::get<1>(V[j]);
				y1 += std::get<2>(V[j]);
			}
		}
		long double r0 = sqrt(x0 * x0 + y0 * y0);
		long double r1 = sqrt(x1 * x1 + y1 * y1);
		r0 = std::max(r0, r1);
		r_max = std::max(r0,r_max);
	}
	cout <<std::fixed<<std::setprecision(50) <<r_max << endl;

}


Measured memory_bytes: 256
N,K=map(int, input().split())
A=list(map(int, input().split()))
F=list(map(int, input().split()))
A=sorted(A)
F=sorted(F)[::-1]
import numpy as np
a=np.array(A)
f=np.array(F)

low=-1
high=10**18

while high-low>1:
  d=(high+low)//2
  #0かa-d//fの大きい値を採用するnp.maximum　
  if np.maximum(0,a-d//f).sum()<=K:
    high=d
  else:
    low=d
print(high)

Measured memory_bytes: 34672
#include <iostream>

int main()
{
    int a = 0;
    int b = 0;
    
    // input
    std::cin >> a;
    std::cin >> b;
    
    if( a >= 1 && a <= 100 && b >= 0 && b <= 100 )
    {
        std::cout << a * b << " " << 2 * a + 2 * b << std::endl;
    }
    else
    {
        std::cout << "Error : out of range!" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3012
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        
        int i = 0;
        for(i = 0; i <= a || i <= b; i++){
            if(Math.abs(a - i) == Math.abs(b - i)){
                System.out.println(i);
                break;
            }
        }
        
        if(i > a && i > b){
             System.out.println("IMPOSSIBLE");
        }
    }
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll cnt[10][10];
    memset(cnt, 0, sizeof(cnt));
    for (ll i = 1; i <= n; i++) {
        string s = to_string(i);
        cnt[s.front() - '0'][s.back() - '0']++;
    }
    ll ans = 0;
    for (ll i = 0; i < 10; ++i) {
        for (ll j = 0; j < 10; ++j) {
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
    int n;
    char s;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%c",&s);
        if(s=='Y'){
            printf("Four");
            return 0;
        }
    }
    printf("Three");
    return 0;
}

Measured memory_bytes: 128
import java.io.*;

class Main
{
	public static void main(String args[]) throws IOException
	{
                BufferedReader br =
		new BufferedReader(new InputStreamReader(System.in));

                String str1 = br.readLine();
                String str2[] = str1.split(" ");
                int a = Integer.parseInt(str2[0]);
                int b = Integer.parseInt(str2[1]);
                int c = a*b;
                int d = 2*(a+b);
		System.out.println( c + " " + d );
	}
}

Measured memory_bytes: 24220
//
//  fizzbuzz.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>

using namespace std;
typedef long long ll;

int main(int argc, const char* argv[]) {
  int n;
  std::cin >> n;

  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    if ((i+1) % 3 != 0 && (i+1) % 5 != 0) {
      cnt += i+1;
    }
  }
  std::cout << cnt << std::endl;
  return 0;
}


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

using namespace std;

int n;
pair<int,int> a[105],b[105];
vector <int> graph[105];

int bpm(int a, int matched[], bool bio[]){
	for(int i = 0; i < graph[a].size(); i++){
		int vertex = graph[a][i];
		if(!bio[vertex]){
			bio[vertex] = 1;
			if(matched[vertex] < 0 || bpm(matched[vertex],matched,bio)){
				matched[vertex] = a;
				return 1;
			}
 		}
	}
	return 0;
}

int maxBPM(){
	int matched[105];
	memset(matched,-1,sizeof(matched));
	int res = 0;
	for(int i = 0; i < n; i++){
		bool bio[105];
		memset(bio,0,sizeof(bio));
		if(bpm(i,matched,bio)) res++;
	}
	return res;
}

int main(){
	cin >> n;
	
	for(int i = 0; i < n; i++){
		int x,y;
		cin >> x >> y;
		a[i].first = x, a[i].second = y;
	}
	for(int i = 0; i < n; i++){
		int x,y;
		cin >> x >> y;
		b[i].first = x, b[i].second = y;
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(b[i].first > a[j].first && b[i].second > a[j].second){
				graph[i].push_back(j);
			}
		}
	}
	
	cout << maxBPM();
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(b <= a){
        cout << "delicious" << endl;
    }
    else if(a+x >= b){
        cout << "safe" << endl;
    }
    else{
        cout << "dangerous" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, raw_input().split())
A = [raw_input() for i in range(N)]
B = [raw_input() for i in range(M)]
def judge():
    for i in range(N-M+1):
        for j in range(N-M+1):
            ok = True
            for r in range(M):
                for c in range(M):
                    if A[i+r][j+c] != B[r][c]:
                        ok = False
            if ok:
                return "Yes"
    return "No"
print judge()

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

int main(void)
{
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='?')break;
		switch(op)
		{
			case '+': printf("%d\n",a+b);break;
			case '-': printf("%d\n",a-b);break;
			case '*': printf("%d\n",a*b);break;
			case '/': printf("%d\n",a/b);break;
		}
	}
	return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;

namespace _0029
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string,int> dictionary = new Dictionary<string,int>();
            string[] s = Console.ReadLine().Split(); string max = "";
            for (int i = 0; i < s.Count(); i++)
            {
                if (!dictionary.ContainsKey(s[i])) dictionary[s[i]] = 0;
                dictionary[s[i]]++;
                if (s[i].Length > max.Length) max = s[i];
            }
            bool found = false;
            for (int i = s.Count(); !found; i--)
            {
                foreach (var j in dictionary)
                {
                    if (j.Value == i)
                    {
                        found = true;
                        Console.Write(j.Key);
                    }
                }
            }
            Console.WriteLine(" " + max);
        }
    }
}


Measured memory_bytes: 9176
from heapq import heapify, heappush, heappop
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
B = [0] * M
C = [0] * M
for i in range(M):
    B[i], C[i] = map(int, input().split())

cb = sorted(zip(C, B), reverse=True)

cnt = 0
exchange = []
for c, b in cb:
    exchange.extend([c] * b)
    cnt += b
    if cnt >= N:
        break

exchange.sort()

for _ in range(len(exchange)):
    m = heappop(A)
    heappush(A, max(m, exchange.pop()))

print(sum(A))

Measured memory_bytes: 24620
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		String str1=in.next(),str2=in.next();
		str1+=str1;
		if(str1.indexOf(str2)!=-1)out.println("Yes");
		else out.println("No");
		out.flush();
	}

}



Measured memory_bytes: 26200
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 - 1) * (n - 2) / 2) {
		    System.out.println(-1);
		    return;
		}
		StringBuilder sb = new StringBuilder();
		int count = 0;
		for (int i = 2; i <= n; i++) {
		    sb.append(1).append(" ").append(i).append("\n");
		    count++;
		}
		int task = 0;
		for (int i = 2; i <= n - 1 && task < (n - 1) * (n - 2) / 2 - k; i++) {
		    for (int j = i + 1; j <= n && task < (n - 1) * (n - 2) / 2 - k; j++) {
    		    sb.append(i).append(" ").append(j).append("\n");
    		    task++;
		    }
		}
		count += task;
		System.out.println(count);
		System.out.print(sb);
   }
}



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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              unsigned int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x);
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll m,ll mod);
ll pow2(ll n,ll k);
ll modinv(ll n,ll mod){  return pow1(n,mod-2,mod);}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
void solve(){
        ll i,j,k,l,n,m,y,z,r;
        
        cin>>k;
        string s;
        cin>>s;
        n=s.sz;
        if(n<=k){
                cout<<s<<endl;
        }
        else{
                s=s.substr(0,k);
                s+="...";
                cout<<s<<endl;
        }
        
        
        
}
int main(){
        FS;
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}
ll ceil1(ll n,ll x){
        return (n-1)/x+(n>0);
}
ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}
ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
int main(){
    int n, tmp, minv, ans = 0; sc(n);
    vector<int> h(n);
    for (int i = 0; i < n; i++) sc(h[i]);
    while(1){
        minv = 1000;
        for (int i = 0; i < n; i++){
            if (h[i] == 0) continue;
            minv = min(minv, h[i]);
        }
        if (minv == 1000) break;
        for (int i = 0; i < n; i++){
            if (h[i] == 0) continue;
            if (i == n - 1 || h[i+1] == 0) ans += minv;
            h[i] -= minv;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math
N = int(input())
sum = 0
for i in range(1,N+1):
    for j in range(i,N+1):
        for k in range(j,N+1):
            if i == j and j == k and k == i:
                sum += math.gcd(math.gcd(i,j),k)
            elif i != j and j != k and k != i:
                sum += 6 * math.gcd(math.gcd(i,j),k)
            else:
                sum += 3 * math.gcd(math.gcd(i,j),k)
print(sum)

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

int main()
{
 string s;
  cin>>s;
  
  if(s=="SUN")
    cout<<7;
  else if(s=="SAT")
    cout<<1;
  else if(s=="FRI")
    cout<<2;
  else if(s=="THU")
    cout<<3;
  else if(s=="WED")
    cout<<4;
  else if(s=="TUE")
    cout<<5;
  else if(s=="MON")
    cout<<6;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using Tuple = tuple<int, int, int>;




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

    int ans = 0;
    rep(i, n) {
        double aa = (a[i]+0.0000000001)/sum;
        double bb = 1.0/(4*m);
        if(aa >= bb) ans++;
    }

    if(ans >= m) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
//بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;


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

    string a, b;
    int x;
    cin >> a >> b;

    reverse(a.begin(),a.end());

    if( a == b)
        cout << "YES" << endl;
    else
        cout   << "NO" << endl;

    return 0;
}


Measured memory_bytes: 3624