akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;

const int mod = 1000000007;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

int main()
{
    ll n, m, k;
    cin >> n >> m >> k;

    mint ans = 0;
    mint com = 1;
    for (int i = 1; i <= k - 2; i++)
    {
        com = com * (n * m - 1 - i) / i;
    }
    for (int i = 1; i <= m; i++)
    {
        mint tmp = 1;
        tmp *= n;
        tmp *= n;
        tmp *= (m - i);
        tmp *= i;
        ans += tmp;
    }
    // cout << "AAA" << endl;
    for (int i = 1; i <= n; i++)
    {
        mint tmp = 1;
        tmp *= m;
        tmp *= m;
        tmp *= (n - i);
        tmp *= i;
        ans += tmp;
    }
    ans *= com;
    cout << ans << endl;

    return 0;
}

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

int dy[] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx[] = {-1, 0, 1, 1, 1, 0, -1, -1};

bool solve() {
	int H, W; cin >> H >> W;
	if (H == 0 && W == 0) return (false);
	vector<string> S(H);
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	string ans;
	int length = 0;
	unordered_set<string> st;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < 8; k++) {
				bool flag[11][22] = {};
				int y = i, x = j;
				string s;	
				int size = 0;
				while (!flag[y][x]) {
					s += S[y][x];
					//cout << s << endl;
					size++;
					if (st.find(s) != st.end()) {
						if (length < size) {
							ans = s;
							length = size;
						} else if (length == size && ans > s) {
							ans = s;
						}
					}
					st.insert(s);
					flag[y][x] = true;
					(y += dy[k] + H) %= H, (x += dx[k] + W) %= W;
				}
			}
		}
	}
	if (ans.size() > 1) {
		cout << ans << endl;
	} else {
		cout << 0 << endl;
	}
	return (true);
}

int main() {
	while (solve());
}



Measured memory_bytes: 35008
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val tList = (0 until n).map {
        readLine()?.toLong()!!
    }

    var result = 1L
    for (t in tList) {
        result = l(result, t)
    }

    println(result)
}

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

private fun gcd(a: Long, b: Long): Long {
    if (b == 0L) return a
    return gcd(b, a % b)
}

Measured memory_bytes: 33708
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;
long long dp[20][100009];
string s;

long long quickpow(long long b, int e)
{
	return e ? ((e & 1 ? b : 1)*quickpow((b*b) % 13, e >> 1)) % 13 : 1;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s;
	n = s.length();
	reverse(s.begin(), s.end());
	if (s[0] == '?') {
		for (int i = 0; i < 10; i++) {
			dp[i][0] = 1;
		}
	}
	else {
		dp[s[0] - '0'][0] = 1;
	}
	for (int i = 1; i < n; i++) {
        long long B = quickpow(10, i), tmp;
		if (s[i] == '?') {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 13; k++) {
					tmp = B * j;
					tmp = tmp % 13;
					tmp = tmp + k;
					tmp = tmp % 13;
					dp[tmp][i] += dp[k][i - 1];
					dp[tmp][i] = dp[tmp][i] % MOD;
				}
			}
		}
		else {
			for (int k = 0; k < 13; k++) {
				tmp = B * (s[i] - '0');
				tmp = tmp % 13;
				tmp = tmp + k;
				tmp = tmp % 13;
				dp[tmp][i] = dp[k][i - 1];
				dp[tmp][i] = dp[tmp][i] % MOD;
			}
		}
	}
	cout << dp[5][n - 1] << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 10704
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef long long ll;
char s[100000][11];

int comp(const void* a, const void* b){
    return (int)(*(char*)a-*(char*)b);
}

int comp_str(const void* a, const void* b){
    return strncmp(s[*(int *)a], s[*(int *)b], 10);
}

int main(void){
    int N;
    ll cnt=0;
    int a[100000];

    scanf("%d", &N);
    ll i;
    for(i=0;i<N;i++){
        scanf("%10s", s[i]);
        qsort(s[i], 10, sizeof(char), comp);
        s[i][10] = '\0';
        a[i] = i;
    }

    qsort(a, N, sizeof(int), comp_str);

    ll b_num=0;

    for(i = 0; i < N-1; i++){
        if(strncmp(s[a[i]], s[a[i+1]],10)!=0){
            cnt+=(i-b_num+1)*(i-b_num)/2;
            b_num=i+1;
        }
    }
    cnt+=(N-b_num)*(N-b_num-1)/2;

    
    printf("%lld", cnt);
    return 0;
}

