akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,A,B,C,D; cin>>N>>A>>B>>C>>D;
    --N;
    ll X=abs(B-A);
    rep(i,N+1){
        if(C*i-D*(N-i)<=X and D*i-C*(N-i)>=X){
            cout<< "YES" <<"\n"; return;
        }
    }
    cout<< "NO" <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {

    int N, M; cin >> N >> M;
    vector<vector<int> > s(M);

    for (int i = 0; i < M; ++i) {
        int k; cin >> k;
        for (int j = 0; j < k; ++j) {
            int a; cin >> a; --a; //0-index
            s[i].push_back(a);
        }
    }

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

    ll res = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        bool ok = true;
        for (int i = 0; i < M; i++) {
            int swich_on = 0;
            for (auto v : s[i]) {
                if(bit & (1<<v)) ++swich_on; //現在のbitにv番目のフラグが立っているとスイッチが点灯
            }
            if (swich_on % 2 != p[i]) ok = false;
        }
        if (ok) ++res;
    }
    
    cout << res << endl;

    return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;};
void qmod(ll &a,ll b){a=(a*b)%MOD;};
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n,z,w;cin>>n>>z>>w;
  vector<ll> a(n);
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  reverse(ALL(a));
  vector<ll> l(n),r(n);
  l[0]=abs(a[0]-a[1]);
  r[0]=abs(a[0]-a[1]);
  /*l[1]=max(abs(a[1]-a[0]),abs(a[0]-a[2]));
  r[1]=min(abs(a[1]-a[0]),abs(a[0]-a[2]));*/
  //cout<<l[1] spa r[1]<<endl;
  for(i=1;i<n-1;i++){
    l[i]=abs(a[0]-a[i+1]);
    r[i]=abs(a[0]-a[i+1]);
    for(j=i-1;j>=0;j--){
      chmax(l[i],r[j]);
      chmin(r[i],l[j]);
    }
  }
  l[n-1]=abs(a[0]-w);
  for(j=n-2;j>=0;j--){
    chmax(l[n-1],r[j]);
  }
  cout<<l[n-1]<<endl;

  return 0;
}

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

int n, q;
vector<vector<int>> vec;
vector<int> counter;
vector<int> res;

//雪崩戦法
void sumsum(int root, int point){
  point += counter[root];
  res[root] = point;
  for(int i=0; i<vec[root].size(); i++){
    sumsum(vec[root][i], point);
  }
}
    

