akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(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 eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
double eps = 1e-8;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    ll a;
    cin >> a;
    string b;
    cin >> b;
    if(a == 0 || b == "0.00") {
        cout << 0 << endl;
        return 0;
    }
    b = b.substr(0,b.size()-3)+b.substr(b.size()-2);
    ll bb = stol(b);
    ll ans = a*bb;
    ans /= 100;
    cout << ans << endl;
}


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

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let mut k: i32 = iter.next().unwrap().parse().unwrap();

    for i in (1..20000).rev() {
        if a % i == 0 && b % i == 0 {
            k -= 1;
            if k == 0 {
                println!("{}", i);
                return;
            }
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  ll A,B,K;
  cin >> A >> B >> K;
  
  vll vk;
  erep(i,1,min(A,B)){
    if(A%i == 0 && B%i == 0){
      vk.pb(i);
    }
  }

  print(vk[vk.size()-K]);

 return 0;
}


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

int main() {
	int n,k;
	cin>>n>>k;
	int h[n];
	for(int i=0;i<n;i++){
	    cin>>h[i];
	}
	int ans[n]={0};
	for(int i=1;i<n;i++){
	    ans[i]=1000000000;
	}
	
	for(int i=1;i<n;i++){
	    if(i==1){
	        ans[i]=abs(h[0]-h[1]);
	    }else{
	        for(int j=0;j<k;j++){
	            if(i-j-1>=0){
	                ans[i]=min(ans[i],ans[i-j-1]+abs(h[i]-h[i-j-1]));
	            }
	            
	        }
	    }
	}
	cout<<ans[n-1]<<"\n";
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=32000+7;


int main()
{

	int n,x,t;
	scanf("%d%d%d",&n,&x,&t);
	int a=0,b=0;
	while(a<n)
		a+=x,b+=t;
	printf("%d\n",b);
}


Measured memory_bytes: 3660
#include <stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 1000000007
using namespace std;
//priority_queue
const ll Maxn=1e5;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}
bool cmp(double x,double y)
{
    return x>y;
}

int main()
{
    ios::sync_with_stdio(false);
   int a,b,c;
   cin>>a>>b>>c;
   cout<<min(a*b,c);
}


Measured memory_bytes: 256
/*input
2
0 5
-1 0
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
    ll ans=1;
    while(m){
        if(m%2){
            ans*=a;
            ans%=(mod);
        }
        a=(a*a)%(mod);
        m>>=1;
    }
    return ans;
}


void init(ll* a,ll n,ll val){
    for(ll i=0;i<n;i++)
        a[i]=val;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll t=1,i,j;
    ll n,a,b;
    cin>>n;
    map<pll,ll> mp;
    ll s=0;
    ll k=0;
    rep(i,0,n){
        cin>>a>>b;
        ll g=__gcd(a,b);
        if(g) a/=g,b/=g;
        if(a<0) a=-a,b=-b;
        if(a||b) mp[{a,b}]++;
        else k++;
    }
    ll ans=0;
    for(auto it : mp){
        a=it.F.F,b=it.F.S;
        ll k1=mp[{a,b}],k2=mp[{-b,a}]+mp[{b,-a}];
        ans=ans+((ans+1)*((power(2,k1,M)-1+power(2,k2,M)-1+M)%M))%M;
        ans%=M;
        mp[{a,b}]=0,mp[{-b,a}]=0,mp[{b,-a}]=0;
    }
    ans+=k%M;
    ans%=M;
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 47368
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;

int main(){
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	string s;
	A--;
	B--;
	C--;
	D--;
	cin >> s;
	int cnt = 0;
	int cnt2 = 0;
	bool f = true;
	bool f2 = false;
	if(C < D){
		for(int i = A;i <= C;i++){
			if(s[i] == '#')	cnt++;
			else cnt = 0;
			if(cnt >= 2)	f = false;
		}
		cnt = 0;
		for(int i = B;i <= D;i++){
			if(s[i] == '#')	cnt++;
			else 	cnt = 0;
			if(cnt >= 2)	f = false;
		}
		if(f)	cout << "Yes" << endl;
		else 	cout << "No" << endl;
	}else{
		for(int i = B-1;i <= D+1;i++){
			if(s[i] == '.'){
				cnt2++;
				cnt = 0;
			}else{
				cnt2 = 0;
				cnt++;
			}
			if(cnt >= 2)	f = false;
			if(cnt2 >= 3)	f2 = true;
		}
		cnt = 0;
		for(int i = A;i <= C;i++){
			if(s[i] == '#')	cnt++;
			else cnt = 0;
			if(cnt >= 2)	f = false;
		}
		if(f && f2)	cout << "Yes" << endl;
		else 	cout << "No" << endl;
	}
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int step_num;
    int check_height, next_height;
    int temp = 0;
    int ans = 0;
    
    cin >> step_num;
    cin >> check_height >> next_height;
    
    for(int i=0; i<step_num-1; i++){
        if(check_height >= next_height){
            temp++;
        }
        else{
            if(ans < temp)  ans = temp;
            temp = 0;
        }
        
        check_height = next_height;
        cin >> next_height;
    }
    
    if(ans < temp)  ans = temp;
    
    cout << ans << endl;
}

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

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

	int N;
	scanf("%d", &N);
	// printf("%d", N);

	vector<int> X(N);
	vector<int> Y(N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &X[i]);
		Y[i] = X[i];
	}

	sort(X.begin(), X.end());
	for (int i = 0; i < N; i++) {
		if (Y[i] <= X[N / 2 - 1]) {
			printf("%d\n", X[N / 2]);
		} else {
			printf("%d\n", X[N / 2 - 1]);
		}
	}
	return 0;
}

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

int main() {
  int d,n; cin>>d>>n;
  int ans=n;
  if (d==0) ans = n;
  else if (d==1) ans = n*100;
  else if (d==2) ans = n*100*100;
  if (n==100) ans += pow(100,d);
  cout << ans << endl;
  return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n, m, k;
    cin >> n >> m >> k;
    vector<Int> a(n + 1, 0), b(m + 1, 0);
    for (Int i = 0; i < (Int)n; i++) {
        cin >> a[i + 1];
    }
    for (Int i = 0; i < (Int)m; i++) {
        cin >> b[i + 1];
    }
    for (Int i = 0; i < (Int)n; i++) {
        a[i + 1] += a[i];
    }
    for (Int i = 0; i < (Int)m; i++) {
        b[i + 1] += b[i];
    }
    Int x = 0;
    for (Int i = 0; i < (Int)n + 1; i++) {
        if (a[i] <= k) x = i;
    }
    b.push_back(INF);
    //print(a[n] + b[m]);
    Int res = 0;
    for (Int i = x; i >= 0; i--) {
        Int c = upper_bound(all(b), k - a[i]) - b.begin();
        // print(i, c - 1);
        // print(a[i], b[c - 1]);
        res = max(res, i + c - 1);
    }
    print(res);
    return 0;
}

Measured memory_bytes: 8008
#include<stdio.h>
#define MAX 10000
#define NIL -1

 struct Node{
          int parent;
          int left;
          int right;
          };

 struct Node T[MAX];

 void Preorder(int u){
           if(u==NIL)return;
           printf(" %d",u);
           Preorder(T[u].left);
           Preorder(T[u].right);
           }

 void Inorder(int u){
           if(u==NIL)return;
           Inorder(T[u].left);
           printf(" %d",u);
           Inorder(T[u].right);
           }

 void Postorder(int u){
           if(u==NIL)return;
           Postorder(T[u].left);
           Postorder(T[u].right);
           printf(" %d",u);
           }

 int main(){
        int i,n,v,l,r,root;
        scanf("%d",&n);
        for(i=0;i<n;i++){T[i].parent=T[i].left=T[i].right=NIL;}
        for(i=0;i<n;i++){
                  scanf("%d%d%d",&v,&l,&r);
                  T[v].left=l;
                  T[v].right=r;
                  if(l!=NIL)T[l].parent=v;
                  if(r!=NIL)T[r].parent=v;
                  }
        for(i=0;i<n;i++){if(T[i].parent==NIL)root=i;}

       printf("Preorder\n");
       Preorder(root);
       printf("\n");
 
       printf("Inorder\n");
       Inorder(root);
       printf("\n");
 
       printf("Postorder\n");
       Postorder(root);
       printf("\n");

        return 0;
        }






Measured memory_bytes: 2100
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#define MP make_pair
using namespace std;
long long int sc[1001][1001],ssc[1001][1001];
char c[1001];
int main()
{
	int h, w, cnt = 0, ans = 0, n,kfc=0;
	int x, y;
	pair<int, int> p;
	queue< pair<int, int> > que;
	queue< pair<int, int> > que1;
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++)
	{
		scanf("%s", c);
		for (int j = 0; j < w; j++)
		{

			if (c[j] == '.')
				sc[i][j] = -1;
			else
				sc[i][j] = c[j] - 48;
		}
	}
	for (int i = 1; i < h; i++)
	{
		for (int j = 1; j < w; j++)
		{
			if (sc[i][j] != -1)
			{
				for (int a = i - 1; a < i + 2; a++)
				{
					for (int b = j - 1; b < j + 2; b++)
					{
						if (sc[a][b] == -1)ssc[i][j] ++;
					}
				}
				if (sc[i][j] <= ssc[i][j])
				{
					que.push(MP(i, j)); que1.push(MP(i, j));  kfc++;
				}
			}
		}
	}
	for (int i = 0; i < kfc; i++) {
		x = que.front().first;
		y = que.front().second;
		que.pop();
		que1.pop();
		sc[x][y] = -1; que.push(MP(x, y)); que1.push(MP(x, y));
	}
	while (!que.empty())
	{
		while (!que.empty())
		{
			x = que.front().first;
			y = que.front().second;
			que.pop();
			for (int a = -1; a < 2; a++)
			{
				ssc[x - 1][y + a]++;
				ssc[x + 1][y + a]++;
			}
			ssc[x][y - 1]++;
			ssc[x][y + 1]++;
		}
		n = que1.size();
		for (int i = 0; i < n; i++)
		{
			x = que1.front().first;
			y = que1.front().second;
			que1.pop();
			for (int a = -1; a < 2; a++)
			{
				if (sc[x - 1][y + a] <= ssc[x - 1][y + a] && sc[x - 1][y + a] != -1) {
					que.push(MP(x - 1, y + a)); que1.push(MP(x - 1, y + a)); sc[x - 1][y + a] = -1;
				}
				if (sc[x + 1][y + a] <= ssc[x + 1][y + a] && sc[x + 1][y + a] != -1) {
					que.push(MP(x + 1, y + a)); que1.push(MP(x + 1, y + a)); sc[x + 1][y + a] = -1;
				}
			}
			if (sc[x][y - 1] <= ssc[x][y - 1] && sc[x][y - 1] != -1) {
			que.push(MP(x, y - 1)); que1.push(MP(x, y - 1)); sc[x][y - 1] = -1;
			}
			if (sc[x][y + 1] <= ssc[x][y + 1] && sc[x][y + 1] != -1) {
				que.push(MP(x, y + 1)); que1.push(MP(x, y + 1)); sc[x][y + 1] = -1;
			}
		}
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 18852
n = int(input())
A = [0]*n
for i in range(n):
  a = int(input())
  A[i] = [ tuple(map(int, input().split())) for _ in range(a) ]
ans = 0
for i in range(2**n):
  P = [2]*n
  f = False
  for j in range(n):
    if i >> j & 1:
      if P[j] != 2 and P[j] ^ 1:
          f = True
          break
      P[j] = 1
      for x, y in A[j]:
        if P[x-1] != 2 and P[x-1] ^ y:
          f = True
          break
        P[x-1] = y
  if f:
    continue
  c = bin(i).count("1")
  if P.count(1) <= c:
    ans = max(ans, c)
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

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

    do {  
        cin >> a >> b >> c;
    } while ((a < 0 || a > 100) || (b < 0 || b > 100) || (c < 0 || c > 100));

    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return (0);
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int M = 1e9 + 7;
const int N = 1e5 + 100;
const int MAX = 1e9 + 1;
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
char mp[10][10];
int n, m;

bool in(int i, int j) {
    return i >= 0 && j >= 0 && i < n && j < m;
}

bool ok() {
    int cx = 0, cy = 0;
    while (!(cx == n - 1 && cy == m - 1)) {
        int rx = cx, ry = cy + 1;
        int dx = cx + 1, dy = cy;
        if (in(rx, ry)) {
            if (mp[rx][ry] == '#') {
                if (in(dx, dy) && mp[dx][dy] == '#')
                    return false;
                cx = rx, cy = ry;
            }
            else {
                if (!(in(dx, dy) && mp[dx][dy] == '#'))
                    return false;
                cx = dx, cy = dy;
            }
        }
        else {
            if (!(in(dx, dy) && mp[dx][dy] == '#'))
                return false;
            cx = dx, cy = dy;
        }
    }
    return true;

}

int main() {
    int i, j;
    cin >> n >> m;
    int cnt = 0;
    for (i = 0; i < n; ++i) {
        cin >> mp[i];
        for (j = 0; j < m; ++j)
            if (mp[i][j] == '#')
                ++cnt;
    }
    cout << (cnt == n + m - 1 && ok() ? "Possible\n" : "Impossible\n");
    return 0;
}


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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int katta(char a, char b){
    if(a == b)
        return 1;
    else
        return 0;
}

int main()
{
    long N, K;
    long R, S, P;
    string T;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    int r[100005], s[100005], p[100005];
    int ans = 0, index;
    REP(i, K){
        for(int j = 0; (j * K + i) < N; j++){
            if(j == 0){
                r[j] = R * katta(T[j*K+i], 's');
                s[j] = S * katta(T[j*K+i], 'p');
                p[j] = P * katta(T[j*K+i], 'r');
            }else{
                r[j] = R * katta(T[j*K+i], 's') + max(s[j-1], p[j-1]);
                s[j] = S * katta(T[j*K+i], 'p') + max(r[j-1], p[j-1]);
                p[j] = P * katta(T[j*K+i], 'r') + max(r[j-1], s[j-1]);
            }
        }
        if((N-i)%K == 0)
            index = (N-i)/K-1;
        else
            index = (N-i)/K;
        
        ans += max(max(r[index], s[index]), p[index]);
    }
    cout << ans << endl;
    return 0;
    
}



Measured memory_bytes: 1664
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}


void solve()
{
	int a,b;
	cin >> a >> b;
	for(int i = 1;i < 1001;i++)
	{
		int x = floor(i * 1.0 * 0.08);
		int y = floor(i * 1.0 * 0.1);
		if(x == a && y == b)
		{
			cout << i << ln;
			return;
		}
	}
	cout << -1 << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	clock_t start,stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for(int tc = 1;tc < t + 1;tc++) solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
constexpr int INF = 1001001001;
constexpr int DEBUG = 0;
using ll = long long;
using namespace std;
int main() {
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i] ;
    
    int Vmax = accumulate(v.begin(), v.end(), 0) + 1;
    vector<vector<ll>> dp(N+1, vector<ll>(Vmax+1, INF));
    rep(i, N+1) dp[i][0] = 0;
    rep(i, N) {
        rep(j, Vmax+1)
            dp[i+1][j] = dp[i][j];
        rep(j, Vmax+1) {
            if (dp[i][j] == INF)
                continue;
            dp[i+1][j+v[i]] = min(dp[i][j+v[i]], dp[i][j] + w[i]);
        }
    }
    
    if (DEBUG >= 1) {
        cout << " V:";
        rep(i, Vmax)
            cout << setw(2) << (i + 1) << " ";
        cout << endl;
        rep(i, N+1) {
            rep(j, Vmax+1) {
                string str = dp[i][j] != INF ? to_string(dp[i][j]) : "--";
                cout << setw(2) << str << " ";
            }
            cout << endl;
        }
    }
    
    int ans = 0;
    rep(i, Vmax) {
        if (dp[N][i] == INF || dp[N][i] > W)
            continue;
        ans = max(ans, i);
    }
    cout << ans<< endl;
    
    return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define inf ((float)(1e9))
using namespace std;
const int maxn=100;
int n,a[maxn],sum=0,pos=-1;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	float s=(float)sum/n,minn=inf;
	for(int i=0;i<n;i++)
		if(abs(a[i]-s)<minn)
		{
			minn=abs(a[i]-s);
			pos=i;
		}
	cout<<pos<<endl;
	return 0;
}

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

int main(){
    int n,l;
    scanf("%d%d", &n, &l);
    string arr[n];
    for(int i=0; i<n; i++){
        cin>>arr[i];
    }
    int x=n;
    while(x--){
        for(int i=0; i<n-1; i++){
            for(int j=0; j<l; j++){
                if(arr[i][j]<arr[i+1][j])
                    break;
                else if(arr[i][j]>arr[i+1][j]){
                    string aux=arr[i];
                    arr[i]=arr[i+1];
                    arr[i+1]=aux;
                    break;
                }
            }
        }
    }
    string nstr;
    for(int i=0; i<n; i++){
        nstr+=arr[i];
    }
    cout<<nstr;
return 0;
}


Measured memory_bytes: 256
(let* ((n (read))
       (m (read))
       (edges (make-array (1+ n) :element-type 'fixnum :initial-element 0)))
  (dotimes (i m t)
    (incf (elt edges (read)))
    (incf (elt edges (read))))
  (format t "~:[NO~;YES~]" (every #'evenp edges)))

Measured memory_bytes: 60772
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
  static string[] map;
  static int H;
  static int W;
        static void Main(string[] args)
        {
          //入力を受け取る
          var N = int.Parse(Console.ReadLine());
          var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          Console.WriteLine(a.Sum()-N);

        }
}


Measured memory_bytes: 13432
sx,sy,tx,ty=map(int,input().split())
print('U'*(ty-sy)+'R'*(tx-sx)+'D'*(ty-sy)+'L'*(tx-sx+1)+'U'*(ty-sy+1)+'R'*(tx-sx+1)+'D'+'R'+'D'*(ty-sy+1)+'L'*(tx-sx+1)+'U')

Measured memory_bytes: 61504
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
}
 int n;
 vi arr(3002);
 int dp[3002][3002];
 int memo(int s,int e)
 {
     if(s>e)
     return 0;
     if(s==e-1)
     return dp[s][e]=max(arr[s],arr[e]);
     if(s==e-2)
     {
         return dp[s][e]=max(arr[s]+min(arr[s+1],arr[e]),arr[e]+min(arr[s],arr[s+1]));
     }
     if(dp[s][e]!=-1)
     return dp[s][e];
     int x=arr[s]+min(memo(s+2,e),memo(s+1,e-1));
     int y=arr[e]+min(memo(s,e-2),memo(s+1,e-1));
     return dp[s][e]=max(x,y);
 }
int32_t main()
{
    c_p_c();
     
    cin>>n;
    
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    memset(dp,-1,sizeof(dp));
    int sum=accumulate(arr.begin(),arr.end(),0ll);
    //cout<<sum;
     
    cout<<-sum+2*memo(0,n-1);
    return 0;
}

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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int N;
  cin>>N;
  vector<int> a(N),b(N),c(N-1);
  rep(i,N)
    cin>>a[i];
  rep(i,N)
    cin>>b[i];
  rep(i,N-1)
    cin>>c[i];
  int answer=0;
  rep(i,N)
    answer+=b[i];
  rep(i,N-1){
    if(a[i+1]-a[i]==1)
      answer+=c[a[i]-1];
  }
  cout<<answer;


}

Measured memory_bytes: 256
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;
#define max(a,b,c) (max(a,max(b,c)))

const int INF=0x3f3f3f3f;
const int SIZE=1000005;

vector<pair<int,int> > mp[SIZE];
vector<int> path[SIZE];
bool vis[SIZE];
int par[SIZE],dist[SIZE*2],id[SIZE];
bool use[SIZE];

int getp(int a){
	if(par[a]==a) return a; else return par[a]=getp(par[a]);
}

void mer(int a,int b){
	par[getp(a)]=getp(b);
}

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int p,q,c;
		scanf("%d%d%d",&p,&q,&c);
		mp[c].push_back(make_pair(p,q));
	}
	int sz=n;
	for(int col=1;col<SIZE;col++){
		for(int i=0;i<mp[col].size();i++){
			int a=mp[col][i].first,b=mp[col][i].second;
			par[a]=a;
			par[b]=b;
			use[a]=use[b]=false;
			id[a]=id[b]=-1;
		}
		for(int i=0;i<mp[col].size();i++){
			mer(mp[col][i].first,mp[col][i].second);
		}
		for(int i=0;i<mp[col].size();i++){
			int a=mp[col][i].first,b=mp[col][i].second;
			if(!use[a]){
				int r=getp(a);
				use[a]=true;
				if(id[r]==-1) id[r]=++sz;
				path[a].push_back(id[r]);
				path[id[r]].push_back(a);
			}
			if(!use[b]){
				int r=getp(b);
				use[b]=true;
				if(id[r]==-1) id[r]=++sz;
				path[b].push_back(id[r]);
				path[id[r]].push_back(b);
			}
		}
	}
	memset(dist,-1,sizeof(dist));
	dist[1]=0;
	queue<int> que;
	que.push(1);
	while(!que.empty()){
		int d=que.front();
		que.pop();
		for(int i=0;i<path[d].size();i++){
			int to=path[d][i];
			if(dist[to]==-1){
				dist[to]=dist[d]+1;
				que.push(to);
			}
		}
	}
	int ans=dist[n];
	if(ans!=-1) ans/=2;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 75776
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n;
    cin >> n;
    set<string> st;
    rep(i,n){
        string s;
        cin >> s;
        st.insert(s);
    }

    auto ans = st.size();
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 19244
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,K = inpl()
aa = inpl()
cnts = [0]*2005

izyos = [0]*N

for i,a in enumerate(aa):
    izyos[i] = sum(cnts[a+1:])
    cnts[a] += 1

sums = [0]*N
for i,a in enumerate(aa):
    sums[i] = sum(cnts[a+1:])

ans = sum(izyos)*K+sum(sums)*((K-1)*K//2)%mod
ans %= mod
print(ans)


Measured memory_bytes: 44524
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int a;
    if(s == "000"){
      cout << 0 << endl;
    }else if(s == "100" || s == "010" || s == "001"){
      cout << 1 << endl;
    }else if(s == "101" || s == "110" || s == "011"){
      cout << 2 << endl;
    }else{
      cout << 3 << endl;
    }
    return 0;
}

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

int main() {
	int w, h, c, r, wt, ht;

	cin >> w >> h >> c;

	wt = w;
	ht = h;
	r = w % h;

	while(r > 0){
		wt = ht;
		ht = r;
		r = wt % ht;
	}

	cout << (w / ht) * (h / ht) * c << endl;

	return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 205;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, k, P, fac[MAXN], inv[MAXN];
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int binom(int x, int y) {
	if (y > x) return 0;
	else return 1ll * fac[x] * inv[y] % P * inv[x - y] % P;
}
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = 1ll * fac[i - 1] * i % P;
	inv[n] = power(fac[n], P - 2);
	for (int i = n - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1ll) % P;
}
int solve(int n, int k) {
	int ans = 0;
	for (int deg = 1; deg <= k && deg <= n - 2; deg++) {
		static int dp[MAXN][MAXN];
		if ((n - 1) - deg > k) continue;
		memset(dp, 0, sizeof(dp));
		dp[0][deg] = 1, dp[0][deg + 1] = P - 1;
		for (int i = 0; i <= deg - 1; i++)
		for (int j = deg; j <= n - 1; j++) {
			update(dp[i][j], dp[i][j - 1]);
			int tmp = dp[i][j], l = max(max(j, i + 2), n + i - k), r = min(n - 1, k + (i + 1));
			if (l <= r) update(dp[i + 1][l], tmp), update(dp[i + 1][r + 1], P - tmp);
		}
		for (int i = deg; i <= n - 1; i++) {
			update(dp[deg][i], dp[deg][i - 1]);
			update(ans, dp[deg][i]);
		}
	}
	return 1ll * ans * fac[n - 1] % P;
}
int main() {
	read(n), read(k), read(P);
	init(n); int ans = (k == n - 1) ? fac[n] : 0;
	for (int i = 3; i <= n; i++)
		update(ans, 1ll * fac[n] * inv[i] % P * solve(i, k - (n - i)) % P);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3800
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main(void) {
  int N, M, ans = 0;
  cin >> N >> M;
  vector<vector<bool> > g(N, vector<bool>(N, false));

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    g[a - 1][b - 1] = g[b - 1][a - 1] = 1;
  }

  vector<int> v(N);
  iota(v.begin(), v.end(), 1);

  do {
    //始点が1でない時
    if (v[0] != 1)
      continue;

    bool flag = true;
    for (int i = 1; i < N; i++) {
      if (!g[v[i - 1] - 1][v[i] - 1]) {
        flag = false;
        break;
      }
    }

    if (flag)
      ans++;

  } while (next_permutation(v.begin(), v.end()));

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

Measured memory_bytes: 256
L,R = map(int,input().split())
ans = 0
L_min = 10**10
L_ = L//2019
R_ = R//2019

if L_ == R_:
  ans = 10**10
  for i in range(L,R+1):
    for j in range(L,R+1):
      if i != j and ans > (i*j)%2019:
        ans = (i*j)%2019
  print(ans)
else:
  print(0)

Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
    int A , B,  multiply ;
    scanf("%d %d",&A,&B);
    multiply = A*B ;
    if (1<=A && A<=9 && 1<=B && B<=9){
        printf("%d\n",multiply);
    }
    else {
        printf("-1\n");
    }
    return 0;
}



Measured memory_bytes: 1732
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
const double pi = acos(-1.0);
const int N = 1e5+5;
const int inf = 0x3f3f3f3f;
int dis[N],pre[N];
bool vis[N];
struct node{
	int u,w;
	node(int x,int y):u(x),w(y){}
	bool operator < (const node &a)const
	{
		return w>a.w;
	}
};
vector<node>v[N];
void dijkstra(int st)
{
	fill(dis,dis+N,inf);
	fill(vis,vis+N,false);
	priority_queue<node>q;
	dis[st]=0;
	q.push(node(st,0));
	while(q.size())
	{
		node t=q.top();
		q.pop();
		int from=t.u;
		if(vis[from])continue;
		vis[from]=true;
		for(int i=0;i<v[from].size();i++)
		{
			int to=v[from][i].u;
			int w=v[from][i].w;
			if(!vis[to]&&dis[from]+w<dis[to])
			{
				dis[to]=dis[from]+w;
				q.push(node(to,dis[to]));
				pre[to]=from;
			}
		}
	}
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)pre[i]=i;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		v[x].push_back(node(y,1));
		v[y].push_back(node(x,1));
	}
	dijkstra(1);
	int f=0;
	for(int i=2;i<=n;i++)
	if(dis[i]==inf)
	{
		f=1;
		break;
	}
	if(f)cout<<"No"<<endl;
	else
	{
		cout<<"Yes"<<endl;
		for(int i=2;i<=n;i++)
		cout<<pre[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13776
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

#define MAX_N 100000

int par[MAX_N]; // 親の番号
int depth[MAX_N];
int nGroup[MAX_N];

// n要素で初期化
void init(int n){
  for(int i=0; i<n; i++){
    par[i] = i;
    depth[i] = 0;
    nGroup[i] = 1;
  }
}
// 木の根を求める
int root(int x){
  if(par[x] == x){ // 根
    return x;
  } else {
    return par[x] = root(par[x]); // 経路圧縮
  }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y){
  return root(x) == root(y);
}

// xとyの属する集合を併合
void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y) return;

  if(depth[x] < depth[y]){
    par[x] = y;
    nGroup[y] += nGroup[x];
    nGroup[x] = 0;
  } else {
    par[y] = x;
    nGroup[x] += nGroup[y];
    nGroup[y] = 0;
    if(depth[x] == depth[y])
      depth[x]++;
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  init(N);
  for(int i=0; i<M; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--;  y--;
    unite(x, y);
  }
  int ans = 0;
  for(int i=0; i<N; i++)
    if(nGroup[i] != 0)
      ans++;
  cout << ans << endl;
  return 0;
}


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

int main() {
	string S;
	cin >> S;
	int N = S.size();
	vector<bitset<10>> v;

	for(int tmp=0;tmp < (1 << (N - 1));tmp++){
		bitset<10> bits(tmp);
		v.push_back(bits);
	}

	long long ans=0;
	string tmp;

	for(int i=0;i<(1 << (N - 1));i++){
		for(int j=0; j<N; j++){
			tmp.push_back(S.at(j));
			if(v.at(i).test(j)){
				ans += stoll(tmp);
				tmp = "";
			}
		}
		if(!(tmp == "")){
			ans += stoll(tmp);
			tmp = "";
		}
	}

	cout << ans << endl;
}


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

vector<int> checker1(int A, int B, vector<string> vec){
  vector<int> res(0);
  for (int i = 0; i < A; i++){
    int counter = 0;
    for (int j = 0; j < B; j++){
      if (vec.at(i).at(j) == '#')
        counter++;
    }
    if (counter != 0)
      res.push_back(i);
  }
  return res;
}
vector<int> checker2(int A, int B, vector<string> vec){
  vector<int> res(0);
  for (int i = 0; i < A; i++){
    int counter = 0;
    for (int j = 0; j < B; j++){
      if (vec.at(j).at(i) == '#')
        counter++;
    }
    if (counter != 0)
      res.push_back(i);
  }
  return res;
}
int main() {
  int H, W, a = 0;
  vector<int> row, column;
  cin >> H >> W;
  vector<string> vec(H);
  for (int i = 0; i < H; i++){
    cin >> vec.at(i);
  }
  row = checker1(H, W, vec);
  column = checker2(W, H, vec);
  for (double i = 0; i < row.size(); i++){
    for (double j = 0; j < column.size(); j++){
      cout << vec.at(row.at(i)).at(column.at(j));
      if (j == column.size() - 1)
        cout << endl;
    }
  }
}



Measured memory_bytes: 3652
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#define ls l, m, rt << 1 
#define rs m + 1, r, rt << 1 | 1

const int Maxv = 1000000, INF = 0x3f3f3f3f;
int imin[Maxv], dp[Maxv], cost[Maxv], n, q, cnt; 
std::vector<int> T[Maxv];

void build(int l, int r, int rt){
    if (l == r) {
        imin[rt] = INF;
        return;
    }
    int m = l + r >> 1;
    build(ls);
    build(rs);
    imin[rt] = std::min(imin[rt<<1], imin[rt << 1 | 1]);
}

int query(int L, int R, int l, int r, int rt){
    if(L <= l && r <= R) {
		return imin[rt];
	}
    int m = (l + r) >> 1, res = INF;
    if(L <= m) {
    	res = std::min(res, query(L, R, ls));	
	}
    if(R > m) {
    	res = std::min(res, query(L, R, rs));
	}
    return res;
}

void update(int pos, int val, int l, int r, int rt) {
    if (l == r) {
        imin[rt] = std::min(imin[rt], val);
        return;
    }
    int m = (l + r) >> 1;
    if (pos <= m) {
    	update(pos, val, ls);
	}
    else {
    	update(pos, val, rs);
	}
    imin[rt] = std::min(imin[rt << 1], imin[rt << 1 | 1]);
}

int main()
{
    scanf("%d",&n);
    build(1, n, 1);
    for(int i = 1, j; i <= n; i++) {
        scanf("%d", &j);
        cnt += !j;
        cost[i] = j ? 1 : -1;
    }
    scanf("%d", &q);
    for(int i = 0, j, k; i < q; i++) {
        scanf("%d%d", &j, &k);
        T[j].push_back(k);
    }
    memset(dp, INF, sizeof(dp));
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int k = 0; k < T[i].size(); k++) {
			int j = T[i][k]; 
            int mi = dp[i - 1];
            mi = std::min(mi, query(std::max(i - 1,1), j, 1, n, 1));
            if (mi < dp[j]) {
                dp[j] = mi;
                update(j, mi, 1, n, 1);
            }
        }
        dp[i] = std::min(dp[i], dp[i - 1] + cost[i]); 
    }
    printf("%d\n", dp[n] + cnt);
    return 0;
}


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

int main(){
    int N, s;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    s = 0;
    for (int i = 0; i < N; i++){
        cin >> b[i];
        s += b[i];
    }
    for (int i = 0; i < N - 1; i++) cin >> c[i];
    for (int i = 0; i < N - 1; i++){
        if (a[i] + 1 == a[i + 1]) s += c[a[i] - 1];
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int head[2005],nxt[4005],v[4005],tot=1;
int rs[2005],rt[2005],s[2005],t[2005],n,m;
int deg[2005],c[2005],cnt=0;
bool bl[2005],bv[2005];
bool g[2005][2005];
vector <int> p[2005];
inline void add(int a,int b)
{tot++;nxt[tot]=head[a];head[a]=tot;v[tot]=b;}
bool dfs(int pos,int f,int tar,int u)
{if (pos==tar) return 1;
for (int i=head[pos];i;i=nxt[i])
{if (v[i]==f) continue;
if (dfs(v[i],pos,tar,u))
{g[u][(i>>1)]=1;return 1;}
}
return 0;
}
inline bool rev(int id)
{int sz=p[id].size();swap(s[id],t[id]);
for (int i=0;i<sz;i++) swap(rs[p[id][i]],rt[p[id][i]]);
}
int main (){
	int i,j,a,b,ans=0;
	scanf ("%d%d",&n,&m);
	for (i=1;i<n;i++)
	{scanf ("%d%d",&a,&b);
	deg[a]++;deg[b]++;
	add(a,b);add(b,a);
	}
	for (i=1;i<=m;i++)
	{scanf ("%d%d",&s[i],&t[i]);
	dfs(s[i],0,t[i],i);
	rs[i]=s[i];rt[i]=t[i];
	p[i].pb(i);
	}
	for (i=1;i<n;i++)
	{int o=0;
	for (j=1;j<=m;j++)
	{if (g[j][i]) o++;
	if (o>=2) break;
	}
	ans+=o;
	}
	while (1)
	{int pos=-1,id=-1,nv;cnt=0;
	for (i=1;i<=n;i++)
	{if (bv[i]) continue;
	if (deg[i]==1) {pos=i;break;}
	}
	if (pos==-1) break;
	bv[pos]=1;
	for (i=head[pos];i;i=nxt[i])
	{if (bv[v[i]]) continue;
	id=(i>>1);nv=v[i];
	deg[v[i]]--;
	}
	for (i=1;i<=m;i++)
	{if (bl[i]) continue;
	if (g[i][id]) c[++cnt]=i;
	}
	if (cnt==0) continue;
	if (cnt==1)
	{if (s[c[1]]==pos) {s[c[1]]=nv;}
	else {t[c[1]]=nv;}
	g[c[1]][id]=0;
	if (s[c[1]]==t[c[1]]) bl[c[1]]=0;
	continue;
	}
	for (i=3;i<=cnt;i++)
	{if (s[c[i]]==pos) {s[c[i]]=nv;}
	else {t[c[i]]=nv;}
	g[c[i]][id]=0;
	}
	if (s[c[1]]!=pos) rev(c[1]);
	if (t[c[2]]!=pos) rev(c[2]);
	bl[c[1]]=1;
	int ns=s[c[2]],nt=t[c[1]],i,sz=p[c[1]].size();
	s[c[2]]=ns;t[c[2]]=nt;
	for (i=0;i<sz;i++) p[c[2]].pb(p[c[1]][i]);
	memset(g[c[2]],0,sizeof(g[c[2]]));
	dfs(ns,0,nt,c[2]);
	for (i=1;i<=m;i++)
	{if (bl[i]) continue;
	if (s[i]==t[i]) bl[i]=1;
	}
	}
	printf ("%d\n",ans);
	for (i=1;i<=m;i++) printf ("%d %d\n",rs[i],rt[i]);
	return 0;
}

Measured memory_bytes: 4352
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7

lcm = 1
for a in A:
    lcm = lcm * a // gcd(lcm,a)

ans = 0
for a in A:
    ans += lcm // a
ans %= MOD
print(ans)

Measured memory_bytes: 6112
#include<stdio.h>
#include<math.h>
#define A_MAX 100003
#define MAX 2147483647
int a[A_MAX];
int l[A_MAX];
int b,n;
 
int j_min(int, int);
int j_max(int, int);
void update(int);



 
int main(){
 
    int q,i,j,que,x,y,z;
     
    scanf("%d %d",&n,&q);
    b=sqrt(n);
     
    for(i=0;i<n;i++)a[i]=MAX;
    for(i=0;i<n;i++)l[i]=-1;
     
    for(j=0;j<q;j++){
     
        scanf("%d",&que);

        if(que){
            scanf("%d",&x);
            if(l[x/b]!=-1)update(x/b);
            printf("%d\n",a[x]);
        }
         
        else {
            scanf("%d %d %d",&x,&y,&z);
            if(l[x/b]!=-1)update(x/b);
            for(i=x;i<=j_min(y,(x/b+1)*b-1);i++)a[i]=z;
            for(i=x/b+1;i<y/b;i++)l[i]=z;
            if(l[y/b]!=-1)update(y/b);
            for(i=j_max(x,y/b*b);i<=y;i++)a[i]=z;
        }
         
    }
     
    return 0;
     
}

int j_min(int x,int y){
    if (x > y) return y;
    return x;   
}

int j_max(int x , int y){
    if ( x>y ) return x;
    return y;   
}


void update(int x){
    for(int i=x*b;i<=j_min(n-1,(x+1)*b-1);i++)a[i]=l[x];
    l[x]=-1;
    return;
}




Measured memory_bytes: 2628
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int n, a, b;
    vector<pair<int, int>> p;
    int ans = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        p.push_back(make_pair(a, b));
    }

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

    ans += p[0].first;
    ans += (p[n-1].first-p[0].first)+p[n-1].second;


    cout << ans << endl;
}


Measured memory_bytes: 1400
import sys

def to_i(e):
  return int(e)

def calc_gcd(a, b):
  if b > 0:
    return calc_gcd(b, a % b)
  else:
    return a

def calc_lcm(a, b):
  return ((a / calc_gcd(a, b)) * b)

while True:
  line = sys.stdin.readline()
  if not line: break
  a, b = map(to_i, line.rstrip().split(" "))
  gcd = calc_gcd(a, b)
  lcm = calc_lcm(a, b)
  print str(gcd) + " " + str(lcm)

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define Si size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define Em empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define Fi first
#define Se second
#define Pi acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>

void FAST();
LL big_mod(LL val,LL pow,LL mod);
LL mod_inverse(LL val,LL mod);







int a[100005];
int b[100005];
int c[100005];

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,n;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
        b[i]=__gcd(a[i],b[i-1]);
    }
    for(i=n;i>=1;i--)
    {
        c[i]=__gcd(a[i],c[i+1]);
    }
    int ans=0;
    for(i=1;i<=n;i++)
    {
        ans=max(ans,__gcd(b[i-1],c[i+1]));
    }
    cout << ans;
    return 0;
}







void FAST()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

LL big_mod(LL val,LL pow,LL mod)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)
        {
            res = (res*val) % mod;
        }
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

LL mod_inverse(LL val,LL mod)
{
    LL mod1 = mod;
    if(mod == 1)
    {
        return 0;
    }
    LL y = 0;
    LL x = 1;
    LL quotient,temp;
    while(val > 1)
    {
        quotient = val / mod;
        temp = mod;
        mod = val % mod;
        val = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }
    if(x < 0)
    {
        x += mod1;
    }
    return x;
}


Measured memory_bytes: 1408
let rec how_many_divisors i n z =
  if i > n then 0
  else if z mod i = 0 then 1 + (how_many_divisors (i + 1) n z)
  else how_many_divisors (i + 1) n z ;;

let f s = Scanf.sscanf s "%d %d %d" how_many_divisors ;;
print_endline (string_of_int (f(read_line()))) ;;


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

int main()
{
    int x,k=0,i,n,v[201];
    cin>>n;

   for(i=0;i<n;i++)
   {
       cin>>x;

       while(x%2==0)
       {
           x=x/2;
           k++;
       }

        v[i]=k;
        k=0;
   }

    sort(v,v+n);
    cout<<v[0];

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

void solve(istream& cin, ostream& cout) {
  int n, m;
  cin >> n >> m;
  priority_queue<int> que;
  ll ans = 0;
  REP(i, n) {
    int a;
    cin >> a;
    que.push(a);
    ans += a;
  }
  int j = 0;
  while (m > 0) {
    ll now = que.top();
    que.pop();
    ans -= now - now / 2;
    now /= 2;
    que.push(now);
    m--;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 1020
// Problem : C - Forbidden List
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
using namespace std;
int t[205];
int main()
{
 int x,n,d=200,ans=0;
 cin>>x>>n;
 for(int i=1;i<=n;i++)
 {
  int p;
  cin>>p;
  t[p]=1;
 }
 for(int i=0;i<=200;i++)
  if(!t[i]&&abs(i-x)<d)
  {
   ans=i;
   d=abs(i-x);
  }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 3636