akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m, d[MAX_N+5];
vector <int> G[MAX_N+5];
int f[MAX_N+5], s[MAX_N+5];
void topo() {
	queue <int> que; int ind = 0;
	for (int i = 1; i <= n; i++) if (!d[i]) que.push(i);
	while (!que.empty()) {
		int u = que.front(); que.pop(), s[++ind] = u;
		for (int v : G[u]) if (!--d[v]) que.push(v);
	}
}
int main() {
	read(n), read(m);
	for (int i = 1, u, v; i <= m; i++)
		read(u), read(v), d[v]++, G[u].push_back(v);
	topo();
	for (int i = n, u; i; i--)
		for (int v : G[u = s[i]])
			f[u] = max(f[u], f[v]+1);
	int mx = 0;
	for (int i = 1; i <= n; i++)
		mx = max(mx, f[i]);
	return printf("%d\n", mx), 0;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

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

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

  int sum = 0;
  for (int a = 1; a <= K; ++a) {
    for (int b = 1; b <= K; ++b) {
      for (int c = 1; c <= K; ++c) {
        sum += gcd(a, gcd(b, c));
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3636
// Graph II - Minimum Spanning Tree (AOJ)                         
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_ 12_A&lang=jp
// https://onlinejudge.u-aizu.ac.jp/#/problems/ALDS1_12_A
// 中央×前

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int P[10000];

// n個の頂点を初期化する
void init(int n) {
	for (int i = 0; i < n; i++) P[i] = i;
}

// 頂点の親の番号を返す
int root(int a) {
	if (P[a] == a) return a;
	return (P[a] = root(P[a]));
}

// 親(集合)が同じか判定する
bool is_same_set(int a, int b) {
	return root(a) == root(b);
}

// aとbを同一グループにまとめる
void unite(int a, int b) {
	P[root(a)] = root(b);
}

int main(void) {
	int n;
	cin >> n;
	vector<vector<int>> A(n, vector<int>(n, 0));
	vector<vector<int>> v;
	vector<int> w(3, 0);
	int a;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			cin >> a;
			w[0] = a;
			w[1] = i;
			w[2] = j;
			v.push_back(w);
		}
	}

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

	init(n);
	int sum = 0;

	for(vector<int> i : v) {
	//	cout << "("<< i[0] << "," << i[1] << "," << i[2] << ")" << endl;
		if (i[0] == -1) continue;
		if (is_same_set(i[1], i[2])) continue;
	//	cout << i[0] << "を追加！！" << endl;
		sum += i[0];
		unite(i[1], i[2]); 
	//	for(int j = 0; j < n; j++) cout << j << ":" << P[j] << "/";
	}
	cout << sum << endl;
}



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

int main() {
  
  string s;
    cin >> s;
  
  if ( s == "AAA" || s == "BBB" ) {
    cout << "No" << endl;
  }
  
  else { 
    cout << "Yes" << endl;
  }
  
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cmath>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

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

Int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}

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

int root_sum(int target, vi &parents, vi &nodes_value, vi &memo, int sum){
    if(memo[target] != -1){
        sum += memo[target];
        return sum;
    }
    if (parents[target] == target){
        sum+=nodes_value[target];
        return sum;
    }else{
        sum+=nodes_value[target];
        return root_sum(parents[target],parents, nodes_value, memo, sum);
    }
}


bool is_prime(int n, map<int,int> &memo){
    if(memo[n] == 1){
        return false;
    }else if(memo[n] == 2){
        return true;
    }

    bool prime = true;
    double sqrt_n = sqrt(double(n));
    for(int i =2; i<=max(2,int(sqrt_n)); i++){
        if(memo[i]==2 && n%i==0){
            prime = false;
        }
    }
    if(prime){
        memo[n] = 2;
    }else{
        memo[n] = 1;
    }

    return prime;
}

int main() {
    Int N;
    cin >> N;

    map<int,int> memo;
    memo[0]=1;
    memo[1]=1;
    memo[2]=2;
    vi answers;

    REP(i,2,55555){
        if(is_prime(i,memo) && i%5 == 1){
            answers.push_back(i);
        }

        if(answers.size() == N){
            break;
        }
    }

    rep(i,answers.size()){
        cout << answers[i] << " ";
    }
    cout << endl;


    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int a;
  vector<int> rate(9, 0);
  int min = 0;
  int max;

  for(int i = 0; i < N; i++){
    cin >> a;
    if(a < 3200){
      rate.at(a / 400)++;
    }
    else{
      rate.at(8)++;
    }
  }

  for(int i = 0; i < 8; i++){
    if(rate.at(i)){
      min++;
    }
  }

  max = min + rate.at(8);

  cout << (min==0?1:min) << " " << max << endl;

  return 0;
}


Measured memory_bytes: 384
import itertools
N,M=map(int,input().split())
s=[]
for _ in range(M):
    s.append(list(map(int,input().split()))[1:])
p=list(map(int,input().split()))
ans=0
for bit in itertools.product([0,1],repeat=N):
    count=[0]*M
    for light in range(M):
        for k in s[light]:
            count[light]+=bit[k-1]
    if all (count[i]%2==p[i] for i in range(M)):
        ans+=1
print(ans)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;

    if (S == U) A--;
    else B--;
    printf("%d %d\n", A, B);
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# Copyright (C) 2017 Sayutin Dmitry.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; version 3
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; If not, see <http://www.gnu.org/licenses/>.

def main():
    s = input().strip()
    print("Yes" if s.find("AC") != -1 else "No")

main()


Measured memory_bytes: 2940
/*
                                                  
  _|_|                              _|  _|    _|  
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|    
_|    _|  _|_|          _|          _|  _|_|      
_|    _|  _|          _|      _|    _|  _|  _|    
  _|_|    _|        _|_|_|_|    _|_|    _|    _|  
                                                                                                    
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
int main(){
    int n;cin>>n;
    if(n&(n-1)){
        cout<<"Yes"<<endl;
        cout<<"1 2"<<endl<<"2 3"<<endl<<"3 "<<n+1<<endl<<n+1<<' '<<n+2<<endl<<n+2<<' '<<n+3<<endl;
        for(int i=4;i+1<=n;i+=2){
            cout<<"1 "<<i<<endl<<i<<' '<<i+n+1<<endl;
            cout<<"1 "<<i+1<<endl<<i+1<<' '<<i+n<<endl;
        }
        if(n%2==0){
            rep(i,4,n){
                int tmp=i^1^n;
                if(tmp<n&&tmp!=3){
                    cout<<i<<' '<<2*n<<endl<<tmp<<' '<<n;
                    return 0;
                }
            }
        }
    }else{
        cout<<"No";
    }
    return 0;
}

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

int main(){
    int R;
    cin >> R;
    double leng;

    leng = 2 * 3.14 * R;

    cout << leng << endl;
    return 0;
}

Measured memory_bytes: 3764
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

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

    int mini = 100000;

    rep2(i, 1, (N / 2) + 1)
    {
        int a = i;
        int b = N - i;
        int tmp = 0;
        while (a != 0)
        {
            tmp += a % 10;
            a /= 10;
        }
        while (b != 0)
        {
            tmp += b % 10;
            b /= 10;
        }
        mini = min(mini, tmp);
    }
    cout << mini << endl;
}


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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i < (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

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

  i64 N;
  cin >> N;
  std::string S;
  getchar();
  getline(cin, S);

  vi W(N+1), E(N+1);
  W[0] = 0;
  E[0] = 0;

  i64 i;
  REP(0, N, i) {
    if(S[i] == 'W') {
      W[i+1] = W[i] + 1;
      E[i+1] = E[i];
    }
    else if(S[i] == 'E') {
      W[i+1] = W[i];
      E[i+1] = E[i] + 1;
    }
  }

  i64 ans = N;
  REP(0, N, i) {
    ans = min(ans, W[i] - W[0] + E[N] - E[i+1]);
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 5380
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	return (a%b?gcd(a%b,b):b);
	
}

int main()
{
	int N,c=1,ans=0,a;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>a;
		if(a==c)c++;
		else ans++;
	}
	cout<<(c==1?-1:ans);
}


Measured memory_bytes: 256
from itertools import product
n = int(input())
f = []
for i in range(n):
    f.append(list(map(int, input().split())))
p = []
for _ in range(n):
    p.append(list(map(int, input().split())))

schejule_list = list(product([0, 1], repeat=10))
ans = - float("inf")
for schedule in schejule_list:
    if schedule == (0,0,0,0,0,0,0,0,0,0):
        continue
    res = 0
    for i in range(n):
        kaburi = 0
        for j in range(10):
            kaburi += f[i][j] * schedule[j]
        res += p[i][kaburi]
    ans = max(ans, res)
print(ans)




Measured memory_bytes: 9236
a,b,c=map(int,input().split())
d=[]
for i in range(a):
    d.append(list(map(int,list(input().split()))))
e=[]
for i in range(b):
    e.append(list(map(int,list(input().split()))))
g=[]
f=[]
total=0
for k in range(a):
    for i in range(c):
        for j in range(b):
            total+=d[k][j]*e[j][i]
        f.append(total)
        total=0
    g.append(f)
    f=[]
for i in range(a):
    for j in range(c):
        if j==c-1:
            print("{}".format(g[i][j]),end= "") 
        else:
            print("{} ".format(g[i][j]),end= "")
    print()


Measured memory_bytes: 7060
#include<stdio.h>
#define N 100
int min(int a,int b){
    if(a<b) return a;
    else return b;
}
int main(){
    int n,r,c,i,j,k,l;
    int p[N+1],m[N+1][N+1];

    scanf("%d",&n);
    for(i=1;i<=n;i++) scanf("%d %d",&p[i-1],&p[i]);
    
    for(i=1;i<=n;i++) m[i][i]=0;

    for(l=2;l<=n;l++){
        for(i=1;i<=n-l+1;i++){
            j=i+l-1;
            m[i][j]=2000000000;    
            for(k=i;k<=j-1;k++){
                m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
    }
    printf("%d\n",m[1][n]);
    return 0;
}



Measured memory_bytes: 2108
#include <iostream>

using namespace std;

int n, c, d;
string s;
int main()
{
    cin >> n >> s;

    for (int i=0; i<s.size(); i++) {
        if (s[i] == '(')
            c++;
        else
            c--;
        d = min(d, c);
    }

    for (int i=0; i<-d; i++) {
        cout << "(";
    }
    cout << s;
    for (int i=0; i<c-d; i++) {
        cout << ")";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数list 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}

int main() {
    ll n;
    cin>>n;
    pr(pow(n, 3));
    return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define db cout << " HERE " << endl;
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 2000001;
int main() {
	int n ;
	cin >> n;
	ll pre[n];
	cin >> pre[0];
	ll ar[n];
	ar[0] = pre[0];
	FOR(i,1,n) {
		cin >> pre[i];
		ar[i] = pre[i];
		pre[i]+=pre[i-1];
	}
	ll ans = 0;
	F0R(i,n) {
		ans= ((ans)%MOD + ((ar[i]%MOD)*(((pre[n-1])%MOD-(pre[i])%MOD)+MOD)%MOD));
	}
	cout << ans << endl;
}
// template by benq


Measured memory_bytes: 6716
#include <bits/stdc++.h>
#define int long long int

using namespace std ;

const int N = 2000 , md = 1e9 + 7 ;
int dp[N][N] , n , m;
char c[N][N] ;

int32_t main(){
	cout << setprecision(30) << fixed ;
	cin >> n >> m ;
	dp[1][1] = 1 ; 
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= m ; j++){
			cin >> c[i][j] ;
			if(c[i][j] == '#')continue ;
			if(c[i - 1][j] == '.')dp[i][j] += dp[i - 1][j] ;
			if(c[i][j - 1] == '.')dp[i][j] += dp[i][j - 1] ;
			dp[i][j] %= md ;
		}
	}
	cout << dp[n][m] ;
	return 0 ; 
}
/*
#include <radman/roderc++.h>
                     ....._____
                 .~~~~~////////\\                                                                                           ...
              .:::::////////////\\                                          ....::////////..                              (/\\\\...
           .::::://////   \\\\///\\              .:::://                ..:::::///////////////.                           \\\\\$$$$$$
         \\\\\//////      \\\\///\\           //\\\//////             \\\\\////////////////////.                           ""\\$$$$$$$
         \\\\\////         \\\\////         |||||////////.            \\\\\/////     ~~~~~//////          ...                  "\$$$$
         \\\\\//\         ////|||/          \\\\\/////////            \\\\\//\       ~~~~~//////        (/\\\\...                   .
         \\\\\//\        ////|||/          |||||////*\\///.           \\\\\//\       ~~~~~//////        \\\\\$$$$$$                 .@@@@@.
         \\\\\//\       ////|||/           \\\\\///|\\\////           \\\\\//\       ~~~~~//////         ""\\$$$$$$$               @@@@////\
         \\\\\//\ ____---/|||/            |||||///|\\\\\///.          \\\\\//\       ~~~~~//////             "\$$$$                @@@@\///\
         \\\\\//\--|||||||_-'             \\\\\///|\\\\\////          \\\\\//\       ~~~~~//////                                  ,@@@@|///|
         \\\\\//\|||||_"-\\\\\           |||||///|  ~~~~~///.         \\\\\//\      ~~~~~//////     .@@@@.                    /@@@@@|/////
         \\\\\//\///"""\\\\\\\\          \\\\\///|~~~~[[[////.        \\\\\//\     ~~~~~//////      @@@@@@@@                ..@@@@@.//////
         \\\\\//\    \"""\\\\\\\        |||||///|~~[[[[["\////.       \\\\\//\    ~~~~~//////      '@@@@/////\       .:;@@@@@@@..///////"
         \\\\\//\      \"""\\\\\\       \\\\\///|[[[[*\\\\\////.      \\\\\//\   ~~~~~//////        *@@@\//////\@@@@@@@@..//////////"
         \\\\\//\       \:::\\\\/      |||||///|[[[*   \\\\\\///      \\\\\//\~~~~~///////'            *@@\/////////////////////"
         \\\\\//\        \___\\/       \\\\\///|*       \\\\\/"       \\\\\//\~~////////'                 **"///////////"""
         \\\\\//\                     |||||///|                       \\\\\//\///////"
         \\\\\//\                     \\\\\///|                       \\\\\//\////"
         \\\\\///                    |||||////|                       \\\\\////"
         \\\\\/"                     \\\\\///*                        \\\\\/"
                                     """""*
*/


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;

string s;

signed main() {
    cin >> s;
    rep(i,s.size()) if (s[i] == '7') {
            Yes
            return 0;
        }
    No
}





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

using namespace std;

int main() {
    long long N,A,B;
    cin >> N;
    cin >> A;
    cin >> B;

    long long sum = A+B;
    long long amari = N % sum;

    if(amari > A) amari = A;
    long long sho = N / sum;
    
    cout << amari + sho*A;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        long n = stdin.nextLong();
        long p = stdin.nextLong();

        if (n == 1) {
            System.out.println(p);
            System.exit(0);
        }

        long q = (long) Math.sqrt(p);
        long ans = 1;
        for (long i = 2; i <= q; i++) {
            long v = 0;
            while (p % i == 0) {
                v++;
                p /= i;
            }
            if (n <= v) {
                ans *= (long)Math.pow((double)i, (double)(v / n));
            }
        }
        System.out.println(ans);
    }

    private static boolean isPrime(long x) {
        if (x < 2) return false;
        if (x == 2) return true;
        if (x % 2 == 0) return false;
        for (long i = 3; i * i <= x; i += 2) {
            if (x % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

//3 3 1
//
//111 0
//112 1
//113 0
//121 2
//122 1
//123 2
//131 0
//132 1
//133 0
//211 1
//212 2
//213 1
//221 1
//222 0
//223 1
//231 1
//232 2
//233 1
//311 0
//312 1
//313 0
//321 2
//322 1
//323 2
//331 0
//332 1
//333 0
//
//24/27
//
//2値が隣あって出現する確率  
//全部6回ずつ 11,12,13,21,22,23,31,32,33
//6 * 9 = 54
//d = 1になるのは、
//6 * 4 = 24

//d = 0なら、n個
//i - d > 0 なら++
//i + d <= N なら++

int main(){
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    ll n,m,d;
    cin >> n >> m >> d;

    //全通り -> nのm乗

    //2値の組み合わせ -> n * n;
    //2値の組合わせ1つあたりの出現回数-> n^(m-2)
    
    //答えとなる組み合わせ 
    ll kumi = 0;
    if(d == 0)kumi = n;
    else
    {
        for(ll i = 1; i <= n; ++i)
        {
            if(i - d >= 1)++kumi;
            if(i + d <= n)++kumi;
        }
    }

    //2値の組合わせ1つあたりの出現回数
    //ll kaisu = pow(n,m-2) * (m-1);

    //kekka  =  kumi * n^(m-2) / n ^ m
    //=  kumi / n^n

    double res;
    res = (double)(m-1) * (double)kumi;

    //cout << kumi << endl;
    //cout << kaisu << endl;


    ll cnt = 0;
    //while(cnt < m)
    while(cnt < 2)
    {
        ++cnt;
        res /= double(n);
    }

    printf("%.12f\n",res);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int d;
  cin>>d;
  cout<<"Christmas";
  rep(i,0,25-d) cout<<" Eve";
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

using lli = int64_t;
using vi = vector<lli>;

int main()
{
    ios_base::sync_with_stdio(0);

    int n; cin >> n;

    vi v(n);

    lli sumr = 0;

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

    lli ans = LLONG_MAX;

    lli suml = 0;

    for(int i = 0; i < n - 1; i++)
    {
        suml += v[i];
        sumr -= v[i];

        ans = min(ans, lli(llabs(sumr - suml)));
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 998244353; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;


void solve() {
	int N, M, V, p; cin >> N >> M >> V >> p;
	vector<int>A(N);
	REP(i, N)cin >> A[i];
	VSORT(A); VREVERSE(A);
	int ok = p, ng = N + 1;
	//print_space(A);
	while (abs(ok - ng) > 1) {

		int mid = (ok + ng) / 2;
		//print(mid);
		int id = mid - 1;
		int rem = V;
		rem -= 1;
		if (A[id] + M < A[p - 1]) {
			ng = mid;
			continue;
		}
		rem -= (N - mid);
		rem -= p - 1;
		if (rem <= 0) {
			ok = mid;
			continue;
		}
		vector<int>tmp;
		for (int i = p - 1; i < id; i++)tmp.push_back(A[i]);
		//print_space(tmp);
		int las = A[id] + M;
		int mx = tmp[rem - 1];
		int addRem = M;
		//DEBUG(las);
		bool can = false;
		ll sum = 0;
		REP(i, tmp.size()) {
			sum += min(addRem, las - tmp[i]);
		}
		sum /= rem;
		if (sum >= addRem)can = true;
		if (can)ok = mid;
		else ng = mid;
	}
	print(ok);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 1596
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
import math
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
#INF = float("inf")
H,W = map(int,input().split())#頂点、辺の数
INF = float("inf")
cost = [list(map(int,input().split())) for _ in range(10)]
#実装
for k in range(10):
    for i in range(10):
        for j in range(10):
            cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j])
s = 0
for _ in range(H):
    A = list(map(int,input().split()))
    for k in A:
        if k == -1:
            continue
        s += cost[k][1]
print(s)

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  if ( N*A < B ) {
    cout << N*A << endl;
  }
  
  else if ( N*A > B ) {
    cout << B << endl;
  }
  
  else {
    cout << N*A << endl;
  }
  
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a) for (int i = (a); i >= 0; --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int fac[100005];
int rev[100005];

int C[51][51];  // C[n][k] -> nCk

void comb_table(int N) {
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= i; ++j) {
            if (j == 0 or j == i) {
                C[i][j] = 1LL;
            } else {
                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
            }
        }
    }
}

int N, A, B;
signed main() {
    cin >> N >> A >> B;

    map<int, int> count;
    vector<int> v(N);
    REP(i, N) {
        cin >> v[i];
        count[v[i]]++;
    }
    sort(v.begin(), v.end(), greater<int>());

    set<int> s;

    map<int, int> rest;
    int ans = 0;
    int last = 0;
    int r = A;
    REP(i, A) {
        ans += v[i];
        last = v[i];
        rest[v[i]]++;
    }
    printf("%.6f\n", (double)ans / A);

    comb_table(50);

    int ways = 0;
    if (v[0] != last) {
        ways = C[count[last]][rest[last]];
    } else {
        FOR(r, rest[last], min(rest[last] + B - A, count[last]) + 1) {
            ways += C[count[last]][r];
        }
    }
    cout << ways << endl;

    return 0;
}


Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 1e5 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}

ll dp[Max+2];

ll ara[Max],n;

ll call(ll val)
{
    //cout<<i<<" "<<val<<endl;

     ll &ret=dp[val];


       if(ret!=-1)
        return ret;

       if(val==0)return dp[val]=0;

       ret=0;

          for(ll i=0; i<n && !ret; i++)
          {
              if(ara[i]<=val)
                ret=!call(val-ara[i]);
          }

          return ret;


}


int main()
{

   fastread();

   ll i,j,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;


    memset(dp,-1,sizeof(dp));

      cin>>n>>m;

      input(ara,n);



        if(call(m))
            cout<<"First"<<endl;

        else cout<<"Second"<<endl;





}





Measured memory_bytes: 8648
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    bingo = []
    for i in range(3):
        bingo.append(list(map(int, lines.pop(0).split(' '))))
    bingo = sum(bingo, [])
    N = int(lines.pop(0))
    for i in range(N):
        a = int(lines.pop(0))
        if a in bingo:
            b = bingo.index(a)
            bingo[b] = -1
    atari = [
        [0,1,2],
        [3,4,5],
        [6,7,8],
        [0,3,6],
        [1,4,7],
        [2,5,8],
        [0,4,8],
        [2,4,6]
    ]

    for ax in atari:
        ok = True
        for i in ax:
            if not bingo[i] < 0:
                ok = False
                continue
        if ok:
            print('Yes')
            return
    print('No')


lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <bitset>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;
constexpr int MOD = 1e9 + 7;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

string s;

void input() {
  cin >> s;
}

void solve() {
  string ans = "Yes";

  if ((int)s.find("AB") * (int)s.find("BA") > 0)
    ans = "No";

  cout << ans << '\n';
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();

  int t = 1;

#ifdef _DEBUG
  t = 3;
#endif

  //  cin >> t;

  while (t--) {
    input();
    solve();
  }
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input!{
        n: usize,
        m: usize,
        h: [u64; n],
        ab: [(Usize1, Usize1); m],
    }
    let mut g: Vec<Vec<usize>> = vec![vec![]; n];
    for (a, b) in ab {
        g[a].push(b);
        g[b].push(a);
    }

    let mut ans = 0;
    for (i, row) in g.iter().enumerate() {
        let mut is_higher = true;
        for &r in row {
            if h[i] <= h[r] { 
                is_higher = false;
                break;
            };
        }
        if is_higher {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

const int INF = 1e8 + 7;
const int N = 1e5 + 8;

long long a[N];
int n;
int calc(int x, int k)
{
	int l = 0, r = k, res = -1;
	while (l <= r)
	{
		int mid = l + r >> 1;
		if ((long long)((2 * k - mid + 1) * mid / 2) <= x)
		{
			res = mid;
			l = mid + 1;
		}
		else r = mid - 1;
	} 
	return res;
}
int main()
{
	cin.sync_with_stdio(0);
	for (int i = 1; i < N; ++i) a[i] = (long long)i * (i + 1) / 2;
	while (cin >> n)
	{
		int k = lower_bound(a + 1, a + N, n) - a;
		int num = a[k] - n;
		int l = calc(num, k);
		for (int i = 1; i <= l; ++i) cout << '(';
		num = num - ((2 * k - l + 1) * l / 2);
		for (int j = 1; j <= k - num; ++j) cout << ')';
		cout << '(';
		for (int j = 1; j <= num; ++j) cout << ')';
		for (int i = 1; i <= k - l - 1; ++i) cout << '(';
		cout << endl;
	}
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(998244353)
#define PI 3.14159265358979323846264338327950L
// ------------------ Debugging ------------------
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "[ " << *it << " = " << a << " ] ";
    err(++it, args...);
}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}
template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
// -----------------------------------------------

signed main() {
    int n, k, d;
    cin >> n >> k >> d;

    n = abs(n);
    if (n/d >= k) {
    	cout << abs(n - k*d) << endl;
    } else {
    	k -= n/d;
    	if (k&1) {
    		cout << abs(n%d - d) << endl;
    	} else {
    		cout << n%d << endl;
    	}
    }
}



Measured memory_bytes: 3640
using System;
using System.Linq;

namespace ALDS1_5_D {
    class Problem {
        private int[] _nums, _workL, _workR;
        private long _count;

        public Problem(int[] nums,int n) {
            _nums = nums;

            int capacity = n / 2 + 2;
            _workL = new int[capacity];
            _workR = new int[capacity];

            // Run
            _count = 0;
            MergeSort(0, n);
        }

        public long Count {
            get { return _count; }
        }
        
        private void MergeSort(int left,int right) {
            if (left + 1 < right) {
                int mid = (left + right) / 2;
                MergeSort(left, mid);
                MergeSort(mid, right);
                Merge(left, mid, right);
            }
        }

        private void Merge(int left,int mid,int right) {
            int lenL = mid - left;
            for(int i = 0; i < lenL; i++) {
                _workL[i] = _nums[left + i];
            }
            _workL[lenL] = int.MaxValue;

            int lenR = right - mid;
            for(int i = 0; i < lenR; i++) {
                _workR[i] = _nums[mid + i];
            }
            _workR[lenR] = int.MaxValue;

            int indexL = 0;
            int indexR = 0;
            for(int i = left; i < right; i++) {
                if (_workL[indexL] <= _workR[indexR]) {
                    _nums[i] = _workL[indexL];
                    indexL++;
                    _count += indexR;
                }
                else {
                    _nums[i] = _workR[indexR];
                    indexR++;
                }
            }
        }
    }

    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            int[] arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Problem p = new Problem(arr, n);
            Console.WriteLine(p.Count);
        }
    }
}

Measured memory_bytes: 27752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x, a, b;
		x = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();
		x = x - a;
		if (x == 0)
			System.out.println(0);
		else {
			while (x > 0) {
				x -= b;
			}
			if(x < 0)
				System.out.println(x + b);
			else
				System.out.println(x);
		}
	}

}


Measured memory_bytes: 21332
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        String previous = null;
        Set<String> seen = new HashSet<>();
        for (int i = 0; i < n; i++) {
            String line = scanner.nextLine();
            if (seen.contains(line)) {
                System.out.println("No");
                return;
            }
            seen.add(line);

            if (previous != null && previous.charAt(previous.length() - 1) != line.charAt(0)) {
                System.out.println("No");
                return;
            }
            previous = line;
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int h,w,max_dis=0;
string a;
bool r[21][21],r1[21][21];
int dis[21][21];

void f(){
	for (us i=0;i<h;i++)
		for (us j=0;j<w;j++)
			r1[i][j]=r[i][j]^1;
}

void disz(){
	for (us i=0;i<h;i++)
		for (us j=0;j<w;j++)
			dis[i][j]=0;
}

void bfs(short a,short b){
	queue<pair<short,short>> q;
	q.push({a,b});
	r1[a][b]=true;
	while(!q.empty()){
		int x=q.front().first,y=q.front().second;
		q.pop();
		int u[4][2]={{x+1,y},{x-1,y},{x,y+1},{x,y-1}};
		for (us k=0;k<4;k++){
			short x_=u[k][0],y_=u[k][1];
			//cout<<x_<<" "<<y_<<"\n";
			if (x_<h&&x_>=0&&y_<w&&y_>=0){
				if (!r1[x_][y_]){
					//cout<<x_<<" "<<y_<<"\n";
					q.push({x_,y_});
					r1[x_][y_]=true;
					dis[x_][y_]=dis[x][y]+1;
					max_dis=max(max_dis,dis[x_][y_]);
				}
			}
		}
	}
}


int main()
{
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(15);
	cin>>h>>w;
	for (us i=0;i<h;i++){
		cin>>a;
		for (us j=0;j<w;j++){
			if (a[j]=='.')
				r[i][j]=true;
			else 
				r[i][j]=false;
		}
		a.clear();
	}
	for (us i=0;i<h;i++){
		for (us j=0;j<w;j++){
			if (r[i][j]){
				f();
				disz();
				bfs(i,j);
			}
		}
	}
	cout<<max_dis;
	return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
info = []
for i in range(N):
    x, y, h = getNM()
    info.append([x, y, h])
info.sort(reverse = True,key = lambda info:info[2])

ans = []
for i in range(101):
    for j in range(101):
        height = -1
        flag = True
        for k in range(N):
            minusx = abs(i - info[k][0])
            minusy = abs(j - info[k][1])
            if height == -1:
                # 上で逆順にソートしてるので確実に１以上の高さがでる
                height = info[k][2] + minusx + minusy
            else:
                # 問題の式に沿うように
                if info[k][2] != max(height - minusx - minusy, 0):
                    flag = False
                    break
        if flag:
            ans = [i, j, height]
print(*ans)

Measured memory_bytes: 43504
import java.util.Scanner;


public class Main{

	public static void main(String args[]){

		long MOD=1000000007L;

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();


		System.out.println(Math.min(a*n, b));
	}
}

Measured memory_bytes: 22100
n = gets.chomp.to_i
a = []
b = []
n.times do
 aa, bb = gets.chomp.split.map(&:to_i)
 a.push(aa)
 b.push(bb)
end

MOD = 1000000007

zero = 0
t = {}

n.times do |i|
  aa, bb = a[i], b[i]
  if aa == 0 && bb == 0
    zero += 1
    next
  end

  gc = aa.gcd(bb)
  aa /= gc
  bb /= gc
  if aa == 0
    bb = 1
  elsif bb == 0
    aa = 1
  elsif aa < 0
    aa *= (-1)
    bb *= (-1)
  end
  if t[[aa,bb]].nil?
    t[[aa,bb]] = 1
  else
    t[[aa,bb]] += 1
  end
end

ans = 1
t.each do |ar, num|
  aa, bb = ar
  if bb == 0
    aa = -1
  elsif bb < 0
    aa *= (-1)
    bb *= (-1)
  end
  u = t[[bb, -aa]] || 0
  t.delete([bb, -aa])
  tmp = 2 ** num - 1 + 2 ** u - 1 + 1
  ans *= tmp
  ans %= MOD
end

p (ans + zero - 1) % MOD


Measured memory_bytes: 36076
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	hh := make([]int, n)
	max := 0
	h := 0
	for i := 0; i < n; i++ {
		hh[i] = getNextInt(scanner)
		if i == 0 {
			continue
		}
		if max < h {
			max = h
		}
		if hh[i-1] < hh[i] {
			h = 0
		} else {
			h++
		}
	}

	if max < h {
		max = h
	}
	fmt.Fprintln(writer, max)
	writer.Flush()
}


Measured memory_bytes: 3584