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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
	int n,k;
	scanf("%d %d",&n,&k);

	if(k>n/2){
		puts("-1");
		return 0;
	}

	bool odd=n&1;
	if(odd) n--;

	for(int p=0;p<k;++p){

		for(int i=0;i<n/2;++i){
			int a=(p+i)%n;
			int b=(p+n-1-i)%n;
			printf("%d %d\n",a+1,b+1);
		}


		for(int i=1;i<n/2;++i){
			int a=(p+i)%n;
			int b=(p+n-i)%n;
			printf("%d %d\n",a+1,b+1);
		}


		if(odd) printf("%d %d\n",p+1,n+1);
		if(p!=k-1) puts("");
	}
	return 0;
}

Measured memory_bytes: 1176
#include <stdio.h>

int main() {
	int n, a;

	scanf("%d", &n);
	while (n--) {
		scanf("%d", &a);
		if (a % 2 == 0 && a % 3 && a % 5) {
			printf("DENIED\n");
			return 0;
		}
	}
	printf("APPROVED\n");
	return 0;
}


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

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

    vector<int> h(n);
    bool judge=true;
    REP(i,n){
        cin>>h[i];
        if(i>0){
            if(h[i-1]==h[i]+1){
                h[i]++;
            }else if(h[i-1]>h[i]+1){
                judge=false;
                break;
            }
        }
    }

    cout<<(judge ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    
   string s;
   
   cin >> s;
   
   if(s=="Sunny"){
       
       cout << "Cloudy" <<endl;
   }
   
   if(s=="Cloudy"){
       
       cout << "Rainy"<<endl;
   }
   
   if(s=="Rainy"){
       
       cout << "Sunny"<<endl;
   }

  
  return 0;
}

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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    string s,t;
    cin>>s>>t;
    int ans=s.size();
    for(int i=0; i<=s.size()-t.size(); i++) {
        int curr=0;
        for(int j=0; j<t.size(); j++) {
            if(s[i+j]!=t[j])
                curr++;
        }
        ans = min(ans, curr);
    }
    cout << ans << '\n';
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, K, LR, RL, cnt;
string S;

int main(){
	cin >> N >> K >> S;
	for (int i = 0; i < N - 1; ++i) {
		if (S[i] == S[i + 1])++cnt;
		else if (S[i] == 'R') {
			++RL;
		}
		else {
			++LR;
		}
	}
	while (K--) {
		if (RL) {
			--RL;
			++cnt;
		}
		if (LR) {
			--LR;
			++cnt;
		}
	}
	cout << cnt << endl;
}

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

int main() {
    for (int H, W; cin >> H >> W, W;) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++)
                cout << (i != H - 1 && j != W - 1 && i && j ? '.' : '#');
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define MAXN int(10e5+3)
using namespace std;

int vet[MAXN];

int main() {
    int n, s;
    cin >> n >> s;
    int ac = 0, wa = 0;
    while(s--) {
        int a;
        string x;
        cin >> a;
        getchar();
        cin >> x;
        if(x == "WA" && vet[a] != -1)
            vet[a]++;
        else if(vet[a] != -1) {
            ac++;
            wa+=vet[a];
            vet[a] = -1;
        }
    }
    cout << ac << " " << wa << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

    Edge[] g;
    int n;


    void run() {
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        int m = sc.nextInt();

        g = new Edge[n];
        for (int i = 0; i < n; i++) {
            g[i] = new Edge();
            if (i != 0) g[i].add(new P(i - 1, 0));
        }

        for (int i = 0; i < m; i++) {
            int l = sc.nextInt() - 1, r = sc.nextInt() - 1, c = sc.nextInt();
            g[l].add(new P(r, c));
        }
        System.out.println(dijkstra());
    }

    long dijkstra() {
        long[] d = new long[n];
        Arrays.fill(d, 1L << 60);
        d[0] = 0;
        PriorityQueue<P> q = new PriorityQueue<>(Comparator.comparingLong(p -> p.c));
        q.add(new P(0, 0));

        while (!q.isEmpty()) {
            P cur = q.remove();
            if (cur.t == n - 1) return cur.c;
            if (cur.c != d[cur.t]) continue;

            for (P next: g[cur.t]) {
                if (d[next.t] > cur.c + next.c) {
                    d[next.t] = cur.c + next.c;
                    q.add(new P(next.t, cur.c + next.c));
                }
            }
        }
        return -1;
    }

    class Edge extends ArrayList<P> {}

    class P {
        int t;
        long c;
        P(int t, long c) {
            this.t = t;
            this.c = c;
        }
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }

}


Measured memory_bytes: 112040
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

a,b,c = map(int,input().split())
if b - a == c -b:
    print("YES")
else:
    print("NO")

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

using namespace std;

int N, M, t[200009];

int tata (int x)
{
    if (t[x] == x) return x;
    return t[x] = tata (t[x]);
}

