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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  for (auto & a : A)
    cin >> a;
  for (auto & b : B)
    cin >> b;
  auto cnt = N - M + 1;
  for (int i1 = 0; i1 < cnt; ++i1)
  {
    for (int j1 = 0; j1 < cnt; ++j1)
    {
      int i2, j2;
      for (i2 = i1; i2 < i1 + M; ++i2)
      {
        for (j2 = j1; j2 < j1 + M; ++j2)
        {
          if (A[i2][j2] != B[i2 - i1][j2 - j1])
            break;
        }
        if (j1 + M != j2)
          break;
      }
      if (i1 + M != i2)
        continue;
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h[] = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		int ans = 0;

		for (int i = 0; i < n; i++) {
			while (h[i] > 1) {
				ans++;
				h[i]--;
				for (int i2 = i + 1; i2 < h.length; i2++) {
					if (h[i2] > 1) {
						h[i2]--;
					} else {
						break;
					}
				}
			}
		}

		boolean start = false;
		boolean zero = false;
		boolean none = true;
		for (int i = 0; i < n; i++) {
			if (h[i] != 0) {
				none = false;
				start = true;
				if (zero == true) {
					ans++;
					zero = false;
				}
			}
			if (h[i] == 0 && none == false) {
				zero = true;
			}
		}

		if (none == false)
			ans++;

		System.out.println(ans);

	}
}


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

using namespace std;

set<int> mn,mx;

int data[200005];
unsigned long long ans=0;

int main()
{
  int n,i;

  scanf("%d",&n);
  for(int c=0;c<n;c++)
  {
    scanf("%d",&i);
    data[i]=c;
  }
  for(int c=1;c<=n;c++)
  {
    set<int>::iterator it;
    unsigned long long mncount,mxcount;

    it=mn.upper_bound(-data[c]);
    if (it==mn.end())mncount=data[c];
    else mncount=data[c]-(-(*it))-1;
    it=mx.upper_bound(data[c]);
    if (it==mx.end())mxcount=(n-1)-data[c];
    else mxcount=(*it)-data[c]-1;

    ans+=((mncount*mxcount)+(mncount+mxcount+1))*c;
    mn.insert(-data[c]);
    mx.insert(data[c]);
  }
  printf("%llu\n",ans);
}


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;

int main() {
    int N, M = 0;
    cin >> N;
    vi a(N), b(N);
    rep(i, N) cin >> a[i];
    repr(i, N) {
        ll asum = 0;
        rep1(j, N/(i+1) - 1) {
            asum += b[i + j*(i+1)];
        }
        asum %= 2;
        b[i] = (a[i] - asum + 2)%2;
        if(b[i] == 1) M++;
    }

    cout << M << "\n";
    rep(i, N) {
        if(b[i] == 1) cout << (i+1) << " ";
    }
    
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i, sz(v)) { if (i) os << " "; os << v[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a - mod; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
      solve();
    }
}

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

  ll ans = 0;
  rep(i, n) rep(j, m) {
    if (table[i][j]) continue;

    queue<pii> q;
    q.push(pii(i, j));
    table[i][j] = 1;

    int cnt = 0, cnt2 = 0;
    if (s[i][j] == '#') cnt++;
    else cnt2++;

    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, 1, 0, -1};
    while (!q.empty()) {
      int y = q.front().F, x = q.front().S;
      q.pop();

      rep(k, 4) { // debuged, i to k
        int ny = y + dy[k], nx = x + dx[k];
        if (ny < 0 || ny >= n || nx < 0 || nx >= m) continue;
        if (table[ny][nx]) continue;
        if (s[ny][nx] == s[y][x]) continue;

        if (s[ny][nx] == '#') cnt++;
        else cnt2++;
        table[ny][nx] = 1;
        q.push(pii(ny, nx));
      }
    }
    // cout << cnt << " " << cnt2 << endl;
    ans += 1LL * cnt * cnt2;
  }
  cout << ans << endl;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

string vow = "aeiou";

void solve ( int test_case )
{
    vs v { "Sunny" , "Cloudy" , "Rainy" } ;

    int i=0 ;
    string s ; cin >> s ;

    for ( ; i < 3 && v[i] != s ; i++ ) ;
    i ++ ;
    if ( i == 3 ) i = 0 ;

    cout << v[i] ;
}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		int []N = new int[str.length()];
		int sum=0;
		for(int i=0; i<str.length(); i++) {
			if(i==0) {
				N[0]=Integer.parseInt(str.substring(0,1));
			}
			else{
				String n = str.substring(i,i+1);
				N[i] = Integer.parseInt(n);
				if(N[i] == N[i-1]){
					N[i]=(N[i]==1)?0:1;
					sum++;
				}
			}
		}
		System.out.print(sum);
	}
}