int main(){
  cin >> n >> q;
  for(int i=0; i<n; i++) vec.push_back(vector<int>());
  for(int i=0; i<n; i++) counter.push_back(0);
  for(int i=0; i<n; i++) res.push_back(0);
  for(int i=0; i<n-1; i++){
    int from, to;
    cin >> from >> to;
    vec[from-1].push_back(to-1);
  }
  for(int i=0; i<q; i++){
    int num, p;
    cin >> num >> p;
    counter[num-1] += p;
  }
  sumsum(0, 0);
  for(int i=0; i<n; i++){
    cout << res[i] << " ";
  }
  return 0;
}
  

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

  template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K,a;
  while(cin >> K){
    if(K == 0 ) break;
    int ans = 0;
    rep(_,K*(K-1)/2){
      cin >> a ;
      ans +=a ;
    }
    cout << ans/(K-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int a, soma = 0, aux, A;
    scanf("%d", &a);
    if(a < 10){
        printf("Yes\n");
    }
    else{
        A = a;
        while(a > 10){
            aux = a % 10;
            a /= 10;
            soma += aux;
        }
        if(A % (soma + a) == 0)
            printf("Yes\n");
        else
            printf("No\n");
    }
	return 0;
}






Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;
using namespace std;
typedef std::pair<ll, ll> mp;
#define fi first
#define lim 1e18
#define se second
#define MOD 1000000007
inline ll read()
{
	ll x = 0, f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { (x *= 10) += ch - '0'; ch = getchar(); }
	return x * f;
}

const int maxk = 100, mod = 1000000007;
ll fib[maxk], res; int mx, k = 1;
std::vector<mp> excellent[maxk];

int main() {
	fib[0] = fib[1] = 1;
	while(fib[k] + fib[k - 1] <= lim) {
		++ k;
		fib[k] = fib[k - 1] + fib[k - 2];
	}

 excellent[1].push_back(mp(1, 2));
	for (int i = 2; i <= k; i++)
	{
		for (pair<ll, ll> p : excellent[i-1])
			excellent[i].push_back(mp(p.se, p.fi + p.se));
		excellent[i].push_back(mp(fib[i+1], fib[i+1] + fib[i-1]));
	}

 int T = read();
	while (T--)
	{
		ll x = read(), y = read(); mx = 1, res = 0;
		if (x > y) swap(x, y);
		while (mx+2 <= k && fib[mx+1] <= x && fib[mx+2] <= y) mx++;
		for (pair<ll, ll> p : excellent[mx])
		{
			if (p.fi <= x && p.se <= y)
				(res += (y - p.se) / p.fi + 1) %= MOD;
			if (p.se <= x)
				(res += (x - p.se) / p.fi + 1) %= MOD;
		}
		if (mx == 1) res += x;
		printf("%d %lld\n", mx, res);
	}
}

Measured memory_bytes: 4360
def main(argv)
  (n, q) = gets.chomp.split(' ').map(&:to_i)
  s = gets.chomp
  
  a = []
  (n - 1).times do |i|
    if s[i] == 'A' && s[i + 1] == 'C' then
      a.push(i)
    end
  end
  
  t = [0] * (n + 1)
  n.times do |i|
    t[i + 1] = t[i]
    ret = a.bsearch{|x| x >= i}
    if ret != nil && ret == i then
       t[i + 1] += 1
    end
  end
  
  q.times do |i|
    (l, r) = gets.chomp.split(' ').map(&:to_i)
    c = t[r] - t[l - 1]
    
    ret = a.bsearch{|x| x >= (r - 1)}
    if ret != nil && ret == (r - 1) then
      c -= 1
    end
    puts c.to_s
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

int kam[15], c[15];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int d, g;
    cin >> d >> g;
    ll ans = 1e9;
    for(int i = 0; i < d; i++) cin >> kam[i] >> c[i];
    for(int i = 0; i < (1 << d); i++){
        ll score = 0, solved = 0;
        for(int j = 0; j < d; j++){
            if(i >> j & 1){
                score += kam[j] * 100LL * (j + 1) + c[j];
                solved += kam[j];
            }
        }
        for(int j = d - 1; j >= 0; j--){
            if(i >> j & 1) continue;
            if(score >= g) break;
            int need = g - score;
            int z = min(kam[j], need / (100 * (j + 1)));
            score += z * 100 * (j + 1);
            solved += z;
        }
        if(score >= g) ans = min(ans, solved);
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int N; cin >> N;
  int i = N;
  int sum = 0;
  while (i > 0) {
    sum += (i % 10);
    i /= 10;
  }
  if (N % sum == 0) cout << "Yes" << endl;
  else              cout << "No" << endl;
}


Measured memory_bytes: 3576
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

struct UnionFind {
    private:
    vector<int> child, tree, sum;

    public:
    UnionFind(int v) {
        tree.resize(v);
        sum.resize(v);
        rep(i, v) tree[i] = i, sum[i] = 1;
    }

    int root(int i) {
        if(i == tree[i]) {
            rep(j, child.size()) tree[child[j]] = i;
            child.clear(); 
            return i;
        }
        else {
            child.push_back(i);
            return i = root(tree[i]);
        }
    }

    int size(int i) {
        return sum[root(i)];
    }

    int unit(int x, int y) {
        if(isUnit(x,y)) return 0;
        x = root(x);
        y = root(y);
        sum[min(x,y)] += sum[max(x,y)];
        tree[max(x,y)] = min(x,y);
    }

    bool isUnit(int x, int y) {
        return root(x) == root(y);
    }
};

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    ll memo=n*(n-1)/2;
    vector<int> ans(0);
    vector<int> xx(m);
    vector<int> yy(m);
    rep(i,m){
        cin>>xx[m-1-i]>>yy[m-1-i];
        xx[m-1-i]--;
        yy[m-1-i]--;
    }
    rep(i,m){
        ans.pb(memo);
        int x=xx[i],y=yy[i];
        if(!uf.isUnit(x,y)){
            memo-=uf.size(x)*uf.size(y);
        }
        uf.unit(x,y);
        memo=max((ll)0,memo);
    }
    rrep(i,m){
        cout<<ans[i]<<endl;
    }
    
}

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

char s[252521];
char t[252521];
char mp[128], rev[128];