void unite (int x, int y)
{
    x = tata (x), y = tata (y);
    if (x != y) t[x] = y;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
for (int i=1; i<=N + M; i++)
    t[i] = i;
for (int i=1; i<=N; i++)
{
    int l, x;
    scanf ("%d", &l);
    while (l --) scanf ("%d", &x), unite (i, N + x);
}
for (int i=2; i<=N; i++)
    if (tata (i) != tata (1))
    {
        printf ("NO\n");
        return 0;
    }
printf ("YES\n");
return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  int ans =0;
  for (int i=0;i<4;i++){
    if (a[i]=='+'){
      ans++;
    }
    else {
      ans--;
    }
  }
  cout << ans << endl;
}

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

using ll = long long;
// #define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

// MOD = 1000000007;
// MOD = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint COMB(ll n, ll r) {
  mint ret = 1;
  for(ll i=0; i<r; ++i) ret *= n-i;
  for(ll i=1; i<=r; ++i) ret /= i;
  return ret;
}

/***** MAIN *****/
signed main() {
  ll n, a, b;
  cin >> n >> a >> b;
  mint ans = mint(2).pow(n) - 1;
  ans -= COMB(n,a) + COMB(n,b);
  cout << ans.x % MOD;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  
  for (int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end(), greater<int>());
  
  int asum = 0;
  int bsum = 0;
  int j = 0;
  while(true){
    if (2*j == N){
      break;
    }
    asum += a.at(2*j);
    if (2*j + 1 == N){
      break;
    }
    bsum += a.at(2*j + 1);
    j++;
  }
  
  cout << asum - bsum << endl;
}

Measured memory_bytes: 256
n,k=map(int, input().split())
d=abs(n-k)
t=n//k
if n%k==0:
    print(0)
elif n>d:
    a=n-t*k
    if a>abs(a-k):
        print(abs(a-k))
    else:
        print(a)
else:
    print(n)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define u128 __int128
#define ss second
#define pb push_back

#define N 100010
#define MOD 1000000007

// ll n, m, k;

ll bexp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1)
			res = res * a;
		a *= a;
		b >>= 1;
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int ans = 0;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for(int i = 1; i < n - 1; ++i)
	{
		if((a[i] > a[i-1] && a[i] < a[i + 1]) || (a[i] < a[i-1] && a[i] > a[i + 1]))
			ans++;
	}
	cout << ans;
	return 0;
}

// int dpf(int last, int sum0, int sum1, int k)
// {
// 	if(k == m)
// 		return 1;
// 	for (int j = 0; j < n; ++j)
// 	{
// 		if(j != last && sum0 + vi[j] > sum1)
// 		{
// 			if(dpf(j, sum1, sum0 + vi[j], k + 1))
// 			{
// 				path[sum1] = j;
// 				return 1;
// 			}
// 		}
// 	}
// 	return 0;
// }


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

using namespace std;

