akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

long long dp[101][100010] = {0};

int main () {
    int n, w;
    std::cin >> n >> w;
    int weight[n], value[n];
    for (int i = 0; i < n; ++i) {
        std::cin >> weight[i] >> value[i];
    }

    for(int i = 0; i < n; ++i) {
        for(int sumw=0; sumw <= w; ++sumw) {
            if(sumw - weight[i] >= 0) {
                if(dp[i+1][sumw] < dp[i][sumw - weight[i]]+ value[i]) {
                    dp[i+1][sumw] = dp[i][sumw - weight[i]]+ value[i];
                }
            }
            if(dp[i+1][sumw] < dp[i][sumw]){
                dp[i+1][sumw] = dp[i][sumw];
            }
        }
    }

    std::cout << dp[n][w] << std::endl;


}

Measured memory_bytes: 81532
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	String s = sc.next();
	boolean result = false;
	if (n % 2 == 0) {
	    if (s.substring(0,n/2).equals(s.substring(n/2))) {
		result = true;
	    }
	}
	System.out.print(result ? "Yes" : "No");
    }
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, A, B;
    cin >> N >> A >> B;
    if((min(A, B) == 1 && max(A, B) == 2) && (min(A, B) == N - 1 && max(A, B) == N)) {
        cout << "Borys" << endl;
    } else {
        ll temp = abs(A - B);
        if(temp % 2) cout << "Borys" << endl;
        else cout << "Alice" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 50;
int a[maxn], b[maxn], c[maxn], book[maxn];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		scanf("%d", a + i);
	}
	for(int i = 1; i <= n; i++){
		scanf("%d", b + i);
	}
	for(int i = 1; i < n; i++){
		scanf("%d", c + i);
	}
	long long ans = 0;
	for(int i = 1; i <= n; i++){
		book[a[i]] = 1;
		ans += b[a[i]];
		if(a[i - 1] + 1 == a[i]){
			ans += c[a[i] - 1];
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) {
    cin >> A.at(i);
  }
  bool flag = true;
  REP(i, N) {
    if ((A.at(i) % 2 == 0)) {
      if (!(A.at(i) % 3 == 0 || A.at(i) % 5 == 0))
        flag = false;
    }
  }
  if (flag)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main(){
    LL n;
    vector<vector<int>> f(200, vector<int>(10));
    vector<vector<LL>> p(200, vector<LL>(11));
    vector<int> c(200, 0);
    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<10; j++){
            cin >> f[i][j];
        }
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<11; j++){
            cin >> p[i][j];
        }
    }

    LL tmp_ans;
    LL ans=-2000000000;
    for(int i=1; i<1024; i++){
        int tmp_i = i;
        int idx=0;
        //cout << tmp_i << endl;
        for(int j=0; j<n; j++){
            c[j]=0;
        }
        while(tmp_i>0){
            if(tmp_i&1){
                for(int j=0; j<n; j++){
                    if(f[j][idx]==1){
                        c[j]++;
                    }
                }
            }
            idx++;
            tmp_i >>= 1;
        }
        tmp_ans=0;
        for(int j=0; j<n; j++){
            tmp_ans+=p[j][c[j]];
        }
        if(tmp_ans>ans){
            ans=tmp_ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 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...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using P = pair<int, int>;

vector<vector<int>> G; // adjacency list
vector<ll> num;
vector<bool> used;
vector<P> query;

void dfs(int now, ll sum) {
    num[now] += sum;
    used[now] = true;
    vector<int> nexts = G[now];
    for (auto next : nexts) {
        if (!used[next]) {
            dfs(next, num[now]);
        }
    }
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int N, Q;
    scanf("%d %d", &N, &Q);
    G.resize(N);
    num.resize(N);
    used.resize(N);
    query.resize(Q);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    for (int i = 0; i < Q; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--;
        query[i] = make_pair(a, b);
    }

    REP(i, Q) { num[query[i].first] += query[i].second; }

    dfs(0, 0);

    REP(i, N) { cout << num[i] << endl; }

    return 0;
}


Measured memory_bytes: 32128
n=int(input())
a=[int(j) for j in input().split()]
a.sort()

tmp=0
ans=n
c=1
for i in range(n-1):
    tmp+=a[i]
    if tmp*2<a[i+1]:
        ans-=c
        c=1
    else:
        c+=1
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?(c=getchar()):0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
const int N=101;
char mat[N][N];
short f[N][N][N][N],sum[N][N];
inline int asksum(int x1,int x2,int y1,int y2){
	return x1<=x2&&y1<=y2?sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1]:0;
}
int main(){
	int n=ni,m=ni,ex,ey;
	memset(sum,0,sizeof(sum));
	for(int i=1;i<=n;i++){
		scanf("%s",mat[i]+1);
		for(int j=1;j<=m;j++){
			sum[i][j]=(mat[i][j]=='o')+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
			if(mat[i][j]=='E'){
				ex=i,ey=j;
			}
		}
	}
	for(int i=ex;i>=1;i--){
		for(int j=ex;j<=n;j++){
			for(int k=ey;k>=1;k--){
				for(int l=ey;l<=m;l++){
					short &F=f[i][j][k][l]=0;
					int xs=max(1+(j-ex),i),xt=min(n-(ex-i),j);
					int ys=max(1+(l-ey),k),yt=min(m-(ey-k),l);
					if(i<ex)apmax(F,f[i+1][j][k][l]+asksum(xs,i,ys,yt));
					if(j>ex)apmax(F,f[i][j-1][k][l]+asksum(j,xt,ys,yt));
					if(k<ey)apmax(F,f[i][j][k+1][l]+asksum(xs,xt,ys,k));
					if(l>ey)apmax(F,f[i][j][k][l-1]+asksum(xs,xt,l,yt));
				}
			}
		}
	}
	printf("%d\n",(int)f[1][n][1][m]);
	return 0;
}

Measured memory_bytes: 200960
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    string s; cin >> s;
    int ans = 0;
    rep(i, 0, s.length()){
        int cnt = 0;
        rep(j, i, s.length()){
            if(!(s[j] == 'A' || s[j] == 'G' || s[j] == 'C' || s[j] == 'T')){
                ans = max(ans, cnt);
                break;
            }
            cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 1; i < n; i++){
		if (a[i-1] < a[i]) a[i]--;
		if (a[i-1] > a[i]){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	
}



Measured memory_bytes: 640
from bisect import bisect_left


n,m = list(map(int,input().split()))
a = [[0] for i in range(n)]
b = [None]*m
for i in range(m):
    p,s = list(map(int,input().split()))
    p-=1
    a[p].append(s)
    b[i] = [p,s]
for i in range(len(a)):
    a[i].sort()
for i in range(len(b)):
    ken = b[i][0]
    si = bisect_left(a[ken], b[i][1])
    ken = str(ken+1).zfill(6)
    si = str(si).zfill(6)
    print("".join([ken,si]))

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

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n+23] = {};
    ll sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    double p = (double)sum/(double)(4*m);
    sort(a, a+n, greater<int>());
    bool ok = true;
    for(int i = 0; i < m; i++)
    {
        if((double)a[i] < (p))
        {
            ok = false;
            break;
        }
    }
    if(ok == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

int H,W,h,w;

int main()
{
    cin >> H >> W >> h >> w;
    if(!(H%h) && !(W%w)){
        printf("No\n");
    }
    else{
        printf("Yes\n");
        if(W%w){
            vector<int> SW(W+1,0);
            for(int i = w; i <= W;i+=w){
                SW[i] = -(i/w);
            }

            for(int i = 1; i < w;i++){
                for(int j = i; j <= W;j+=w){
                    SW[j] = 505 - j;
                }
            }

            vector<int> Ws(W,0);
            _rep(i,1,W){
                Ws[i-1] = (SW[i] - SW[i-1]);
            }
            _for(i,0,H){
                _for(j,0,W){
                    if(j) printf(" ");
                    printf("%d",Ws[j]);
                }
                printf("\n");
            }

        }
        else if(H%h){
            vector<int> SH(H+1,0);

            for(int i = h; i <= H;i += h){
                SH[i] = -(i/h);
            }
            for(int i = 1; i < h;i++){
                for(int j = i; j <= H;j+=h){
                    SH[j] = 505 - j;
                }
            }
            
            vector<int> Hs(H,0);
            _rep(i,1,H){
                Hs[i-1] = (SH[i] - SH[i-1]);
            }

            _for(i,0,H){
                _for(j,0,W){
                    if(j) printf(" ");
                    printf("%d",Hs[i]);
                }
                printf("\n");
            }

        }
    }
    return 0;
}


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

int main(void) {
	int i;
	int n, k, x, y;
	int price;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	n = atoi(ch);
	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	k = atoi(ch);
	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	x = atoi(ch);
	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	y = atoi(ch);

	if(n <= k) {
		price = x * n;
	}
	if(n > k) {
		price = x * k + y * (n - k);
	}

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

	return 0;
}


Measured memory_bytes: 2112
N = input()

length = len(N)

n = int(N)

ans = 0

for i in range(1,length):
    if i % 2 == 1:
        ans += 9*(10**(i-1))


# print(ans)
if length % 2 == 1:
    ans += n-10**(length-1)+1

print(ans)
    




Measured memory_bytes: 3064
n,k=map(int,input().split())
x=[0]*n
y=[0]*n
a=[]
for i in range(n):
  x[i],y[i]=map(int,input().split())
  a.append((x[i],y[i]))
ans=4*(10**18)
x.sort()
y.sort()
for i in range(n-1):
  for j in range(i+1,n):
    for l in range(n-1):
      for m in range(l+1,n):
        L=x[i]
        R=x[j]
        D=y[l]
        U=y[m]
        if L==R or U==D:
          continue
        cnt=0
        for s in a:
          if L<=s[0]<=R and D<=s[1]<=U:
            cnt+=1
        if cnt>=k:
          ans=min(ans,(R-L)*(U-D))
print(ans)

Measured memory_bytes: 48988
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

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

    int A[N];
    rep(i,N){
        cin>>A[i];
    }

    rep(i,N-K){
        if(A[i]<A[i+K])cout <<"Yes"<<endl;
        else cout << "No"<<endl;
    }

    



}


Measured memory_bytes: 5204
//Authore :: Rabbi

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define MOD   1000000007
#define PI  acos(-1)
#define clr(x) memset(x,-1,sizeof(x))
#define End return 0
#define Start ios_base::sync_with_stdio(0);cin.tie(0);
int main()
{
 Start;

 ll a,b,c;
 cin>>a>>b;
 if(a>9||b>9)cout<<-1<<endl;
 else cout<<a*b<<endl;

 End;
}




Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>
#include<numeric>

using namespace std;

int main() {
    vector<int> price;
    int N, K, buf, sum = 0;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> buf;
        price.push_back(buf);
    }
    sort(price.begin(), price.end());
    for (int i = 0; i < K; i++) {
        sum += price[i];
    }
    cout << sum;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int n,a;cin>>n>>a;
	int t = n%500;
	if (a-t>=0) {
		ct("Yes");
	} else {
		ct("No");
	}
}

Measured memory_bytes: 256
from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


N, M = map(int, input().split())
mat = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]