Measured memory_bytes: 2044
#include <iostream>
#include <iomanip>
#include <set>

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;
const int INF = 1e+9 + 7;
typedef long long ll;

//入力

int main() {
  ios::sync_with_stdio(false);

  int a,b,c;
  cin >> a >> b >> c;

  set<int> s;

  s.insert(a);
  s.insert(b);
  s.insert(c);

  cout << s.size() << endl;

  return 0;
}


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

using namespace std;

int main(void) {
    int H, W;
    cin >> H >> W;
    vector< vector<int> > a(H, vector<int>(W));
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            int tmp;
            cin >> tmp;
            a[i][j] = tmp%2;
        }
    }

    int cnt = 0;
    vector< tuple<int,int,int,int> > go;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W-1; j++) {
            if(a[i][j]) {
                go.emplace_back(i+1, j+1, i+1, j+2);
                a[i][j+1] = 1 - a[i][j+1];
                cnt++;
            }
        }
    }
    for(int i=0; i<H-1; i++) {
        if(a[i][W-1]) {
            go.emplace_back(i+1, W, i+2, W);
            a[i+1][W-1] = 1 - a[i+1][W-1];
            cnt++;
        }
    }

    cout << cnt << endl;
    for(auto e: go) {
        cout << get<0>(e) << " " << get<1>(e) << " " << get<2>(e) << " " << get<3>(e) << endl;
    }
    return 0;
}


Measured memory_bytes: 5232
# import fractions
import sys
from sys import stdin

n = int(stdin.readline().rstrip())
x = [list(map(int, stdin.readline().rstrip().split())) for i in range(n)]

x.sort(key=lambda x: x[1])
sup = 0
for xi in x:
    sup += xi[0]
    if sup > xi[1]:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 53724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll a;
ld b;

int main() {
	fastio; cin >> a >> b;
	cout << (ll) (a*b);
}


Measured memory_bytes: 3740
#include<iostream>
using namespace std;
int N;
bool ask(int id)
{
	cout<<"?";
	for(int i=0;i<N;i++)cout<<" "<<id+i;
	cout<<endl;
	string s;cin>>s;
	return s=="Red";
}
main()
{
	cin>>N;
	int L=1,R=N+1;
	bool l=ask(1);
	while(R-L>1)
	{
		int M=(L+R)/2;
		bool f=ask(M);
		if(l==f)L=M;
		else R=M;
	}
	string ans(2*N,' ');
	ans[L-1]=l?'R':'B';
	ans[L+N-1]=l?'B':'R';
	for(int i=1;i<=2*N;i++)
	{
		if(i==L||i==L+N)continue;
		if(L<i&&i<L+N)
		{
			cout<<"? "<<i;
			for(int j=1;j<L;j++)cout<<" "<<j;
			for(int j=L+N+1;j<=2*N;j++)cout<<" "<<j;
			cout<<endl;
		}
		else
		{
			cout<<"? "<<i;
			for(int j=L+1;j<L+N;j++)cout<<" "<<j;
			cout<<endl;
		}
		string s;cin>>s;
		ans[i-1]=s=="Red"?'R':'B';
	}
	cout<<"! "<<ans<<endl;
}


Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if (a >= 13) {
    cout << b << endl;
  } else if (6 <= a) {
    cout << b / 2 << endl;
  } else {
    cout << "0" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll a[2020] = {}, d[2020][2020] = {}, z = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        int b = 0;
        for (int j = 1; j <= n; j++) if (a[j] > a[b]) b = j;
        for (int j = 0; j <= i; j++) {
            if (!j) d[i][j] = d[i - 1][j] + a[b] * abs(b - (n - i + j + 1));
            else if (j == i) d[i][j] = d[i - 1][j - 1] + a[b] * abs(b - j);
            else d[i][j] = max(d[i - 1][j] + a[b] * abs(b - (n - i + j + 1)), d[i - 1][j - 1] + a[b] * abs(b - j));
        }
        a[b] = 0;
    }
    for (int i = 0; i <= n; i++) {
        z = max(z, d[n][i]);
        //for (int j = 0; j <= i; j++) cout << d[i][j] << " \n"[j == i];
    }
    cout << z;
}


Measured memory_bytes: 35508
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