int main()
{
    int k;
    string s;

    cin>>k>>s;

    if(k>=s.size())

        cout<<s<<"\n";

    else
    {
     string s1;
     s1=s.substr(0,k);
     cout<<s1<<"..."<<endl;
     
    }


    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 998244353;
const ull mod1 = 2e18 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 1e5 + 5;
int t;
int a[N], b[N];
int main()
{
	//freopen("in.txt", "r", stdin);
	int n;
	while (cin >> n)
	{
		f(i, 1, n) { scanf("%d", &a[i]); b[i] = a[i]; }
		sort(b + 1, b + 1 + n);
		ll ans = 0;
		f(i, 1, n)
		{
			f(j, i + 1, n)
			{
			//	debug(b[i] + b[j]);
				int idx = lower_bound(b + 1, b + 1 + n, b[i] + b[j])-b;
				idx--;
				//debug(idx), debug(j);
				ans += max(0, idx-j);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back
#define debug(x) cerr << #x << " = " << x << " "

ll product(l4 a, l4 b)
{
  return a.first*b.second-a.second*b.first;
}
ll len(l4 a)
{
  return a.first * a.first + a.second * a.second;
}
int main()
{
  int n;
  while (~scanf("%d", &n))
    {
      vector<l4> v(n);
      for (auto &e : v) scanf("%lld %lld", &e.first, &e.second);
      sort(v.begin(), v.end(), [&](const ii &l, const ii &r)
			       {
				 return atan2(l.second, l.first) < atan2(r.second, r.first);
			       });
      v.insert(v.end(), v.begin(), v.end());
      /*      cerr << v.size() << endl;
      for (auto e : v)
	cerr << e.first << ", " << e.second << endl;
      cerr << endl;
      */
      ll ans = 0;
      int r = 0;
      l4 sum(0, 0);
      auto update = [&]()
		    {
		      ans = max(ans, len(sum));
		    };
      for (int i = 0; i < n; ++i)
	{
	  sum = mp(0, 0);
	  for (int j = i; j < i+n; ++j)
	    {
	      sum.first += v[j].first;
	      sum.second += v[j].second;
	      update();
	    }
	}
      printf("%.10lf\n", sqrt(ans));
    }
}


Measured memory_bytes: 256
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    string s;
    cin>>s;

    lli N=s.length(),i;

    rep(i,0,N-1)
    {
        if(s[i]=='A' and s[i+1]=='C')
        {
            cout<<"Yes";
            exit(0);
        }
    }

    cout<<"No";




 return 0;
}


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  // std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n * 2);
  iota(begin(a), end(a), 1);
  cout << "?";
  for(int i = 0; i < n; i++) {
    cout << " " << a[i];
  }
  cout << endl;
  string s;
  cin >> s;
  int ok = 0, ng = n;
  // ちょうど 49 個になる数を探す
  // 単調性は無いが ok ~ ng 内には答えは存在する

  while(ng - ok > 1) {
    // ok で 50以上,
    // ng で 50未満
    int mid = (ng + ok) / 2;
    for(int i = 0; i < mid; i++) swap(a[i], a[i+n]);
    cout << "?";
    for(int i = 0; i < n; i++) {
      cout << " " << a[i];
    }
    cout << endl;
    string t;
    cin >> t;
    for(int i = 0; i < mid; i++) swap(a[i], a[i+n]);
    if(s != t) ng = mid; else ok = mid;
  }

  // ok で 50 以上
  // ng で 50 未満
  // ok + 1 == ng
  // =>
  // ng で 49

  for(int i = 0; i < ng; i++) swap(a[i], a[i+n]);
  // a[ng-1] == !s, a[ng-1 + n] == s

  set<int> ss;
  for(int i = 0; i < n; i++) ss.insert(i);
  ss.erase(ng-1);
  ss.insert(n+ng-1);

  for(int i = 0; i < n; i++) if(i != ng - 1) {
    swap(a[ng-1], a[i+n]);
    cout << "?";
    for(int i = 0; i < n; i++) {
      cout << " " << a[i];
    }
    cout << endl;
    string t;
    cin >> t;
    if(s == t) {
      ss.insert(i + n);
    }
    swap(a[ng-1], a[i+n]);

    swap(a[n+ng-1], a[i]);
    cout << "?";
    for(int i = 0; i < n; i++) {
      cout << " " << a[i];
    }
    cout << endl;
    cin >> t;
    if(s == t) {
      ss.erase(i);
    }
    swap(a[n+ng-1], a[i]);
  }

  string ans(n * 2, s == "Blue" ? 'R' : 'B');
  for(auto e : ss) {
    ans[a[e]-1] = s == "Blue" ? 'B' : 'R';
  }

  cout << "! " << ans << endl;

  return 0;
}


Measured memory_bytes: 724
#!/snap/bin/pypy3
from itertools import permutations
from math import sqrt, factorial


def main():
    n = int(input())

    points = [tuple(map(float, input().split())) for _ in range(n)]

    total_distance = 0.0
    for sample in permutations(range(n), n):
        total_distance += sum(sqrt((points[sample[i]][0] - points[sample[i + 1]][0])**2 + (points[sample[i]][1] - points[sample[i + 1]][1])**2) for i in range(n - 1))

    print(total_distance / factorial(n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 43628
// D - Non-decreasing
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

int main(){
	int N; cin>>N;
	int ix = 1, sign = 0;//-+ : min|max
	rp(i, 1, N+1){
		int a; cin>>a;
		if(abs(sign) < abs(a)){ sign = a; ix = i; }
	}

	cout<< 2*N-1 <<endl;
	rp(i, 1, N+1) printf("%d %d\n", ix,i);

	if(sign < 0) irp(i, N, 1) printf("%d %d\n", i,i-1);
	else rp(i, 1, N) printf("%d %d\n", i,i+1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 305
#define pi pair<int,int>
#define mk make_pair
#define Mod 1000000007
using namespace std;
int n,m,x,y,z,dp[N][N][N];
vector<pi>G[N];
inline bool check(int x,int y,int z){
	int pos=max(x,max(y,z));
	if (x<y) swap(x,y);if (x<z) swap(x,z);
	if (y<z) swap(y,z);
	for (int i=0;i<(int)G[pos].size();i++){
		int l=G[pos][i].first;
		int limit=G[pos][i].second;
		if (limit==3) if (z<l) return 0;
		if (limit==2){
			if (y<l) return 0;
			if (z>=l) return 0;
		}
		if (limit==1) if (y>=l) return 0;
	}
	return 1;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		scanf("%d%d%d",&x,&y,&z);
		G[y].push_back(mk(x,z));
	}
	dp[0][0][0]=1;
	for (int i=0;i<=n;i++){
		for (int j=0;j<=n;j++){
			for (int k=0;k<=n;k++){
				if (!dp[i][j][k]) continue;
				int nxt=max(i,max(j,k))+1;
				if (check(nxt,j,k)) dp[nxt][j][k]=1ll*(dp[nxt][j][k]+dp[i][j][k])%Mod;
				if (check(i,nxt,k)) dp[i][nxt][k]=1ll*(dp[i][nxt][k]+dp[i][j][k])%Mod;
				if (check(i,j,nxt)) dp[i][j][nxt]=1ll*(dp[i][j][nxt]+dp[i][j][k])%Mod;
			}
		}
	}
	int ans=0;
	for (int i=0;i<=n;i++)
		for (int j=0;j<=n;j++){
			ans=(ans+dp[n][i][j])%Mod;
			ans=(ans+dp[i][n][j])%Mod;
			ans=(ans+dp[i][j][n])%Mod;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 110848
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import bisect
import math

def div(a, b):
    if a % b == 0:
        return a // b
    else:
        return (a // b) + 1

def main():
    num = int(input())
    vote_a, vote_b = 1, 1
    for i in range(num):
        a, b = map(int, input().split())
        aaa = div(vote_a, a)
        bbb = div(vote_b, b)
        ccc = max(aaa, bbb)
        vote_a, vote_b = a * ccc, b * ccc

    print(vote_a + vote_b)





if __name__ == '__main__':
    main()


Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define fi first
#define se second
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
map<ll, ll> rev;
map<ll, int> cnt;
int n;
const int mxs = 3000;
bool bpr[mxs];
int prs[mxs], prcnt = 0;
int main() {
	for (int i = 0; i < mxs; i++)
		bpr[i] = 1;
	for (int i = 2; i < mxs; i++)
		if (bpr[i]) {
			prs[prcnt++] = i;
			for (int j = 2; j * i < mxs; j++)
				bpr[j * i] = 0;
		}
	cin >> n;
	for (int i = 0; i < n; i++) {
		ll u;
		scanf("%lld", &u);
		ll bk = 1, ns = 1;
		for (int j = 0; j < prcnt; j++) {
			int pr = prs[j], tt = 0;
			while (u % pr == 0) {
				tt++, u /= pr;
			}
			tt %= 3;
			if (tt == 1) ns = ns * pr, bk = bk * pr * pr;
			if (tt == 2) ns = ns * pr * pr, bk = bk * pr;
		//	if (bk > 1e10) bk = 0;
		}
		if (u != 1) {
			ll sq = int(sqrt(u) + 0.5);
			ns *= u;
			if (sq * sq == u) bk *= sq;
			else {
		//		if (1.0 * bk * u * u > 1e11) bk = 0;
				bk = bk * u * u;
			}
		}
		rev[ns] = bk, cnt[ns]++;
	//	cout << ns << ' ' << bk << endl;
	}
	ll tot = 0;
	#define iter map<ll, int>::iterator
	for (iter i = cnt.begin(); i != cnt.end(); i++) {
		ll nr = i->fi, nx = rev[nr];
		if (i->se == 0) continue;
		if (cnt[nx] && nx < nr) continue;
		if (nr == 1) tot++;
		else
			tot += max(cnt[nr], cnt[nx]);
	}
	cout << tot << endl;
	return 0;
}


Measured memory_bytes: 23680
def main():
    b = int(input())
    l_A = [int(i) for i in input().split()]
    l_B = [int(i) for i in input().split()]
    l_C = [int(i) for i in input().split()]

    last = -100
    ans = 0
    for A in l_A:
        ans += l_B[A-1]
        if A - last - 1 == 1:
            ans += l_C[A - 2]
        last = A-1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int x,a,b;
int main()
{
	scanf("%d%d%d",&x,&a,&b);
	int t=(x-a)/b;
	x=x-a-b*t;
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define gcd            __gcd
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x,y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    nitin;
    int cnt=0;
    int x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    int a=(x/d);
    int ans=abs((x-k*d));
    if( a<=k && (k-a)%2==0)
    {
        ans=min(ans,abs(x-a*d));
    }
    --a;
    if( a<=k && (k-a)%2==0)
    {
        ans=min(ans,abs(x-a*d));
    }
    ++a;
    if(a+1<=k && (k-(a+1))%2==0)
    {
        ans=min(ans,abs(x-(a+1)*d));
    }
    ++a;
    if(a+1<=k && (k-(a+1))%2==0)
    {
        ans=min(ans,abs(x-(a+1)*d));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define N 100010
using namespace std;
int a[N];
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++ i)
		scanf("%d", &a[i]);
	int x = (n - k) / (k - 1);
	if((n - k) % (k - 1) != 0)
		++ x;
	++ x;
	printf("%d", x);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;
const ll LINF = 1e18;

int main(){
  int n,v;
  vector<int> odd(100010),even(100010);
  cin >> n;
  rep(i,n/2){
    cin >> v; 
    odd[v]++;
    cin >> v;
    even[v]++;
  }
  vector<P> even_p,odd_p;
  for(int i=1;i<=100010;i++){
    even_p.push_back(P{even[i],i});
    odd_p.push_back(P{odd[i],i});
  }
  sort(rall(even_p));
  sort(rall(odd_p));
  int res = 0;
  if(even_p[0].second == odd_p[0].second){
    res = min(n-even_p[0].first-odd_p[1].first,n-even_p[1].first-odd_p[0].first);
  }else{
    res = n-odd_p[0].first-even_p[0].first;
  }
  
  cout << res << endl;
}

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

int main() {
  int N, Alice = 0, Bob = 0, num;
  priority_queue<int> a;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> num;
    a.push(num);
  }
  for(int i = 0; i < N; i++) {
  	if(i % 2) Bob += a.top();
    else Alice += a.top();
    a.pop();
  }
  cout << (Alice - Bob) << endl;
}

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

ll gcd(ll a, ll b){
	if(0 < b) return gcd(b, a%b);
	else return a;
//	return b ? gcd(b, a%b) : a;
}

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

ll f(ll a, ll b, ll c){
	ll ans = a;
	ans -= a/b;
	ans -= a/c;
	ans += a/lcm(b,c);
	return ans;
}

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

	ll ans = f(b,c,d) - f(a-1,c,d);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int INF=0x3f3f3f3f,maxn=1;
//vector<int>v[maxn];
//map<int,string>mp;
//queue<int>q;
int a[maxn],n,m;
int main()
{
	//int i,j,k,ans=0;
	long long x,y,z,w;
	x=y=z=w=0;
	cin>>x>>y;
	cin>>z>>w;
	if(w==1)
		cout<<"1"<<endl;
	else
		cout<<"0"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define int long long
#ifdef ONLINE_JUDGE
const int maxn = 3e5 + 10;
#else
const int maxn = 1e3 + 10;
#endif
using namespace std;
int L;
signed main()
{
    ios::sync_with_stdio(false);
    cin >> L;
    int cnt = 0;
    while ((1 << (cnt + 1)) <= L) {
        ++cnt;
    }
    vector<vector<int>> edges;
    int V = 2;
    for (ri i = 1; i <= cnt; ++i) {
        edges.push_back({ V - 1, V, 0 });
        edges.push_back({ V - 1, V, 1 << (i - 1) });
        ++V;
    }
    V -= 1;
    int sub = L - (1 << cnt), fuck = 1 << cnt;
    for (ri i = 1; i < V; ++i) {
        if (sub & 1 << (i - 1)) {
            edges.push_back({ i, V, fuck });
            fuck += 1 << (i - 1);
        }
    }
    cout << V << " " << edges.size() << endl;
    for (auto e : edges) {
        cout << e[0] << " " << e[1] << " " << e[2] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        int[] C = new int[N];

        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i] = scanner.nextInt();
        }
        for (int i = 0; i < N-1; i++) {
            C[i] = scanner.nextInt();
        }

        long ans = 0;
        int good = Integer.MIN_VALUE;
        for (int i = 0; i < N; i++) {
            ans += B[A[i]-1];
            if((good +1) == A[i]) {
                ans += C[A[i]-2];
            }
//                System.out.println("good = " + (good+1) + " a[i] " + A[i] );
            good = A[i];
//            System.out.println(" i = " + i + " ans" + ans + " B[i] " + B[A[i]-1]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
int main(void){
	int a,b;
	for(;scanf("%d%d",&a,&b)!=EOF;){
		int wa=a+b;
		int cnt=1;
		while(!(wa<10)){
			wa/=10;
			cnt++;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 600
N=list(input())
n=len(N)
M=0
X=Y=0
for i in N:
  M+=1
  if i=="A" :
    X=M
    break
M=0
for i in N[::-1]:
  M+=1
  if i=="Z":
    Y=M
    break
print(n+2-X-Y)
     

Measured memory_bytes: 6180
#include<stdio.h>

struct NU{int n;double m;int s;int S;};

int main(){
int n,s;
double m;
struct NU num[25],n2[18];
for(int i=0;i<3;i++){

for(int j=0;j<8;j++){
scanf("%d %lf",&n,&m);
num[j].n=n;num[j].m=m;
//printf("%d %lf[%d]\n",num[j].n,num[j].m,j);
}

for(int j=0;j<8;j++){
//	printf("%d %lf\n",num[j].n,num[j].m);
for(int k=8-1;k>j;k--){
if(num[k-1].m>num[k].m){struct NU t=num[k-1];num[k-1]=num[k];num[k]=t;}
}
}
for(int j=0;j<8;j++){
if(j<2)printf("%d %.2lf\n",num[j].n,num[j].m);
else if(j>=2&&i==0)n2[j-2]=num[j];
else if(j>=2&&i==1)n2[j-2+6]=num[j];
else if(j>=2&&i==2)n2[j-2+12]=num[j];
}
}

for(int j=0;j<19;j++){
for(int k=17;k>j;k--){
if(n2[k-1].m>n2[k].m){struct NU tt=n2[k-1];n2[k-1]=n2[k];n2[k]=tt;}
}
}

for(int j=0;j<2;j++){
if(j<2)printf("%d %.2lf\n",n2[j].n,n2[j].m);
//else if(j>=2)n2[j]=num[j];
}

return 0;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stdio.h>
#include <string.h>

#define rep(i, n) for (int i = 0; i < n; ++i)
typedef uint64_t ll;

using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> A,ball;
    A.assign(n, 0);
    ball.assign(n, 0);
    vector<ll> combi;
    combi.assign(n, 0);
    rep(i, n)
    {
        cin >> A[i];
        ball[A[i]-1] += 1;
    }
    ll cnt = 0;
    rep(i, n)
    {
        if(ball[i] > 1 ){
            if (ball[i]%2 == 0){
                combi[i] = ball[i] / 2;
                combi[i] *= ball[i] - 1;
                cnt += combi[i];
            }else{
                combi[i] = (ball[i]-1) / 2;
                combi[i] *= ball[i] ;
                cnt += combi[i];
            }
        }
    }
    ll out_result,out_result2,out_result3;
    rep(i, n)
    {
        if (ball[A[i]-1] > 1){
            if (ball[A[i]-1]%2 == 0){
                out_result = (ball[A[i]-1] - 2) / 2;
                out_result *= ball[A[i]-1] - 1;
            }else{
                out_result = (ball[A[i]-1] - 1) / 2;
                out_result *= ball[A[i]-1] - 2;
            }
            out_result2 = cnt - combi[A[i]-1];
            out_result3 = out_result + out_result2;
//            out_result = cnt - combi[A[i]] + out_result;
            cout << out_result3 << endl;
        }
        else
        {
            cout << cnt << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7296
from math import sqrt
n = int(input())

for i in range(n):
    l = input()
    x1,y1,x2,y2,x3,y3=map(float,l.split(' '))
    a_2 = (x1 - x2)**2 + (y1 - y2)**2
    b_2 = (x2 - x3)**2 + (y2 - y3)**2
    c_2 = (x3 - x1)**2 + (y3 - y1)**2
    cos_a_2 = (b_2 + c_2 - a_2)**2/(4* b_2 * c_2)
    sin_a_2 = 1 - cos_a_2
    r = round(sqrt(a_2/sin_a_2)/2,3)
    a = (x1**2 - x3**2 + y1**2 - y3**2)*(x2 - x1)
    b = (x1**2 - x2**2 + y1**2 - y2**2)*(x3 - x1)
    c = (y2 - y1)*(x3 - x1)
    d = (y3 - y1)*(x2 - x1)
    py = round((a-b)/(c-d)/2,3)
    a = (x1**2 - x3**2 + y1**2 - y3**2)*(y2 - y1)
    b = (x1**2 - x2**2 + y1**2 - y2**2)*(y3 - y1)
    c = (x2 - x1)*(y3 - y1)
    d = (x3 - x1)*(y2 - y1)
    px = round((a-b)/(c-d)/2,3)
    print('%.3f %.3f %.3f' %(px, py, r))

Measured memory_bytes: 7632
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_ABC172
{
    class MainClass
    {


        public static void Main(string[] args)
        {
            string s = ReadLine();
            string t = ReadLine();
            int l = s.Length;
            int ans = 0;
            
            for(int i =0;i<l;i++){
                if(s[i]!=t[i]) ans++;
                
            }
            WriteLine(ans);
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

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

    sort(all(h));
    int m = 1001001001;
    rep(i, n-k+1){
        m = min(m, h[i+k-1]-h[i]);
    }

    cout << m << endl;
    return 0;
}


Measured memory_bytes: 640
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		BigInteger cnt = BigInteger.ZERO;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (i * j < n) {
					cnt = cnt.add(BigInteger.ONE);
				} else {
					break;
				}
			}
		}
		System.out.println(cnt);
	}
}


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

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

  double sum = 0;

  for(int i = 0; i < n; i++){
    double x;
    string u;

    cin >> x >> u;

    if(u == "BTC") sum += x * 380000.0;
    else sum += x;

  }

  printf("%.6f\n", sum);

  return 0;

}



Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long sum = 0;
    for(long i=1;i<=Math.sqrt(n);i++){
      if(n%i==0){
        long y = n/i;
        if(y==1)continue;
        if(n/(y-1)==n%(y-1))sum+=y-1;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 23636
#include<stdio.h>
int main(){
  int a,b,c,n,i,j,m[3],temp,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&a,&b,&c);
    m[0]=a;
    m[1]=b;
    m[2]=c;
    for(v=0;v<2;v++){
      for(j=2;j>v;j--){
	if(m[j]<m[j-1]){
	  temp=m[j];
	  m[j]=m[j-1];
	  m[j-1]=temp;
	}
      }
    }
    a=m[0];
    b=m[1];
    c=m[2];
    if((a*a)+(b*b)==(c*c)){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
  }
  return (0);
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int d;
		for ( int i=0; i<m; i++) {
			d = sc.nextInt();
			n -= d;
		}
		if (n < 0) {
			n = -1;
		}


		sc.close();
		System.out.println(n);
	}
}


Measured memory_bytes: 38016
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int ans=0,n=s.length();
  for(int i=0;i<n;i++)
  {
    if(s[i]!=t[i])
      ans++;
  }
  cout<<ans;
}

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

using namespace std;

int main(void) {
	string n;
	cin >> n;
	int count = 0;
	for (int i = 0; i < 4; i++) {
		if (n[i] == '2') {
			count++;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n;
  scanf("%d", &n);
  v1i a(n-1), b(n-1), c(n-1);
  rep(i, n-1) scanf("%d %d %d", &a[i], &b[i], &c[i]);
  rep(i, n){
    int t = 0;
    rep(j, n-1-i){
      if(t <= b[i+j]) t = b[i+j] + a[i+j];
      else t = ((t-b[i+j]-1)/c[i+j]+1)*c[i+j]+b[i+j]+a[i+j];
    }
    printf("%d\n", t);
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var d = ab[1] - ab[0];
        var poles = new int[] { 0, 0 };
        var i = 0;
        while (i < d)
        {
            i++;
            poles[i % 2] = poles[(i - 1) % 2] + i;
        }
        Console.WriteLine(poles[i % 2] - ab[1]);
    }
}


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

int main() {
	
	int n;
	cin >> n;
	vector<int> digit(4);
	rep(i, 4){
		digit[i] = n % 10;
		n /= 10;
	}
	string ans = "No";
	if(digit[0] == digit[1] && digit[1] == digit[2]) ans = "Yes";
	else if(digit[1] == digit[2] && digit[2] == digit[3]) ans = "Yes";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate

def solve(n,k,a):
    for _ in range(k):
        if a==[n]*n:    return a
        t = [0]*(n+1)
        for i,x in enumerate(a):
            t[max(0,i-x)] += 1
            t[min(n,i+x+1)] -=1
        a = list(accumulate(t))[:-1]
    return a

n,k = map(int,sys.stdin.readline().rstrip().split())
a = list(map(int,sys.stdin.readline().rstrip().split()))

print(*solve(n,k,a))

Measured memory_bytes: 178960
g=[[0]*5 for _ in[0]*5]
for i in range(9):
 e=input()
 for j in range(4+i%2):
  if int(e[j]):
   if i%2:g[i//2][j]+=4;g[i//2+1][j]+=1
   else:r=g[i//2];r[j]+=2;r[j+1]+=8
y,x=0,1
k=1
a=[1]
while 1:
 k+=2
 for _ in[0]*4:
  k+=1
  if g[y][x]&int(2**(k%4)):a+=[k%4];break
 if k%2:x+=1-2*((k%4)>1)
 else:y+=2*((k%4)>0)-1
 if x+y==0:break
print(''.join('URDL'[c]for c in a))


Measured memory_bytes: 5604
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

v_odd = v[1::2]
v_even = v[0::2]

v_odd_mc = Counter(v_odd).most_common()
v_even_mc = Counter(v_even).most_common()

v_odd_mc.append((0, 0))
v_even_mc.append((0, 0))

if v_odd_mc[0] != v_even_mc[0]:
    print(n-v_odd_mc[0][1]-v_even_mc[0][1])
else:
    print(n - max(v_odd_mc[0][1] + v_even_mc[1][1], v_odd_mc[1][1]+v_even_mc[0][1]))
    # print(min(n - v_odd_mc[0][1] - v_even_mc[1][1], n - v_odd_mc[1][1] - v_even_mc[0][1]))

Measured memory_bytes: 21084
#include <bits/stdc++.h>
using namespace std;
const long mod=1e9+7;

int main() {
  string S;
  cin >> S;
  long dpa[S.length()];
  long dpb[S.length()];
  dpa[0]=1;
  dpb[0]=2;
  for(int i=1;i<S.length();i++){
    if(S[i]=='0'){
      dpa[i]=3*dpa[i-1]%mod;
      dpb[i]=dpb[i-1];
    }
    else{
      dpa[i]=(3*dpa[i-1]+dpb[i-1])%mod;
      dpb[i]=2*dpb[i-1]%mod;
    }
  }
  cout << (dpa[S.length()-1]+dpb[S.length()-1])%mod;
}




Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> v(m);
    for (int i = 0; i < m; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    vector<pair<int, int> > v2(m);
    for (int i = 0; i < m; ++i) {
        v2[i].second = v[i];
    }
    for (int i = 0; i < m - 1; ++i) {
        v2[i].first = v[i + 1] - v[i];
    }
    sort(v2.begin(), v2.end() - 1, greater<pair<int, int> >());
    int c[n - 1];
    for (int i = 0; i < n - 1; ++i) {
        c[i] = v2[i].second; //差が大きい上から前者
    }
    sort(c, c + n - 1);
    /*
    for (int i = 0; i < n - 1; ++i) {
        cout << c[i] << " ";
        if (i == n - 2) cout << endl;
    }*/
    long long sum = 0;
    int flg = 0;
    //この辺のindexは実際の数でimage
    for (int i = 0; i < m - 1; ++i) {
        if (flg < n - 1 && c[flg] == v[i]) {
            flg++;
            continue;
        }
        sum += v[i + 1] - v[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split(" ")))

A.sort()
if A[-1] < 0:
    s = A[-1]
    sa_list = []
    for a in A[:-1]:
        sa_list.append((s, a))
        s -= a
    print(s)
    for s, a in sa_list:
        print(s, a)
elif 0 <= A[0]:
    s = A[0]
    sa_list = []
    for a in A[1:-1]:
        sa_list.append((s, a))
        s -= a
    sa_list.append((A[-1], s))
    A[-1] -= s 
    print(A[-1])
    for s, a in sa_list:
        print(s, a)
else:
    s = A[-1]
    sa_list = []
    end = None
    for i, a in enumerate(A):
        if i == 0:
            continue
        if 0 <= a:
            end = i
            break
        sa_list.append((s, a))
        s -= a
    t = A[0]
    for a in A[end:-1]:
        sa_list.append((t, a))
        t -= a
    sa_list.append((s, t))
    s -= t
    print(s)
    for s, a in sa_list:
        print(s, a)

Measured memory_bytes: 20212
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)

int N,M,Q;
char str[2005];
int fk[2005][2005],f2[2005][2005],f3[2005][2005];

int main(){
	scanf("%d%d%d",&N,&M,&Q);
	F(i,1,N){
		scanf("%s",str+1);
		F(j,1,M){
			if(str[j]=='1'){
				fk[i][j]=1;
				if(fk[i-1][j]) f2[i-1][j]=1;
				if(fk[i][j-1]) f3[i][j-1]=1;
			}
		}
	}
	F(i,1,N) F(j,1,M)
		fk[i][j]+=fk[i-1][j]+fk[i][j-1]-fk[i-1][j-1],
		f2[i][j]+=f2[i-1][j]+f2[i][j-1]-f2[i-1][j-1],
		f3[i][j]+=f3[i-1][j]+f3[i][j-1]-f3[i-1][j-1];
	F(i,1,Q){
		int X1,Y1,X2,Y2;
		scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
		int Dots=fk[X2][Y2]-fk[X1-1][Y2]-fk[X2][Y1-1]+fk[X1-1][Y1-1];
		int Edges=f2[X2-1][Y2]-f2[X1-1][Y2]-f2[X2-1][Y1-1]+f2[X1-1][Y1-1]+f3[X2][Y2-1]-f3[X1-1][Y2-1]-f3[X2][Y1-1]+f3[X1-1][Y1-1];
		printf("%d\n",Dots-Edges);
	}
	return 0;
}

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

 

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), diff;
    ll lack = 0;
    ll excess = 0;
    int ans = 0;
    rep(i,N) cin >> A.at(i);
    rep(i,N) cin >> B.at(i);
    rep(i,N) {
        if (A.at(i) < B.at(i)) {
            ++ans;
            lack += B.at(i) - A.at(i);
        }
        else if (A.at(i) > B.at(i)) {
            excess += A.at(i) - B.at(i);
            diff.push_back(A.at(i) - B.at(i));
        }
    }
    if (!diff.empty()) sort(diff.begin(), diff.end(), greater<ll>());
    if (lack > excess) cout << -1 << endl;
    else {
        int i = 0;
        while (lack > 0) {
            ++ans;
            lack -= diff.at(i);
            ++i;
        }
        cout << ans << endl;
    }
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  if (N >= M) {
    cout << 0 << endl;
  }
  else {
    vector<int64_t> X(M);
    for (int i = 0; i < M; i++) {
      cin >> X.at(i);
    }
    sort(X.begin(), X.end());
    
    vector<int> R(M-1);
    for (int i = 0; i < M-1; i++) {
      R.at(i) = X.at(i+1) - X.at(i);
    }
    
    sort(R.begin(), R.end());
    reverse(R.begin(), R.end());
    
    int sum = 0;
    for (int i = 0; i < N-1; i++) {
      sum += R.at(i);
    }
    
    cout << X.at(M-1) - X.at(0) - sum << endl;
  }
}

    
    
    

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if(s*t >= d) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

const int VMAX=10010;
int V,E;
vector<vector<pair<int,int>>> edge;
bool used[VMAX];
long long MST(int start){
    if(V==1) return 0;
    rep(i,VMAX) used[i]=0;
    // {cost,{from,to}}
    priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> pq;
    for(auto e:edge[start]){
        pq.push({e.second,{start,e.first}});
    }
    long long ret=0;
    int cnt=1;
    while(pq.size()||cnt<V){
        auto e=pq.top(); pq.pop();
        int cost=e.first,from=e.second.first,to=e.second.second;
        used[from]=1;
        if(!used[to]){
            ret+=cost;
            used[to]=1;
            cnt++;
            for(auto e:edge[to]){
                pq.push({e.second,{to,e.first}});
            }
        }
    }
    return (cnt==V?ret:-1);
}
int main(){
    cin>>V>>E;
    edge.resize(V);
    int start;
    rep(i,E){
        int from,to,cost; cin>>from>>to>>cost;
        start=from;
        edge[from].push_back({to,cost});
        edge[to].push_back({from,cost});
    }
    cout<<MST(start)<<endl;
    return 0;
}



Measured memory_bytes: 8856