akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(char a, char b) {
	return a > b;
}

int main() {
	char s[100010];
	cin >> s;
	int cnt = strlen(s);
	int tmp;
	while (0 < cnt) {
		tmp = cnt;
		if (strncmp("eraser", s + cnt - 6, 6) == 0) {
			cnt -= 6;
		}
		else if (strncmp("erase", s + cnt - 5, 5) == 0) {
			cnt -= 5;
		}
		else if (strncmp("dreamer", s + cnt - 7, 7) == 0) {
			cnt -= 7;
		}
		else if (strncmp("dream", s + cnt - 5, 5) == 0) {
			cnt -= 5;
		}
		if (tmp == cnt) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 384
// Problem : G - Longest Path
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_g
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vvi vector<vi>
#define pb push_back
#define vs vector<string>
#define all(x) x.begin(),x.end()
#define mii map<int,int>
#define vd vector<double>
#define deb(x) cout<<#x<<" -> "<<x<<endl
const int inf=0x3f3f3f3f3f3f3f3f;
#define MAXN 1000005

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

void print(vi &v){
    for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
    cout<<endl;
}

// <--------------------Code Begins Here-------------------->



int dfs(int i,vb &vis,vvi &adj,vi &dp){
	vis[i] = true;
	int maxi = 0;
	for(int x:adj[i]){
		if(!vis[x]){
			maxi = max(maxi,dfs(x,vis,adj,dp));
		}
		else{
			maxi = max(maxi,dp[x]);
		}
	}
	dp[i] = maxi + 1;
	return maxi+1;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    vvi adj(n+1);
    vi ind(n+1);
    for(int i = 0; i < m; i++){
    	int x,y;
    	cin>>x>>y;
    	adj[x].pb(y);
    }
    vb vis(n+1,false);
    vi dp(n+1);
    int ans = 0;
    for(int i = 1; i <= n; i++){
    	if(!vis[i]){
    		ans = max(ans,dfs(i,vis,adj,dp));
    	}
    }
    cout<<ans-1<<endl;
    return 0;
}

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

//Define.
  //string S;
  //int N,M;
  int A,B;
  //int i;
  //string rS;
  //int R;
  
//入力
  //cin >> S;
  //cin >> N >> M;
  cin >> A >> B;
  //cin >> i;

//出力  
  //cout << rS << endl;
  cout << max({A + B, A-B, A*B}) << endl;
 
}


Measured memory_bytes: 256
N = int(input())
b = list(map(int, input().split()))
a = []

for i in range(N):
    tmp = -1
    for j in range(N - i):
        if b[j] == j + 1:
            tmp = j
            
    if tmp != -1:
        a.append(b.pop(tmp))

if len(a) == N:
    for i in range(N - 1, -1, -1):
        print(a[i])
else:
    print(-1)

Measured memory_bytes: 3064
N, M = map(int,input().split())
x = [0]*M
for i in range(M):
    x[i] = input()
y = list(set(x))
s = [0]*len(y)
c = [0]*len(y)
for i in range(len(y)):
    s[i],c[i] = map(int, y[i].split())

error = 0
cnt = [0]*N
ans = [0]*N
for i in range(len(y)):
    cnt[s[i]-1] += 1
    ans[s[i]-1] = c[i]
    if N >=2 and s[i]==1 and c[i] == 0:
        error +=1

if max(cnt) >= 2:
    error += 1


if (N >= 2 and ans[0]==0):
    ans[0] = 1
    
if error >= 1:
    print("-1")
else:
    print("".join(map(str, ans)))

Measured memory_bytes: 3064
/*
    Problem 55
    https://atcoder.jp/contests/abc134/tasks/abc134_e
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<int> LIS;
    for (int i = 0; i < A.size(); i++) {
        auto itr = lower_bound(LIS.begin(), LIS.end(), A[i], greater_equal<int>());
        if (itr == LIS.end())
            LIS.push_back(A[i]);
        else
            *itr = A[i];
    }
    cout << LIS.size() << '\n';
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
ll d[210][210];

void warshall_floyd(int n) {
    for(int k = 0; k < n; k++) {          // 経由する頂点
        for(int i = 0; i < n; i++) {      // 始点
            for(int j = 0; j < n; j++) {  // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    for(int i = 0; i < R; i++) {
        cin >> r[i];
        r[i]--;
    }
    sort(r.begin(), r.end());
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            d[i][j] = inf;
        }
        d[i][i] = 0;
    }
    for(int i = 0; i < M; i++) {
        int A, B, C;
        cin >> A >> B >> C;
        A--;
        B--;
        d[A][B] = C;
        d[B][A] = C;
    }
    warshall_floyd(N);
    ll ans = inf;
    do {
        ll tmp = 0;
        for(int i = 1; i < R; i++) {
            tmp += d[r[i - 1]][r[i]];
        }
        ans = min(ans, tmp);
    } while(next_permutation(r.begin(), r.end()));

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

Measured memory_bytes: 512
#include <iostream> // 「標準的な入出力に関して必要な情報を取って来い」という程度の意味
#include <string> // 文字列を扱う際にインクルードするもの
using namespace std; //cout cin など stdを必要とする機能を記述する際に簡易的に書くために定義

int main() {
    int N, R;
    cin >> N >> R;
    if (N>=10) {
        cout << R << endl;
    } else {
        cout << R+100*(10-N) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18
#define MAX_N 100005


struct UnionFind{
    ll par[MAX_N]; // 親
    ll rank[MAX_N]; // 木の深さ
    ll siz[MAX_N]; // 素集合のサイズ

    // n要素で初期化
    void init(ll n){
        for(ll i=0;i<n;i++){
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }

    // 木の根を求める
    ll root(ll x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }

    // xとyの属する集合を併合
    bool unite(ll x, ll y){
        x = root(x);
        y = root(y);
        if(x==y) return false; // 併合失敗
        if(rank[x] < rank[y]){
            par[x] = y;
            siz[y] += siz[x];
        }else{
            par[y] = x;
            siz[x] += siz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
        return true; // 併合成功
    }

    bool issame(ll x, ll y){
        return root(x)==root(y);
    }

    ll size(ll x){
        return siz[root(x)];
    }
};

int ans[MAX_N];

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

    UnionFind uf;
    uf.init(n);

    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
        ans[a]--;
        ans[b]--;
    }

    rep(i, n) ans[i] += uf.size(i)-1;

    rep(i, k){
        int c, d;
        cin >> c >> d;
        c--;
        d--;

        if(uf.issame(c, d)){
            ans[c]--;
            ans[d]--;
        }
    }

    rep(i, n-1) cout << ans[i] <<" ";
    cout << ans[n-1] <<endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;


int main(){
	vector<int> a(9);
	vector<bool> b(9, false);
	for( auto &k : a ) cin >> k;
	int n; cin >> n;
	while( n-- ){
		int t; cin >> t;
		for( int i = 0; i < 9; ++i ){
			if( a[i] == t ) b[i] = true;
		}
	}
	if(
		b[0] and b[1] and b[2]
		or
		b[3] and b[4] and b[5]
		or
		b[6] and b[7] and b[8]
		or
		b[0] and b[3] and b[6]
		or
		b[1] and b[4] and b[7]
		or
		b[2] and b[5] and b[8]
		or
		b[0] and b[4] and b[8]
		or
		b[2] and b[4] and b[6]
	){
		cout << "Yes" << endl;
	} else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define GLX glx ak!!
#define ZZH zzh ak!!
#define LYH lyh ak!!
#define XRY xry ak!!
#define ZJH zjh ak!!
#define HP hp ak!!
#define WXH wxh ak!!
#define JIRY jiry good teacher
#define DYH dyh good teacher
#define ll long long
using namespace std;
int n,ans,x,f[110];
bool vis[110];
inline void dfs(int x){
    if(x>12){
        int ret=24;
        for(int i=0;i<=23;i++)
            for(int j=i+1;j<=23;j++)
                if(vis[i]&&vis[j]) ret=min(ret,min(j-i,24-j+i));
        ans=max(ans,ret);
        return ;
    }
    if(f[x]==2){
		vis[x]=vis[24-x]=1;
		dfs(x+1);
		return;
	}
	if(f[x]){
        vis[x]=1;
		dfs(x+1);
		vis[x]=0;
        if(x){
        	vis[24-x]=1;
			dfs(x+1);
			vis[24-x]=0;
    	}
		return ;
	}
    dfs(x+1);
	return;
}
int main(){
    scanf("%d",&n);
    f[0]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		f[x]++;
	}
	if(f[12]>1||f[0]>1){puts("0");return 0;}
    for(int i=1;i<=12;i++) if(f[i]>2){puts("0");return 0;}
    dfs(0);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <cstring>
#include <cctype>
#include <random>

using namespace std;
typedef long long  ll;
const ll INF = 1000000007;
const ll mod = 998244353;

ll f(vector<pair<ll, ll>> p) {
	int n = p.size();
	for (ll i = 0; i < n; i++)
	{
		p[i].first = min((int)p[i].first, n);
	}
	vector<vector<int>> s(n + 1);
	for (ll i = 0; i < n; i++)
	{
		s[p[i].first].push_back(p[i].second);
	}
	ll res = 0;
	priority_queue<int> q;
	for (int i = n; i >= 1; --i) {
		for (int x : s[i]) q.push(x);
		if (q.size() > 0) {
			res += q.top();
			q.pop();
		}
	}
	return res;
}

void solve() {
	ll n;
	cin >> n;
	vector<pair<ll, ll>> pl, pr;
	ll ans = 0;
	for (ll i = 0; i < n; i++)
	{
		ll k, l, r;
		cin >> k >> l >> r;
		ll m = min(l, r);
		ans += m;
		l -= m; r -= m;
		if (l > 0) pl.emplace_back(k, l);
		else pr.emplace_back(n - k, r);
	}
	ans += f(pl);
	ans += f(pr);
	cout << ans << endl;
}



int main() {
	int ts;
	cin >> ts;
	for (ll i = 0; i < ts; i++)
	{
		solve();
	}
	return 0;
}

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

int main()
{
	int n,k;
	cin>>n>>k;
	//int ans=0;
	vector<int> arr(n);
	for(int i=0;i<n;i++) cin>>arr[i];
	vector<int> dp(n,0);
	
dp[1]=abs(arr[1]-arr[0]);
	//int ans=INT_MAX;
	for(int i=2;i<n;i++)
	{   dp[i]=INT_MAX;
		for(int j=i-1;j>=0 && j>=i-k;j--)
		{
			int op=	dp[j]+abs(arr[j]-arr[i]);
			dp[i]=min(dp[i],op);
		}
		//dp[i]=ans;	
	} 
	cout<<dp[n-1];
}

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

typedef long long ll;
#define MOD 1000000007

int main()
{
    ll N;
    cin >> N;
    vector<ll> A;
    vector<ll> B(N + 1, 0);
    B[0] = 0;
    for (int i = 0; i < N; ++i)
    {
        ll temp;
        cin >> temp;
        A.push_back(temp);
        B[i + 1] = B[i] + A[i];
    }
    ll ans = 0;
    for (int i = 0; i < N - 1; ++i)
    {
        ll sum = (B[N] - B[i + 1]) % MOD;
        ans += A[i] * sum;
        ans = ans % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6928
#include<queue>
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int mod=1000000007;
const int maxn=111111;
int N,cnt[26];
LL ans=1;
char ss[maxn];
int read()
{
	int s=0,c=getchar(),f=1;
	while(c<48||c>57)
	{
		if(c==45) f=-1;
		c=getchar();
	}
	while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return s*f;
} 
void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
void W(int x)
{
	if(x<0) x=-x,putchar(45);
	write(x);
}
int main()
{
	N=read();
	scanf("%s",ss+1);
	for(int i=1;i<=N;++i)
	{
		++cnt[ss[i]-'a'];
	}
	for(int i=0;i<26;++i)
	{
		ans=ans*(cnt[i]+1)%mod;
	}
	write(ans-1);
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <ctime>
#include <set>
#include <sstream>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
string s,k;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>s>>k;
	if(s<k)
	{
		printf("<\n");
		return 0;
	}
	if(s>k)
	{
		printf(">\n");
		return 0;
	}
	if(s==k)
	{
		printf("=\n");
		return 0;
	}
    return 0;
}



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

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

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

        bool ans = (a == 7 && b == 5 && c == 5) || (a == 5 && b == 7 && c == 5) || (a == 5 && b == 5 && c == 7);

        string answer = ans ? "YES" : "NO";

        Console.WriteLine(answer);
    }

    // 最大公約数
    private static int Gcd(int a, int b)
    {
        if (a < b)
        {
            return Gcd(b, a);
        }
        while (b != 0)
        {
            int r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    private static int Lcm(int a, int b)
    {
        return a / Gcd(a, b) * b;
    }

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

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

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

            return _line[_index++];
        }

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

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

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

Measured memory_bytes: 11092
#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 S;
    ll ten9 = 1000000000;
    ll s;
    cin >> S;
    s = (ten9 - S % ten9) % ten9;
    cout << 0 << ' ' << 0 << ' ' << ten9 << ' ' << 1 << ' ' << s << ' ' << (S + s) / ten9 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

char yuni(int a) {
	if (a == 1) return '+';
	else return '-';
}

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

	int num;
	cin >> num;

	int D = num % 10;
	num /= 10;
	int C = num % 10;
	num /= 10;
	int B = num % 10;
	num /= 10;
	int A = num % 10;

	rep(i, 2) {
		ans = A;
		rep(j, 2) {
			ans = A;
			rep(k, 2) {
				ans = A;

				if (i == 1) ans += B;
				else ans -= B;

				if (j == 1) ans += C;
				else ans -= C;

				if (k == 1) ans += D;
				else ans -= D;

				if (ans == 7) {
					cout << A << yuni(i) << B << yuni(j) << C << yuni(k) << D << "=7" << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
# Aizu Problem 0029: English Sentence
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


L_max = 0
counts = {}
for word in input().split():
    if len(word) > L_max:
        L_max = len(word)
        long_word = word
    counts[word] = counts.get(word, 0) + 1
    
for a in sorted([a for a in counts if counts[a] == max(counts.values())]):
    print(a, long_word)

Measured memory_bytes: 7600
room = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]
n=int(input())
for i in range(n):
    b,f,r,v=map(int,input().split())
    room[b-1][f-1][r-1]=room[b-1][f-1][r-1]+v

for j in range(4):
    for k in range(3):
        print(' '+' '.join(str(i) for i in room[j][k]))
    if j<3:
        print('#'*20)


Measured memory_bytes: 5608
#include <iostream>
#include <string>
typedef long long ll;

using namespace std;

int main() {
	string str;
	cin >> str;
	int len = str.length();
	int prev(0);
	ll sum(0);
	for (int i = 0; i < len; ++i) {
		if (str[i] == '<') {
			prev++;
			sum += prev;
		} else {
			int j;
			for (j = i; j < len && str[j] == '>'; ++j) {
			}
			if (prev  < j - i) {
				sum += j- i - prev;
			}
			sum += ((ll)(j - i - 1) * (ll)(j - i)) / 2LL;
			prev = 0;
			i = j - 1;
		}
	}
	cout << sum << endl;
	return 0;
}


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

typedef long long ll;
 
int main(){
  int a[26] = {};
  string s;
  cin >> s;
  for(int i=0; i<s.length(); i++){
    a[s[i]-'a']++;
  }
  for(int i=0; i<26; i++){
    if(a[i]==0){
      cout << char('a'+i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = Array(N) { nextInt() - 1 }
    val B = Array(N + 1) { false }
    var ans = 0
    var pos = 0
    while (true) {
        pos = A[pos]
        if (B[pos]) {
            ans = -1
            break
        }
        ans++
        B[pos] = true
        if (pos == 1) break
    }
    println(ans)
}

Measured memory_bytes: 40932
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)

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

int main(){
    rep(_,1000){
        string str;
        cin>>str;
        bool endFlag=false;
        rep(i,str.size()-1){
            int y=(str[i]-'A')/3;
            int x=(str[i]-'A')%3;
            bool flag=false;
            rep(k,4){
                int ty=y+dy[k];
                int tx=x+dx[k];
                if(ty<0||ty>=3||tx<0||tx>=3)continue;
                if(ty*3+tx==str[i+1]-'A')flag=true;
            }
            if(!flag){
                endFlag=true;
                break;
            }
        }
        if(endFlag)continue;
        cout<<str<<endl;
    }
    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>

using namespace std;
typedef long long  ll;

int main()
{
	ll N;
	cin >> N;
	vector<ll> a(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll target = a[0];
	ll num = 0;
	ll ans = 0;
	for (ll i = 0; i < N; i++)
	{
		if (target == a[i])
			num++;
		else
		{
			if (target != num)
			{
				if (target < num)
					ans += num - target;
				else
					ans += num;
			}
			target = a[i];
			num = 1;
		}
	}
	if (target != num)
	{
		if (target < num)
			ans += num - target;
		else
			ans += num;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import bisect
import sys
sys.setrecursionlimit(10**6)

N = int(input())
A = [0] + list(map(int,input().split()))

adj = [[] for n in range(N+1)]
for n in range(N-1):
    u, v = map(int,input().split())
    adj[u].append(v)
    adj[v].append(u)

ans= [0 for i in range(N+1)]

INF = 10**10

depth = [-1 for n in range(N+1)]
def dfs(s, d, lis): # 頂点番号、深さ、LIS
    depth[s] = d
    idx = bisect.bisect_left(lis,A[s])
    lis[idx], lis_c = A[s], lis[idx]
    ans[s] = bisect.bisect_left(lis, INF)
    for i in adj[s]:
        if depth[i]==-1:
            dfs(i, d+1, lis)
    lis[idx] = lis_c
lis = [INF] * len(A)
dfs(1, 0, lis)
for n in range(1,N+1):
    print(ans[n])


Measured memory_bytes: 232220
import * as fs from 'fs';

namespace AtCoder.abc001 {

    export class Program {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         * 4 1
         * 5 4 2 1
         * out
         * Yes
         *
         * 4 1
         * 5 4 2 1
         * No
         */
        main(): void {
            const [n, m]: number[] = this.args[0].split(' ').map(Number);
            const a: number[] = this.args[1].split(' ').map(Number);
            const sum: number = a.reduce((prev: number, curr: number) => {
                return prev + curr;
            });
            // console.log(sum);

            const sorted: number[] = a.sort((a: number, b: number) => b - a);
            // console.log(sorted)
            // console.log(1 / (4 * m));
            for (let i = 0; i < m; i++) {
                // console.log(sorted[i]);
                if (sorted[i]/sum < 1 / (4 * m)) {
                    console.log('No');
                    return;
                }
            }
            console.log('Yes');
        }
    }
}