string S,T;
  cin>>S>>T;
  bool OK=true;
  if(T.size()-S.size()!=1){
    OK=false;
  }
  for(int i=0;i<S.size();i++){
    if(S[i]!=T[i]){
      OK=false;
    }
  }
  
  if(OK){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
    
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    string k = "ABC";
    int ans = 0;
    rep(i, s.size()-2) {
        if(s.substr(i, 3) == k) ans++; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//Bellman-Ford
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp
//WithoutUpdate -> TLE
#include <iostream>
#include <vector>
//#include <tuple>
using namespace std;

const int inf = 1001001001;

int main()
{
    int n, m, r;
    bool cycle = true;
    cin >> n >> m >> r;
    int d[n];
    // vector<vector<pair<int,int>> > edge(n);
    //tuple<int, int, int> edge[m];
    int S[m], T[m], D[m];
    for (int i = 0; i < m; i++)
    {
        int s, t, d;
        cin >> s >> t >> d;
        S[i] = s;
        T[i] = t;
        D[i] = d;
        //edge[i] = make_tuple(s, t, d);
    }
    for (int i = 0; i < n; i++)
    {
        d[i] = inf;
    }
    d[r] = 0;
    //for (int i = 0; i < n - 1; i++)
    for (int i = 0; i < n; i++)
    {
        bool update = false;
        for (int j = 0; j < m; j++)
        {
            /*
            if (d[get<1>(edge[j])] > d[get<0>(edge[j])] + get<2>(edge[j]))
            {
                d[get<1>(edge[j])] = d[get<0>(edge[j])] + get<2>(edge[j]);
            }
            */
            //if (d[T[j]] > d[S[j]] + D[j])
            if (d[T[j]] > d[S[j]] + D[j] && d[S[j]] != inf)
            {
                if (i == n - 1)
                {
                    cycle = false;
                    break;
                }
                d[T[j]] = d[S[j]] + D[j];
                update = true;
            }
        }
        if (!update)
        {
            break;
        }
    }
    if (cycle)
    {
        for (int i = 0; i < n; i++)
        {
            if (d[i] == inf)
            {
                cout << "INF" << endl;
            }
            else
            {
                cout << d[i] << endl;
            }
        }
    }
    else
    {
        cout << "NEGATIVE CYCLE" << endl;
    }

    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N;
    string s;
    cin >> N >> s;

    int num = 0;
    int idx = 0;
    while (idx < s.size())
    {
        if (s[idx] == '(')
        {
            ++num;
        }
        else
        {
            if (num > 0)
            {
                --num;
            }
            else
            {
                s.insert(0, "(");
                ++idx;
            }
        }
        ++idx;
    }

    while (num > 0)
    {
        s.insert(s.size(), ")");
        --num;
    }
    cout << s << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   int i, y, x;
   for(i=0; i<3000; i++){
       scanf("%d %d", &x, &y);
       if(x == 0 && y == 0){
           break;
       }
       if(x <= y){
           printf("%d %d\n", x, y);
       }
       else{
           printf("%d %d\n", y, x);
       }
   }
   return 0;
    
}



Measured memory_bytes: 2024
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convert(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i]-'0');
	}
	return d;
}
double L;
int main()
{
	cin >> L;
	L /= 3;
	L = L * L * L;
	printf("%.7f", L);
	

}

Measured memory_bytes: 256
a = int(input())
b = input()

str = ''
for i in b:
    if ord(i) + a > ord('Z'):
        n = chr(((ord(i)+a)%ord('A'))-ord('Z')+2*ord('A')-1)
    else:
        n = chr(ord(i)+a)

    str = str + n

print(str)


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