int main(){
  scanf("%s%s",s,t);
  REP(i,128)mp[i] = rev[i] = '$';
  int n = strlen(s);
  REP(i,n){
    if(mp[s[i]]=='$'){
      mp[s[i]] = t[i];
    }else if(mp[s[i]] != t[i]){
      puts("No");return 0;
    }
    if(rev[t[i]]=='$'){
      rev[t[i]] = s[i];
    }else if(rev[t[i]] != s[i]){
      puts("No");return 0;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 640
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(x) begin(x),end(x)
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define pb push_back
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
const ll mod = 998244353;
int n,m;
string s,s1,s2,s3,s4,s5;
int main(){
    fast,cin>>s;
    int id = (int)s.size()/2;
    for(int i=0;i<id;i++){
        s1 += s[i];
    }
    for(int i=id+1;i<s.size();i++){
        s2 += s[i];
    }
    s5 = string(s.rbegin(),s.rend());
    s3 = string(s1.rbegin(),s1.rend());
    s4 = string(s2.rbegin(),s2.rend());
    if(s1 == s3 && s2 == s4 && s == s5){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    for i in range(1,len(a)+1):
        if i%2 == 1 & a[i-1]%2 == 1:
            ans += 1
    print(ans)

        
if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;

  for(int i = 0; i < 10; i++) {
    for(int j = 0; j < 10; j++) {
      for(int k = 0; k < 10; k++) {
        // ijk が作れるか
        int state = 0;
        
        for(int id = 0; id < n; id++) {
          int num = s[id] - '0';
          if(state == 3) break;
          
          if(state == 0 and num == i) state++;
          else if(state == 1 and num == j) state++;
          else if(state == 2 and num == k) state++;
        }


        if(state == 3) {
          ans++;
        }
      }
    }
  }

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


Measured memory_bytes: 256
from collections import deque

int1 = lambda x: int(x) - 1

N, Q = map(int, input().split())
T = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int1, input().split())
    T[a].append(b)
    T[b].append(a)

lst = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    lst[p - 1] += x

d = deque([0])
visited = set()
while d:
    v = d.pop()
    visited.add(v)
    for x in T[v]:
        if x not in visited:
            lst[x] += lst[v]
            d.append(x)
print(*lst)


Measured memory_bytes: 64388
#include <stdio.h>
int main(void)
{
	int e1,e2,e3,e4;
	scanf("%d %d %d %d",&e1,&e2,&e3,&e4);
	if(e1==e2 && e3==e4 || e1==e3 && e2==e4 || e1==e4 && e2==e3){
		printf("yes\n");
	}
	else{
		printf("no\n");
	}
	return 0;
}


Measured memory_bytes: 2120
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(M)]

class UnionFind:
    def __init__(self, N):
        self.size = N
        self.par = [None] * N
        self.rank = [None] * N
        for n in range(N):
            self.par[n] = n
            self.rank[n] = 1

    def root(self, x):
        if self.par[x] == x:
            return x
        r = self.root(self.par[x])
        self.par[x] = r
        return r

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx != ry:
            self.size -= 1
            if self.rank[rx] > self.rank[ry]:
                self.par[ry] = rx
            else:
                self.par[rx] = ry
                if self.rank[rx] == self.rank[ry]:
                    self.rank[ry] += 1

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

c = 0
for i in range(M):
    # i 番目の辺を採用しない場合にグラフが連結かどうか？
    uf = UnionFind(N)
    for a, b in ab[0:i]+ab[i+1:M]:
        uf.unite(a-1, b-1)
    if uf.size > 1:
        c += 1
print(c)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;

  cin >> n;
  cout << n*800 - n/15*200 fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
vector<int> G[100005];
int gr[100005];
int root;
int rez = 0;
int N;
bool dfs(int nod,int tata){
    if(G[nod].size() == (tata != 0)){
        return 0;
    }
    int tmp = 0;
    bool r = 0;
    for(auto it:G[nod]){
        if(it == tata){
            continue;
        }
        int f = dfs(it,nod);
        tmp += 1 - f;
        r |= f;
    }
    if(tmp > 1){
        r = 1;
        rez += tmp - 1;
    }
    return r;
}
int main()
{
    cin >> N;
    for(int i = 1;i < N;i++){
        int x,y;
        cin >> x >> y;
        x++;
        y++;
        G[x].push_back(y);
        G[y].push_back(x);
        gr[x]++;
        gr[y]++;
    }
    for(int i = 1;i <= N;i++){
        if(gr[i] >= 3){
            root = i;
        }
    }
    if(!root){
        rez = 1;
    }
    else{
        dfs(root,0);
    }
    cout << rez;
    return 0;
}


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



int main()
{
    int a[3][3];
    int i,j;
    int n,t;
    int flag=1;
    
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&t);
        for(i=0;i<3;i++)
        {
            for(j=0;j<3;j++)
            {
                if(a[i][j]==t)
                {
                    a[i][j]=0;
                    break;
                }
            }
        }
    }
    for(i=0;i<3;i++)
    {
        if(a[i][0]==0&&a[i][1]==0&&a[i][2]==0)
        {
            flag=0;
            break;
        }
    }
    if(flag==1)
    {
        for(j=0;j<3;j++)
        {
            if(a[0][j]==0&&a[1][j]==0&&a[2][j]==0)
            {
                flag=0;
                break;
            }
        }
        if(flag==1)
        {
            if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0)
            {
                flag=0;
            }
            if(a[2][0]==0&&a[1][1]==0&&a[2][0]==0)
            {
                flag=0;
            }
        }
    }
    if(flag==0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    return 0;
}


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

int N;
int A[202];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,2*N) cin>>A[i];
	sort(A,A+2*N);
	int ret=0;
	FOR(i,N) ret+=A[i*2];
	cout<<ret<<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 <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int N,H,W;
	cin >> N >> H >> W;
	cout << (N-H+1)*(N-W+1)<<endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define MAXNUM(A) (A+9)/10*10

