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

int main ()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if (a+b > c+d)
    cout<< "Left" << endl;
    else if (a+b < c+d)
    cout<< "Right" << endl;
    else 
    cout<< "Balanced" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int32_t main() {
	FAST
	int n;
	cin >> n;
	cout << n*n*n << endl;
}


Measured memory_bytes: 256
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)



priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
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; }


void solve(){
    string s;
    cin >> s;
    int ans=0;
    if(s=="RRR")ans=3;
    if(s=="RRS")ans=2;
    if(s=="SRR")ans=2;
    if(s=="RSR")ans=1;
    if(s=="SRS")ans=1;
    if(s=="SSR")ans=1;
    if(s=="RSS")ans=1;
    if(s=="SSS")ans=0;
    cout << ans << endl;
    
}

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





Measured memory_bytes: 3632
#include<iostream> 
#include<vector>
#include<algorithm>
#include<queue>
#include<stdio.h>
#include<vector>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool ans=true;
  int l=s.size();
  for(int i=0;i<l;i++){
    if(i%2){
      if(s[i]=='R')ans=false;
    }
    else {
      if(s[i]=='L')ans=false;
    }
  }
  puts(ans?"Yes":"No");
  return 0;
}

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

int main(){
  int n, q;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  cin >> q;
  int k[q];
  for(int i = 0; i < q; i++){
    cin >> k[i];
  }
  for(int i : k){
    int lb = lower_bound(a.begin(), a.end(), i) - a.begin();
    int ub = upper_bound(a.begin(), a.end(), i) - a.begin();
    cout << lb << " " << ub << endl;
  }
  return 0;
}


Measured memory_bytes: 3888
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}

int main() {
	ll N;
	cin >> N;
	vector<pair<ll, ll>> A(N);
	vector<vector<ll>> TF(19, vector<ll>(19));
	rep(i, 19) {
		rep(j, 19) {
			TF.at(i).at(j) = 0;
		}
	}
	rep(i, N) {

		bool ten = false;
		string S;
		cin >> S;
		ll a = 0;
		ll k = 0;
		rep(j, S.size()) {
			if (S.at(j) == '.') {
				ten = true;
				continue;
			}
			if (ten) {
				k++;
			}
			int c = S.at(j) - '0';
			a = a * 10 + c;
		}
		ll t = 0, f = 0;
		/*cout << a;*/
		rep(j, 9 - k) {
			t++;
			f++;
		}

		while (a % 2 == 0) {
			t++;
			a /= 2;
		}
		while (a % 5 == 0) {
			f++;
			a /= 5;
		}
		/*cout <<"AAA"<< t <<"DDD"<< f << endl;*/
		TF.at(min(ll(18), t)).at(min(ll(18), f))++;
	}
	ll an = 0;
	rep(i, 19) {
		rep(j, 19) {
			for (ll k = 18 - i; k <= 18; k++) {
				for (ll h = 18 - j; h <= 18; h++) {
					if (i != k || j != h) {
						an += (TF.at(i).at(j) * TF.at(k).at(h));
					}
					else {
						an += (TF.at(i).at(j) * (TF.at(i).at(j) - 1));
					}
				}
			}
		}
	}
	/*rep(i, 19) {
		rep(j, 19) {
			cout << TF.at(i).at(j) << " ";
		}
		cout << endl;
	}*/
	cout << an/2 << endl;
}