const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg = new AtCoder.abc001.Program(args);
prg.main();




Measured memory_bytes: 7500
import java.util.Scanner;
 
public class Main {
	public static int pow(int a, int b){
		int x=1;
		while(b>0){
			if((b&1)==1) x=(x*a);
			a=(a*a);
			b>>=1;
		}
		return x;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D=sc.nextInt();
		int G=sc.nextInt();
		
		int[] p=new int[D+1];
		int[] c=new int[D+1];
		int[] score=new int[D+1];
		
		for(int i=1;i<=D;i++){
			p[i]=sc.nextInt();
			c[i]=sc.nextInt();
			score[i]=100*i*p[i]+c[i];
		}
		
		int pattern=pow(2,D);
		int[] num=new int[pattern];
		int min= 10000;
		for(int i=0;i<pattern;i++){
			int g=G;
			int n=0;
			for(int j=1;j<=D;j++){
				if( ((i>>(j-1))&1)==1 ){
					num[i]+=p[j];
					g-=score[j];
				}
			}
			if(g>0){
				int take=D;
				while(((i>>(take-1))&1)==1) take--;
				if(g>100*take*(p[take]-1)){
					continue;
				}else{
					num[i]+= (g-1)/(100*take)+1;
				}
			}
			min=Math.min(min, num[i]);
		}
		System.out.println(min);
	}
}

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