using namespace std;
/*https://atcoder.jp/contests/abc123/tasks/abc123_b*/

int main() {
	int A, B, C, D, E;
	int sum;
	cin >> A >> B >> C >> D >> E;
	sum = MAXNUM(A) + MAXNUM(B) + MAXNUM(C) + MAXNUM(D) + MAXNUM(E);
	sum -= max({ MAXNUM(A) - A,MAXNUM(B) - B ,MAXNUM(C) - C ,MAXNUM(D) - D ,MAXNUM(E) - E });
	
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  bool f = false;
  for(int i=0;i*4<=n;i++){
    for(int j=0;j*7+i*4<=n;j++){
      if(i*4+j*7==n) f = true;
    }
  }
  cout << (f?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef struct {
	int t;
	int no;
} data_t;

data_t h[1000] = {0};

int sort_dec(const void *a, const void *b)
{
	int dta = ((data_t*)a)->t;
	int dtb = ((data_t*)b)->t;
//	printf("%d %d\n",dta, dtb);
	return (dta - dtb);
}

int main()
{
	int n = 0;
	int t = 0;
	int a = 0;
	int temp = 0;
	int i = 0;
	scanf("%d", &n);
	scanf("%d %d", &t, &a);
	a = a * 1000;
	t = t * 1000;
	for(i = 0; i < n; i++) {
		scanf("%d",&temp);
		h[i].t = abs((t - (temp * 6)) - a);
		h[i].no = i+1;
//		printf("%d %d\n", h[i].t, h[i].no);
	}

	qsort(h, n, sizeof(data_t), sort_dec);
	printf("%d\n",h[0].no);
	return 0;
}


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

using namespace std;

int main()
{
	string str[10000],mstr,lstr;
	int size=0,max=0,i,j;
	
	for(i=0;cin >> str[i];i++)
	{
		if(size<str[i].size())
		{
			size=str[i].size();
			lstr=str[i];
		}
	}
	for(j=0;j<i;j++)
	{
		int count=0;
		for(int k=0;k<i;k++)
			if(str[j]==str[k])
				count++;
		if(max<count)
		{
			max=count;
			mstr=str[j];
		}
	}
	cout << mstr << " " << lstr << endl;
}

Measured memory_bytes: 0
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
       K: usize,
    }

    let mut ans: u64 = 0;
    for i in 1..=K {
        for j in 1..=K {
            for k in 1..=K {
                ans += gcd(gcd(i as u64, j as u64), k as u64);
            }
        }
    }

    echo!(ans);
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <cmath>
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
 
typedef long long lli;
typedef long li;
typedef pair<int,int> PI;
typedef pair<long,int> PLI;
typedef pair<int,long> PIL;
typedef pair<long, long> PL;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<long> VL;
typedef vector<long long> VLL;
typedef priority_queue<int> PQ;
typedef priority_queue<long> PQL;
typedef priority_queue<long long> PQLL;
#define FAST ios::sync_with_stdio(0)
#define forz(n) for (long i = 0; i < n; i++)
#define forv(i,x,y) for (long i=x; i<y; i++)
#define rforz(a,n) for (long i = a; i < n; i++)
#define forlz(n) for (long int i = 0; i < n; i++)
#define TRAV(it, v) for(auto it = v.begin(); it != v.end(); it++) 
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define SQ(a) (a)*(a)
#define UM unordered_map
#define US unordered_set
#define LB(v,x) lower_bound(v.begin(),v.end(),x);
#define UB(v,x) upper_bound(v.begin(),v.end(),x);
#define CUBE(a) (a)*(a)*(a)
#define SORT(v) sort(v.begin(),v.end());
#define SORTC(v,c) sort(v.begin(),v.end(),c);
#define Pi 3.14159265358979323846
 
 
#define module 1000000007
 
 
lli gcd(lli x,lli y){
    if(x==0) return y;
    return gcd(y%x,x);
}
 
PL Egcd(lli x,lli y){
    if(x==0) return MP(0,1);
    PL t=Egcd(y%x,x);
    return MP(t.S-t.F*(y/x),t.F);
}
 
 
lli powerget(lli y, lli x) { 
    lli temp; 
    if( y == 0) 
        return 1; 
    temp = powerget(y/2, x); 
    if (y%2 == 0) 
        return (temp*temp); 
    else{
        lli t = (temp*temp);
        t = t;
        return (x*t); 
    }
} 
 

void solve2(){
    int n,k;
	cin>>n>>k;
	string str;
	cin>>str;
	str[k-1] = (str[k-1]-'A' + 'a');
	cout<<str<<'\n';
}   
 
int main(){
    FAST;
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    //=====================================code starts here
    // lli n;
    // cin>>n;
    // while(n--){
        solve2();
    // }
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast
    ll n,d;
    cin>>n>>d;
    d = 2*d+1;
    ll ans = n/d;
    ll a = n%d;
    if(a!=0)
    {
        ans++;
    }
    cout<<ans<<endl;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_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 Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,c;
  cin >> n >> c;
  vector<vll> d(c, vll(c));
  REP(i, c){
    REP(j, c)
      cin >> d[i][j];
  }

  vector<vll> color(n, vll(n));
  REP(i, n){
    REP(j, n){
      cin >> color[i][j];
      color[i][j]--;
    }
  }



  vector<vector<vll>> dd(3, vector<vll>(c, vll(c, 0)));
  REP(i, n){
    REP(j, n){
      ll remind = (i+j)%3;
      ll X = color[i][j];
      REP(Y, c)
        dd[remind][X][Y] += d[X][Y];
    }
  }

  ll ans = LLINF;
  REP(i, c){
    REP(j, c){
      REP(k, c){
        if(i == j || i == k || j == k)
          continue;

        ll sum = 0;
        REP(X, c){
          sum += dd[0][X][i];
          sum += dd[1][X][j];
          sum += dd[2][X][k];
        }

        ans = min(ans, sum);
      }
    }
  }

  cout << ans << endl;
}


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

int main(){
	int n, i, ans=0;
	cin >> n;
	int v[n], c[n], a[n];
	for(i=0; i<n; i++){
		cin >> v[i];
	}
	for(i=0; i<n; i++){
		cin >> c[i];
	}
	for(i=0; i<n; i++){
		a[i] = v[i]-c[i];
	}
	
	for(i=0; i<n; i++){
		if(a[i]>0)	ans += a[i];
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
while 1:
    try:
        i = raw_input()
        a, b, c, d, e, f = map(float, i.split())
        y = ((c * d) - (a * f)) / ((b * d) - (a * e))
        x = (c - (b * y)) / a
        print "%.3f %.3f" % (x, y)
    except:
        break

Measured memory_bytes: 4220
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int parameter = 2*x + 2*y;
        int area = x*y;
        System.out.println(area + " " + parameter);
    }
}


Measured memory_bytes: 26148
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
static const int MAX = 1000000;
static const int NIL = -1;
int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
    stack<int> S;
    S.push(r);
    color[r] = c;
    while( !S.empty()) {
        int u = S.top(); S.pop();
        for(int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if(color[v] == NIL) {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    for (int i = 0; i < n; i++) color[i] = NIL;
    for (int u = 0; u < n; u++) {
        if(color[u] == NIL) dfs(u, id++);
    }
}

int main() {
    int s,t,m,q;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();
    cin >> q;
    for(int i = 0; i < q; i++) {
        cin >> s >> t;
        if(color[s] == color[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 30020
n = int(input())
ans = 0
if n < 10:
    print(n)
elif n >= 100000:
    print(90909)
elif n >= 10000:
    print(909+n-10000+1)
elif n >= 1000:
    print(909)
elif n >= 100:
    print(9+n-100+1)
elif n >= 10:
    print(9)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define N 500007
#define ll long long
int sum[N],n,m;
struct str
{
    int l,r,d;
}p[N];
bool operator <(str a,str b)
{
    return a.d<b.d;
}
void add(int x,int d)
{
    if(!x)return;
    for(;x<=m;x+=x&-x)
	sum[x]+=d;
}
void mody(int l,int r,int d)
{
    add(l,d),add(r+1,-d);
}
int query(int x)
{
    int ans=0;
    for(;x;x-=x&-x)
	ans+=sum[x];
    return ans;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
	scanf("%d%d",&p[i].l,&p[i].r),p[i].d=p[i].r-p[i].l;
    sort(p+1,p+n+1);
    int j=1;
    for(int d=1;d<=m;d++)
    {
	while(j<=n&&p[j].d<d)mody(p[j].l,p[j].r,1),j++;
	int ans=n-j+1;
	for(int i=d;i<=m;i+=d)
	    ans+=query(i);
	printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 7168
pre_n, city_n = map(int, input().split())
cities = [list(map(int, input().split())) for x in range(city_n)]

history = {}

A = {}

for x in sorted(cities):
    pref = str(x[0])
    if pref not in history:
        history[pref] = '1'

    A.setdefault(str(x), '0'*(6-len(pref)) + pref + '0'*(6-len(history[pref])) + history[pref])

    history[pref] = str(int(history[pref]) + 1)

for x in cities:
    print(A[str(x)])


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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2 * i
#define rc(i) 2 * i + 1
//#define int long long
using namespace std;
using vi = vector<int>;
using ii = pair<int, int>;

const int MAXN = 1e5, INF = 1e9 + 5, MOD = 1e9 + 7;

struct SegmentTree {
    int n;
    vector<int> t;

    int merge(int x, int y) { return x + y; }

    void build() {
        for (int i = n - 1; i > 0; i--) t[i] = merge(t[lc(i)], t[rc(i)]);
    }

    SegmentTree(int x, vector<int> a) {
        n = x;
        t.resize(2 * n);
        for (int i = 0; i < n; i++) t[i + n] = a[i];
    }

    void modify(int p, int val) {
        for (t[p += n] = val; p /= 2;) t[p] = merge(t[lc(p)], t[rc(p)]);
    }

    int query(int l, int r) {
        int res = 0;
        for (l += n, r += n; l < r; l /= 2, r /= 2) {
            if (l & 1) res = merge(res, t[l++]);
            if (r & 1) res = merge(res, t[--r]);
        }
        return res;
    }
};

signed main() {
    FAST_IO;
//    setIO("input.txt", "output.txt");

    int n, q;
    cin >> n >> q;
    vi a(n);
    trav(x, a) {
        cin >> x;
        x--;
    }
    vector<ii> queries[n];
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        queries[r].eb(l, i);
    }
    vi last(n, -1), ans(q);
    SegmentTree freq(n, vi(n, 0));
    for (int i = 0; i < n; i++) {
        if (last[a[i]] != -1) freq.modify(last[a[i]], 0);
        last[a[i]] = i;
        freq.modify(i, 1);
        for (auto query : queries[i]) {
            int l = query.first;
            int idx = query.second;
            ans[idx] = freq.query(l, i + 1);
        }

    }
    for (int i = 0; i < q; i++) cout << ans[i] << "\n";
}


Measured memory_bytes: 36428
a,b,c,x = 4.times.map{gets.to_i}
ans = 0
for i in 0..a
  for j in 0..b
    for k in 0..c
      if 500*i+100*j+50*k == x
        ans += 1
      end
    end
  end
end
puts [ans,511].min

Measured memory_bytes: 1788
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
minnum = float('inf')
for i in range(M):
    x, y, z = map(int, input().split())
    minnum = min(a[x-1] + b[y-1] - z, minnum)

print(min(minnum, min(a) + min(b)))

Measured memory_bytes: 18736
N,M = map(int,input().split())
if N % 2:
    for i in range(M):
        print(1+i,N-i,sep=" ")
else:
    even = M // 2
    odd = M - even
    for i in range(odd):
        print(1+i,N-i,sep=" ")
    st = 1 + odd
    en = st + even * 2
    for i in range(even):
        print(st+i,en-i,sep=" ")

Measured memory_bytes: 78964
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <string.h>
#include <cmath>
#define MAXN 160100
using namespace std;
int N;
int a[30];
double f[30][MAXN];

void solve(){
    for (int i=1;i<MAXN;++i)
        f[1][i]=abs(i-a[1])*1.0/a[1];
    //for (int i=1;i<MAXN;++i)
        //printf("%d %.6lf\n",i,f[1][i]);
    for (int i=2;i<=N;++i)
        for (int j=1;j<MAXN;++j){
            double m=abs(j-a[i])*1.0/a[i];
            double tmp=MAXN;
            int p=sqrt(j);
            for (int k=1;k<=p;++k)
                if (j%k==0){
                tmp=min(tmp,f[i-1][k]);
                tmp=min(tmp,f[i-1][j/k]);
            }
            f[i][j]=max(m,tmp);
        }
    double Ans=MAXN;
    for (int i=1;i<MAXN;++i)
        Ans=min(Ans,f[N][i]);
    printf("%.8lf",Ans);
}


int main(){
    //freopen("input.txt","r",stdin);
    scanf("%d",&N);
    for (int i=1;i<=N;++i)
        scanf("%d",&a[i]);
    solve();
    return 0;
}

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

int N, M, C, sum=0;
long long ans=0;
int main(){
    cin >> N >> M;
    pair<int, int> v[N];

    for(int i = 0; i < N; i++) {
	cin >> v[i].first >> v[i].second;
    }
    sort(v, v+N);

    for(int i = 0; i < N; i++) {
	for(int j = 0; j < v[i].second; j++) {
	    ans += v[i].first ;
	    sum ++;
	    if(sum == M)
		break;
	}
	if(sum == M)
	    break;
    }

    
    cout << ans << endl; 
	      
}


Measured memory_bytes: 1024
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main extends App {

  val sc = new Scanner(System.in)
  val n = sc.nextInt()
  sc.nextLine()
  val d = sc.nextLine().split(" ").map(_.toInt)

  private val array: ArrayBuffer[Int] = ArrayBuffer.empty[Int]

  d.zipWithIndex.foreach { case (dn, i) => (i + 1 until d.length).foreach(j => array += dn * d(j)) }

  println(array.sum)
}


Measured memory_bytes: 25532
# reason about even and odd case separately (kind of)
"""
 12345
1.xx.x
2x..xx
3x..xx
4.xx.x
5xxxx.

 123456
1.xxxx.
2x.xx.x
3xx..xx
4xx..xx
5x.xx.x
6.xxxx.
"""

import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
mii=lambda:map(int,input().split())

n=int(input())

g=[[1]*n for _ in range(n)]

# do the X thing
n2=n-n%2
for i in range(n2):
    g[i][n2-1-i]=0
    g[n2-1-i][i]=0
g[n-1][n-1]=0

out=[]
for i in range(n):
    for j in range(i+1,n):
        if g[i][j]:
            out.append([i+1,j+1])
print(len(out))
for i,j in out:
    print("%d %d"%(i,j))


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

void solve() {
    int n;
    cin >> n;
    
    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < s.size() - 2; i++) {
        if (s.substr(i, 3) == "ABC")
            ans++;
    }
    cout << ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
def resolve():
    s = input()

    n = len(s)
    left = s[:(n-1)//2]
    right = s[(n+3)//2-1:]

    def is_palindrome(s):
        for i in range(len(s)//2):
            if s[i] != s[-i-1]:
                return False
        return True

    if is_palindrome(left) and is_palindrome(right) and is_palindrome(s):
        print('Yes')
    else:
        print('No')
resolve()

Measured memory_bytes: 38384
#region Using directives
using System;
using static System.Console;
using static System.Convert;
using System.Collections.Generic;
using System.Linq;
#endregion

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = (ReadLine()).Split();
            long N = ToInt64(s[0]);
            long M = ToInt64(s[1]);
            long K = ToInt64(s[2]);
            for (long i = 0; i <= N; i++)
            {
                long answ = 0;
                for(long j = 0; j <= M; j++)
                {
                    answ = i*j + (N-i)*(M-j);
                    if (answ == K)
                    {
                        WriteLine("Yes");
                        ReadKey();
                        return;
                    }
                }
            }
            WriteLine("No");
            ReadKey();
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>
#include<set>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = (n-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

long long gcd(long long x, long long y){
    if (x > y)
        return gcd(y, x);
    
    long long m = 1;
    while(m != 0){
        m = y % x;
        y = x;
        x = m;
    }
    return y;
}

int main(){
    int n; long x; cin >> n >> x;
    long ans; cin >> ans; ans = abs(ans - x);

    rep(i, n - 1){
        int y; cin >> y;
        ans = gcd(ans, abs(y - x));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*
g++ -std=c++14 -o2 -Wall ABC121B.cpp -o .\out\ABC121B.out
.\out\ABC121B.out
*/

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

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, c;
  int b[25];
  int a[25][25];
  cin >> n >> m >> c;
  for (int i = 0; i < m; ++i) cin >> b[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> a[i][j];
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int temp = c;
    for (int j = 0; j < m; ++j) {
      temp += a[i][j]*b[j];
    }
    if (temp > 0) ++ans;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
def main(): 
    a,b =map(int, input().split())
    i = a -1
    cnt = 1

    while True:
        if a >= b:
            break
        a += i
        cnt += 1

    if(b == 1):
        cnt = 0

    print(cnt)
if __name__ == "__main__":
    main() 

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<ctype.h>

typedef long long ll;

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

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

ll asc(const void* a, const void* b) { return *(ll*)a - *(ll*)b; }

ll dsc(const void* a, const void* b) { return *(ll*)b - *(ll*)a; }

int main() {
    ll n;
    char c[200000];
    scanf("%lld", &n);
    scanf("%s",c);
    ll r=0, w=0;
    for (int i = 0; i < n; i++) {
        if (c[i] == 'R') r++;
    }
    for (int i = 0; i < r; i++) {
        if (c[i] == 'W') w++;
    }
    printf("%lld",w);
    return 0;
}

Measured memory_bytes: 2348
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();

        long min = A * (N - 1) + B;
        long max = A + (N - 1) * B;

        out.println(Math.max(0, max - min + 1));
    }
}

Measured memory_bytes: 21460
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=3005,mod=1000000007;
typedef long long LL;
char S[N];
int n,m,s[N],x[N],y[N],c[N][N],tot,l[N],r[N],maxn;
LL f[N][N];
struct data{int x,y;} dat[N];

int getint()
{
	char ch;
	int f=1;
	while(!isdigit(ch=getchar())) if(ch=='-') f=-1;
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x*f;
}

bool cmp(data a,data b)
{
	return a.x==b.x?a.y>b.y:a.x<b.x;
}

int main()
{
	n=getint(),m=getint(),scanf("%s",S+1);
	rep(i,0,n) c[i][0]=c[i][i]=1;
	rep(i,1,n) rep(j,1,i-1) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	rep(i,1,n) s[i]=s[i-1]+S[i]-48;
	rep(i,1,m) dat[i].x=getint(),dat[i].y=getint();
	sort(dat+1,dat+1+m,cmp);
	rep(i,1,m) if(dat[i].y>maxn) ++tot,x[tot]=dat[i].x,y[tot]=dat[i].y,maxn=dat[i].y;
	f[0][0]=1,x[tot+1]=y[tot+1]=n+1;
	rep(i,1,tot)
	{
		int w=min(y[i]-x[i]+1,x[i+1]-x[i]),a=s[y[i]]-s[max(x[i]-1,y[i-1])];
		l[i]=max(0,l[i-1]+a-w),r[i]=min(max(y[i]-x[i+1]+1,0),r[i-1]+a);
		rep(j,l[i],r[i])
			rep(k,l[i-1],r[i-1])
				f[i][j]=(f[i][j]+f[i-1][k]*c[w][k+a-j])%mod;
	}
	printf("%lld\n",f[tot][0]);
	return 0;
}

Measured memory_bytes: 65536