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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

ll n;
vector<bool> m1, m2;
bool is_male(ll pos) {
    pos %= n;
    if (m1[pos]) return m2[pos];
    cout << pos << endl;
    string result; cin >> result;
    if (result == "Vacant") exit(0);
    return m1[pos] = true, m2[pos] = result == "Male";
}
void solve(ll l, ll r) {
    assert(l < r);
    ll m = (l + r) / 2;
    if ((is_male(l) + m - l) % 2 == is_male(m)) {
        solve(m, r);
    }
    else {
        solve(l, m);
    }
}
int main() {
    cin >> n;
    m1.assign(n, false);
    m2.assign(n, false);
    solve(0, n);
}


Measured memory_bytes: 852
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<math.h>
using namespace std;
const int maxn=3e2+7;
typedef long long ll;
const int INF=1e9;
int c[300][300],dis[300][300],n,color[300],visited[300];
vector<int> v[300];
int dfs(int x,int flag)
{
	color[x]=flag;
	int len=v[x].size();
	visited[x]=1;
	for(int i=0;i<len;i++)
	{
		int y=v[x][i];
		if(color[x]==color[y])
			return 0;
		if(visited[y]==0&&dfs(y,3-flag)==0)
		{
			return 0;
		}
	}
	return 1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i==j)
				dis[i][j]=0;
			else
				dis[i][j]=INF;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			scanf("%1d",&c[i][j]);
			if(c[i][j]==1)
			{
				v[i].push_back(j);
				v[j].push_back(i);
			}
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i==j)
				dis[i][j]=0;
			else if(c[i][j]==1)
				dis[i][j]=1,dis[j][i]=1;
			else if(c[i][j]==0)
				dis[i][j]=dis[j][i]=INF;
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	if(dfs(1,1)==0)
		printf("-1\n");
	else
	{
		int ans=0;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				if(dis[i][j]<INF)
					ans=max(ans,dis[i][j]);
		printf("%d\n",ans+1);
	}
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>

using namespace std;

long long int a, b;

int main(void) {

	cin >> a >> b;

	if (a > 0) { cout << "Positive" << endl; }
	else if (a <= 0 && b >= 0) { cout << "Zero" << endl; }
	else {
		if ((b - a + 1) % 2 == 0) { cout << "Positive" << endl; }
		else { cout << "Negative" << endl; }
	}



	//system("pause");
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

class ATherefore {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s;
        in>>s;
        auto n = s.at(s.size()-1);
        if(n=='2'||n=='4'||n=='5'||n=='7'||n=='9') out<<"hon"<<endl;
        else if(n=='0'||n=='1'||n=='6'||n=='8') out<<"pon"<<endl;
        else out<<"bon"<<endl;
	}
};


int main() {
	ATherefore solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int N,K; string S;
cin >> N >> K >> S;

int eq = 0, di = 0;
rep(i,N-1) {
    if(S[i] == S[i+1]) eq++;
    else di++;
}
cout << eq + min(K*2, di) << endl;
return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll a,b,c,d,x,y;
    cin>>a>>b>>c>>d;
   x=a*b;
   y=c*d;
   cout<<max(x,y)<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include<cstdio>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int a[n][2];
    int sum = 0;
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i][0]);
        scanf("%d", &a[i][1]);
        sum += a[i][1] - a[i][0] + 1;
    }

    printf("%d\n", sum);

    
    
}

Measured memory_bytes: 256
def match(x,y):
    if x==y or y=='?':
        return 1
    else:
        return 0
S=input()
T=input()
U=""

candidate=[]
count=0

for i in range(len(S)-len(T)+1):#Sの上を走る時のスタート地点
    for j in range(len(T)):#Tの上を走る
        if match(T[j],S[i+j]):
            count+=1
        else:
            count=0
            break#一つでも違ったら次のiへ
    if count==len(T):
        count=0
        U=S[:i]+T+S[i+len(T):]
        U=U.replace('?','a')
        candidate.append(U)
        
if len(candidate)==0:
    print('UNRESTORABLE')
else:
    
    print(sorted(candidate)[0])

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

