akhauriyash/Code-Regression huggingface dataset:
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <array>
#include <functional>
#include <iomanip>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize n = scan<usize>();
  const usize m = scan<usize>();
  std::vector<bool> s(n, false), t(n, false);
  for (const usize i : rep(0, m)) {
    const usize a = scan<usize>() - 1;
    const usize b = scan<usize>() - 1;
    if (a == 0) {
      s[b] = true;
    }
    if (b == n - 1) {
      t[a] = true;
    }
  }
  bool ans = false;
  for (const usize i : rep(0, n)) {
    if (s[i] && t[i]) {
      ans = true;
    }
  }
  std::cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


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

// using namespace std;

bool is_same_char(char c1, char c2)
{
	int diff = 'A' - 'a';
	if (c1 == c2 || c1 + diff == c2 || c1 - diff == c2)
	{
		return true;
	}
	else
	{
		return false;
	}
}

int main()
{
	string target_str, str;
	int number = 0;
	bool aho = true;
	cin >> target_str;

	while (cin >> str)
	{
		if (str == "END_OF_TEXT")
		{
			break;
		}
		if (str.length() != target_str.length())
		{
			continue;
		}
		else
		{
			bool flag = true;
			for (int i = 0; i < str.length(); ++i)
			{
				bool result = is_same_char(str[i], target_str[i]);
				if (!result)
				{
					flag = false;
					break;
				}
			}
			if (flag)
			{
				++number;
			}
		}
	}
	cout << number << endl;
	return 0;
}



Measured memory_bytes: 3140
var N,i,j,count:integer; 
    H:array[1..25] of integer;
    flag:boolean;
begin
read(N);
for i := 1 to N do read(H[i]);
for i := 2 to N do
 begin
  flag:=true;
  for j := 1 to i-1 do if H[i]<H[j] then flag:=false;
  if flag then inc(count);
 end;
write(count+1)
end.

Measured memory_bytes: 128
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007

ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
{
  ll ans=0;
  if(i>=n)
    return 0;

  if(dp[i][k]!=-1)
    return dp[i][k];


  if(k!=0)
  ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
  else
  ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

  return dp[i][k]=ans;

}

//ll t[400008];
// void build(vector<ll>& a, int v, int tl, int tr) {
//     if (tl == tr) {
//         t[v] = a[tl];
//     } else {
//         int tm = (tl + tr) / 2;
//         build(a, v*2, tl, tm);
//         build(a, v*2+1, tm+1, tr);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }

// ll maxi(int v, int tl, int tr, int l, int r) {
//     if (l > r) 
//         return 0;
//     if (l == tl && r == tr) {
//         return t[v];
//     }
//     int tm = (tl + tr) / 2;
//     return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
// }



// void update(int v, int tl, int tr, int pos, ll new_val) {
//     if (tl == tr) {
//         t[v] = new_val;
//     } else {
//         int tm = (tl + tr) / 2;
//         if (pos <= tm)
//             update(v*2, tl, tm, pos, new_val);
//         else
//             update(v*2+1, tm+1, tr, pos, new_val);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }


struct hash_pair {
   template <class T1, class T2>
   size_t operator()(const pair<T1, T2>& p) const{
      auto hash1 = hash<T1>{}(p.first);
      auto hash2 = hash<T2>{}(p.second);
      return hash1 ^ hash2;
   }
};