int main(){
  int N;
  cin >>N;
  string S;
  cin >>S;
  
  string S1,S2;
  S1 = S.substr(0,N/2);
  S2 = S.substr(N/2,N);
  
  if(S1 == S2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import math
n=int(input())
z=[list(map(int,input().split())) for _ in range(n)]
s=0
for i in range(n):
  for j in range(n):
    if i!=j:
      s+=math.sqrt((z[i][0]-z[j][0])**2+(z[i][1]-z[j][1])**2)
print(s/n)

Measured memory_bytes: 3064
s=input()
l=len(s)
se=dict()
k=0
for i in range(l-1,-1,-1):
    #print(0)
    k+=(pow(10,l-1-i,2019)*int(s[i]))
    k%=2019
    if k in se:
        se[k]+=1
    else:
        se[k]=1

ans=0
for j in se:
    i=se[j]
    if i>1:
        ans+=(i*(i-1)//2)
    if j==0:
        ans+=i
print(ans)

Measured memory_bytes: 68556
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
using namespace std;
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb(X) push_back(X)
#define x first
#define y second
#define all(x) (x).begin(), (x).end()
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef pair<int, int> pii;
//ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


const int INF = 1e9 + 7;
ll _, n, m;

int main() {
	INIT
	cin >> n >> m;
	ll sum = 0;
	rep (i, 0, m) {
		ll t = 0;
		cin >> t;
		sum += t;
	}
	if (sum > n) {
		cout <<"-1";
	} else {
		cout << 1ll * (n - sum);
	}
	

	return 0;
}

Measured memory_bytes: 3640
input = gets.chomp
split = input.split("")

answer = "yes"

count_letters = Array.new(27, true)

for letter in split do
	i = letter.encode( "UTF-8" ).ord - 96
	if count_letters[i]!=true
		answer = "no"
		break
	else
		count_letters[i] = false
	end
end

puts answer


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	ll r, D, x[11];
	cin >> r >> D >> x[0];
	for (int i = 1; i < 11; i++)
	{
		x[i] = r*x[i-1] - D;
		cout << x[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n=s.length();
    int ans=1;
    string t[n];
    t[0]=s[0];
    for(int a = 1;a<n;a++)
    {
        t[ans]+=s[a];
        if(t[ans]==t[ans-1]) continue;
        else ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11012
#include <iostream>
#include <string>
#define NIL 3000000000
using namespace std;

class node{
public:
  long long int num;
  node* parent;
  node* left;
  node* right;

  node(){
    num = NIL;
    parent = NULL;
    left = NULL;
    right = NULL;
  }

  node(long long int n){
    num = n;
    parent = NULL;
    left = NULL;
    right = NULL;
  }

  void insert(long long int n){
    if(num==NIL) num=n;
    //値が小さいとき
    if(n<num){
      if(left==NULL){
        left = new node(n);
        left->parent=this;
      }else{
        left->insert(n);
      }

    //値が大きいか等しいとき
    }else if(n>num){
      if(right==NULL){
        right = new node(n);
        right->parent=this;
      }else{
        right->insert(n);
      }
    }else return;
  }

  void print_inorder(){
    if(left!=NULL) left->print_inorder();
    if(num!=NIL) cout << " " << num;
    if(right!=NULL) right->print_inorder();
  }
  void print_preorder(){
    if(num!=NIL) cout << " " << num;
    if(left!=NULL) left->print_preorder();
    if(right!=NULL) right->print_preorder();
  }
};

/*
class root{
public:
  node* rn;

  root(){
    rn = NULL;
  }

  void insert(long long int n){
    if(rn==NULL){
      node r(n);
      rn = &r;
    }else rn->insert(n);
  }

  void print(){
    if(rn==NULL) return;
    else rn->print();
  }
};
*/

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

  node bst;

  string m; long long int num;
  for(int i=0; i<n; i++){
    cin >> m;
    if(m[0]=='i') {
      cin >> num;
      bst.insert(num);
    }
    else if(m[0]=='p') {
      bst.print_inorder(); cout << endl;
      bst.print_preorder(); cout << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 26524
// #include <bits/stdc++.h>
// #define rep(i,n) for (int i = 0; i < (n); ++i)
// using namespace std;
// typedef long long ll;
//
//
//
// int main(){
//   ll n,p;
//   std::cin >> n>>p;
//   if(n==1){
//     std::cout << p << '\n';
//     return 0;
//   }
//
//
//
//   //素数列挙
//   ll now=2;
//   std::vector<ll> pri(pow(p,(1.0/n))+3,1);
//   for (int i = 2; i < pri.size(); i++) {
//     if(pri[i]!=1)continue;
//     else {
//       if(i+i>=pri.size())continue;
//       for (int j = i+i; j < pri.size(); j+=i)pri[j]=0;
//     }
//   }
//
//   ll ans=1;
//   ll i=1;
//   while (1) {
//     i++;
//     if(pri.size()>i){
//
//       if(pri[i]!=1)continue;
//       ll temp =i;
//       if(p%temp==0){
//
//
//
//         int cnt=0;
//         while (p%temp==0) {
//           cnt++;
//           p/=temp;
//         }
//
//         ans*=pow(i,cnt/n);
//
//       }
//     }else break;
//   }
//
//   std::cout << ans << '\n';
//   return 0;
// }



#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;



int main(){
  ll n,p;
  std::cin >> n>>p;
  if(n==1){
    std::cout << p << '\n';
    return 0;
  }


  ll now=2;
  std::vector<ll> pri(pow(p,(1.0/n))+3,1);

  for (int i = 2; i < pri.size(); i++) {
    if(pri[i]!=1)continue;
    else {
      if(i+i>=pri.size())continue;
      for (int j = i+i; j < pri.size(); j+=i)pri[j]=0;
    }
  }


  // rep(i,pri.size()){
  //   std::cout<<i <<":"<<pri[i] << '\n';
  // }

  ll ans=1;
  ll i=1;
  while (1) {
    i++;
    if(pri.size()>i){

      if(pri[i]!=1)continue;
      ll temp =pow(i,n);
      if(p%temp==0){
        int cnt=0;

        // std::cout <<i<<":"<< temp << '\n';
        while (p%temp==0) {
          cnt++;
          p/=temp;
        }
        // std::cout << pow(i,cnt) << '\n';

        if(temp)ans*=pow(i,cnt);
      }
    }else break;
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 7168
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

using namespace std;

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

const int INF = 1001001001;

signed main()
{
    int n, m;
    cin >> n >> m;
    
    unordered_map<int, int> memo;
    rep(i, n){
        int x;
        cin >> x;
        memo[x]++;
    }
    
    vi maisu(m);
    vi pea(m);
    
    for(auto p : memo){
        maisu[p.first % m] += p.second;
        pea[p.first % m] += 2 * (p.second / 2);
    }
    
    int ans = 0;
    
    // diff
    reps(i, 1, (m+1)/2){
        int a = maisu[i];
        int b = maisu[m-i];
        int s = min(a, b);
        ans += s;
        a -= s;
        b -= s;
        ans += min(pea[i], a) / 2;
        ans += min(pea[m-i], b) / 2;
    }
    
    // same
    ans += maisu[0] / 2;
    if(m%2 == 0){
        ans += maisu[m/2] / 2;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 5156
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define full(v) v.begin(),v.end()

void solve()
{
  int na, nb, m;
  cin >> na >> nb >> m;
  vi a(na);
  vi b(nb);
  vecin(na,a);
  vecin(nb,b);

  vi x(m);
  vi y(m);
  vi c(m);
  repz(i,m)
  {
    cin >> x[i] >> y[i] >> c[i];
  }

  int ans = 0;
  ans = *min_element(full(a)) + *min_element(full(b));

  for (int i = 0; i < m; i++)
  {
    ans = min(ans,a[x[i]-1]+b[y[i]-1]-c[i]);
  }

  cout << ans << endl;
}

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

  ll t = 1;
  //cin >> t;
  while (t--)
  {
    solve();
  }
}



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

signed main(){
    int a,b,c;cin>>a>>b>>c;
    int d=min({a,b,c});
    int e=max({a,b,c});
    int f=a+b+c-d-e;
    cout<<d<<" "<<f<<" "<<e<<endl;
}


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

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

    if(a==1){
        if(b==1){
            cout<<"Draw";
        }else cout<<"Alice";
    }else if(b==1) cout<<"Bob";
    else if(a>b) cout<<"Alice";
    else if(b>a) cout<<"Bob";
    else cout<<"Draw";
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

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

    int cnt = 0;
    rep(i, N) if (S[i] == '.') cnt++;

    int ans = cnt;
    rep(i, N) {
        if (S[i] == '#')
            cnt++;
        else
            cnt--;

        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
  int a;
  cin >> a;
  if (a / 10 % 111 == 0 || (a - a / 1000 * 1000) % 111 == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import math

K = int(input())
SUM = 0
gcdlist = []
for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(j,K+1):
            gcd1 = math.gcd(i,j)
            gcd2 = math.gcd(gcd1,k)
            if i == j and j== k:
                SUM += gcd2
            elif i == j or j == k or k == i:
                SUM += gcd2*3
            else:
                SUM += gcd2*6

print(SUM)

Measured memory_bytes: 9228
l=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]
s='#'*20
n=input()
for i in range(n):b,f,r,v=map(int,raw_input().split());l[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(-3,0):print ' '+' '.join(map(str,l[i][j]))
    if i<3:print s

Measured memory_bytes: 4236
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
map<string,int> train;
int main(){
	int n;
	cin>>n;
	while(n--){
		train.clear();
		int ans=0;
		string s;
		cin>>s;
		for(int i=1;i<s.size();i++){
			string l,r;
			for(int j=0;j<i;j++)
				l+=s[j];
			for(int j=i;j<s.size();j++)
				r+=s[j];
			string dl=l,dr=r;
			reverse(dl.begin(),dl.end());
			reverse(dr.begin(),dr.end());
			if(train[l+r]==0){
				train[l+r]++;
				ans++;
			}
			if(train[l+dr]==0){
				train[l+dr]++;
				ans++;
			}
			if(train[dl+r]==0){
				train[dl+r]++;
				ans++;
			}
			if(train[dl+dr]==0){
				train[dl+dr]++;
				ans++;
			}
			if(train[r+l]==0){
				train[r+l]++;
				ans++;
			}
			if(train[r+dl]==0){
				train[r+dl]++;
				ans++;
			}
			if(train[dr+l]==0){
				train[dr+l]++;
				ans++;
			}
			if(train[dr+dl]==0){
				train[dr+dl]++;
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main(){
    string s;
    int n, cnt=0;
    cin >> s;
    if(s.size()%2==0) n = s.size()/2;
    else n = (s.size()-1)/2;
    rep(i,n){
        if(s.at(i)!=s.at(s.size()-i-1)) cnt++;
    }
    cout << cnt << endl;
}

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



  
int main(){
  
  int k,a,b;
  cin>>k>>a>>b;
  
  if ((a%k!=0) and (b%k!=0) and (a/k==b/k)){
    cout<<"NG"<<endl;
  }
  
  else {
    cout<<"OK"<<endl;
  }
    
  

  
  return 0;
        
}

    












Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
int n,h,m;
double a,b,c,d;
char ch;
int main(){
  cin>>n;
  while(n--){
    cin>>h>>ch>>m;
    a=h*30+m/2.0;
    b=m*6;
      
     
    c=max(a,b)-min(a,b);
    if(c>180){
      c=360-c;
    }
  
    //cout << a<< ' '<<b<<' '<<c<<endl;
      
    if(0<=c&&c<30){
      cout<<"alert"<<endl;
    }else if(90<=c&&c<=180){
      cout<<"safe"<<endl;
    }else{
      cout<<"warning"<<endl;
    }
      
  }
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, W;
    cin>>N>>W;
    int w[N];
    long long val[N];
    for(int i=0; i<N; i++)
        cin>>w[i]>>val[i];
   
    long long dp[N][W+1];
    for(int i=0; i<N; i++)
        dp[i][0] = 0;
    for(int i=1; i<=W; i++){
        if(w[0] <= i)
            dp[0][i] = val[0];
        else
            dp[0][i] = 0;
    }
    
    for(int i=1; i<N; i++){
        for(int j=1; j<=W; j++){
            if(j >= w[i]){
                dp[i][j] = max(val[i] + dp[i-1][j-w[i]], dp[i-1][j]);
            }
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    cout<<dp[N-1][W];
}


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

using namespace std;

int main() {
    int n, m;

    cin >> n >> m;

    int x, y;
    vector<int> indeg(n + 1);
    vector<vector<int>> to(n + 1);

    for(int i = 0; i < m; ++i) {
        cin >> x >> y;
        ++indeg.at(y);
        to.at(x).push_back(y);
    }

    vector<int> dp(n + 1);
    queue<int> q;

    for(int i = 1; i <= n; ++i) {
        if(indeg.at(i) == 0) {
            q.push(i);
        }
    }

    int qf, ans = 0;

    while(!q.empty()) {
        qf = q.front();
        q.pop();
        ans = max(ans, dp.at(qf));
        for(int qft: to.at(qf)) {
            dp.at(qft) = max(dp.at(qft), dp.at(qf) + 1);
            if(--indeg.at(qft) == 0) q.push(qft);
        }
    }

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

    return 0;
}

Measured memory_bytes: 6528
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N, K;
vector<int>num[11];
int dp[11][2001];

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		num[b].push_back(a);
	}
	for (int i = 1; i <= 10; i++) {
		stable_sort(num[i].begin(), num[i].end());
		reverse(num[i].begin(), num[i].end());
		for (int j = 1; j < num[i].size(); j++) {
			num[i][j] = num[i][j - 1] + num[i][j] + j * 2;
			//cout << num[i][j] << endl;
		}
	}
	for (int i = 1; i <= 10; i++) {
		for (int j = 1; j <= K; j++) {
			dp[i][j] = dp[i - 1][j];
			for (int k = 0; k < num[i].size(); k++) {
				if (j - k - 1 >= 0) {
					dp[i][j] = max(dp[i][j], dp[i - 1][j - k - 1] + num[i][k]);
				}
			}
		}
	}
	cout << dp[10][K] << endl;
	return 0;
}

Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
    int m1,d1,m2,d2; cin >> m1 >> d1 >> m2 >> d2;
    if(m1 < m2) cout << 1;
    else cout << 0;
}

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

int main(){
    using namespace std;
    unsigned long H, W, Ch, Cw, Dh, Dw;
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    unsigned long C{Cw + 1 + (Ch + 1) * (W + 4)}, D{Dw + 1 + (Dh + 1) * (W + 4)};
    const auto mp{[&H, &W]{
        vector<unsigned long> ret((H + 4) * (W + 4));
        for(unsigned long i{0}; i < H; ++i){
            string S;
            cin >> S;
            transform(begin(S), end(S), begin(ret) + 2 + (W + 4) * (i + 2), [](const char c){return c == '.';});
        }
        return move(ret);
    }()};
    const auto walk{[&W]{
        vector<unsigned long> ret(4);
        ret[0] += 1;
        ret[1] -= 1;
        ret[2] += W + 4;
        ret[3] -= W + 4;
        return move(ret);
    }()};
    const auto warp{[&W]{
        vector<unsigned long> ret(20);
        vector<pair<long, long>> tmp{{-2, -2}, {-2, -1}, {-2, 0}, {-2, 1}, {-2, 2}, {-1, -2}, {-1, -1}, {-1, 1}, {-1, 2}, {0, -2}, {0, 2}, {1, -2}, {1, -1}, {1, 1}, {1, 2}, {2, -2}, {2, -1}, {2, 0}, {2, 1}, {2, 2}};
        transform(begin(tmp), end(tmp), begin(ret), [&W](const auto& t){
            return static_cast<unsigned long>(t.first) + static_cast<unsigned long>(t.second) * (W + 4);
        });
        return move(ret);
    }()};
    deque<unsigned long> dq;
    vector ans((H + 4) * (W + 4), numeric_limits<unsigned long>::max() / 2), vis((H + 4) * (W + 4), 0UL);
    dq.emplace_back(C);
    ans[C] = 0;
    while(!dq.empty()){
        const auto now{dq.front()};
        dq.pop_front();
        if(vis[now])continue;
        vis[now] = true;
        if(now == D){
            cout << ans[now] << endl;
            return 0;
        }
        for(const auto& i : walk)if(mp[now + i] && ans[now + i] > ans[now]){
            ans[now + i] = ans[now];
            dq.push_front(now + i);
        }
        for(const auto& i : warp)if(mp[now + i] && ans[now + i] > ans[now] + 1){
            ans[now + i] = ans[now] + 1;
            dq.push_back(now + i);
        }
    };
    puts("-1");
    return 0;
}

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

using namespace std;

const int MAXN = 1e5+10;

vector<int> adj[MAXN];

int memo[MAXN];

int pd(int v){
    if(memo[v] != -1) return memo[v];
    int ans = 0;
    for(int u: adj[v]){
        ans = max(ans, 1 + pd(u));
    }
    return memo[v] = ans;
}


int main()
{

    int n, m;
    cin >> n >> m;
    while(m--){
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
    }
    memset(memo, -1, sizeof memo);
    int ans  = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, pd(i));
    }

    cout << ans << "\n";
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
//		Scanner scan= new Scanner(System.in);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		
		int X = Integer.parseInt(br.readLine());
		
		if (X >= 30) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 25376
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

//-----CODE------//


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

void solve(void)
{ 

  int N,K;
  cin>>N>>K;

  vector<int> vec (N,0);
  int g;
  int MAX = 0;
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
     if(i==0)g = vec[i];
     else g = gcd(g,vec[i]);
     chmax(MAX,vec[i]);
  }
  if(K%g == 0 && K <= MAX)
  {
    cout<<"POSSIBLE"<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
  

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 1024
h,w,k = map(int, input().split())
sl = [input() for _ in range(h)]

res = [[0]*w for _ in range(h)]
idx = 1
hi = 0
while hi<h:
    hi2 = hi
    while hi2<h and sl[hi2].count("#")==0:
        hi2 += 1
    c = sl[hi2].count("#")
    hidx = hi2
    if hi2<h:
        hi2 += 1
        while hi2<h and sl[hi2].count("#")==0:
            hi2 += 1

    if c==1:
        for i in range(hi,hi2):
            for j in range(w):
                res[i][j] = idx
        hi = hi2
        idx += 1
    else:
        wi = 0
        while wi<w:
            wi2 = wi
            while wi2<w and sl[hidx][wi2]==".":
                wi2 += 1
            if wi2<w:
                wi2 += 1
                while wi2<w and sl[hidx][wi2]==".":
                    wi2 += 1
            for i in range(hi,hi2):
                for j in range(wi,wi2):
                    res[i][j] = idx
            wi = wi2
            idx += 1
        hi = hi2

for r in res:
    print(" ".join(str(x) for x in r))

Measured memory_bytes: 7156
z=10
m=z**9+7
k=13
t=input()[::-1]
dp=[0]*k
dp[0]=1
for d in range(len(t)):
  p=[0]*k
  if t[d]=='?':
    for x in range(z):
      r=int(x)*pow(z,d,k)
      for i in range(k):
        p[(i+r)%k]+=dp[i]
  else:
    r=int(t[d])*pow(z,d,k)
    for i in range(k):
      p[(i+r)%k]+=dp[i]
  dp=[j%m for j in p]
print(dp[5]%m)

Measured memory_bytes: 45116
/** author: __nishad__ **/
//#pragma GCC optimize(2)
//#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a,b) for(ll i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    int a, b, sum=1;
    cin>>a>>b;

    loop(i, 1, a){
        if(sum<=b){
            sum = sum * 2;
        }
        else{
            sum = sum + b;
        }
    }

    cout<<sum;


}






























Measured memory_bytes: 3644
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    S = INPUT()
    T = INPUT()

    print('Yes' if S == T[:len(S)] else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9924
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

	    int i = 1;
	    while (true) {
		    String line = br.readLine();
		    int x = Integer.parseInt(line);

		    if (x == 0) break;

		    System.out.println("Case " + (i++) + ": " + x);
	    }
	}
}

Measured memory_bytes: 31816
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



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

  if(n < 1000) cout << "ABC" << endl;
  else cout << "ABD" << endl;

  return 0;
}

Measured memory_bytes: 256
import collections

S1 = collections.deque()
s_a = 0

S2 = collections.deque()

for i, j in enumerate(input()):
    if j == '\\':
        S1.append(i)
    elif j == '/':
        if S1:
            left_edge = S1.pop()
            diff = i - left_edge
            s_a += diff
            new_puddle_a = diff
            while True:
                if S2:
                    if S2[-1][0] > left_edge:
                        new_puddle_a += S2[-1][1]
                        S2.pop()
                    else:
                        break
                else:
                    break
            new_puddle = (left_edge, new_puddle_a)
            S2.append(new_puddle)
        else:
            pass


print(s_a)

num_of_puddles = len(S2)
puddles = str(num_of_puddles)

for i in range(num_of_puddles):
    puddle = S2.popleft()
    puddles += ' {0}'.format(str(puddle[1]))
else:
    print(puddles)

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

int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << 'A' << s2[0] << 'C' << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

def gcd(n, m) :
    n, m = max(n, m), min(n, m)
    if m == 0 :
        return n
    return gcd(m, n % m)

dis = A[0]
for a in A :
    dis = gcd(dis, a)

for a in A :
    if a < K :
        continue
    if (a - K) % dis == 0 :
        print('POSSIBLE')
        break
else :
    print('IMPOSSIBLE')

Measured memory_bytes: 14224
n = int(input())
a = list(map(int, input().split()))
l = sorted(zip(a, range(0, n)), reverse=True)
p = [0] * n
for i in range(n):
    p[i] = l[i][1]
a.sort(reverse=True)
dp = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
    for j in range(i + 1):
        k = i - j
        if j == 0:
            dp[j][k] = dp[j][k - 1] + abs(n - k - p[i - 1]) * a[i - 1]
        elif k == 0:
            dp[j][k] = dp[j - 1][k] + abs(j - 1 - p[i - 1]) * a[i - 1]
        else:
            dp[j][k] = max(dp[j][k - 1] + abs(n - k - p[i - 1]) * a[i - 1],
                           dp[j - 1][k] + abs(j - 1 - p[i - 1]) * a[i - 1])
ans = 0
for i in range(n):
    ans = max(ans, dp[n - i][i])
print(ans)


Measured memory_bytes: 100460
from collections import Counter


def main():
    inp = input().strip().split(' ')

    k = Counter()

    maxlen = 0
    maxlenword = ''
    for z in inp:
        k[z] += 1

        if len(z) > maxlen:
            maxlenword = z
            maxlen = len(z)

    maxi = k.most_common(1)[0][0]

    print(maxi, maxlenword)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7724
from collections import deque

h,w=map(int,input().split())
maze=[input() for _ in range(h)]
dx=[1,0,-1,0]
dy=[0,1,0,-1]
res=0
for sx in range(w):
  for sy in range(h):
    if maze[sy][sx]==".":
      d=[[-1 for _ in range(w)] for _ in range(h)]
      que=deque([[sx,sy]])
      d[sy][sx]=0
      while que:
        x,y=que.popleft()
        for i in range(4):
          nx=x+dx[i]
          ny=y+dy[i]
          if 0<=nx<w and 0<=ny<h and d[ny][nx]==-1 and maze[ny][nx]==".": 
            que.append([nx,ny])
            d[ny][nx]=d[y][x]+1
            if res<d[ny][nx]:
              res=d[ny][nx] 
print(res)


Measured memory_bytes: 3316