akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			char[] arr = sc.next().toCharArray();
			Arrays.parallelSort(arr);
			s[i] = String.valueOf(arr);
		}
		sc.close();
		Arrays.parallelSort(s);

		long ans = 0;
		long cnt = 1;
		for (int i = 1; i < n; i++) {
			if (s[i].equals(s[i - 1])) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		}
		ans += cnt * (cnt - 1) / 2;
		System.out.println(ans);
	}
}


Measured memory_bytes: 53084
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

char caesar(int n, char c) {
    int zure = c + n - 'a';
    if (zure < 26) return (char)(c + zure);
    else return (char)('a' + (zure % 26));
}

int main(void) {
    string s, strCopy;
    while (getline(cin, s)) {
        for (int j = 0; j < 26; j++) {
            for (int i = 0; i < s.size(); i++) {
                if (s[i] >= 'a' && s[i] <= 'z') {
                    s[i] = (s[i] == 'z') ? 'a' : s[i]+1;
                }
            }
            if (s.find("the") != string::npos || s.find("this") != string::npos || s.find("that") != string::npos) {
                cout << s << endl;
            }
        }
    }
    return 0;
}

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

int main(){
	int n,r;
	cin>>n>>r;
	int i,s;
	if(n<10){
		s=10-n;
		i=s*100;
		i+=r;
	} 
	else if(n>=10){
		i=r;
	}
	cout<<i<<endl;
	return 0;
} 

Measured memory_bytes: 256
H, W = map(int, input().split())
s = [input() for _ in range(H)]

dp = [[H + W] * W for _ in range(H)]

dp[0][0] = int(s[0][0] == "#")

for i in range(H):
    for j in range(W):
        if j:
            if (s[i][j - 1] == ".") and (s[i][j] == "#"):
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i][j - 1])
        if i:
            if (s[i - 1][j] == ".") and (s[i][j] == "#"):
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i - 1][j])

