akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
int main(){
	int N,A,B,C,D;cin>>N>>A>>B>>C>>D;
	string S;cin>>S;
	if(C<D){
		bool flag=true;
		rep(i,A-1,C-2){
			if(S.at(i)=='#'&&S.at(i+1)=='#'){
				flag=false;
                break;
			}
		}rep(i,B-1,D-2){
			if(S.at(i)=='#'&&S.at(i+1)=='#'){
				flag=false;
                break;
			}
		}
		if(flag==true){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else{
		bool flag1=true;
		rep(i,A-1,C-2){
			if(S.at(i)=='#'&&S.at(i+1)=='#'){
				flag1=false;
                break;
			}
		}bool flag2=false;
        int a,b,c;
        a=S.at(B-2);b=S.at(B-1);c=S.at(B);
		rep(i,B-2,D-1){
            if(a=='.'&&b=='.'&&c=='.'){
                flag2=true;
                break;
            }a=b;b=c;
            if(i!=D-2) c=S.at(i+3);
        }
        if(flag1==true&&flag2==true){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<int> pq;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        pq.push(a);
    }
    for(int i=0;i<m;i++){
        int t=pq.top();
        pq.pop();
        pq.push(t/2);
    }
    ll ans=0;
    while(pq.size()){
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 892
$k, $n = gets.split.map(&:to_i)
$a = gets.split.map(&:to_i)

def distance(from_idx, to_idx)
  if from_idx < to_idx
    $a[to_idx] - $a[from_idx]
  else
    $k - $a[from_idx] + $a[to_idx]
  end
end

answer = distance(0, $n - 1)
($n - 1).times do |i|
  d = distance(i + 1, i)
  if d < answer
    answer = d
  end
end

puts answer

Measured memory_bytes: 15364
lst = []

while True:
  p, s = map(int, input().split(","))
  if not p:
    break

  lst.append((s, p))

lst.sort(reverse=True)

dic = {}

rank = 0
solve_num = 0
for t in lst:
  if solve_num == t[0]:
    dic[t[1]] = rank
  else:
    rank += 1
    solve_num = t[0]
    dic[t[1]] = rank

while True:
  try:
    print(dic[int(input())])
  except EOFError:
    break



Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

int main() {
	vector<int> a(5);
	for (int i = 0; i < 5; i++) cin >> a[i];
	int ans = 1e9;
	do {
		int t = 0;
		for (int i = 0; i < 4; i++) {
			t += a[i];
			if (a[i] % 10 != 0) t += 10 - a[i] % 10;
		}
		t += a.back();
		ans = min(ans, t);
	} while (next_permutation(a.begin(), a.end()));
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n;
  cin >> n;
  vector<int> p(n), q(n), a(n);
  for(int i=1; i <= n; i++) a[i-1] = i;
  for(int i=0; i < n; i++) cin >> p[i];
  for(int i=0; i < n; i++) cin >> q[i];

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

  int pp, qq;
  int c = 0;
  do {
    c++;
    bool find = true;
    for(int i=0; i < a.size(); i++) {
      if(a[i] != p[i]){find = false; break;}
    }
    if(find) pp = c;

    find = true;
    for(int i=0; i < a.size(); i++) {
      if(a[i] != q[i]){find = false; break;}
    }
    if(find) qq = c;
  }while(next_permutation(a.begin(), a.end()));

  cout << abs(pp-qq) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
int s[1000];

int main(){
    int n;
    double m,sum,var,dev;
    while(1){
        sum = 0.0,var = 0.0,m = 0.0,dev = 0.0;
        scanf("%d",&n);
        if(n == 0)
            break;
        for(int i = 0;i < n;i++){
            scanf("%d",&s[i]);
            sum += s[i];
        }  
        m = sum / n;
        for(int i = 0;i < n;i++)
            var += (s[i] - m) * (s[i] - m);
        dev = sqrt(var/n);
        printf("%.8lf\n",dev);
    }

    return 0;
}


Measured memory_bytes: 2708
#include<stdio.h>
int main(){
    int x,i,div;
    int pn=0;
    scanf("%d",&x);

    for(;;){
        if(x==2){
            pn=x;
            break;
        }
        for(i=2;i<x;i++){
            div = x % i;
            if(div==0)
            break;
            if(x-1 == i){
                pn = x;
                break;
            }
        }
        if(pn != 0)
        break;
        else
        x= x+1;
    }
    printf("%d",pn);
    return 0;
}

Measured memory_bytes: 1732
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
using mint = modint998244353;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, M;
  cin >> N >> M;
  scc_graph g(N);
  REP(i, M) {
    int u, v;
    cin >> u >> v;
    g.add_edge(u, v);
  }
  vector<vector<int>> scc = g.scc();
  cout << scc.size() << "\n";
  REP(i, scc.size()) {
    cout << scc[i].size() << " ";
    REP(j, scc[i].size()) cout << scc[i][j] << (j!=scc[i].size()-1 ? " " : "");
    cout << "\n";
  }
}

Measured memory_bytes: 40116
a,b,c,d = map(int, input().split())
x = c - a
y = d - b

ans = 'R'*x + 'U'*y 
ans += 'L'*x + 'D'*y
ans += 'D'*1 + 'R'*(x+1) + 'U'*(y+1) + 'L'*1
ans += 'U'*1 + 'L'*(x+1) + 'D'*(y+1) + 'R'*1

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    rep(i,n/7+1){
        if((n-i*7)%4==0){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";

    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define int long
main(){
  int n,t0,t,a0,a;
  cin>>n;
  for(int i=0;i<n;++i){
    t0=t;a0=a;
    cin>>t>>a;
    if(i){
      int r=max(a0/a+(a0%a?1:0),t0/t+(t0%t?1:0));
      t*=r,a*=r;
    }
    cerr<<"("<<t0<<","<<a0<<")->("<<t<<","<<a<<")\n";
  }
  cout<<t+a;
}

Measured memory_bytes: 256
MOD = 998244353
N, K = map(int, input().split())
LR = [tuple(map(int, input().split())) for i in range(K)]

dp = [0] * (N+1)
dp[1] = 1
for i in range(1, N):
  dp[i] += dp[i-1]
  dp[i] %= MOD
  for l, r in LR:
    ll = i + l
    rr = i + r
    if ll <= N:
      dp[ll] += dp[i]
      dp[ll] %= MOD
    if rr < N:
      dp[rr+1] -= dp[i]
      dp[rr+1] %= MOD

print(dp[-1])

Measured memory_bytes: 16820
n, l = map(int, input().split(' '))

aji = [l + i - 1 for i in range(1, n+1)]

aji_zettaichi = [abs(i) for i in aji]

aji_zettaichi_min_id = 0
aji_zettaichi_min = aji_zettaichi[0]

for i in range(len(aji_zettaichi)):
    if aji_zettaichi_min > aji_zettaichi[i]:
        aji_zettaichi_min_id = i
        aji_zettaichi_min = aji_zettaichi[i]

aji.pop(aji_zettaichi_min_id)

print(sum(aji))

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    abc071c()
}

private data class SizeValue(val size: Int, val value: Long)

fun abc071c() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toLong() }

    val grouped = aList.groupBy { it }.map { SizeValue(it.value.size, it.value.first()) }
        .sortedByDescending { it.value }

    var firstBar: Long? = null

    grouped.forEach {
        if (it.size >= 4) {
            return println(firstBar?.let { fb -> fb * it.value } ?: it.value * it.value)
        } else if (it.size >= 2) {
            firstBar?.let { fb -> return println(fb * it.value) }
            firstBar = it.value
        }
    }

    return println(0)
}


Measured memory_bytes: 87428
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const int mo = 1e9 + 7;
typedef long long ll;
ll ans;

void solve()
{
    string s;
    cin>>s;
    int n =s.size();
    for(int i=0;i<n;i+=2)
    {
        if(s[i]=='L')
        {
            puts("No");return ;
        }
    }
    for(int i=1;i<n;i+=2)
    {
        if(s[i]=='R')
        {
            puts("No");return ;
        }
    }
    puts("Yes");
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pqll;
typedef priority_queue<vi> pqvi;
typedef priority_queue<vll> pqvll;
typedef priority_queue<int, vi, greater<int>> pqi_G;
typedef priority_queue<ll, vll, greater<ll>> pqll_G;
typedef priority_queue<vi, vvi, greater<vi>> pqvi_G;
typedef priority_queue<vll, vvll, greater<vll>> pqvll_G;

string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  int n;
  cin >> n;
  string s = to_string(n);
  int sum = 0;
  for (int i = 0; i < s.size(); i++) sum += s.at(i) - '0';
  if (n % sum == 0) Yes();
  else No();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 5002
#define pb push_back
#define For(i,s,e) for (int i=(s); i<(e); i++)
#define Debug_array(a,n) for (int i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (int i=(s); i<=(e); i++)
#define Fod(i,s,e) for (int i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second

using namespace std;

typedef long long ll;
ll gcd(ll a,ll b){
	if(a==0) return b;
	if(b==0) return a;
	return gcd(b,a%b);
}
int main(){
	ios_base::sync_with_stdio(false);
	
	ll n,x;cin>>n>>x;
	ll a[n+1];
	For(i,0,n) cin>>a[i];
	a[n]=x;
	sort(a,a+n+1);
	ll ans = gcd(0,a[1]-a[0]);
	For(i,1,n+1){
		ans = gcd(ans,a[i]-a[i-1]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
int K;
string ans;
bool search(int pos, int len, int pre){
	if(pos == len){
    	if(--K == 0){
        	cout << ans << endl;
            return true;
        }
        return false;
    }
    for(int i = 0; i <= 9; i++){
    	if(pos == 0 && i == 0) continue;
        if(pos > 0 && abs(pre - i) > 1) continue;
        ans += (char)(i + '0');
        if(search(pos + 1, len, i))
          return true;
        ans.pop_back();
    }
    return false;
}
int main(){
	cin >> K;
    ans = "";
    for(int len = 1; len <= 10; len++){
    	if(search(0, len, 0)){
        	return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<iostream>
#include <iterator>
#include <utility>
#include<map>
#include<queue>
#define maxn 2000000
using namespace std;
int n,a[maxn];
int main()
{
	priority_queue<int>P;
	string s;
	while(cin>>s)
	{
		if(s=="end")
		break;
		if(s=="insert")
		{
			int a;
			cin>>a;
			P.push(a); 
		}
		else if(s=="extract")
		{
			cout<<P.top()<<endl;
			P.pop();
		}
	}
	return 0;
}


Measured memory_bytes: 7140
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;

typedef struct Node {
	int key;
	struct Node *prev, *next;
} Node;

void insert(Node *ban, int key) {
	Node *newNode = (Node *)calloc(1, sizeof(Node));
	newNode->key = key;
	newNode->prev = ban;
	newNode->next = ban->next;
	ban->next->prev = newNode;
	ban->next = newNode;
	if(ban->prev == ban) {
		ban->prev = newNode;
	}
}

void deleteNode(Node *ban, int key) {
	Node *node = ban->next;
	while(node->key != -1) {
		if(node->key == key) {
			node->prev->next = node->next;
			node->next->prev = node->prev;
			free(node);
			break;
		}
		node = node->next;
	}
}

void deleteFirst(Node *ban) {
	ban->next->next->prev = ban;
	ban->next = ban->next->next;
}

void deleteLast(Node *ban) {
	ban->prev->prev->next = ban;
	ban->prev = ban->prev->prev;
}

int main() {
	Node ban = {-1, NULL, NULL};
	ban.prev = &ban;
	ban.next = &ban;
	int n;
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		char s[20];
		int key;
		scanf("%s", s);
		if(strcmp(s, "insert") == 0) {
			scanf("%d", &key);
			insert(&ban, key);
		} else if(strcmp(s, "deleteFirst") == 0) {
			deleteFirst(&ban);
		} else if(strcmp(s, "deleteLast") == 0) {
			deleteLast(&ban);
		} else {
			scanf("%d", &key);
			deleteNode(&ban, key);
		}
	}
	Node *node = ban.next;
	while(node->key != -1) {
		if(node->next == &ban) {
			printf("%d", node->key);
		} else {
			printf("%d ", node->key);
		}
		node = node->next;
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 37564
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}


long long N, K, S;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while (cin >> N >> K >> S) {
        long long rem = S+1;
        if (rem > 1000000000) rem = 1;
        for (int i = 0; i < K; ++i) cout << S << " ";
        for (int i = K; i < N; ++i) cout << rem << " ";
        cout << endl;
    }
}


















Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
    int  n;
    cin>>n;
    int k;
    cin>>k;
    int a[100]={0};
    for(int i=1;i<=k;i++)
    {
        int x;
        cin>>x;
        a[x]=1;
    }
    int flag;
    while(1)
    {
        int x=n;
        flag=1;
        while(x)
        {
            int w=x%10;
            if(a[w])
            {
                flag=0;
                break;
            }
            x/=10;
        }
        n++;
        if(flag==1)
            break;
    }
    cout<<n-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ll long long
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	const ll INF = 1e9;
	
	int N;
	cin >> N;
	vector<vector<ll> > arr(3, vector<ll>(N));
	REP(i, N) cin >> arr[0][i] >> arr[1][i] >> arr[2][i];
	vector<vector<ll> > dp(3, vector<ll>(N));
	REP(i, 3) dp[i][0] = arr[i][0];
	FOR(i, 1, N) REP(j, 3) dp[j][i] = max(dp[(j+1)%3][i-1] + arr[j][i], dp[(j+2)%3][i-1] + arr[j][i]);
	ll res = 0;
	REP(i, 3) res = max(res, dp[i][N-1]);
	cout << res << endl;
}


Measured memory_bytes: 5752
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if (c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
        
}


Measured memory_bytes: 3108
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans=0
K=int(input())
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans+=gcd(a,b,c)
print(ans)


Measured memory_bytes: 69788
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  FOR(i, a, b + 1) {
    if (i % k == 0) {
      print("OK");
      return 0;
    }
  }
  print("NG");
  return 0;
}

Measured memory_bytes: 3636
/* ****Tciitb**** */
                     
#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          int long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll ,ll >
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a-1;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;
#define N 100005 

 


 int main()
{
  io
  ll a,b;
  cin>>a>>b;
  if(a<=8 && b<=8)
  {
    cout<<"Yay!";
  }
  else
  {
     cout<<":(";
  }

  
}
  

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

const long long N = 3e6 + 17;
ll a[N], b[N], cnt, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m;
    cout << max(n+m, max(n - m, n * m));
}


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

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

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

	map<string, int> h;
	vector<string> s(n);

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

		if (h.find(s[i]) == h.end()) {
			h[s[i]] = 1;
		}
		else {
			h[s[i]]++;
		}
	}

	int maxx = 0;

	for (map<string, int>::iterator it = h.begin(); it != h.end(); ++it) {
		maxx = max(maxx, it->second);
	}

	for (map<string, int>::iterator it = h.begin(); it != h.end(); ++it) {
		if (it->second == maxx) {
			cout << it->first << endl;
		}
	}

	return 0;
}

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

const int MOD=1000000000+7;

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

  ll ans=0;
  ll two=1;
  for(int b=0;b<60;++b){
    ll ones=0;
    ll zero=0;
    for(int i=0;i<n;++i){
      if(a[i] & (1LL<<b)) ones++;
      else zero++;
    }
    ll cal=(ones*zero)%MOD*two%MOD;
    ans=(ans+cal)%MOD;
    two=(two*2)%MOD;
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 5612
$p=<>;
$q=<>;
@s=split //,$p;
@t=split //,$q;
for(a..z){
    $ds{$_}=-1;
    $dt{$_}=-1;
}
for(0..$#s-1){
    if($ds{$s[$_]}<0){
        $ds{$s[$_]}=$t[$_];
    }else{
        $f="No" if $ds{$s[$_]}ne$t[$_];
    }
    if($dt{$t[$_]}<0){
        $dt{$t[$_]}=$s[$_];
    }else{
        $f="No" if $dt{$t[$_]}ne$s[$_];
    }
}
print$f//="Yes"


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

bool comp(pair<pair<int,int>,int> p1, pair<pair<int,int>,int> p2){

    if(p1.first.first == p2.first.first){
        if(p1.first.second == p2.first.second){
            return p1.second < p2.second;
        }
        return p1.first.second > p2.first.second;
    }
    return p1.first.first < p2.first.first;

}

int main() {

    while(1) {

        int M,T,P,R;

        cin >> M >> T >> P >> R;

        if(M == 0 && T == 0 && P == 0 && R == 0) break;

        pair<int,int> team[T+1]; //solve_num, time
        int wrong_progrums[T+1][P+1]; //wrong_count

        team[0] = make_pair(-1,-1);

        for(int i=1; i<T+1; i++){
            team[i] = make_pair(0,0);
            for(int j=0; j<P+1; j++) {
                wrong_progrums[i][j] = 0;
            }
        }

        for(int i=0; i<R; i++){

            int m, t, p, j;

            cin >> m >> t >> p >> j;

            if(j == 0){
                team[t].first++;
                team[t].second += m + wrong_progrums[t][p] * 20;
            }
            else{
                wrong_progrums[t][p]++;
            }
        }

        pair<pair<int,int>,int> team_result[T+1];

        for(int i=0; i<T+1; i++){
            team_result[i].first.first = team[i].first;
            team_result[i].first.second = team[i].second;
            team_result[i].second = i;
        }

        sort(team_result,team_result+T+1,comp);
        
        cout << team_result[T].second;

        for(int i=T; i>1; i--){
            if(team_result[i].first.first == team_result[i-1].first.first && team_result[i].first.second == team_result[i-1].first.second){
                cout << '=' << team_result[i-1].second;
            }
            else{
                cout << ',' << team_result[i-1].second;
            }
        }

        cout << endl;

    }
    return 0;
}


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

using namespace std;

int main(int argc, char *argv[])
{
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    const long INF = 1e15;
    vector<long> dp(1e5 + 7, -INF);
    dp[0] = 0;
    long answer = 0;
    for (int i = 0; i < N; i++) {
        for (int j = W; j >= w[i]; j--) {
            if (dp[j - w[i]] >= 0) {
                dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
            }
            answer = max(answer, dp[j]);
        }
    }
    cout << answer << endl;
    return 0;
}


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

void solve(long long N, long long i)
{
    cout << (N - i + 1) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long i;
    scanf("%lld", &i);
    solve(N, i);
    return 0;
}


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

int main(void) {
	int x[100], y[100] = { 0 };
	int N,M,X,Y;
	cin >> N >> M >>X >> Y;
	for (int i = 0;i < N;i++)
		cin >> x[i];
	for (int i = 0;i < M;i++)
		cin >> y[i];
	sort(x, x + N);
	sort(y, y + M);
	for (int i = X + 1;i <= Y;i++) {
		if (x[N - 1] < i && y[0] >= i) {
			cout << "No War" << endl;
			return 0;
		}
	}
	cout << "War" << endl;
	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから



void solve(){
  int n;
  cin>>n;
  vector<string>s(n);
  rep(i,n)cin>>s[i];
  vector<int>cnt(26,50);
  rep(i,n){
    vector<int>c(26);
    rep(j,s[i].size()){
      c[s[i][j]-'a']++;
    }
    rep(j,26)chmin(cnt[j],c[j]);
  }
  string t="";
  rep(i,26){
    //cerr<<cnt[i]<<endl;
    rep(j,cnt[i])t+=string{(char)('a'+i)};
  }
  cout<<t;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

typedef vector<double> vd;
typedef vector<vd> vvd;

struct state {
	int p, n, s;
	double c;
	state(int p, int n, int s, double c) : p(p), n(n), s(s), c(c) {};
	bool operator<(const state &o)const {
		return o.c<c;
	}
};

int main() {
	int n, m;
	while(cin >> n >> m, n) {
		int s, g;
		cin >> s >> g;

		vvi d(n, vi(n, INF));
		vvi c(n, vi(n, INF));

		int x, y, dd, cc;
		REP(_, m) {
			cin >> x >> y >> dd >> cc;
			d[x-1][y-1] = d[y-1][x-1] = dd;
			c[x-1][y-1] = c[y-1][x-1] = cc;
		}

		priority_queue<state> Q;
		Q.push(state(-1, s-1, 1, 0.0));
		vector<vvd> cost(n, vvd(n, vd(30+1, INF)));
		while(!Q.empty()) {
			state st = Q.top();
			Q.pop();
			if(st.n == g-1 && st.s == 0) {
				cost[st.p][g-1][0] = min(st.c, cost[st.p][g-1][0]);
				continue;
			}
			if(st.s == 0) {
				continue;
			}
			REP(t, n) {
				if(st.p == t || st.n == t || d[st.n][t] == INF || c[st.n][t] < st.s) {
					continue;
				}

				double nc = st.c + (double)d[st.n][t]/st.s;
				FOR(p, -1, 1) {
					if(30 < st.s+p) {
						break;
					}
					if(nc < cost[st.n][t][st.s+p]) {
						cost[st.n][t][st.s+p] = nc;
						Q.push(state(st.n, t, st.s+p, nc));
					}
				}
			}
		}

		double ans = INF;
		REP(i, n) {
			ans = min(ans, cost[i][g-1][0]);
		}

		if(ans == INF) {
			cout << "unreachable" << endl;
		} else {
			printf("%.5f\n", ans);
		}
	}

	return 0;
}

Measured memory_bytes: 2728
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <utility>
#include <valarray>

using namespace std;

int main()
{
    int A, B;
    scanf("%d %d\n", &A, &B);
    if (A == 1) A = 14;
    if (B == 1) B = 14;
    if (A > B){
        puts("Alice");
    }else if (A < B){
        puts("Bob");
    }else{
        puts("Draw");
    }
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
using namespace std;
#define INF 1000000005
int main()
{
int n;
std::cin >> n;
std::vector<long long int> a;
for(int i = 0; i < n; i++){
    long long int tempa;
    std::cin >> tempa;
    a.push_back(tempa);
}
int sum = 0;
std::vector<pair<int, int>> output;
int max = a[0];
int min = a[0];
int imax = 0;
int imin = 0;
for(int i = 0; i < n; i++){
    if(a[i] > max){
        max = a[i];
        imax = i;
    }
    if(a[i] < min){
        min = a[i];
        imin = i;
    }
}
if(min >= 0){
    for(int i = 1; i < n; i++){
        sum++;
        pair<int,int> temp = make_pair(i - 1,i);
        output.push_back(temp);
    }
} else if(max <= 0){
    for(int i = 1; i < n; i++){
        sum++;
        pair<int,int> temp = make_pair(n - i,n - i - 1);
        output.push_back(temp);
    } 
} else if(abs(max) >= abs(min)){
    for(int i = 0; i < n; i++){
        sum++;
        pair<int,int> temp = make_pair(imax,i);
        output.push_back(temp);
    }
    for(int i = 1; i < n; i++){
        sum++;
        pair<int,int> temp = make_pair(i - 1,i);
        output.push_back(temp);
    }
} else {
    for(int i = 0; i < n; i++){
        sum++;
        pair<int,int> temp = make_pair(imin,i);
        output.push_back(temp);
    } 
    for(int i = 1; i < n; i++){
        sum++;
        pair<int,int> temp = make_pair(n - i,n - i - 1);
        output.push_back(temp);
    }  
}


std::cout << sum << std::endl;
for(int i = 0; i < sum; i++){
    std::cout << output[i].first + 1 << " " << output[i].second + 1 << std::endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<long long, long long>
#define ff first
#define ss second
#define ld long double
const int M = 1e9+7;

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; ll K; cin >> N >> K; int a[N];
    for(int i = 0; i < N; i++) cin >> a[i];
    ll ans = 0;
    for(int i = 0; i < N; i++){
        ll l = 0, r = 0;
        for(int j = 0; j < i; j++) if(a[i] > a[j]) l++;
        for(int j = i+1; j < N; j++) if(a[i] > a[j]) r++;
        r = (r * ((K*(K+1)/2)%M)) % M;
        l = (l * ((K*(K-1)/2)%M)) % M;
        ans = (ans + l + r) % M;
    }
    cout << ans;
}

Measured memory_bytes: 3624
"use strict";
function Main(input) {
  input = input.split("\n");
  var n = Number(input[0].trim());
  var ss = input[1].trim().split('');
  var a = 'A'.charCodeAt(0);
  const al = Array.apply(null, new Array(26)).map((v, i) => {
    return String.fromCharCode(a + i);
  });
  var r = []
  ss.forEach(s => {
    var index = al.indexOf(s);
    if (index + n >= al.length){
      var n2 = (index + n) - al.length;
    } else {
      var n2 = index + n;
    }
    r.push(al[n2]);
  })
  console.log(r.join('').trim());
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7616
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
N = ri()
S = [i for i in rs()]
ans = 0
for i in range(1, N):
    ans = max(len(set(S[:i]) & set(S[i:])), ans)
print(ans)

Measured memory_bytes: 63596
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize "-O3"

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

ll INF = (ll) 1e20;
int iINF = (int) 1e20;
ll mod = (ll) 1e9 + 7;
ll mod2 = (ll) 1e9 + 9;

signed main() {
    string s;
    cin >> s;
    string last, now;
    ll num = 0;
    for(int i = 0; i < s.size(); ++i) {
        now += s[i];
        if(last != now) {
            ++num;
            last = now;
            now = "";
        }
    }
    cout << num;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

int main() {
#ifdef LOCAL
  freopen("e.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  string s;
  bool cond;
  cin >> s;
  int ans = 0, cur = 0;
  char c[] = {'A', 'C', 'G', 'T'};
  for (int i = 0; i < SZ(s); i++) {
    cond = false;
    for (int j = 0; j < 4; j++) cond |= (s[i] == c[j]);
    if (cond)
      cur++;
    else {
      ans = max(ans, cur);
      cur = 0;
    }
  }
  cout << max(ans, cur) << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
void fast()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
}
int main(void)
{
	fast();
    ll int n,k;
    cin>>n>>k;
    // ll int p[n];
    vector<ll int> v;
    for(ll int i=0;i<n;i++)
    {
        ll t;
        cin>>t;
        v.push_back(t);
    }
     if(k>=n)
    {
           cout<<0<<endl;
    }
   /*( else if(k==0)
    {
        int sum=0;
        for(ll int i=0;i<p.size();i++)
        {
            sum=sum+p[i];
        }
        cout<<sum<<endl;
    }
    */
    else
    {
        sort(v.begin(),v.end());
        ll int sum2=0;
        ll int qw=n-k;
        for(ll int j=0;j<qw;j++)
        {
          sum2=sum2+v[j];   
        }
        cout<<sum2<<endl;
    }
}

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

ll mod = 998244353;

ll modpower(ll a, ll r){ //a^r
    ll x = 1;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a){
    return modpower(a, mod-2);
}

vector<ll> fact(300001, 1);
vector<ll> invfact(300001, 1);
ll modconv(ll n, ll k){
	if (k > n || k < 0) return 0;
	return fact[n] * invfact[k]%mod * invfact[n-k] % mod;
}

int main(){
    ll N, A, B, K;
    cin >> N >> A >> B >> K;
    
    for (int i = 2; i <= 300000; i++) fact[i] = (fact[i-1]*i)%mod;
    for (int i = 2; i <= 300000; i++) invfact[i] = modinv(fact[i]);
    ll ans = 0;
    for (ll i = 0; i <= N; i++) {
        if ((K-A*i)%B != 0) continue;
        ll j = (K-A*i)/B;
        if (j < 0 || j > N) continue;
        ans = (ans + modconv(N, i)*modconv(N, j))%mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
 int n;
  cin>>n;
   vector<string>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  set<string>s;
  for(int i=0;i<n;i++){
    s.insert(a[i]);
  }
  cout<<s.size()<<endl;
}


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

int main() {
	int N;
	cin>>N;
	map<int,int> a;
	map<int,int> b;
	int x,y;
	vector<int> aall(0);
	vector<int> ball(0);
	for(int i=0;i<N/2;i++){
		cin>>x>>y;
		if(a.count(x)){
			a[x]++;
		}
		else{
			a[x]=1;
			aall.push_back(x);
		}
		if(b.count(y)){
			b[y]++;
		}
		else{
			b[y]=1;
			ball.push_back(y);
		}
		
	}
	vector <pair<int,int>> aset;
	vector <pair<int,int>> bset;
	
	for(int i=0;i<aall.size();i++){
		aset.push_back(make_pair(a[aall.at(i)],aall.at(i)));
	}
	
	for(int i=0;i<ball.size();i++){
		bset.push_back(make_pair(b[ball.at(i)],ball.at(i)));
	}
	
	sort(aset.begin(),aset.end());
	reverse(aset.begin(),aset.end());
	sort(bset.begin(),bset.end());
	reverse(bset.begin(),bset.end());
	int ans;
	if(aset.at(0).second!=bset.at(0).second){
		ans=N-aset.at(0).first-bset.at(0).first;
	}
	else {
		if(N==2){
			ans=1;
		}
		else{
			int smax=0;
			int asize=aset.size();
			int bsize=bset.size();
			asize=min(asize,2);
			bsize=min(bsize,2);
			for(int i=0;i<asize;i++){
				for(int j=0;j<bsize;j++){
					if(smax<aset.at(i).first+bset.at(j).first){
						if(aset.at(i).second==bset.at(j).second)continue;
						else{
							smax=aset.at(i).first+bset.at(j).first;
						}
					}
				}
			}
			if(smax==0){
				ans=N/2;
			}
			else ans=N-smax;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}





Measured memory_bytes: 6516
import kotlin.system.exitProcess

val dic = mutableMapOf<Long, Char>()

fun main(args: Array<String>) {
	val (n, m) = readLine()!!.split(' ').map { it.toLong() }
	val s = readLine()!!
	val t = readLine()!!

	val l = lcm(n, m)

	judge(s, l, 0)
	judge(t, l, 1)
	println(l)
}

fun judge(s: String, l: Long, k: Int) {
	for ((i, c) in s.withIndex()) {
		val j = l / s.length * i
		if (dic[j] != null && dic[j] != c && k != 0) {
			println(-1)
			exitProcess(0)
		}
		dic[j] = c
	}
}

fun gcd(a: Long, b: Long): Long {
	return when {
		a < b -> {
			gcd(b, a)
		}
		b == 0L -> {
			a
		}
		else -> {
			gcd(b, a % b)
		}
	}
}

fun lcm(a: Long, b: Long): Long {
	return (a * b) / gcd(a, b)
}


Measured memory_bytes: 54060
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

std::vector<int> getsqrt(int N){
  std::vector<int> rtn;
  for(int i=1; i<=std::sqrt(N); i++){
    if ( N % i == 0 ){
      rtn.push_back(i);
      if ( i != (N/i) ) rtn.push_back(N/i);
    }
  }
  return rtn;
}

int main (void) {
  int N; std::cin >> N;
  std::vector<int> A(N);
  std::vector<int> a(N);
  for(int i=0; i<N; i++) std::cin >> a[i];

  std::vector<int> ans;
  for(int i=N-1; i>=0; i--){
    if ( A[i] != a[i] ) {
      ans.push_back(i+1);
      A[i] = (A[i]+1)%2;
      auto l = getsqrt(i+1);
      for(auto&& k : l){
        A[k-1] = (A[k-1]+1) % 2;
      }
    }
  }

  std::cout << ans.size() << std::endl;
  for(auto&& k : ans) std::cout << k << std::endl;
  return 0;
}

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

int main() {
  int n,x[100],y[100],k=1,op[2],oq[2];
  while(cin >> n) {
    if(n==0) break;
    for(int i=0;i<n;i++) {
      cin >> x[i] >> y[i];
    }
    double surface=0;
    for(int i=1;i<n-1;i++) {
      op[0] = x[i]-x[0];
      op[1] = y[i]-y[0];
      oq[0] = x[i+1]-x[0];
      oq[1] = y[i+1]-y[0];
      surface += 0.5 * (op[1]*oq[0] - op[0]*oq[1]);
    }
    printf("%d %.1lf\n",k,surface);
    k++;
  }
}

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

int main() {
	int n;
  	cin >> n;
  	double ave = 0;
  	double frame = 0;
  	double l = 0;
  	int min = 0;
  vector<int> a(n);
  for(int i = 0;i < n;i++){
	cin >> a.at(i);
  }
 	for(int j = 0;j < n;j++){
      ave += a.at(j);
    }
  	ave /= n;
	  for(int k = 0;k < n;k++){
     frame = abs(ave - a.at(k));
     if(k == 0){
       l = frame;
     }else if(frame < l){
       l = frame;
       min = k;
     }
   }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end() 
#define size(x) ll(x.size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
  int x,flag=0;
  cin >> x;
  rep(i,x){
    if(i*100 <= x and x <= i*105) {
      flag=1;
    }
  }
  cout << flag << endl;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cstdlib>
#define maxn 2000005
#define mod 1000000007
using namespace std;
int add(int x,int y){x+=y; return x>=mod?x-mod:x;}
int sub(int x,int y){x-=y; return x<0?x+mod:x;}
int mul(int x,int y){return 1ll*x*y%mod;}
int ksm(int a,int b)
{
    int s=1;
    for(;b;a=mul(a,a),b>>=1)
        if(b&1) s=mul(s,a);
    return s;
}
int inv[maxn],fac[maxn],ans;
int x1,x2,x3,x4,x5,x6;
int y1,y2,y3,y4,y5,y6;
int C(int n,int m){return mul(fac[n],mul(inv[m],inv[n-m]));}
int ld(int x,int y)
{
    int tmp=C(x-x2-1+y-y2-1,x-x2-1);
    tmp=sub(tmp,add(C(x-x2-1+y-y1,x-x2-1),C(x-x1+y-y2-1,x-x1)));
    tmp=add(tmp,C(x-x1+y-y1,x-x1));
    return tmp;
}
int rd(int x,int y)
{
    int tmp=C(x5-x-1+y5-y-1,x5-x-1);
    tmp=sub(tmp,add(C(x6-x+y5-y-1,x6-x),C(x5-x-1+y6-y,x5-x-1)));
    tmp=add(tmp,C(x6-x+y6-y,x6-x));
    return tmp;
}
int main()
{
    scanf("%d%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5,&x6);
    scanf("%d%d%d%d%d%d",&y1,&y2,&y3,&y4,&y5,&y6);
    x1--,y1--,x2--,y2--;
    x5++,y5++,x6++,y6++;
    inv[0]=fac[0]=1;
    for(int i=1;i<maxn;i++)
        inv[i]=mul(inv[i-1],ksm(i,mod-2)),fac[i]=mul(fac[i-1],i);
    for(int i=y3;i<=y4;i++)
    {
        ans=add(ans,mul(mod-x3-i+1,mul(ld(x3-1,i),rd(x3,i))));
        ans=add(ans,mul(x4+i,mul(ld(x4,i),rd(x4+1,i))));
    }
    for(int i=x3;i<=x4;i++)
    {
        ans=add(ans,mul(mod-y3-i+1,mul(ld(i,y3-1),rd(i,y3))));
        ans=add(ans,mul(y4+i,mul(ld(i,y4),rd(i,y4+1))));
    }
    printf("%d\n",ans);
}

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

int main() {
    int x, t;
    cin >> x >> t;
    if (t < 0){
        cout << "NO" << endl;
    }
    if (t==0){
        cout << "YES" << endl;
    }
    if ( x >= (2* (t-1)+1)){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=pow(10,9)+7;
bool cmp(pair<long double ,int > x, pair<long double , int> y){ return x.F<y.F && x.S<y.S; }
const ll maxn=2*1e5+10;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
ll fun(ll x) {   
  vector<ll> v;
  while(x){
  	v.pb(x%10);
  	x=x/10;
  }
  return v[v.size()-1];
} 
int main(){ 
    
//    #ifndef ONLINE_JUDGE
//  		freopen("input.txt", "r", stdin);
//    #endif
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n;
    cin>>n;
    
    map<pair<ll,ll>,ll> mp;
    
    		for (int k=1;k<=n;k++){
    			ll f=fun(k);
    			ll l=k%10;
    			mp[{f,l}]++;
			}
		
	
    ll ans=0;
    for (int i=0;i<=9;i++){
    	for (int j=0;j<=9;j++){
    		if (mp.count({i,j}) && mp.count({j,i})) ans+=mp[{i,j}]*mp[{j,i}];
		}
	}
	cout<<ans<<endl;
    
	return 0;
}


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

char conv(int x){
    if(x>0){
        return '+';
    }
    else{
        return '-';
    }
}

int main(){
int A, B, C, D, S;
cin >> S;
A = S/1000;
B = S%1000/100;
C = S%100/10;
D = S%10;

vector<int> x={1,1,1,1,-1,-1,-1,-1}, y={1,1,-1,-1,1,1,-1,-1}, z={1,-1,1,-1,1,-1,1,-1};

int calc=0;
bool flag=false;
char op1, op2, op3;

for(int i = 0; i < 8; i++){
    for(int j = 0; j < 8; j++){
        for(int k = 0; k < 8; k++){
            calc = A + B*x.at(i) + C*y.at(j) + D*z.at(k);
            if(calc == 7){
                flag = true;
                op1 = conv(x.at(i));
                op2 = conv(y.at(j));
                op3 = conv(z.at(k));
                break;
            }
        }
        if(flag){
            break;
        }

    }
    if(flag){
        break;
    }
}

cout << A << op1 << B << op2 << C << op3 << D <<"=7" <<endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <math.h>

int n,y;

int main(){
	while(scanf("%d%d",&n,&y), n != 0){
		int ans=0;
		double ira=0;
		int b,r,t;
		double ir;
		for(int I = 0; I < n; I++){
			scanf("%d%d%d",&b,&r,&t);
			if(t == 1){
				ir = 1 + y*r/100.0;
			}
			else{
				ir = pow((1+r/100.0),y);
			}
			if(ir > ira){
				ira  = ir;
				ans = b;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

class name
{
    static void Main()
    {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] d = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int sum = 0;
        for(int i = 0; i < s[0]; i++)
        {

            if (i % 2 == 0 && d[i] % 2 == 1)
            {
                sum++;

            }

        }

        Console.WriteLine(sum);



    }



}

Measured memory_bytes: 27972