int main() { 

int h,w,m,x,y;
set<pair<int,int> > s;
cin>>h>>w>>m;
int row[h+1]={0};
int col[w+1]={0};

unordered_map<pair<int,int> , int ,hash_pair> hap;
for(int i=0;i<m;i++)
{
  cin>>x>>y;
 // hap[{x,y}]=1;
  s.insert({x,y});
  row[x]++;
  col[y]++;
}

int ans=0,ma=0;
for(int i=1;i<=h;i++)
{
  //cout<<row[i]<<" ";
  ans=max(ans,row[i]);
}

for(int i=1;i<=w;i++)
{
  ma=max(ma,col[i]);
}

vector<int> candr;
vector<int> candc;
for(int i=1;i<=h;i++)
  if(ans==row[i])
    candr.pb(i);

for(int i=1;i<=w;i++)
  if(ma==col[i])
    candc.pb(i);


ll k=ans+ma-1,flag=1;
for(int i=0;i<candr.size();i++)
  for(int j=0;j<candc.size();j++)
  {
    if(s.find({candr[i],candc[j]})==s.end())
    {
      k++;
      goto l1;
    }
    if(flag==0)
      break;
  }


l1:
cout<<k;


return 0;
}


Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
bool vis[100001];
vector<int>list1[100001];
stack<int>stk;
void topo(int start)
{
	vis[start]=true;
	for(int i=0;i<list1[start].size();i++)
	{
		if(vis[list1[start][i]]==false)
		topo(list1[start][i]);
	}
	stk.push(start);
}
int main()
{
	int node,edge;
	cin >> node >> edge ;
	int i,j,k;
	memset(list1,0,sizeof(list1));
	for(i=1;i<=edge;i++)
	{
	    int x,y;
	    cin >> x >> y;
	    list1[x].push_back(y);
	}
	memset(vis,false,sizeof(vis));
	int t_sort[node+1];
//	for(i=1;i<=node;i++)
//	cout << indegree[i] << " ";
	for(i=1;i<=node;i++)
	{
		if(vis[i]==false)
		topo(i);
	}
	k=1;
	while(!stk.empty())
	{
		t_sort[k++]=stk.top();
		stk.pop();
	}
//	for(i=1;i<=node;i++)
//	cout << t_sort[i] << " ";
//	for(i=1;i<=node;i++)
//	{
//		for(j=0;j<list[i].size();j++)
//		cout << list[i][j] << " ";
//		cout << "\n";
//	}
//	for(i=0;i<t_sort.size();i++)
//	cout << t_sort[i] << " ";
	int dis[node+1]={0};
	for(i=1;i<=node;i++)
	{
		for(j=0;j<list1[i].size();j++)
		{
			dis[list1[i][j]]=-1000000;
		}
	}
	for(i=1;i<=node;i++)
	{
		if(dis[t_sort[i]]!=-1000000)
		{
		for(j=0;j<list1[t_sort[i]].size();j++)
		{
			if(dis[list1[t_sort[i]][j]]<dis[t_sort[i]]+1)
			dis[list1[t_sort[i]][j]]=dis[t_sort[i]]+1;
		}
		}
	}
	int ans=0;
	for(i=1;i<=node;i++)
	{
		if(dis[i]>ans)
		ans=dis[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 8656
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
ll dp[3005][3005][2];
ll arr[3005];
ll vis[3005][3005][2];
ll solve(ll i,ll j,int turn)
{
	if(i == j)
	{
		if(!turn)
			return arr[i];
		return -arr[i];
	}
	if(vis[i][j][turn])
		return dp[i][j][turn];
	if(!turn)
		dp[i][j][turn] = max(arr[j]+solve(i,j-1,1),arr[i]+solve(i+1,j,1));
	else
		dp[i][j][turn] = min(-arr[j]+solve(i,j-1,0),-arr[i]+solve(i+1,j,0));
	vis[i][j][turn] = 1;
	return dp[i][j][turn];
}
int main()
{
	ll n,i,j;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>arr[i];
	cout<<(solve(0,n-1,0))<<endl;
	return 0;
}

Measured memory_bytes: 281088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,(e))
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define irpz(i,s) irp(i,(s),-1)
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T> T in(){T x;cin>>x;return x;}
// long long a = in<long long>();
template<class T> vector<T> inarr(int s,int e, T init=0){
	vector<T> v;T x;
	for(int i=0;i<s;++i)v.push_back(init);
	for(int i=s;i<e;++i){x=in<T>();v.push_back(x);}
	return v;
}

string S;

string solve(){
	rp(i,0,S.size()) S[i] = 'x';
	return S;
}

int main(){
	cin>>S;
	cout<< solve() <<endl;
}


Measured memory_bytes: 256
n = int(input())
w = [input() for _ in range(n)]

ans = 'Yes'
if n!=len(set(w)):
  ans ='No'
else:
  for i in range(n-1):
    if w[i][-1]!=w[i+1][0]:      
      ans='No'
      break
print(ans)  

Measured memory_bytes: 3060
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202007_2nd/D_input.txt")
else:
    f=sys.stdin
#from 2nd count
def cnt_func(num):
    cnt=0
    while num:
        num%=bin(num).count("1")
        cnt+=1
    return cnt+1
n=int(f.readline().strip())
s=f.readline().strip()
input_val=int(s,2)
input_one_count=s.count("1")
#Base value
zero_first=input_val%(input_one_count+1)
one_first=input_val%(input_one_count-1) if input_one_count>1 else 0
ans=0
for idx,emt in enumerate(s):
    p=n-idx-1
    if emt=="0": #inverted to "1"
        ans=cnt_func((zero_first+(pow(2,p,input_one_count+1)))%(input_one_count+1))
    else: #inverted to "0"
        if input_one_count>1:
            ans=cnt_func((one_first-(pow(2,p,input_one_count-1)))%(input_one_count-1))
        else:
            ans=0
    print(ans)
f.close()

Measured memory_bytes: 9508
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int n,m,k;
    cin >> n >> m >> k;
    rep(i, 0, n+1){
        rep(j, 0, m+1){
             if(k == i*m+j*n-i*j*2){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3620
#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;
const int mod = (int)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, m;
	cin >>n >>m;
	vector<pii> v(m);
	rep(i,m) cin >> v[i].first >>v[i].second;
	sort(all(v), [](pii a, pii b){ return a.second < b.second;});
	int ans =0, crr= 0;
	rep(i, m){
		//dbg("db",v[i].first,v[i].second,crr,ans);
		if(crr <= v[i].first){
			ans++;
			crr = v[i].second;
		}
	}
	cout << ans <<"\n";
	return 0;
}


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

int main(){
    int a,b,c,cnt=0;
    cin >> a >> b >> c;
    if(a==b&&b==c){
        if(a%2&&b%2&&c%2) cout << 0 << endl;
        else cout << -1 << endl;
        return 0;
    } 
    while(!(a%2||b%2||c%2)){
        int d = a,e=b,f=c;
        a = (e+f)/2;
        b = (d+f)/2;
        c = (e+d)/2;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int a,b,c,d;

int main(){
	cin>>a>>b>>c>>d;
	cout<<(a!=c)<<endl;
}

Measured memory_bytes: 256
// Problem : A - αlphabet
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	char c; cin >> c;
	if (c >= 'a' && c <= 'z') {
		cout << 'a' << "\n";
	} else {
		cout << 'A';
	}
	return 0;
}
 


Measured memory_bytes: 3644
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
L,R=map(int,input().split())
if R-L>=2019:
    print(0)
    exit()
else:
    ans=2019999
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans=min(i*j%2019,ans)
            if ans==0:
                print(ans)
                exit()
    print(ans)

Measured memory_bytes: 20892
#include <stdlib.h>
#include <stdio.h>

int main() {
    char strinput[13];
    scanf("%s", strinput);
    printf("%c", strinput[0]);
    printf("%c", strinput[1]);
    printf("%c", strinput[2]);
    printf("%c", strinput[3]);
    printf(" ");
    printf("%c", strinput[4]);
    printf("%c", strinput[5]);
    printf("%c", strinput[6]);
    printf("%c", strinput[7]);
    printf("%c", strinput[8]);
    printf("%c", strinput[9]);
    printf("%c", strinput[10]);
    printf("%c", strinput[11]);
    printf("\n");
    return 0;
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int N; cin >> N;
    VS S(N); VI P(N); REP(i,N) cin >> S[i] >> P[i];
    VI p(N); REP(i,N) p[i] = i;

    auto c = [&](int i, int j){
        if(S[i] < S[j]) return true;
        else if(S[i] == S[j]){
            if(P[i]>P[j]) return true;
            else return false;
        }
        else return false;
    };

    sort(ALL(p), c);
    for(int i : p) cout << i+1 << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3644
import math
import numpy as np
k = int(input())

Map = [[0 for j in range(k)] for i in range(k)]
for i  in range(1,k+1):
    for j in range(1,k+1):
        tmp = math.gcd(i,j)
        Map[i-1][j-1] = tmp
        Map[j-1][i-1] = tmp

ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        tmp_ans = Map[i-1][j-1]
        for x in range(1,k+1):
            ans += Map[tmp_ans-1][x-1]
            
            
print(ans)


Measured memory_bytes: 27376
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <stack>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)

typedef long long ll;
typedef pair<int, int> pii;

string solve(string str)
{
	stack<char> stk;
	char ascii[256];
	ascii[']'] = '[';
	ascii[')'] = '(';

	rep(i, str.size()) {
		if (str[i] == '[' || str[i] == '(')
			stk.push(str[i]);
		if (str[i] == ']' || str[i] == ')') {
			if (stk.size() == 0)
				return "no";
			char ch = stk.top(); stk.pop();
			if (ch != ascii[str[i]])
				return "no";
		}
	}

	return stk.size()==0?"yes":"no";
}

int main(void)
{
	string s;
	for (;;) {
		getline(cin, s);
		if (s[0] == '.') break;

		cout << solve(s) << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <cstdio>
#include <iostream>
#include <stack>
#include <stdlib.h>
#define INF 100000
using namespace std;
int point_a = 0;
int point_b = -1;
int* A = (int*)malloc(INF*sizeof(int));
int* B = (int*)malloc(INF*sizeof(int));
stack<int> st;
int array[512345];
int a[212345];

void pushback(int b){
	while(b>=0)
	{
		st.push(B[b]);
		b--;
	}
}

void popto(int b,int t){
	while(t > 0){
		b++;
		B[b] = st.top();
		st.pop();
		t--;
	}
}

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
    /*这方法过不了4个例子以外的*/ 
    /*
	for(int i = 1; i <= n; i++){
		
		
		for(int j = 0; j < i; j++){
			st.push(A[j]);
		}
		for(int j = 0; j < i; j++){
			A[j] = st.top();
			st.pop();
		}
	

		}
	*/
	int left = 212345, right = left + 1;
	for(int i = 0; i < n; i++){
		if(i%2 == (n-1)%2){
			array[left--] = a[i];
		}
		else{
			array[right++] = a[i];
		}
	}
	

for(int i = left + 1; i < right; i++){
		cout << array[i] << " ";
	}
	cout << endl;
	
}

Measured memory_bytes: 3712
in_data=input()

in_list=in_data.split(" ")

in_list[0]=int(in_list[0])
in_list[1]=int(in_list[1])
in_list[2]=int(in_list[2])

##約数の配列を作成

divisor=[]

for x in range(in_list[0],in_list[1]+1):
    if in_list[2]%x==0:
        number=in_list[2]/x
        divisor.append(number)

print(len(divisor))


Measured memory_bytes: 5600
while True:
    H, W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        if i == 0 or i == H - 1:
            print("#"*W)
        else:
            print("#" + "."*(W-2) + "#")
    print()


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,rgb[3][4005]={};
	cin>>n;
	string s;
	cin>>s;
	for(ll i=0;i<n;i++){
		if(s[i]=='R'){
			rgb[0][i]=1;
		}
		else if(s[i]=='G'){
			rgb[1][i]=1;
		}
		else{
			rgb[2][i]=1;
		}
	}
	for(ll i=1;i<n;i++){
		for(ll j=0;j<3;j++){
			rgb[j][i]=rgb[j][i]+rgb[j][i-1];
		}
	}
	ll cnt=0;
	for(ll i=0;i<n;i++){
		for(ll k=i+2;k<n;k++){
			ll j;
			if((k+1+i+1)%2==0){
			j=(k+1+(i+1))/2;
			j--;
			}
			else{
				j=inf;
			}
			if(s[i]==s[k]){
				continue;
			}
			ll now=0;
			char ch;
			if(s[i]!='R'&&s[k]!='R'){
				now=0;
				ch='R';
			}
			else if(s[i]!='G'&&s[k]!='G'){
				now=1;
				ch='G';
			}
			else{
				now=2;
				ch='B';
			}
			cnt+=rgb[now][k-1]-rgb[now][i];
			if(j!=inf){
	//			cout << s[j]<<" ";
			}
	//		cout << cnt<<" "<< i<<" "<< j<<" "<<k<<" "<<ch<<endl;
			if(j==inf){
				continue;
			}
				if(ch==s[j]){
			//		cout << "k";
					cnt--;
				}
	//		cout << cnt<<endl;
		}
	}
	cout <<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	int N;
	cin>>N;
	VI A(N);
	ll sum = 0;
	REP(i, N) {cin >> A[i]; sum += A[i];}

	ll snuke = 0, kuma = sum;
	ll ans = LLINF;
	REP(i, N-1) {
		snuke += A[i];
		kuma -= A[i];
		ans = min(ans, abs(snuke - kuma));
	}
	cout<<ans<<endl;










	return 0;
}


Measured memory_bytes: 3924
#include<cstdio>
#include<cmath>
int main(){
  double a,b,c;
  scanf("%lf %lf %lf",&a,&b,&c);
  printf("%.7f\n",a*b*sin((M_PI*c/180))/2);
  printf("%.7f\n",a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos((M_PI*c/180))));
  printf("%.7f\n",b*sin((M_PI*c/180)));
}


Measured memory_bytes: 3104
def lscan; gets.split.map(&:to_i); end

N = gets.to_i
vv = lscan.map(&:to_f)

(N-1).times do |i|
  vv = vv.sort
  a,b = vv.shift, vv.shift
  vv.push (a+b)/2
end

p vv.max

Measured memory_bytes: 1788
import math

x = int(input())
# 1999 is false
if x > 1999:
  print('1')
elif x < 100:
  print('0')
else:
  upper, under = divmod(x, 100)
  if under == 0:
    print('1')
  elif upper > (under - 1) // 5:
    print('1')
  else:
    print('0')


Measured memory_bytes: 2940
import sys
N,K=map(int, input().split()) 

if K>(N-1)*(N-2)/2:
  print(-1)
  sys.exit()

a = []  

for i in range(2,N+1):
  a.append([1,i])

x = (N-1)*(N-2)/2 - K
for i in range(2,N+1):
  for j in range(i+1,N+1):
    if x==0:
      break
    else:
      a.append([i,j])
      x = x-1
  
print(len(a))
for i in a:print(*i, sep=' ')

Measured memory_bytes: 43760
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){

  int num[5];
  rep(i,5)cin >> num[i];

  rep(i,5){
    if(num[i]==0){
      cout << i+1 << endl;
    return 0;
  }
   }

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  string s;
  cin>>s;
  int N=s.size();
  int ans=N*(N-1)/2+1;
  std::vector<int> v(26,0);
  for(int i=0;i<N;i++)v[s[i]-'a']++;
  for(int i=0;i<26;i++)ans-=v[i]*(v[i]-1)/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 640
/*
 * FILE: ABC 137 A - +-x.cpp
 *
 * @author: Piyush Kanti Das <piyush123kantidas[at]gmail[dot]com>
 *
 * LINK:
 *
 * DATE CREATED: 11.08.2019 09:59:21 +06
 *
 * DESCRIPTION:
 *
 * DEVELOPMENT HISTORY:
 * Date         Version     Description
 * --------------------------------------------------------------
 * 11-08-2019	1.0         File Created
 *
 */


/*
// _______________________________________________________________/\\\_________
//  ______________________________________________________________\/\\\_________
//   ___/\\\\\\\\\___/\\\____/\\\__/\\\____________________________\/\\\_________
//    __/\\\/////\\\_\///____\//\\\/\\\___/\\\____/\\\__/\\\\\\\\\\_\/\\\_________
//     _\/\\\\\\\\\\___/\\\____\//\\\\\___\/\\\___\/\\\_\/\\\//////__\/\\\\\\\\\\__
//      _\/\\\//////___\/\\\_____\//\\\____\/\\\___\/\\\_\/\\\\\\\\\\_\/\\\/////\\\_
//       _\/\\\_________\/\\\__/\\_/\\\_____\/\\\___\/\\\_\////////\\\_\/\\\___\/\\\_
//        _\/\\\_________\/\\\_\//\\\\/______\//\\\\\\\\\___/\\\\\\\\\\_\/\\\___\/\\\_
//         _\///__________\///___\////_________\/////////___\//////////__\///____\///__
//
*/

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

typedef long long           ll;
typedef double              lf;
typedef unsigned long long  ull;
typedef pair<int, int>      pii;
typedef vector<pii>         vpii;
typedef vector<int>         vi;
typedef vector<long long>   vll;

#define __FastIO        ios_base::sync_with_stdio(false); cin.tie(0)

#define forr(i, a, b)   for (__typeof (a) i=a; i<=b; i++)
#define rof(i, b, a)    for (__typeof (a) i=b; i>=a; i--)
#define rep(i, n)       for (__typeof (n) i=0; i<n; i++)
#define forit(i, s)     for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define all(ar)         ar.begin(), ar.end()

#define fill(ar)   		memset(ar, -1, sizeof(ar))
#define clr(a)          memset(a, 0, sizeof(a))

#define nl              cout << '\n';
#define sp              cout << ' ';
#define ckk             cout << "##########\n"

#define pb              push_back
#define MP 				make_pair

#define debug1(x)       cerr << #x << ": " << x << endl
#define debug2(x, y)    cerr << #x << ": " << x << '\t' << #y << ": " << y << endl
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z << endl

#define gama 0.57721566490
#define PI              acos(-1.0)
#define INF             0x7fffffff
#define MOD             1000000007
#define EPS             1e-7
#define MAX             100005

int Set(int N,int pos){return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}


ll BM( ll a , ll b , ll m )
{
    if ( b == 0 ) return 1 ;
    ll x = BM(a,b/2,m);
    x = (( x % m) * (x % m))%m;
    
    if( b % 2 ) x = (( x % m) * (a %m)) % m ;
    return x ;
}

//Auto-format --> ctrl+shift+a
/********************* Code starts here ************************/

int main() {
    __FastIO;   //Be aware to use it!
    
    ll a, b;
    cin >> a >> b;
    ll ans = a*b;
    ans = max(ans, max(a+b, a - b));
    cout << ans << endl;
    return 0;
}


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

const int N = 3010;
int n;
ll a[N], dp[N][N][2];
bool vis[N][N][2];

ll rec(int l, int r, int t) {
	if (l > r)
		return 0;
	if (vis[l][r][t])
		return dp[l][r][t];
	vis[l][r][t] = true;
	if (t == 0) {
		return dp[l][r][t] = max(a[l] + rec(l + 1, r, 1), a[r] + rec(l, r - 1, 1));
	} else {
		return dp[l][r][t] = min(-a[l] + rec(l + 1, r, 0), -a[r] + rec(l, r - 1, 0));
	}
}

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ll answer = rec(0, n - 1, 0);
	cout << answer;

	return 0;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




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

	int N;
	cin >> N;
	vector<pair<double, double>> pos(N);
	for (int i = 0; i < N; ++i) {
		cin >> pos[i].first >> pos[i].second;
	}

	vector<vector<double>> dist(N, vector<double>(N));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			double x1, y1, x2, y2;
			tie(x1, y1) = pos[i];
			tie(x2, y2) = pos[j];
			double diffx = x1 - x2, diffy = y1 - y2;
			dist[i][j] = sqrt(diffx * diffx + diffy * diffy);
		}
	}

	Vi permu(N);
	for (int i = 0; i < N; ++i) {
		permu[i] = i;
	}

	double ans = 0;

	do {
		for (int i = 0; i < N - 1; ++i) {
			ans += dist[permu[i]][permu[i + 1]];
		}
	} while (next_permutation(permu.begin(), permu.end()));


	double facN = 1;
	for (int i = 1; i <= N; ++i) {
		facN *= i;
	}

	ans /= facN;

	cout << setprecision(20) <<ans << endl;

	return 0;
}

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

int main(){
    string s, t;
    int a, b;
    cin >> s >> t >> a >> b;
    string u;
    cin >> u;
    if (s == u) a--;
    else b--;
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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


const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


int main(){
    ll N;
    cin >> N;
    char s[101000];
    for(int i = 0; i < N; i++){
        cin >> s[i];
    }

    ll x[26];
    fill(x, x+26, 1);
    ll res = 1;
    for(int i = 0; i < N; i++){
        x[s[i] - 'a']++;
    }

    for(int j = 0; j < 26; j++){
        res = mul(res, x[j]);
    }

    cout << res - 1 << endl;


    return 0;
}


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

int main()
{
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());

  int ans = 1000000000;
  for (int i = 0; i < N; i++)
  {
    int start = A.at(i);
    int end = A.at((N - 1 + i) % N);
    if (end < start)
    {
      end += K;
    }
    ans = min(ans, end - start);
  }

  cout << ans << endl;
}


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

int main(void)
{
    string s;
    cin >> s;
    int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
    if(a+b+c+d==7)
        cout << a << '+' << b << '+' << c << '+' << d << "=7" << endl;
        else if (a + b + c - d == 7)
            cout << a << '+' << b << '+' << c << '-' << d <<"=7" <<endl;
            else if(a+b-c+d==7)
                cout << a << '+' << b << '-' << c << '+' << d << "=7" << endl;
                else if(a-b+c+d==7)
                    cout << a << '-' << b << '+' << c << '+' << d << "=7" << endl;
                    else if(a-b-c+d==7)
                        cout << a << '-' << b << '-' << c << '+' << d << "=7" << endl;
                        else if(a+b-c-d==7)
                            cout << a << '+' << b << '-' << c << '-' << d << "=7" << endl;
                            else if(a-b-c-d==7)
                                cout << a << '-' << b << '-' << c << '-' << d << "=7" << endl;
                                else if(a-b+c-d==7) 
                                    cout << a << '-' << b << '+' << c << '-' << d << "=7" << endl;

                            return 0;
}

Measured memory_bytes: 256
/*digits number*/
//输入两个整数求其和，然后计算其位数。
//按照进制原理来就可以了，不断用１０除移位，直到和变为０为止，
//就可以计数其位数。



#include <stdio.h>

int sum_digits(int n,int base)
{//定义一个函数，为以后操作简便(封装函数)
    int count = 0;          //初始化计数为零

    while(n){               //当n不为零的时候进行操作
        count++;
        n /= base;
    }

    return count;          //这个返回值很重要，一定要写
}

int main(void)
{
    int a,b;

    while(scanf("%d%d",&a,&b) != EOF)
        printf("%d\n",sum_digits(a + b,10));//这个输出很简便，记住！合并为一行

    return 0;
}





Measured memory_bytes: 2028
#include <bits/stdc++.h>
using namespace std;
#define     ll      long long
#define     pb      push_back
#define     F       first
#define     S       second
#define     n1      "\n"
#define     sz      size()
#define     cinfast ios_base::sync_with_stdio(false); cin.tie(NULL);

int x[110];
int main ()
{
int n , k ;
cin >> n >> k ;
for (int i = 0 ; i<k ; ++i){
    int d ; cin >> d;
    for (int j=0 ; j<d ; ++j){
        int a ; cin >> a;
        x[a]++;
    }
}
int ans=0;
for (int i=1; i<=n ; ++i )if(!x[i])ans++;
cout << ans ;
}






Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<iomanip>


using namespace std;


int main()

{
	long long x, y,q,r;
	cin >> x >> y;
	int  z = 0;
	while (x > 0)
	{
		q=x%y;
		z++;
		x /= y;
	}
	cout << z << endl;



}

Measured memory_bytes: 256
// Numeral_System.cpp
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1137&lang=jp

#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
string proc(string f1,string f2);
int main()
{
	int n;	//?¨?????????°
	string f1,f2;//mcxi?¨???????
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> f1 >> f2;
		cout << proc(f1,f2) << endl;
	}
	return 0;
}
string proc(string f1,string f2){
	string r="";
	int ibuf;	//??°??????????¨?
	int i1 = 0;
	int	i2 = 0;	//??°????????????????????????
	char sbuf;	//???????????????
	int iintn = 0;	//??°?????´????????°
	int ix = 1;		//?????°(mcxi????????????)
	int iintp=0;	//??°??????????????°
	for(int i=0;i<f1.length();i++){
		sbuf = f1[iintp];
		if((int)sbuf-(int)'0'>0 && (int)sbuf-(int)'0' < 10){//??°?????§??????
			iintn=(int)sbuf-(int)'0';
			iintp += 2;
			i++;
		}else{
			iintn=1;
			iintp ++;
		}//iintp????¬??????????iintn???2~9?????°???
		if(f1[iintp-1]=='m'){
			ix=1000;
		}else if(f1[iintp-1]=='c'){
			ix=100;
		}else if(f1[iintp-1]=='x'){
			ix=10;
		}else if(f1[iintp-1]=='i'){
			ix=1;
		}
		i1 = i1 + (ix * iintn);
	}
	//---------f2?¨????
	iintn = 0;	//??°?????´????????°
	ix = 1;		//?????°(mcxi????????????)
	iintp=0;	//??°??????????????°
	for(int i=0;i<f2.length();i++){
		sbuf = f2[iintp];
		if((int)sbuf-(int)'0'>0 && (int)sbuf-(int)'0' < 10){//??°?????§??????
			iintn=(int)sbuf-(int)'0';
			iintp += 2;
			i++;
		}else{
			iintn=1;
			iintp ++;
		}//iintp????¬??????????iintn???2~9?????°???
		if(f2[iintp-1]=='m'){
			ix=1000;
		}else if(f2[iintp-1]=='c'){
			ix=100;
		}else if(f2[iintp-1]=='x'){
			ix=10;
		}else if(f2[iintp-1]=='i'){
			ix=1;
		}
		i2 = i2 + (ix * iintn);
	}
	ibuf = i1 + i2;
	//1000??????
	if(ibuf / 1000 > 1){
		r+=to_string(ibuf/1000);
		r+="m";
	}else if(ibuf/1000 == 1){
		r+="m";
	}
	ibuf -= (ibuf / 1000) * 1000;
	if(ibuf / 100 > 1){
		r+=to_string(ibuf/100);
		r+="c";
	}else if(ibuf/100 == 1){
		r+="c";
	}
	ibuf -= (ibuf / 100) * 100;
	if(ibuf / 10 > 1){
		r+=to_string(ibuf/10);
		r+="x";
	}else if(ibuf/10 == 1){
		r+="x";
	}
	ibuf -= (ibuf / 10) * 10;
	if(ibuf / 1 > 1){
		r+=to_string(ibuf/1);
		r+="i";
	}else if(ibuf/1 == 1){
		r+="i";
	}
	return r;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
const int nax = 1e5+5; //this should be const for the below values to be initialised
vector < int > edges[nax];
int indegree[nax];
int dist[nax];
bool vis[nax];

void dfs(int i) {
	vis[i] = true;
	for(int j : edges[i]) {
		dist[j] = max(dist[j],dist[i]+1);
		indegree[j]--; //responsible for dp else tle
		if(indegree[j] == 0)
			dfs(j);
	}
}
int main() {
	
	int n,m,a,b;
	cin>>n>>m;
	for(int i = 0 ; i < m ; i++) {
		cin>>a>>b;
		edges[a].push_back(b);
		indegree[b]++;
	}
	for(int i = 1 ; i <= n ; i++) {
		if(!vis[i] and indegree[i]==0) {
			dfs(i);
		}
	}
	int ans = 0;
	for(int i = 1 ; i<=n ; i++) {
		ans = max(ans,dist[i]);
	}
	cout<<ans;
	return 0;
}
//Errichto's code


Measured memory_bytes: 9728
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename M>
void warshallFloyd(M &m, const int &n) {
  rep(k, n) rep(i, n) rep(j, n) cmin(m[i][j], m[i][k] + m[k][j]);
}

void solve() {
  int n, m;
  cin >> n >> m;
  vvi t(n, vi(n));
  rep(i, n) rep(j, n) t[i][j] = i == j ? 0 : INF;
  char gomi;
  rep(i, m) {
    int a, b, c, d;
    cin >> a >> gomi >> b >> gomi >> c >> gomi >> d;
    a--;
    b--;
    t[a][b] = c;
    t[b][a] = d;
  }
  warshallFloyd(t, n);
  int s, g, v, p;
  cin >> s >> gomi >> g >> gomi >> v >> gomi >> p;
  s--;
  g--;
  cout << v - p - t[s][g] - t[g][s] << endl;
}

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

int main(){
    ll n;
    cin >> n;
    ll a[n];
    ll sum = 0;
    ll ans = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    rep(i,n){
        ll b = a[i]%ll(1e9+7);
        sum -= a[i];
        ll c = sum%ll(1e9+7);
        ans += (b*c)%ll(1e9+7);
        ans %= ll(1e9+7);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5128
#include <stdio.h>

int main(){
	int x,y;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0) break;
		if(x>y){
			printf("%d %d\n",y,x);
		}else{
			printf("%d %d\n",x,y);
		}
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

ll pot[MX];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll X; cin >> X;

    ll i = 1;
    for (; ; i++) {
        pot[i] = i*i*i*i*i;
        if (i == 3000) break;
    }

    for (i = 0; i <= 3000; i++) {
        for (ll j = 0; j <= 3000; j++) {
            if (pot[i]-pot[j] == X) {
                cout << i << " " << j << "\n";
                return 0;
            }

            if (pot[j]-pot[i] == X) {
                cout << j << " " << i << "\n";
                return 0;
            }

            if (-pot[i]-pot[j] == X) {
                cout << -i << " " << j << "\n";
                return 0;
            }

            if (pot[i]-(-pot[j]) == X) {
                cout << i << " " << -j << "\n";
                return 0;
            }
        }

    }

    assert(false);
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
typedef vector<int> vi;
int main()
{
  int n;
  cin>>n;

  vector<string>op;

  for(int i=0;i<n;i++)
  {  string s;
      cin>>s;
      op.pb(s);
  }
  sort(op.begin(),op.end());
  int c=1;
  for(int i=1;i<n;i++)
  {
      if(op[i]!=op[i-1])
         c++;
  }
  cout<<c<<"\n";
   return 0;
}


Measured memory_bytes: 11660
#include <iostream>
#include <string>
using namespace std;
int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans=1;
    for(int i=0;i<N-1;i++){
        if(S[i]!=S[i+1]) ans ++;
    }
    cout << ans << endl;
}

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

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int N = sc.nextInt();
        int[] L = new int[N];
        Arrays.fill(L, 0);
        int sum = 0;
        for(int i = 1; i < N; i++){
          int A = sc.nextInt();
          L[A-1] += 1;
        }
        for(int i = 0; i < N; i++){
          System.out.println(L[i]);
        }
      }
}


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

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    ll X, Y, A, B, C;
    ll ans=0;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A), q(B), r(C);
    rep(i, A) cin >> p.at(i);
    rep(i, B) cin >> q.at(i);
    rep(i, C) cin >> r.at(i);
    sort(all(p), greater<ll>());
    sort(all(q), greater<ll>());
    rep(i, A-X) p.pop_back();
    rep(i, B-Y) q.pop_back();
    r.insert(r.end(), all(p));
    r.insert(r.end(), all(q));
    sort(all(r), greater<ll>());
    rep(i, C) r.pop_back();
    out(accumulate(all(r), ans));
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 5488
S = int(input())
h = int((S - (S % 3600)) / 3600)
m = int(((S - (h * 3600)) - (S - (h * 3600)) % 60) / 60)
s = int(S - (h * 3600 + m * 60))
print('{0}:{1}:{2}'.format(h, m, s))