lli n;

int main(void){
	cin >> n;
	vector<lli> c(5);
	lli minv = 1e18;
	rep(i, 5){
		cin >> c[i];
		minv = min(minv, c[i]);
	}
	lli ans = (n+minv-1)/minv+4;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3628
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; 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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

int main() {
    string S; cin >> S;
    int m = 100000;
    for(int i = 0; i < S.size()-2; i++) {
        //cout << abs(stoi(S.substr(i,3))-753) << endl;
        chmin(m,abs(stoi(S.substr(i,3))-753));
    }
    cout << m << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N = int(input())
A = list(map(int, input().split()))

def is_even(x):
    return x % 2 == 0

ans = 0
for i in range(N):
    while is_even(A[i]):
        A[i] //= 2
        ans += 1

print(ans)

Measured memory_bytes: 4084
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var N, r int

	fmt.Scan(&N)
	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
		arr[i] -= i + 1
	}
	sort.Ints(arr)
	m := arr[N/2]
	for i := 0; i < N; i++ {
		r += int(math.Abs(float64(arr[i] - m)))
	}
	fmt.Println(r)
}

Measured memory_bytes: 5504
n, t = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort()
m = ab[-1][0]
dp = [0] * (m + t)
for a, b in ab:
    for j in range(t - 1, -1, -1):
        dp[a + j] = max(dp[a + j], dp[j] + b)
