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

int main()
{
	int n, m, l, i, j, k;
	cin >> n >> m >> l;

	int Anm[101][101];
	int Bml[101][101];
	long Cnl[101][101] = {};
	for (i = 0; i<n; i++)
	{
		for (k = 0; k<m; k++)
		{
			cin >> Anm[i][k];
		}
	}
	for (k = 0; k<m; k++)
	{
		for (j = 0; j<l; j++)
		{
			cin >> Bml[k][j];
		}
	}

	for (i = 0; i<n; i++)
	{
		for (j = 0; j<l; j++)
		{
			for (k = 0; k<m; k++)
			{
				Cnl[i][j] += Anm[i][k] * Bml[k][j];
			}
		}
	}

	for (i = 0; i<n; i++)
	{
		for (j = 0, k = 0; j<l; j++, k++)
		{
			if (k != 0){
				cout << " ";
			}
			cout << Cnl[i][j];
		}
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 1324
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
struct Point{
    ll x,y;
};
int main(void){
    ll N;cin>>N;
    Point P[N];
    REP(i,N){
        cin>>P[i].x>>P[i].y;
    }
    ld ans=0;
    WREP(i,N,j,N){
        if(i==j)continue;
        ld dx=P[j].x-P[i].x;
        ld dy=P[j].y-P[i].y;
        ans+=hypot(dx,dy);
    }
    cout<<dcml(10)<<ans/N<<"\n";
    
}

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

int main(){
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	for (int i = 0; i < n; i++){
		cout << ((i == 0) ? "" : " ") << a[n - 1 - i];
	}
	delete[] a;
	cout << endl;
}

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

set<ll> seen;
ll a, b, c, d;

ll gcd(ll x, ll y)
{
    if(!y) return x;
    return gcd(y, x%y);
}

void solve()
{
	ll ans = b-a+1;
	ll x = (a+c-1)/c, y=b/c;
	ll m = (a+d-1)/d, n=b/d;
	ans -= y-x+1;
	ans -= n-m+1;
	ll g = c*d/gcd(c,d);
	ll l = (a+g-1)/g, r=b/g;
	ans += r-l+1;
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> a >> b >> c >> d;
	solve();
	return 0;
}

Measured memory_bytes: 256
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

constexpr int INF{1001001001};
constexpr lint LINF{1001001001001001001ll};
constexpr int MOD{(int)1e9 + 7};
constexpr double EPS{1e-9};
const double PI{acos(-1)};
constexpr int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)(v.size() - 1) ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  char s[100][100];
  int h, w;
  cin >>h >> w;
  rep(i, h) cin >> s[i];

  rep(i, h) rep(j, w) {
    if (s[i][j] == '.') {
      int cnt = 0;
      rep(k, 8) {
        int nx = dx[k] + j, ny = dy[k] + i;
        if (!inside(nx, ny, w, h)) continue;
        if (s[ny][nx] == '#') cnt++;
      }
      s[i][j] = cnt + '0';
    }
  }

  rep(i, h) print(s[i]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A * N, B) << endl;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n, m;
    cin >> n >> m;
    vi a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    vpii r(m);
    rep(i, m) {
        r[i].first = b[i];
        r[i].second = a[i];
    }
    VSORT(r);
    int ans = 0, t = 0;
    rep(i, m) {
        if (t <= r[i].second) {
            ++ans;
            t = r[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,M;
  cin >> N >> M;
  vvi G(N);
  rep(i,M) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i,sz(G[0])) {
    int k = G[0][i];
    rep(j,sz(G[k])){
      if(G[k][j] == N-1) {
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 12016
s=input()
a="2"
if int(s[0])!=2:
        ans="TBD"
else:
        for i in range(1,4):
                a=a+s[i]
        for j in range(5,7):
                a=a+s[j]
        for l in range(8,10):
                a=a+s[l]
        if 20190430>=int(a):
                ans="Heisei"
        else:
                ans="TBD"
print(ans)

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


public class Main{
	static void main() throws Exception{
		int k=sc.nextInt();
		String s=sc.nextLine();
		if(s.length()<=k) {
			pw.println(s);
			return;
		}
		for(int i=0;i<k;i++)pw.print(s.charAt(i));
		pw.println("...");
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int tc=1;
		while(tc-->0)main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}


Measured memory_bytes: 32704
#include <iostream>
using namespace std;
int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a < c && c < b){
    cout << "Yes" << endl;
  }
  else if(b < c && c < a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

using namespace std;

int main()
{
    string instr1,instr2;
    cin >> instr1 >> instr2;
    for(int i=0; i<3; ++i) {
        if(instr1[i]!=instr2[2-i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INT_MAX
#define inf llONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
using namespace std;

const int N = 2e5 + 10;

pair < ll, ll > a[N], tmp;
ll c[N];
ll dp[100];

bool cmp(pair < ll, ll > a, pair < ll, ll > b) {
    return a.first * (b.second + 1) > b.first * (a.second+ 1);
}

void solve() {

    int n; ll T;
    scanf("%d %lld", &n, &T);
    int cnt1 = 0, cnt2 = 0;
    rep(i, 1, n) {
      ll x , y ;
        scanf("%lld %lld", &x, &y);
        if(x == 0) c[++ cnt2] = y + 1;
        else a[cnt1++] = {x , y};
    }

    sort(c + 1 , c + cnt2 + 1);
    sort(a, a + cnt1, cmp);

    rep(i, 1, 30) dp[i] = T + 1;
    dp[0] = 0;
    rep(i, 1, cnt2 ) c[i] += c[i - 1];

    rep(i, 0, cnt1 - 1) {
        dep(j, 1, 30) {
            dp[j] = min(dp[j], (a[i].first + 1) * (dp[j - 1] + 1) + a[i].second);
        }
    }

    int ans = 0;
    rep(i, 0, 30) {
        if(dp[i] > T) continue;
        int add = 0;
        if(cnt2) add = upper_bound(c + 1, c + cnt2 + 1, T - dp[i]) - c - 1;
        ans = max(ans, i + add);
    }
    printf("%d\n", ans);
    return ;
}
int main() {
    solve();

    return 0;
}


Measured memory_bytes: 3584
import java.util.*;

public class Main {

    /* チェックリスト
     * 結果はintの範囲を超えていませんか？(必要な時以外はlongを使いましょう)
     * TLEしそうな処理はありませんか？
     */
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        System.out.println(n * n * n);
    }
}

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

typedef long long ll;
const int N = 2000006;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int a,b;
	cin>>a>>b;
	if( a < b){
		for(int i=0;i<b;i++)cout<<a;
	}else{
		for(int i=0;i<a;i++)cout<<b;
	}
	
	return 0;
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int ans=a*b;
	if(1<=a && a<=9 && 1<=b && b<=9) cout<<ans<<endl;
	else cout<<-1<<endl; 
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int H, W, K;
    cin >> H >> W >> K;
    vector<string> c(H);
    rep(i, H) cin >> c[i];

    int ans = 0;
    rep(h, (1 << H)) rep(w, (1 << W)) {
        int cnt = 0;
        rep(y, H) {
            if (h & (1 << y)) {
                rep(x, W) {
                    if ((w & (1 << x)) && c[y][x] == '#') {
                        ++cnt;
                    }
                }
            }
        }
        if (cnt == K) ++ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n , m , l , r , ans, mx ,mn ;
int main(){
    cin >> n >> m;
    mn = n;
    for(int i = 0 ; i < m  ; i++){
        cin >> l >> r;
        mx = max(mx,l);
        mn = min(mn,r);
    }
    cout << max(mn-mx+1,0);
    return 0;
}

Measured memory_bytes: 256
#ABC 075 B Minesweeper

#数字の入力
#外枠を作ってカウントをやりやすくする
h, w = map(int, input().split())
s = []
waku = "a"*(w+2)
s.append(waku)
for i in range(h):
    kari = "a" + input() + "a"
    s.append(kari)
s.append(waku)
#ここまでで枠付きの文字列を入力した。調べるべきはs[1~h][1~w]
#for i in range(h+2):
#    print(s[i])
new_s = []
new_kari = ""
for i in range(1,h + 1):
    for j in range(1,w+1):
        count = 0
        if s[i][j] == ".":
            for k in range(-1,2):#周辺の1行ずれを探すために-1,0，1を発生させる
                for l in range(-1,2):
                    if s[i+k][j+l] == "#":
                        count += 1
            new_kari += str(count)
        else:
            new_kari += "#"
    new_s.append(new_kari)
    new_kari = ""
for i in range(h):
    print(new_s[i])

Measured memory_bytes: 3064
A, B = [int(ele) for ele in input().split()]


def main():
    ans = "Possible"
    print(ans if solve() else "Impossible")


def solve():
    if A % 3 == 0 or B % 3 == 0 or (A+B) % 3 == 0:
        return True

    return False


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main(){
  int n,m;
  int road[100];
  for(int i =0; i < 100; i++){
    road[i] = 0;
  }
  scanf("%d%d", &n, &m);
  for(int i =0; i < m; i++){
    int a,b;
    scanf("%d%d", &a, &b);
    road[a-1]++;
    road[b-1]++;
  }
  for(int i =0; i < n; i++){
    printf("%d\n", road[i]);
  }
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

bool judge(ll mid){
  for(ll i=2;i*i<=mid;i++){
    if(mid%i==0) return false;
  }
  return true;
}

int main(){
  ll X;
  cin>>X;

  for(ll i=X;;i++){
    if(judge(i)){
      cout<<i<<endl;
      return 0;
    }
  }

  return 0;
}


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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n;
    cin >> n;
    cout << n * n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int mat[3][3];

    for(int i=0; i<3 ; i++){
        for(int j=0; j<3 ; j++){
            scanf("%d",&mat[i][j]);
        }
    }

    int flag =0;

    if(mat[0][0]-mat[0][1] == mat[1][0]-mat[1][1] && mat[1][0]-mat[1][1]==mat[2][0]-mat[2][1]){
        flag=0;
    }
    else{flag=1; goto x;}

    if(mat[0][0]-mat[0][2] == mat[1][0]-mat[1][2] && mat[1][0]-mat[1][2]==mat[2][0]-mat[2][2]){
        flag=0;
    }
    else{flag=1; goto x;}

    if(mat[0][2]-mat[0][1] == mat[1][2]-mat[1][1] && mat[1][2]-mat[1][1]==mat[2][2]-mat[2][1]){
        flag=0;
    }
    else{flag=1; goto x;}




    if(mat[0][0]-mat[1][0] == mat[0][1]-mat[1][1] && mat[0][1]-mat[1][1]==mat[0][2]-mat[1][2]){
        flag=0;
    }
    else{flag=1; goto x;}

     if(mat[0][0]-mat[2][0] == mat[0][1]-mat[2][1] && mat[0][1]-mat[2][1]==mat[0][2]-mat[2][2]){
        flag=0;
    }
    else{flag=1; goto x;}

     if(mat[2][0]-mat[1][0] == mat[2][1]-mat[1][1] && mat[2][1]-mat[1][1]==mat[2][2]-mat[1][2]){
        flag=0;
    }
    else{flag=1; goto x;}





    if(mat[0][0]+mat[2][2] == mat[0][2]+mat[2][0]){
        flag=0;
    }
    else{flag=1; goto x;}


    x:
        if(flag==0){
            printf("Yes");
        }
        else{
            printf("No");
        }


}


Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int dfs(int s, const vector<vector<int>> &opp) {
    vector<int> depth;
    for (int t : opp[s]) {
        depth.push_back(dfs(t, opp));
    }

    if (depth.size() == 0)
        return 1;

    sort(depth.rbegin(), depth.rend());

    int ret = -inf;
    for (int i = 0; i < depth.size(); ++i) {
        ret = max(ret, depth[i] + i + 1);
    }

    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> opp(n);
    for (int i = 1; i < n; ++i) {
        int a;
        cin >> a;
        opp[a - 1].push_back(i);
    }

    cout << dfs(0, opp) - 1 << endl;
    return 0;
}

Measured memory_bytes: 16640
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z=0;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }
    
    // 素数である
    return true;
}
signed main(){
    int n;cin>>n;
    vector<int>v;
    rep(i,2,n+1)if(IsPrime(i))v.ps(i);
    vector<int>cnt;
    rep(i,0,v.size()){
        int c=0;
        rep(j,1,n+1){
            int k=j;
            while(k%v[i]==0){
                c++;
                k/=v[i];
            }
        }
        //cout<<v[i]<<" "<<c<<endl;
        cnt.ps(c);
    }sort(cnt.begin(),cnt.end());
    int a=cnt.end()-lower_bound(cnt.begin(),cnt.end(),4);
    int b=cnt.end()-lower_bound(cnt.begin(),cnt.end(),2);
    int d=cnt.end()-lower_bound(cnt.begin(),cnt.end(),24);
    int e=cnt.end()-lower_bound(cnt.begin(),cnt.end(),14);
    int f=cnt.end()-lower_bound(cnt.begin(),cnt.end(),74);
    //cout<<a<<" "<<b<<endl;
    cout<<a*(a-1)*(b-2)/2+(b-1)*d+e*(a-1)+f<<endl;return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
li_a = input().split()

ndict = defaultdict(int)

for i in li_a:
    ndict[i] += 1

result = 0
for k in ndict.keys():
    if ndict[k] > int(k):
        result += ndict[k] - int(k)
    elif ndict[k] < int(k):
        result += ndict[k]

print(result)


Measured memory_bytes: 20852
n, k = map(int,input().split())
l = list(input().split())
#print(l)
l1 = [i for i in range(10) if i not in l]
#print(l1)
for i in range(n,100000):
  l2 = [False]*len(str(i))
  for j in range(len(str(i))):
    if str(i)[j] not in l:
      l2[j] = True
      a = i
    else:
      break
  if all(l2):
    print(a)
    break
  else:
    continue

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s,t; cin>>s>>t;
  ll n=s.size(), m=t.size();
  for(ll i=n-m+1; i>=0; i--){
    bool tmp=true;
    rep(j,m){
      if(!(s[i+j]=='?'||s[i+j]==t[j])) tmp=false;
    }
    if(tmp){
      rep(j,m){
        s[i+j]=t[j];
      }
      rep(j,n) if(s[j]=='?') s[j]='a';
      cout<<s<<endl;
      return 0;
    }
  }
  cout<<"UNRESTORABLE"<<endl;
}


Measured memory_bytes: 256
from math import gcd, sqrt, pi, floor, ceil
from collections import defaultdict as d
from itertools import combinations as c
from string import ascii_lowercase as a

n = int(input())
dd = d(int)
for i in range(n):
	e = input()
	dd[e] += 1
print('AC x', dd['AC'])
print('WA x', dd['WA'])
print('TLE x', dd['TLE'])
print('RE x', dd['RE'])

Measured memory_bytes: 9988
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.next()
    val b = sc.next()
    val ret = when {
        a == b -> "="
        a > b -> ">"
        a < b -> "<"
        else -> ""
    }
    println(ret)
}

Measured memory_bytes: 31268
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int n,a[100050],sum;
int main(){
	scanf("%d",&n);
	sum=0;
	a[0]=0;
	a[n+1]=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum=sum+abs(a[i]-a[i-1]);
	}
	sum=sum+abs(a[n]);
	for(int i=1;i<=n;i++) printf("%d\n",sum-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1]));
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <string.h>
#include <stdio.h>
#include <queue>
#include <limits.h>
#include <stack>
#include <set>
#include <map>

#define P pair
#define MP make_pair

typedef long long int llint ;

using namespace std;

int n;
int niz[105];
int sol;

int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		if(niz[x]!=10)
		{
			niz[x]=10;
			sol++;
		}
	}
	cout<<sol;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans[2222];
int main()
{
    int n,x,y;cin >> n >> x >> y;
    for(int i=1;i<n;i++)
        for(int j=i+1;j<=n;j++)
            ans[min(j-i,min(abs(x-i)+abs(y-j),abs(y-i)+abs(x-j))+1)]++;
    for(int i=1;i<n;i++)cout << ans[i] << endl;
    return 0;
}

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

int main(){
    string str; cin >> str;
    int q; cin >> q;
    for (int i = 0; i < q; i++){
        string order; cin >> order;
        if (order == "print"){
            int a, b;
            cin >> a >> b;
            for (int i = a; i <= b; i++){
                cout << str[i];
            }
            cout << endl;
        }
        else if (order == "reverse"){
            int a, b;
            cin >> a >> b;
            int j = b;
            for (int i = a; i < j; i++){
                swap(str[i], str[j]);
                j--;
            }
        }
        else if (order == "replace"){
            int a, b;
            string p;
            cin >> a >> b >> p;
            int k = 0;
            for (int i = a; i <= b; i++){
                str[i] = p[k];
                k++;
            }
        }

    }
    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
int solve(const vector<vector<int>> &G) {
    vector<int> conn(G.size()), del(G.size());
    queue<int> Q;
    for (int i = 0; i < G.size(); i++) {
        conn[i] = G[i].size();
        if (conn[i] == 1) Q.push(i);
    }
    while (!Q.empty()) {
        int node = Q.front();
        Q.pop();
        if (del[node]) continue;
        if (conn[node] == 0) return 0;
        del[node] = 1;
        for (int next : G[node]) if (!del[next]) {
            del[next] = 1;
            for (int next2 : G[next]) if (!del[next2]) {
                conn[next2] -= 1;
                if (conn[next2] == 1) Q.push(next2);
            }
        }
    }
    return 1;
}
int main() {
    int N; cin >> N;
    vector<vector<int>> G(N);
    for (int i = 0; i < N - 1; i++) {
        int x, y; cin >> x >> y; x--, y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    cout << (solve(G) == 0 ? "First" : "Second") << endl;
    return 0;
}


Measured memory_bytes: 7292
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as AU
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                 as IM
import           Data.List
import qualified Data.Map                    as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
  s <- getLine
  putStrLn $ solve s

solve s = [h] ++ show len ++ [e]
  where
    h = head s
    e = last s
    len = length $ tail $ init s


Measured memory_bytes: 508
//d
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int n,k;
int a[100010];
int f[100010];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		f[i]=0x3f3f3f3f;
	}
	if(n==2)
	{
		cout<<abs(a[1]-a[2]);
		return 0; 
	}
	f[1]=0;
	f[2]=abs(a[2]-a[1]);
	for(int i=3;i<=k;i++)
	{
		f[i]=f[1]+abs(a[1]-a[i]);
	}
	int tmp;
	for(int i=k+1;i<=n;i++)
	{
		tmp=0x3f3f3f3f;
		for(int j=0;j<=k;j++)
		{
			f[i]=min(f[i],f[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout<<f[n];

	
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <complex>
#include <cmath>
#include <cstdio>
using namespace std;

typedef complex<double> P;

const double EPS = 1e-10;
const double PI = acos(-1);

double cross(const P &a, const P &b){
  return imag(conj(a) * b);
}

double dot(const P &a, const P &b){
  return real(conj(a) * b);
}

struct L : public vector<P>{
  L(const P &a, const P &b){
    push_back(a);
    push_back(b);
  }
};

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b, c) > 0) return +1;
  if(cross(b, c) < 0) return -1;
  if(dot(b, c) < 0) return +2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

P crosspoint(const L &l, const L &m){
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  return m[0] + B / A * (m[1] - m[0]);
}

vector<P> convexCut(const vector<P> &p, const L &l){
  vector<P> q;
  int n = p.size();

  for(int i = 0; i < n; i++){
    P A = p[i];
    P B = p[(i + 1) % n];
    if(ccw(l[0], l[1], A) != -1) q.push_back(A);
    if(ccw(l[0], l[1], A) * ccw(l[0], l[1], B) < 0)
      q.push_back(crosspoint(L(A, B), l));
  }

  return q;
}

double getArea(const vector<P> &v){
  double res = 0;
  for(int i = 0; i < v.size(); i++){
    res += cross(v[i], v[(i + 1) % v.size()]);
  }
  return fabs(res) / 2.0;
}

bool EQ(double a, double b){
  return abs(a - b) < EPS;
}

void solve(const vector<P> &v){
  double allArea = getArea(v);
  double l = 0;
  double h = PI;
  double mid;

  if(2.0 * getArea(convexCut(v, L(P(0, 0), P(cos(l), sin(l))))) - allArea > 0.0){
    swap(l, h);
    l += 2.0 * PI;
  }

  while(true){
    mid = (l + h) / 2.0;
    P p = P(cos(mid), sin(mid));
    vector<P> cut = convexCut(v, L(P(0, 0), p));
    double area = 2.0 * getArea(cut) - allArea;

    if(EQ(area, 0.0)){
      break;
    }

    if(area > 0.0){
      h = mid;
    }
    else{
      l = mid;
    }
  }

  P p = P(10 * cos(mid), 10 * sin(mid));
  printf("%.20f %.20f\n", p.real(), p.imag());
}

int main(){
  int n;

  while(cin >> n, n){
    vector<P> v;

    for(int i = 0; i < n; i++){
      P p;
      cin >> p.real() >> p.imag();
      v.push_back(p);
    }

    solve(v);
  }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int main(){
    int N;
    while(std::cin >> N, !std::cin.eof()){
        int P[100];
        REP(i, N){
            std::cin >> P[i];
        }

        std::sort(P, P+N);

        int sum = 0, penalty = 0;
        REP(i, N){
            sum += P[i];
            penalty += sum;
        }

        std::cout << penalty << std::endl;
    }
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

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

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

#define int  ll
void solve()
{
	int n;
	cin>>n;
	string x;
	cin>>x;
	int num=0;
	rep(i,n){
		if(x[i]=='1')++num;
	}
	int add=num+1,sub=num-1;
	int m_add=0,m_sub=0;
	if(add<=n){
		rep(i,n){
			m_add*=2;
			if(x[i]=='1'){
				m_add+=1;
				m_add%=add;
			}
		}
	}
	if(sub>0){
		rep(i,n){
			m_sub*=2;
			if(x[i]=='1'){
				m_sub+=1;
				m_sub%=sub;
			}
		}
	}
	rep(i,n){
		int mm_add=m_add,mm_sub=m_sub;
		if(x[i]=='0'){
			mm_add+=mod_pow<int>(2,n-i-1,add);
			mm_add%=add;
			int ans=1;
			int div=add;
			while(mm_add>0){
				++ans;
				div=popcount(mm_add);
				mm_add%=div;
			}
			cout<<ans<<"\n";
		}
		else{
			if(sub==0){
				cout<<0<<"\n";
			}
			else{
				mm_sub-=mod_pow<int>(2,n-i-1,sub);
				mm_sub+=sub;
				mm_sub%=sub;
				int ans=1;
				int div=sub;
				while(mm_sub>0){
					++ans;
					div=popcount(mm_sub);
					mm_sub%=div;
				}
				cout<<ans<<"\n";
			}
		}
	}
}
#undef int
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3680
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e2 + 10;
int a[N];
int ans = 1;
void solve(int n, int x, int k)
{
	vector<int> vp;
	int tot = 0;
	for (int i = 1; i <= n; i++)
	{
		if (a[i] % x == 0) continue;
		vp.push_back(a[i] % x);
	}
	sort(vp.begin(), vp.end());
	list<int> v(vp.begin(), vp.end());
	while (!v.empty())
	{
		if (v.back() == x)
		{
			v.pop_back();
			continue;
		}
		if (v.front() == 0)
		{
			v.pop_front();
			continue;
		}
		int o = min(v.front() + 0, x - v.back());
		tot += o;
		v.front() -= o;
		v.back() += o;
	}
	if (tot <= k) ans = max(ans, x);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	for (int i = 1; i * i <= sum; i++)
	{
		if (sum % i) continue;
		solve(n, i, k);
		solve(n, sum / i, k);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np

num = np.array([i=="1" for i in input()])
s_1 = np.array([i%2==0 for i in range(len(num))])
s_0 = np.array([i%2==1 for i in range(len(num))])

#print(num)
#print(s_1)
#print(s_0)

#print(s_1 == num)
#print(s_0 == num)
r_1 = np.sum(s_1 == num)
r_0 = np.sum(s_0 == num)
print(min(r_0, r_1))


Measured memory_bytes: 13668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ios                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define fill(x, v) memset(x, v, sizeof(x))
const ll mod = 1000000007;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
/*
std::cout << std::setprecision(9) << f << '\n';//3.141590000;
map<char,int>::reverse_iterator rit;
*/
// --------dsu-- --------
vector<int> volume(1000000);
vector<int> parent(1000000);

void initialise_dsu()
{
    for (int i = 0; i < volume.size(); i++)
        volume[i] = 1;
    for (int i = 0; i < parent.size(); i++)
        parent[i] = i;
}

int find_par(int v)
{
    return (v == parent[v] ? v : parent[v] = find_par(parent[v]));
}

void union_sets(int a, int b)
{
    a = find_par(a);
    b = find_par(b);
    if (a != b)
    {
        if (volume[a] < volume[b])
            swap(a, b);
        parent[b] = a;
        volume[a] += volume[b];
    }
}

int power(int x, unsigned int y, int p)
{
    int res = 1;

    x = x % p;

    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
//-----------------------------

const int N = 2e3 + 10;
ll dp[N][N];
pll a[N];

int n;
ll solve(ll L, ll R)
{
    if (L > R)
        return 0;
    ll &ret = dp[L][R];
    if (ret >= 0)
        return ret;
    int pos = L + n - 1 - R;
    ret = 1LL * abs(a[pos].second - L) * a[pos].first + solve(L + 1, R);
    ret = max(ret, 1LL * abs(a[pos].second - R) * a[pos].first + solve(L, R - 1));
    return ret;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a, a + n, greater<pll>());
    memset(dp, 255, sizeof(dp));
    ll ret = solve(0, n - 1);
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 42832
s = input()
L = []

ans = float('inf')
for l in s:
    cnl = 0
    anl = 0
    for s_ in s:
        if l == s_:
            anl = max(anl, cnl)
            cnl = 0
        else:
            cnl += 1
    anl = max(anl, cnl)
    ans = min(ans, anl)

print(ans)

Measured memory_bytes: 39408
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N;
	cin >> N;
	vector<ll> A(N);
	vector<ll> B(N);
	rep(i, N) {
		cin >> A[i];
		
	}
	B = A;
	sort(A.begin(), A.end()); 
	rep(i,N){
		if (B[i] == A[N - 1]) {
			cout << A[N - 2] << endl;
		}
		else {
			cout << A[N - 1] << endl;
		}
	}
}


Measured memory_bytes: 4736
N = int(input())
D = list(map(int,input().split()))
c = [0 for i in range(N)]
if D[0] != 0:
	print(0)
	exit()
for d in D:
	c[d] += 1
MOD = 998244353

if c[0] != 1:
	print(0)
	exit()
flag = True
for i in range(N):
	if not flag and c[i] > 0:
		print(0)
		exit()
	if c[i] == 0:
		flag = False

ans = 1
for i in range(1, N):
	if c[i] == 0:
		print(ans)
		exit()
	t = (c[i-1] ** c[i]) % MOD
	ans = (ans * t) % MOD
print(ans)

Measured memory_bytes: 14396
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int Maxn=2e5+5;
int f[Maxn];
int main()
{
	int n,tmp;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		cin>>tmp;
		f[tmp]++;
	}
	for(int i=1;i<=n;i++)
		cout<<f[i]<<endl;
	return 0;
}


Measured memory_bytes: 4300
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define N 405
#define mod 1000000007
using namespace std;
inline int read()
{
	char c=getchar(); int num=0,f=1;
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c<='9'&&c>='0') { num=num*10+c-'0'; c=getchar(); }
	return num*f;
}
int n,c,a[N],b[N],dp[N][N],p[N][N],pre[N][N];
int main()
{
	p[0][0]=1;
	for (int i=1;i<=400;i++)
	{
		p[i][0]=pre[i][0]=1;
		for (int j=1;j<=400;j++) p[i][j]=1ll*p[i][j-1]*i%mod;
	}
	for (int i=1;i<=400;i++)
	 for (int j=0;j<=400;j++) pre[i][j]=(pre[i-1][j]+p[i][j])%mod;
	n=read(); c=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<=n;i++) b[i]=read();
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	 for(int j=0;j<=c;j++)
	  for(int k=0;k<=j;k++)
	  {
		  int tmp=(pre[b[i]][k]-pre[a[i]-1][k]+mod)%mod;
		  dp[i][j]=(dp[i][j]+1ll*dp[i-1][j-k]*tmp%mod)%mod;
	  }
	printf("%d",dp[n][c]);	
	return 0;
}

Measured memory_bytes: 2176
# AOJ 0010 Circumscribed Circle of a Triangle
# 三角形の外接円

require "matrix"

n = gets.to_i

n.times do
  x1, y1, x2, y2, x3, y3 = gets.split(" ").map {|v| v.to_f}
  dx12 = x2 - x1
  dy12 = y2 - y1
  dx13 = x3 - x1
  dy13 = y3 - y1

  # 点 1 を表す位置ベクトル
  r1 = Vector[x1, y1]
  # 点 2 を表す位置ベクトル
  r2 = Vector[x2, y2]
  # 点 1 と点 2 の中点を表す位置ベクトル
  m12 = 0.5 * (r1 + r2)
  # 点 1 から点 2 へのベクトル
  v12 = Vector[dx12, dy12]
  # v12 を 90° 回転したベクトル
  v12v = Vector[-dy12, dx12]

  # 連立方程式
  #  dx12 * s + dx13 * t = (dy13 - dy12) / 2
  # -dy12 * s - dy13 * t = (dx13 - dx12) / 2
  coeff = Matrix[
    [dx12, dx13],
    [-dy12, -dy13]
  ]
  const = Vector[
    0.5 * (dy13 - dy12),
    0.5 * (dx13 - dx12)
  ]
  # 連立方程式を解く
  x = coeff.inv * const

  # 外接円の中心を表すベクトル
  rp = m12 + x[0] * v12v
  px = rp[0]
  py = rp[1]

  # 外接円の半径を求める
  dx1p = px - x1
  dy1p = py - y1
  r = Math.sqrt(dx1p * dx1p + dy1p * dy1p)

  # 出力
  printf "%.3f %.3f %.3f\n", px, py, r
end

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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//#define int long long
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; }
template<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}

    
signed main(void){
    int k;cin>>k;
    queue<ll> que;
    rep(i,9)que.push(i+1);

    ll top;
    rep(i,k){
        top = que.front();
        que.pop();
        if(top % 10 != 0) que.push(top * 10 + top % 10 - 1);
        que.push(top * 10 + top % 10);
        if(top % 10 != 9) que.push(top * 10 + top % 10 + 1);
    }
    cout << top << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int S = sc.nextInt();
    int W = sc.nextInt();
    if (W >= S) {
      System.out.println("unsafe");
    } else {
      System.out.println("safe");
    }
  }
}

Measured memory_bytes: 35700
n, k = gets.split(' ').map(&:to_i)

sum = 0

[*(k+1)..n].each{|b|
  c = n / b
  if c >= 1 then
    sum += c*(b-k)
    if n >= c*b + k then
#      sum += n - (c*b + k) + 1                                                            
      sum += n - (c*b + k)
      sum += 1 if k > 0
    end
  end
}

puts sum


Measured memory_bytes: 3452