Measured memory_bytes: 29792
n = int(input())
a = list(map(int, input().split()))

p = 1
b = []
for e, f in zip(a[:-1], a[1:]):
    if e == f:
        p += 1
    else:
        b.append(p)
        p = 1

b.append(p)

ans = 0
for e in b:
    ans += e // 2

print(ans)


Measured memory_bytes: 3060
import sys
stdin=sys.stdin

ns = lambda:stdin.readline().rstrip()
ni = lambda:int(stdin.readline().rstrip())
nm = lambda:map(int,stdin.readline().split())
nl = lambda:list(map(int,stdin.readline().split()))

N,M=nm()
Al=[0]*N
Wl=[0]*N
ac=0
wa=0
for i in range(M):
    tmp1,tmp2=map(str,stdin.readline().split())
    p=int(tmp1)-1
    s=tmp2
    if(s=='AC'):
        Al[p]+=1
        if(Al[p]==1):
            ac+=1
            wa+=Wl[p]
    else:
        Wl[p]+=1

ans=[ac,wa]
print(*ans)
        

Measured memory_bytes: 4724
#include<iostream>

using namespace std;


int main()
{
	int n,tmp1,tmp0;
	int arr[5001] = {0};
	int sum[5001] = { 0 };
	
	while (1) {
		cin >> n;
		if (n == 0) {
			break;
		}

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

		sum[0] = arr[0];
		int j = 0;
		for (int i = 1; i < n; i++) {
			tmp0 = arr[i - 1];
			tmp1 = arr[i];
			if (tmp1 * tmp0 > 0) {
				if (tmp1 > 0) {
					sum[j] += tmp1;
				}
				else {
					if (sum[j] > 0) {
						sum[j] += tmp1;
					}
					else {
						if (tmp1 > tmp0) {
							sum[j] = tmp1;
						}
					}		
				}	
			}
			else {
				++j;
				if (sum[j-1] > 0) {
					sum[j] = sum[j-1] + tmp1;
				}
				else {
					sum[j] = tmp1;
				}
			}
			//cout << "sum[" << j << "]=" << sum[j] << endl;
		}

		/*for (int i = 0; i <= j; i++) {
			cout << sum[i] << ends;
		}
		cout << endl;*/

		int max = sum[0];
		for (int i = 1; i <= j; i++) {
			if (sum[i] > max) {
				max = sum[i];
			}
		}
		cout << max << endl;
		
	}

	return 0;
}


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