print(max(dp))

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

ll solve() {
    ll N, M;
    cin >> N >> M;
    vector<ll> P(M);
    vector<string> S(M);
    vector<ll> wa(N);
    vector<bool> ac(N,false);
    for ( int i = 0; i < M; i++ ) {
        cin >> P[i] >> S[i];
        ll p = P[i]-1;
        if ( ac[p] ) continue;
        if ( (!ac[p]) && (S[i] == "WA") ) {
            wa[p]++;
        }
        if ( S[i] == "AC" ) ac[p] = true;
    }
    
    ll n_ac = 0, n_wa = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( ac[i] ) n_ac++;
        if ( ac[i] ) n_wa += wa[i];
    }
    
    cout << n_ac << " " << n_wa << "\n";
    return 0;
}

int main() {
    solve();
    return 0;
}

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

int d[8][8];

int main(){
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    d[a-1][b-1] = 1;
    d[b-1][a-1] = 1;
  }
  vector<int> v;
  for (int i = 1; i < n; i++) {
    v.push_back(i);
  }
  long long count = 0;
  do {
    if (d[0][v[0]] != 1) continue;
    for (int i = 1; i < n-1; i++) {
      if (d[v[i-1]][v[i]] != 1) break;
      if (i == n-2) count++;
    }
    if (n == 2) count++;
  } while( next_permutation(v.begin(), v.end()));
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)

