akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
	int n;
	cin >> n;
	vector<LL> a(n+1);
	a[0] = 0;
	map<LL,LL> freq;
	freq[0]++;
	LL ans = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		a[i] += a[i-1];
		ans += freq[a[i]];
		freq[a[i]]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
vector<vi> res;int n,m,q;
int cnt  =0;

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(b<=c){
        cout<<a*(b-1)/b<<endl;
    }
    else{
        cout<<a*c/b<<endl;
    }
    }

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

using ll = long long int;
using llu = unsigned long long int;
using ld = long double;
const long long int NUM = 1000000;
const long double PI = 2*acos(0.0);
const int INF = 1e9 + 10 ;
const long long int maximum = (-1*INF);
#define LCM(a,b)            (a / __gcd(a,b)) * b
#define GCD(a,b)            __gcd(a,b)
#define dist(x1,y1,x2,y2)   sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define sqr(a)              ((a)*(a))
#define fast                ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define precision(a)        fixed<<setprecision(a)
#define endl                "\n"
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define ms(a,b)             memset((a),(b),sizeof(a))
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(min(a,b),min(c,d))
#define max4(a,b,c,d)       max(max(a,b),max(c,d))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
#define REP(i,b)            for(long long int i = 0; i < b; i++)
#define READ(f)             freopen("f", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)

/*void sieve(ll n) {
    bool status[(n>>1)+1] = {false};
    ll inc, i;
    for(i = 3; i*i <= n; i += 2)
    {
        if(!status[i>>1])
        {
            inc = i<<1;
            for(ll j = i*i; j <= n; j += inc)
                status[j>>1] = true;
        }
    }
}*/

/*bool compare(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    if(a.ff == b.ff)
        return a.ss <= b.ss;
    return a.ff < b.ff;
}*/


/*ll logs(ll x)
{
    return 64 - __builtin_clzll(x) - 1;
}*/

//map<char, ll> m = { {'q', 9}, {'r', 5}, {'b', 3}, {'n', 3}, {'p', 1}, {'k', 0}, {'.', 0} };

//||

