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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007; 
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}

int main(){
  vll dp(31, 0);
  dp.at(0) = 1;
  rep(i, 0, 30){
    rep(j, i + 1, min(30, i + 3) + 1){
      dp.at(j) += dp.at(i);
    }
  }
  
  while(true){
    ll n;
    cin >> n;
    if(n == 0) break;
    cout << (dp.at(n) + 3649) / 3650 << endl; 
  }
}


Measured memory_bytes: 3004
m,k=map(int,input().split())
if m==1 and k==0:
    a=[0,0,1,1]
    print(*a)
    exit()
elif m==1 and k==1:
    print(-1)
    exit()
if k<=2**m-1:
    ans=[]
    for i in range(2**(m)):
        if i!=k:
            ans.append(i)
    ans.append(k)
    for i in range(2**m-1,-1,-1):
        if i!=k:
            ans.append(i)
    ans.append(k)
    print(*ans)
else:
    print(-1)


Measured memory_bytes: 59396
#include<stdio.h>
int main(){
	int i,y,N,A,B,C,X,Y[103],count;
	for(;scanf("%d %d %d %d %d",&N,&A,&B,&C,&X)&&(N||A||B||C||X);){
		count=0;
		for(i=0;i<N;i++){
			scanf("%d",&y);
			for(;;){
				if(count>10000){
					count++;
					break;
				}
				if(X==y){
					count++;
					X=(A*X+B)%C;
					break;
				}
				count++;
				X=(A*X+B)%C;
			}
		}
		if(count>10001)printf("-1\n");
		else printf("%d\n",count-1);
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;

#define i64 long long int

int n;
priority_queue<int> lq, rq;

int main() {
	scanf("%d", &n);
	
	while(lq.size()>0) lq.pop();
	while(rq.size()>0) rq.pop();
	i64 s = 0, lef_sum = 0, rig_sum = 0;
	for(int i=0;i<n;i++) {
		int op; scanf("%d", &op);
		if(op==1) {
			int a, b; scanf("%d%d", &a, &b);
			s+=b;
			
			int ls = lq.size(), rs = rq.size();
			if(ls==0) {
				lq.push(a);
			} else {
				int lma = lq.top(); 
				if (a>lma) {
					rig_sum += a-lma;
					rq.push(-a);
				} else {
					lef_sum += lma-a;
					lq.push(a);
				}
			}
			
			if(lq.size() > rq.size()+1) {
				int rmi = lq.top(); lq.pop();
				int lma = lq.top();
				lef_sum -= (rmi-lma)*lq.size();
				rq.push(-rmi);
				rig_sum += (rmi-lma)*rq.size();
			}
			if (lq.size() < rq.size()) {
				int lma = lq.top(), rmi = -rq.top();
				rq.pop();lq.push(rmi);
				
				lef_sum += (rmi-lma)*(lq.size()-1);
				rig_sum -= (rmi-lma)*(rq.size()+1);
			}
		} else {
			int x = lq.top();
			printf("%d %lld\n", x, lef_sum + rig_sum + s);
			//printf("%d %lld - l: %lld, r: %lld\n", x, lef_sum + rig_sum + s, lef_sum, rig_sum);
		}
	}
	
	return 0;
}

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

namespace AtCoderPre
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int K = N[0];
            int X = N[1];

            var result = new int[2 * K - 1];
            for (int i = 0; i < 2 * K - 1; i++)
                result[i] = X - K + 1 + i;

            Console.WriteLine(string.Join(" ", result));

            
        }

    }
}

Measured memory_bytes: 13268
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader bf =new BufferedReader(new InputStreamReader(System.in));
		String t;
		int c=0,h=0;
		int[] p = new int[5];
		while((t=bf.readLine())!=null){
			String[] d=t.split(",");
			for(int i=0;i<3;i++)p[i]=Integer.parseInt(d[i]);
			p[3]=p[0]*p[0]+p[1]*p[1];p[4]=p[2]*p[2];
			if(p[3]==p[4])c++;
			if(p[0]==p[1])h++;
		}
		System.out.println(c);
		System.out.println(h);
	}
}

Measured memory_bytes: 9188
using System;