ans = N
Q = [set([v for v in range(M)])]
while Q:
    C = Counter()
    sports_cand = Q.pop(0)
    for n in range(N):
        for m in range(M):
            if mat[n][m] in sports_cand:
                C[mat[n][m]] += 1
                break
    tmp = 0
    for key, val in C.most_common():
        if val > tmp:
            tmp = val
            ans = min(ans, val)
            if len(sports_cand) > 2:
                Q.append(sports_cand-{key})
        else:
            break
print(ans)


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

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

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

int main(){
    ll N; cin>>N;
    vector<ll>s(N);
    rep(i,N) cin>>s[i];
    ll ans=0;

    rep1(C,N-1){
        if((N-1)%C==0){
            ll i=0;
            ll tmp=0;
            ll tmpans=0;
            while(N-1-i*C>i*C){
                tmp+=s[N-1-i*C]+s[i*C];
                chmax(tmpans,tmp);
                i++;
            }
            chmax(ans,tmpans);
        }
        else{
            ll tmp=0;
            ll tmpans=0;
            ll x=(N-1-C)/C;
            rep1(i,x){
                tmp+=s[i*C];
                tmp+=s[N-1-i*C];
                chmax(tmpans,tmp);
            }
            chmax(ans,tmpans);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << N*(N+1)/2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
#define M 200005

using namespace std;

lli dp[2005];
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    lli n;

    cin >> n;

    lli ans =1;
    lli x=1;
    lli y = 1;
    for(int i=1;i<=n;i++)
    {
        ans *= 10;
        ans %= mod;
        x *= 9;
        y*= 8;
        x %= mod;
        y %= mod;
    }

    x*=2;
    x%=mod;
    ans -= x;
    ans += y;

    ans += mod;
    ans %= mod;


    cout << ans << endl;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();
        System.out.print(read(num));
    }

    private static String read(long num) {
        if(num<=26) {
            char c = (char)(num+96);
            return String.valueOf(c);
        } else {
            long b = num%26;
            char c = (char)(b+96);
            num = num/26;

            if (b==0) {
                num -= 1;
                c = 'z';
            }
            return read(num) + c;
        }
    }

}

Measured memory_bytes: 39152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=1e9+7;
ll ksm(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
ll f[N],ans=0;
int main(){	
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=k;i>=1;i--){
		f[i]=ksm(k/i,n);
		for(int j=i+i;j<=k;j+=i)
			f[i]=(f[i]-f[j]+mod)%mod;
		ans=(ans+f[i]*i)%mod; 
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 4544
N = int(input())
def function(X):
    c = 0
    for t in range(1,1000):
        if X <= c + 26**t:
            return t, c
        c += 26**t

def function2(n,y):
    if y == 1:
        return chr(ord('a') + ((n-1) // (26**(y-1))))
    else:
        if (n % (26**(y-1))) == 0:
            return chr(ord('a') + ((n-1) // (26**(y-1)))) + function2((26**(y-1)),y-1)
        else:
            return chr(ord('a') + ((n-1) // (26**(y-1)))) + function2((n % (26**(y-1))),y-1)
keta, summ = function(N)
summ = N - summ
print(function2(summ,keta))

Measured memory_bytes: 9184
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
using namespace std;

int main(void)
{
    while (1)
    {
        int a, b;
        cin >> a >> b;
        if (cin.eof())
            break;
        stringstream ss;
        ss << a + b;
        cout << ss.str().length() << endl;
    }
    return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define ll long long 
#define inf 1000000007
using namespace std;
void make_fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int main(){
    make_fast();
	    string s,t;
	    cin>>s>>t;
	    int res=0;
	    for(int i=0;i<s.size();i++)if(s[i]!=t[i])res++;
	    cout<<res<<endl;
}
	   


Measured memory_bytes: 3776
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean f = true;
        for (int i = 0; i < s.length(); i++) {
            if(Algo.isEven(i) && s.charAt(i) == 'L'){
                f = false;
              	break;
            }
            if(Algo.isOdd(i) && s.charAt(i) == 'R'){
                f = false;
                break;
            }
        }
        io.YesNo(f);
    }
}

class io{

    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }
}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



Measured memory_bytes: 21716
/*input
3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

vector<int> a,b,c,d;

int main()
{
	IOS;
	int n;
	cin>>n;
	if(n==3){
		cout<<"2 5 63\n";
		return 0;
	}
	for(int i=4;i<=30000;i++){
		if(i%6==0) a.pb(i);
		else if(i%6==2) b.pb(i);
		else if(i%6==3) c.pb(i);
		else if(i%6==4) d.pb(i);
	}
	int bye=20000-n;

	while(bye){
		if(bye==1){
			a.pop_back();
			bye--;
		}
		else if(SZ(b)){
			b.pop_back();
			d.pop_back();
			bye-=2;
		}
		else if(SZ(c)>=2){
			c.pop_back();
			c.pop_back();
			bye-=2;
		}
		else {
			a.pop_back();
			bye--;
		}
	}
	for(int i:a) cout<<i<<' ';
	for(int i:b) cout<<i<<' ';
	for(int i:c) cout<<i<<' ';
	for(int i:d) cout<<i<<' ';
	cout<<"2 3\n";
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Node[] T = new Node[100005];
		int[] D = new int[100005];
		int d=0;
		int v=0;
		int c=0;
		int l=0;
		
		for(int i=0; i<n; i++){
			T[i] = new Node(-1, -1, -1);
		}
		for(int i=0; i<n; i++){
			v = sc.nextInt();
			d = sc.nextInt();
			for(int j=0; j<d; j++){
				c = sc.nextInt();
				if(j==0){
					T[v].setL(c);
				}else{
					T[l].setR(c);
				}
				l = c;
				T[c].setP(v);
			}
		}
        for(int i = 0; i < n; i++) {
            D[i] = rec(i, T);
        }
        for(int i = 0; i < n; i++) {
            disp(i, T, D);
        }
	}
    static int rec(int u, Node[] T) {
        int d = 0;
        while(T[u].getP() != -1) {
            u = T[u].getP();
            d ++;
        }
        return d;
    }
	
    static void disp(int u, Node[] T, int[] D) {
        int i, c;
        System.out.print("node " + u + ": ");
        System.out.print("parent = " + T[u].getP() + ", ");
        System.out.print("depth = " + D[u] + ", ");
        if(T[u].getP() == -1) {
            System.out.print("root, ");
        }else if(T[u].getL() == -1) {
            System.out.print("leaf, ");
        }else {
            System.out.print("internal node, ");
        }
        System.out.print("[");
        for(i = 0, c = T[u].getL(); c != -1; i++, c = T[c].getR()) {
            if(i != 0) {
                System.out.print(", ");
            }
            System.out.print(c);
        }
        System.out.println("]");
    }
}

class Node {
    private int p, l ,r;
    public Node(int p, int l, int r) {
        this.p = p;
        this.l = l;
        this.r = r;
    }
    int getP() {
        return p;
    }
    int getL() {
        return l;
    }
    int getR() {
        return r;
    }
    void setR(int r) {
        this.r = r;
    }
    void setL(int l) {
        this.l = l;
    }
    void setP(int p) {
        this.p = p;
    }
}


Measured memory_bytes: 136156
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


int
main(void){  
  int c = 0;
  int a[3];
  cin >> a[0] >> a[1] >> a[2];

  SORT(a, 3);

  //cout << a[0] << endl;
  
  int temp = abs(a[1]-a[0]);
  c = temp;  
  c = c +abs(a[2]-a[1]);

  cout << c << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a-1;i>=0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    double a, b;
    cin >> a >> b;
    print(a/b);
}




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

ll pd[200005];
ll rd[200005];
ll Ep(int x, int y){
  if(y == 0) return 1;
  if(y == 1) return x;
  ll r = Ep(x,y/2);
  if(y%2 == 1) return r *r%MOD *x%MOD;
  else return r *r%MOD;
}
ll Ftl(ll x){
  if(x == 1 || x == 0) return 1;
  if(pd[x] != 0) return pd[x];
  return pd[x] = Ftl(x-1) *x%MOD;
}
ll rFtl(ll x){
  if(x == 1 || x == 0) return 1;
  if(rd[x] != 0) return rd[x];
  return rd[x] = rFtl(x-1)*Ep(x,MOD-2)%MOD;
}
ll comb(ll m, ll n){
  if(m < n) return 0;
  return Ftl(m) *rFtl(n)%MOD *rFtl(m-n)%MOD;
}

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  ll ans = 0;
  for(int i=0; i<=k; ++i){
    ll nans = m * Ep(m-1,n-i-1) %MOD;
    nans *= comb(n-1,i);
    nans %= MOD;
    ans += nans;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 12976
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	k := stdin.ReadInt()

	if k == 1 {
		stdout.Println(n * (n - 1) % MOD)
	} else if n <= k {
		stdout.Println(H(n, n))
	} else {
		ans := 0
		for m := 0; m <= k; m++ {
			ans += C(n, m) * H(n-m, m)
			ans %= MOD
		}
		stdout.Println(ans)
	}

}

const MOD = 1000000007

var FCT = []int{1}

func ModPow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x = (x * x) % MOD
			y /= 2
		} else {
			z = (z * x) % MOD
			y--
		}
	}
	return z
}

func ModInv(x int) int {
	return ModPow(x, MOD-2)
}

func C(n, r int) int {
	for i := len(FCT); i <= n; i++ {
		FCT = append(FCT, FCT[i-1]*i%MOD)
	}
	return FCT[n] * (ModInv(FCT[n-r]) * ModInv(FCT[r]) % MOD) % MOD
}

func H(n, r int) int {
	return C(n+r-1, r)
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 13440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  ll cnt=0;
  while(a>=b) {
    b*=2;
    cnt++;
  }
  while(b>=c) {
    c*=2;
    cnt++;
  }
  if(cnt<=k) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using ll=long long int;
using namespace std;
typedef pair<int, int>pi;
int main() {
	int n; cin >> n;
	int ac = 0; int tle = 0;
	int wa = 0; int re = 0;
	while(n--) {
		string s; cin >> s;
		if (s == "TLE")tle++;
		else if (s == "WA")wa++;
		else if (s == "AC")ac++;
		else re++;
	}
	cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";
	return 0;
}

Measured memory_bytes: 3588
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

	string s;
	cin >> s;

	if (n % 2 != 0)
	{
		cout << "No" << endl;
		return 0;
	}

	int h = n / 2;
	rep(i, h)
	{
		if (s[i] != s[i + h])
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int k,a,b;
    cin>>k>>a>>b;
    bool f=false;
    for(int i=1;i<=1000;i++){
        if(a<=i*k&&k*i<=b){
            f=true;
            break;
        }
    }
    if(f)OUT("OK");
    else OUT("NG");
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x >= r && y >= r && W-r >= x && H-r >= y){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3104
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int n;
int arr[25][25];
int bits[2100005];
long long memo[2100005];
vector<int> v;
int all;
bool cmp(int i,int j){ return bits[i]<bits[j];}
void init(){
    int ans,bm;
    for (int x=0;x<=all;x++){
        v.push_back(x);
        ans=0;
        bm=x;
        while (bm){
            ans++;
            bm^=bm&-bm;
        }
        bits[x]=ans;
    }
    sort(v.begin(),v.end(),cmp);
}
int main(){
    //freopen("input.txt","r",stdin);
    scanf("%d",&n);
    for (int x=0;x<n;x++){
        for (int y=0;y<n;y++){
            scanf("%d",&arr[x][y]);
        }
    }
    all=(1<<n)-1;
    init();
    int bm;
    memo[0]=1;
    for (int x=0;x<v.size();x++){
        memo[v[x]]%=1000000007;
        //printf("%d %lld %d\n",v[x],memo[v[x]],bits[v[x]]);
        bm=v[x]^all;
        while (bm!=0){
            if (arr[bits[v[x]]][__builtin_ctz(bm)]==1){
                memo[v[x]|(bm&-bm)]+=memo[v[x]];
            }
            bm-=bm&-bm;
        }
    }
    printf("%d\n",memo[all]);
}


Measured memory_bytes: 33128
import java.util.Scanner;

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

        int res = 0;

        for(int a=0; a<=A; a++){
            for(int b=0; b<=B; b++){
                int c = (X-a * 500 - b*100) / 50;
                if(c >= 0 && c <=C)
                    res++;
            }
        }
        System.out.println(res);
    }
}


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

// #define ANS  //for answer
#define CMP  //for compe

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x,(x)
#define ncv(x) #x,":",(x)
#define ncvc(x) #x,":",(x),","
using ll = long long;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>void pPRINT(std::ostream& ost,const T t,const U... u) {ost<<t<<" ";pPRINT(ost, u...);}
template <class... T>void PRINT(const T... t) {pPRINT(std::cout, t...);}
template <class... T>void PRINTl(const T... t){pPRINT(std::cout,t...);std::cout<<"\n";}
template <class T>void PRINTa(const T* const t,const ll size){REP(i,size)PRINT(t[i]);PRINTl();}
template <class T>void PRINTal(const T* const t,const ll size){REP(i,size)PRINTl(i,":",t[i]);}
#ifdef CMP
using namespace std;
#else
#endif
#ifndef DBG
#define DEBUG(...)
void init(){}
#else
#define DEBUG(...) PRINT("##DEBUG##","file :",__FILE__,", line :",__LINE__,"[");PRINT(__VA_ARGS__);PRINTl("]");
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

void solve();

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

  init();
  DEBUG();
  solve();

  return 0;
}

void solve(){

  DEBUG("SOLVE START");

  ll n;cin>>n;
  string s[n];REP(i,n)cin>>s[i];
  REP(i,n){sort(&(s[i])[0],&(s[i])[0]+10);}
  // PRINTal(s,n);
  bool a[n]={};
  map<string,int> mp;
  REP(i,n)mp[s[i]]++;
  ll ans=0;
  for(auto&& v:mp){
    ll val = v.second;
    ans+=val*(val-1)/2;
  }
  PRINT(ans);

}

Measured memory_bytes: 18304
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val t = (listOf(0) + readLine()!!.split(" ").map{it.toInt()} + listOf(0)).toIntArray()
    val v = listOf(0) + readLine()!!.split(" ").map{it.toInt()} + listOf(0)

    for (i in 1 until t.size) {
        t[i] += t[i - 1]
    }

    val mx = Array(20010) { 0 }
    val mx2 = Array(20010) { 0 }

    for (i in 1 .. N) {
        mx[t[i-1]] = Math.min(v[i - 1], v[i])
        mx2[t[i-1]] = v[i]
        for (j in t[i - 1] + 1 until t[i]) {
            mx[j] = v[i]
            mx2[j] = v[i]
        }
    }

    val a = Array(20010) { 0 }

    for (k in 1..110) {
        for (i in 1 until 20008) {
            if (a[i - 1] - a[i] >= 0 && a[i + 1] - a[i] >= 0 && a[i] + 1 <= mx[i]) {
                a[i]++
            }
        }
    }

    var res = 0.0

    for(i in 1 until a.size) {
        if (a[i - 1] == a[i] && a[i - 1] < mx2[i - 1]) {
            res += a[i] + 0.25
        } else {
            res += (a[i - 1] + a[i]) / 2.0
        }
    }

    System.out.printf("%1.10f\n", res)
}


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

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
    	String[] n = br.readLine().split(" ");
        int r = Integer.parseInt(n[0]);
        int c = Integer.parseInt(n[1]);
        int[][] rc = new int[r][c];
        int[] yoko = new int[r];
        int[] tate = new int[c];
        int sum = 0;
        for (int i = 0; i < r; i++)
        {
        	String[] rcinput = br.readLine().split(" ");
        	for (int j = 0; j < c; j++)
        	{
        		rc[i][j] = Integer.parseInt(rcinput[j]);
        		yoko[i] += Integer.parseInt(rcinput[j]);
        		tate[j] += Integer.parseInt(rcinput[j]);
        		sum += Integer.parseInt(rcinput[j]);
        	}
        }
        
        for (int i = 0; i < r + 1; i++)
        {
        	for (int j = 0; j < c + 1; j++)
        	{
        		if (i < r && j <c)
        			System.out.print(rc[i][j] + " ");
        		else if (j == c && i != r)
        			System.out.println(yoko[i]);
        		else if (i == r && j != c)
        			System.out.print(tate[j] + " ");
        		else if (i == r && j == c)
        			System.out.println(sum);
        	}
        }
	}

}

Measured memory_bytes: 31252
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  MAX = 10**9 + 7
  
  n = int(input())
  grid = [list(input().strip()) for _ in range(2)]
  
  i = 0
  lx = []
  while i < n:
    if grid[0][i] == grid[1][i]:
      lx.append('-')
      i += 1
    else:
      lx.append('=')
      i += 2
  
  cnt = 3 if lx[0] == '-' else 6
  for i in range(1, len(lx)):
    if lx[i-1] == '-' and lx[i] == '-':
      cnt *= 2
    if lx[i-1] == '-' and lx[i] == '=':
      cnt *= 2
    if lx[i-1] == '=' and lx[i] == '-':
      cnt *= 1
    if lx[i-1] == '=' and lx[i] == '=':
      cnt *= 3
    cnt %= MAX
  print(cnt)
  

if __name__=='__main__':
  main()



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

#define ll            long long
#define pb            push_back
#define si            set <int>
#define F             first
#define S             second
#define mii           map<int ,int >
#define msi           map<string,int >
#define mis           map<int , string>
#define fr(i,a,b)     for(int  i=a;i<=b;i++)
#define loop(i,n)     for(int i=0;i<n;i++)
#define all(v)        v.begin(),v.end()
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define mp            make_pair
#define input(arr,n)  loop(i,n) cin>>arr[i]
#define output(arr,n) loop(i,n) cout<<arr[i]<<" "
#define mod           998244353
#define sof           sizeof
using namespace std;
int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}

bool isPrime(int num){
    
    if(num==2) return true;
    if(num<2 || num%2==0) return false;
    for(int i = 3; i*i <=num; i+=2) {
       if(num % i == 0) {
          
          return false;
       }
    }
    return true;
   
}

bool comp(const pair<int,int> &a,const pair<int,int> &b){
  return a.F>b.F;
}


ll w[100]; int v[100];
ll dp[100][100001];
void solve(){
  //cout<<"gadbad";
 
  int n,W;
  

  cin>>n>>W;
  loop(i,100){
    loop(j,100001) dp[i][j]=1e18;
  }

  loop(i,n) cin>>w[i]>>v[i];
  
  

  dp[0][0]=0;
  dp[0][v[0]]=w[0];

  for(int i=1;i<n;i++){
    dp[i][0]=0;
    for(int j=1;j<100001;j++){

        dp[i][j]=dp[i-1][j];

        if(j>=v[i]){
          dp[i][j]=min( dp[i][j], w[i] +dp[i-1][j-v[i]]);
        }
  
    }
  }

  ll ans;
  for(int i=100000;i>=0;i--){
    if(dp[n-1][i]<=W){
      ans=i;
      break;
    }
  }
  cout<<ans;


}




signed main()   
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif  

  int t;
  t=1;
  //cin>>t;
  loop(i,t){

      solve();
      if(i<t-1) cout<<"\n";
  }

  
  
  //directed graph
    



}
  


  



Measured memory_bytes: 81764
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] height = new int[N];
		int count = 0;
		int anser =0;
		for(int i = 0; i<N;i++) {
			height[i] = sc.nextInt();
		}
		//一つずつ確認して大きければanserに入れる。
		for(int num = 0; num<N-1; num++) {
				if(height[num] >= height[num+1]) {
					count++;
				}else {
					count = 0;
				}
				anser = anser<=count? count:anser;
			}
		System.out.println(anser);
	}
}

Measured memory_bytes: 50664
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",&x)
#define rep(i,a,b) for(int i = a ; i <= b ; i++)
#define per(i,a,b) for(int i = b ; i >= a ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 5e18;
const int mod = 1e4 + 7;
const int maxn = 2e5 + 7;

int main() {
    LL a,b,c;
    while(cin >> a >> b >> c) {
        if(c - a - b < 0) cout << "No" << endl;
        else {
            if(4LL * a * b < (c - a - b) * (c - a - b)) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf_8 -*-

level = False
def debug(v):
    if level:
        print(v)

n = int(input())
a = [0]

for i in range(n):
    v = input().split()
    v.pop(0)
    v.pop(0)
    a.append([int(x) for x in v])

debug(a)
stack = [1]
results = [[0 for i in range(2)] for j in range(n + 1)]
results[0][0] = 0
time = 0

def depth_first_search(a, stack):
    debug(a)
    debug(results)
    debug(stack)
    global time
    if len(stack) == 0:
        return

    v = stack.pop()
    if results[v][0] == 0:
        time += 1
        results[v][0] = time

    es = a[v]
    if len(es) == 0 and results[v][1] == 0:
        time += 1
        results[v][1] = time

    if len(es) != 0:
        stack.append(v)
        next_vert = es.pop(0)
        if results[next_vert][0] == 0:
            stack.append(next_vert)

    depth_first_search(a, stack)

for i in range(n):
    stack = [i + 1]
    depth_first_search(a, stack)

debug(results)

results.pop(0)

i = 1
for row in results:
    print(str(i) + " " + str(row[0]) + " " + str(row[1]))
    i += 1

Measured memory_bytes: 7852
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fr(i, n) for (ll i = 0; i < n; i++)
#define Fr(i, k, n) for (ll i = k; i <= n; i++)
void solve();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // Single Test Case?cin>>t;
    while (t--) {
        solve();
        cout << "\n";
    }
    //	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs"<<
    //"\n";
}
void solve() {
    int x;
    cin >> x;
    (x == 0) ? cout << 1 : cout << 0;
}

Measured memory_bytes: 3644