int main() {
    fast;
    string s1, s2;
    cin >> s1 >> s2;
    ll len = s1.size();
    REP(i, len) {
        if (s1[i] != s2[i]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<stack>
#include<queue>
#include<map>



using namespace std;


int main()
{
    set<string> SET;
    int n;
    cin >> n;
    string s;
    for (int i = 0;i<n;i++)
    {
        cin >> s;
        SET.insert(s);
    }   
    cout << SET.size() << endl;
    return 0;
}

Measured memory_bytes: 15664
let s = read_line ()
let f x = let n = ref 0 in String.iter (fun c -> if c = x then incr n) s; !n
let a, b, c = f 'a', f 'b', f 'c'
let _ = print_endline @@ if max a (max b c) - min a (min b c) > 1 then "NO" else "YES"

Measured memory_bytes: 2688
#!/usr/bin/env python3
import sys

YES = "Yes" 
NO = "No"  

A,B,C = list(map(int, input().split()))
K = int(input())

def check(A,B,C):
    if A < B < C:
        print(YES)
        sys.exit()

for i in range(K):
    if B <= A:
        B = B * 2
    elif C <= B:
        C = C * 2

    check(A,B,C)

print(NO)

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

int main() {

	int x_right, y_upper, n; cin >> x_right >> y_upper >> n;
	int x_left = 0;
	int y_lower = 0;
	for (int i = 0; i < n; i++) {
		int x, y, a; cin >> x >> y >> a;
		if (a == 1) x_left = max(x_left, x);
		if (a == 2) x_right = min(x_right, x);
		if (a == 3) y_lower = max(y_lower, y);
		if (a == 4) y_upper = min(y_upper, y);
	}
	cout << max(0, x_right - x_left) * max(0, y_upper - y_lower) << endl;
    return 0;
}

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

int main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    double S = W * H / 2.0;
    int a = (x + x == W and y + y == H);
    printf("%.15lf %d\n", S, a);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	private static long solve(int a, int b, int c, int x, int y){
		long option1 = (a * x) + (b * y);
		long option2 = 0;
	if (x > y){
	   option2 = ((x - y) * a) + (Math.min(x, y) * c * 2);
	} else if (y > x){
	   option2 = ((y - x) * b) + (Math.min(x, y) * c * 2);
	} else {
	    option2 = (x * c * 2);
	}
	option2 = Math.min(option2, Math.max(x, y) * c * 2);
	return Math.min(option1, option2);
	}
	public static void main(String args[]){
	   Scanner sc = new Scanner(System.in);
	   int a = sc.nextInt();
	   int b = sc.nextInt();
	   int c = sc.nextInt();
	   int x = sc.nextInt();
	   int y = sc.nextInt();
	   System.out.println(solve(a, b, c, x, y));
	}
}

Measured memory_bytes: 22740
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())

        if N % 2 == 0:
            print(N // 2 - 1)
        else:
            print(N // 2)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 38256
n=int(input())
a=[0]+list(map(int,input().split()))+[0]
# ansは1の連続する長さの最大値+1
ans=[]
ans1=1
for i in a:
    if i==1:
        ans1+=1
    else:
        ans.append(ans1)
        ans1=1
print(max(ans))


Measured memory_bytes: 5596
#include<stdio.h>
int main(void)
{
	int n,m,a[1000],b[1000],x,i;
	while(1)
	{
		x=1;
		scanf("%d %d", &n, &m);
		if(n==0&&m==0)
		break;
		for(i=1; i<=n; i++)
		scanf("%d", &a[i]);
		for(i=1; i<=m; i++)
		scanf("%d", &b[i]);
		i=1;
		while(x<n)
		{
			x+=b[i];
			i++;
			x+=a[x];
		}
		printf("%d\n", i-1);
	}
	
	return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

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

int main() {
        //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<char, ll> mp;
    string S;
    ll N;
    ll mod=1e9+7;
    cin >> N >> S;
    for(int i = 0; i < N; i++) {
        mp[S[i]]++;
    }
    ll ans = 1;
    for(char moji = 'a'; moji <= 'z'; moji++) {
        ans = (ans * (mp[moji] + 1)) % mod;
    }
    cout << (ans - 1 + mod) % mod << endl;



    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
  	int h, w;
  	vector<string> vs;
  	cin >> h >> w;
  	for (int i = 0; i < h; i++) {
  		string s;
  		cin >> s;
  		vs.push_back(s);
  	}
  	vector<vector<int> > vv(h, vector<int> (w, 0x3f3f3f3f));
  	for (int i = 0; i < h; i++) {
  		for (int j = 0; j < w; j++) {
  			if (vs[i][j] == '#') {
  				vv[i][j] = 0;
  			}
  		}
  	}

  	for (int i = 0; i < h; i++) {
  		for (int j = 0; j < w; j++) {
  			if (i > 0) {
  				vv[i][j] = min(vv[i][j], vv[i - 1][j] + 1);
  			}
  		}
  	}

  	for (int i = 0; i < h; i++) {
  		for (int j = 0; j < w; j++) {
  			if (j > 0) {
  				vv[i][j] = min(vv[i][j], vv[i][j - 1] + 1);
  			}
  		}
  	}

  	for (int i = h - 1; i >= 0; i--) {
  		for (int j = 0; j < w; j++) {
  			if (i < h - 1) {
  				vv[i][j] = min(vv[i][j], vv[i + 1][j] + 1);
  			}
  		}
  	}
  	for (int i = 0; i < h; i++) {
  		for (int j = w - 1; j >= 0; j--) {
  			if (j < w - 1) {
  				vv[i][j] = min(vv[i][j], vv[i][j + 1] + 1);
  			}
  		}
  	}
  	int res = 0;
  	for (int i = 0; i < h; i++) {
  		for (int j = 0; j < w; j++) {
  			res = max(res, vv[i][j]);
  		}
  	}
  	cout << res << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  vector<pair<string, int>> res;
  for (auto e : mp)
    res.push_back(e);
  sort(res.begin(), res.end(), [](pair<string, int> x, pair<string, int> y) {
    if (x.second == y.second)
      return x.first < y.first;
    return x.second > y.second;
  });
  rep(i, res.size()) {
    if (i && res[i].second < res[i-1].second)
      break;
    cout << res[i].first << endl;
  }
  return 0;
}

Measured memory_bytes: 28016
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
bool vis[maxn];
vector<int>G[maxn];
int dp[maxn];
int n , m ;

void dfs(int u)
{
	vis[u] = 1;
	dp[u] = 0 ;
	
	for(auto v : G[u]){
		
		if(vis[v]==0)  dfs(v);
		dp[u] = max(dp[u],1+dp[v]);
	}
}


int main(){
	
	cin >> n >> m;
	--n;
	while(m--){
		int u , v;
		cin >> u >> v;
		
		--u , --v;
		G[u].push_back(v);
	}
	
	int ans = 0 ;
	
	for(int i = 0 ; i <=n ; i++){
		if(vis[i]==0)
		dfs(i);
	}
	
//	for(int i = 0 ; i <= n ; i++)
//	cout<<dp[i]<<" ";
	
	for(int i = 0 ; i <= n ;i++)
	{
		ans = max(dp[i] , ans);
	}
	
	cout<<ans<<endl;
}

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


int n, m, s, t;
vector<pair<int, long long> > edge[2][100000];
long long dist[2][100000], dist_res[100000];
long long ans[100000];

void dijkstra(int kind, int start){
  priority_queue<pair<long long, int> > Q;

  for(int i = 0; i < 100000; i++){
    dist[kind][i] = 10000000000000000;
  }
  dist[kind][start] = 0;
  Q.push(make_pair(-0, start));
  while(!Q.empty()){
    pair<long long, int> q = Q.top(); Q.pop();
    int now = q.second;
    long long d = -(q.first);
    if(dist[kind][now] < d){
      continue;
    }
    dist[kind][now] = d;
    for(int i = 0; i < edge[kind][now].size(); i++){
      if(edge[kind][now][i].second + d < dist[kind][edge[kind][now][i].first]){
	dist[kind][edge[kind][now][i].first] = edge[kind][now][i].second + d;
	Q.push(make_pair(-dist[kind][edge[kind][now][i].first], edge[kind][now][i].first));
      }
    }
  }
}


int main(){
  cin >> n >> m >> s >> t;
  s--; t--;
  for(int i = 0; i < m; i++){
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    edge[0][u].push_back(make_pair(v, a));
    edge[0][v].push_back(make_pair(u, a));
    edge[1][u].push_back(make_pair(v, b));
    edge[1][v].push_back(make_pair(u, b));
  }

  dijkstra(0, s);
  dijkstra(1, t);
  for(int i = 0; i < n; i++){
    dist_res[i] = dist[0][i] + dist[1][i];
  }
  ans[n-1] = dist_res[n-1];
  for(int i = n-1; i > 0; i--){
    ans[i-1] = min(ans[i], dist_res[i-1]);
  }
  for(int i = 0; i < n; i++){
    printf("%lld\n", 1000000000000000 - ans[i]);
  }
}


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

typedef long long ll;
const int MaxN = 212345;
const ll mod = 998244353;

int n, m;
vector<int> g[112345];

void topological_sort(int u, stack<int>& stk, bool vis[]) {
	//cout << u << "\n";
	vis[u] = true;
	for (auto& v : g[u]) {
		if (vis[v] == false) {
			topological_sort(v, stk, vis);
		}
	}
	stk.push(u);
}

void solve_case() {
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
	}
	
	int dp[n + 1]; bool vis[n + 1];
	stack<int> stk;
	memset(dp, 0, sizeof(dp));
	memset(vis, 0, sizeof(vis));
	
	for (int i = 1; i <= n; i++) {
		if(vis[i] == 0) {
			topological_sort(i, stk, vis);
		}
	}
	
	int t_sort[n];
	int i = 0;
	while(!stk.empty()){
		t_sort[i] = stk.top();
		stk.pop();
		i++;
		
		//cout << t_sort[i-1] << " ";
	}
	
	int j;
	int ans = 0;
	for (i = 0; i < n; i++) {
		j = t_sort[i];
		for (auto& u : g[j]) {
			dp[u] = max(dp[u], 1 + dp[j]);
			ans = max(ans, dp[u]);
		}
	}
	
	cout << ans << "\n";
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll t=1;
    //cin >> t;
    while(t--) solve_case();
}


Measured memory_bytes: 12964
n,d = map(int,input().split())
num = [[0]*d for i in range(d)]
a = 0
for i in range(n):
  x,y = map(int,input().split())
  x %=d
  y%=d
  num[x][y] += 1
  a = max(a,num[x][y])
x=1
while x*x<a:
  x += 1
r = (x-1)*d
a = x-1
dai = d-1
syo = 0
anum = [[[0]*d for i in range(d)]for i in range(3)]
rui = [[[0]*(2*d+1) for i in range(2*d+1)]for i in range(3)]
for i in range(d):
  for j in range(d):
    z = num[i][j]
    if z > (a+1)**2:
      anum[0][i][j]=1
      anum[1][i][j]=1
      anum[2][i][j]=1
    elif z> a*(a+1):
      anum[1][i][j]=1
      anum[2][i][j]=1
    elif z > a*a:
      anum[1][i][j]=1
for x in range(3):
  for i in range(1,2*d+1):
    for j in range(1,2*d+1):
      rui[x][i][j]+=rui[x][i-1][j]+rui[x][i][j-1]-rui[x][i-1][j-1]+anum[x][(i-1)%d][(j-1)%d]
def cheak(kon):
  for i in range(1,d+1):
    for j in range(1,d+1):
      if rui[0][i+kon][j+kon] - rui[0][i - 1][j+kon] - rui[0][i+kon][j - 1] + rui[0][i - 1][j - 1]:
        continue
      if rui[1][i+d-1][j+d-1] - rui[1][i+kon+1 - 1][j+d-1] - rui[1][i+d-1][j+kon+1 - 1] + rui[1][i+kon+1 - 1][j+kon+1 - 1]:
        continue
      if rui[2][i+d-1][j+kon] - rui[2][i+kon+1 - 1][j+kon] - rui[2][i+d-1][j - 1] + rui[2][i+kon+1 - 1][j - 1]:
        continue
      if rui[2][i+kon][j+d-1] - rui[2][i - 1][j+d-1] - rui[2][i+kon][j+kon+1 - 1] + rui[2][i - 1][j+kon+1 - 1]:
        continue
      return 1
  return 0 
kon = (dai+syo)//2
while True:
  if dai-syo <= 1:
    if cheak(syo) == 1:
       dai = syo
    break
  kon = (dai+syo)//2
  c = cheak(kon)
  if c == 1:
    dai = kon
  else:
    syo = kon
print(dai+r)

Measured memory_bytes: 175448
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  ll n, k;
  cin >> n >> k;
  map<int, ll> mp;
  rep (i, n) {
    int a, b;
    cin >> a >> b;
    auto itr = mp.find(a);
    if (itr != mp.end()) mp[a] += b;
    else mp[a] = b;
  }
  ll count = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    int flag = 0;
    count += itr->second;
    if (k <= count) {
      P(itr->first);
      break;
    }
  }
  return 0;
}

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


int main() {

    int a, b, t;
    cin >> a >> b >> t;
    cout << b*(t/a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main() {
    int n;
    cin>>n;
    vector<string> s(n);
    vector<int> t(n);
    for(int i=0; i<n; i++) cin>>s[i]>>t[i];
    string x;
    cin>>x;
    bool find=false;
    ll ans=0;
    for(int i=0; i<n; i++){
        if(x==s[i] && !find){
            find=true;
        }else if(find){
            ans+=t[i];
        }
    }
    cout<<ans<<endl;
}


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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		x1 -= x2;
		y1 -= y2;
		
		int x3 = y1 + x2;
		int y3 = -x1 + y2;
		x1 += x2;
		y1 += y2;
		
		x2 -= x3;
		y2 -= y3;
//		pr.printf("%d %d %d %d\n", x2, y2, x3, y3);
		int x4 = y2 + x3;
		int y4 = -x2 + y3;
		
		pr.printf("%d %d %d %d\n", x3, y3, x4, y4);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
int main()
{
	FAST
	#ifdef ayk_16
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	ll x;
	cin>>x;
	while(1)
	{
		ll f=0;
		for(ll i=2;i<x;i++)
		{
			if(x%i==0)
			{
				f=1;
				break;
			}
		}
		if(f==0)
		{
			cout<<x;
			break;
		}
		x++;
	}
}

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

int main(){
    int ans = 0;
    int n, h, w;
    cin >> n >> h >> w;
    int a, b;
    for (int i = 0; i < n; i++){
        cin >> a >> b;
        if (a < h) continue;
        if (b < w) continue;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanLLInt(N);
    scanVecLLInt(A, N);
    ll result = 0;
    while (true){
        sort(A.begin(), A.end());
        // loop(i, N) printf("%lld ", A[i]); puts("");
        if (A.back() < N) break;
        if (N <= A.front()){
            const ll h = A.front() - N + 1;
            loop(i, N){
                A[i] -= h;
            }
            result += h * N;
        }else{
            const ll times = ((A[N - 1] - N) / N) + 1;
            loop(i, N - 1){
                A[i] += times;
            }
            A[N - 1] -= (times * N);
            result += times;
        }
    }
    printf("%lld\n", result);
}


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

int main() {
    int n, m;
    long long num = pow(10,9) + 7;
    long long ans = 1;
    cin >> n >> m;

    if (n==m) {
        for (int i=0; i<n; i++){
            ans *= i+1;
            ans %= num;
        }
        ans *= ans;
        ans %= num;
        ans *= 2;
        ans %= num;
    }
    else if (abs(n-m) == 1) {
        for (int i=0; i<n; i++){
            ans *= i+1;
            ans %= num;
        }
        for (int i=0; i<m; i++) {
            ans *= i+1;
            ans %= num;
        }
    }
    else {
        cout << 0 << endl;
        exit(0);
    }
    cout << ans << endl;
}


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

int main(){
	
	int w,n;
	char con;
	cin>>w>>n;
	vector<int> s(w);
	vector<int> a(n);
	vector<int> b(n);
	
	for(int i=0;i<w;i++)
		s[i]=i+1;
	
	for(int i=0;i<n;i++)
		cin>>a[i]>>con>>b[i];
	
	for(int i=0;i<n;i++)
		swap(s[a[i]-1],s[b[i]-1]);
	
	for(int i=0;i<w;i++)
		cout<<s[i]<<endl;
}

Measured memory_bytes: 1192
#include<iostream>
#include<climits>

using namespace std;
// Problem https://atcoder.jp/contests/arc096/tasks/arc096_a
int solver(int pizzaAPr,int pizzaBPr,int pizzaABHPr,int needA,int needB){
    int result = INT_MAX ;
    // cout << pizzaAPr << " " << pizzaBPr << " " << pizzaABHPr << " " << needA << " " << needB << endl;
    for(int j=0;j<=200000;j=j+2){
        int pizzaAPrPiece = j / 2;
        int pizzaBPrPiece = j / 2;
        int moreNeedA = max(0,needA-pizzaAPrPiece);
        int moreNeedB = max(0,needB-pizzaBPrPiece);
        int sumMoney=j*pizzaABHPr + pizzaAPr * moreNeedA + pizzaBPr * moreNeedB;
        if(sumMoney < result){
            result = sumMoney;
        }
    }

    return result;
}

int main(void){
    int A,B,C,X,Y;
    int answer=0;
    cin >> A >> B >> C >> X >> Y;
    answer=solver(A,B,C,X,Y);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long x = sc.nextLong();
		long y = sc.nextLong();
		int count = 0;
		
		for (long i = x; i <= y; i *= 2) {
			count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  double res = 0;
  while (n--) {
    double a; cin >> a;
    res += 1 / a;
  }
  cout << fixed << setprecision(15) << 1 / res << '\n';
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARegularTriangle solver = new ARegularTriangle();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARegularTriangle {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            out.print(a == b && b == c ? "Yes" : "No");
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public void close() {
        }

    }
}



Measured memory_bytes: 21460
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn=new Scanner(System.in);
        byte a=stdIn.nextByte();
        byte b=stdIn.nextByte();
        byte c=stdIn.nextByte();
        c-=a-b;
        if(c>0){
            System.out.println(c);
        }
        else System.out.println(0);
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.ArrayList;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] val=new int[n+1];
		Sushi[] box=new Sushi[n];
		ArrayList<Long> list=new ArrayList<Long>();
		for(int i = 0; i<n; i++){
			int t = sc.nextInt();
			long d = sc.nextLong();
			box[i]=new Sushi(t,d);
		}
		Arrays.sort(box,Comparator.comparing(Sushi::getD).reversed());
		long sum=0;
		long vali=0;
		for(int i = 0; i<k; i++){
			sum+=box[i].d;
			if(val[box[i].t]==0){
				vali++;
			}else{
				list.add(box[i].d);
			}
			val[box[i].t]++;
		}
		long ans=vali*vali+sum;
		if(list.size()==0){
			System.out.println(ans);
			return;
		}
		int min=list.size()-1;
		for(int i=k; i<n; i++){
			if(val[box[i].t]==0){
				vali++;
				val[box[i].t]++;
				sum+=box[i].d-list.get(min);
				min--;
				ans=Math.max(ans,vali*vali+sum);
				if(min==-1){
					break;
				}
			}
		}
		System.out.println(ans);
	}
	static class Sushi{
		int t;
		long d;
		public Sushi(int t, long d){
			this.t=t;
			this.d=d;
		}
		public long getD(){
			return this.d;
		}
	}
}

Measured memory_bytes: 96480
import sys

#s = input()
s = sys.stdin.read()
#print(s)
CH = [0 for _ in range(26)]
for i in s:
    asc = ord(i)
    if 65 <= asc <= 90:
        CH[asc - 65] += 1
    elif 97 <= ord(i) <= 122:
        CH[asc - 97] += 1
for i in range(26):
    print(f'{chr(97+i)} : {CH[i]}')


Measured memory_bytes: 5576
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
const int MAXM = 4e2 + 5;
const int MAXN = 26 + 5;
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;

int n=26, m;
int c[MAXN];
int a[MAXM][MAXN];

int p[MAXM];
set<int> idx[MAXN];
int ans;

void init(void)
{
	for(int i=1; i<=n; ++i)
	{
		idx[i].clear();
		idx[i].insert(0);
		idx[i].insert(m+1);
	}
	
	for(int k=1; k<=m; ++k)
		idx[ p[k] ].insert(k);
}

int recalc(int pos, int x)
{
	int old = p[pos];
	if(old == x) return ans;
	
	int res = ans;
	
	idx[old].erase(pos);
	
	set<int>::iterator it = idx[old].upper_bound(pos);
	int nxt = *it;
	int lst = *(--it);
	
	res -= (pos - lst) * c[old] * (nxt - pos) + a[pos][old];
	
	it = idx[x].upper_bound(pos);
	nxt = *it;
	lst = *(--it);
	
	res += (pos - lst) * c[x] * (nxt - pos) + a[pos][x];
	
	idx[x].insert(pos);
	
	p[pos] = x;
	return res;
}

int main(void)
{
	srand(time(0));
	
	scanf("%d",&m);
	for(int i=1; i<=n; ++i) scanf("%d",&c[i]);
	for(int i=1; i<=m; ++i)
		for(int j=1; j<=n; ++j)
			scanf("%d",&a[i][j]);
	
	static int lst[MAXN];
	
	ans = 0;
	for(int k=1; k<=m; ++k)
	{
		int mx = -inf;
		int mxi = -1;
		for(int i=1; i<=n; ++i)
		{
			int res = a[k][i];
			for(int j=1; j<=n; ++j) if(j!=i)
				res -= c[j] * (k-lst[j]);
			
			if(mxi==-1 || mx < res)
				mxi = i, mx = res;
		}
		lst[mxi] = k;
		
		ans += mx;
		p[k] = mxi;
	}
	
	init();
	
	int T = 2.5e6;
	while(T--)
	{
		int pos = rand()%m + 1;
		int x = rand()%n + 1;
		
		int old = p[pos];
		int res = recalc(pos, x);
		if(res < ans) recalc(pos, old);
		else ans = res;
	}
	
	for(int i=1; i<=m; ++i) printf("%d\n",p[i]);
	return 0;
}

Measured memory_bytes: 3388
n=int(input())
ans=[None]*(n+1)
for i in range(n+1):
  ans[i]=[0]*(n+1)
l=list(map(float,input().split()))
for i in range(n+1):
  ans[0][i]=0
for i in range(1,n+1):
  for j in range(0,n+1):
    if(i==1):
      if(j==0):
        ans[i][j]=1-l[0]
        continue
      elif(j==1):
        ans[i][j]=l[0]
        continue
      else:
        break
    if(j==0):
      ans[i][0]=ans[i-1][0]*(1-l[i-1])
      continue
    ans[i][j]=ans[i-1][j-1]*l[i-1] + ans[i-1][j]*(1-l[i-1])
a=0
import math
for i in range(math.ceil(n/2),n+1):
  a+=ans[n][i]
print(a)

Measured memory_bytes: 252296
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <functional>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
using namespace std;

int n,m,p,heap[200100],tot,cnt[200100],ans;
struct data
{
    int r;
    data *nxt;
} pool[200100],*tp=pool,*fst[200100];

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';;
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

int main()
{
    scanf("%d%d",&n,&m),ans=n;
    repu(i,1,n)
    {
        int l=getint(),r=getint();
        if (!l)
            ++cnt[r];
        *tp=(data){r,fst[l]},fst[l]=tp++;
    }
    p=1;
    repu(i,1,m)
        for (data *j=fst[i]; j; j=j->nxt)
            if (p<=i)
                ++p,--ans,heap[++tot]=j->r,push_heap(heap+1,heap+1+tot,greater<int>());
            else
            {
                int r=j->r;
                if (heap[1]<r)
                {
                    pop_heap(heap+1,heap+1+tot,greater<int>());
                    swap(r,heap[tot]),push_heap(heap+1,heap+1+tot,greater<int>());
                }
                ++cnt[r];
            }
    repu(i,1,m)
        for (; cnt[i] && p<=m; --cnt[i],--ans,p=max(p,i)+1);
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll DP[2100][2100];
ll SUM[2100][2100];

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> S(N+1);
    vector<ll> T(M+1);
    REP(i,N){
        cin >> S[i];
    }
    REP(i,M){
        cin >> T[i];
    }

    S[N] = -10000;
    T[M] = -100;

    //REP(i,2100) REP(j,2100) DP[i][j] = -1e12;
    DP[0][0] = 1;

    REP(i,N+1){
        ll s = S[i];
        REP(j,M+1){
            ll t = T[j];

            SUM[i][j] = DP[i][j];
            if(i > 0) SUM[i][j] += SUM[i-1][j];
            if(j > 0) SUM[i][j] += SUM[i][j-1];
            if(j > 0 && i > 0) SUM[i][j] += MOD - SUM[i-1][j-1];
            SUM[i][j] %= MOD;

            if(s == t){
                DP[i+1][j+1] += SUM[i][j];
                DP[i+1][j+1] %= MOD;
            }

            //DP[i][j+1] += DP[i][j];
            //DP[i][j+1] %= MOD;

        }
    }

    ll ans = 0;
    ans = SUM[N][M] % MOD;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 67840
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    vector<int> v(3);
    for(int i=0;i<3;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    int cost=0;
    for(int i=0;i<2;i++){
        cost+=v[i+1]-v[i];
    }
    cout<<cost<<endl;
    return 0;
}

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

using namespace std;
int a[200005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	long long ans=0;
	for(int i=1;i<n;i++){
		if(a[i]<a[i-1]){
			ans+=abs(a[i]-a[i-1]);
			a[i]=a[i-1];
		}
	}
	cout<<ans<<endl;
	return 0;
	
}

Measured memory_bytes: 4356
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))

unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans  = 0;
    string ans2;
    int N;
    cin >> N;
    char a[N];
    for(int i = 0;i < N;i++){
        cin >>a[i];
    }
    for(int i = 0;i < N;i++){
        if(a[i] == 89){
            ans2 = "Four";
            break;
        }else{
            ans2 = "Three";
        }
    }
    cout << ans2 << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc080/tasks/abc080_a

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int n, a, b;

  cin >> n >> a >> b;

  cout << min(a * n, b) << '\n';

  return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N, Q;
    for (int N, Q; cin >> N >> Q and N and Q;) {
        vector<pair<int,pair<string, int>>> p;
        rep(i, N) {
            string e;
            int a, b;
            cin >> e >> a >> b;
            p.push_back(make_pair(b, make_pair(e, a)));
        }
        sort(p.begin(), p.end(),[](const pair<int, pair<string, int>>& a, const pair<int, pair<string, int>>& b) {
            return a.first < b.first;
        });
        rep(i, Q) {
            int d;
            cin >> d;

            auto itr = lower_bound(p.begin(), p.end(), make_pair(d, make_pair("a", 0)), [](const pair<int, pair<string, int>>& a, const pair<int, pair<string, int>>& b) {
                return a.first < b.first;
            });

            if (itr == p.end()) {
                cout << "Unknown" << endl;
            }
            else {
                auto tmp = *itr;
                if (tmp.first-tmp.second.second+1 <= d and d <= tmp.first) {
                    cout << tmp.second.first << ' ' << tmp.second.second - (tmp.first - d) << endl;
                }
                else {
                    cout << "Unknown" << endl;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll n,x,y,z; cin>>n>>x>>y>>z;
  ll ans = 0;
  if(y%2==1){
    cout<<0<<endl;
    return 0;
  }

  /*
    22をbセット(y/2セット)
    333をcセット(0セット〜z/3セット)
    (b+c)Cb
    31をdセット(0セット〜z-3cセット)
    (b+c+d)Cd
    1をx-dセット
    (b+c+d+x-d)C(x-d)
    2の間に3をz-3c-d個
    (z-3c-d+b-1)C(b-1)
  */

  ll b = y/2;
  rep(c, z/3+1){
    rep(d, z-3*c+1){
      ans += nCr(b+c, b) * nCr(b+c+d,d) %MOD * nCr(b+c+d+x-d, x-d) %MOD * nCr(z-3*c-d+b-1, b-1) %MOD;
      ans %= MOD;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef long long ll;
map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ll N, M;
  cin >> N >> M;
  
  map<ll, int> prime = prime_factor(M);
  
  // 前処理
  COMinit();
  // 計算例 
  ll ans = 1;
  for(auto m: prime){
    ll tmp = m.second;
    ll tmpans = COM(N+tmp-1, N-1);
    ans = ans * tmpans;
    ans %= MOD;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 12160
#include <stdio.h>

int main(void) {
  int a, b, c;

  scanf("%d %d %d", &a, &b, &c);

  if(c<a)
    a ^= c ^= a ^= c;
  if(b<a)
    a ^= b ^= a ^= b;
  if(c<b)
    b ^= c ^= b ^= c;

  printf("%d %d %d\n", a, b, c);

  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
#include <string>
using namespace std;

int main(void){
  long long n,a[100010],plusans=0,minusans=0,sum=0;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++){//first number>=0
    sum+=a[i];
    if(i%2==0){
      if(sum<=0){
        plusans+=1-sum;
        sum=1;
      }
    }
    else{
      if(sum>=0){
        plusans+=sum+1;
        sum=-1;
      }
    }
  }
  sum=0;
  for(int i=0;i<n;i++){//first number<0
    sum+=a[i];
    if(i%2==0){
      if(sum>=0){
        minusans+=sum+1;
        sum=-1;
      }
    }
    else{
      if(sum<=0){
        minusans+=1-sum;
        sum=1;
      }
    }
  }
  cout<<min(plusans,minusans)<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if (a % 2 == b % 2)
		cout << (b - a) / 2 << endl;
	else {
		ll p = a + (b - a) / 2, q = n - b + 1 + (b - a) / 2;
		cout << min(p, q) << endl;
	}
	return 0;
}

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

int main() {

    string S; cin >> S;

    int numN = 0; int numS = 0; int numE = 0; int numW = 0;

    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == 'N') numN++;
        if (S.at(i) == 'S') numS++;
        if (S.at(i) == 'E') numE++;
        if (S.at(i) == 'W') numW++;
    }

    if (0 < numN * numS * numE * numW) cout << "Yes" << endl;

    else if (0 < numE * numW && numN == 0 && numS == 0) cout << "Yes" << endl;

    else if (0 < numN * numS && numE == 0 && numW == 0) cout << "Yes" << endl;

    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N=10;
ld f[320][1<<5],ans;
int n,L;
int l[N],a[N],mrk[N];
void dp(){
	memset(f,0,sizeof f);
	f[n*l[n]][0]=1;
	for (int i=1;i<L*n;i++){
		int x=i%n,v=1<<x-1;
		if (x==0)continue;
		for (int j=i;j<=L*n;j++){
			int j1=min(L*n,max(i+n*a[x],j));
			for (int s=v;s<1<<n-1;s=(s+1)|v)
				f[j1][s]+=f[j][s^v]/L;
		}
	}
	ans+=f[L*n][(1<<n-1)-1];
}
void dfs(int x){
	if (x==n){
		dp();
		return;
	}
	for (int i=1;i<n;i++){
		if (!mrk[i]){
			mrk[i]=1;
			a[x]=l[i];
			dfs(x+1);
			mrk[i]=0;
		}
	}
}
int main(){
	cin>>n>>L;
	for (int i=1;i<=n;i++)scanf("%d",&l[i]);
	for (int i=1;i<n;i++)
		if (l[i]>l[n])swap(l[i],l[n]);
	dfs(1);
	for (int i=1;i<n;i++)ans/=i;
	printf("%.12Lf\n",ans);
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int S, h, m, s;

	scanf("%d", &S);

	s = S % 60;
	S /= 60;
	m = S % 60;
	h = S / 60;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;
ll fac[1000000 + 10], inv[1000000 + 10];
ll pow_mod(ll a, ll n)
{
    ll ret = 1;
    while (n)
    {
        if (n & 1)
            ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}
void init()
{
    fac[0] = 1;
    for (int i = 1; i < 1000000 + 10; i++)
    {
        fac[i] = fac[i - 1] * i % mod;
    }
}
ll Cc(ll x, ll y)
{
    return fac[x] * pow_mod(fac[y] * fac[x - y] % mod, mod - 2) % mod;
}

int cnt;
int main()
{
    init();
    int x, y;

    cin >> x >> y;
    if (x > y)
        swap(x, y);
    if ((x + y) % 3 != 0)
    {
        cout << 0 << endl;
    }
    else
    {
        int cnt = 1;
        while (1)
        {
            if (x * 2 == y)
            {
                break;
            }
            else
            {
                x--;
                y++;
                cnt++;
            }
        }
        x++;
      //  cout << x << " " << cnt << endl;
        cout << Cc(x - 1, cnt - 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 9728
import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush

from collections import Counter
#T = int(stdin.readline())
#for i in range(T):
S=stdin.readline()
T=stdin.readline()

S=S[:-1]
T=T[:-1]


if S==T[:-1]:
    print("Yes")
else:
    print("No")

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

typedef struct OBJ{
    /*OBJ(ll a,ll b,ll c, char d){
        cost = a;
        h = b;
        w = c;
        prev = d;
    }*/
    pair<ll,ll> cost;
    ll h;
    ll w;
    char prev;
    bool operator< (const OBJ &a) const
    {
        return cost > a.cost;
    };
} obj;


ll x[2] ={0,1};
ll y[2] ={1,0};

int main(){
    ll H,W;
    cin >> H >> W;
    vector<vector<char>> s(H,vector<char>(W));
    vector<vector<ll>> dist(H, vector<ll>(W, 1e10));

    rep(i,H){
        rep(j,W){
            cin >> s[i][j];
        }
    }
    //vector<obj> huhu(20);
    //sort(huhu.begin(),huhu.end(),comp);
    priority_queue<OBJ> que;
    
    obj p;
    if(s[0][0] == '.'){
        p.cost=make_pair(0,1);
    }else{
        p.cost=make_pair(1,0);
    }
    p.h=0;
    p.w=0;
    p.prev='.';
    que.push(p);
    while(!que.empty()){

        p = que.top();
        que.pop();
        if(!(0<=p.h && p.h<H))continue;
        if(!(0<=p.w && p.h<W))continue;
        if(dist[p.h][p.w] != 1e10 )continue;
        //if(!(s[p.h][p.w] == '#' && p.prev == '.')){
        dist[p.h][p.w] = p.cost.first;
        //}else{
            //dist[p.h][p.w] = ++p.cost;
        //}
        rep(i,2){
            obj q;
            q.h = p.h + y[i];
            q.w = p.w + x[i];
            if(!(0<=q.h && q.h<H))continue;
            if(!(0<=q.w && q.h<W))continue;
            if(s[p.h][p.w] == '.' && s[q.h][q.w] == '#'){
                q.cost.first = p.cost.first + 1;
            }else{
                q.cost.first = p.cost.first;
            }
            //q.cost = p.cost;
            q.prev = s[p.h][p.w];
            que.push(q);
        }
    }
    cout << max(dist[H-1][W-1],ll(0)) << endl;
    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
#define pii pair<int,int>
#define ff first
#define ss second

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int MAX = 1e5+10, MOD = 1e9+7;
int isp[MAX],phi[MAX];
vector<int> prime;

int n,k;

int exp(int a, int b){
	int res = 1;
	while(b){
		if (b&1) res = (res*a)%MOD;
		b>>=1;
		a = (a*a)%MOD;
	}
	return res;
}

void linear_sieve(){
	fill(isp,isp+MAX,1);
	isp[1] = 0;
	phi[1] = 1;
	for(int i=2;i<MAX;i++){
		if (isp[i]){
			prime.emplace_back(i);
			phi[i] = -1;
		}
		for(int j=0;j<prime.size() && i*prime[j]<MAX; j++){
			isp[i*prime[j]] = 0;
			if (i%prime[j]!= 0) phi[i*prime[j]] = phi[i] * phi[prime[j]];
			else{
				phi[i*prime[j]] = 0;
				break;
			}
		}
	}
}
signed main(){

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




	cin>>n>>k;
	linear_sieve();
	int ans = 0;

	for(int i=1;i<=k;i++){
		for(int j = 1; j<= k/i;j++){
			ans = (ans + i*phi[j]*exp(k/(i*j),n) + MOD)%MOD;

		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5356