class Program
{
    public static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i <= n/4;i ++) {
            for (int j = 0; j <= n/4-i; j ++) {
                if (i*4 + j*7 == n) {
                    Console.WriteLine("Yes");
                    return;
                }
                if (i == n/4) {
                    Console.WriteLine("No");
                    return;
                }
            }
        }
    }
}

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

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    vector<ll> A(5);
    for(int i=0;i<5;i++) cin >> A[i];
    sort(A.begin(),A.end());
    ll min_digit=INF;
    ll ans=0;
    for(int i=0;i<5;i++){
        ll time=0;
        for(int j=0;j<=13;j++){
            if(time>=A[i]) break;
            time+=10;
        }
        ans+=time;
        ll tmp=A[i];
        ll last_digit;
        last_digit=tmp%10;
        if(last_digit==0) last_digit=10;
        min_digit=min(min_digit,last_digit);
   }
   ans-=10-min_digit;
   cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int R;
  cin>>R;
  if(R<1200)
    cout<<"ABC"<<endl;
  else if(R>=2800)
    cout<<"AGC"<<endl;
  else{
    cout<<"ARC"<<endl;
  }
}

Measured memory_bytes: 3632
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
static const int MOD = 10000007;

int N;

int keta(int n) {
  return floor( (double)(log((double) n) / log(10.0) ) ) + 1;
}

int pow10(int k) {
  return (int)pow(10.0, k);
}

int main() {
  cin >> N;
  int k;
  k = keta(N);
  // cout << k << endl;
  int sum = 0;
  if (k%2 == 1) {
    sum += N - pow10(k-1) + 1;
    int s = k - 2;
    while (s > 0) {
      sum += pow10(s) - pow10(s-1);
      s = s - 2;
    }
  } else {
    int s = k - 1;
    while (s > 0) {
      sum += pow10(s) - pow10(s-1);
      // printf("%d %d\n", pow10(s), s);
      s = s - 2;
    }
  }

  cout << sum << endl;

}


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

namespace ABC131
{
	class Program
	{
		static void Main(string[] args)
		{
			char[] input = Console.ReadLine().ToCharArray();
			char mem = input[0];
			string output = "";
			for(int i = 1; i < 4; i++)
			{
				if(mem == input[i])
				{
					output = "Bad";
					break;
				}
				mem = input[i];
				output = "Good";
			}
			Console.WriteLine(output);
		}
	}
}


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

int main(){
  int n[10000],s[10000],N,S,cnt=0;
  cin>>N;
  for(int i=0;i<N;i++)cin>>n[i];
  cin>>S;
  for(int i=0;i<S;i++) cin>>s[i];
  for(int i=0;i<S;i++)
    for(int j=0;j<N;j++) if(n[j]==s[i]){
 cnt++;
 break;
      }

  cout<<cnt<<endl;
  return 0;
}

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

int main() {
	string in, out="";
	
	cin>>in;
	
	for(const char& u: in){
		if(u=='0' | u=='1') out+=u;
		else if (out.size()>0) out.pop_back();
		
	}
	cout<<out;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

double dp[3001][3001];
int N;
double p[3001];

int main(void) {
    cin>>N;

    for(int i = 0;i < N;i++)
        cin>>p[i];

    dp[0][0] = 1.0;
    for(int i = 0;i < N;i++) {
        for(int j = 0;j <= i;j++) {
            dp[i+1][j+1] +=dp[i][j]*p[i];
            dp[i+1][j] += dp[i][j]*(1-p[i]);
        }
    }

    double ans = 0.0;
    for(int i = N;i > N/2;i--)
        ans += dp[N][i];

    printf("%.10f\n",ans);

    return 0;
}





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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(' ');
                int c1 = int.Parse(temp[0]);
                int c2 = int.Parse(temp[1]);
                int c3 = int.Parse(temp[2]);

                bool[] memo = new bool[11];
                memo[c1] = memo[c2] = memo[c3] = true;

                bool flg = true;

                int limit = 20 - (c1 + c2);
                int count = 0;

                if (limit < 5)
                {
                    for (int i = 1; i <= limit; i++)
                    {
                        if (!memo[i]) count++;
                    }

                    flg = count >= 4 ? true : false;
                }

                sb.AppendLine(flg ? "YES" : "NO");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 8884
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int main(){
  int a,b,c,x;cin >> a >> b >> c >> x;
  int ans = 0;
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        if(500*i+100*j+50*k==x) ans++;
      }
    }
  }
  cout << ans << endl;
}


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

