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

int main() {
	int k, s;
	int a;
	int sum = 0;

	cin >> k >> s;

	if (s > 3 * k)cout << sum << endl;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			a = s - i - j;
			if (a > k&&a < 0)break;
			else if(a<=k&&a>=0){
				sum++;
				//cout << "(" << i << "," << j << "," << s - i - j << ")" << endl;
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int n, u, v, m;
int card[100000];
int row[2][1000010], col[2][1000010];
int board[2][500][500];
int rem[2];
int row_n[2][500], col_n[2][500], crs_n[2][2];

void solve() {
	for(int loop = 0; loop < m; loop++) {
		int c = card[loop];

		for(int i = 0; i < 2; i++) {
			if(row[i][c] == -1) continue;
			row_n[i][row[i][c]]--;
			if(row_n[i][row[i][c]] == 0) rem[i]--;
			col_n[i][col[i][c]]--;
			if(col_n[i][col[i][c]] == 0) rem[i]--;
			if(row[i][c] == col[i][c]) {
				crs_n[i][0]--;
				if(crs_n[i][0] == 0) rem[i]--;
			}
			if(row[i][c] == n - 1 - col[i][c]) {
				crs_n[i][1]--;
				if(crs_n[i][1] == 0) rem[i]--;
			}
		}

		if(rem[0] <= 0 && rem[1] > 0) {
			cout << "USAGI" << endl;
			return;
		}
		if(rem[0] > 0 && rem[1] <= 0) {
			cout << "NEKO" << endl;
			return;
		}
		if(rem[0] <= 0 && rem[1] <= 0) {
			cout << "DRAW" << endl;
			return;
		}
	}
	cout << "DRAW" << endl;
}

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

	cin >> n >> rem[0] >> rem[1] >> m;

	fill((int*)begin(row), (int*)end(row), -1);
	fill((int*)begin(col), (int*)end(col), -1);

	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < n; j++) {
			for(int k = 0; k < n; k++) {
				cin >> board[i][j][k];
				row[i][board[i][j][k]] = j;
				col[i][board[i][j][k]] = k;
			}
		}
	}

	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < n; j++) {
			row_n[i][j] = n;
			if(n != 1)
				col_n[i][j] = n;
		}
		for(int j = 0; j < 2; j++) {
			if(n != 1)
				crs_n[i][j] = n;
		}
	}

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

	solve();
}

Measured memory_bytes: 20428
import java.math.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long k = sc.nextLong();
    String s = "";
    for (int i = 0; i < k; i++) {
      s += "ACL";
    }
    System.out.println(s);
  }
}


Measured memory_bytes: 27068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

vector<ll> v;

void rec(ll n=0,ll k=1){
  if(k>1e9)return;
  int f[10]={},tmp=n;
  while(tmp){
    f[tmp%10]++;
    tmp/=10;
  }
  if(f[3]&&f[5]&&f[7])v.push_back(n);
  rec(n+3*k,k*10);
  rec(n+5*k,k*10);
  rec(n+7*k,k*10);
}