S = input()
N = len(S)
dp = [-1 for i in range(N)]


def f(n):
    if n < 0:
        return 0
    elif n == 0:
        return 1

    if dp[n] != -1:
        return dp[n]
    elif n - 1 >= 0 and S[n] == S[n - 1]:
        dp[n] = f(n - 2) + 1
        if n - 2 >= 0:
            dp[n] = max(dp[n], f(n - 3) + 2)
        return dp[n]
    else:
        dp[n] = f(n - 1) + 1
        return dp[n]


print(f(N - 1))

Measured memory_bytes: 169084
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    s = [0]
    for i in range(n-1):
        s.append(s[-1]+a[~i])
    s.reverse()
    for i in range(n):
        if a[i] >  s[i]*2:
            break
    print(i+1)  

    
if __name__ == '__main__':
    main()

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<vector<int>> a(n);
    vector<int> count(n);
    rep(i,m){
        int A, B; cin >> A >> B;
        a[A-1].push_back(B-1);
        count[A-1] ++;
        a[B-1].push_back(A-1);
        count[B-1] ++;
    }
    int ans = 0;
    // rep(i,n) cout << count[i] << " " ;
    // cout << endl;
    rep(i,n){
        bool can = true;
        // if(count[i] == 0){
        //     ans++;
        //     continue;
        // }
        rep(j,count[i]){
            if(h[i] <= h[a[i][j]]) can = false;
        }
        if(can) ans++;
        // cout << ans << " ";
    }
    // cout << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9008