int main() {
	string s;
	cin >> s;
	vector<string> date = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	rep(i, 7) {
		if (date[i] == s) {
			if (s == "SUN") cout << 7 << endl;
			else cout << 7 - i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b;
  scanf("%d %d", &a, &b);
  int c = a + b;
  if(c < a - b) c = a - b;
  if(c < a * b) c = a * b;
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
#B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k = I()
s = input()
n = len(s)
if n <= k:
    print(s)
else:
    print(s[:k] + '...')

Measured memory_bytes: 65304
def resolve():
    import sys
    sys.setrecursionlimit(10**6)
    
    N,M = map(int,input().split())
    ab =[map(int,input().split()) for _ in range(M)]
    branch = [[] for _ in range(N)]
    for a,b in ab:
        branch[a-1].append(b-1)
        branch[b-1].append(a-1)
    
    bit = 0
    count = 0
    def walk(p):
        nonlocal bit,N
        bit |= (1 << p)
        if bit == 2 ** N - 1:
            nonlocal count
            count += 1
        for n in branch[p]:
            if not(bit & (1 << n)):
                walk(n)
        bit &= ~(1 << p)

    walk(0)
    print(count)
resolve()

Measured memory_bytes: 42460
n, m, c = map(int, input().split())
bl = list(map(int, input().split()))
al = [list(map(int, input().split())) for _ in range(n)]

count = 0

for i in range(n):
    an = 0
    for j in range(m):
        an += al[i][j] * bl[j]

    if an + c > 0:
        count += 1

print(count)


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

bool isP(int x)
{
	if (x == 0 || x == 1)

	{
		return false;
	}
	else
	{
		for (int i = 2; i*i <= x; i++)
		{
			if (x%i == 0)
			{
				return false;
			}
			

		}
		return true;
	}
}

int main()
{
	int n, a, cnt = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		cnt += isP(a);
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3100
#include <stdio.h>

int main(void)
{
	int n,m;
	for(;;){
		bool flag[1001]={0};
		scanf("%d %d", &n, &m);
		if(n==0)break;
		for(int i=0,j=1,have=n;j<n;i++,have++){
			if(have>n){
				have=1;
			}
			if(flag[have]==0){
				if(i==m){
					i=0;
					j++;
					flag[have]=1;
				}
			}
			else i--;
			
		}
		for(int i=1;i<=n;i++){
			if(flag[i]==0){
				printf("%d\n",i);
				break;
			}
			
		}
	}
	return 0;
}

Measured memory_bytes: 0
# 2019/10/29



def divisors(n):
    div=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            div.append(i)
    div.sort()
    return div


n=int(input())
div=divisors(n)
res=float('inf')
for e in div:
    d=e+n//e-2
    res=min(res,d)
print(res)

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

string S;
int P = 2019;

long long solve(){
    vector<long long> val(P, 0);
    long long tenfactor = 1;
    long long cur = 0;
    val[cur]++;
    for (int i = 0; i < S.size(); i++)
    {
        cur = (cur + (S[S.size() - i - 1] - '0') * tenfactor) % P;
        tenfactor = (tenfactor * 10) % P;
        val[cur]++;
    }
    long long res = 0;
    for(int p = 0; p < P; p++) res += val[p] * (val[p] - 1) / 2;
    return res;
}

int main() {
    cin >> S;
    cout << solve() << endl;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int n; cin >> n;
        vector<int> a(3 * n); cin >> a;
        vector<ll> suf(3 * n);
        priority_queue<int> pq;
        ll sum = 0;
        for (int i = 3 * n - 1; i >= 0; i--) {
                if (sz(pq) < n) {
                        pq.emplace(a[i]);
                        sum += a[i];
                } else if (a[i] < pq.top()) {
                        sum += a[i] - pq.top();
                        pq.emplace(a[i]);
                        pq.pop();
                }
                suf[i] = sum;
        }

        sum = 0;
        while (sz(pq)) pq.pop();
        ll ans = -1e18;
        for (int i = 0; i < 3 * n; i++) {
                if (sz(pq) < n) {
                        pq.emplace(-a[i]);
                        sum += a[i];
                } else if (a[i] > -pq.top()) {
                        sum += a[i] + pq.top();
                        pq.emplace(-a[i]);
                        pq.pop();
                }
                if (i + 1 >= n && 3 * n - i - 1 >= n) {
                        ans = max(ans, sum - suf[i + 1]);
                }
        }

        cout << ans;

}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 7368
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int n; cin >> n;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    for (int i = n - 1; i >= 1; i--) {
        if (h[i-1] <= h[i])
            continue;
        else if (h[i-1] - h[i] == 1) {
            h[i-1] = h[i];
        } else {
            cout <<"No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int n,t; 
int f[200010];
long long ans;

int main() 
{
	cin>>n>>t;
	for (int i=1;i<=n;i++) scanf("%d",&f[i]);
	for (int i=1;i<n;i++) ans+=min(f[i+1]-f[i],t);
	cout<<ans+t<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  int v[n];
  long diff[n+1];
  long long sum = 0;
  REP(i,n){
    int a;
    cin >> a;
    v[i] = a;
    if (i != 0){
      diff[i] = abs(v[i] - v[i-1]);
    } 
    else{
      diff[0] = abs(v[0]);
    }
  }
  diff[n] = abs(v[n-1]);

  REP(i,n+1){
    sum += abs(diff[i]);
  }

  REP(i,n){
    if (i==0){
      cout << sum - diff[0] - diff[1] + abs(v[1]) << endl; 
    }
    else if (i==n-1){
      cout << sum - diff[n-1] - diff[n] + abs(v[n-2]) << endl; 
    }
    else {
      cout << sum - diff[i] - diff[i+1]  + abs(v[i+1] - v[i-1]) << endl; 
    }
  }

}



Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        System.out.println("a " + ((a > b)?">":(a == b)?"==":"<") + " b");
    }
}

Measured memory_bytes: 17320
#include <stdio.h>


int main(void){
  int n,ans=0;
  scanf("%d\n",&n );

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

  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      ans=ans+d[i]*d[j];
      //printf("%d*%d\n",d[i],d[j] );
    }
  }
  printf("%d\n",ans );

  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;

namespace kozaiyApp
{
    public class C
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]); // 展望台の数
            int M = int.Parse(input[1]); // 道の本数

            var AH = new List<List<int>>(); // 相手の標高

            int[] H = new int[N]; // 標高
            string[] inputH = Console.ReadLine().Split(' ');

            for (int i = 0; i < N; i++)
            {
                H[i] = int.Parse(inputH[i]);
                var ah = new List<int>();
                AH.Add(ah);
            }

            for (int i = 0; i < M; i++)
            {
                string[] inputT = Console.ReadLine().Split(' ');
                int A = int.Parse(inputT[0]) - 1;
                int B = int.Parse(inputT[1]) - 1;
                AH[A].Add(H[B]);
                AH[B].Add(H[A]);
            }

            int ans = 0;
            for (int i = 0; i < N; i++)
            {
                int q = 1; // 1なら自分の標高が一番高い
                // 相手の標高リストを確認して自分の標高が一番高ければans+1
                foreach (int h in AH[i])
                {
                    if (H[i] <= h)
                    {
                        q = 0;
                        break;
                    }
                }
                if (q == 1)
                {
                    ans += 1;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 60912
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#include <climits>
#include <deque>
#include <random>
#include <functional>
#include <unordered_map>
#define rep(i,n) for(int i=0;i < (int)(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
    ll a[1000];
    a[0] = 2;
    a[1] = 1;
    int n;
    cin >> n;
    rep(i,100){
        a[i+2] = a[i]+a[i+1];
    }
    cout << a[n] << endl;
    
}

Measured memory_bytes: 256
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;

int n,m;
ll a[86];
ll k;
string s;

int main() {
	cin >> n;

	a[0]=2;a[1]=1;
	FOR(i, 2, n+1){
		a[i] = a[i-1] + a[i-2];
	}
	cout << a[n] << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
string s;
long long x,y,z;
cin>>x>>y>>z;
if(x<=z)
 {   cout<<0<<" ";
 z-=x;
     if(y<=z)
        cout<<0;
     else cout<<y-z;

 }
 else cout<<x-z<<" "<<y;
return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//B
int main() {
	// your code goes here
	int n,i,k,h,ans=0;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> h;
		if(h>=k) ans++;
	}
	cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 256
/*Author SHUBH AGRAWAL  */

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
long long int modp(lld a,lld p,lld n)
{
    int d[100];
    int i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

long long int nCrModPFermat(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
    
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    
    lld fac[n+1]; 
    fac[0] = 1; 
    for (lld i=1 ; i<=n; i++) 
    fac[i] = fac[i-1]*i%p; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}

lld p1=1000000007,p2=998244353;
lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,n1,n2,h,z;
lld w,u;

lld d,p=1000000000;
bool chkpalin(string s)
{
    lld l=s.size();
    for(int i=0;i<l;i++)
    {
        if(s[i]!=s[l-1-i])
        {
            return false;
        }
    }
    return true;
}

void solve()
{
    cin>>l;
    printf("%f",(l*1.0*l*l)/27);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
   //cin>>t;
   for(int i=0;i<t;i++)
    {
     //   cout<<"Case #"<<i+1<<": ";
        solve();
    //    cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int n,q;
ll a[200000];
ll x[200000];
ll s1[200000],s2[200000];

int calc(ll c){
	int id=upper_bound(a,a+n,c)-a;
	if(id)id--;
	int l=id,r=n;
	while(r-l>1){
		int t=(l+r)/2;
		ll low=(a[t]-c);
		int p=lower_bound(a,a+id+1,c-low)-a;
		int cnt=t-p+1;
		if(t>=n-cnt)r=t;
		else l=t;
	}
	return l;
}
int main(){
	scanf("%d%d",&n,&q);
	rep(i,n){
		scanf("%lld",&a[i]);
		if(i%2==0)s1[i]+=a[i];
		if(i%2==1)s2[i]+=a[i];
		if(i){
			s1[i]+=s1[i-1];
			s2[i]+=s2[i-1];
		}
	}
	rep(i,q){
		scanf("%lld",&x[i]);
		if(abs(x[i]-a[n-2])>abs(x[i]-a[n-1])){
			printf("%lld\n",(n-1)%2==0?s1[n-1]:s2[n-1]);
		}
		else{
			int id=calc(x[i]);
			ll ans=(s1[n-1]+s2[n-1])-(s1[id]+s2[id]);
			ll cnt=n-1-id;
			ll e=id-cnt;
			if(e>=0){
				ans+=(e%2==0?s1[e]:s2[e]);
			}
			printf("%lld\n",ans);
		}
	}
}

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

using namespace std;

int main(int argc, char const *argv[])
{

	//freopen("inf.txt", "r", stdin); 
	//freopen("out.txt", "w", stdout); 
	    
	int a,b;
	cin>>a>>b;
	int start = b-a+1;
	int end = b+a-1;
	for(int i=max(start,-1000000);i<=min(end,1000000);i++) cout<<i<<" ";
	return 0;
}

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

#define forn(i,n) for( int i = 0 ; i < n ; ++i )
#define pb push_back
#define pf push_front
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define forll(it, cnt) for( auto &it : cnt )
#define endl '\n'
#define debug(x) cout << "[" << #x <<" = " << " ]" << endl
#define ff first
#define ss second
#define fast ios::sync_with_stdio(false); cin.tie(NULL)

int a[2][105];

int main(){
    fast;
    int n;
    cin >> n;
    for( int i = 0 ; i < n; ++ i){
        for( int j = 0 ; j < 2 ; ++j ){
            cin >> a[j][i];
        }
    }
    for( int i = 0 ; i <= n - 3 ; ++i ){
        int tot = 0;
        for( int j = i ; j <= i + 2 ; ++j ){
            if( a[0][j] == a[1][j] ) tot++;
        }
        if( tot == 3 ) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
N,K = input().split()
N = int(N)
K = int(K)

have = []
result = 0

for i in range(N):
    have.append([1]*K)


for i in range(K):
    d = int(input())
    
    A = input().split()
    A = map(int,A)

    for a in A:
        have[a-1][i-1] = 0

        
for j in have:
    if j == [1]*K:
        result += 1

print(result)

Measured memory_bytes: 9224
#include <iostream>
        using namespace std;
         
        int main(){
          int a, b;
          cin >> a;
          cin >> b;
          
          if(a % 2 == 0 || b % 2 == 0){
            cout << "No" << endl;
          }else{
            cout << "Yes" << endl; 
           }
          
          return 0;
        }

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

int main() {
  int H, W;

  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;

    for (int h=0;h<H;h++) {
      for (int w=0;w<W;w++)
        if ((w+h)%2 == 0)
          cout << "#";
        else
          cout << ".";
      cout << endl;
    }

    cout << endl;
  }
}



Measured memory_bytes: 3108
fun main(args: Array<String>) = println(run {
    val (n,l) = readLine()!!.split(" ").map { it.toInt() }

    val taste = (1..n).map { l+it-1 }
    val sum = taste.sum()
    taste.map { sum-it }.minBy { Math.abs(sum-it) }

})


Measured memory_bytes: 37904
n=int(input())
a=list(map(int,input().split()))

de=0 #最初の予定距離
for i in range(n-1):
  de+=abs(a[i+1]-a[i])
de+=abs(a[0])+abs(a[-1])

#リストの最初と最後に0追加すれば処理楽になる（？）
a.append(0)
a.insert(0,0)


for i in range(1,n+1):
  ans=de
  x=a[i-1]
  y=a[i]
  z=a[i+1]
  if a[i-1]<=a[i]<=a[i+1] or a[i-1]>=a[i]>=a[i+1]:
    pass
  elif x<=z<=y or y<=z<=x:
    ans-=abs(a[i]-a[i+1])*2
  else:
    ans-=abs(a[i]-a[i-1])*2
  print(ans)

Measured memory_bytes: 13920
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;
int d[5] = {0, 1, 0, -1, 0};
int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n >> m){
        vector<string> s(n + 2, string(m + 2, '#'));
        vector<vi> dp(n + 2, vi(m + 2, 0));
        queue<pii> q;
        REPS(i, n) {
            REPS(j, m) {
                cin >> s[i][j];
                if (s[i][j] == '#') {
                    dp[i][j] = 0;
                    q.emplace(i, j);
                } else {
                    dp[i][j] = MOD;
                }
            }
        }
        int ans = 0;
        while(!q.empty()) {
            int y, x; tie(y, x) = q.front(); q.pop();
            REP(k, 4) {
                int dy = y + d[k];
                int dx = x + d[k + 1];
                if (dp[dy][dx] == MOD) {
                    ans = dp[dy][dx] = dp[y][x] + 1;
                    q.emplace(dy, dx);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 13456
x,y,a,b,c = map (int ,input().split())
al = [int(x) for x in(input().split())]
bl = [int(x) for x in(input().split())]
cl = [int(x) for x in(input().split())]


al.sort()
bl.sort()

d = al[-x:]+bl[-y:]+cl
d.sort(reverse = True)
ans = 0
for i in range(x + y):
  ans += d[i]
print(ans)

Measured memory_bytes: 23340
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$N = $sc->nextInt();
$K = $sc->nextInt();

$ls = [];
for ($i = 0; $i < $N; $i++) {
    $ls[] = $sc->nextInt();
}
rsort($ls);

$max = 0;
for ($j = 0; $j < $K; $j++) {
    $max += $ls[$j];
  
}
echo $max;

Measured memory_bytes: 4856
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

//----------------------------------------


#include<random>

int main(void)
{

	int n;
	cin >> n;

	vector<int> d(n);

	rep(i, n) cin >> d[i];

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

	int low =d[n / 2 - 1];

	int up = d[n / 2];

	cout << up - low << endl;




}



Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

class UnionFind {
public:
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}

  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }

  void unite(int x, int y) {
    int px = find(x);
    int py = find(y);
    if (px != py) {
      if (data[py] < data[px]) swap(px, py);
      data[px] += data[py]; data[py] = px;
    }
  }
};


int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n+1);
  for (int i = 0; i < m; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    uf.unite(x, y);
  }
  int ans = 0;
  set<int> group;
  for (int i = 1; i <= n; ++i) {
    int id = uf.find(i);
    if (group.find(id) == group.end()) {
      ++ans;
      group.insert(id);
    }
  }
  cout << ans << endl;
}


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

int main(void){

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

    while(x!=0||y!=0){
        if(x<y)cout<<x<<" "<<y<<endl;
        else cout<<y<<" "<<x<<endl;
        cin>>x>>y;

    }
    return 0;

}



Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <map>

using Cost = int64_t;
using DistMat = std::vector< std::vector<Cost> >;

/**
 * Refine A by warshall-floyd.
 * \param A input distance matrix
 * \param out refined distance matrix
 * \param directs i->j is still direct after refinement(0: yes, -1: no)
 */
void warshall_floyd(
    const DistMat &A,
    DistMat &out,
    DistMat &directs)
{
  int N = (size_t) A.size();
  out.resize(N);
  directs.resize(N);
  for(int i=0; i<N; i++) {
    out[i].resize(N);
    directs[i].resize(N);
    for(int j=0; j<N; j++) {
      out[i][j] = A[i][j];
    }
  }

  // step
  for(int k=0; k<N; k++) {
    for(int i=0; i<N; i++) {
      for(int j=i+1; j<N; j++) {
        Cost d_prev = out[i][j], d_new = out[i][k] + out[k][j];
        if(d_new < d_prev) {  // impossible case
          out[i][j] = d_new;
          // std::cout << i << "->" << j << " impossible: " << d_new << " @k=" << k << std::endl;
        } else if(k != i && k != j && d_new == d_prev) {
          directs[i][j] = -1;
          // std::cout << i << "->" << j << " indirect: " << d_new << " @k=" << k << std::endl;
        } // in default, reserve outt[i][j]

        out[j][i] = out[i][j];
        directs[j][i] = directs[i][j];
      }
    }
  }
}

int main()
{
  // assume every path is direct
  // and then cut useless path

  // read input
  int N;
  std::cin >> N;

  DistMat A(N);
  for(int i=0; i<N; i++) {
    A[i].assign(N, 0);
    for(int j=0; j<N; j++) {
      std::cin >> A[i][j];
    }
  }

  DistMat mat_dists_wf;
  DistMat mat_directs;
  warshall_floyd(A, mat_dists_wf, mat_directs);

  // possibility and total costs
  Cost ret = 0;
  for(int i=0; i<N; i++) {
    for(int j=i+1; j<N; j++) {
      if(mat_dists_wf[i][j] < A[i][j]) {
        ret = -1;
        goto END;
      } else if(mat_directs[i][j] == 0) {
        // std::cout << i << ", " << j << ": " << A[i][j] << std::endl;
        ret += A[i][j];
      }
    }
  }

END:
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 5780
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]

graph = [[0] * N for _ in range(N)]
for u, v in edges:
    graph[u - 1][v - 1] = 1
    graph[v - 1][u - 1] = 1

visited = [False] * N
visited[0] = True

def dfs(s):    
    if all(visited):
        return 1

    cnt = 0
    for i in range(N):
        if visited[i] or graph[s][i] != 1:
            continue
            
        visited[i] = True
        cnt += dfs(i)
        visited[i] = False
        
    return cnt

print(dfs(0))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int dp[101][101];
int hisi[101][101];
int main()
{
    int temp=0;
    char t;
    string s;
    vector<int> nums;
    while(cin>>s)
    {
        if(cin.eof())break;
        int len = s.size();
        for(int i=0;i<len;i++)
        {
            if(s[i]==','){nums.push_back(temp);temp=0;}
            else{temp= temp*10 +(int) s[i]-'0';}
        }
        nums.push_back(temp);
        temp=0;
    }
    //cout << nums.size()<<endl;
    int hen = (int)sqrt((double)nums.size());
    int dan = 0;
    int k=0,x=0,y=0;
    for(dan=0;dan<hen;dan++)
    {
        x=0;
        y=dan;
        while(1)
        {
            hisi[x][y] = nums[k];
            //cout << x<<","<<y << endl;
            k++;
            x++;
            y--;
            
            if(y<0)break;
        }
    }
    for(dan=hen;dan<2*hen-1;dan++)
    {
        y = hen -1;
        x = dan-hen+1;
        //for(int s = 0;s<dana+1;s++)
        while(1)
        {
            hisi[x][y] = nums[k];
            k++;
            x++;
            y--;
            if(x==hen)break;
        }
    }
    dp[0][0] = hisi[0][0];
    for(int i=1;i<hen;i++)
    {
        dp[0][i] = dp[0][i-1]+hisi[0][i];
        dp[i][0] = dp[i-1][0]+hisi[i-1][0];
    }
    for(int j=1;j<hen;j++)
    {
        for(int i=1;i<hen;i++)
        {
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])+hisi[i][j];
        }
    }
    cout << dp[hen-1][hen-1]<<endl;
    //rep(j,hen){rep(i,hen){cout<<hisi[i][j];}cout<<endl;}
    return 0;
}

Measured memory_bytes: 0
s = input()
n = len(s)
L=[0]
R=[0]
cnt = 0

for i in range(n):
    if s[i] == '<':
        cnt += 1
    else:
        cnt = 0
    L.append(cnt)
cnt = 0
s = s[::-1]
for i in range(n):
    if s[i]  == '>':
        cnt += 1
    else:
        cnt = 0
    R.append(cnt)

R = R[::-1]
ans = 0
for i in range(n+1):
    ans += max(R[i], L[i])

print(ans)

Measured memory_bytes: 36860
#include<iostream>
using namespace std;
int main(){
	int h,w;
	cin>>h>>w;
	char a[h+2][w+2];
	for(int i=0;i<=h+1;i++)
		for(int j=0;j<=w+1;j++)
			a[i][j]='.';
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin>>a[i][j];
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			if(a[i][j]=='#'&&a[i+1][j]!='#'&&a[i-1][j]!='#'&&a[i][j+1]!='#'&&a[i][j-1]!='#'){
				cout<<"No"<<endl;
				return 0;
			}
	cout<<"Yes"<<endl;
	return 0;
}

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

using namespace std;

class Dice
{
  public:
    vector<int> diceNum;
    Dice(vector<int>& inputs);
    void toW();
    void toS();
    void ParallelRotation();
};

Dice::Dice(vector<int>& inputs)
{
  diceNum=inputs;
}

void Dice::toW()
{
  swap(diceNum[0],diceNum[3]);
  swap(diceNum[0],diceNum[5]);
  swap(diceNum[0],diceNum[2]);
}

void Dice::toS()
{
  swap(diceNum[0],diceNum[1]);
  swap(diceNum[0],diceNum[5]);
  swap(diceNum[0],diceNum[4]);
}

void Dice::ParallelRotation()
{
  swap(diceNum[1],diceNum[2]);
  swap(diceNum[2],diceNum[4]);
  swap(diceNum[4],diceNum[3]);
}

bool Judge(Dice& dice1,Dice& dice2)
{
  int count=0;
  for(int i=0;i<6;i++)
  {
    if(dice1.diceNum[i]==dice2.diceNum[i]) count++;
  }
  if(count==6)return true;
  else return false;
    
}

int main(int argc,char* argv[])
{
  vector<int> inputs(6);
  int count = 0;
  bool flag=false;
  for(int i=0;i<6;i++){cin >> inputs[i];}
  Dice dice1(inputs);
  for(int i=0;i<6;i++){cin >> inputs[i];}
  Dice dice2(inputs);

  while(1)
  {
    dice2.toS();
    for(int j=0;j<4;j++)
    {
      dice2.ParallelRotation();
      flag=Judge(dice1,dice2);
      if(flag==true) break;
    }
    if(flag==true) break;
    dice2.toW();
    for(int j=0;j<4;j++)
    {
      dice2.ParallelRotation();
      flag=Judge(dice1,dice2);
      if(flag==true) break;
    }
    count++;
    if(flag==true) break;
    if(count==3)break;
  }
  if(flag==true) cout << "Yes" << endl;
  else if(flag==false) cout << "No" << endl;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;

const int mx=200010;
const ll mod=1e9+7;

int n;
string s;
ll ans = 0;
map <string,int> mp;

int main() {
  cin >> n;
  for(int i = 0; i<n; i++){ 
    cin >> s;
    sort(s.begin(),s.end());
    ans += mp[s];    			//first time no count
    mp[s]++;
  }
  cout << ans << endl;

  return 0;
}  


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

int main(){
	/*input*/
	int n, d, x;	cin >> n >> d >> x;
	vector<int>a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	/*calculation*/
	int ans = x;
	for(int i = 0; i < n; i++){
		for(int tmp = 0; a[i]*tmp + 1 <= d; tmp++){
			ans++;
		}
	}
	/*output*/
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MN = 303;

int DP[MN][MN][MN];

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

    string S; cin >> S;
    int N = S.size();
    int K; cin >> K;

    memset(DP, 191, sizeof DP);
    for (int i = 0; i < N; ++i) DP[i][i][0] = 1, DP[i+1][i][0] = 0;

    for (int len = 0; len < N; ++len) {
        for (int i = 0; i+len <= N; ++i) {
            int j = i+len-1;
            if (j < 0) continue;
            for (int k = 0; k <= K; ++k) {
                if (i) DP[i-1][j][k] = max(DP[i][j][k], DP[i-1][j][k]);
                if (j < N-1) DP[i][j+1][k] = max(DP[i][j][k], DP[i][j+1][k]);
                if (i && j < N-1) DP[i-1][j+1][k+(S[i-1]!=S[j+1])] = max(DP[i][j][k]+2, DP[i-1][j+1][k+(S[i-1]!=S[j+1])]);
            }
        }
    }
    cout << *max_element(DP[0][N-1], DP[0][N-1]+K+1);
}


Measured memory_bytes: 112324
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<numeric>
using namespace std;

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

	int sum = accumulate(m.begin(), m.end(), 0);
	x -= sum;
	sort(m.begin(), m.end());
	cout << n + x / m[0] << endl;
}

Measured memory_bytes: 256
//28
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>

using namespace std;

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

int main(){
  for(int n;cin>>n,n;){
    vector<pair<int,int> > v;
    for(int i=0;i<n;i++){
      pair<int,int> p;
      cin>>p.first>>p.second;
      v.push_back(p);
    }
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
      pair<int,int> p;
      cin>>p.first>>p.second;
      v.push_back(p);
    }
    sort(v.begin(),v.end(),cmp);
    int ans=0;
    int ma[200];
    fill_n(ma,200,1<<30);
    for(int i=0;i<v.size();i++){
      int c=lower_bound(ma,ma+200,v[i].second)-ma;
      ans=max(ans,c);
      ma[c]=v[i].second;
    }
    cout<<ans+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
import java.math.BigInteger;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger N = new BigInteger(sc.next());
        sc.close();

        boolean b = false;
        for (int i=1; i<10; i++) {
            BigInteger d[] = N.divideAndRemainder(new BigInteger(Integer.toString(i)));
            if (d[1].compareTo(BigInteger.ZERO)==0 && d[0].compareTo(BigInteger.TEN)==-1) {
                b =true;
                break;
            }
        }

        if (b)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 22996
var stdin = require('fs').readFileSync('/dev/stdin', 'utf8');
  var input  = stdin.toString().trim().split('\n');
var S = parseInt(input[0], 10);
var h = Math.floor(S / (60 * 60));
var m = Math.floor(S % (60 * 60) / 60);
var s = Math.floor(S % 60);

  console.log([h,m,s].join(':'));

Measured memory_bytes: 15512
#pragma warning (disable :4996)
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-12;
#define For(i,n,m) for(int i=n;i<=m;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,l,r) for(int i=l;i>=r;--i)
#define clr(a,b) memset(a,b,sizeof(a))

ll n, m;
ll a[101000];
bool f[101000];
int main() {
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin >> n >> m;
	rep(i, 1, n) cin >> a[i];
	rep(i, 1, m) {
		ll x, y;
		cin >> x >> y;
		if (a[x] <= a[y]) f[x] = 1;
		if (a[y] <= a[x]) f[y] = 1;
	}
	ll cnt(0);
	rep(i, 1, n) if (!f[i]) ++cnt;
	cout << cnt << "\n";
	return 0;
}

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

int main(){
  int n,x;
  while (true)
  {
    cin >> n >> x;
    if(n == 0 && x == 0) return 0;
    int sum = 0;
    for (int a = 1; a <= n; a++)
    for (int b = a+1; b <= n; b++)
    for (int c = b+1; c <= n; c++)
    if (a + b + c == x) sum++;
    cout << sum << endl;
  }

}


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

#define int long long

signed main() {
    string N;
    cin >> N;
    if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


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

typedef long long int ll;


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

    if(a > b) swap(a,b);

    vector <ll> ay, by;
    for(ll i = 1;i * i <= a;i++){
        if(a % i == 0){
            ay.push_back(i);
            if(a / i != i){
                ay.push_back(a / i);
            }
        }
    }
    for(ll i = 1;i * i <= b;i++){
        if(b % i == 0){
            by.push_back(i);
            if(b / i != i){
                by.push_back(b / i);
            }
        }
    }

    sort(ay.begin(), ay.end());
    sort(by.begin(), by.end());

    vector<ll> cd;
    ll ac = 0, bc = 0;
    for(;;){
        if(ac == ay.size() || bc == by.size()) break;
        if(ay[ac] == by[bc]){
            cd.push_back(ay[ac]);
            ac++;
            bc++;
        }
        else if(ay[ac] > by[bc]){
            bc++;
        }
        else{
            ac++;
        }
    }

    ll ans = 0;
    for(ll i = 1;i < (ll)cd.size() - 1;i++){
        for(ll j = i + 1;j < (ll)cd.size();j++){
            if(cd[j] != 0 && cd[i] != 0){
                if(cd[j] % cd[i] == 0){
                    cd[j] = 0;
                }
            }
        }
    }

    for(ll i = 0;i < cd.size();i++){
        if(cd[i] != 0)ans++;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 512