const int MAXN = 100010;
typedef long long LL;
int n, X[MAXN], S;
LL ans = 0, P[MAXN];
int lst = -1;
inline int absx(int x) { return x < 0 ? -x : x; }
void add(int x) {
	if (lst != -1) ans += absx(lst - x);
	lst = x;
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> S;
	for (int i = 1; i <= n; ++i)
		std::cin >> X[i] >> P[i];
	int lcur = 1, rcur = n;
	while (X[lcur] <= S && S <= X[rcur]) {
		if (P[lcur] >= P[rcur]) {
			P[lcur] += P[rcur];
			add(X[rcur--]);
		} else {
			P[rcur] += P[lcur];
			add(X[lcur++]);
		}
	}
	if (X[lcur] <= S) for (int i = lcur; i <= rcur; ++i) add(X[i]);
	else for (int i = rcur; i >= lcur; --i) add(X[i]);
	add(S);
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  int a;
  cin>>a;
  int ans=1e6;
  for(int i=0;;i++){
    ans=min(ans,abs(753-a%1000));
    a/=10;
    if(a<100)break;
  }
  cout<<ans<<endl;
}


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

#define ll long long
#define pii pair <int, int>
#define fi first
#define se second
#define N 60
int n, tot;
pii a[N];
map <pii, int> mp;
vector < vector <int> > G;
int vis[N];
void DFS(int u, int fa) {
	vis[u] = 1;
	for (auto v : G[u]) if (v != fa) {
		DFS(v, u);
	}
}

int main() {
	while (scanf("%d", &n) != EOF) {
		mp.clear();
		for (int i = 1; i <= n; ++i) {
			scanf("%d%d", &a[i].fi, &a[i].se);
			mp[a[i]] = i;
		}
		vector <pii> vec;
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= n; ++j) if (i != j) {
				vec.push_back(pii(a[i].fi - a[j].fi, a[i].se - a[j].se));
			}
		}	
		sort(vec.begin(), vec.end());
		vec.erase(unique(vec.begin(), vec.end()), vec.end());
		int res = 1e9;
	    if (n == 1) {
			res = 1;
		}	
		for (auto it : vec) {
			G.clear(); G.resize(n + 1);
			memset(vis, 0, sizeof vis);
			tot = 0;
			int p = it.fi, q = it.se;
			for (int i = 1; i <= n; ++i) { 
				int x = a[i].fi, y = a[i].se;
				if (mp.find(pii(1ll * x - p, 1ll * y - q)) != mp.end()) {
					G[i].push_back(mp[pii(1ll * x - p, 1ll * y - q)]);
					G[mp[pii(1ll * x - p, 1ll * y - q)]].push_back(i);
				}
			}	
			for (int i = 1; i <= n; ++i) {
				if (!vis[i]) {
					++tot;
					DFS(i, i);
				}
			}
			res = min(res, tot);
		}
		printf("%d\n", res);
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b,i,count=0;
  scanf("%d %d",&a,&b);
  
  for(i=a;i<=b;i++){
    if( (i/10000==i%10) && (i%10000/1000==i%100/10) ) count++;
  }
  printf("%d",count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 1e9;

signed main() {
    int N;
    cin >> N;
    ll zero = 0, ans = 0;
    vector<pair<ll, ll>> input;
    for (int i = 0; i < N; i++) {
        ll A, B;
        cin >> A >> B;
        zero += A == B;
        if (A > B) input.emplace_back(A, B);
        ans += A;
    }
    auto sorting = [](pair<ll, ll> a, pair<ll, ll> b) {
        return a.second < b.second;
    };
    sort(input.begin(), input.end(), sorting);
    cout << (zero == N ? 0 : ans - input[0].second) << endl;
}

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

const int INF = -100;
int k, r, c;
int a[8] = { INF, INF, INF, INF, INF, INF, INF, INF };
bool b[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };

bool check() {
	for (int i = 0; i < 7; i++) {
		for (int j = i + 1; j < 8; j++)
			if (a[i] == a[j] || j - i == abs(a[i] - a[j]))
				return false;
	}
	return true;
}

void set(int i) {
	if (i == 8) {
		if (check()) {
			for (int i = 0; i < 8; i++) {
				for (int j = 0; j < 8; j++) {
					if (a[i] == j)
						cout << "Q";
					else
						cout << ".";
				}
				cout << endl;
			}
		}
		return;
	}

	if (b[i])
		set(i + 1);
	else {
		for (int j = 0; j < 8; j++) {
			a[i] = j;
			set(i + 1);
		}
	}
}

int main()
{
	cin >> k;

	for (int i = 0; i < k; i++) {
		cin >> r >> c;
		a[r] = c;
		b[r] = 1;
	}

	set(0);

	return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, x;
  while (cin >> n >> x) {
    vector<int> v(n);
    cin >> v;
    sort(v.begin(), v.end());
    x -= accumulate(v.begin(), v.end(), 0);
    cout << n + x / v[0] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
s=input()
x,y=map(int,input().split())
A=s.split("T")
X_move,Y_move=[],[]
for i in range(len(A)):
    t=len(A[i])
    if i%2:
        Y_move.append(t)
    else:
        X_move.append(t)
x-=X_move.pop(0)
X_move.sort(reverse=True)
Y_move.sort(reverse=True)
now_x,now_y=0,0
for k in X_move:
    if x>=now_x:
        now_x+=k
    else:
        now_x-=k
for k in Y_move:
    if y>=now_y:
        now_y+=k
    else:
        now_y-=k
print('Yes' if now_x==x and now_y==y else 'No')

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int mod = 1_000_000_007;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        long ans = 0L;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if(a[i] > a[j]){
                    if(i < j){
                        ans = (ans + k * (k+1) /2) % mod;
                    }else if(j < i){
                        ans = (ans + k * (k-1) /2) % mod;
                    }
                }
            }
        }
        System.out.println(ans);
        sc.close();

    }
}

