akhauriyash/Code-Regression huggingface dataset:
import datetime

sum1 = 0
sum2 = 0
c = 0
try:
	while 1:
		s = raw_input().split(",")
		s[0] = int(s[0])
		s[1] = int(s[1])
		
		sum1 += s[0] * s[1]
		sum2 += s[1]
		c += 1
except:
	print(sum1)
	print(int(round(sum2 * 1.0 / c, 0)))
	exit()

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll X1,Y1,X2,Y2,X,Y;

ll go(ll a,ll b) {
	if(a<b) swap(a,b);
	ll g=__gcd(a,b);
	a/=g;
	b/=g;
	return g*(a+b-1);
	
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X1>>Y1>>X2>>Y2;
	X=abs(X2-X1);
	Y=abs(Y2-Y1);
	cout<<go(X,Y)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <math.h>
using namespace std;
int main() {
	long N;
  	string tmp;
  	cin >> N;
  
  	for(int i=0;i<N;i++){
      cin >> tmp;
      if(tmp=="Y"){
        cout << "Four" << endl;
		return 0;
      }
    }
  	cout << "Three" << endl;
	return 0;
}


Measured memory_bytes: 256
ary = gets.split(" ").map(&:to_i)

a = ary[0]
b = ary[1]
c = ary[2]
d = ary.last

if  d >= (a-c).abs 
        puts "Yes"
elsif d >= (a-b).abs and d >= (b-c).abs
    puts "Yes"
else
    puts "No"
end



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pic = pair<int,char>;

int main(){
    int n;
    cin >>n;

    vector<int> x(n),y(n);
    vector<char> d(n);

    vector<int> ux,uy;
    rep(i,n){
        cin >>x[i] >>y[i] >>d[i];
        ux.pb(x[i]);
        uy.pb(y[i]);
    }

    sort(all(ux));
    ux.erase(unique(all(ux)), ux.end());
    sort(all(uy));
    uy.erase(unique(all(uy)), uy.end());

    int X = ux.size(), Y = uy.size();

    rep(i,n){
        x[i] = lower_bound(all(ux), x[i]) - ux.begin();
        y[i] = lower_bound(all(uy), y[i]) - uy.begin();
    }

    int ans = 0;
    rep(i,n){
        // initialize
        vector<set<pic>> sx(X), sy(Y);
        rep(j,n){
            sx[x[j]].insert({y[j],d[j]});
            sy[y[j]].insert({x[j],d[j]});
        }

        int tmp = 0;
        int cx = x[i], cy = y[i];
        char cd = d[i];
        while(1){
            // remove current position
            sx[cx].erase({cy,cd});
            sy[cy].erase({cx,cd});
            ++tmp;

            if(cd == '>'){
                auto itr = sy[cy].lower_bound({cx,cd});
                if(itr == sy[cy].end()) break;

                cx = itr->fi;
                cd = itr->se;
            }
            else if(cd == '<'){
                auto itr = sy[cy].lower_bound({cx,cd});
                if(itr == sy[cy].begin()) break;
                --itr;
                cx = itr->fi;
                cd = itr->se;

            }
            else if(cd == 'v'){
                auto itr = sx[cx].lower_bound({cy,cd});
                if(itr == sx[cx].end()) break;

                cy = itr->fi;
                cd = itr->se;
            }
            else if(cd == '^'){
                auto itr = sx[cx].lower_bound({cy,cd});
                if(itr == sx[cx].begin()) break;
                --itr;
                cy = itr->fi;
                cd = itr->se;
            }
            else assert(false);
        }

        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3484
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];

  ll sw = -1;
  deque<ll> b;

  rep(i, n){
    if(sw == 1){
      b.push_back(a[i]);
    } else{
      b.push_front(a[i]);
    }
    sw = -sw;
  }

  if(sw == 1){
    rep(i, n){
      cout << b.front() << ' ';
      b.pop_front();
    }      
  } else{
    rep(i, n){
      cout << b.back() << ' ';
      b.pop_back();
    }    
  }
  
  return 0;
}


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

const double pi=acos(-1);
typedef long long ll;
const int maxn=1e4+10;
int  f[300050],vis[200050];
set<ll> si;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    ll k=1,state=0;
    while(n--){
        cin >> k;
        if(!state){
            if(!si.count(k))
                si.insert(k);
            else
                state=1;
        }
    }
    if(!state)
    cout << "YES";
    else
        cout << "NO";
    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

struct D{
	int l, r, d;
	bool operator < ( const D &right ) const {
		return r < right.r;
	}
};

int main(){
	int n;
	while(cin >> n,n){
		vector<D> d(n);
		rep(i,n){
			auto& p = d[i];
			cin >> p.l >> p.r >> p.d;
			p.l--; p.r--;
		}
		sort(all(d));

		vector<vector<int>> cur(400, vector<int>(400,0));
		rep(i,n){
			const auto& p = d[i];
			for (int j = 365; j >= 0; j--) {
				for (int k = 365; k >= 0; k--) {
					if(j <= p.l){
						cur[p.r + 1][k] = max(cur[p.r + 1][k], cur[j][k] + p.d);
					}
					if(k <= p.l){
						cur[j][p.r + 1] = max(cur[j][p.r + 1], cur[j][k] + p.d);
					}
				}
			}
		}

		int ans = 0;
		rep(i,400){
			rep(j,400){
				ans = max(ans, cur[i][j]);
			}
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;
 
class Data{
public:
  int mX;
  int mY;
  Data(int _x,int _y){
    mX = _x;
    mY = _y;
  }
  Data():mX(0),mY(0){}
};
 
Data path[100][100];
bool visited[100][100];
 
int main(){
 
  int W;
  while(~scanf("%d",&W)){
    if(W==0) break;
 
    memset(visited,0,sizeof(visited));
    for(int y=0;y<W;y++){
      for(int x=0;x<W;x++){
	int nx,ny;
	cin >> nx >> ny;
	path[y][x] = Data(nx,ny);
      }
    }
 
    int res = 0;
    for(int y=0;y<W;y++){
      for(int x=0;x<W;x++){
	if(visited[y][x]) continue;
 
	bool tmp[100][100];
	memcpy(tmp,visited,sizeof(bool)*100*100);
 
	int sx = x;
	int sy = y;
	tmp[sy][sx] = true;
 
	int nx = sx;
	int ny = sy;
	for(int i=0;i<=W*W;i++){
	  int prev_x = nx;
	  int prev_y = ny;
	  nx = path[prev_y][prev_x].mX;
	  ny = path[prev_y][prev_x].mY;
	  tmp[ny][nx] = true;
 
	  if(nx==sx && ny==sy){
	    res++;
	    memcpy(visited,tmp,sizeof(bool)*100*100);
	    break;
	  }
	}
      }
    }
 
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1344
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
bool isPalindrome(char str[]) 
{ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = strlen(str) - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
           return false;
        } 
    } 
    return true;
} 
  
void solve() {
	char s[201],a[201],b[201];
	cin >> s;
	int n = strlen(s);
	int i;
	for(i=0;i<=(n-3)/2;i++) {
		a[i]=s[i];
	}
	a[i]='\0';
	int j=0;
	for(i=(n+1)/2;i<n;i++) {
		b[j++]=s[i];
	}
	b[j]='\0';
	
	if(isPalindrome(s) && isPalindrome(a) && isPalindrome(b)) {
		cout << "Yes\n";	
	}
	else{
		cout << "No"<<endl;
	}
}

signed main() {
	boost;
	solve();
}

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

void solve(int cur, vector<vector<int> >& u,map<pair<int,int>, int> & w, vector<int >& ret) {
	for (int next_v : u[cur]) {
		if (ret[next_v] != -1) continue;
		if (w[make_pair(cur,next_v)] == 0) {
			ret[next_v] = ret[cur];
		} else {
			ret[next_v] = (ret[cur] == 0) ? 1 : 0; 
		}
		solve(next_v, u, w, ret);
	}
}



int main() {
	int n;
	cin >> n;
	vector<vector<int> > u(n, vector<int> (0));

	map<pair<int,int>, int> w;

	vector<int > r(n, -1);



	for (int i = 0; i < n - 1; i++) {
		int v1, v2;
		long long w0;

		cin >> v1 >> v2 >> w0;
		v1--;
		v2--;

		u[v1].push_back(v2);
		u[v2].push_back(v1);
		w[make_pair(v1,v2)] = (w0 & 1);
		w[make_pair(v2,v1)] = (w0 & 1);
	}
	r[0] = 0;
	solve(0, u, w, r);

	for (int i = 0; i < n; i++) {
		cout << r[i] << endl;
	}

	return 0;
}

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

int main()
{
	int count[3]{};
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	for (int i{}; i < n; i++)
	{
		int p;
		scanf("%d", &p);
		if (p <= a)
			count[0]++;
		else if (p <= b)
			count[1]++;
		else
			count[2]++;
	}
	printf("%d\n", *std::min_element(count, count + 3));
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int A[110];

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i) cin >> A[i];
	for(int i=0; i<N; ++i){
		if(A[i]%2==0){
			if(A[i]%3>0 && A[i]%5>0){
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> va;
typedef vector<int> vb;
typedef vector<int> vc;

typedef int _loop_int;
#define REP(i, n) for (_loop_int i = 0; i < (_loop_int)(n); ++i)
#define FOR(i, a, b) for (_loop_int i = (_loop_int)(a); i < (_loop_int)(b); ++i)
#define FORR(i, a, b)                                                          \
  for (_loop_int i = (_loop_int)(b)-1; i >= (_loop_int)(a); --i)

#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG_ARRY(v, n) REP(i, n) cout << " " << v[i]
#define DEBUG_VEC(v)                                                           \
  cout << #v << ":";                                                           \
  REP(i, v.size()) cout << " " << v[i];                                        \
  cout << endl
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a) % MOD + MOD) % MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(a, b) (abs(a - b) < EPS)
typedef complex<Real> P;

int main() {
  string s = "";
  cin >> s;
  int n = s.length();
  int odd = 0, even = 0;
  REP(i, n) {
    if (i % 2 == 0) {
      /* cout << '0' << endl; */
      if (s[i] != '0') {
        even++;
      }
    } else {
      /* cout << '1' << endl; */
      if (s[i] != '1') {
        even++;
      }
    }
    if (i % 2 == 1) {
      /* cout << '0' << endl; */
      if (s[i] != '0') {
        odd++;
      }
    } else {
      /* cout << '1' << endl; */
      if (s[i] != '1') {
        odd++;
      }
    }
  }
  cout << min(even, odd) << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

const ll mod=998244353;

int main(void){

  ll n,i,j,d,ans,dmax=-1;
  ll dcnt[100010]={};

  cin>>n;

  cin>>d;
  if(d!=0){
    cout<<0<<endl;
    return 0;
  }
  dcnt[d]++;

  for(i=1;i<n;i++){
    cin>>d;
    if(dmax<d)dmax=d;
    dcnt[d]++;
  }

  if(dcnt[0]!=1){
    cout<<0<<endl;
    return 0;
  }

  ans=1;
  for(i=1;i<=dmax;i++){
    if(dcnt[i]==0){
      cout<<0<<endl;
      return 0;
    }
    for(j=0;j<dcnt[i];j++){
      ans*=dcnt[i-1];
      ans%=mod;
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 1024
x, y, a, b, c = map(int, input().split())
p_array = list(map(int, input().split()))
q_array = list(map(int, input().split()))
r_array = list(map(int, input().split()))

p_array_sort = sorted(p_array, reverse=True)
q_array_sort = sorted(q_array, reverse=True)
r_array_sort = sorted(r_array, reverse=True)

p_i = x - 1
q_i = y - 1

for r in r_array_sort:
    p = p_array_sort[p_i]
    q = q_array_sort[q_i]
    if r <= p and r <= q:
        break
    elif q <= p:
        q_array_sort[q_i] = r
        q_i = max(q_i - 1, 0)
    else:
        p_array_sort[p_i] = r
        p_i = max(p_i - 1, 0)

ans = sum(p_array_sort[:x]) + sum(q_array_sort[:y])
print(ans)

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

int main()
{
  int N, x = 0;
  cin >> N;
  int tmp = N;

  for (; tmp > 0;)
  {
    int mod = tmp % 10;
    tmp /= 10;
    x += mod;
  }

  if (N % x == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


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

#ifdef _DEBUG
    #include "/home/v-o_o-v/deb.h"
    #define deb(x...)cerr << "[" << #x << "] = [";_print(x);
#else
    #define deb(x...)
#endif

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    int h[n];
    vector<int> v;
    
    for(int i = 0; i < n; i++){
        cin >> h[i];
        if(v.empty())v.pb(h[i]);
        else if(v.back() <= h[i])v.pb(h[i]);
    }
    cout << v.size() << '\n';
    return 0;
}
// Write Here


Measured memory_bytes: 3616
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    bool b = false;
    map<int, int> m;

    for(;;){
        string s;
        getline(cin, s);
        if(s.size() == 0){
            if(!b){
                b = true;
                continue;
            }else
                break;
        }

        istringstream iss(s);
        int a;
        iss >> a;
        map<int, int>::iterator it = m.find(a);
        if(it == m.end()){
            if(!b)
                ++ m[a];
        }else{
            if(!b)
                ++ it->second;
            else
                it->second += 10001;
        }
    }

    map<int, int>::iterator it;
    for(it=m.begin(); it!=m.end(); ++it){
        if(it->second > 10000)
            cout << it->first << ' ' << (it->second % 10000) << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

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

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

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int d[100100];
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}
ll gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll calc(ll b,ll n) {
	if (n < b) return n;
	return calc(b, n / b) + n % b;
}

void Solve() {

	int n, m, q;

	cin >> n >> m >> q;
	ll t[510][510];
	for (size_t i = 0; i <= n + 1; i++)
	{
		for (size_t j = 0; j <= n + 1; j++)
		{
			t[i][j] = 0;
		}
	}
	for (size_t i = 0; i < m; i++)
	{
		int l, r;
		cin >> l >> r;
		t[l][r]++;
	}

	for (int i = 1; i < n; i++)
	{
		for (int j = i + 1;  j <= n;  j++)
		{
			t[i][j] += t[i][j - 1];
		}
	}

	for (int i = n; i > 0; i--)
	{
		for (int j = i - 1; j > 0; j--)
		{
			t[j][i] += t[j + 1][i];
		}
	}
	for (size_t i = 0; i < q; i++)
	{
		int l, r;
		cin >> l >> r;
		cout << t[l][r] << endl;
	}

}


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



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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int n, m;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> n >> m;
    if (n%2) {
        int temp = n;
        for (int i = 1; i <= m; ++i) {
            cout << i << ' ' << temp-- << '\n';
        }
    } else {
        int lf = 1, rt = n;
        for (int i = 1; i <= min(m, n/4); ++i) cout << lf++ << ' ' << rt-- << endl;
        ++lf;
        forn(i, m-n/4) {
            cout << lf++ << ' ' << rt-- << endl;
        }
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string S,T;
  cin >> S >> T;
  int N = S.size();
  int M = T.size();
  int R1[N+1];
  int R2[M+1];
  R1[0] = 0; R2[0] = 0;
  for (int i = 0; i < N; i++) {
    int c = S[i] - 'A' + 1;
    R1[i+1] = R1[i] + c;
  }
  for (int i = 0; i < M; i++) {
    int c  = T[i] - 'A' + 1;
    R2[i+1] = R2[i] + c; 
  }

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int x = R1[b] - R1[a-1];
    int y = R2[d] - R2[c-1];
    if (x%3 == y%3) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

int main() {
  int n, x;
  cin >> n >> x;

  vector<int> a(n);
  rep(i, n) cin >> a[i];

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

  int sum = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (sum + a[i] <= x) {
      sum += a[i];
      ans++;
      if (i == n - 1 && sum < x) ans--;
    } else break;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
        int num[101][101]={0},r,c,i,j;
        scanf("%d %d",&r,&c);
        for(i=0;i<r;i++){
                for(j=0;j<c;j++){
                        scanf("%d",&num[i][j]);
                        num[i][c]+=num[i][j];
                        num[r][j]+=num[i][j];
                        num[r][c]+=num[i][j];
                }
        }
        for(i=0;i<=r;i++){
                for(j=0;j<=c;j++){
                        printf("%d",num[i][j]);
                        if(j!=c)
                                putchar(' ');
                }
                putchar('\n');
        }
        return 0;
}

Measured memory_bytes: 652
def main():
    N = int(input())
    S = [input() for i in range(N)]
    from collections import Counter
    c = Counter(S)
    cnt = c.most_common()[0][1]
    ans = []
    for s in c.most_common():
        # print(s)
        if s[1] == cnt:
            ans.append(s[0])
    ans.sort()
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45068
#include "./bits/stdc++.h"
using namespace std;

int main(){
    int a,b;
    int multi;
    cin >> a >> b;
    multi = a * b;
    if(multi % 2){
        printf("Odd\n");
    }
    else
    {
        printf("Even\n");
    };
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  lp(z,n){
    int a[5][5];
    lp(i,5){
      lp(j,5){
	cin>>a[j][i];
      }
    }
    int check,ans=0;
    lp(i,5){
      lp(j,5){
	lp(k,5-i){
	  lp(l,5-j){
	    check=0;
	    for(int m=k;m<=i+k;m++){
	      for(int n=l;n<=j+l;n++){
		if(a[n][m]==0){
		  check=1;
		  break;
		}
	      }
	      if(check==1) break;
	    }
	    if(check==0){
	      ans=max(ans,(i+1)*(1+j));
	    }
	  }
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin >> n >> m;
	string s = "###";
	for(int i = 1;i <= m;i++){
		int pos;
		char c;
		cin >> pos >> c;
		if(pos > n)cout << -1,exit(0);
		--pos;
		if(s[pos] != '#' && c != s[pos])cout << -1,exit(0);
		s[pos] = c;
	}
	
	if(n == 1){
		if(s[0] == '#')cout << '0'; else cout << s[0];
	}else if(n == 2){
		if(s[0] == '0')cout << -1,exit(0); else if(s[0] != '#') cout << s[0]; else cout << '1';
		if(s[1] == '#')cout << '0'; else cout << s[1];
	}else{
	if(s[0] == '0')cout << -1,exit(0);
	if(s[0] == '#')s[0] = '1';
	cout << s[0];if(s[1] == '#')cout << '0'; else cout << s[1]; if(s[2] == '#')cout << 0; else cout << s[2];	
	}
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,sin,cos,radians,tan
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,h,m=mii()
h%=12

hun = [b*sin(radians(360*m/60)),b*cos(radians(360*m/60))]

zi=[a*sin(radians(360*h/12 + 360*m/60/12)),a*cos(radians(360*h/12+ 360*m/60/12))]

ans = ((hun[0]-zi[0])**2 + (hun[1]-zi[1])**2)**0.5
#print(hun,zi)
print(ans)



Measured memory_bytes: 90576
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    print(700 + (S.count('o') * 100))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*input
3 2
1 2 1
2 3 1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define YY cout<<"YES\n"
#define NN cout<<"NO\n"
#define yy cout<<"Yes\n"
#define nn cout<<"No\n"
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=105;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
ll d[maxn][maxn];
ll tg[maxn][maxn];
int main()
{
	int n,m;
	cin>>n>>m;
	REP(i,n) REP(j,n) d[i][j]=INF;
	REP(i,n) d[i][i]=0;
	while(m--){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		d[a][b]=d[b][a]=c;
		tg[a][b]=tg[b][a]=c;
	}
	REP(j,n) REP(i,n) REP(k,n){
		d[i][k]=min(d[i][k],d[i][j]+d[j][k]);
	}
	int ans=0;
	REP(i,n) for(int j=i+1;j<n;j++) if(tg[i][j]){
		if(tg[i][j]!=d[i][j]) ans++;
	}	
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<ctime>

using namespace std;

string gjl;
long long kkk;


int main()
{
	cin>>gjl;
	kkk=gjl.size();
	
	for(register int i=0;i<kkk;i++)
	{
		if(gjl[i]=='C')
			for(register int j=i+1;j<kkk;j++)
				if(gjl[j]=='F')
				{
					cout<<"Yes";	
					return 0;
				}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
use proconio::{input};

fn main() {
    input!{
        s: String,
        _: String,
        mut a: i32,
        mut b: i32,
        u: String
    };
    if s == u {
        a -= 1;
    } else {
        b -= 1;
    }
    println!("{} {}", a, b);
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
const int N=187;
int dp[N][N][N][18];
int sum[N][N];
char c[N][N];
int n,m;
inline int cal(int x,int y,int l,int r)
{
	return sum[r][y]+sum[l-1][x-1]-sum[l-1][y]-sum[r][x-1];
}
inline bool no_cost(int x,int y,int l,int r)
{
	if(cal(x,y,l,r)==0||cal(x,y,l,r)==(y-x+1)*(r-l+1))return true;
	return false;
}

int dfs(int x,int l,int r,int k)
{
	if(dp[x][l][r][k]!=-1)return dp[x][l][r][k];
	if(l>r||x<=0||x>m)return x;
	int nxt=dfs(x,l,r,k-1);
	if(nxt!=m&&nxt>=x)dp[x][l][r][k]=dfs(nxt+1,l,r,k-1);
	else dp[x][l][r][k]=nxt;
	int L=0,R=r-l;
	while(L<=R)
	{
		int mid=(L+R)>>1;
		int Le=dfs(x,l,l+mid,k-1);
		int Ri=dfs(x,l+mid+1,r,k-1);
		dp[x][l][r][k]=max(dp[x][l][r][k],min(Le,Ri));
		if(Le<=Ri&&Le!=-1)
			R=mid-1;
		else
			L=mid+1;
	}
	return dp[x][l][r][k];
}
int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>c[i][j];
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(c[i][j]=='.');
		}
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=i;j<=n;++j)
		{
			int last=1,k=1;
			while(k<=m)
			{
				while(k<=m&&no_cost(last,k,i,j))k++;
				if(last==k)
				{
					dp[last][i][j][0]=0;
					k=++last;
				}
				for(;last<k;last++)dp[last][i][j][0]=k-1;
			}
		}
	}
	for(int i=0;i<=18;i++)
	{
		if(dfs(1,1,n,i)==m)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 460160
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        
        double Short = (double)(h * (360 / 12)) + (double)m * 1/2;

        double Long = (double)m * (360 / 60);

        double ang = (double)Math.abs(Long - Short);
        //System.out.println(ang);

        double ans = (double)a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(Math.min(ang, 360 - ang)));
        
        System.out.println(Math.sqrt(ans));
    
	}
}

Measured memory_bytes: 36048
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int main(){
char c[1919];
c['2']='k';c['3']='s';c['4']='t';c['5']='n';
c['6']='h';c['7']='m';c['8']='y';c['9']='r';
c['0']='w';c['T']='a';c['L']='i';c['U']='u';
c['R']='e';c['D']='o';
	string s;
	cin>>s;
	r(i,0,s.size()){
		if(s[i]=='0'&&s[i+1]=='U'){cout<<"nn";i++;}
		else if(s[i]!='1')cout<<c[s[i]];
	}cout<<endl;
}

Measured memory_bytes: 3232
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int a = n%10;
      	String ans = "";
      	if(a==2 || a==4 || a==5 || a==7 || a==9) ans="hon";
      	else if(a==0 || a==1 || a==6 || a==8) ans="pon";
      	else if(a==3) ans="bon";
      	System.out.println(ans);
	}
}

Measured memory_bytes: 35600
#include <iostream>
#include <cmath>
using namespace std;
int CDigit(long long x){
  int i=1;
  while(x/10){
    x = x/10;
    i++;
  }
  return i;
}
int main (){
  long long N,m=1;
  cin >> N;
  m = N;
  for(int i = 2;i<=(int)pow(N,0.5)+1;i++){
    if(N%i == 0){
      m = i;
    }
  }
  cout << CDigit(max(N/m,m));
}


Measured memory_bytes: 384
def solve(x, k, d):
    if x > 0 and x - k * d > 0:
        return x - k * d
    elif x < 0 and x + k * d < 0:
        return abs(x + k * d)
    elif k % 2 == 0:
        a = x % (2 * d)
        return min(a, abs(a - 2 * d))
    else:
        a = (x - d) % (2 * d)
        return min(a, abs(a - 2 * d))

# def solve_naive(x, k, d):
#     for i in range(k):
#         if x>0:
#             x-=d
#         else:
#             x+=d
#     return abs(x)

# import random

# def check(count=100):
#     for _ in range(count):
#         x = random.randint(-1e15, 1e15)
#         k = random.randint(1, 100)
#         d = random.randint(1, 1e15)
#         if solve(x, k, d) != solve_naive(x, k, d):
#             print(x, k, d, solve(x, k, d), solve_naive(x, k, d))

# check(100)

x, k, d = map(int, input().split())
print(solve(x, k, d))

Measured memory_bytes: 9196
#include<cstdio>
int n,a[200003],b[200003];
long long fac[8003],ifac[8003],f[4003][4003],ans;
inline long long qpow(register long long x,register int b) {
	register long long ans=1;
	while(b) {
		if(b&1) {
			ans*=x;
			ans%=1000000007;
		}
		x*=x;
		x%=1000000007;
		b>>=1;
	}
	return ans;
}
inline long long c(register int x,register int y) {
	return fac[x]*ifac[y]%1000000007*ifac[x-y]%1000000007;
}
int main() {
	scanf("%d",&n);
	for(register int i=0; i^n; ++i) {
		scanf("%d%d",&a[i],&b[i]);
		++f[2001-a[i]][2001-b[i]];
	}
	for(register int i=1; i^4003; ++i) {
		for(register int j=1; j^4003; ++j) {
			f[i][j]+=f[i-1][j]+f[i][j-1];
			f[i][j]%=1000000007;
		}
	}
	fac[0]=1;
	for(register int i=1; i^8003; ++i) {
		fac[i]=fac[i-1]*i;
		fac[i]%=1000000007;
	}
	ifac[8002]=qpow(fac[8002],1000000005);
	for(register int i=8001; ~i; --i) {
		ifac[i]=ifac[i+1]*(i+1);
		ifac[i]%=1000000007;
	}
	for(register int i=0; i^n; ++i) {
		ans+=f[2001+a[i]][2001+b[i]];
		ans%=1000000007;
		ans-=c((a[i]+b[i])<<1,b[i]<<1);
		ans%=1000000007;
	}
	ans+=1000000007;
	ans%=1000000007;
	ans*=500000004;
	ans%=1000000007;
	ans+=1000000007;
	ans%=1000000007;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 126976
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

char a[55][55],b[55][55];
signed main(){
	int h,w;cin>>h>>w;
	rep(i,h)cin>>a[i];
	rep(i,h)rep(j,w){
		if(a[i][j]=='#'){
			b[i][j]='#';continue;
		}
		b[i][j]='0';
		for(int k=-1;k<=1;k++){
			for(int t=-1;t<=1;t++){
				if(k==0&&t==0)continue;
				int nx=i+k,ny=j+t;
				if(nx<0||ny<0||nx>=h||ny>=w)continue;
				if(a[nx][ny]=='#')b[i][j]++;
			}
		}
	}
	rep(i,h)cout<<b[i]<<endl;
}

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

using namespace std;

int main(){
string str;

cin>>str;
if(str[0]=='7'){
cout<<"Yes"<<endl;
return 0;
} else if(str[1]=='7'){
cout<<"Yes"<<endl;
return 0;
}else if(str[2]=='7'){
cout<<"Yes"<<endl;
return 0;
}else{
cout<<"No"<<endl;
return 0;
}
}

Measured memory_bytes: 3620
#include <iostream>

int main() {
    while( true ) {
        int h , w ;
        std::cin >> h >> w ;
        if( ! ( h | w ) ) {
            break ;
        } else {
            for( int i = 0 ; i < h ; i++ ) {
                for( int ii = 0 ; ii < w ; ii++ ) {
                    if( i != 0 && i != h - 1 && ii != 0 && ii != w - 1 ) {
                        std::cout << "." ;
                    } else {
                        std::cout << "#" ;
                    }
                }
                std::cout << std::endl ;
            }
            std::cout << std::endl ;
        }
    }
}



Measured memory_bytes: 3124
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N; cin>>N;
    vec a(N);
    MP mp;
    rep(i,N){
        cin>>a[i];
        mp[a[i]]++;
    }
    ll res=0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        res+=itr->second*(itr->second-1)/2;
    }
    rep(i,N){
        cout<<res-(mp[a[i]]-1)<<endl;
    }
    return 0;
}

Measured memory_bytes: 11008
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int N;
	cin >> N;
	int W[110];
	for (int i = 1; i <= N; i++) {
		cin >> W[i];
	}

	int P[110];

	int now = 0;

	for (int i = 1; i <= N; i++) 
	{
		P[i] = W[i];
		now += P[i];
		P[i] = now;
	}

	int min = 9999999;

	for (int i = 1; i <= N; i++) {
		if (abs(P[i] - (P[N] - P[i])) < min)min = abs(P[i] - (P[N] - P[i]));
	}
	cout << min;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

int L, N;
VP ans;
VI cost;
VI tmp;
map<int, bool>F;


void doubling(int a) {
	if (a == 2) return;
	if (a % 2) {
		tmp.push_back(--a);
		if (a != 2) {
			tmp.push_back(a / 2);
			F[a / 2] = 1;
			a /= 2;
			doubling(a);
		}
	}
	else {
		tmp.push_back(a / 2);
		F[a / 2] = 1;
		a /= 2;
		doubling(a);
	}
}


void kakeru() {
	fore(i, cost)i *= 2;
	ans.push_back(pii(N - 1, N));
	ans.push_back(pii(N - 1, N));
	cost.push_back(1);
	cost.push_back(0);
	N++;
}
void purasu(int L) {
	ans.push_back(pii(0, N - 1));
	cost.push_back(L);
}

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


	ans.push_back(pii(0, 1));
	ans.push_back(pii(0, 1));
	cost.push_back(0);
	cost.push_back(1);
	N = 2;
	cin >> L;
	if (L == 2) {
		cout << N << " " << ans.size() << endl;
		REP(i, ans.size()) cout << ans[i].first + 1 << " " << ans[i].second + 1 << " " << cost[i] << endl;

		return 0;
	}

	doubling(L);
	SORT(tmp);
	fore(i, tmp) {
		//cout << i << endl;
		if (F[i])kakeru();
		else purasu(i);
	}
	cout << N << " " << ans.size() << endl;
	REP(i, ans.size()) cout << ans[i].first + 1 << " " << ans[i].second + 1 << " " << cost[i] << endl;

	return 0;
}



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

using ll=long long;
const ll MOD=1000000007;

int main() {
  char x,y;
  cin >> x >> y;
  if(x==y)
    cout << "=" << endl;
  else if(x>y)
    cout << ">" << endl;
  else
    cout << "<" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define ALL(x) (x).begin(),(x).end()
template <class T> void chmin(T& a, const T& b) { if (b < a) a = b; }
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

signed main() {
    int N, K;
    cin >> N >> K;

    vector<ll> xi(N);
    REP(i, N) cin >> xi[i];

    auto lb = lower_bound(ALL(xi), 0ll);
    ll dmin = 1e12;
    for (auto it = xi.begin(); it != lb; it++) {
        if ((it - lb) > K) continue;
        if ((it - xi.begin()) + K-1 >= N) break;
        chmin(dmin, abs(*it) + abs(*(it+K-1) - *it));
    }

    for (auto it = lb; it != xi.end(); it++) {
        if (xi.end()-1 - lb > K) break;
        if ((it - xi.begin()) - (K-1) < 0) continue;
        chmin(dmin, *it + abs(*it - *(it - (K-1))));
    }

    if ((lb - xi.begin()) + (K-1) < N) {
        chmin(dmin, *(lb + (K-1)));
    }

    ll L = (*lb == 0) ? K - 1 : K;
    if ((lb - xi.begin()) - K >= 0) {
        chmin(dmin, abs(*(lb - K)));
    }

    cout << dmin << LF;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
  int N,ans;
  scanf("%d",&N);

  if(N%9==0){
    printf("Yes\n"); 
  }else if(N%8==0){
    if(N<=72){
    printf("Yes\n");
    }else{printf("No\n");}
  }else if(N%7==0){
    if(N<=63){
    printf("Yes\n");
    }else{printf("No\n");}
    }else if(N%6==0){
    if(N<54){
    printf("Yes\n");
    }else{printf("No\n");}
     }else if(N%5==0){
    if(N<45){
    printf("Yes\n");
    }else{printf("No\n");}
     }else if(N%4==0){
    if(N<36){
    printf("Yes\n");
    }else{printf("No\n");}
     }else if(N%3==0){
    if(N<27){
    printf("Yes\n");
    }else{printf("No\n");}
     }else if(N%2==0){
    if(N<18){
    printf("Yes\n");
    }else{printf("No\n");}
     }else if(N%1==0){
    if(N<9){
    printf("Yes\n");
    }else{printf("No\n");}
    
    }else{
    
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
typedef long long ll;
//ll mod = 1e9+7;
ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    if ( k == 0 ) {
        cout << n * n << endl;
        return 0;
    }
    for ( ll i = k + 1; i <= n; ++i ) {
        ll mod_group_num = n / i;
        ans += mod_group_num * ( i - k );
        ll num = n % i;
        ans += max(0LL, num - k + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]
    
    N,x = (int(_) for _ in input().split())
    a = list(int(_) for _ in input().split())
    cost = 0
    for i in range(1,N):
        tmp_sum = a[i-1] + a[i]
        if(tmp_sum > x):
            cost += tmp_sum - x
            a[i] = a[i] - (tmp_sum - x)
            if(a[i]<0):
                a[i-1] = a[i-1] + a[i]
                a[i] = 0
                
    print(cost)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 14556
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N;
	int d[99];
	int num[100] = {}; // 1 <= d_i <= 100
	int answer = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> d[i];
		num[d[i]]++;
	}

	for (int j = 1; j <= 100 ; j++) {
		if (num[j] > 0) {
			answer++;
		}
	}
	
	cout << answer << endl;
	return 0;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

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

int main()
{
    int n, h, w;
    ci >> n >> h >> w;

    co << (n - w + 1) * (n - h + 1) << en;
  
    return 0;
}


Measured memory_bytes: 256
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <bitset>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

ll gcd(ll a, ll b)
{
    if (a > b)
        std::swap(a, b);

    while (true)
    {
        auto m = b % a;
        if (m == 0)
            return a;
        b = a;
        a = m;
    }
}

void dfs(vec<int>& color, const vvec<std::pair<int, ll>>& edges, int current, int col)
{
    if (color[current] != -1)
        return;

    color[current] = col;

    for (auto e : edges[current])
    {
        auto c = col;
        if (e.second % 2 != 0)
            c = (col + 1) % 2;
        dfs(color, edges, e.first, c);
    }
}

int main()
{
    using namespace std;

    int n;
    cin >> n;
    vec<int> u(n), v(n);
    vec<ll> w(n);
    vvec<pair<int, ll>> edges(n);

    for (int i = 0; i < n - 1; ++i)
    {
        cin >> u[i] >> v[i] >> w[i];
        u[i]--;
        v[i]--;
        edges[u[i]].push_back(make_pair(v[i], w[i]));
        edges[v[i]].push_back(make_pair(u[i], w[i]));
    }

    vec<int> color(n, -1);

    color[0] = 0;

    for (auto e : edges[0])
    {
        auto c = 0;
        if (e.second % 2 != 0)
            c = 1;
        dfs(color, edges, e.first, c);
    }

    for (auto c : color)
    {
        cout << c << endl;
    }

    return 0;
}


Measured memory_bytes: 11904