int main()
{
  int a;
  cin >> a;
  if(a == 3 || a == 5 || a == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3516
#include <iostream>
#include <iomanip>

#include <vector>
#include <string>
#include <iterator>
#include <algorithm>
typedef long long ll;
const long long C_MOD = 1046527;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C

// string -> number (int) -> key (long long) -> hash (ll)
class Hash {
public:
    Hash() : m_h(std::vector<std::string>(C_MOD, std::string())) {};

    // get a number from a single char
    const ll getChar(char ch) const {
        if      (ch == 'A') return 1;
        else if (ch == 'C') return 2;
        else if (ch == 'G') return 3;
        else if (ch == 'T') return 4;
        else                return 0;
    }

    const ll getKey(std::string& str) const {
        ll sum = 0, p = 1;
        const ll nb = str.size();
        for (ll i = 0; i < nb; ++i) {
            sum += p * getChar(str[i]);
            p *= 5;
        }
        return sum;
    }

    const ll find(std::string& str) const {
        const ll key = getKey(str);
        const ll ih1 = h1(key);
        const ll ih2 = h2(key);
        for (ll i = 0; ; ++i) {
            const ll h = (ih1 + i * ih2) % C_MOD;
            if (m_h[h] == str)           return 1; // found
            else if (m_h[h].size() == 0) return 0; // not found
        }
        return 0;

    } 

    const ll insert(std::string& str) {
        const ll key = getKey(str);
        const ll ih1 = h1(key);
        const ll ih2 = h2(key);
        for (ll i = 0; ; ++i) {
            const ll h = (ih1 + i * ih2) % C_MOD;
            if (m_h[h] == str) return 1; // already exists
            else if (m_h[h].size() == 0) {
                m_h[h] = str; // instert
                return 0;
            }
        }
        return 0;
    }

private:
    const inline ll h1(ll key) const { return key % C_MOD; }
    const inline ll h2(ll key) const { return 1 + (key % (C_MOD - 1)); }
    std::vector<std::string> m_h;
};


void Main() {
    ll nb; std::cin >> nb;

    Hash h;
    std::string order, str;

    for (ll i = 0; i < nb; ++i) {
        std::cin >> order >> str;
        if (order == "insert")
            h.insert(str);
        else
            std::cout << (h.find(str) == 1 ? "yes" : "no")  << std::endl;
    }

    return;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    return 0;
}



Measured memory_bytes: 23976
char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)c==d[k]?(k++,c=r[i++]):(putchar(c),c=g[j++]);exit(0);}

Measured memory_bytes: 524
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
#https://atcoder.jp/contests/arc091/tasks/arc091_b
#D - Remainder Reminder
"""
if has negative

if all positive

"""

N = gi()
A = [0] * N
ans = 0
max_vi = -1
max_v = -1e4 - 1
min_vi = -1
min_v = 1e4 + 1
for i in range(N):
    a = gi()
    A[i] = a
    if (a >= max_v):
        max_vi = i
        max_v = a
    if (a < min_v):
        min_vi = i
        min_v = a
    ans += abs(a)

seq = []
for i in range(N):
    if i == max_vi or i == min_vi:
        continue
    a = A[i]
    if a >= 0:
        seq.append((min_v, a))
        min_v -= a
    else:
        seq.append((max_v, a))
        max_v -= a
print(max_v - min_v)
for p in seq:
    print("%d %d" % (p[0], p[1]))
print(max_v, min_v)


Measured memory_bytes: 35360
S = input()
List = list(S)
res = 0
if List[0] == "R":
  res = 1
for i in range(1,3):
  if List[i-1] == "R" and List[i] == "R":
    res +=1
  elif List[i-1] == "S" and List[i] == "R":
    res = 1
  else:
    pass
print(res)