Measured memory_bytes: 6424
#include <stdio.h>
int min(int a,int b){
    if(a<b) return a;
    else return b;
}
int main(void){
    int n,i,j,ans=10000000;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<101;i++){
        int tmp=0;
        for(j=0;j<n;j++){
            tmp += (a[j]-i)*(a[j]-i);
        }
        ans = min(ans,tmp);
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include<iostream>
using namespace std;
int main()
{
	long long a, b, c, d, N;

	cin >> a >> b >> c;

	d = (a + b)*c / 2;

	cout << d;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

bool ok[N];

void sieve() {

    for(int i = 1; i < N; i ++)
        ok[i] = 1;

    for(int i = 2; i * i < N; i ++) {
        for(int j = i * i; j < N; j += i) {
            ok[j] = 0;
        }
    }
    return ;
}


lli ans[N];

void solve()
{

    sieve();
    ok[1] = 0;
    for(int i = 1; i <= 100000; i ++ ) {
        if(ok[i] and ok[(i + 1) / 2])
            ans[i] = 1;
    }
    for(int i = 1; i <= 100000; i ++) {
        ans[i] += ans[i - 1];
    }


    lli q;
    cin>>q;
    while(q --) {
        lli l, r;
        cin>>l>>r;
        lli p = ans[r] - ans[l - 1];
        cout<<p<<'\n';
    }

    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    int h, w;
    vector<string> s;
    string temp;

    vector<int> dx = {-1,  0,  1,  0};
    vector<int> dy = { 0,  1,  0, -1};

    cin >> h >> w;

    s.push_back(string(w + 2, '.'));
    for(int i = 0; i < h; i++){
        cin >> temp;
        s.push_back("." + temp + ".");
    }
    s.push_back(string(w + 2, '.'));

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(s[i][j] == '#'){
                bool isNG = true;
                for(int k = 0; k < dx.size(); k++){
                    if(s[i + dx[k]][j + dy[k]] == '#'){
                        isNG = false; break;
                    }
                }
                if(isNG){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;

    return 0;

}

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


using namespace std;

using ll   = long long;
using ii   = pair < int , int >;
using i3   = pair < int , ii >;
using li   = pair < ll , int >;
using lii  = pair <  ll,  ii >;
using vi   = vector < int >;
using vl   = vector < ll >;
using vli  = vector < li >;
using vii  = vector < ii >;
using vi3  = vector < i3 >;
using vlii = vector < lii >;

const int N = 2e5 + 5;
const ll INF = 1e17;
const double eps = 1e-12 , PI = acos(-1);

int n , m;

void solve(int cs){
    scanf("%d %d" , &n , &m);

    int s = 1;
    int cnt = 0;

    while(s < m){
        s --;
        s += n;
        cnt ++;
    }

    printf("%d\n" , cnt);
}

main(){
    int t = 1;
    //scanf("%d" , &t);

    for(int cs = 1 ; t -- ; cs ++){
        solve(cs);
    }

    return 0;
}



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

void main_()
{
    ll N, A, B;
    cin >> N >> A >> B;

    ll ans = 0;
    if (A > B) {
        ans = 0;
    } else if (N == 1) {
        ans = (A == B) ? 1 : 0;
    } else {
        ans = (B - A) * (N - 2) + 1;
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

int main(){
    int a, b, c;
    cin >>a>>b>>c ;
    int ans = a%b ;
    
    if( (a%b == c ) ){
            cout << "YES" << endl;
            return 0 ;
    }

    for( int i = 2 ; i < 100000 ; i++ ){
        if( (a*i)%b == c ){
            cout << "YES" << endl;
            return 0 ;
        }
        if( (a*i)%b == ans ) break ;
    }
    cout << "NO" << endl ;

}

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

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

    int A = ABCD[0] - '0';
    int B = ABCD[1] - '0';
    int C = ABCD[2] - '0';
    int D = ABCD[3] - '0';

    if (A + B + C + D == 7) {
        printf("%d+%d+%d+%d=7\n", A, B, C, D);
    } else if (A + B + C - D == 7) {
        printf("%d+%d+%d-%d=7\n", A, B, C, D);
    } else if (A + B - C + D == 7) {
        printf("%d+%d-%d+%d=7\n", A, B, C, D);
    } else if (A + B - C - D == 7) {
        printf("%d+%d-%d-%d=7\n", A, B, C, D);
    } else if (A - B + C + D == 7) {
        printf("%d-%d+%d+%d=7\n", A, B, C, D);
    } else if (A - B + C - D == 7) {
        printf("%d-%d+%d-%d=7\n", A, B, C, D);
    } else if (A - B - C + D == 7) {
        printf("%d-%d-%d+%d=7\n", A, B, C, D);
    } else if (A - B - C - D == 7) {
        printf("%d-%d-%d-%d=7\n", A, B, C, D);
    }

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
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();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second.first
#define T4 second.second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

int main(){
	int n;
	while(cin>>n){
		int ret=0;
		REP(i,10){
			REP(j,10){
				REP(k,10){
					REP(l,10){
						if(i+j+k+l==n)ret++;
					}
				}
			}
		}
		cout<<ret<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
using Microsoft.VisualBasic;
using System;
using System.Linq.Expressions;
using System.Security.Cryptography.X509Certificates;
using System.Collections.Generic;
using System.Linq;



class Myapp
{
    static void Main()
    {
        var x = long.Parse(Console.ReadLine());

        int count = 0;
        long money = 100;
        while (money < x)
        {
            money += money / 100;
            count += 1;
        }
        Console.WriteLine(count);
    }
}
    


Measured memory_bytes: 27532
#include <iostream>      /* printf */
#include <cmath>       /* sin */
#include <iomanip>

#define PI 3.14159265
using namespace std;

int main ()
{

  int n;

  while (1) {
    cin >> n;
    if (n == 0) {
      break;
    }

    double s[1000];

    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }

    double m = 0;
    for (int i = 0; i< n; i++) {
      m += s[i];
    }
    m /= n;
    double alpha = 0;
    for (int i=0; i<n; i++) {
      alpha += pow(s[i] - m, 2);
    }
    alpha = sqrt(alpha/n);
    cout << fixed << setprecision(6) << alpha << endl;

  }
  return 0;
}

Measured memory_bytes: 1292
MAX_RANGE = 99999999999

def f(n:float):
    if n % 2 == 0:
        return n / 2
    else:
        return (3 * n) + 1

def main():
    s = float(input().strip())

    def a(i):
        if i < 1:
            raise ValueError
        elif i == 1:
            return s
        else:
            return f(a(i-1))

    a_s = [None, s]
    for i in range(2, MAX_RANGE):  # 1 .. MAX_RANGE-1
        value = a(i)
        for j in range(1, i):  # 1 .. i-1
            if a_s[j] == value:
                print(i)
                return
        a_s.append(value)

    # print(a_s)


if __name__ == "__main__":
    main()

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

int main() {
    long long N;
    vector<long long> ni;
    long long count = 0;
    cin >> N;

    for(long long a = 2; a * a <= N; a++) {
      if(N % a != 0) continue;

      long long i = 0;
      while(N % a == 0) {
        i++;
        N /= a;
      }
      ni.push_back(i);
    }

    if(N != 1) count++;

    for(long long j = 0; j < ni.size(); j++) {
      int k = 0;
      for(;k < ni.at(j); k++) {
        count++;
        ni.at(j) -= k+1;
      }
    }

    cout << count << endl;
}


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

void fnInput(int& rnAchieve, vector<int>& rvnPrice, vector<vector<int>>& rvvnSkill)
{
  int nPriceSiz, nSkillSiz;
  cin >> nPriceSiz >> nSkillSiz >> rnAchieve;
  rvnPrice.resize(nPriceSiz);
  rvvnSkill.resize(nPriceSiz, vector<int>(nSkillSiz));

  for (int ny = 0; ny < rvvnSkill.size(); ny++)
  {
    cin >> rvnPrice[ny];

    for (int nx = 0; nx < rvvnSkill[ny].size(); nx++)
      cin >> rvvnSkill[ny][nx];
  }
}

int fnMinPriceSkillup(int nAchieve, const vector<int> cnrvnPrice, 
                      const vector<vector<int>>& cnrvvnSkill)
{
  int nMinPrice = INT_MAX;

  for (int nCtl = 0; nCtl < ( 1 << cnrvnPrice.size() ); nCtl++)
  {
    int nPrice = 0;
    vector<int> vnSumSkill(cnrvvnSkill[0].size());

    for (int ny = 0; ny < cnrvnPrice.size(); ny++)
      if (nCtl & ( 1 << ny ))
      {
        for (int nx = 0; nx < cnrvvnSkill[ny].size(); nx++)
          vnSumSkill[nx] += cnrvvnSkill[ny][nx];

        nPrice += cnrvnPrice[ny];
      }

    bool bRslt = true;

    for (int nSumSkill : vnSumSkill)
      if (nSumSkill < nAchieve)
      {
        bRslt = false;
        break;
      }

    if (bRslt)
      nMinPrice = min(nMinPrice, nPrice);
  }
  if (nMinPrice == INT_MAX)
    return -1;
  else
    return nMinPrice;
}
  
int main()
{
  int nAchieve;
  vector<int> vnPrice;
  vector<vector<int>> vvnSkill;

  fnInput(nAchieve, vnPrice, vvnSkill);
  cout << fnMinPriceSkillup(nAchieve, vnPrice, vvnSkill) << endl;

  return 0;
}

Measured memory_bytes: 3608
/*
 * Author: madlogic
 * It's better to do something than nothing
*/
#include <bits/stdc++.h>
using namespace std;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
// #define int long long
const int INF = 1000000000;
const int MOD = 1000000007;
const double PI = 2*acos(0.0);
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	int res = s.length();
	for(int i=1;i<s.length();i++)
		if(s[i]==s[i-1])
			--res,i+=2;
	cout<<res<<endl;
	return 0;	
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;



int main(){
   string S;
   cin >> S;
   if(S.at(0) == S.at(2)){
      cout << "Yes" << endl;
   }
   else{
      cout << "No"<< endl;
   }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
able_up = [0] * N
able_down = [0] * N
for i in range(N):
    if (i-A[i]) >= 0: able_up[i-A[i]] += 1
    if (i+A[i]) < N: able_down[i+A[i]] += 1
# print(able_up)
# print(able_down)
ans = 0
for i in range(N):
    ans += able_up[i] * able_down[i]
print(ans)

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, x, y;
	cin >>n >>x >> y;
	vector<VI> a(n,VI(n));
	rep(i, n) rep2(j,i+1,n) a[i][j] = a[j][i] = j-i;
	rep(i, n) rep2(j,i+1,n){
		a[i][j] = min(a[i][j], a[i][x-1]+a[y-1][j]+1);
	}
	VI ans(n);
	rep(i, n) rep(j, i) ans[a[j][i]]++;
	rep2(i, 1, n) cout <<ans[i] <<'\n';
	return 0;
}


Measured memory_bytes: 16000
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 100001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

vector<int> es[2 * MAX];
vector<int> use(2 * MAX, 0);

void bfs(int start){
    int node;
    queue<int> q;
    q.push(start);
    use[start] = 1;

    while(!q.empty()){
        node = q.front(); q.pop();
        for(int next: es[node]){
            if(use[next] == 0){
                q.push(next);
                use[next] = 1;
            }
        }
    }
}

signed main(){
    int n, m, k, tmp;
    cin >> n >> m;

    rep(n){
        cin >> k;
        repp(j, k){
            cin >> tmp;
            es[i].pb(tmp+MAX);
            es[tmp+MAX].pb(i);
        }
    }

    bfs(0);

    int flag = 1;
    rep(n){
        if(use[i] == 0){
            flag = 0;
            break;
        }
    }

    if(flag == 1){
        cout << "YES";
    }else{
        cout << "NO";
    }

}


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

public class Main {
	static boolean memo[];
	static int ans, min;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] x = new int[m];
		int sum = 0;
		for (int i = 0; i < m; i++) {
			x[i] = sc.nextInt();
		}
		Arrays.sort(x);
		if (m > n) {
			int[] diff = new int[m - 1];
			for (int i = 0; i < m - 1; i++) {
				diff[i] = Math.abs(x[i + 1] - x[i]);
				sum += diff[i];
			}
			Arrays.sort(diff);
			for (int i = 0; i < n - 1; i++) {
				sum = sum - diff[m - 2 - i];
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 50844
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NM = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (N, M) = (NM[0], NM[1]);
            var edges = new (int U, int V, long S)[M];
            for (var i = 0; i < M; i++)
            {
                var abc = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                var (a, b) = (abc[0] - 1, abc[1] - 1);
                long c = -abc[2];
                edges[i] = (a, b, c);
            }

            const long Infinity = (long)1e18;
            var scores = Enumerable.Repeat(Infinity, N).ToArray();
            scores[0] = 0;
            for (var loop = 0; loop < N - 1; loop++)
            {
                for (var i = 0; i < M; i++)
                {
                    var u = edges[i].U;
                    var v = edges[i].V;
                    var s = edges[i].S;
                    if (scores[u] == Infinity) continue;
                    if (scores[v] > scores[u] + s) scores[v] = scores[u] + s;
                }
            }
            var answer = scores[N - 1];

            var negative = new bool[N];
            for (var loop = 0; loop < N; loop++)
            {
                for (var i = 0; i < M; i++)
                {
                    var u = edges[i].U;
                    var v = edges[i].V;
                    var s = edges[i].S;
                    if (scores[u] == Infinity) continue;

                    if (scores[v] > scores[u] + s)
                    {
                        scores[v] = scores[u] + s;
                        negative[v] = true;
                    }

                    if (negative[u]) negative[v] = true;
                }
            }

            Console.WriteLine(negative[N - 1] ? "inf" : (-answer).ToString());
        }
    }
}


Measured memory_bytes: 28820
A,B,C,K = [int(i) for i in input().split()]
# BC, AC, AB = B - A
# AABC, ABBC, ABCC = A - B
# AABBBCCC, AAABBCCC, AAABBBCC = B - A
print(B - A if K&1 else A - B)

Measured memory_bytes: 8916
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
int n,a,b,ans=0;
signed main(){
    cin>>n>>a>>b;
    if(n==1){
        if(a==b)ans=1;
    }
    else if(a<=b){
        int mini=a*(n-1)+b;
        int maxi=a+b*(n-1);
        ans=maxi-mini+1;
    }
    ans=max((int)(0),ans);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int sieve(int n){
  bool b[200001];
  memset(b,1,200001);
  b[1]=0;
  int i,j;
  //for(i=0;i<n;i++)cout<<b[i];
  for(i=2;(i*i)<=200000;i++){
    if(b[i]){
      for(j=i*i;j<=200000;j+=i)b[j]=0;
    }
  }
  if(b[n]==1)return n;
  else {
    for(i=n;;i++)if(b[i])return i;
  }

}

int main(){
  
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int n;
  cin>>n;
  cout<<sieve(n);





  
  


  
 
 
 
    
 
return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
 
int n;
int s[200000];
 
signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> s[i];
	
	int ans = 0;
	for (i = 1; i < n; i++) {
		int score = 0;
		for (j = 0; j < n - i; j += i) {
			score += s[j] + s[n - 1 - j];
			if ((n - 1) % i == 0 && j >= n - 1 - j) {
				break;
			}
			ans = max(ans, score);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int mod = 1'000'000'007;
    
    int N;
    cin >> N;
    
    ll power = 1;
    for(int i=1; i<=N ; i++){
        power *= i;
        power = power % mod;
    }
    
    cout << power << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define l1 long
#define ld long double
#define lld long long double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x) cout<<"$ "<<x<<" $"<<endl
#define bug(x) cout<<"& "<<x<<" &"<<endl
#define all(v) v.begin(),v.end()
#define lop1(i,j,n) for(int i=j; i<n; ++i)
#define lop2(i,j,n) for(int i=j; i<=n; ++i)
#define lop3(i,n,j) for(int i=n; i>j; --i)
#define lop4(i,n,j) for(int i=n; i>=j; --i)
#define view(v) for(auto i: v) cout<<i<<" "
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
const ll M=1e9+7;
const ld PI=3.1415926536;
//int p[N];
//int find(int k){ return p[k]==k ? k : p[k]=find(p[k]); }
using namespace std;

void solve()
{
    int x, y;
    cin>>x>>y;
    if((y-(2*x))%2) cout<<"No";
    else
    {
        int a=(y-(2*x))/2;
        int b=x-a;
        if(a<0 or b<0) cout<<"No";
        else cout<<"Yes";
    }
    return;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    fast
    ll t=1;
	//cin>>t;
    while(t--) solve();
	return 0;
}


Measured memory_bytes: 3652
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;
ll modpow(ll a,ll n,ll mod){ // a^n の mod を計算
    ll res = 1;
    while(n>0){
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}
signed main(){
    // ll m100 = modpow(10,100,mod);
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=n+1;i>=k;i--){
        ans += ((n + (n+1-i))*i/2)+1;
        ans -=  (i-1)*i/2;
        ans %= mod;
        // cout<<ans<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
const int INF = 1e9;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数
uintmax_t combination(unsigned int n, unsigned int r){    //組み合わせ
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

int main()
{
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int c[n-1];
    int MP=0;
    rep(i, n)
    {
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }
    rep(i,n-1){
        cin >> c[i];
    }
    int num;
    int num_old = 10000;
    rep(i, n)
    {
        num=a[i];
        MP += b[num-1];
        if(num_old+1==num&&num_old!=n){
            MP += c[num_old-1];
        }
        num_old = num;
    }
    cout << MP << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=8005,low=8000;
char s[N];
int x,y,n;
bitset<N*2>bx,by;
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    scanf("%d%d",&x,&y);
    bx[0+low]=1;by[0+low]=1;
    bool flag=true;
    int t=0,st=0;
    for(int i=1;i<=n;i++)
        if(s[i]=='F') t++;
    else
    {
        if(flag)
            bx<<=t,flag=false;
        else
        {
            if(st) by=(by<<t)|(by>>t);
            else bx=(bx<<t)|(bx>>t);
        }
        st^=1;
        t=0;
    }
    if(flag)
        bx<<=t,flag=false;
    else
    {
        if(st) by=(by<<t)|(by>>t);
        else bx=(bx<<t)|(bx>>t);
    }
    if(bx[x+low]&&by[y+low]) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int N, M, i, j;
  scanf("%d %d", &N, &M);
  int A[M];
  for(i=0;i<M;i++){
    A[i]=0;
  }
  int num=0;
  for(j = 0; j < N; ++j){
  if (scanf("%d", &num) == 1)
  {
    for (i=0; i < num; ++i)
    {
        int data=0;
        if (scanf("%d", &data) == 1)
        {
          A[data-1] ++;
            
        }
        else
        {
            
        }
    }
    
  }
  else
  {
    
  }
}
  i = 0;
  for(j = 0; j < M; j ++){
    if(A[j] == N){
      i ++;
    }
  }
  printf("%d", i);
  return 0;
}


Measured memory_bytes: 128
A, B = gets.split.map(&:to_i)

def d_xor(b)
  if b % 4 == 0
    return b
  elsif b % 4 == 1
    return 1
  elsif b % 4 == 2
    return b + 1
  end
  0
end

puts d_xor(A - 1) ^ d_xor(B)

Measured memory_bytes: 1788
#include<cstdio>
using namespace std;
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	if(n==1) n=14;if(m==1) m=14;
	if(n>m) printf("Alice");
	else if(n==m) printf("Draw");
	else printf("Bob");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>

using namespace std;

typedef long long    ll;
typedef long double  ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

template <typename T> bool chmax(T &a, T& b) {if (a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, T& b) {if (a > b) {a = b; return true;} return false;}
#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define mset(x, val) memset(x,(val),sizeof(x))
#define cons(a, b) make_pair((a), (b))
#define car first
#define cdr second

#define endl '\n'
const ll   INF  = 0x7f7f7f7f7f7f7f7f;
const int  INFi = 0x7f7f7f7f;


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

string solve(ll a, ll b) {
  return (a*b)%2 ? "Odd" : "Even";
}

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

  ll a, b;
  cin >> a >> b;

  auto ans = solve(a, b);
  cout << ans << endl;

  return 0;
}


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

public class BinarySearch{
	public static void Main()
	{
		Console.ReadLine();
		var sList = ReadLineAndToIntList();
		Console.ReadLine();
		var tList = ReadLineAndToIntList();
	
		int count = 0;
	
		tList.ForEach(t =>
		{
			if(sList.BinarySearch(t) > -1) count++;
		});
		
		Console.WriteLine(count);
	}
	
	//??????????????????????????????
	public static List<int> ReadLineAndToIntList()
	{
		return Console.ReadLine().Split().Select (c => {
			int num;
			int.TryParse(c, out num);
			return num;
		}).ToList();
	}
}

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

int main(){
  
  int i, N, cnt=0;
  cin >> N;
  for(i=1; i<=N; i++){
    int a;
    cin >> a;
    if(i%2==1 && a%2==1)cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	string s;
	cin >> s;
	bool AC=true;
	int c = 0;
	if (s[0] != 'A')AC = false;
	rep(i, s.size()) {
		if (i >= 2 && i < s.size() - 1) {
			if (s[i] == 'C')c++;
		}
	}
	if (c!=1)AC = false;
	rep(i, s.size()) {
		if(s[i]=='B'||(s[i]>'C'&&s[i]<='Z'))AC = false;
	}
	cout << (AC ? "AC" : "WA") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("kmp.gir","r",stdin);freopen ("kmp.cik","w",stdout);
#define mod 1000000009
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[N],sum,dp[N];

int main()
{
	fast;
	cin>>n>>m;
	if((n+m)%2==0)
		return cout<<(n+m)/2,0;
	cout<<"IMPOSSIBLE";


}



/*     cd onedrive\desktop\kod
cls


*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
    #define all(a)      (a).begin(),(a).end()
    #define sz(x)       (int)x.size()
    
    #define ff first
    #define ss second
    #define mp make_pair
         
    #define pb push_back
    #define endl "\n"
         
    #define int long long 
    #define double long double
         
    #define bp __builtin_popcountll
    #define inf 1e16
    
    const int N=1e5+5; 
    const int M=1e6+6;
    const int MOD=1e9+7;
    void solve()
    {        
    	int x,y,a,b,c;
    	cin>>x>>y>>a>>b>>c;
    	multiset<int> s;
    	vector<int> p1(a),p2(b),p3(c);
    	for(int i=0;i<a;i++)
    	cin>>p1[i];
    	for(int i=0;i<b;i++)
    	cin>>p2[i];
    	for(int i=0;i<c;i++)
    	cin>>p3[i];
    	sort(all(p1));
    	sort(all(p2));
    	sort(all(p3));
    	reverse(all(p1));
    	reverse(all(p2));
    	reverse(all(p3));
    	for(int i=0;i<x;i++) s.insert(p1[i]);
    	for(int i=0;i<y;i++) s.insert(p2[i]);
    	for(int i=0;i<c;i++){
    		int pp=*s.begin();
    		if(p3[i]>pp)
    		{
    			s.erase(s.begin());
    			s.insert(p3[i]);
    		}
    		else
    		{
    			break;
    		}
    	}
    	int sum=0;
    	for(auto X:s)
    	sum+=X;
    	cout<<sum;
    	
    }

    signed main()  
    {
        FAST
        int t=1;
        // cin>>t;
        while(t--)
        {
            solve();
        }
    }
        


Measured memory_bytes: 11008
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    int nSum = 0;
    nSum += n;
    nSum += n*n;
    nSum += n*n*n;
    printf("%d\n", nSum);
    return 0;
}

Measured memory_bytes: 3820
import sys
readline = sys.stdin.buffer.readline

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    now=1
    flg = 0
    path = [1]
    pathcheck ={1}
    while True:
        now = a[now-1]
        flg = flg + 1
        if now in pathcheck:
            flg = -1
            path.append(now)
            break
        path.append(now)
        pathcheck.add(now)
        if flg == k:
            break


    if flg == k:
        print(now)
        exit()

    x1 = path.index(now)
    x2 = len(path)-1
    x3 = (k-x1)%(x2-x1)
    print(path[x1+x3])

if __name__ == '__main__':
    main()

Measured memory_bytes: 32400
/**
 * File              : N - Slimes .cpp
 * Author            : horcrux2301 <khajuriaharsh729@gmail.com>
 * Date              : 06.01.2019
 * Last Modified Date: 06.01.2019
 */
#include <bits/stdc++.h>
#define mp(a,b)   make_pair(a,b)
#define ll        long long
#define mp(a,b)   make_pair(a,b)
#define si(n)     scanf("%d",&n)
#define sl(n)     scanf("%lld",&n)
#define pi(n)     printf("%d\n",n)
#define pl(n)     printf("%lld\n",n)
#define           newline cout << endl;
#define           ff first
#define           ss second
#define           pii pair<int, int>
#define           pll pair<ll, ll>
using namespace std;

template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const int size = 500;
ll dp[size][size][2];
ll arr[size];
ll n;

void setdp(){
  for(int i=0;i<size;i++){
    for(int j=0;j<size;j++){
      dp[i][j][0]=-1;
      dp[i][j][1]=-1;
    }
  }
}

// min(0,i-1) + min(i,n-1) + arr[i-1]+arr[i]

pll solve(ll s,ll e){
  //trace("s,e",s,e);
  if(dp[s][e][0]!=-1) return mp(dp[s][e][0],dp[s][e][1]);
  if(s==e){
      dp[s][e][0] = arr[s];
      dp[s][e][1] = 0;
      return mp(dp[s][e][0], dp[s][e][1]);
  }
  if(s+1==e){
    dp[s][e][0]=arr[s]+arr[e];
    dp[s][e][1]=arr[s]+arr[e];
    dp[s][s][0]=arr[s];
    dp[s][s][1]=0;
    dp[e][e][0]=arr[e];
    dp[e][e][1]=0;
    return mp(dp[s][e][0], dp[s][e][1]);
  }
  ll maxi = 1e18,val=1e18;
  for(int i=s;i<e;i++){
    auto k1 = solve(s,i);
    auto k2 = solve(i+1,e);
    ll tmaxi = k1.ff+k2.ff+k1.ss+k2.ss;
    ll tval = k1.ff+k2.ff;
    if(tmaxi<maxi){
        maxi=tmaxi;
        val=tval;
    }
  }
  dp[s][e][0]=val;
  dp[s][e][1]=maxi;
  return mp(dp[s][e][0], dp[s][e][1]);
}

int main(){
  //clock_t tStart = clock();
  int test;
  test=1;
  //si(test);
  while(test--){
      cin >> n;
      for(int i=0;i<n;i++){
        cin >> arr[i];
      }
      setdp();
      cout << solve(0,n-1).ss << endl;
      //for(ll i=0;i<n;i++){
      //  for(ll j=0;j<n;j++){
      //      cout << dp[i][j][0] << ',' << dp[i][j][1] << ' ';
      //  }newline
      //}newline
  }
  //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  return 0;
}


Measured memory_bytes: 4224
from math import factorial

mod = 10**9 + 7

def cmb(n,r):
    a = factorial(n) // factorial(r) // factorial(n - r)
    return(int(a % mod))

S = int(input())


# S = 3a + b
a = S // 3
b = S % 3

ans = 0

for i in range(a):
    ans += cmb(a-1 + b, a-1)
    a -= 1
    b += 3
    ans %= mod

print(ans)


Measured memory_bytes: 9204
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, N);
    ll s = 0;
    REP(i, N.size())
    {
        s += N[i] - '0';
    }
    YES(s % 9 == 0);
}

Measured memory_bytes: 3756
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x[ohara], y, sum, k, q, l[ohara];
P p[ohara], p1[ohara];

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

  cin >> n;
  rep(i, n) cin >> p[i].fi >> p[i].se;
  sort(p, p + n);
  rep(i, n) x[i] = p[i].fi, l[i] = p[i].se;

  ll mi = LINF;
  mi = x[0] + l[0];
  rrep(i, 1, n) {
    if (x[i] - l[i] < mi) {
      mi = min(mi, x[i] + l[i]);
      ans++;
    } else {
      mi = x[i] + l[i];
    }
  }
  Cout(n - ans);
  return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int A,B;cin>>A>>B;
    if(A%3==0 || B%3==0 || (A+B)%3==0){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H, W;
    cin >> H >> W;
    for(int i=0; i<W+2; i++) {
        cout << "#";
        if(i == W+1) {
            cout << endl;
        }
    }
    
    vector<string> S(H);
    for(int i=0; i<H; i++) {
        cin >> S.at(i);
    }
    for(int i=0; i<H; i++) {
        cout << "#" << S.at(i) << "#" << endl;
    }
    
    for(int i=0; i<W+2; i++) {
        cout << "#";
        if(i == W+1) {
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	ll N;
	cin >> N;
	ll A[100000];
	rep(i, N) cin >> A[i];
	
	ll sum = 0;
	rep(i, N) sum += A[i];

	int OK = 1;
	if (sum % (N * (N + 1) / 2)) OK = 0;
	else {
		ll k = sum / (N * (N + 1) / 2);
		rep(i, N) A[i] -= k * (i + 1);
		ll kazu = 0;
		rep(i, N - 1) {
			if ((A[i] - A[i + 1]) % N || A[i] < A[i + 1]) OK = 0;
			else kazu += (A[i] - A[i + 1]) / N;
		}
		if (kazu > k) OK = 0;
	}

	if (OK) co("YES");
	else co("NO");

	Would you please return 0;
}

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

using namespace std;

int n, m, ans;
int l[(int)1e5], r[(int)1e5];

int main(){
	cin >> n >> m;
	int left = 1, right = n;
	for(int i = 0; i < m; ++i){
		cin >> l[i] >> r[i];
		left = max(left, l[i]), right = min(right, r[i]);
	}
	ans = max(0, right - left + 1);
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int N,M;
int a[200005],b[200005];
int main()
{
    while(~scanf("%d%d",&N,&M))
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        for(int i=0;i<M;i++)
        {
            int c,d;
            scanf("%d%d",&c,&d);
            if(c==1)
                a[d]=1;
            if(d==1)
                a[c]=1;
            if(c==N)
                b[d]=1;
            if(d==N)
                b[c]=1;
        }
        int flag = 0;
        for(int i=1;i<=N;i++)
        {
            if(b[i]==1&&a[i]==1)
            {
                flag = 1;
                break;
            }
        }
        if(flag)
            printf("POSSIBLE\n");
        else
            printf("IMPOSSIBLE\n");
    }



    return 0;
}

Measured memory_bytes: 1664
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, M: int):
    import math
    def combination(n, r):
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    ans = 0
    if N >= 2:
        ans += combination(N,2)
    if M >= 2:
        ans += combination(M,2)
    print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
while 1:
  n=input()+1
  if n==1: break
  x=[]
  y=[0]*n
  for i in range(n-1):
    a=map(int,raw_input().split())
    a.append(sum(a))
    x.append(a)
    for i in range(n): y[i]+=a[i]
  x.append(y)
  for a in x: print "".join(map(lambda x:str(x).rjust(5),a))

Measured memory_bytes: 4228
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
string a;
int la;
int main()
{
	cin>>a;
	la=a.size();
	cout<<a[0]<<la-2<<a[la-1]<<endl;
	return 0;
}

Measured memory_bytes: 256