Measured memory_bytes: 26036
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ret = 3;
            if (r[0] == r[1]) ret--;
            if (r[1] == r[2]) ret--;
            if (r[0] == r[2]) ret--;
            if (ret == 0)
            {
                ret++;
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;

int D[100010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> D[i];
	if (D[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	sort(D, D + N);
	ll ans = 1;
	int before = 1;
	int cnt = 0;
	for (int i = 1; i < N; i++) {
		cnt++;
		if (D[i] == 0 || D[i] - D[i - 1] > 1) {
			cout << 0 << endl;
			return 0;
		}
		if (D[i] != D[i + 1]) {
			for (int j = 0; j < cnt; j++) {
				ans = (ans * before) % MOD;
			}
			before = cnt;
			cnt = 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int A, B, m;
    cin >> A >> B >> m;
    
    vector<int> a(A), b(B);
    REP(i, A) cin >> a[i];
    REP(i, B) cin >> b[i];

    vector<int> x(m), y(m), c(m);
    for(int i = 0; i < m; i++) {
        cin >> x[i] >> y[i] >> c[i];
        x[i]--;
        y[i]--;        
    }

    int min_a = inf, min_b = inf;
    REP(i, A) chmin(min_a, a[i]);
    REP(i, B) chmin(min_b, b[i]);

    int ans = min_a+min_b;
    
    REP(i, m) {
        chmin(ans, a[x[i]]+b[y[i]]-c[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<unordered_map>
#include<map>
#include<string>
#include<cstring>
#include<stack>
#include<cmath>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 100000
#define M 1e18

using namespace std;

int main() {
	int n;
	ll a, b, c;
	sfd(n);
	sfll(a);
	for( int i=1; i<n; i++ ) {
		sfll(b);
		c = __gcd(a, b);
		a = a/c*b;
	}
	pfll(a);

	return 0;
}

Measured memory_bytes: 256
#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;

int main(){
   ll n,a,b;
   cin>>n>>a>>b;
   cout<<max((n-2)*b-(n-2)*a+1,(ll)0)<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a;
    cin>>a;
    if(a<1200){
        cout<<"ABC";
    }
    else if(a<2800){
        cout<<"ARC";
    }
    else if(a>=2800){
        cout<<"AGC";
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Yes(bool Yes){cout << (Yes ? "Yes" : "No") << endl;};
void YES(bool YES){cout << (YES ? "YES" : "NO") << endl;};


int main(){
    
    ll A, B;
    cin >> A >> B;
    if(A == B)cout << "Draw" << endl;
    else if(A == 1 || (A > B && B != 1))cout << "Alice" << endl;
    else cout << "Bob" << endl;

    return 0;
}


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

int main(){

    int n, w, h; cin >> n >> w >> h;
    vector<pair<int, int> > p;     //{r, l}
    for(int i = 0; i < n; i++){
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'W') {
            p.push_back({x + y, -x + y});
        } else if(c == 'N') {
            p.push_back({2*h + x - y, x + y});
        } else if(c == 'E') {
            p.push_back({2*(h+w) - x - y, 2*h + x - y});
        } else {
            p.push_back({2*(h+w) - x + y ,2*(h+w) - x - y});
        }

        //if(p[i].first < 0) p[i].first += 2 * (h + w) - 1;
        //if(p[i].second < 0) p[i].second += 2 * (h + w) - 1;
        
    }

    
    sort(p.begin(), p.end());

    /*for(int i = 0; i < p.size(); i++){
        cout << "(" << p[i].first << ", " << p[i].second << ")" << endl;
    }*/

    //スタート位置でループ
    int ans = n;
    int L = 2*(w + h);
    for(int i=0; i<n; ++i) {
        vector<pair<int, int> > tmp;
        tmp = p;
        for(int j=i-1; j>=0; --j) {
            if(tmp[j].first < tmp[i].first) {
                tmp[j].first += L;
                tmp[j].second += L;
            }
        }
        sort(tmp.begin(), tmp.end());
        int cnt = 1;
        int now = tmp[0].first;
        for(int j=0; j<n; ++j) {
            if(tmp[j].second > now) {
                now = tmp[j].first;
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	long N;
	cin >> N;

	if( N&1 ) {
		cout << 0 << endl;
	}
	else {
		long ans = 0;
		for( long i = 10; i <= N; i *= 5 ) {
			ans += N/i;
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 200001
struct D{
	int a,b;
	bool operator<(D c)const{return b<c.b;}
}Q[M];
int n;
bool flag=1;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&Q[i].a,&Q[i].b);
		if(Q[i].b<Q[i].a)flag=0;
	}
	sort(Q+1,Q+n+1);
	int st=0;
	for(int i=1;i<=n;i++){
		st+=Q[i].a;
		if(st>Q[i].b){
			flag=0;
			break;
		}
	}
	puts(flag?"Yes":"No");
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
struct Point
{
	int x;
	int y;
	Point(int x = 0, int y = 0) :x(x), y(y) {}
};
const int MAX = 50;
int map[MAX][MAX];
bool book[MAX][MAX];
void depthFSearch(int h, int w, Point start)
{
	int next[9][2] = { { -1,-1 },{ -1,0 },{ -1,1 },{ 0,-1 },{ 0,0 },{ 0,1 },{ 1,-1 },{ 1,0 },{ 1,1 } };
	for (int k = 0; k <= 8; k++)
	{
		int nx = start.x + next[k][0];
		int ny = start.y + next[k][1];
		if (nx < 0 || nx >= h || ny < 0 || ny >= w || !map[nx][ny])
			continue;
		if (!book[nx][ny] && map[nx][ny])
		{
			book[nx][ny] = true;
			Point p = { nx,ny };
			depthFSearch(h, w, p);
		}
	}
	return;
}
int main()
{
	while (true)
	{
		int w, h;
		cin >> w >> h;
		if (!w && !h)
			break;
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
			{
				cin >> map[i][j];
				book[i][j] = false;
			}
		int sum = 0;
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
			{
				if (!book[i][j] && map[i][j])
				{
					book[i][j] = true;
					Point start(i, j);
					depthFSearch(h, w, start);
					sum++;
				}
			}
		cout << sum << endl;
	}
}


Measured memory_bytes: 3316
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        String[] line = new Scanner(System.in).nextLine().split(" ", 3);

        int num[] = new int[3];
        num[0] = Integer.parseInt(line[0]);
        num[1] = Integer.parseInt(line[1]);
        num[2] = Integer.parseInt(line[2]);
        Arrays.sort(num);

        if (num[0] == 5 && num[1] == 5 && num[2] == 7) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    int h,w;
    cin>>h>>w;
    int  block[60][60]={};

    rep2(i,h)rep2(k,w){
        char c;
        cin>>c;
        if(c=='#')block[i][k]=1;
    }
    string ans="Yes";
    rep2(i,h){
        rep2(k,w){
        if(block[i][k]){
            if(block[i-1][k]||block[i+1][k]||block[i][k-1]||block[i][k+1]){
                continue;
            }
            else{
                ans="No";
            }
        }
        }
    }
    cout<<ans<<endl;

    return 0;

}
/*


*/


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

using namespace std;

const int N = 1e5+1;
const int Z = 1e9+7;

int main() {
    string l;
    cin >> l;

    int pow3[l.length()];
    pow3[0] = 1;
    for (int i = 1; i < l.length(); i++) {
        pow3[i] = 1ll * pow3[i-1] * 3 % Z;
    }
    int pow2 = 1;

    int ans = 0;
    for (int i = 0; i < l.length(); i++) {
        if (l[i] == '1') {
            ans = (ans + 1ll * pow2 * pow3[l.length()-1-i]) % Z;
            pow2 = pow2 * 2 % Z;
        }
    }
    ans = (ans + pow2) % Z;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 896
N, X = map(int, input().split())
patty = [1]
buns = [0]

for i in range(0, N):
    patty.append(patty[i] * 2 + 1)
    buns.append(buns[i] * 2 + 2)


burger_high = patty[N] + buns[N]



def dfs(now_runrun, now_burger_high, dimension):
    if dimension == 0:
        return 1
    ## るんるんが一番下にいれば一つもパティは食べれない
    elif now_runrun == 1:
        return 0

    ## るんるんが真ん中にいたら、n - 1次元バーガー + 1を食べる
    elif now_runrun == now_burger_high // 2 + 1:
        return patty[dimension - 1] + 1

    ## るんるんが一番上にいたら全てのパティを食べる
    elif now_runrun == now_burger_high:
        return patty[dimension]


    next_burger = now_burger_high // 2 - 1
    next_dimension = dimension - 1

    if now_runrun <= now_burger_high // 2:
        return dfs(now_runrun - 1, next_burger, next_dimension)
    else:
        return dfs(now_runrun - (patty[next_dimension] + buns[next_dimension] + 2),
                   next_burger, next_dimension) + patty[next_dimension] + 1


print(dfs(X, burger_high, N))


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
ll MOD = ll(1e8) + 9;

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


void solve(){
    int N, M, K;
    cin >> N >> M >> K;

    vector<int> nblock(N, 0);
    vector<int> nfriend(N, 0);
    vector<int> nfriendunion(N, 0);

    UnionFind tree(N);
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        tree.unite(A-1, B-1);
        nfriend[A-1]++;
        nfriend[B-1]++;
    }

    for (int i = 0; i < N; i++) {
        nfriendunion[tree.root(i)]++;
    }

    vector<int> ans(N);
    for (int i = 0; i < N; i++) {
        ans[i] = nfriendunion[tree.root(i)] - 1 - nfriend[i];
    }

    for (int i = 0; i < K; i++) {
        int A, B;
        cin >> A >> B;
        if (tree.same(A-1, B-1)) {
            ans[A-1]--;
            ans[B-1]--;
        }
    }


    for (int i = 0; i < N; i++) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;


    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  
  for (ll i = 0; i < k; i++) {
    vector<ll> cnt(n, 0);
    for (ll j = 0; j < n; j++) {
      cnt[max(0ll, j - a[j])]++;
      if (j + a[j] + 1 < n) cnt[j + a[j] + 1]--;
    }
    for (ll j = 1; j < n; j++) {
      cnt[j] += cnt[j - 1];
    }
    a = cnt;
    
    bool flag = true;
    for (ll j = 0; j < n; j++) {
      if (a[j] != n) {
        flag = false;
        break;
      }
    }
    if (flag) break;
  }
  
  for (ll i = 0; i < n - 1; i++) cout << a[i] << " ";
  cout << a.back() << endl;
}

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

int main(){
      int n;cin >> n;
      int m;cin >> m;
      int c;cin >> c;
      int arrb[m + 10];
      for(int i = 0;i < m;i++)cin >> arrb[i];
      int ans = 0;
      for(int i = 0;i < n;i++){
            int sum = 0;
            for(int j = 0;j < m;j++){
                  int t;cin >> t;
                  sum += t * arrb[j];
            }
            sum += c;
            if(sum > 0)ans++;
      }
      cout << ans;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

vll binary_convert(ll n){
    vll s;
    ll size = 0;

    while(n / (ll)(pow(2,size)) > 0)size++;
    rep(i,size + 1){
        s.pb(n / (ll)(pow(2,i)));
        n %= (ll)(pow(2,i));
    }

    return s;
}

ll fib(ll n){
    vll a(n+1);
    a[0] = 1;
    a[1]  = 1;

    REP(i,2,n+1){
        a[i] = a[i-1] + a[i-2];
        a[i] %= mod;
    }

    return a[n-1];
}

int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    ll tmp1 = b/c - a/c;
    ll tmp2 = b/d - a/d;
    ll tmp3 = b/lcm(c,d) - a/(lcm(c,d));

    ll tmp4 = tmp1 + tmp2 - tmp3;
    if(a % c == 0)tmp4++;

    cout << b - a  - tmp4 + 1 << endl;
    return 0;
}

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

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    int s,w;cin>>s>>w;
    if(w<s) cout<<"safe"<<endl;
    else cout<<"unsafe"<<endl;



    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace AtCoderBeginnerContest179
{
    class Program
    {
        static void Main(string[] args)
        {
            // 課題A - Plural Form(2020/9/19)

            string str = Console.ReadLine();

            //List<string[]> iptList = new List<string[]>();
            //var valueDict = new Dictionary<string, int>();

            //for (int i = 0; i < people; i++) iptList.Add(Console.ReadLine().Split(' '));

            int len = 1;

            string getStr;

            getStr = str.Substring(str.Length - len, len);

            if(getStr.Equals("s")) Console.Write(str + "es");
            else Console.Write(str + "s");

        }
    }
}


Measured memory_bytes: 25892
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair< int, pair<int, int> >
#define plpll pair< ll, pair<ll, ll> >

using namespace std;

int a[60];

int32_t main(){
    int n, sum = 0;
    cin >>n;
    for(int i = 0; i < n; i ++){
        cin >>a[i];
        sum += a[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i ++)
        ans += a[i]* (sum - a[i]);
    cout <<ans/ 2 <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            string s;
            cin >> s;
            int n = s.size(); 
            int dp[n+10] = {0};

            int cur = 0;
            for(int i = 0; i < n; i++)
            {
                dp[i+1] = ((dp[i]*10) + (s[i] - '0'))%2019;
            }

            // map<int,int> mp;
            vector<int> mp(2020,0);
            mp[0]++;
            cur = 0;
            int ans = 0;
            for(int i = 1; i <= n; i++)
            {
                cur = dp[i];
                ans += mp[cur];
                mp[cur]++;
                // cout << cur << endl;
                vector<int> temp(2020,0);
                for(int i = 0; i < 2019; i++)
                    temp[(i*10)%2019]+=mp[i];
                mp.clear();
                mp = temp; 
            }
            // cout << dp[9] - dp[4] << endl;
            cout << ans << endl;





           return 0;
        }
          

Measured memory_bytes: 5308
#include <iostream>
using namespace std;
  
int main() {
    int a,b;
    cin>>a>>b;
    if(a<b){
        cout<< "a < b"<<endl;
    }else if(a>b) {
        cout<<"a > b"<<endl;
    }else if(a==b){
        cout<<"a == b"<<endl;
    }
            
    return 0;
}    

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define ll long long
#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
using namespace std;

ll a[3],b[3];
ll c[4];
int main(){
        FOR(i,0,3){
                   cin >> a[i] >> b[i];
                   c[a[i]-1]++;
                   c[b[i]-1]++;
        }
        sort(c,c+4);
        //FOR(i,0,4) cout << c[i] << endl;
        if (c[0] == 1 && c[3] == 2) cout << "YES" << endl;
        else cout << "NO" << endl;
       
        return 0;
}


Measured memory_bytes: 256
import heapq


def main():
    N, M = list(map(int, input().split(' ')))
    S = input()
    # 最短手数のdpテーブルを作る
    T = S[::-1]  # ゴールから逆順にたどる（最後に逆にする）
    dp = [-1] * (N + 1)
    que = [0] * M
    for i, t in enumerate(T):
        if i == 0:
            dp[0] = 0
            continue
        if len(que) == 0:
            print(-1)
            return
        index = heapq.heappop(que)
        if t == '1':
            continue
        dp[i] = 1 + dp[index]
        while len(que) < M:
            heapq.heappush(que, i)
    dp.reverse()
    # 細切れに進んでいく
    path = list()
    target = dp[0] - 1
    cnt = 0
    for i in range(N + 1):
        if dp[i] != target:
            cnt += 1
        else:
            path.append(cnt)
            cnt = 1
            target -= 1
    print(' '.join(map(str, path)))


if __name__ == '__main__':
    main()


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

int main() {
	int N, a[100], min = 100, max = 0, outmin = 100000000;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (min > a[i]) min = a[i];
		if (max < a[i]) max = a[i];
	}
	for (int i = min; i <= max; i++) {
		int count = 0;
		for (int j = 0; j < N; j++) {
			int x = abs(a[j] - i);
			count += x * x;
		}
		if (outmin > count) outmin = count;
	}
	cout << outmin << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
 #define all(v) (v).begin(),(v).end()
 using ll = long long;
using Graph = vector<vector<int>>;
const int MAX = 510000;
const int MOD = 1000000007;
 const int NINE=1000000000;
 
 
int main(){
ll N;
  cin>>N;
string s;
  cin>>s;
  vector<ll>ab(26);
  ll t=1;
  rep(i,N){
  
    
    if(s[i]==s[i-1]) t++;
    else{
    ll k=s[i-1]-'a';
    ab[k]=ab[k]+t;
    t=1;
    }
    
  
  }
    ll k=s[N-1]-'a';
    ab[k]=ab[k]+t;
    
  ll ans=1;
  rep(i,26){
  ans=(ab[i]+1)*ans%1000000007;
  
  }
  cout<<ans-1;

  
  
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

struct Graph {
    struct Vertex { int n, v; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1, -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    void dfs(int i) {
        v[i].v = l;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (v[o.i].v >= 0) continue;
            dfs(o.i);
        }
    }
    void foo() {
        l = 0;
        for (int i = 0; i < n; i++) {
            if (v[i].v >= 0) continue;
            dfs(i);
            l++;
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m, l;
};

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

    int n, k[2];
    cin >> n >> k[0] >> k[1];

    Graph g[2] = { { n, k[0] * 2 }, { n, k[1] * 2 } };
    for (int j = 0; j < 2; j++) {
        for (int i = 0; i < k[j]; i++) {
            int a, b;
            cin >> a >> b;
            a--; b--;

            g[j].add_edge(a, b);
            g[j].add_edge(b, a);
        }
        g[j].foo();
    }

    map<pair<int, int>, int> mp;
    for (int i = 0; i < n; i++) {
        mp[{ g[0].v[i].v, g[1].v[i].v }]++;
    }
    for (int i = 0; i < n; i++) {
        cout << mp[{ g[0].v[i].v, g[1].v[i].v }] << " \n"[i == n - 1];
    }

    return 0;
}

Measured memory_bytes: 18176
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//
int main() {
	ll A, B,a,b ,N; cin >> N >> a >> b;
	if (a < b) {
		A = b;
		B = a;
	}
	else {
		A = a;
		B = b;
	}

	if ((A - B) % 2 == 0)cout << (A - B) / 2 << endl;
	else cout << min((2*N-A-B+1)/2,(A-1+B)/2) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
    int count[1200];
    char ch;
    while(scanf("%c",&ch) != EOF){
        if(ch >= 'a' && ch <= 'z'){
            count[ch - 'a']++;
        }
        else if(ch >= 'A' && ch <= 'Z'){
            count[ch - 'A']++;
        }
    }
    for(int j = 0;j < 26; j++){
        printf("%c : %d\n",j + 'a',count[j]);
    }
    return 0;
}


Measured memory_bytes: 2676
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int a,b,c;cin>>a>>b>>c;
    int val=c-a-b;
    if(val<=0)
    {
        cout<<"No";
        return 0;
    }


    val*=val;
    if(4*a*b<val)
        cout<<"Yes"<<endl;
    else
        cout<<"No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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

    ll ans = 0;
    if (k == 0) {
        ans = n * n;
        cout << ans << endl;
        return 0;
    }

    for (ll b = 1; b <= n; b++) {
        if (b - 1 < k) continue;
        ans += (b - k) * (n / b) + max(0LL, (n % b) - k + 1);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;
int main()
{
    int N, K;
    cin >> N >> K;

    vector<vector<int>> G(N);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ll ans = K;
    queue<P> que;
    que.push({0, 0});
    int deep = 0;
    while (!que.empty()) {
        int v = que.front().first, p = que.front().second;
        que.pop();
        ll cnt = 0;
        rep(i, G[v].size()) {
            if (G[v][i] == p) continue;
            que.push({G[v][i], v});
            cnt++;
        }
        int kind = K - 2;
        if (deep == 0) kind += 1;
        deep++;
        ll res = 1;
        rep(i, cnt) {
            res *= kind;
            res %= MOD;
            kind--;
        }
        ans *= res;
        ans %= MOD;
    }

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

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

int main(){
    long long N,H,W;
    cin >> N>>H>>W;

    vector< vector<long long> > arr;
	arr.resize(N);		// ()内の数字が要素数になる
	for( int i=0; i<N; i++ ){
		arr[i].resize(2);
	}

    for(int i=0;i<N;i++){
        for(int k=0;k<2;k++){
            cin >> arr[i][k];
        }
    }



    int cnt = 0;
    for(int i=0;i<N;i++){
        if(arr[i][0]>=H && arr[i][1]>=W){
            cnt++;
        }
//       cout << "------"<<endl;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256