import java.util.*;
public class Main {
	public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt(), K = sc.nextInt();
      ArrayList<Integer> list = new ArrayList<>();
      for (int i=0; i<N; i++) {
        list.add(sc.nextInt());
      }
      Collections.sort(list);
      int ans = 0;
      for (int j=0; j<K; j++) {
        ans += list.get(j);
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 38796
n = gets.to_i
a = gets.split.map(&:to_i)

a[0] == 1 and (p n == 0 ? 1 : -1; exit)
n == 0 and (p -1; exit)

x = 1
s = a.sum
ans = 0
1.upto(n) do |i|
    x * 2 < a[i] and (p -1; exit)

    ans += x + a[i]
    s -= a[i]
    x * 2 - a[i] <= s ? x = x * 2 - a[i] : x = s
end

p ans

Measured memory_bytes: 20748
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
typedef long long ll;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
using namespace std;
vector<ll> ans;
ll tenpow[20];
void dfs(int st, ll num, int cnt){
    if(cnt == 12) return;
    ans.push_back(num);
    for(int i = max(0, st - 1); i <= min(9, st + 1); i++)
        dfs(i, num + i * tenpow[cnt], cnt + 1);
}
int main(void){
#ifdef ljxtt
freopen("data.in", "r", stdin);
#endif
    tenpow[0] = 1;
    for(int i = 1; i <= 10; i++) tenpow[i] = tenpow[i - 1] * 10;
    for(int i = 0; i <= 9; i++) dfs(i, i, 1);
    sort(ans.begin(), ans.end());
    int t = unique(ans.begin(), ans.end()) - ans.begin();
    int n; cin >> n;
    // for(int i = 1; i <= 100; i++)
    //     cout << ans[i] << endl;
    cout << ans[n] << endl;
    return 0;
}

Measured memory_bytes: 10604
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(solve(A, B));

        sc.close();
    }

    static String solve(int A, int B) {
        return ((A + B) % 2 == 0) ? String.valueOf((A + B) / 2) : "IMPOSSIBLE";
    }
}

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

#define ll long long
#define ar array

const int mxN=5e5, M=1e9+7;
int n, m;
ll iv[mxN+1], f1[mxN+1], f2[mxN+1];

ll nck(int n, int k) {
	return f1[n]*f2[k]%M*f2[n-k]%M;
}

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

	iv[1]=1;
	for(int i=2; i<=mxN; ++i)
		iv[i]=M-M/i*iv[M%i]%M;
	f1[0]=f2[0]=1;
	for(int i=1; i<=mxN; ++i) {
		f1[i]=f1[i-1]*i%M;
		f2[i]=f2[i-1]*iv[i]%M;
	}

	cin >> n >> m;
	ll ans=0;
	for(int i=0; i<=n; ++i) {
		ll c=i&1?M-1:1;
		c=c*nck(n, i)%M*nck(m, i)%M*f1[i]%M*nck(m-i, n-i)%M*nck(m-i, n-i)%M*f1[n-i]%M*f1[n-i]%M;
		ans=(ans+c)%M;
	}
	cout << ans;
}

Measured memory_bytes: 15344
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    A.sort();
    auto sieve = new bool[](10 ^^ 6 + 100);
    long ans;
    // writeln(A);
    foreach (i; 0 .. N)
    {
        bool a = (i - 1 < 0) ? true : A[i - 1] != A[i];
        bool b = (N <= i + 1) ? true : A[i + 1] != A[i];
        if (!sieve[A[i]] && a && b)
        {
            // writeln(sieve[A[i]]);
            // writeln(A[i]);
            ans++;
        }
        if (sieve[A[i]])
            continue;
        foreach (x; 1 .. 10_000_000)
        {
            if (sieve.length <= A[i] * x)
                break;
            sieve[A[i] * x] = true;
        }
    }
    writeln(ans);
}


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

using namespace std;

#define MOD 1000000007
typedef long long int ll;

int main(){

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

	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ans+=n/i-(n%i==0);
	}
	cout<<ans<<endl;

        
	

	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll>

using namespace :: std;

const ll maxn=2050;
const ll mod=1e9+7;
const ll inf=1e9+500;

int  s[maxn*2][maxn*2];
int  t[maxn*2][maxn*2];
int dp[maxn*2][maxn*2];

ll fac[maxn*16];
ll rfac[maxn*16];