Measured memory_bytes: 9116
// OURL: https://atcoder.jp/contests/abc124/tasks/abc124_b
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

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; }

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"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
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(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} 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...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int mh=0,ans=0;
  REP(i,n) {
    int h;
    cin >> h;
    if (h >= mh) {
      ans++;
      mh = h;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
  int a,b;
  char op;

  while(true)
  {
    cin >> a >> op >> b;
    if ( op == '?' ) return 0;
    switch(op)
    {
      case '+':
        cout << a+b << endl;
        break;
      case '-':
        cout << a-b << endl;
        break;
      case '*':
        cout << a*b << endl;
        break;
      case '/':
        cout << a/b << endl;
        break;
    }
  }
}

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

void print(const vector<int>& xs) {
  for (auto& x : xs) cout << x << ", ";
  cout << endl;
}

int A, B, C;

main() {
  int m = 0;  // max.
  cin >> A >> B >> C;
  vector<int>xs = {A, B, C};
  do {
    const int left = (10*xs[0] + xs[1]) + xs[2];
    const int right = xs[0] + (10*xs[1] + xs[2]);
    // printf("%d%d+%d=%d, %d+%d%d=%d\n",
    //        xs[0], xs[1], xs[2], left,
    //        xs[0], xs[1], xs[2], right);
    m = max(m, left);
    m = max(m, right);
  } while (next_permutation(xs.begin(), xs.end()));
  printf("%d\n", m);
}

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

using namespace std;
int main() {
  string s;
  cin >> s;
  for( int i = 0; i  <s.size(); ++i ) {
    if( i == 3 ) cout << 8;
    else cout << char(s[i]);
    
  }
  cout << endl;
  
  return 0;
}


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

void chmin(int& a, int b){
    a = min(a, b);
}
int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int main(){
    int N;
    int A[100000] = {0};
    cin >> N;
    for(int i=0; i<N-1; i++){
        int x, y, a;
        cin >> x >> y >> a;
        A[x] ^= a;
        A[y] ^= a;
    }

    int num[16] = {0};
    for(int i=0; i<N; i++) num[A[i]]++;

    int fix = 0;
    vector<int> rest;
    for(int i=1; i<16; i++){
        fix += num[i] / 2;
        if(num[i] % 2) rest.push_back(i);
    }

    int sz = rest.size();
    int M = 1<<sz;
    const int INF = 1e9;
    static int dp[1<<15];
    dp[0] = fix;
    for(int i=1; i<M; i++) dp[i] = INF;

    for(int i=1; i<M; i++){
        for(int j=i; j>0; j=(j-1)&i){
            int s = 0, c = 0;
            for(int k=0; k<sz; k++) if(nth_bit(j, k)){
                c++;
                s ^= rest[k];
            }
            if(s == 0) chmin(dp[i], dp[i-j] + c-1);
        }
    }

    cout << dp[M-1] << endl;
    return 0;
}


Measured memory_bytes: 768
import numpy as np
N,K=map(int, input().split())
A =list(map(int,input().split()))
MOD = 10 ** 9 + 7
if N==K:
  ans0 = 1
  for a in A[0:N]:
    ans0 *= a
    ans0 %= MOD
  print(ans0)
  exit()

A=sorted(A)  
if (K%2==1 and A[-1]<0):
  ans1 = 1
  for a in A[N-K:N]:
    ans1 *= a
    ans1 %= MOD
  print(ans1)
  exit()

A=sorted(A, key=lambda x:abs(x), reverse=True)
AA=[np.sign(i) for i in A]
 
ansA = 1
for a in A[0:K]:
  ansA *= a
  ansA %= MOD
ansAA = AA[0:K].count(-1)%2
if ansA==0 or ansAA==0:
  print(ansA)
  exit()

B1=A[0:K]
C1=A[0:K]
B2=sorted(A[K:N])
Bp=[i for i in A[0:K] if i>0]
Bm=[i for i in A[0:K] if i<0]

if B2[0]>0:B2.insert(0,0)
if B2[-1]<0:B2.insert(-1,0)
if not Bp:Bp.insert(0,B1[-1])
if not Bm:Bm.insert(0,B1[0])
  
B1.remove(Bp[-1])
B1.append(min(B2[0],0))

ansB = 1
for a in B1[0:K]:
  ansB *= a
  ansB %= MOD

C1.remove(Bm[-1])
C1.append(max(B2[-1],0))
 
ansC = 1
for a in C1[0:K]:
  ansC *= a
  ansC %= MOD

BB1=[np.sign(i) for i in B1]
ansBB1 = BB1[0:K].count(-1)%2
BB2=[np.sign(i) for i in C1]
ansBB2 = BB2[0:K].count(-1)%2
if ansBB1==1:
  print(ansC)
  exit()
if ansBB2==1:
  print(ansB)
  exit()

if abs(Bp[-1]*B2[-1])-abs(Bm[-1]*B2[0])>=0:
  print(ansC)
else: print(ansB)

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

int main() {
  int ans = 0;
  int n, d;

  cin >> n;
  int i, j, k;
  for(i = 0; i < n; i++) {
    cin >> d;
    k = 1;
    for(j = 2; j * j <= d; j++) {
      if(d % j == 0) {
        k = 0;
        break;
      }
    }
    ans += k;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3100
/*
 * 	The way if it's all predetermined
 * 		And the way i should go all my life
 * 			I swear to go wherever will be
 * 				'Cause there'll be something to see and to find
 * 	I don't know the meaning of life
 * 		But i know what's truly precious
 * 			The way it's leading me to be in love
 * 				No fear i can find me always in my heart
 * 	The life it's not for comparing things
 * 		So i hold both of light and shadow
 * 			The rays of stars will bring me to you
 * 				Throught the dark night skies
 * 					See the way to be shined
 * 	I dont know what's right for our lives
 * 		But i know the truth of my love
 * 			The way it feels our breaths at the wind
 * 				And the way i should go all my life
 * 					I swear to go wherever will be
 * 						Thus the grace i wouldn't have
 * 							Will always in my heart
 * 								Thus the grace i wouldn't have
 * 									Will always in my heart
 */
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifndef rd
#define endl '\n'
#endif
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=2e9;
const int mod=1e9+7;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
auto clk=clock();
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

void solve() {
	int n;
	cin>>n;
	if(n%2==0) {
		cout<<n*n/2-n<<endl;
		fr(i,1,n) {
			fr(j,i+1,n) {
				if(i!=j&&i+j!=n+1) {
					cout<<i<<" "<<j<<endl;
				}
			}
		}
	}
	else {
		cout<<((n-1)*(n-1))/2<<endl;
		fr(i,1,n-1) {
			fr(j,i+1,n-1) {
				if(i!=j&&i+j!=n) {
					cout<<i<<" "<<j<<endl;
				}
			}
		}
		fr(i,1,n-1) {
			cout<<i<<" "<<n<<endl;
		}
	}
}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cerr<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


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

#define BR << "\n"
#define SP << " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] SP; } cout BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout BR;

int main() {
  ll N;
  cin >> N;

  ll sum = 0;
  ll MAX = 0;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum ^= a[i];
    MAX = max(MAX, a[i]);
  }
  if ( sum != 0 ) {
    cout << "No\n";
    return 0;
  }
  if ( MAX != 0 && N % 3 != 0 ) {
    cout << "No\n";
    return 0;
  }


  for (int t = 0; t < 40; t++) {
    int count = 0;
    for (int i = 0; i < N; i++) {
        count += a[i] % 2;
        a[i] /= 2;
    }
    if (count != 0 && count != 2 * N / 3) {
      cout << "No\n";
      return 0;
    }
  }

  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>

int main(){
  int H,W,count=0;
  char cs[55][55]={"."};
  scanf("%d %d",&H,&W);
  for(int l=0;l<H;l++){	scanf("%s",cs[l]);}
  for(int l=0;l<H;l++){
    for(int l2=0;l2<W;l2++){
      if(cs[l][l2]=='#' && cs[l-1][l2]!='#' && cs[l+1][l2]!='#' && cs[l][l2-1]!='#' && cs[l][l2+1]!='#'){
        count++;
      }
    }
  }
  if(count==0){printf("Yes");}else{printf("No");}
  return 0;
}

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

void solve(){
    string s;
    cin >> s;
    if(s.length()%2){
        cout << "No" << endl;
        return;
    }
    for(int i = 0; i < s.length(); i++){
        if(i%2 == 0 && s[i] != 'h' || i%2 == 1 && s[i] != 'i'){
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
    return;
}
int main(){
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int A, B;
  cin >> A >> B;

  if(A >= 13) cout << B << "\n";
  else if(A <= 5) cout << 0 << "\n";
  else cout << B/2 << "\n";

  return 0;
}


Measured memory_bytes: 3628
#![allow(unused_imports)]
use proconio::*;
use num::Integer;

#[fastout]
fn main() {
   input! {
       n: usize,
       s: String
   }
   let mut r = 0i64;
   let mut g = 0i64;
   let mut b = 0i64;
   let ss:Vec<char> = s.as_str().chars().collect();
   for c in &ss {
       match c {
           'R' => r += 1,
           'G' => g += 1,
           'B' => b += 1,
           _ => ()
       }
   }
   let mut ans = r*g*b;
   for i in 0..n {
       let mut j = i+2;
       while j < n {
           match (ss[i]!=ss[(i+j)/2], ss[j]!=ss[(i+j)/2], ss[i]!=ss[j]) {
               (true, true, true) => ans -= 1,
               _ => (),
           };
           j += 2;
       }
   }
   println!("{}", ans);
}


Measured memory_bytes: 2200
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string n;cin>>n;
  string ans="No";
  if(n[1]=='9'||n[0]=='9')ans="Yes";
  cout(ans);
  
  return 0;
}

Measured memory_bytes: 125568
N, K = map(int, input().split())
X = list(map(int, input().split()))

distans_list = [100000000000] * N
for i in range(N - K + 1):
    if X[i] < 0:
        if X[i+K-1] < 0:
            distans_list[i] = abs(X[i])
        else:
            if abs(X[i]) < abs(X[i+K-1]):
                distans_list[i] = 2 * abs(X[i]) + X[i+K-1]
            else:
                distans_list[i] = abs(X[i]) + 2 * X[i+K-1]
    else:
        distans_list[i] = X[i+K-1]
##print(distans_list)
print(min(distans_list))

Measured memory_bytes: 14224
fun main(args: Array<String>) {
    val (n, x, y) = readLine()!!.split(' ').map { it.toInt() }

    val ans = IntArray(n)
    for (i in 1..n-1) {
        for (j in i+1..n) {
            val a = j-i
            val b = Math.abs(x-i) + Math.abs(y-j) + 1
            val c = Math.abs(x-j) + Math.abs(y-i) + 1
            val min = Math.min(a, Math.min(b, c))
            ans[min]++
        }
    }
    for (i in 1 until n) {
        println(ans[i])
    }
}


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

int main() 
{
    char b;
    cin >> b;
    if (b == 'A') cout << 'T';
    if (b == 'T') cout << 'A';
    if (b == 'G') cout << 'C';
    if (b == 'C') cout << 'G';
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#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;

#define ll long long
using vt = int; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

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

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

int main() {
	ll a, b;
	cin >> a >> b;
    cout << lcm(a, b);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int M = 1e5 + 7;
int main()
{
	int n,a[3][M];
	ll b[M] = {0};
	cin>>n;
	rep(i,0,3){
		rep(j,0,n) scanf("%d",&a[i][j]);
	}
	sort(a[0],a[0] + n);
	sort(a[1],a[1] + n);
	sort(a[2],a[2] + n);
	
	per(i,0,n) {
		b[i] = a[2] + n - upper_bound(a[2],a[2] + n,a[1][i]) + b[i + 1];
	}
	ll ans = 0;
	rep(i,0,n){
		int ind = upper_bound(a[1],a[1] + n,a[0][i]) - a[1];
		ans += (ll)b[ind];
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <set>

using namespace std;

long long n;
long long a[100005];
multiset<long long> se;
long long ans;

int main()
{
    //freopen("input.txt", "r", stdin);
    scanf("%lld", &n);
    for(long long i = 1; i <= n; i++)
    {
        long long t;
        scanf("%lld", &t);
        a[t] = i;
    }
    se.insert(0);
    se.insert(0);
    se.insert(n + 1);
    se.insert(n + 1);
    se.insert(a[n]);
    for(long long i = n - 1; i >= 1; i--)
    {
        multiset<long long>::iterator it = se.lower_bound(a[i]), it1, it2, it3, it4;
        it1 = next(it);
        it2 = prev(it);
        it3 = prev(it2);
        ans += (*it2 - *it3) * (*it - a[i]) * i;
        ans += (*it1 - *it) * (a[i] - *it2) * i;
        se.insert(a[i]);
    }
    printf("%lld", ans);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

#define int long long

struct Edge {
	int to, cost, dist;
};
struct Node {
	int v, cost;
};
bool operator>(const Node& n1, const Node& n2) {
	return n1.cost > n2.cost;
}

signed main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, M;
	while ( cin >> N >> M, N || M ) {
		vector< vector<Edge> > G(N);
		REP(i, M) {
			int u, v, d, c; cin >> u >> v >> d >> c; --u, --v;
			G[u].pb({v, c, d});
			G[v].pb({u, c, d});
		}
		vector<ll> dist(N, linf); dist[0] = 0;
		{
			priority_queue<Node, vector<Node>, greater<Node> > Q; Q.push({0, 0});
			while ( !Q.empty() ) {
				Node node = Q.top(); Q.pop();
				int v = node.v, cost = node.cost;
				if (cost > dist[v]) continue;
				assert(cost == dist[v]);
				for (const Edge& e : G[v]) {
					if (dist[v] + e.dist < dist[e.to]) {
						dist[e.to] = dist[v] + e.dist;
						Q.push({e.to, dist[e.to]});
					}
				}
			}
		}
		vector< vector<Edge> > g(N);

/*
		for (int i = 0; i < N; ++i) {
			cout << dist[i] << " ";
		}
		cout << endl;
*/

		vector<ll> a(N, inf); a[0] = 0;
		REP(i, N) {
			for (const Edge& e : G[i]) {
				if (dist[i] + e.dist <= dist[e.to]) {
					assert(dist[i] + e.dist == dist[e.to]);
					a[e.to] = min(a[e.to], e.cost);
//					g[i].pb({e.to, e.cost, e.dist});
//					g[e.to].pb({i, e.cost, e.dist});
				}
			}
		}
		ll ans = 0;
		REP(i, N) ans += a[i];
		cout << ans << endl;
//		G = g;
/*
		ll ans = 0;
		{
			int cnt = 0;
			vector<bool> used(N, false);
			priority_queue<Node, vector<Node>, greater<Node> > Q; Q.push({0, 0});
			while ( !Q.empty() ) {
				Node node = Q.top(); Q.pop();
				int v = node.v, cost = node.cost;
				if (used[v]) continue;
				used[v] = true;
				++cnt;
				ans += cost;
				for (const Edge& e : G[v]) {
//					if ( !used[e.to] && dist[v] + e.dist == dist[e.to] ) {
					if ( !used[e.to] ) {
						Q.push({e.to, e.cost});
					}
				}
			}
			assert(cnt == N);
		}
		cout << ans << endl;
*/
	}
}

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

using namespace std;

using lint = long long;

void solve() {
	int A, B; scanf("%d%d", &A, &B);
	int r = B-A;
	int ans = r*(r+1)/2 - B;
	printf("%d\n", ans);
}


int main(int argc, char *argv[]) {
	int T=1;
	for(int TC = 1; TC <= T; TC++) {
		solve();
	}
	return 0;
}

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

using namespace std;


int main(){
    
    long int S;
    cin >> S;
    
    long int x1, y1, x2, y2;
    
    x1 = sqrt(S);
    
    while (x1*x1 < S) {
        x1 += 1;
    }
    y2 = x1;

    x2 = abs(x1*y2 - S);
    y1 = 1;
    
    cout << 0 << " " << 0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;

}



Measured memory_bytes: 256
import fractions
a, b, c, d = map(int, input().split())
ans = 0
nc = b//c - (a-1)//c
nd = b//d - (a-1)//d
cd = c*d // fractions.gcd(c,d)
ncd = b//cd - (a-1)//cd
ans = b-a+1-nc-nd+ncd
print(ans)

Measured memory_bytes: 5344
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    N = int(read())
    one = N % 10
    if one == 3:
        ans = 'bon'
    elif one == 0 or one == 1 or one == 6 or one == 8:
        ans = 'pon'
    else:
        ans = 'hon'
    print(ans)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstring>
#include<string>
using namespace std;
typedef long long LL;
int cnt1,cnt2,cnt3,l1,l2,l3,turn=1;
int main(){
	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;
	l1=s1.size();
	l2=s2.size();
	l3=s3.size();
	while(cnt1!=l1+1&&cnt2!=l2+1&&cnt3!=l3+1){
		if(turn==1){
	//	puts("a");
			turn = s1[cnt1++]-'a'+1;
			if(cnt1==l1+1){
				puts("A");
				return 0;
				}
			}
		if(turn==2){
	//	puts("b");
			turn = s2[cnt2++]-'a'+1;
			if(cnt2==l2+1){
				puts("B");
				return 0;
				}
			}
		if(turn==3){
	//	puts("c");
			turn = s3[cnt3++]-'a'+1;
			if(cnt3==l3+1){
				puts("C");
				return 0;
				}
			}
		}
	return 0;
	}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
typedef long long ll;

using namespace std;

int N;
int V[51],C;
int main() {
    cin>>N;
    for(int i=0;i<N;i++) cin>>V[i];

    int res = 0;
    for(int i=0;i<N;i++) {
        cin>>C;
        if(V[i]-C>0) res+=V[i]-C;
    }
    cout<<res;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)

string S;
ll dp[100005][3];

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>S;

ll N=S.size();

if(S[0]=='0'){
	dp[0][1]=1;
}else{
	dp[0][0]=1;
}
rep1(i,N){
	if(S[i]=='0'){
		dp[i][1]=dp[i-1][0]+1;
		dp[i][0]=dp[i-1][1];
	}else{
		dp[i][0]=dp[i-1][1]+1;
		dp[i][1]=dp[i-1][0];
	}
}

cout<<min(dp[N-1][0],dp[N-1][1])<<endl;

}
	


Measured memory_bytes: 2768
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    char s;
    std::cin >> s;
    std::cout << (char)(s+1) << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		for(int i = str.length() - 1; i > -1; i--){
			System.out.printf("%c", str.charAt(i));
		}
		System.out.println();
	}
}

Measured memory_bytes: 11000
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
//#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int H;
    int W;
    
    cin >> H;
    cin >> W;
    
    string a[H][W];
    int flagshowH[H]={};
    int flagshowW[W]={};
    string tmp;
    for( int hi = 0 ; hi < H ; hi++ ){
        cin >> tmp;
        for( int wi = 0 ; wi < W ; wi++ ){
            a[hi][wi] = tmp.substr(wi,1);
            if(a[hi][wi]=="#") flagshowW[wi]=1;
        }
    }

    for( int wi = 0 ; wi < W ; wi++ ){
        for( int hi = 0 ; hi < H ; hi++ ){
            if(a[hi][wi]=="#") flagshowH[hi]=1;
        }
    }

    for( int hi = 0 ; hi < H ; hi++ ){
        if(flagshowH[hi]==1){
            for( int wi = 0 ; wi < W ; wi++ ){
                if(flagshowW[wi]) cout << a[hi][wi];
            }
            cout << endl;
        }
    }


}

Measured memory_bytes: 768
h, w = map(int,input().split())
ans = 10 ** 10
if h % 3 == 0 or w % 3 == 0 :
    print(0)
    exit()

if h % 3 != 0 :
    ans = min(ans, w)
if w % 3 != 0 :
    ans = min(ans, h)

for j in range(1, h // 2 + 1):
    a = [w * j, (h - j) * (w // 2), (h - j) * (w // 2 + w % 2)]
    a.sort()
    ans = min(ans, a[2] - a[0])

for j in range(1, w // 2 + 1):
    a = [h * j, (w - j) * (h // 2), (w - j) * (h // 2 + h % 2)]
    a.sort()
    ans = min(ans, a[2] - a[0])

print(ans)

Measured memory_bytes: 41580
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<string>
#include<cstdio>
#include<stack>
#include<memory.h>
#include<cmath>
#include<bitset>
#include<functional>
#include<memory>
#include<utility>
using namespace std;
#define FOR(i,m,n) for(i=m;i<n;i++)
#define MIN(x,y) (x>y?y:x)
#define ab(x,y) (x>y ?(x-y):(y-x))
#define CLR(a,b) memset(a,b,sizeof(a))
#define ROF(i,m,n) for(i=m;i>=n;i--)
#define BUG cout<<"debug"<<endl;
#define RT return
#define BK break
#define HEAP priority_queue
#define SP " "
#define lowf(a,b,c) lower_bound(a,b,c)
#define upf(a,b,c) upper_bound(a,b,c)
#define CP bool cmp(node A,node B)
#define maxn 100000
typedef long long LL;
typedef vector<int> VI;
const int INF = 214748347;
const int NEN = -INF - 1;
const LL LINF = 9223372036854775807;
bool vis[10005];
int dis[10005];
int fa[10005];
typedef struct edge
{
	int dest;
	int power;
	int cost;
	edge(int v,int d, int c)
	{
		dest = v;
		power = d;
		cost = c;
	}
	edge()
	{
		;
	}
}edge;
vector<vector<edge>>Map(10010);
int N, M;
queue<int>spfa;
int main()
{
	while (cin>>N>>M&&(M+N))
	{
		while (!spfa.empty())spfa.pop();
		CLR(vis, 0);
		int i, a, b,temp,u,v,d,c;
		FOR(i, 0, N + 2)dis[i]= INF;
		FOR(i, 0,N+2)Map[i].clear();
		FOR(i, 0, M)
		{
			scanf("%d %d %d %d", &u, &v, &d, &c);
			Map[u].push_back(edge(v,d,c));
			Map[v].push_back(edge(u,d,c));
		}
		spfa.push(1);
		vis[1] = 1;
		fa[1] = 0;
		dis[1] = 0;
		int targ, tdis,tc;
		while (!spfa.empty())
		{
			temp = spfa.front();
			spfa.pop();
			vis[temp] = 0;
			FOR(i, 0, Map[temp].size())
			{
				targ = Map[temp][i].dest;
				tdis = Map[temp][i].power;
				tc = Map[temp][i].cost;
				if (tdis + dis[temp] < dis[targ])
				{
					if (!vis[targ])
					{
						spfa.push(targ);
						vis[targ] = 1;
					}
					dis[targ] = dis[temp] + tdis;
					fa[targ] = tc;
				}
				else if ((tdis + dis[temp]) == dis[targ])
				{
					fa[targ] = min(fa[targ], tc);
				}
			}
		}
		int ans = 0;
		FOR(i, 1, N + 1)
		{
			ans += fa[i];
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	ll N,A,B,ans;
	cin>>N>>A>>B;
	if(B<A)ans=0;
	else if(B==A)ans=1;
	else if(N==1)ans=0;
	else if(N==2)ans=1;
	else{
		ans=1+(N-2)*(B-A);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int n,l;
  scanf("%d %d", &n, &l);

	int taste0 = 1-l;
	int eat;
	if (taste0 < 1) {
		eat = 1;
	} else if (taste0 > n) {
		eat = n;
	} else {
		eat = taste0;
	}

	int sum = (l-1)*(n-1) + (1+n)*n/2;
	sum -= eat;
	printf("%d\n", sum);

  return 0;
}

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

#define F first
#define S second

using namespace std;
typedef long double ld;
typedef long long ll;

const int max_n = 300011, max_m = 500011, inf = 1000111222;
const ll inff = 1000111222333444;

struct dsu {
    int p[max_n], sz[max_n];
    dsu() {
        for (int i = 0; i < max_n; ++i) {
            p[i] = i;
            sz[i] = 1;
        }
    }
    int find_set(int x) {
        if (p[x] == x) return x;
        return p[x] = find_set(p[x]);
    }
    void union_set(int x, int y) {
        x = find_set(x);
        y = find_set(y);
        if (x != y) {
            if (sz[x] < sz[y]) swap(x, y);
            p[y] = x;
            sz[x] += sz[y];
        }
    }
};

int n, a[max_n], d;
vector<pair<ll, pair<int, int> > > edges;
dsu dd;

ll dist(int i, int q) {
    return 1LL * abs(i - q) * d + a[i] + a[q];
}

void dev(int l, int r) {
    if (l + 1 == r) {
        return;
    }
    int mid = (l + r) / 2;
    pair<ll, int> cv1, cv2;
    cv1 = cv2 = {inff, 0};
    for (int i = l; i < mid; ++i) {
        cv1 = min(cv1, {a[i] - 1LL * d * i, i});
    }
    for (int i = mid; i < r; ++i) {
        cv2 = min(cv2, {a[i] + 1LL * d * i, i});
    }
    for (int i = l; i < mid; ++i) edges.push_back({dist(i, cv2.S), {i, cv2.S}});
    for (int i = mid; i < r; ++i) edges.push_back({dist(i, cv1.S), {i, cv1.S}});
    dev(l, mid);
    dev(mid, r);
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> d;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    dev(0, n);
    sort(edges.begin(), edges.end());
    ll ans = 0;
    for (int i = 0; i < edges.size(); ++i) {
        if (dd.find_set(edges[i].S.F) != dd.find_set(edges[i].S.S)) {
            dd.union_set(edges[i].S.F, edges[i].S.S);
            ans += edges[i].F;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 71008
import math

li = list(map(int,input().split()))
A=li[0]
B=li[1]
H=li[2]
M=li[3]

long = M/60 * 360
short = H/12 * 360 + M/60 * 30

def f(a,b,angle):
    c2 = a*a + b*b -2*a*b*math.cos(math.radians(angle))
    return math.sqrt(c2)

angle = 0
ans = 0
if(short==long):
    ans = abs(A-B)
elif(abs(short-long) == 180):
    ans = A+B
else:
    angle = abs(short-long)
    if(angle > 180):
        angle = 360 - angle
    ans = f(A,B,angle)

print(ans)

Measured memory_bytes: 9432
s=input();ans=0
if s[0]!='C':
    ans+=1
if s[1]!='O':
    ans+=1
if s[2]!='D':
    ans+=1
if s[3]!='E':
    ans+=1
if s[4]!='F':
    ans+=1
if s[5]!='E':
    ans+=1
if s[6]!='S':
    ans+=1
if s[7]!='T':
    ans+=1
if s[8]!='I':
    ans+=1
if s[9]!='V':
    ans+=1
if s[10]!='A':
    ans+=1
if s[11]!='L':
    ans+=1
if s[12]!='2':
    ans+=1
if s[13]!='0':
    ans+=1
if s[14]!='1':
    ans+=1
if s[15]!='6':
    ans+=1
print(ans)

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  map<char, int> m;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++)
    m[s[i]]++;

  bool can = true;
  for (auto x : m)
    if (x.second % 2 == 1)
      can = false;

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define DIM 100005
using namespace std;
int n, k, i, ok, x, y, t, nr, k2;
long long m, maxim;
int c[DIM], viz[DIM];
vector<int> v[DIM];
pair<int, int> w[DIM];
void dfs(int nod){
    viz[nod] = 1;
    c[nod] = nr;
    for(int i = 0; i < v[nod].size(); i++){
        if(viz[ v[nod][i] ] == 0){
            dfs(v[nod][i]);
        }
    }
}
int main(){
    cin>> n >> m >> k;
    if(m == n - 1){
        ok = 1;
        for(i = 1; i <= k; i++){
            cin>> x >> y >> t;
            if(t == 1){
                ok = 0;
            }
        }
        if(ok == 1){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
        return 0;
    }
    for(i = 1; i <= k; i++){
        cin>> x >> y >> t;
        x++;
        y++;
        if(t == 0){
            v[x].push_back(y);
            v[y].push_back(x);
        }
        else{
            w[++k2] = make_pair(x, y);
        }
    }
    maxim = n;
    for(i = 1; i <= n; i++){
        if(viz[i] == 0){
            nr++;
            dfs(i);
            maxim--;
        }
    }
    maxim += nr * 1LL * (nr - 1) / 2;
    ok = 1;
    if(m > maxim){
        ok = 0;
    }
    for(i = 1; i <= k2; i++){
        if(c[ w[i].first ] == c[ w[i].second ]){
            ok = 0;
        }
    }
    if(ok == 1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


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

int main()
{
    bool h[13]={};
    bool s[13]={};
    bool c[13]={};
    bool d[13]={};
    char CharCheck=0;
    int IntCheck=0;
    int Num=0;
    cin>>Num;
    for (int i=0;i<Num;i++)
    {
        cin>>CharCheck>>IntCheck;
        switch(CharCheck)
        {
            case 'S':
				s[IntCheck-1] = 1;
            break; 
            case 'H':
            h[IntCheck-1]=1;
            break;
            case 'C':
            c[IntCheck-1]=1;
            break;
			case 'D':
            d[IntCheck-1]=1;
            break;
        }
    }
    //???????????????????????????????¶?????????§????????????
    for(int i=0;i<13;i++)
    {
        if(s[i]==0)cout<<"S "<<i+1<<endl;
    }
    //????????????????????????????¶?????????§????????????
    for(int i=0;i<13;i++)
    {
        if(h[i]==0)cout<<"H "<<i+1<<endl;
    }
    //????????????????????????????¶?????????§????????????
    for(int i=0;i<13;i++)
    {
        if(c[i]==0)cout<<"C "<<i+1<<endl;
    }
    //????????????????????????????¶?????????§????????????
    for(int i=0;i<13;i++)
    {
        if(d[i]==0)cout<<"D "<<i+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>

int main(int argc, const char **argv)
{
    int div = 0, min = 0, max = 0, loop = 0;

    fscanf(stdin, "%d", &div);
    fscanf(stdin, "%d %d", &min, &max);

    for ( loop = min; loop <= max; loop++ )
    {
        if ( loop % div == 0 )
        {
            fprintf(stdout, "OK\n");
            return 0;
        }
    }

    fprintf(stdout, "NG\n");
    return 0;
}

Measured memory_bytes: 2080