Measured memory_bytes: 7688
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		String S = scanner.next();
		int max = 0;
		int x = 0;
		for (int i = 0; i < S.length(); i++) {
			if(S.charAt(i)=='I'){
				x++;
				if(x>max){
					max = x;
				}
			}else{
				x--;
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 9684
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    For(i,n) for(int i=0;i<n;i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    Sort(s) sort(s.begin(),s.end())
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    test   int t;cin>>t;forn(i,t)
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long 
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
    int n;
    map<int,int>f;
    cin>>n;
    forn(i,100)
    {
        forn(j,100)
        {
           forn(k,100)
           {
               int p=i*i+j*j+k*k+i*j+j*k+k*i;
               f[p]++;
            }
       }
   }
   for(int i=1;i<=n;i++)cout<<f[i]<<nl;

End;
}


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

const int kCellNum = 100;

void createMtx(int mtx[100][100], int rowNum, int colNum)
{
    for (int i=0; i<rowNum; ++i)
    {
        for (int j=0; j<colNum; ++j)
        {
            cin >> mtx[i][j];
        }
    }
}

int main()
{
    int mtxA[kCellNum][kCellNum] = {0};
    int mtxB[kCellNum][kCellNum] = {0};

    int n, m, l;
    cin >> n >> m >> l;
    createMtx(mtxA, n, m);
    createMtx(mtxB, m, l);

    for (int i=0; i<n; ++i)
    {
        for (int j=0; j<l; ++j)
        {
            long long sum = 0;
            for (int k=0; k<m; ++k)
            {
                sum += mtxA[i][k] * mtxB[k][j];
            }
            cout << sum;
            if (j != l-1) cout << ' ';
        }
        cout << endl;
    }

    return 0;
}

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

int main() {
  int a=0,b=0,ans=0;
  cin >> a;
  b = (a/10)*10;
  if ((a-b) == 1) {
    ans++;
  }
  a = a/10;
  b = (a/10)*10;
  if ((a-b) == 1) {
    ans++;
  } 
  a = a/10;
  b = (a/10)*10;
  if ((a-b) == 1) {
    ans++;
  } 
  cout << ans << endl;
}
  

Measured memory_bytes: 256