ll poww(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b/=2;
    }
    return ans;
}
ll ent(ll n,ll k){
    if(k>n || k<0)return 0;
    return (((fac[n]*rfac[n-k])%mod)*rfac[k])%mod;
}
int main(){
    ll n;
    cin>>n;
    fac[0]=1;
    rfac[0]=1;
    for(ll i=1;i<maxn*16;i++){
        fac[i]=(fac[i-1]*i)%mod;
        rfac[i]=poww(fac[i],mod-2);
    }

    ll ans=0;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        s[-a+maxn][-b+maxn]++;
        t[+a+maxn][+b+maxn]++;
        ans-=ent(2*(a+b),2*a);
    }
    ans%=mod;
    ans+=mod;
    ans%=mod;
    for(int i=1;i<maxn*2;i++){
        for(int j=1;j<maxn*2;j++){
            dp[i][j]=(dp[i-1][j]+dp[i][j-1]+s[i][j]);
            if(dp[i][j]>=mod)dp[i][j]-=mod;
            if(t[i][j])
                ans+=((ll)t[i][j]*(ll)dp[i][j])%mod;
        }
    }
    ans%=mod;
    cout<<(ans*poww(2,mod-2))%mod;
}


Measured memory_bytes: 135424
$/=get.words;$_=sort -*,get.words;
say .[^$1].sum/$1;
#(+.[^$1].grep(*==.[$1-1]),+$1..(($!=+.grep(*==.[$1-1]))min+$2))[.[$1-1]==.[0]]>>.&{combinations($!,$_).elems}.sum.say
#$!={+.grep(*==.[$1-1])};($!(.[^$1]),+$1..(($!=$!($_))min+$2))[.[$1-1]==.[0]]>>.&{combinations($!,$_).elems}.sum.say
$!={+.grep(*==.[$1-1])};($!(.[^$1]),+$1..($!()min+$2))[.[$1-1]==.[0]]>>.&{combinations($!(),$_).elems}.sum.say

Measured memory_bytes: 80448
#include <stdio.h>

int main()
{
    int n, k, i, x[100];
    int sum = 0;
    scanf("%d%d", &n, &k);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &x[i]);
        if (x[i] <= k / 2)
            sum += x[i] * 2;
        else
            sum += (k - x[i]) * 2;
    }

    printf("%d",sum );

    return (0);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
