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

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

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

int H, W;
map<string, int> past;
char field[12][22];

void solve(int x, int y){
  rep(i, 8){
    bool used[12][22];
    string s = "";
    memset(used, 0, sizeof(used));
    used[y][x] = true;
    s += field[y][x];
    int nx = x+dx[i], ny = y+dy[i];
    if(nx < 0) nx = W-1;
    else if(nx >= W) nx = 0;
    if(ny < 0) ny = H-1;
    else if(ny >= H) ny = 0;
   while(true){
      if(used[ny][nx]) break;
      used[ny][nx] = true;
      s += field[ny][nx];
      nx += dx[i], ny += dy[i];
      if(nx < 0) nx = W-1;
      else if(nx >= W) nx = 0;
      if(ny < 0) ny = H-1;
      else if(ny >= H) ny = 0;
      if(s.size() >= 2) past[s]++;
      //if(s == "MF") cout << "x = " << x << ", y = " << y << endl;
    }
  }
}

void init(){
  past.clear();
}  

int main(){
  while(cin >> H >> W, H|W){
    init();
    rep(i, H){
      cin >> field[i];
    }
    rep(i, H){
      rep(j, W){
	solve(j, i);
      }
    }
    
    int L = 0;
    string ans = "";
    
    for(map<string, int>::iterator it = past.begin() ; it != past.end() ; it++){
      if(it->second < 2 ) continue;
      string tmp = it->first;
      //cout << tmp << endl;
      if(tmp.size() > L){
	L = tmp.size();
	ans = tmp;
      }
      else if(tmp.size() == L){
	if(ans > tmp){
	  ans = tmp;
	}
      }
    }
    if(ans.size() == 0) cout << "0" << endl;
    else cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 36028
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500 + j*100 + k*50 == x:
                cnt += 1
print(cnt)                


Measured memory_bytes: 3060
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
//const int mod = 1e9 + 7;

int main() {
	int n, t;
	int a[100002];
	cin >> n >> t;
	rep(i, 0, n) { cin >> a[i]; }
	ll min = INT_MAX,mini=INT_MAX;
	ll max = 0, cnt = 0;
	map<int, int>mp;
	rep(i, 0, n) {
		if (min > a[i]) {
			min = a[i];
			mini = i;
		}
		if (max <= a[i] - min) {
			mp[i] = a[i]-min;
			max = a[i] - min;
		}
	}
	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		if (itr->second == max) { cnt += 1; }
	}
	print(cnt);
	return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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 modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll a;
  cin >> a;
  
  double b;
  cin >> b;

  b = b * 100;

  ll B = round(b);

  cout << a * B / 100 << endl;

  return 0;
}


Measured memory_bytes: 3760
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>

using namespace std;

int main()
{
	char A=11,B=12,C=13,D=14,E=15;
	char x,y;
	while(~scanf("%c %c",&x,&y))
	{
		if(x<y)
			printf("<\n");
		if(x>y)
			printf(">\n");
		if(x==y)
			printf("=\n");
		break;
	}
	return 0;
}

	



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

int main(){
   char str[22];
   int l;
while(gets(str))
{
l=strlen(str)-1;
while(l>=0)
{

 cout<<str[l--];
}

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

Measured memory_bytes: 1084
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main()
{
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int a = x2 - x1;
    int b = y2 - y1;
    cout << x2 - b << ' ' << y2 + a << ' ' << x1 - b << ' ' << y1 + a << endl;

    return 0;
}

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


// returns min(k : sum(As[i:i+k)) >= s, for some i)
int smallest_window(long long s, vector<long long> As){
    if (accumulate(begin(As), end(As), 0LL) < s) return 0;
    int record = As.size();
    int cum = 0;
    int tail = 0;
    for (int head = 0; head < As.size(); ++head){
        while (tail < As.size() and cum < s){
            cum += As[tail];
            ++tail;
        }
        if (cum >= s and tail - head < record) record = tail - head;
        cum -= As[head];
    }
    return record;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, s;
    cin >> n >> s;
    vector<long long> As(n);
    for (auto & a : As) cin >> a;
    cout << smallest_window(s, As) << endl;
    return 0;
}

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

int main(){
  int m[101][101]={},n,k,v,i,j,u;
  cin>>n;
  for(i=1;i<=n;i++){
    cin>>u>>k;
    for(j=0;j<k;j++)cin>>v,m[u][v]=1;
  }
  for(i=1;i<=n;i++){
    for(j=1;j<n;j++)cout<<m[i][j]<<" ";
    cout<<m[i][j]<<endl;
  }
    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
const ll INF = 101010101000;
ll dp[110][101010]; //N*Vの配列。最低の重さ。

int main(){
  int n, W;
  int max_v = 0;
  cin >> n >> W;
  vector<ll> w(n), v(n);
  rep(i,n) cin >> w[i] >> v[i];
  rep(i,n) max_v += v[i];
  //初期化
  rep(i,n+1){
    rep(j,max_v+1){
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  
  rep(i,n){
    ll w_i = w[i];
    ll v_i = v[i];
    rep(j,max_v+1){
      if(j-v_i>=0) dp[i+1][j] = min(dp[i][j],dp[i][j-v_i]+w_i);
      else dp[i+1][j] = min(dp[i][j],dp[i+1][j]);
    }
  }
  /*rep(i,n+1){
    rep(j,max_v+1){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/
  ll ans = 0;
  rep(i,max_v+1){
    if(dp[n][i]<=W){
      ans = i;
    }
  }
  cout << ans << endl;
}

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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

bool issq(int x) { int y = (int)round(sqrt(x)); return y * y == x; }

pii mult(pii a, pii b) {
	return {a.first * b.first - a.second * b.second, a.first * b.second + a.second * b.first};
}

int multeq(int a, int b, int c, int d, int e, int f) {
	pii t = {e, f};
	if (mult({a, b}, {c, d}) == t || mult({a, -b}, {c, d}) == t || mult({a, b}, {c, -d}) == t || mult({a, -b}, {c, -d}) == t) return true;
	return false;
}

bool ok(int m, int n, int i, int j) {
	int iup = floor(sqrt(i)), jup = floor(sqrt(j));
	for (int ii = -iup; ii <= iup; ii++) if (issq(i - ii * ii)) {
		int a = ii, b = (int)round(sqrt(i - ii * ii)); // actually (a, -b) and (a, b)
		for (int jj = -jup; jj <= jup; jj++) if (issq(j - jj * jj)) {
			int c = jj, d = (int)round(sqrt(j - jj * jj));
			if (multeq(a, b, c, d, m, n))
				return true;
		}
	}
	return false;
}

void solve() {
	int m, n; cin >> m >> n;
	int g = m * m + n * n;
	for (int i = 2; i * i <= g; i++) if (g % i == 0) {
		if (ok(m, n, i, g / i)) {
			cout << "C" << endl;
			return;
		}
	}
	cout << "P" << endl;
}

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

	int n; cin >> n;
	rep(i, 0, n) solve();
}



Measured memory_bytes: 3284
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define exists(x,m) m.find(x) != m.end()
#define umap unordered_map
#define uset unordered_set
#define pq priority_queue

const ll MOD = 1e9 + 7;

vll primes;
vector<bool> composite;

void prime_sieve(ll lim) {
	composite = vector<bool>(lim+1);
	for (int num = 2; num <= lim; num++) {
		if (!composite[num]) primes.pb(num);
		for (int i = 0; i < isize(primes) and num * primes[i] <= lim; i++) {
			composite[num * primes[i]] = true;
			if (num % primes[i] == 0) break;
		}
	}
}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	vi A = vi();
	int maxx = 0;
	rep(i, n) {
		int x; cin >> x;
		A.pb(x);
		maxx = max(maxx, x);
	}	
	prime_sieve(1e3+100);
	umap<int, int> prime_freq = umap<int, int>();
	for (const int& a : A) {
		int b = a;
		for (int i = 0; primes[i]*primes[i] <= b; i++) {
			if (b % primes[i] == 0) prime_freq[primes[i]]++;
			while(b % primes[i] == 0) b /= primes[i];
		}
		if (b != 1) prime_freq[b]++;
	}
	int max_freq = 0;
	for (const auto& [p, freq] : prime_freq) {
		max_freq = max(max_freq, freq);
	}
	if (max_freq <= 1) {
		cout << "pairwise coprime";
	} else {
		cout << (max_freq < n ? "setwise coprime" : "not coprime");
	}
}

Measured memory_bytes: 10404
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
using ull = unsigned long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ull> a(n);
  rep(i, n) cin >> a[i];
  ull all_xor = 0;
  for(int i = 0; i < n; ++i){
    all_xor ^= a[i];
  }
  for(int i = 0; i < n; ++i){
    cout << (all_xor ^ a[i]) << " ";
  }
  cout << endl;
  return 0;
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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


int main(void){
  ios::sync_with_stdio(false);
  int s, w;
  cin >> s >> w;
  if (w >= s) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
  string a;
  string b;
  cin >> a >> b;
  int count=0;
  	for (int i=0; i<a.size(); i++) {
      if (a[i] != b[i]){
        count++;
		}
    }
   cout << count << endl;
}

Measured memory_bytes: 3844
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

using P = pair<int, int>;
#define x first
#define y second

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    P obs[n+1];
    for (int i=0; i<n; i++) cin >> obs[i].x >> obs[i].y;
    obs[n] = {h+1, 0};
    sort(obs, obs+n+1);
    int ofs = 0;
    for (auto &oi:obs) {
        if (oi.x > oi.y + ofs) {
            cout << oi.x - 1 << '\n';
            return 0;
        }
        else if (oi.x == oi.y + ofs) ofs++;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    long long n;
    string ans;
    cin >> n;
    while(n > 0) {
        --n;
        ans += ('a' + n % 26);
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

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

int main(){
  int x,y,ans=0,k=1;
  cin>>x>>y;
  for(int i=0;i<=x;i++){
    ans=0;
    ans=2*i+4*(x-i);
    if(ans==y){
      k=0;
      break;
    }
  }
  if(k==1)cout<<"No";
  else cout<<"Yes";
}


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

int main(){
	int N,h,temp=0,count=0;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> h;
		if(temp<h){
			count+=h-temp;
		}
		temp=h;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int extgcd(int a,int b,int &x,int &y){
	int g=a;
	x=1,y=0;
	if(b!=0){
		g=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	return g;
}
 
// 逆元
int mod_inverse(int a,int m){
	int x, y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}
 
// 階乗
std::vector<int>fact;
void mod_fact(int n, int m){
	fact.resize(n+1);
	fact[0]=1;
	for(int i=1;i<=n;i++){
		fact[i]=fact[i-1]*i%m;
	}
}
 
// nCk mod p
int mod_nCr(int n, int k, int m){
	if(n<k)return 0;
	return fact[n]*mod_inverse(fact[k]*fact[n-k]%m,m)%m;
}

int N,K;
int A[100010],B[100010];
vector<int> G[100010];

void f(int s,int p,int &res,int d){
	int cnt=0;
	REP(i,G[s].size()){
		int e=G[s][i];
		if(e==p)continue;
		cnt++;
		f(e,s,res,d+1);
	}
	if(d==0){
		res*=mod_nCr(K-1,cnt,MOD);res%=MOD;
		res*=fact[cnt];res%=MOD;
	}
	else{
		res*=mod_nCr(K-2,cnt,MOD);res%=MOD;
		res*=fact[cnt];res%=MOD;
	}
}

signed main(){
	cin>>N>>K;
	mod_fact(100010,MOD);
	REP(i,N-1){
		cin>>A[i]>>B[i];
		A[i]--,B[i]--;
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
	}
	int res=1;
	f(0,-1,res,0);
	cout<<(res*K)%MOD<<endl;
	return 0;
}


Measured memory_bytes: 15104
#add comment
L, R = map(int, input().split())
mod = 2019

#2019以上の差があれば、2019の倍数が必ずあるので、i,jのどちらかをそれにすれば、余りは０
if R - L >= mod:
  print(0)
else:
  s = []
  for i in range(L, R):# iをLからR-1まで
    for j in range(i+1, R+1):#Rをi+1からRまで
      s.append((i*j) % mod)#i*jを2019で割った余りをlistに追加
  s.sort()#昇順でsort
  print(s[0])#先頭が一番最小なので、それが答え

Measured memory_bytes: 81392
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)

using namespace std;

typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

///======code start here======///

signed main() {
	fastio;
	int n, k; cin >> n >> k;
	ll h[n + 1]; h[0] = 12345678901234567;
	rep(i, 1, n + 1) cin >> h[i];
	ll dp[n + 1]; dp[0] = 0; dp[1] = 0;
	rep(i, 2, n + 1) dp[i] = 12345678901234567;
	rep(i, 2, n + 1) {
		rep(j, 1, k + 1) {
			dp[i] = min(dp[max(i - j, 0)] + abs(h[max(i - j, 0)] - h[i]), dp[i]);
		}
		
	}
	cout << dp[n] << endl;
	return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
	while(true){
		int a, b;
		cin >> a >> b;
		if(a==0){
			break;
		}
		for(int i = 0; i < a; i++){
			for(int j = 0; j < b; j++){
				if(i==0||i==a-1||j==0||j==b-1){
					cout << "#";
				}
				else{
					cout << ".";
				}
			}
			cout << "\n";
		}
		cout << "\n";
	}
}


Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  ll sum = 0;
  for(int i = 0; i < n; i++){
    if((i+1) % 3 == 0 || (i+1)%5 == 0){
      continue;
    }else{
      sum += (i + 1);
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main(){
	
	long long int N, A, B;
	
	cin >> N >> A >> B;
	
	if(N == 1){
		if(A == B){
			cout << "1" << endl;
		}else{
			cout << "0" << endl;
		}
		return 0;
	}
	
	if(N == 2){
		cout << "1" << endl;
		return 0;
	}
	
	long long int ans = (B - A) * (N - 2) + 1;
	
	if(ans < 0){
		ans = 0;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int n,m;//n=taro,m=hanako
  while(true){
    cin >>n >>m;
    if(n==0) break;
    int hana=0,taro=0;
    std::vector<int> h,t;
    for(int i=0;i<n;i++){
      int s;cin >> s;taro+=s;
      t.push_back(s);
    }
    for(int i=0;i<m;i++){
      int s;cin >> s;hana+=s;
      h.push_back(s);
    }
    sort(h.begin(),h.end());sort(t.begin(),t.end());
    bool flag=false;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        if(2*(h[j]-t[i])==(hana-taro)){
          cout << t[i] << " " << h[j] << endl;
          flag=true;break;
        }
      }
      if(flag) break;
    }
    if(!flag) cout << -1 << endl;
  }
}

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

int main(){
  int c1, c5, c10, c50, c100, c500;
  cin>>c1>>c5>>c10>>c50>>c100>>c500;

  int t;
  t = (1 * c1) + (5 * c5) + (10 *  c10) + (50 * c50) + (100 * c100) + (500 *c500);

  if( t >= 1000) cout<<1<<endl;
  else cout<<0<<endl;

  return 0;
}



Measured memory_bytes: 3052
import numpy as np
h,w,k = map(int,input().split())

ls = []
for i in range(h):
    ls.append(str(input()))


ns = np.zeros((h,w),dtype = int)
for i in range(h):
    for j in range(w):
        if ls[i][j] == "#":
            ns[i][j] = 1

ans = 0
for i in range(2** h):
    for j in range(2 ** w):
        black = 0
        for x in range(h):
            for y in range(w):
                if (i >> x) & 1 == 0 and (j >> y) & 1 == 0:
                    if ns[x][y] == 1:
                        black += 1
        if black == k:
            ans += 1

print(ans)


Measured memory_bytes: 27032
#include <stdio.h>
#include <math.h>

int main(void)
{
	int d,n;
	
	scanf("%d%d",&d,&n);
	
	if(n==100){
		n=101;
	}
	
	int result=pow(100,d);
	
	printf("%d\n",result*n);
	
	return 0;
}

Measured memory_bytes: 128
mod=10**9+7

H,W=map(int,input().split())
a=[list(input()) for _ in range(H)]
a[0][0]=1
for h in range(H):
    for w in range(W):
        if h==0:
            if w==0:
                continue
            if a[h][w]==".":
                a[h][w]=a[h][w-1]
            else:
                a[h][w]=0
        else:
            if a[h][w]=="#":
                a[h][w]=0
            elif w==0:
                a[h][w]=a[h-1][w]
            else:
                a[h][w]=(a[h-1][w]+a[h][w-1])%mod
print(a[-1][-1])

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  vl t(2), a(2), b(2);
  cin >> t[0] >> t[1];
  cin >> a[0] >> a[1];
  cin >> b[0] >> b[1];
  rep(i, 2) {
    a[i] *= t[i];
    b[i] *= t[i];
    if (a[i] > b[i]) {
      a[i] -= b[i];
      b[i] = 0;
    } else {
      b[i] -= a[i];
      a[i] = 0;
    }
  }
  dump(t, a, b);
  int za = (a[0] == 0 && a[1] == 0) ? 1 : 0;
  int zb = (b[0] == 0 && b[1] == 0) ? 1 : 0;
  if (za && zb) {
    cout << "infinity" << endl;
    return;
  } else if (za || zb) {
    cout << 0 << endl;
    return;
  }
  ll cnt = 0;
  if (a[0] == 0 && b[0] == a[1]) {
    cout << "infinity" << endl;
    return;
  }
  if (a[0] == 0 && b[0] > a[1]) {
    cout << 0 << endl;
    return;
  }
  if (b[0] == 0 && a[0] == b[1]) {
    cout << "infinity" << endl;
    return;
  }
  if (b[0] == 0 && a[0] > b[1]) {
    cout << 0 << endl;
    return;
  }
  if (a[0] == 0) {
    ll delta = a[1] - b[0];
    dump("a[0]==0", b[0], a[1], delta);
    cnt = b[0] / delta * 2;
    if (b[0] % delta) cnt++;
    dump(cnt);
  }
  if (b[0] == 0) {
    dump("b[0]==0");
    ll delta = b[1] - a[0];
    cnt = a[0] / delta * 2;
    if (a[0] % delta) cnt++;
    dump(cnt);
  }
  cout << cnt << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| iterator.next().unwrap().parse().unwrap())
        .collect();

    if k <= n {
        let mut current: usize = 0;
        let mut count: usize = 0;
        while count < k {
            current = a[current] - 1;
            count += 1;
        }

        return (current + 1).to_string();
    }

    let mut current: usize = 0;
    let mut visited: Vec<bool> = vec![false; n];
    let mut route: Vec<usize> = Vec::new();
    loop {
        if visited[current] {
            break;
        }
        route.push(current);
        visited[current] = true;
        current = a[current] - 1;
    }

    let position = route.iter().position(|it| *it == current).unwrap();
    let m = (k - position) % (route.len() - position);
    let ans = route[position + m];
    return (ans + 1).to_string();
}


Measured memory_bytes: 6116
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

#define int ll
const int mod = 1e9+7;
const int N = 1<<18;

int n, ans, all = 1;

int w[N];
int A[N];

int p0[N];
int p1[N];
int moge[N];

int fpow(int a, int b)
{
	int res = 1;

	while(b)
	{
		if(b&1)
			res = res*a%mod;

		a = a*a%mod;
		b /= 2;
	}

	return res;
}

/*int f(int a, int b)
{
	if(a+1<moge[b])
		return 0;
	else
		return all*p1[b]%mod*p0[a]%mod;
}*/

struct tree
{
	int load[2*N];

	void insert(int a, int v)
	{
		a += N;

		while(a)
		{
			load[a] += v;
			load[a] %= mod;
			a /= 2;
		}
	}

	int query(int a, int b)
	{
		if(a>b)
			return 0;

		a += N;
		b += N;

		int res = load[a];

		if(a!=b)
		{
			res += load[b];
			res %= mod;
		}

		while(a<b-1)
		{
			if(a%2==0)
			{
				res += load[a+1];
				res %= mod;
			}

			if(b%2==1)
			{
				res += load[b-1];
				res %= mod;
			}

			a /= 2;
			b /= 2;
		}

		return res;
	}
};

tree T, cnt;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n;

	for(int i = 1; i <= n; ++i)
	{
		cin >> A[i];
		++w[A[i]];
	}

	for(int i = n; i >= 1; --i)
	{
		w[i] += w[i+1];
	}

	for(int i = n; i >= 1; --i)
	{
		w[i] -= n-i;
		all = all*w[i]%mod;
	}

	p0[0] = p1[0] = 1;
	moge[0] = 1;

	for(int i = 1; i <= n; ++i)
	{
		p0[i] = p0[i-1]*w[i]%mod;
		p1[i] = p1[i-1]*(w[i]-1)%mod;

		if(p1[i]==0)
		{
			p0[i] = p1[i] = 1;
			moge[i] = i;
		}
		else
			moge[i] = moge[i-1];
	}

	if(!all)
	{
		cout << 0 << endl;
		return 0;
	}

	for(int i = 1; i <= n; ++i)
	{
		int z0 = fpow(p1[i], mod-2)*p0[i]%mod;
		int z1 = fpow(p0[i], mod-2)*p1[i]%mod;
		p0[i] = z0;
		p1[i] = z1;
	}

	for(int i = 1; i <= n; ++i)
	{
		ans += all*cnt.query(A[i], n)%mod;
		ans += p1[A[i]]*T.query(moge[A[i]], A[i]-1)%mod;

		ans %= mod;

		T.insert(A[i], all*p0[A[i]]%mod*fpow(2, mod-2)%mod);
		cnt.insert(A[i], 1);
	}

	memset(T.load, 0, sizeof T.load);

	for(int i = n; i >= 1; --i)
	{
		ans += p1[A[i]]*T.query(moge[A[i]], A[i])%mod;

		ans %= mod;

		T.insert(A[i], -all*p0[A[i]]%mod*fpow(2, mod-2)%mod);
	}

	ans += mod;
	ans %= mod;

	cout << ans << endl;
}

Measured memory_bytes: 18304
<?php


fscanf(STDIN, "%d", $n);

$array_map = [];
for($i=0;$i<$n;$i++){
    fscanf(STDIN, "%s", $str);
    $str_array = str_split($str);
    sort($str_array);
    $array_map[] = implode("",$str_array);
}

sort($array_map);
$buff = 1;
$buff_str = "";
$ans = 0;
for($i=0;$i<$n;$i++){
    if($buff_str != $array_map[$i]){
        $buff_str = $array_map[$i];
        if($buff != 1){
            $ans += ($buff * ($buff - 1)) / 2;
        }
        $buff = 1;
    }else{
        $buff++;
    }
}
if($buff != 1){
    $ans += ($buff * ($buff - 1)) / 2;
}
echo $ans;


Measured memory_bytes: 12792
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN=100100;
int x[MAXN],p[MAXN],lis[MAXN],n,s,pos,cntlis,l,r,ans;
signed main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>s;
	for(register int i=1;i<=n;i++)
	{
		cin>>x[i]>>p[i];
		if(x[i]<s) pos=i;
	}
	l=1,r=n;
	while((l<=pos&&r>pos)||(r<=pos&&l>pos))
		if(p[l]>=p[r]) lis[++cntlis]=x[r],p[l]+=p[r],r--;
		else lis[++cntlis]=x[l],p[r]+=p[l],l++;
	if(r<=pos)
		for(register int i=l;i<=r;i++) lis[++cntlis]=x[i];
	else
		for(register int i=r;i>=l;i--) lis[++cntlis]=x[i];
	lis[++cntlis]=s;
	for(register int i=1;i<cntlis;i++) ans=ans+abs(lis[i]-lis[i+1]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
import java.util.*;
import java.math.*;

public class Main{
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int ans = 0;
        long q = 2;
        int e = 1;
        long div;

        while(true){
            div = (long) Math.pow(q, e);
            if(N % div == 0){
                N /= div;
                ans++;
                e++;
                continue;
            }

            while(N % q == 0){
                N /= q;
            }
            q++;
            e = 1;
            if(q * q > N) break;
        }

        if(N != 1){
            ans++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 35916
import Data.Bifunctor
 
operatable = all even
operate = map (`div` 2)
count :: [Int] -> Int
count nums = snd $ until (not . operatable . fst) (bimap operate (+ 1)) (nums, 0)
 
main :: IO ()
main = do
    getLine
    strList <- getLine
    print . count $ read <$> words strList

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
const ll inf = 1e9+5;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,k;
  cin >> n >> k;
  mcf_graph<ll,ll> graph(2*n+2);
  int src = 2*n, sink = 2*n+1;
  graph.add_edge(src,sink,k*n,inf);
  for(int i = 0; i < n; ++i){
    graph.add_edge(src,i,k,0);
    graph.add_edge(i+n,sink,k,0);
    for(int j = 0; j < n; ++j){
      ll a;
      cin >> a;
      graph.add_edge(i,j+n,1,inf-a);
    }
  }
  pair<ll,ll> ans = graph.flow(src,sink,k*n);
  cout << k*n*inf-ans.second << '\n';
  vector<vector<bool>> vu(n,vector<bool>(n));
  for(auto& edge : graph.edges()){
    if(edge.from != src and edge.to != sink and edge.flow == 1){
      vu[edge.from][edge.to-n] = true;
    }
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      if(vu[i][j]) cout << 'X';
      else cout << '.';
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 4004
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n,mod;
int f[5005][5005],g[5005][5005];
int add(int v)
{
	return v>=mod?v-mod:v;
}
int dev(int v)
{
	return v<0?v+mod:v;
}
long long ans=0;
int main()
{
	scanf("%d%d",&n,&mod);
	int k=(n+1)/2;
	f[0][0]=1;
	for(int i=1;i<=k;i++)
	for(int k=0;k<=n;k++)
	for(int j=k;j<=n;j+=i) f[i][j]=add(f[i][j]+f[i-1][k]);
	g[0][0]=1;
	for(int i=k-1;i>=1;i--)
	for(int j=0;j<=n;j++)
	{
		if(i*j>=n) break;
		for(int k=i*j;i+k<=n;k++) g[j+1][i+k]=add(g[j+1][i+k]+g[j][k]);
	}
	for(int i=1;i<=n;i++)
	for(int j=0;j<=n;j++) g[i][j]=add(g[i][j]+g[i-1][j]);
	for(int i=0;i<=n;i++)
	for(int j=1;j<=n;j++) g[i][j]=add(g[i][j]+g[i][j-1]);
	if(!(n&1))
	{
		int ans=0;
		for(int x=1;x<=n;x++)
		for(int i=0;i<x;i++) ans=add(ans+1ll*f[k][i]*g[n-x][x-i-1]%mod);
		printf("%d\n",ans);
	}
	else
	{
		int ans=0;
		for(int x=1;x<=n;x++)
		for(int i=0;i<x;i++) ans=add(ans+1ll*f[k-1][i]*g[n-x][x-i-1]%mod)%mod;
		printf("%d\n",ans);
	}
}

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

signed main () {
    int n;
	scanf("%d", &n);
	if (n & 1) {
		printf("%d\n", n * (n - 2) / 2 + 1);
		for (int i = 1; i < n; i++) {
			for (int j = i + 1; j <= n; j++) {
				if (i + j != n)
					printf("%d %d\n", i, j);
			}
        }
	} 
    else {
        printf("%d\n", n * (n - 2) / 2);
		for (int i = 1; i < n; ++i) {
			for (int j = i + 1; j <= n; ++j) {
				if (i + j != n + 1)
					printf("%d %d\n", i, j);
			}
        }
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i,N,M,a,b,minimum[4]={0,1,3,0};
  cin>>N>>M;
  if(N==M&&N==0){cout<<0<<endl;return 0;}
  if(N<4){
    if(N==0)N++;
    N=minimum[N-1];
  }else{
    a=N;
    while(a%4)a--;
    b=0;
    For(i,a,N)b=b^i;
    N=b;
  }
  if(M<4){
    if(M==0)M++;
    M=minimum[M];
  }else{
    a=M;
    while(a%4)a--;
    b=0;
    For(i,a,M+1)b=b^i;
    M=b;
  }
  cout<<(N^M)<<endl;
  return 0;
}

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

int main(){
    int n;
    while(1){
    cin >> n;
    if (n == 0) break;
    int sum = 0;
    int s[n];
    for (int i = 0; i < n; i++){
        cin >> s[i];
        sum += s[i];
    }
    double m = sum * 1.0 / n;
    double sum2 = 0;
    for (int i = 0; i < n; i++){
        sum2 += pow(s[i]*1.0-m*1.0,2);
    } 
    double answer = sqrt(sum2/n);
    printf("%lf\n", answer);
    }
    return 0;
}


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

int max3(int a, int b, int c) {
    int ans;
    if (a < b)
        ans = b;
    else
        ans = a;
    if (ans < c)
        ans = c;
    return ans;
    
}

int mymax(int a, int b) {
    int ans;
    if (a < b)
        ans = b;
    else
        ans = a;
    return ans;
    
}




int main() {
    int n,ans;
    cin >> n;
    vector <vector <int>> abc(n, vector <int>(3));
    vector <vector <int>> max(n, vector <int>(3));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> abc.at(i).at(j);
        }
    }

    max.at(0).at(0) = abc.at(0).at(0);
    max.at(0).at(1) = abc.at(0).at(1);
    max.at(0).at(2) = abc.at(0).at(2);

    for (int i = 1; i < n; i++) {
        max.at(i).at(0) = mymax(max.at(i-1).at(1), max.at(i-1).at(2)) + abc.at(i).at(0);
        max.at(i).at(1) = mymax(max.at(i-1).at(0), max.at(i-1).at(2)) + abc.at(i).at(1);
        max.at(i).at(2) = mymax(max.at(i-1).at(0), max.at(i-1).at(1)) + abc.at(i).at(2);
    }

    ans = max3(max.at(n-1).at(0), max.at(n-1).at(1), max.at(n-1).at(2));


    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())

int main() {

	int n, ans = 0;
	cin >> n;
	set<ll> a;
	map<ll, int> m;
	FOR(i, n) {
		int A;
		cin >> A;
		a.insert(A);
		m[A]++;
	}
	auto itr = a.begin();
	FOR(i, a.size()) {
		ans += m[*itr] % 2;
		itr++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 11136
import java.util.ArrayList;
import java.util.Scanner;




class Main{


	static	ArrayList<Integer> one ;
	static	ArrayList<Integer> two ;
	static	ArrayList<Integer> three ;
	static	ArrayList<Integer> four ;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[]a = new int[n + 1];
		int[]b = new int[n + 1];
		int[]c = new int[m + 1];
		int[]d = new int[m + 1];

		for(int i = 1;i < n+1;i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		
		for(int i = 1;i < m+1;i++){
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		
		int ans[] = new int[n+1];
		
		for(int i = 1;i < n+1;i++){
			int dis = 1000000000;
			int minnum = 0;
			for(int j = 1; j < m+1;j++){
				if( (Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j])) < dis){
					dis = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
					minnum = j;
				}
			}
			
			ans[i] = minnum;			
		}
		
		for(int i = 1;i < n+1;i++){
			System.out.println(ans[i]);
		}
		
		
		
		
		
	}
}

class Pair implements Comparable{
	Character from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




Measured memory_bytes: 21844
# -*- coding: utf-8 -*-
import math
import datetime
import itertools
import sys
import copy

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())
N = int(input())

if N%2 == 1 :
  print (0)
  exit()
else :
  cnt = 0
  i = 1
  N //= 2
  while N >= 5**i :
    cnt += N // (5**i)
    i += 1
    
  print (cnt)
  
  

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

typedef long long ll;
const int MOD = 1000000007;

ll mod_pow(ll a, ll b) {
    if (b == 0) return 1;
    ll res = mod_pow(a * a % MOD, b / 2);
    if (b % 2 == 1) res = res * a % MOD;
    return res;
}

ll comb(ll a, ll b) {
    ll res = 1;
    for (int i = 0; i < b; i++) {
        res = res * (a - i) % MOD * mod_pow(i + 1, MOD - 2) % MOD;
    }
    return res;
}

int main() {
    ll N, M;
    cin >> N >> M;

    ll res = 1;
    for (int i = 2; i * i <= M; i++) {
        int cnt = 0;
        while (M % i == 0) {
            M /= i;
            cnt++;
        }
        res *= comb(N + cnt - 1, cnt);
        res %= MOD;
    }

    if (M != 1) {
        res = res * N % MOD;
    }
    cout << res << endl;
    return 0;
}

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

const int MOD = 1000000007;

int main() {
    int H, W; cin >> H >> W;
    vector<vector<bool>> grids(H, vector<bool>(W));
    for (int i = 0; i < H; i++) {
        string line; cin >> line;
        for (int j = 0; j < W; j++) {
            grids[i][j] = (line[j]=='.');
        }
    }
    vector<vector<int>> ptn(H+1, vector<int>(W+1));
    ptn[0][1] = 1;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (grids[i-1][j-1]) ptn[i][j] = (ptn[i-1][j] + ptn[i][j-1]) % MOD;
        }
    }
    cout << ptn[H][W] << endl;
}


Measured memory_bytes: 4352
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	char a, b;
	cin>>a>>b;
	if(a<b) cout<<'<'<<endl;
	else if(a>b) cout<<'>'<<endl;
	else cout<<'='<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 1e18;

void solve()
 {
  string s,t,u;
  int x,y;
  cin>>s>>t;
  cin>>x>>y>>u;
  if( s == u)
   x--;
  else
   y--;
  cout<<x<<" "<<y;
 }  
signed main()
 {   
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  cout.tie(0); 
   /*int t;
   cin>>t;
   loop(i,1,t+1)*/
      solve();
      
  //cerr<<END<<1.0*clock();
  return 0;
} 


Measured memory_bytes: 3632
#include <iostream>
#include <climits>
#include <algorithm>


using namespace std;

int H, N;
string S;


int main()
{

    cin >> H >> N;

    int ai = 0;
    int A  = 0;


    for (int i = 0; i < N; i++) {
        cin >> ai;
        A = A + ai;
    }

    if (H<=A) {
        cout << "Yes" << "\n";

    } else {
        cout << "No" << "\n";
    }


}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    ll D,N;
    cin >> D >> N;
    if(N==100) N++;
    if(D == 0)cout << N << endl;
    else if(D == 1) cout << N * 100 << endl;
    else cout << N * 10000 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a =  Integer.parseInt(sc.next());
		int b =  Integer.parseInt(sc.next());
		
		int ans = a - b*2;
		
		if(ans < 0) {
			ans = 0;
		}
		
		System.out.println(ans);
		
		
		
		
	}
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    map<int, vector<int>> mp;
    for(int i=0; i<m; i++)
    {
        int a, b;
        cin >> a >> b;
        if(mp.count(a) == 1) mp.at(a).push_back(b);
        else mp[a].push_back(b);
        if(mp.count(b) == 1) mp.at(b).push_back(a);
        else mp[b].push_back(a);
    }
    // for(auto [k, v] : mp)
    // {
    //     cout << k << endl;
    //     for(auto i : v)
    //     {
    //         cout << "  " << i << endl;
    //     }
    // }

    queue<int> q;
    q.push(1);
    vector<int> cmp(n+1, -1);
    cmp.at(1) = 0;
    while(!q.empty())
    {
        int cp = q.front();
        q.pop();
        // cout << cp << ": ";
        // cout << cmp.at(cp) << endl;
        for(int np : mp.at(cp))
        {
            if(cmp.at(np) != -1) continue;
            q.push(np);
            cmp.at(np) = cp;
        }
    }
    bool ans = true;
    for(int i=2; i<=n; i++)
    {
        if(cmp.at(i) == -1) ans = false;
    }
    if(ans)
    {
        cout << "Yes\n";
        for(int i=2; i<=n; i++)
        {
            cout << cmp.at(i) << '\n';
        }
    }
    else cout << "No\n";

    return 0;
}


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

int main() {
	int n;
	int taro = 0, hana = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string t, h;
		cin >> t >> h;
		if (t > h)taro += 3;
		else if (t == h) {
			taro++;
			hana++;
		}
		else hana += 3;
	}
	cout << taro << " " << hana << endl;
}

Measured memory_bytes: 1212
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int maxn = 1e5;
int n, cnt;
int a[maxn + 10];
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for(int i = 1; i <= n; i++) {
		if(a[i] == i) {
			cnt++;
			if(i != n)swap(a[i], a[i + 1]);
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll a, b;
  char op;
  while (true) {
    cin >> a >> op >> b;
    if (op == '?') return;
    ll ans;
    if (op == '+') ans = a + b;
    if (op == '-') ans = a - b;
    if (op == '*') ans = a * b;
    if (op == '/') ans = a / b;
    cout << ans << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3212
import sys
import heapq

input = sys.stdin.buffer.readline
in_n = lambda: int(input())
in_nn = lambda: map(int, input().split())
in_s = lambda: input().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')]

MOD = 10**9 + 7
INF = 8 * 10**18


def dijkstra(N, s0, edge):

    d = [INF] * N
    used = [False] * N
    edgelist = [(0, s0)]
    heapq.heapify(edgelist)

    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in edge[v]:
            if d[e[1]] <= (e[0] + d[v]) or used[e[1]]:
                continue
            heapq.heappush(edgelist, [e[0] + d[v], e[1]])
    return d


def main():

    N, M, S, T = in_nn()
    S, T = S - 1, T - 1

    edge_yen = [[] for _ in range(N)]
    edge_sun = [[] for _ in range(N)]

    for i in range(M):
        u, v, a, b = in_nn()
        u, v = u - 1, v - 1
        edge_yen[u].append((a, v))
        edge_yen[v].append((a, u))
        edge_sun[u].append((b, v))
        edge_sun[v].append((b, u))

    d_s_yen = dijkstra(N, S, edge_yen)
    d_t_sun = dijkstra(N, T, edge_sun)

    money = 10**15
    year = [0] * N
    for i in range(N):
        year[i] = money - d_s_yen[i] - d_t_sun[i]

    ans = [0] * N
    year_max = 0
    for i in range(N - 1, -1, -1):
        year_max = max(year_max, year[i])
        ans[i] = year_max

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 136744
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC082_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var ave = (str[1] + str[0]) / 2.0;

            double sss = Math.Ceiling(ave);

            Console.WriteLine(sss);

        }
    }
}


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

int main(){
    string S;
    cin >> S;
    int n = S.size();
    reverse(S.begin(), S.end());
    vector<vector<int>> DP(n + 1, vector<int>(2));

    for (int i = 0; i < n; i++){
        int a = S[i] - '0';
        DP[i + 1][0] = DP[i][0] + a;
        DP[i + 1][1] = DP[i][0] + 9;
        if (a - 1 >= 0)
            DP[i + 1][0] = max(DP[i + 1][0], DP[i][1] + a - 1);
        DP[i + 1][1] = max(DP[i + 1][1], DP[i][1] + 9);
    }

    cout << DP[n][0] << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            long[] A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long ans = A.Max() - A.Min();
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396