ans = dp[-1][-1]
print(ans)


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private struct Pair { public long x, y; public Pair(long x, long y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int H = NextInt();
        int W = NextInt();
        string[] S = new string[H];
        for (int i = 0; i < H; i++) S[i] = NextString();
        //全てのマスに対して各方向の評価
        int[,] data = new int[2010, 2010];
        //左から
        for (int i = 0; i < H; i++)
        {
            int sum = 0;
            for (int j = 0; j < W; j++)
            {
                if (S[i][j] == '.') sum++;
                else sum = 0;
                data[i, j] = sum;
            }
        }
        //右から
        for (int i = 0; i < H; i++)
        {
            int sum = 0;
            for (int j = W - 1; j != -1; j--)
            {
                if (S[i][j] == '.') sum++;
                else sum = 0;
                data[i, j] += sum;
            }
        }
        //↑から
        for (int i = 0; i < W; i++)
        {
            int sum = 0;
            for (int j = 0; j < H; j++)
            {
                if (S[j][i] == '.') sum++;
                else sum = 0;
                data[j, i] += sum;
            }
        }
        //sita から
        for (int i = 0; i < W; i++)
        {
            int sum = 0;
            for (int j = H - 1; j != -1; j--)
            {
                if (S[j][i] == '.') sum++;
                else sum = 0;
                data[j, i] += sum;
            }
        }

        int ans = 0;
        for (int i = 0; i < H; i++)
            for (int j = 0; j < W; j++)
                if (S[i][j] == '.') ans = Math.Max(ans, data[i, j]);


        Console.WriteLine(ans - 3);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 49000
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#define lli long long int
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
  string S;
  int ans = 0;
  cin >> S;
  rep(i, S.size()){
    if(S[i] == 'o'){
      ans++;
    }
  }
  if(ans + 15 - S.size() >= 8){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
  return 0;
}


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

#define TASKNAME ""

using namespace std;

const ll INF = 998244353;
const int MAXN = 1e6 + 7;
const double EPS = 1e-8;

ll power(ll a, ll k) {
    if (!k) {
        return 1;
    }
    ll b = power(a, k / 2);
    b = b * b % INF;
    if (k % 2) {
        return a * b % INF;
    } else {
        return b;
    }
}

ll rev(ll a) {
    return power(a, INF - 2);
}

ll f[MAXN];

void init() {
    f[0] = 1;
    for (ll i = 1; i < MAXN; i++) {
        f[i] = f[i - 1] * i % INF;
    }
}

ll C(ll n, ll k) {
    return f[n] * rev(f[k]) % INF * rev(f[n - k]) % INF;
}

int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // MY
    init();
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll res = 0;
    for (ll i = 0; a * i <= k; i++) {
        ll d = k - a * i;
        if (d % b) continue;
        ll j = d / b;
        if (i > n || j > n) continue;
        res += C(n, i) * C(n, j) % INF;
        res %= INF;
    }
    cout << res;
}


Measured memory_bytes: 8064
N = int(input())
A_list = list(map(int, input().split()))
two_list = [2 ** i for i in range(32)]

count = 0
items = {}
for a in A_list:
    if a in items:
        items[a] += 1

    else:
        items[a] = 1
A_list.sort(reverse=True)

for a in A_list:
    if items[a] >= 1:
        for t in two_list:
            m = t - a
            if m in items:
                if m == a and items[a] >= 2:
                    count += 1
                    items[a] -= 1
                    items[m] -= 1
                    break

                elif m != a and items[m] >= 1 and items[a] >= 1:
                    count += 1
                    items[a] -= 1
                    items[m] -= 1
                    break
print(count)

Measured memory_bytes: 33200
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

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

    vector<int> pow2(13, 1);
    for(int i=1; i<13; i++){
        pow2[i] = pow2[i-1] * 2;
    }

    vector<int> a(m), bc(m);    
    for(int i=0; i<m; i++){
        int b;
        cin >> a[i] >> b;
        for(int j=0; j<b; j++){
            int c;
            cin >> c;
            c -= 1;
            bc[i] += pow2[c];
        }
    }

    vector<vector<int>> dp(m+1, vector<int>((1<<n), INF));
    dp[0][0] = 0;
    for(int i=0; i<m; i++){
        for(int j=0; j<(1<<n); j++){
            dp[i+1][(j|bc[i])] = min(dp[i+1][(j|bc[i])], dp[i][j] + a[i]);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }
    /*
    for(int i=0; i<=m; i++){
        for(int j=0; j<(1<<n); j++){
            if(dp[i][j] == INF) cout << setw(5) << "INF";
            if(dp[i][j] != INF) cout << setw(5) << dp[i][j];
            cout << " ";
        }
        cout << endl;
    }
    */

    if(dp[m][(1<<n)-1] != INF) cout << dp[m][(1<<n)-1] << endl;
    if(dp[m][(1<<n)-1] == INF) cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 16384
program c_
    use,intrinsic :: iso_fortran_env
    use, intrinsic:: ieee_arithmetic
    implicit none
    integer(int64):: a
    real(real32):: b
    call ieee_set_rounding_mode(ieee_up)
    read*, a,b
    print'(i0)', (a*int(100*b))/100
end program c_

Measured memory_bytes: 2996
ticket = list(str(input()))

for state in range(1 << (len(ticket)-1)):
    fomula = ticket[0] + ''.join(('+' if state >> i & 1 else '-') + x for i, x in enumerate(ticket[1:]))
    if eval(fomula) == 7:
        print(fomula + ''.join('=7'))
        exit()


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

#define INF INT_MAX
#define MAX_V 10000
#define ll long long

using namespace std;

struct UnionFind {
    vector<int> par, sz;
 
    UnionFind(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }
 
    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }
 
    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

	int size(int x){
		return sz[find_root(x)];
	}
 
    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
};

vector<pair<int, int>> v;

int main()
{
	ll N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;
		v.push_back(make_pair(a-1, b-1));
	}
	UnionFind uf(N);
	//全ての橋がなくなったあとの不便さ
	vector<ll> ans;
	ll temp =  N * (N - 1) / 2;
	ans.push_back(temp); //nC2
	for (int i = M - 1; i >= 0; i--)
	{
		int a = v[i].first, b = v[i].second;
		// printf("a:%d b:%d\n",a,b);
		if (!uf.same(a,b))
		{
			// printf("size_a:%d size_b:%d\n",uf.size(a),uf.size(b));
			temp = temp - (ll)(uf.size(a) * uf.size(b));
			ans.push_back(temp);
		}
		else
		{
			ans.push_back(temp);
		}
		uf.unite(a, b);
	}
	for (int i = M-1; i >= 0; i--)
	{
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3828
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

n = ir()
a = lr()

dp = [0 for i in range(60)]

for num in a:
    for j in range(60):
        if ((num >> j) & 1):
            dp[j]+=1
ans = 0
for i in range(60):
    k = dp[i]
    tmp = k*(n-k)*power(2,i,mod)%mod
    ans = (ans+tmp)%mod
print(ans)

Measured memory_bytes: 129500
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>

using namespace std;


int main() {
	map<int, int> mp;

	int n, s[200] = {}, num[200000] = {}, result = 0, lamp = 1, in, ax, h, w, m, a, b, c, d, r, tmp = 1;
	string str, str2;
	char memo;
	cin >> str;
	n = str.length();
	in = n;
	for (int i = 0; i < n; i++) {
		s[str[i] - 'a']++;
	}
	for (int i = 0; i <= 25; i++) {
		if (s[i] == 0) { memo = 'a' + i; break; }

	}
	if (n != 26) { cout << str << static_cast<char>(memo); return 0; }

	for (int i = n - 1; i > 0; i--) {
		if (str[i - 1] > str[i]) { continue; }
		for (int j = 0; j <= i - 2; j++) {
			cout << str[j];
		}
		for (int j = n - 1; j >= i;j--) {
			if (str[j]>str[i-1]) { memo = str[j]; break; }
		}
		cout << memo;
		return 0;
	}
	cout << -1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

		int n,arr[100005],cnt = 0;
	cin>>n;
	for(int i = 1;i<=n;i++)
	{
		cin>>arr[i];
	}
	for(int i = 1;i<n;i++)
	{
			if(arr[i]==i){
				swap(arr[i],arr[i+1]);
				cnt++;
			}
	}
	if(arr[n]==n)
		cnt++;
	cout<<cnt;
  

   return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b;cin>>a>>b;
  vector<ll>c(b+1,0);
  rep(i,a){
    ll d,e;cin>>d;
    rep(i,d){
      cin>>e;
      c[e]++;
    }
  }
  ll f=0;
  rep(i,b+1){
    if(c[i]==a)f++;
  }
  cout<<f;
}


Measured memory_bytes: 26956
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i*i < n; i++) {
        ll a = (n-i);
        if((a%i)==0) {
            ll b = a/i;
            if(n/b!=i)continue;
            if((b*i)+i == n)ans += b;
        }
    }
    pr(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
vector<string> vec;

void dfs(string s){
  if(s.size() == N){
    vec.push_back(s);
    return;
  } 
  if(s.empty()){
    s += 'a';
    dfs(s);
    s.pop_back();
  }
  char s1 = *max_element(s.begin(), s.end()) + 1;
  for(char i = 'a'; i <= s1; i++){
    s += i;
    dfs(s);
    s.pop_back();
  } 
}

int main(){
  cin >> N;
  string s = "";
  dfs(s);
  for(int i = 0; i < vec.size(); i++) cout << vec[i] << endl;
}

Measured memory_bytes: 9588
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<string>s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}

	for (int i = 0; i < n; i++) {
		if (i > 0) {
			if (s[i][0] != s[i - 1][s[i - 1].size() - 1]) {
				cout << "No" << endl;
				return 0;
			}
			else {
				for (int j = 0; j < i; j++) {
					if (s[j] == s[i]) {
						cout << "No" << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define rg register
#define LL long long
#define __space putchar(' ')
#define __endl putchar('\n')
template <typename qwq> inline void read(qwq & x)
{
    x = 0;
    rg int f = 1;
    rg char c = getchar();
    while (c < '0' || c > '9')
    {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
    {
        x = (x << 1) + (x << 3) + (c ^ 48);
        c = getchar();
    }
    x *= f;
}
template <typename qaq> inline void print(qaq x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}
LL x,y,ans,temp;
inline void work1()//都大于0 
{
	if (y == 0) --ans;
	if (x > y)
	{
		ans += x - y + 2;//首先让x变为负,才可以实现+1操作让其绝对值变小;绝对值相等后,让x为正 
	}
	else ans += y - x;//否则直接相加即可 
}
inline void work2()//x大于等于0 y小于0 
{
	ans += abs(x + y) + 1;//若x < abs(y),先让x + 1至x = abs(y)再为负,否则让x为负再疯狂+ 1让x = y 
}
inline void work3()//x小于0 y大于等于0 
{
	if (y == 0) --ans;
	ans += abs(x + y) + 1;//若x > abs(y),先让x + 1至x = abs(y)再为正,否则让x为正再疯狂+ 1让x = y
}
inline void work4()//x小于0 y小于0 
{
	if (x > y)
	{
		ans += x - y + 2;//首先让x变为正,才可以实现+1操作让其绝对值变大;绝对值相等后,让x为负 
	}
	else ans += y - x;//否则直接相加即可 
}
int main()
{
	read(x),read(y);
	if (x == y) ans = 0;
	else if (x >= 0 && y >= 0) work1();
	else if (x >= 0 && y < 0) work2();
	else if (x < 0 && y >= 0) work3();
	else if (x < 0 && y < 0) work4();
	print(ans); 
}

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

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while (n) {
      if (n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};

struct Combination {
  vector<ModInt<>> _fact, _rfact, _inv;
  Combination(long long nsize = 5000000)
      : _fact(nsize + 1), _rfact(nsize + 1), _inv(nsize + 1) {
    _fact[0] = _rfact[nsize] = _inv[0] = 1;
    for (int i = 1; i <= nsize; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[nsize] /= _fact[nsize];
    for (int i = nsize - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for (int i = 1; i <= nsize; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }
  inline ModInt<> fact(int k) const { return _fact[k]; }

  inline ModInt<> rfact(int k) const { return _rfact[k]; }

  inline ModInt<> inv(int k) const { return _inv[k]; }

  ModInt<> P(int n, int r) const {
    if (r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  ModInt<> C(int p, int q) const {
    if (q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }
  // n types,choose r
  ModInt<> H(int n, int r) const {
    if (n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};

long long k, n;
string s;
Combination com;

ModInt<> solve();

int main() {
  cin >> k >> s;
  n = s.size();
  cout << solve() << endl;
  return 0;
}

ModInt<> solve() {
  ModInt<> res = 0;
  for (int i = n; i <= n + k; ++i) {
    ModInt<> now = 26;
    now = now.pow(n + k - i);
    now *= com.C(i - 1, n - 1) * ModInt<>(25).pow(i - n);
    res += now;
  }
  return res;
}

Measured memory_bytes: 63932
q = int(input())
s = []
rs = []

for i in range(q):
    s.append(list(map(int, input().split())))
    if s[i][0] == 3:
        rs.append(s[i][1])
        rs.append(s[i][2])
    else:
        rs.append(s[i][1])

rs.append(10 ** 9 + 1)
rs = sorted(list(set(rs)))
index = {rs[i]: i for i in range(len(rs))}
counter = [0 for i in range(len(rs) + 1)]
cnt = 0
for i in range(q):
    op, x = s[i][0], s[i][1]
    idx = index[x]
    if op == 0:
        cnt += 1
        counter[idx] += 1
        print(cnt)
    elif op == 1:
        print(counter[idx])
    elif op == 2:
        cnt -= counter[idx]
        counter[idx] = 0
    else:
        l = idx
        r = index[s[i][2]]
        for j in range(l, r + 1):
            for k in range(counter[j]):
                print(rs[j])



Measured memory_bytes: 61788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

const int N = 100005;

string s;

vector < pair<int, int> > answ;
vector <int> vec;

void solve(int v,int it,int sz) {
	if (it == (int)vec.size() - 1) {
		for (int i = v + 1; i < v + sz; i++) {
			answ.push_back(make_pair(v, i));
		}
		return;
	}
	int k = vec[it];
	sz -= k + 1;
	for (int i = v+1; i <= v + sz + 1; i++) {
		answ.push_back(make_pair(v, i));
	}
	solve(v + sz + 1, it + 1, k);
}

int main() {
	cin >> s;
	int n = (int)s.size();
	if (s[0] == '0' || s[n - 1] == '1') {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i <= n - 2; i++) {
		if (s[i] != s[n - 2 - i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n / 2; i++) {
		if (s[i] == '1') {
			vec.push_back(i + 1);
		}
	}
	reverse(vec.begin(), vec.end());
	solve(1, 0, n);
	for (int i = 0; i < (int)answ.size(); i++) {
		cout << answ[i].first << " " << answ[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 6452
from sys import stdin

S = stdin.readline().rstrip()
T = stdin.readline().rstrip()
alphabet = 'abcdefghijklmnopqrstuvwxyz'
cnt = 0

for letter in alphabet:
    X = []
    Y = []
    for k in range(len(T)):
        if T[k] == letter:
            X.append(S[k])
            if len(X) > 1 and X[len(X) - 1] != X[len(X) - 2]:
                print('No')
                break
        if S[k] == letter:
            Y.append(T[k])
            if len(Y) > 1 and Y[len(Y) - 1] != Y[len(Y) - 2]:
                print('No')
                break
    if len(X) > 1 and X[len(X) - 1] != X[len(X) - 2]:
        break
    if len(Y) > 1 and Y[len(Y) - 1] != Y[len(Y) - 2]:
        break
    cnt += 1

if cnt == 26:
    print('Yes')

Measured memory_bytes: 4528
from itertools import permutations as pe
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))
l = [i for i in range(1, N+1)]
p, q = 0, 0
for i,j  in enumerate(pe(l)):
    if j==P:
        p = i+1
    if j==Q:
        q = i+1
print(abs(p-q))


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(string S)
        {
            int w = 0, b = 0;
            foreach (int c in S)
            {
                switch (c)
                {
                case '0': ++w; break;
                case '1': ++b; break;
                }
            }
            return Math.Min(w, b) * 2;
        }

        static void Main(string[] args)
        {
            Console.WriteLine(Solve(Read()));
        }
    }
}


Measured memory_bytes: 13140
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();

    if(A + B > C + D){
      System.out.println("Left");
    }else if(A + B == C + D){
      System.out.println("Balanced");
    }else{
      System.out.println("Right");
    }
  }
}


Measured memory_bytes: 21972
#include<stdio.h>
int main(){
  int i,j,max,s[3];
  scanf("%d %d",&i,&j);
  s[0]=i+j;
  s[1]=2*i-1;
  s[2]=2*j-1;
  max=s[0];
  if(max<s[1]) max=s[1];
  if(max<s[2]) max=s[2];
  printf("%d",max);
  return 0;
}

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

int main(){
    int h, w;
    while(1){
        cin>>h>>w;
        if(h==0&&w==0) break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if((i%2)!=0&&(j%2)!=0){
                    cout<<'#';
                }
                if((i%2)!=0&&(j%2)==0){
                    cout<<'.';
                }
                if((i%2)==0&&(j%2)==0){
                    cout<<'#';
                }
                if((i%2)==0&&(j%2)!=0){
                    cout<<'.';
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  int A[N];
  int b[N];
  vector<vector<int> > x(N),y(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
    b[i] = -1;
    for(int j=0;j<A[i];j++){
      int n,m;
      cin >> n >> m;
      x[i].push_back(n);
      y[i].push_back(m);
    }
  }
  int ans = 0;
  for(ll bit = 0;bit <(1<<N); ++bit){
    int sum = 0;
    for(int i=0;i<N;i++){
      if(bit & (1<<i)){
	b[i]=0;
      }else{
	b[i]=1;
	sum++;
      }
    }
    for(int j=0;j<N;j++){
      for(int t=0;t<A[j];t++){
	if(b[j]==1 && b[x[j][t]-1]!=y[j][t]) {
	  sum = 0;
	  break;
	}
      }
    }
    ans = max(sum,ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main(){
	int w,a,b;
	cin>>w>>a>>b;
	if(a<b&&b>(a+w)){
		cout<<abs(b-(a+w));
	}else if(a>b){
		cout<<abs(a-(b+w));
	}else if(a<=b<=(a+w)){
		cout<<"0";
	}
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

/// Ported from ACL.
/// Computes \sum_{i = 0}^{n - 1} floor((a * i + b) / m).
fn floor_sum(n: i64, m: i64, mut a: i64, mut b: i64, mut acc: i64) -> i64 {
    if a >= m {
        let q = a / m;
        acc += (n - 1) * n / 2 * q;
        a -= q * m;
    }
    if b >= m {
        let q = b / m;
        acc += n * q;
        b -= q * m;
    }
    let y_max = (a * n + b) / m;
    let x_max = y_max * m - b;
    if y_max == 0 {
        return acc;
    }
    acc += (n - (x_max + a - 1) / a) * y_max;
    floor_sum(y_max, a, m, (a - x_max % a) % a, acc)
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        nmab: [(i64, i64, i64, i64)],
    }
    for (n, m, a, b) in nmab {
        puts!("{}\n", floor_sum(n, m, a, b, 0));
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 3824
import java.util.Scanner;
 class  Main {
    static public  void  main (String[] av){
     int  b;
        Scanner sc =new Scanner(System.in);
        int n =sc.nextInt();
        int a[]= new int[n];
        int j=0;int v;
        for(int  i=0;i<n;i++){
            a[i] =sc.nextInt();
        }
                for(int k=0;k<n-1;k++){
        System.out.print(a[k]+ " ");
}
System.out.println(a[n-1]);
        for (int i= 1 ;i<=n-1;i++){
v=a[i];
        j=i-1;
        while (j>= 0 && a[j]>v){
a[j+1]=a[j];
j--;
a[j+1] =v;
        }
        for(int k=0;k<n-1;k++){
        System.out.print(a[k]+ " ");
}
System.out.println(a[n-1]);
}
        }

}
    


Measured memory_bytes: 32940
#include <iostream>

std::pair<int, int> f(int a, int b) {
    std::pair<int, int> p;
    p.first = a * b;
    p.second = (a + b) * 2;
    return p;
}

int main() {

    int a, b;
    std::cin >> a >> b;

    std::pair<int, int> result = f(a, b);
    std::cout << result.first << " " << result.second << std::endl;

    return 0;
}



Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Atcoder_nA{
  public static void Main(){

    int n = int.Parse(Console.ReadLine());
    long[] a = new long[n];
    long ans = 1;
    Atcoder_nA ac = new Atcoder_nA();
    for (int i = 0; i < n; i++){
        a[i] = long.Parse(Console.ReadLine());
        ans = ac.lcm(ans,a[i]);
    }

    Console.WriteLine(ans);
  }
  long gcd(long x, long y){
      if(x % y == 0) return y;
      return gcd(y, x % y);
  }
  long lcm(long x, long y){
      return x / gcd(x,y) * y;
  }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int MOD = 1000000007;
//g++ -std==c++14
//setprecision(10)
int main(){
    int n;  cin >> n;
    int va;
    map <int, int> num;
    vector <int> edge;
    for(int i = 0; i < n; i++){
        cin >> va;
        num[va]++;
        if(num[va] != 0 && num[va] % 2 == 0)
            edge.push_back(va);
    }
    if(edge.size() < 2)
        cout << 0 << endl;
    else{
        sort(edge.rbegin(), edge.rend());
        cout << (long long int)(*edge.begin()) * (*(next(edge.begin(),1))) << endl;
    }
}

Measured memory_bytes: 4992
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
nodes = [[] for i in range(N)]
edges = {}
for i in range(N-1):
    a, b = MAP()
    a -= 1; b -= 1
    nodes[a].append(b)
    nodes[b].append(a)
    edges[(a, b)] = i

# DFSで木の走査(開始位置はどこでもいい)
# (自分, 親, 親との辺の色)
stack = [(0, -1, -1)]
mx = 0
ans = [0] * (N-1)
while stack:
    u, prev, used = stack.pop()
    color = 0
    # 自分の子ノードを順番に塗り進めていく
    for v in nodes[u]:
        if v == prev:
            continue
        color += 1
        # 親-自分間で使用済の色だったら1つ進める
        if color == used:
            color += 1
        a, b = min(u, v), max(u, v)
        i = edges[(a, b)]
        ans[i] = str(color)
        stack.append((v, u, color))
    # 各ノードから使った色数の最大を取る
    mx = max(mx, color)

print(mx)
print('\n'.join(ans))


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

ll gcd(ll a, ll b) {
    if (a<b) swap(a, 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(void) {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll SdivC, SdivD, SdivCD, a, b;
    a = B / C;
    b = (A-1) / C;
    SdivC = a - b;

    a = B / D;
    b = (A-1) / D;
    SdivD = a - b;

    a = B / (lcm(C, D));
    b = (A-1) / (lcm(C, D));
    SdivCD = a - b;

    ll ans = B - A + 1 - ( SdivC + SdivD - SdivCD );

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2586&lang=jp
// references : http://algoogle.hadrori.jp/aoj/2586/
const int INF = 1e9;
double eps = 1e-9;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n;
	while (cin >> n, n) {
		vector<double> px(n), py(n), pz(n), vx(n), vy(n), vz(n), r(n), vr(n);
		for (int i = 0; i < n;i++) {
			cin >> px[i] >> py[i] >> pz[i] >> vx[i] >> vy[i] >> vz[i] >> r[i] >> vr[i];
		}

		vector<pair<double, pair<int, int>>> E;
		for (int i = 0; i < n;i++) {
			E.push_back({ r[i] / vr[i],{i,i} });
			for (int j = i+1; j < n;j++) {
				bool flag = false;
				double x = px[i] - px[j];
				double y = py[i] - py[j];
				double z = pz[i] - pz[j];
				double R = r[i] + r[j];
				double Vx = vx[i] - vx[j];
				double Vy = vy[i] - vy[j];
				double Vz = vz[i] - vz[j];
				double Vr = vr[i] + vr[j];
				double a = Vx*Vx + Vy*Vy + Vz*Vz - Vr*Vr;
				double b = x*Vx + y*Vy + z*Vz + R*Vr;
				double c = x*x + y*y + z*z - R*R;
				if (!(b*b - a*c + eps > 0))continue;

				double Min = INF;
				vector<double> p(2);
				p[0] = (-b + sqrt(b*b - a*c)) / a;  p[1] = (-b - sqrt(b*b - a*c)) / a;
				for (int k = 0; k < 2;k++) {
					if (p[k] * vr[i] < r[i] && p[k] * vr[j] < r[j] && p[k] > 0) {
						Min = min(Min, p[k]); flag = true;
					}
				}
				if (flag) {
					E.push_back({ Min,{i,j} });
				}
			}
		}
		vector<int> f(n, 0);
		vector<double> ans(n, 0);
		sort(E.begin(), E.end());
		for (auto e : E) {
			if (f[e.second.first] != 0 || f[e.second.second] != 0)continue;
			f[e.second.first] = f[e.second.second] = 1;
			ans[e.second.first] = ans[e.second.second] = e.first;
		}
		for (auto A : ans) {
			cout << fixed << setprecision(10)<< A << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int cnt0 = 0, cnt1 = 0;
    for(int c : s)
        c=='0' ? cnt0++ : cnt1++;
    cout << 2 * min(cnt0, cnt1) << endl;
}

Measured memory_bytes: 512
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=50;

int a[N],b[N],c[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(int i=1;i<=n-1;i++)
        cin>>c[i];
    int ans=0;
    for(int i=1;i<=n;i++)
        ans+=b[i];
    for(int i=1;i<=n-1;i++)
        if(a[i]+1==a[i+1])
            ans+=c[a[i]];
    cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll long double
#define int long long
int n;
vector < long double> v;
ll dp[3000][3000];
long double f(int x,int y)
{
	if(x==n)
	{
		return y>n/2;
		
	}
	if(dp[x][y]>=0)
		return dp[x][y];
	return dp[x][y]=(v[x]*f(x+1,y+1)+(1-v[x])*f(x+1,y));
}
int32_t main()
{
	IOS;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
	{
		long double x;
		cin>>x;
		v.push_back(x);
	}
	cout<<fixed<<setprecision(9)<<f(0,0)<<endl;
	return 0;
}

Measured memory_bytes: 141184
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;
    map<ll, ll> mp;
    for(ll i = 1; i <= 100; i++){
        for(ll j = 1; j <= 100; j++){
            for(ll k = 1; k <= 100; k++){
                ll tmp = i*i + j*j + k*k + i*j + j*k + k*i;
                mp[tmp]++;
            }
        }
    }

    for(ll i = 1; i <= n; i++){
        cout << mp[i] << endl;
    }
}

Measured memory_bytes: 6052
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author dilip
 */

/*
*   author : dilip
*   time : 23-06-2019 22:11
*/

#include <iostream>
#include <fstream>

#include <iostream>
#include<stdio.h>
#include<bits/stdc++.h>

using namespace std;

int dp[3005][3005];

class FLCS {
public:
	void solve(std::istream& in, std::ostream& out) {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        string s,t;
        in >> s;
        in >> t;
        int m = s.size();
        int n = t.size();
        for(int i=1;i<=m;i++){
        	for(int j=1;j<=n;j++){
        		//if(i == 0 || j == 0)dp[i][j] = 0;
        		 if(s[i-1] == t[j-1])dp[i][j] = dp[i-1][j-1]+1;
        		else dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
        	}
        }

        string res = "";
		int i = s.size(), j = t.size();
		while(i > 0 && j > 0){
			if(dp[i][j] == dp[i-1][j])--i;
			else if(dp[i][j] == dp[i][j-1])--j;
			else {
				res = s[i-1] + res;
				--i;--j;
			}
		}

	out << res << endl;

	}
};


int main() {
	FLCS solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 35456
M, K = map(int, input().split())

N = 1 << M

if M == 0:
	if 0 < K:
		print(-1)
	else:
		print('0 0')
elif M == 1:
	if 0 < K:
		print(-1)
	else:
		print('0 0 1 1')
else:
	if N <= K:
		print(-1)
	else:
		RK = K
		A = [RK]
		B = [i for i in range(N) if i != RK]
		print(' '.join((
			' '.join(map(str, reversed(A))),
			' '.join(map(str, reversed(B))),
			' '.join(map(str, A)),
			' '.join(map(str, B)))))



Measured memory_bytes: 17968
N=int(input())
a=b=c=0
for i in range(N+1):
    if i!=0:
        j=i
        while i%2==0:
            a=a+1
            i=int(i/2)
        if a>b:
            b=a
            c=int(j)
        a=0
if c==0:
    print(1)
else:
    print(c)

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll n;cin>>n;
	vl a(n);rep(i,n)cin>>a[i];
	ll sum[n+1];
	sum[0]=0;
	rep(i,n)sum[i+1]=a[i]+sum[i];
	ll ans=INF;
	for(int i=1;i<n;++i){
		ans=min(ans,abs(sum[i]-(sum[n]-sum[i])));
	}
	cout<<ans<<endl;
}

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

using namespace std;

int a[100];

int32_t main()
{
    string s;
    cin >> s;

    for(int i=0;i<s.size();i++)
    {
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C')
            a[i] = 1;
    }

    int ans = 0;
    int cnt = 0;

    for(int i=0;i<=s.size();i++)
    {
        if(a[i] == 0)
        {
            ans = max(ans,cnt);
            cnt = 0;
        }
        else
            cnt++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*
			███╗   ███╗ █████╗ ███████╗███╗   ███╗ ██████╗ ██╗   ██╗██████╗ ███████╗ █████╗ ███╗   ███╗██████╗ ██╗   ██╗
			████╗ ████║██╔══██╗╚════██║████╗ ████║██╔═══██╗██║   ██║██╔══██╗╚════██║██╔══██╗████╗ ████║██╔══██╗╚██╗ ██╔╝
			██╔████╔██║███████║    ██╔╝██╔████╔██║██║   ██║██║   ██║██║  ██║    ██╔╝███████║██╔████╔██║██║  ██║ ╚████╔╝
			██║╚██╔╝██║██╔══██║   ██╔╝ ██║╚██╔╝██║██║   ██║██║   ██║██║  ██║   ██╔╝ ██╔══██║██║╚██╔╝██║██║  ██║  ╚██╔╝
			██║ ╚═╝ ██║██║  ██║   ██║  ██║ ╚═╝ ██║╚██████╔╝╚██████╔╝██████╔╝██╗██║  ██║  ██║██║ ╚═╝ ██║██████╔╝   ██║
			╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝  ╚═╝     ╚═╝ ╚═════╝  ╚═════╝ ╚═════╝ ╚═╝╚═╝  ╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝    ╚═╝

			“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define pb push_back
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define sz(v) ((int)((v).size()))
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define Accepted 0
#define watch(x) cout << #x << " = " << x << endl;
#define un_map unordered_map
#define RT(x) return cout << (x), 0;
#define sc(a) scanf("%d", &a)
#define scll(x) scanf("%I64d", &x)
#define scan(s) scanf("%[^\n]%*c", &s)
#define pr(s) printf("%s", s.c_str()); // print string
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double EPS = -1e-2;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const ll mod = 1000000007;
const int Mx = INT_MAX;
const int Mn = INT_MIN;
const ll MX = LLONG_MAX;
const ll MN = LLONG_MIN;
const int N = 1e5 + 1;
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
int n, k;
int dp[N];
//int mem[N];
vector<int>v;
/*int solve(int i) {
	int& ret = mem[i];
	if (~ret)return ret;
	ret = Mx;
	for (int j = 1; j <= k && i + j < n; j++)
		ret = min(ret, solve(i + j) + abs(v[i] - v[i + j]));

	ret = ret == Mx ? 0 : ret;
	return ret;
}*/
int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	//clr(mem, -1);
	cin >> n >> k;
	v = vector<int>(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	//cout << solve(0) << endl;


	for (int i = 0; i < n; i++) {
		int& ret = dp[i];
		ret = Mx;
		for (int j = 1; j <= k && i - j >= 0; j++)
			ret = min(ret, dp[i - j] + abs(v[i] - v[i - j]));

		ret = ret == Mx ? 0 : ret;
	}

	cout << dp[n - 1] << endl;
	return Accepted;
}


Measured memory_bytes: 3948
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_int_list():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


def main():
    n, m = get_int_list()
    kas = []
    for _ in range(n):
        kas.append(get_int_list())

    counter = Counter()
    for ka in kas:
        for x in ka[1:]:
            counter[x] += 1
    print(len(list(filter(lambda x: x == n, counter.values()))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512