int str1[]={1,3,5,7,8,10,12};
int str2[]={4,6,9,11};
int str3[]={2};
int x,y;
void sove()
{
    int flag1=0;
       for(int i=0;i<7;i++)
    {
        if(str1[i]==x)
        flag1++;
        if(str1[i]==y)
        flag1++;
    }
    if(flag1==2)
    {
        cout<<"Yes"<<endl;
        return ;
    }
    int flag2=0;
    for(int i=0;i<4;i++)
    {
        if(str2[i]==x) flag2++;
        if(str2[i]==y) flag2++;
    }
    if(flag2==2)
    {
        cout<<"Yes"<<endl;
        return ;
    }
    int flag3=0;
    if(x==2) flag3++;
    if(y==2) flag3++;
    if(flag3==2)
    {
        cout<<"Yes"<<endl;
        return ;
    }
    cout<<"No"<<endl;
    return ;
}
int main()
{
  //  int x,y;
    cin>>x>>y;
    int flag1=0;
    sove();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 hh, ww, nn, aa, pp = 0;
	cin >> hh >> ww >> nn;
	int64 memo[hh][ww];
	for(int64 ii = 1;ii <= nn;ii++)
	{
		cin >> aa;
		for(int64 jj = 0;jj < aa;jj++)
		{
			memo[pp / ww][pp % ww] = ii;
			pp++;
		}
	}
	for(int64 ii = 0;ii < hh;ii++)
	{
		if(ii % 2 == 0)
		{
			for(int64 jj = 0;jj < ww;jj++)
			{
				cout << memo[ii][jj];
				if(jj != ww - 1)
				{
					cout << ' ';
				}
			}
			cout << '\n';
		}
		else
		{
			for(int64 jj = ww - 1;jj >= 0;jj--)
			{
				cout << memo[ii][jj];
				if(jj != 0)
				{
					cout << ' ';
				}
			}
			cout << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 3696
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = n;
        int sum = 0;
        int rem = 0;
        while(m != 0){
            rem = m % 10;
            sum = sum + rem;
            m = m / 10;
        }
        if((n % sum) == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << ": " << x << '\n';

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, ans = 1;
  cin >> n;
  const int kmod = 1e9 + 7;
  for (int i = 1; i <= n; i++) {
    ans *= i;
    ans %= kmod;
  }
  cout << ans << '\n';
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef unsigned long long ull;
ull modmul(ull a, ull b, ull M) {
  ll ret = a * b - M * ull(1.L / M * a * b);
  return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull modpow(ull b, ull e, ull mod) {
  ull ans = 1;
  for (; e; b = modmul(b, b, mod), e /= 2)
    if (e & 1) ans = modmul(ans, b, mod);
  return ans;
}

bool isPrime(ull n) {
  if (n < 2 || n % 6 % 4 != 1) return (n | 1) == 3;
  ull A[] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022},
      s = __builtin_ctzll(n-1), d = n >> s;
  for (ull a : A) {   // ^ count trailing zeroes
    ull p = modpow(a%n, d, n), i = s;
    while (p != 1 && p != n - 1 && a % n && i--)
      p = modmul(p, p, n);
    if (p != n-1 && i != s) return 0;
  }
  return 1;
}

ull pollard(ull n) {
  auto f = [n](ull x) { return modmul(x, x, n) + 1; };
  ull x = 0, y = 0, t = 0, prd = 2, i = 1, q;
  while (t++ % 40 || __gcd(prd, n) == 1) {
    if (x == y) x = ++i, y = f(x);
    if ((q = modmul(prd, max(x,y) - min(x,y), n))) prd = q;
    x = f(x), y = f(f(y));
  }
  return __gcd(prd, n);
}

vector<ull> factor(ull n) {
  if (n == 1) return {};
  if (isPrime(n)) return {n};
  ull x = pollard(n);
  auto l = factor(x), r = factor(n / x);
  l.insert(l.end(), all(r));
  return l;
}

const int MAX_PR = 1'000'000;
bitset<MAX_PR> isprime;
vi eratosthenesSieve(int lim) {
  isprime.set(); isprime[0] = isprime[1] = 0;
  for (int i = 4; i < lim; i += 2) isprime[i] = 0;
  for (int i = 3; i*i < lim; i += 2) if (isprime[i])
    for (int j = i*i; j < lim; j += i*2) isprime[j] = 0;
  vi pr;
  rep(i,2,lim) if (isprime[i]) pr.push_back(i);
  return pr;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  vi pr = eratosthenesSieve(MAX_PR);

  int n;
  cin >> n;

  vi cnt(MAX_PR+1);
  rep(i,0,n) {
    int k;
    cin >> k;
    ++cnt[k];
  }

  bool pairwise = true, setwise = true;

  for (auto p: pr) {
    int q = p;
    int tot = 0;
    while (q <= MAX_PR) {
      tot += cnt[q];
      q += p;
    }
    if (tot>1) pairwise = false;
    if (tot==n) setwise = false;
  }

  if (pairwise) cout << "pairwise coprime\n";
  else if (setwise) cout << "setwise coprime\n";
  else cout << "not coprime\n";
}

Measured memory_bytes: 7880
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    h = np.array(list(map(int, input().split())))
    dp = np.zeros(N, dtype=int)

    dp[0] = 0
    for i in range(1, N):
        start = max(0, i - K)
        dp[i] = min(dp[start:i] + np.abs(h[start:i] - h[i]))
    # print(dp)
    print(int(dp[N-1]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 23004
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
char s[N];

int main() {
  scanf("%s", s);
  bitset<26> visit;
  for (int i = 0; s[i]; ++i) {
    visit[s[i] - 'a'] = 1;
  }
  int ret = -1;
  for (int k = 0; k < 26; ++k) {
    if (!visit[k]) {
      ret = k;
      break;
    }
  }
  if (ret >= 0) {
    printf("%c\n", (char)('a' + ret));
  } else {
    puts("None");
  }
  return 0;
}


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

int main(){
  int n, a[110], maxt, maxb, v[2][110];
  cin >> n;
  for(int i = 0; i < 2; i++)
    for(int j = 0; j < n; j++)
      cin >> v[i][j];
  maxt = v[0][0]; maxb = maxt + v[1][0];
  for(int i = 1; i < n; i++){
    maxt += v[0][i];
    maxb = v[1][i] + max(maxt, maxb);
  }
  cout << maxb << endl;
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e16;
const int N = 2e5 + 5;

unordered_map <LL,LL> dp[ N ];
int n;
LL a[ N ];

LL solve(int idx, int taken) {
  int need = n/2 - (n - idx + 1)/2;
  if (taken < need) return -INF;
  if (idx >= n) return taken == n/2 ? 0 : -INF;
  if (dp[idx].count(taken)) return dp[idx][taken];
  LL ret = -INF;
  ret = max(ret, solve(idx + 2, taken + 1) + a[idx]);
  ret = max(ret, solve(idx + 1, taken));
  return dp[idx][taken] = ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << solve(0, 0) << endl;
  return 0;
}


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


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

long long gcd(long long a, long long b) {
	return b == 0 ? a : gcd(b, a % b);
}

void solve() {
	long long a, b; cin >> a >> b;
	long long c = gcd(a, b);
	int t = 0;
	for (long long i = 2; i * i < c; i++) {
		if (c % i == 0) t++;
		while (c % i == 0) c /= i;
	}
	if (c != 1) t++;
	cout << t + 1;
}

int main() {


	solve();


	return 0;
}

Measured memory_bytes: 256