int main(){
  ll n;
  cin>>n;
  rec();
  sort(v.begin(),v.end());
  ll i=0;
  for(;i<v.size();i++){
    if(v[i]>n)break;
  }
  cout<<i<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
const int maxn = 1e1 + 5;
using namespace std;

char a[maxn];


int main(){
	scanf("%s", a + 1);
	int len = strlen(a + 1);
	for(int i = 1; i <= len; i++){
		if(a[i] == 'B'){
			for(int j = i; j >= 1; j--){
				if(a[j] != 'B'){
					a[j] ='B';
					break;
				}
			}
		}
	}
	for(int i = 1; i <= len; i++){
		if(a[i] != 'B') printf("%c", a[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (long long i = 0; i < (n); ++i)
#define rep(i, a, b) for (long long i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

const long long MAX_V = 200000;
const long long INF = 1e18;

struct edge
{
    long long to, cost;
};
typedef pair<long long, long long> P;

long long d[MAX_V];
long long n;

vector<edge> G[MAX_V];
void dijkstra(long long s, vector<edge> G[])
{
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + MAX_V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        long long v = p.second;
        if (d[v] < p.first)
            continue;
        for (long long i = 0; i < G[v].size(); i++)
        {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost)
            {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
int main(void)
{

    cin >> n;

    REP(i, n - 1)
    {
        long long a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        edge e;
        e.to = b;
        e.cost = c;
        G[a].push_back(e);

        edge e2;
        e2.to = a;
        e2.cost = c;
        G[b].push_back(e2);
    }
    long long q, k;
    cin >> q >> k;
    dijkstra(k - 1, G);
    REP(i, q)
    {
        long long x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << d[x] + d[y] << endl;
    }
}

Measured memory_bytes: 14464
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		double[] A = new double[N];
		double[] gyakusu = new double[N];
		double sum = 0;
		for (int i=0;i<N;i++) {
			A[i] = Double.parseDouble(sc.next());
			gyakusu[i] = 1/A[i];
			sum+=gyakusu[i];
		}
		System.out.println(1/sum);
	}
}

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

#define ll  int
#define intmax INT_MAX
#define pi 3.14159265358979323846
#define ff first 
#define ss second
#define pb push_back
#define watch(x) cerr<<(#x)<<"  "<<x<<"\n";
const int MOD=998244353;
const int MAXN = 3e5+4;
int dp[MAXN],a[MAXN];

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

int n; cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
dp[2]=abs(a[1]-a[2]);
for(int i=3;i<=n;i++){
	dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
}

cout<<dp[n]<<"\n";


return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h.at(i);
    int ans = 0;
    int now = 0;
    rep(i,n-1){ 
        if(h.at(i) >= h.at(i+1))now++;
        else now = 0;
        ans = max(ans,now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3680
import numpy as np

n,k = map(int,input().split())

if k%2 == 0:
    temp = 0
    temp = 0
    for i in range(1,n+1):
        if i%k == 0:
            temp += 1
    ans = temp**3
    temp = 0
    for i in range(1,n+1):
        if i%k == k//2:
            temp += 1
    ans += temp**3
    print(ans)
else:
    temp = 0
    for i in range(1,n+1):
        if i%k == 0:
            temp += 1
    print(temp**3)




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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(B>=A*C)
    cout<<C<<endl;
  else
    cout<<B/A<<endl;



  return 0;
}
  


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

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

	int n;
	n = s.size();
	vector<int> start = {1, 1, (n + 3)/2}, end = {n, (n - 1)/2, n};
	int perf = 1;
	vector<string> ans_perf = {"No", "Yes"};
	for (int i = 0; i < 3; i++) {
		for (int j = start.at(i) - 1; j < end.at(i)/2; j++) {
			if (s.at(j) != s.at(end.at(i) - j - 1)) {
				perf = 0;
				break;
			}
		}
		if (!perf) break;
	}
	cout << ans_perf.at(perf) << endl;
}


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


int main() {
  int N,l,r,s = 0;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> l >> r;
    s += (r - l) + 1;
  }
  cout << s << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int main() {
    ll N,M; cin>>N>>M;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    vector<ll> r(N+1,0);
    for (int i = 0; i < N; ++i) {
        r[i+1]=r[i]+A[i];
    }
    int mini=-1,maxi=A[N-1]*2+1;
    while(maxi-mini>1){
        int mid=(maxi+mini)/2;
        ll cnt=0;
        bool f=false;
        for(int i=N-1;i>=0;--i){
            int tmp=A.end()-lower_bound(A.begin(),A.end(),mid-A[i]);
            //tmp-=N-1-i;
            cnt+=tmp;
            if(cnt>=M){
                f=true;
                break;
            }
        }
        //cout<<mid<<" "<<cnt<<endl;
        if(f){
            mini=mid;
        }else{
            maxi=mid;
        }
    }
    //cout<<mini<<endl;
    ll ans=0ll;
    ll cnt=0;
    for (int i = N-1; i >= 0; --i) {
        if(mini-A[i]>A[N-1]) break;
        auto tmp=lower_bound(A.begin(),A.end(),mini-A[i]);
        int ind=tmp-A.begin();
        ans+=r[N]-r[ind];
        ans+=A[i]*(A.end()-tmp);
        //cout<<r[N]-r[ind]<<endl;
        cnt+=A.end()-tmp;
    }
    //cout<<cnt<<endl;
    ans-=(cnt-M)*mini;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main()
{
  int n;
  cin >> n;
  vector<ll> vec(n);
  rep(i, n) cin >> vec[i];
  vector<ll> left(n, 0);
  vector<ll> right(n, 0);
  reps(i,1, n) {
    left[i] = gcd(left[i-1], vec[i-1]);
  }
  repr(i, n-2) {
    right[i] = gcd(right[i+1], vec[i+1]);
  }
  ll ans = 0;
  rep(i, n) {
    ans = max(ans, gcd(left[i], right[i]));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5576
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {


		int N,tmp,maximum = -BIG_NUM,minimum = BIG_NUM;
		Scanner scanner = new Scanner(System.in);

		N = scanner.nextInt();

		for(int loop = 0; loop < N; loop++){
			tmp = scanner.nextInt();
			maximum = Math.max(maximum, tmp-minimum);
			minimum = Math.min(minimum, tmp);
		}

		System.out.println(maximum);
	}
}



Measured memory_bytes: 100532
fun main(args: Array<String>){
    val (n, y) = readLine()!!.split(' ').map(String::toInt)
    for(i in 0 .. n){
        for(j in 0 .. (n-i)){
            val k = n - i - j
            if(10000 * i + 5000 * j + 1000 * k == y){
                println("$i $j $k")
                return
            }
        }
    }
    println("-1 -1 -1")
}

Measured memory_bytes: 38364
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<list>
#include<functional>
#define mp make_pair
#define X first
#define Y second
#define INF 1987654321
#define PI 3.14159265358979323846264
#define MOD 1000000007LL
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef complex<double> base;
ll POW(ll a, ll b) { if (b == 0)return 1; if (b == 1)return a; if (b & 1)return (a*POW(a, b - 1)) % MOD; ll t = POW(a, b / 2); return (t*t) % MOD; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[] = { 0,-1,1,0 }, dy[] = { 1,0,0,-1 };//동북남서
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

int cnt[4000][4000][2];
int sum[4000][4000][2];
int S(Pi LD, Pi RU, int type)
{
	int x1 = LD.X, y1 = LD.Y;
	int x2 = RU.X, y2 = RU.Y;
	return sum[x2][y2][type] - sum[x2][y1 - 1][type] - sum[x1 - 1][y2][type] + sum[x1 - 1][y1 - 1][type];
}
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	fup(i, 0, n - 1, 1)
	{
		int x, y;
		char c;
		scanf("%d %d %c", &x, &y, &c);
		x %= (2 * k), y %= (2 * k);
		cnt[x][y][c=='W'?0:1]++;
		cnt[x + 2*k][y][c == 'W' ? 0 : 1]++;
		cnt[x][y + 2*k][c == 'W' ? 0 : 1]++;
		cnt[x + 2*k][y + 2*k][c == 'W' ? 0 : 1]++;
	}
	fup(i, 1, 4 * k, 1)
	{
		fup(j, 1, 4 * k, 1)
		{
				sum[i][j][0] = sum[i - 1][j][0] + sum[i][j - 1][0] - sum[i - 1][j - 1][0] + cnt[i-1][j-1][0];
				sum[i][j][1] = sum[i - 1][j][1] + sum[i][j - 1][1] - sum[i - 1][j - 1][1] + cnt[i-1][j-1][1];
		}
	}
	int ans = 0;
	fup(i, 1, 2 * k, 1)
	{
		fup(j, 1, 2 * k, 1)
		{
			int t = 0;
			t += S(Pi(i, j), Pi(i + k - 1, j + k - 1), 0);
			t += S(Pi(i + k, j + k), Pi(i + 2 * k - 1, j + 2 * k - 1), 0);
			t += S(Pi(i + k, j), Pi(i + 2 * k - 1, j + k - 1), 1);
			t += S(Pi(i, j + k), Pi(i + k - 1, j + 2 * k - 1), 1);
			ans = max(ans, t);
		}
	}
	printf("%d", ans);
}

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

int main(){
  string a,b,c;
  cin >> a >> b >>c;
  if(a.back()==b.front() && b.back()==c.front()){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    ll A[x], B[y], C[z];
    rep(i, x) cin >> A[i];
    rep(i, y) cin >> B[i];
    rep(i, z) cin >> C[i];

    vector<ll> AB;
    rep(i, x) {
        rep(j, y) {
            AB.push_back(A[i] + B[j]);
        }
    }
    sort(AB.rbegin(), AB.rend());

    vector<ll> ABC;
    rep(i, min(k, (int)AB.size())) {
        rep(j, z) {
            ABC.push_back(AB[i] + C[j]);
        }
    }
    sort(ABC.rbegin(), ABC.rend());
    
    rep(i, k) cout << ABC[i] << endl;
}

Measured memory_bytes: 43364
n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

count = 0

for i in range(n):
  if(i != 0):
    if(a[i] - a[i - 1] == 1):  
      count += b[a[i] - 1] + c[a[i - 1] - 1]
    else:
      count += b[a[i] - 1]
  else:
    count += b[a[i] - 1]

print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
ll arr[maxn];
int n;
int main(void) {
    while(~scanf("%d", &n)) {
        for(int i = 0; i < n; ++i)
            scanf("%I64d", arr + i);
        ll ma1 = 0, ma2 = 0;
        sort(arr, arr + n);
        for(int i = n - 1; i >= 1; --i) {
            if(arr[i] == arr[i - 1]) {
                ma2 = ma1;
                ma1 = arr[i];
                arr[i] = arr[i - 1] = 0;
                if(ma1 && ma2) break;
            }
        }
        cout << ma1 * ma2 << endl;
    }
}


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

int main(){
    double pai=3.141592653589;
    int h,w;
    for(;;){
        scanf("%d %d",&h,&w);
        if(h==0 && w==0) break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin>>n;
 n=n%10;
 if(n==3)
 cout<<"bon"<<endl;
 else if(n==1 || n==0 || n==6 || n==8)
 cout<<"pon"<<endl;
 else
 cout<<"hon"<<endl;
 return 0;
}


Measured memory_bytes: 3632
N, M = list(map(int, input().split()))
Ls, Rs = [], []
for i in range(M):
    n, m = list(map(int, input().split()))
    Ls.append(n)
    Rs.append(m)

# ll = Ls[0]
# rr  =Rs[0]
# for i in range(M):
#     ll = max(ll, Ls[i])
#     rr = min(rr, Rs[i])
#
# print(rr - ll + 1)
print(max(0, min(Rs) - max(Ls) + 1))



Measured memory_bytes: 56664
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 200005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define PI acos(-1.0)
#define eps 1e-9

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    int a, b;
    cin>>a>>b;
    for(int i = 1; i < 4; i++)
    {
        if(i!=a && i!=b)
        {
            cout<<i<<endl;
            break;
        }
    }

    //End();
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

vector<int> array_left_rotation(vector<int> a, int n, int k) {
    
}

int main(){
  long int W;
  long int a,b;
  cin >> W >> a >> b;
  int n;
  if((b-a)*(a+W-b)>=0||(b+W-a)*(a-b)>=0){
    n=0;
  }
  else{
    n=min(fabs(b-a-W),fabs(a-b-W));
  }
  cout <<n <<endl;
    
    return 0;
}


Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def kaibunn(s):
    n = len(s)
    m = n // 2
    res = True
    for i in range(m):
        if s[i] != s[n-1-i]:
            res = False
            break
    return res


def main():
    S = input().rstrip()

    N = len(S)

    isKaibunn = kaibunn(S)

    if isKaibunn:
        T = S[0:(N-1)//2]
        isKaibunn = kaibunn(T)
        if isKaibunn:
            T = S[(N+3)//2-1:N]
            isKaibunn = kaibunn(T)

    if isKaibunn:
        print('Yes')
    else:
        print('No')


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string n;
    cin >> n;
    int k;
    cin >> k;
    vector<vector<vector<lint>>> dp(n.size() + 1, vector<vector<lint>>(4, vector<lint>(2, 0)));
    dp[0][0][0] = 1;
    for (int i = 1; i <= (int)n.size(); ++i) {
        // 0
        if (n[i - 1] == '0') {
            for (int j = 0; j <= 3; ++j) {
                dp[i][j][0] += dp[i - 1][j][0];
                dp[i][j][1] += dp[i - 1][j][1];
            }
        } else {
            for (int j = 0; j <= 3; ++j) {
                dp[i][j][1] += dp[i - 1][j][0];
                dp[i][j][1] += dp[i - 1][j][1];
            }
        }
        // 1-9
        for (int j = 1; j <= 3; ++j) {
            dp[i][j][1] += 9 * dp[i - 1][j - 1][1];
            dp[i][j][1] += max(0, n[i - 1] - '1') * dp[i - 1][j - 1][0];
        }
        if (n[i - 1] != '0') {
            for (int j = 1; j <= 3; ++j) {
                dp[i][j][0] += dp[i - 1][j - 1][0];
            }
        }
    }
    cout << dp[n.size()][k][1] + dp[n.size()][k][0] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int MAX_T = 200050;
int main(){
  int n, C;
  cin >> n >> C;
  vector<int> s(n), t(n), c(n);
  rep(i, n) {
    int a, b, cc;
    cin >> a >> b >> cc;
    a *= 2;
    b *= 2;
    --cc;
    s[i] = a, t[i] = b, c[i] = cc;
  }
  
  vector<int> sum(200100);
  rep(i, C) {
    vector<int> imos(200100);
    rep(j, n) if(c[j] == i) imos[s[j] - 1]++, imos[t[j]]--;
    int t = 0;
    rep(j, MAX_T) {
      t += imos[j];
      if(t > 0) sum[j]++;
    }
  }
  int ans = 0;
  rep(j, MAX_T) {
    ans = max(sum[j], ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2944
n, m = list(map(int, input().split()))
s = input()
t = input()

for k in range(min(n,m), 0, -1):
    if n%k==0 and m%k==0:
        l = k
        break

for i in range(0,l):
    if s[(n//l)*i] != t[(m//l)*i]:
        print('-1')
        exit()
else:
    print(n*m//l)

Measured memory_bytes: 3316
import java.util.*;

public class Main{
	static int N, V, X, Y;
	static int[] L, B, R, T;
	static double g = 9.8;
	static double EPS = 1e-6;

//	根据y&#36724;方向的初速度vy和重力g，返回t&#26102;&#38388;点&#26102;的位置y
	private static double calc(double vy, double t) {
		return vy*t - g*t*t/2;
	}
	
	private static int cmp(int lb, int ub, double a) {
		return a < lb+EPS ? -1 : a > ub-EPS ? 1 : 0;
	}
	
	private static boolean check(double qx, double qy){
		double a = g*g/4;
		double b = g*qy - V*V;
		double c = qx*qx + qy*qy;
		double D = b*b - 4*a*c;
		if(D<0 & D>-EPS) D=0;
		if(D < 0) return false;
		
		for(int d = -1; d < 2; d=d+2){
			double t2 = (-b + d*Math.sqrt(D)) / (2*a);	

//			System.out.println(t2);
			if(t2 < 0) continue;
			double t = Math.sqrt(t2);
			double vx = qx / t;
			double vy = Math.sqrt(V*V - vx*vx);
			
			double yt = calc(vy, X/vx);
			if(yt < Y - EPS) continue;
			
			boolean ok = true;
			for(int i = 0; i < N; i++){
//				石&#22836;在pig右&#36793;，直接&#36807;&#28388;
				if(L[i] >= X) continue;
//				当来到pig正上方&#26102;，与pig之&#38388;有没有障碍物
				if(R[i] >= X & T[i] >= Y & yt >= B[i]) ok = false;				
//				中途会不会遇到障碍
//				一共要判定4条
//				一：与&#27599;个障碍物的左&#36793;界的相&#23545;位置
				int yL = cmp(B[i], T[i], calc(vy, L[i]/vx));
//				二：与&#27599;个障碍物的右&#36793;界的相&#23545;位置
				int yR = cmp(B[i], T[i], calc(vy, R[i]/vx));
//				三：bird升到最高点&#26102;与&#27599;个障碍物的左右界的相&#23545;位置
				int xH = cmp(L[i], R[i], vx*(vy/g));
//				四：bird升到最高点&#26102;与&#27599;个障碍物的上下界的相&#23545;位置（？）
				int yH = cmp(B[i], T[i], calc(vy, vy/g));
				
//				System.out.println(yL+" "+yR+" "+xH+" "+yH);
				if(yL* yR <= 0) ok = false;
				if(xH == 0 & yH >= 0 & yL < 0) ok = false;
			}
			if(ok) return true;
		}		
		return false;
	}	

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		
		N = s.nextInt();
		V = s.nextInt();
		X = s.nextInt();
		Y = s.nextInt();
		
		L = new int[N];
		B = new int[N];
		R = new int[N];
		T = new int[N];
		
		for(int i = 0; i < N; i ++){
			L[i] = s.nextInt();
			B[i] = s.nextInt();
			R[i] = s.nextInt();
			T[i] = s.nextInt();
			if(R[i] > X) R[i] = X;
		}
		
		boolean ok = check(X,Y);
		for(int i = 0; i < N; i++){
			ok |= check(L[i], T[i]);
			ok |= check(R[i], T[i]);
		}
		
		if(ok)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

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

int main()
{
	int n, u, k, v1, c1;
	const int INF = 1000000;
	
	cin >> n;
	
	vector<vector<int> > v(n), c(n);
	vector<int> w(n, INF);
	vector<bool> f(n, false);

	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v1 >> c1;
			v[u].push_back(v1);
			c[u].push_back(c1);
		}
	}

	w[0] = 0;

	while (true) {
		int k = -1;
		for (int i = 0; i < n; i++)
			if (!f[i] && (k == -1 || w[i] < w[k]))
				k = i;

		if (k == -1)
			break;

		f[k] = true;

		for (int i = 0; i < (int)v[k].size(); i++)
			w[v[k][i]] = min(w[v[k][i]], w[k] + c[k][i]);
	}

	for (int i = 0; i < n; i++)
		cout << i << " " << w[i] << endl;

	return 0;
}


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

class Main{
	public static void main(String args[]){
		// 標準入力準備
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = new String();
		try{
			while((str = br.readLine()) != null){
				// nを取得して配列を作成
				int n = Integer.parseInt(str);
				if(n == 0) return;
				int tallMatrix[][] = new int[n][n];
				boolean isLeftUp[][] = new boolean[n][n];
				boolean isRightUp[][] = new boolean[n][n];

				// 行列を入力
				for(int row = 0; row < n; row++){
					str = br.readLine();
					String array[] = str.split(" ");
					for(int column = 0; column < n; column++){
						tallMatrix[row][column] = Integer.parseInt(array[column]);
					}
				}
				//printMatrix(tallMatrix);

				// 左手を挙げる
				for(int row = 0; row < n; row++){
					// 一番低い身長を求める
					int shortestScore = tallMatrix[row][0];
					for(int column = 1; column < n; column++){
						if(tallMatrix[row][column] < shortestScore)
							shortestScore = tallMatrix[row][column];
					}
					// 一番低い人の手を挙げさせる
					for(int column = 0; column < n; column++){
						if(tallMatrix[row][column] == shortestScore)
							isLeftUp[row][column] = true;
					}
				}
				//printMatrix(isLeftUp);

				// 右手を挙げる
				for(int column = 0; column < n; column++){
					// 一番高い身長を求める
					int tallestScore = tallMatrix[0][column];
					for(int row = 1; row < n; row++){
						if(tallMatrix[row][column] > tallestScore)
							tallestScore = tallMatrix[row][column];
					}
					// 右手を挙げさせる
					for(int row = 0; row < n; row++){
						if(tallMatrix[row][column] == tallestScore)
							isRightUp[row][column] = true;
					}
				}

				// 両手を挙げている生徒の身長を求める
				int resultTall = 0;
				for(int row = 0; row < n; row++){
					for(int column = 0; column < n; column++){
						if(isLeftUp[row][column]&&isRightUp[row][column]){
							resultTall = tallMatrix[row][column];
							break;
						}
					}
					if(resultTall != 0) break;
				}
				System.out.println(resultTall);

			}
		}catch(Exception e){
			System.err.println(e);
		}
	}

	static void printMatrix(int matrix[][]){
		for(int row = 0; row < matrix.length; row++){
			for(int column = 0; column < matrix[row].length; column++){
				System.out.print(matrix[row][column] + "\t");
			}
			System.out.println();
		}
	}

	static void printMatrix(boolean matrix[][]){
		for(int row = 0; row < matrix.length; row++){
			for(int column = 0; column < matrix[row].length; column++){
				System.out.print(matrix[row][column] + "\t");
			}
			System.out.println();
		}
	}
}

/*
 * 上級アルゴリズムのクラスでは，n^2 の生徒が n*n に座っている
 */

Measured memory_bytes: 16940
N,X,D=map(int,input().split())
f,c,r={},[0]*10**8,0
for x,y,z in sorted((((N-k)*j+~-k)*k//2+k*X//D,j,k*X%D) if D else (0,j,k*(X!=0))for k in range(N+1)for j in[0,2]):
 if c[z]+y<1:
  f[z]=x
 r+=(x-f[z]+1)*(c[z]<y)
 c[z]-=y-1
print(r)

Measured memory_bytes: 887720
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll h[100000];
ll tmp[100000];
ll n,a,b;
bool judge(ll k){
  for(int i=0;i<n;++i){
    tmp[i]=h[i]-b*k;
  }    
  ll cnt=0;
  for(int i=0;i<n;++i){
    if(tmp[i]>0){
      cnt+=tmp[i]/(a-b);
      if(tmp[i]%(a-b))
	++cnt;
    }
  }
  return (cnt<=k);
}
int main(){
  cin>>n>>a>>b;
  for(int i=0;i<n;++i)
    cin>>h[i];
  sort(h,h+n);
  reverse(h,h+n);
  ll lb=0;
  ll ub=1<<30LL;
  for(int i=0;i<61;++i){
    ll k = (lb+ub)/2;
    if(judge(k))
      ub = k;
    else
      lb = k;
  }
  cout << ub << endl;
  return 0;
}


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

int abs(int i, int j) {
  if (i - j > 0) {
    return i - j;
  } else {
    return j - i;
  }
}
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  vector<int> cost(N, INT_MAX);
  rep(i, N) { cin >> h.at(i); }
  cost.at(0) = 0;
  for (int i = 1; i < N; i++) {
    int j = max(0, i - K);
    for (; j < i; j++) {
      cost.at(i) = min(cost.at(j) + abs(h.at(j), h.at(i)), cost.at(i));
    }
  }
  cout << cost.at(N - 1) << endl;
}


Measured memory_bytes: 1024
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    print(a+a*a+a*a*a)
    return





a = RN()
solve()


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

int main( ) {
  int D;
  cin >> D;
  
  if(D == 25){
    cout << "Christmas" << endl;
  } else if (D == 24) {
    cout << "Christmas Eve" << endl;
  } else if (D == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else if (D == 22) {
    cout << "Christmas Eve Eve Eve" << endl;
  } else {
    cout << "error" << endl;
  }
  
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	nNodes := scanInt(sc)
	nConns := scanInt(sc)

	graph := make([][]int, nNodes)
	for i := 0; i < nConns; i++ {
		a, b := scanInt(sc), scanInt(sc)
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	groups := make([]int, nNodes)

	var setGroups func(int, int)
	setGroups = func(u int, groupId int) {
		if groups[u] > 0 {
			return
		}
		groups[u] = groupId

		for _, v := range graph[u] {
			setGroups(v, groupId)
		}
	}
	for i := 0; i < nNodes; i++ {
		setGroups(i, i+1)
	}

	nQuestions := scanInt(sc)

	w := bufio.NewWriter(os.Stdout)
	var ans string
	for i := 0; i < nQuestions; i++ {
		a, b := scanInt(sc), scanInt(sc)
		if groups[a] == groups[b] {
			ans = "yes"
		} else {
			ans = "no"
		}
		fmt.Fprintln(w, ans)
	}
	w.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}



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

using namespace std;

int main(){

	int n, aux;
	string s;

	cin >> n >> s;

	if(s.size()<=n){
		cout << s << endl;
	}
	else{
		
		for(int i=0;i<n;i++){
			cout << s[i];
		}

		cout << "...\n";
	}

	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long k,a,b;  cin >> k >> a >> b;

    if(b-a<=2){
        cout << k+1 << endl;
        return 0;
    }

    long long  ans=1;

    k -= a-1;
    ans+=a-1;
    ans+=(k/2)*b;
    ans-=(k/2)*a;
    ans+=k%2;

    cout << ans << endl;
}

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

using namespace std;

int main(void) {

    int N;
    string s;
    long long r, g, b;
    int i, j, k;
    long long sum;
    int ij;

    r = 0;
    g = 0;
    b = 0;

    cin >> N;
    cin >> s;

    for (i = 0; i < N; i++) {
        if (s[i] == 'R') {
            r++;
        }else if(s[i] == 'G') {
            g++;
        }else if(s[i] == 'B') {
            b++;
        }
    }

    sum = r * g * b;

    if (sum == 0) {
        cout << sum << endl;
        return 0;
    }

    // 条件2を満たすもの
    for (i = 1; i <= N - 2; i++) {
        for (j = i + 1; j <= N - 1;j++) {
            if (s[i - 1] == s[j - 1]) {
                continue;
            }
            
            ij = abs(i - j);
            k = j + ij;

            if (k <= N) {
                if (s[i - 1] != s[k - 1] && s[j - 1] != s[k - 1]) {
                    sum--;
                }
            } 

        }
    }
    
    if (sum < 0) {
        sum = 0;
    }

    cout << sum << endl;

    return 0;    
}

Measured memory_bytes: 3648
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define N 1020
#define MOD 1000000007
using namespace std;

class Matrix
{
public:
    int x[2][2];

    Matrix(void)
    {
        memset(x, 0, sizeof(x));

        return;
    }

    Matrix operator*(const Matrix &that) const
    {
        Matrix o;

        o.x[0][0] = ((long long)this -> x[0][0] * that.x[0][0] + (long long)this -> x[0][1] * that.x[1][0]) % MOD;
        o.x[0][1] = ((long long)this -> x[0][0] * that.x[0][1] + (long long)this -> x[0][1] * that.x[1][1]) % MOD;
        o.x[1][0] = ((long long)this -> x[1][0] * that.x[0][0] + (long long)this -> x[1][1] * that.x[1][0]) % MOD;
        o.x[1][1] = ((long long)this -> x[1][0] * that.x[0][1] + (long long)this -> x[1][1] * that.x[1][1]) % MOD;

        return o;
    }

    Matrix operator^(long long that) const
    {
        Matrix x, o;

        x = *this;
        o.x[0][0] = o.x[1][1] = 1;
        for(; that; that >>= 1)
        {
            if(that & 1)
                o = o * x;
            x = x * x;
        }

        return o;
    }
};

char a[N][N];

int Power(int x, long long y)
{
    int o;

    for(o = 1; y; y >>= 1)
    {
        if(y & 1)
            o = (long long)o * x % MOD;
        x = (long long)x * x % MOD;
    }

    return o;
}

int main(void)
{
    int n, m;
    long long k;
    int i, j, c, x, y;
    Matrix t;

    scanf("%d %d %lld", &n, &m, &k);
    for(i = c = 0; i < n; i ++)
    {
        scanf("%s", a[i]);
        for(j = 0; j < m; j ++)
            c += a[i][j] == '#';
    }

    for(i = x = 0; i < n; i ++)
        x += a[i][0] == '#' && a[i][m - 1] == '#';
    for(i = y = 0; i < m; i ++)
        y += a[0][i] == '#' && a[n - 1][i] == '#';

    if(x && y)
        printf("1\n");
    else if(!x && !y)
        printf("%d\n", Power(c, k - 1));
    else if(x)
    {
        for(i = 0; i < n; i ++)
            for(j = 1; j < m; j ++)
                y += a[i][j] == '#' && a[i][j - 1] == '#';
        t.x[0][0] = c;
        t.x[0][1] = (MOD - y) % MOD;
        t.x[1][1] = x;
        t = t ^ (k - 1);
        printf("%d\n", (t.x[0][0] + t.x[0][1]) % MOD);
    }
    else
    {
        for(i = 1; i < n; i ++)
            for(j = 0; j < m; j ++)
                x += a[i - 1][j] == '#' && a[i][j] == '#';
        t.x[0][0] = c;
        t.x[0][1] = (MOD - x) % MOD;
        t.x[1][1] = y;
        t = t ^ (k - 1);
        printf("%d\n", (t.x[0][0] + t.x[0][1]) % MOD);
    }

    return 0;
}


Measured memory_bytes: 1280
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

const ll HMAX=1010;
vector<vector<char>> S(HMAX,vector<char>(HMAX,'#'));


int main(){
    ll H,W;
    cin>>H>>W;
    ll Ch,Cw,Dh,Dw;
    cin>>Ch>>Cw;
    cin>>Dh>>Dw;
    Ch++;
    Cw++;
    Dh++;
    Dw++;

    REP(i,H){
        REP(j,W){
            cin>>S[i+2][j+2];
        }
    }

    //ダイクストラ
    vll dist(HMAX,vl(HMAX,INF));
    priority_queue<tuple<ll,ll,ll>,vector<tuple<ll,ll,ll>>,greater<tuple<ll,ll,ll>>> que;
    
    // 初期条件 (頂点 0 を初期ノードとする)
    dist[Ch][Cw]=0;

    que.push(make_tuple(0,Ch,Cw)); // 0 を橙色頂点にする
    
    
        // 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        
        tuple<ll,ll,ll> p = que.top(); // 優先度キューから先頭頂点を取り出す
        que.pop();
        ll d=get<0>(p);
        ll x=get<1>(p);
        ll y=get<2>(p);

        
        
        if(dist[x][y]<d) continue;

        REP2(i,-2,3){
            REP2(j,-2,3){
                if(S[x+i][y+j]=='#') continue;
                if(i==0&&j==0) continue;
                ll nd;
                if(i==0&&j==1) nd=d;
                else if(i==0&&j==-1) nd=d;
                else if(i==1&&j==0) nd=d;
                else if(i==-1&&j==0) nd=d;
                else{
                    nd=d+1;
                }
                if(nd<dist[x+i][y+j]){
                    dist[x+i][y+j]=nd;
                    que.push(make_tuple(nd,x+i,y+j));
                }
            }
        }
    }

    if(dist[Dh][Dw]==INF) dist[Dh][Dw]=-1;
    cout<<dist[Dh][Dw]<<endl;





}

Measured memory_bytes: 12860
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n + 1)
    
    def root(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])

        return self.par[x]
    
    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1


N, M = map(int, input().split())

uf = UnionFind(N)
for _ in range(M):
    x, y, z = map(int, input().split())
    uf.union(x, y)

ans = 0
for i in range(N+1):
    if uf.par[i] == i:
        ans += 1

print(ans - 1)

Measured memory_bytes: 7856
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll dp[100001];

ll llpow(ll a,ll b){// a^b
    if (b == 0) return 1;

    if((b & 1) == 0) return llpow(a*a%MOD, b/2);
    else return a*llpow(a, b-1)%MOD;
}

int main(){
  ll N, K;
  ll tmp;
  ll ans=0;
  
  scanf("%lld%lld", &N, &K);

  dp[K] = 1;

  for (ll x = K-1; x > 0; x--)
  {
    tmp = llpow(K/x, N);
    for (ll j = 2; x*j <= K; j++)
    {
        tmp = (MOD - dp[x*j] + tmp ) % MOD;
    }
    dp[x] = tmp;
  }

  for (ll i = 1; i <= K; i++)
  {
      ans = (ans + i*dp[i]%MOD) % MOD;
  }
  
  printf("%lld\n", ans);
  
  return 0;
}


Measured memory_bytes: 2892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Xml;

namespace ConsoleApp18
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> list = new List<string>();
            int num = int.Parse(Console.ReadLine());
            for (int i = 0; i < num; i++)
            {
                string n = Console.ReadLine();
                if (n == null)
                    break;
                list.Add(n);
            }
            int ans = list.Distinct().Count();
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 48240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll m; cin >> m;
	print(24+24-m)
	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int a[100100],num[100100];
lint mo=1000000007;
vector<lint> zyo;lint extgcd(lint a, lint b, lint &x, lint &y) {
  lint g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
lint invMod(lint a, lint m) {
  lint x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0;
}
lint co(int a,int b){
	if(a<0 || b<0 || a<b) return 0;
	return ((zyo[a]*invMod(zyo[b],mo))%mo*invMod(zyo[a-b],mo))%mo;
}
int main()
{
	int n,d=-1;
	zyo.pb(1);rep(i,200100) zyo.pb((zyo[i]*(i+1))%mo);
	cin>>n;n++;
	rep(i,n) cin>>a[i];
	memset(num,-1,sizeof(num));
	rep(i,n){
		if(num[a[i]]<0) num[a[i]]=i;
		else d=i-num[a[i]];
	}
	REP(i,1,n+1){
		lint ret=co(n,i)-co(n-d-1,i-1);
		ret%=mo;ret+=mo;ret%=mo;
		cout<<ret<<endl;
	}
}


Measured memory_bytes: 3696
from functools import *

H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

ans_list = ([[i+1] * a[i] for i in range(N)])
ans_list = reduce(lambda a, b: a + b, ans_list)

for i in range(H):
    ans = ans_list[i*W:i*W+W] if i%2 == 0 else ans_list[i*W+W-1:i*W-1:-1]
    print(*ans)

Measured memory_bytes: 5208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();
        int d = sc.NextInt();

        bool ok = true;

        while (true)
        {
            c = c - b;
            if (c <= 0)
            {
                break;
            }
            a = a - d;
            if (a <= 0)
            {
                ok = false;
                break;
            }
        }

        string answer = ok ? "Yes" : "No";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27548
#include<stdio.h>

void addition(int a[101][101],int r,int c){
	int i_r, i_c;
	for (i_r = 0; i_r < r; i_r++){
		for (i_c = 0; i_c < c; i_c++){
			a[i_r][c] = a[i_r][c] + a[i_r][i_c];
		}
	}
	for (i_c = 0; i_c < c; i_c++){
		for (i_r = 0; i_r < r; i_r++){
			a[r][i_c] = a[r][i_c] + a[i_r][i_c];
		}
	}
	for (i_c = 0; i_c < c; i_c++){
			a[r][c] = a[r][c] + a[r][i_c];
	}
}

int main(void){
	int r, c;
	int a[101][101] = { 0 };
	scanf("%d %d",&r,&c);
	int i_r, i_c;
	for (i_r = 0; i_r < r; i_r++){
		for (i_c = 0; i_c < c; i_c++){
			scanf("%d", &a[i_r][i_c]);
		}
	}

	addition(a, r, c);
	for (i_r = 0; i_r < r+1; i_r++){
		for (i_c = 0; i_c < c; i_c++){
			printf("%d ", a[i_r][i_c]);
		}
                printf("%d", a[i_r][i_c]);
		putchar('\n');
	}


	return 0;
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;

int n,m,k,sx,sy;
char mp[805][805];
int vis[805][805],f[805][805];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int mask;

struct node{
	int x,y,step;
};

void bfs2(){
	queue<node> q;
	q.push(node{sx,sy,0});
	vis[sx][sy] = 1; f[sx][sy] = 1;
	while(!q.empty()){
		int x=q.front().x, y=q.front().y, s=q.front().step;
		q.pop();
		for(int i=0; i<4; i++){
			int tx=x+dx[i],ty=y+dy[i];
			if(tx<1 || tx>n || ty<1 || ty>m || mp[tx][ty]=='#' || vis[tx][ty]) continue;
			// if(tx==1 || tx==n || ty==1 || ty==m) { mask=1; return ;}
			vis[tx][ty] = 1;
			int t = s+1;
			if(t <= k) f[tx][ty] = 1;
			q.push(node{tx,ty,t});
		}
	}
}

int main(){
	cin >> n >> m >> k;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++){
			scanf(" %c",&mp[i][j]);
			if(mp[i][j] == 'S') sx=i,sy=j;
		}

	MS(vis);
	bfs2();
	// if(mask){
	// 	cout << 1 << endl;
	// 	return 0;
	// }
	// MS(vis);
	// int ans = bfs();

	int t = INF;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++){
			if(f[i][j]){
				// cout << i << " " << j << endl;
				t = min(t,min(n-i,min(i-1,min(m-j,j-1))));
			}
		}
	int ans;
	// cout << t << endl;
	// if(t%k == 0) ans = t/k;
	// else ans = (t+k)/k;
	ans = ceil(t*1.0/k);
	cout << ans+1 << endl;

    return 0;
}


Measured memory_bytes: 6016