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

#define MAX 100

int main() {
	int N, s[MAX], S = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
		S += s[i];
	}
	if (S % 10 != 0) {
		cout << S << endl;
		return 0;
	} else {
		sort(s, s + N);
		for (int i = 0; i < N; i++) {
			if ((S - s[i]) % 10 != 0) {
				cout << S - s[i] << endl;
				return 0;
			}
		}
		cout << 0 << endl;
	}
	return 0;
}


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

int main(){
    int a,b,c,x;
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>x;
    int sum;
    int count=0;
    for(int i=0;i<a+1;i++){
        for(int j=0;j<b+1;j++){
            for(int k=0;k<c+1;k++){
                sum = i*500+j*100+k*50;
                if(sum==x){
                    count++;
                }
            }
        }
    }
    cout<<count<<endl;
}

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

int main(){
	int W,H,x,y,r;
	cin >> W;
	cin >> H;
	cin >> x;
	cin >> y;
	cin >> r;
	
	if(x-r < 0 || y-r < 0){	cout << "No" << endl;	}
	else if(x+r > W || y+r > H){	cout << "No" << endl;	}
	else{	cout << "Yes" << endl;	}
}

Measured memory_bytes: 3096
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;
vector<ll> a(1,1);
vector<ll> p(1,1);

ll f(ll n, ll x){
    if(n==0){
        if(x==0){
            return 0;
        }else{
            return 1;
        }
    }
    if(x==1){
        return 0;
    }else if(x<=1+a[n-1]){
        return f(n-1,x-1);
    }else if(x==2+a[n-1]){
        return p[n-1]+1;
    }else{
        return p[n-1]+1+f(n-1,x-a[n-1]-2);
    }
}


int main(){
    ll n,x;
    cin>>n>>x;
    for(ll i=0;i<=n;i++){
        a.push_back(a[i]*2+3);
        p.push_back(p[i]*2+1);
    }
    cout<<f(n,x)<<endl;

}

Measured memory_bytes: 3536
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

using namespace std;
typedef int64_t int64;

// Manages Union-Find Forest.
class UnionFindForest {
  std::vector<int> parent_;
  std::vector<int> rank_;
  std::vector<int> size_;

public:
  // Initialize forest.
  // parent_[i]=i, rank_[i]=0, size_[i]=1.
  UnionFindForest(const int &n);
  // Get the number of the root of the node q.
  int Root(const int &q);
  // Return true if the roots of x and y is same.
  bool IsSame(const int &x, const int &y);
  // Unite the tree x and tree y.
  void Unite(int x, int y);
  // Get the number of nodes which are the same group as node q.
  int Size(const int &q);
};
UnionFindForest::UnionFindForest(const int &n) {
  parent_.resize(n);
  rank_.resize(n);
  size_.resize(n);
  for (int i = 0; i < n; i++) {
    parent_[i] = i;
    rank_[i]   = 0;
    size_[i]   = 1;
  }
}
int UnionFindForest::Size(const int &q) {
  return size_[Root(q)];
}

int UnionFindForest::Root(const int &q) {
  if (parent_[q] == q) {
    return q;
  } else {
    return parent_[q] = Root(parent_[q]);
  }
}

bool UnionFindForest::IsSame(const int &x, const int &y) {
  return Root(x) == Root(y);
}

void UnionFindForest::Unite(int x, int y) {
  x = Root(x);
  y = Root(y);
  if (x == y) return;
  if (rank_[x] < rank_[y]) {
    parent_[x] = y;
    size_[y] += size_[x];
    size_[x] = 0;

  } else {
    parent_[y] = x;
    size_[x] += size_[y];
    size_[y] = 0;
    if (rank_[x] == rank_[y]) rank_[x]++;
  }
}

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

  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> edge(m);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    edge[i]=make_pair(a-1,b-1);
  }

  int count=0;
  for(int i=0;i<m;i++){
    UnionFindForest uf(n);
    for(int ei=0;ei<m;ei++){
      if(ei==i) continue;
      uf.Unite(edge[ei].first,edge[ei].second);
    }
    bool isok=true;
    for(int ni=0;ni<n;ni++){
      if(uf.Root(0)!=uf.Root(ni)){
        isok=false;
        break;
      }
    }
    if(isok) count++;
  }
  cout<<m-count<<endl;

  return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    h,w=parseMap(split(readline()))
    n=parseInt(readline())
    a=parseMap(split(readline()))
    tmp=1
    ans=[[0 for i in 1:w] for j in 1:h]
    for i in 1:h
        if i%2==1
            ran=1:w
        else
            ran=w:-1:1
        end
        for j in ran
            ans[i][j]=tmp
            a[tmp]-=1
            if a[tmp]<=0
                tmp+=1
            end
        end
    end
    for i in 1:h
        println(join(ans[i]," "))
    end
end
main()

Measured memory_bytes: 121084
#include<iostream>
#include<string>
using namespace std;
int dp[20][20];
int main(){
    int a,b;
    int n;
    int x[40],y[40];
    while(true){
    cin>>a>>b;
    if(a==0&&b==0)
        break;
    cin>>n;
    for(int i=0;i<20;i++)
        for(int j=0;j<20;j++)
            dp[i][j]=0;
    for(int i=1;i<n+1;i++){
        cin>>x[i]>>y[i];
        dp[y[i]][x[i]]=-1;
    }
    dp[1][1]=1;
    for(int i=1;i<b+1;i++){
        for(int j=1;j<a+1;j++){
            if(dp[i][j]!=-1){
            if(dp[i-1][j]>0)
                dp[i][j]+=dp[i-1][j];
            if(dp[i][j-1]>0)
                dp[i][j]+=dp[i][j-1];
            }
            else
                dp[i][j]=0;
        }
    }
    cout<<dp[b][a]<<endl;
    }
    return 0;
}
 

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int t;
    cin >> t;
    map<string, int> mp;
    string s;
    REP(_, 0, t)
    {
        cin >> s;
        mp[s]++;
    }

    vector<string> ss({"AC", "WA", "TLE", "RE"});
    for (auto &w : ss)
    {
        cout << w << " x " << mp[w] << "\n";
    }
}


Measured memory_bytes: 3660
#include <stdio.h>

int main(void){

  int n;
  scanf("%d", &n);
  char s[n+1];
  scanf("%s", s);

  int slimes = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i-1]) {
      slimes++;
    }
  }

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

  return 0;
}

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

int main(){
    int a = 0, b = 0, c;
    for(int i = 0; i < 4; i++){
        cin >> c;
        a += c;
    }
    for(int i = 0; i < 4; i++){
        cin >> c;
        b += c;
    }
    cout << max(a, b) << endl;
    return 0;
}

Measured memory_bytes: 1160
while 1:
	n=input()
	if n==0:break
	hmax=7500
	block=[map(int,raw_input().split()) for i in range(n)]
	field=[[0]*5 for i in range(hmax)]
	h=0
	for d,p,q in block:
		if d==1:
			for li in range(h,-2,-1):
				if field[li][q-1:q+p-1]!=[0]*p or li==-1:
					field[li+1][q-1:q+p-1]=[1]*p
					h=max(h,li+2)
					break
		else:
			for li in range(h,-2,-1):
				if field[li][q-1]!=0 or li==-1:
					for i in range(p):
						field[li+i+1][q-1]=1
					h=max(h,li+1+p)
					break
		i=0
		while 1:
			if field[i]==[1]*5:
				del field[i]
				h-=1
			elif field[i]==[0]*5:
				break
			else:
				i+=1
	print sum([sum(field[li]) for li in range(h)])

Measured memory_bytes: 6364
#include<stdio.h>

int main(void)
{
    char str[111111],ans='a';
    int i;
    scanf("%s",str);
    for(i=0;str[i]!='\0';i++){
      //1
        if (ans==str[i]){
            ans++;
            i=0;
        }
      //2
        if(ans=='z'+1){
            printf("None");
            break;
        }
        
    }
    if(ans!='z'+1)
    printf("%c",ans);
    
    
    
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

ll xooor(ll n){


   switch(n & 3)  
    { 
    case 0: return n; 
    case 1: return 1;      
    case 2: return n + 1;
    case 3: return 0;     
    } 
}

int main(){
	IOS

	ll a,b;
	cin>>a>>b;
	ll xoor=xooor(b);
	ll xoor2=xooor(a-1);
	ll xoor3=xoor^xoor2;
	cout<<xoor3<<endl;
	
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

c = []
for i in range(n):
    c.append(b[i]-a[i])

d = 0

for i in range(n):
    if c[i]<0:
        d+=-c[i]
        c[i]=0

for i in range(n):
    d-=c[i]//2

if d<=0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 41584
#include<bits/stdc++.h>
/*
alias A='g++ -std=c++17 -O2 A.cpp'
alias b='g++ -std=c++17 -O2 B.cpp'
alias c='g++ -std=c++17 -O2 C.cpp'
alias d='g++ -std=c++17 -O2 D.cpp'
alias e='g++ -std=c++17 -O2 E.cpp'
alias a='./a.out'
cd programming
cd cpp
cd practice

*/
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define Sort(v) sort((v).begin(), (v).end())
using veci = vector<int>;
using vecs = vector<string>;
using vecd = vector<double>;
using vecl = vector<long long>;
using G = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
ll lINF = LLONG_MAX; ll lmINF = LLONG_MIN;
int INF = INT_MAX; int mINF = INT_MIN;
double PI = acos(-1);
int main(){
    int n; cin >> n;
    string com;
    int ac=0, wa=0, tle=0, re=0;
    rep(i, n){
        cin >> com;
        if (com == "AC"){
            ac++;
        }
        if (com == "WA"){
            wa++;
        }
        if (com == "TLE"){
            tle++;
        }
        if (com == "RE"){
            re++;
        }
    }
    cout << "AC " << 'x' << " " << ac << endl; 
    cout << "WA " << 'x' << " " << wa << endl; 
    cout << "TLE " << 'x' << " " << tle << endl; 
    cout << "RE " << 'x' << " " << re << endl; 
}

Measured memory_bytes: 3632
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>

using namespace std;

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

const double eps = 1e-6;
const ll MOD = 1000000007;
const ll INF = 1e15;

typedef int Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

ll N, M;
vector<int> visited;
Graph g;

P dfs(ll now, int color) {
	P ret = P(0, 0);
	visited[now] = color;
	if (color == 0)
		ret.first++;
	else
		ret.second++;
	for (int i = 0;i < g[now].size();i++) {
		if (visited[g[now][i].dst] == -1) {
			P temp = dfs(g[now][i].dst, 1 - color);
			ret.first += temp.first;
			ret.second += temp.second;
		}
		else if (visited[g[now][i].dst] == color)
			ret.first = -INF;
	}
	return ret;
}

int main() {
	cin >> N >> M;
	g = Graph(N);
	vector<vector<ll>> dist(N, vector<ll>(N, 0));
	for (int i = 0;i < M;i++) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		dist[a][b] = 1;
		dist[b][a] = 1;
	}
	for (int i = 0;i < N;i++)
		for (int j = 0;j < N;j++)
			if (i!=j && dist[i][j] == 0)
				g[i].push_back(Edge(i, j, 1));
	vector<P> v;
	visited.assign(N, -1);
	bool ok = true;
	for (int i = 0;i < N;i++) {
		if (visited[i] == -1) {
			v.push_back(dfs(i, 0));
			ok &= v.back().first >= 0;
		}
	}
	if (!ok) {
		cout << -1 << endl;
		return 0;
	}
	vector<vector<int>> dp(v.size()+1, vector<int>(N+1));
	dp[0][0] = 1;
	for (int i = 0;i < v.size();i++) {
		P x = v[i];
		for (int from = N;from >= 0;from--) {
			if (from + x.first <= N)
				dp[i+1][from + x.first] = max(dp[i+1][from + x.first], dp[i][from]);
			if (from + x.second <= N)
				dp[i+1][from + x.second] = max(dp[i+1][from + x.second], dp[i][from]);
		}
	}
	ll ans = INF;
	for (ll i = 0;i <= N;i++) {
		if (dp.back()[i] == 1)
			ans = min(ans, i * (i - 1) / 2 + (N - i) * (N - i - 1) / 2);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12544
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int dp[2][1000005];
int main(){
    int w,h,n;
    while(cin>>w>>h,w||h){
        cin>>n;
        fill(dp[0],dp[0]+2000010,0);
        vector<vector<int> >V(h+1);
        while(n--){
            int x,y;
            cin>>x>>y;
            V[y].push_back(x);
        }
        dp[1][1]=1;
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                for(int k=0;k<V[i].size();k++)
                    if(V[i][k]==j){
                        dp[i&1][j]=0;
                        break;
                    }
                //dp[i&1][j]%=100000;
                dp[i&1][j+1]+=dp[i&1][j];
                dp[(i+1)&1][j]+=dp[i&1][j];
                dp[(i&1)][j]=0;

            }

        }
        cout<<dp[(h+1)&1][w]<<endl;
    }
}

Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
long long h,a,ok;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
scanf("%lld %lld",&h,&a);
while(h>0){
	 ok++;
	 h=h-a;
}
printf("%lld",ok);
return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e15;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 1e5 + 100;
const int LOG = 20;
const int mod = 1e9 + 7;
const int MX = 1e6 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

dbl p[MAXN];
dbl dp[3000][3000];
void solve() {
    int n;
    cin >> n;
    for(int i=1;i<=n;++i){
        cin >> p[i];
    }
    dp[0][0] = 1;
    for(int i=1;i<=n;++i){
        for(int j=0;j<=i;++j){
            dp[i][j] += dp[i-1][j] * (1 - p[i]);
            if(j > 0)
                dp[i][j] += dp[i-1][j-1] * (p[i]);

            dout << i <<" - "<<j <<" : "<<dp[i][j]<<endl;
        }
    }

    dbl ans = 0;
    for(int j=0;j<=n;++j){
        if(j > n-j){
            ans+=dp[n][j];
        }
    }
    cout << ans<<"\n";
}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;

    while (t--)
        solve();
    dout << endl << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 139776
#include<bits/stdc++.h>
#include<cmath>
#define  debug(x)   cout << '>' << #x << ':' << x << endl;

#define  fo(i,n)    for(ll i=0;i<n;i++)
#define  all(x)     (x).begin(), (x).end()
#define  unq(vec)   sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin());
typedef long long ll;


using namespace std;
const int     MO = int(1e9) + 7;



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


   int k,a,b;
   cin>>k;
   cin>>a>>b;
   int y=b/k;
   int s=y*k;
   if(s>=a && s<=b){
    cout<<"OK";
   }else{
   cout<<"NG";
   }


}



Measured memory_bytes: 3688
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using pqg=priority_queue<T,vector<T>,greater<T>>;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

int main()
{
    ll n=in();
    vector<ll>v(n),c(n);
    REP(i,n)v[i]=in();REP(i,n)c[i]=in();
    ll ans=0;REP(i,n)ans+=max(0LL,v[i]-c[i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
Submitted With (^^) by -> Hossam ^_^
_____________________
|     ___     ___     |
|    (^_^)   (^_^)    |
|   /( | )\_/( | )\   |
|_____|_|_____|_|_____|
*/

#include <bits/stdc++.h>

using namespace std;

inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
};

#define X first
#define Y second
#define endl '\n'
#define ll long long
#define inf (0x7fffffffffffffff)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << (x) << "\n";
#define ZXC cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl;

const int mod = (int)1e9 + 7;
// const int mod = 998244353;
const int MX = (int)1e5 + 10;

int main()
{
    prep();
    srand(time(0));

    int n, k;

    cin >> n >> k;

    int cnt[k] = {};
    for(int i = 1; i <= n; ++i){
        cnt[i % k]++;
    }
    
    ll res = 0;
    for(int i = 0; i < k; ++i){
        if((k - i + k - i) % k == 0)
            res += cnt[i] * 1ll * cnt[(k - i) % k] * 1ll * cnt[(k - i) % k];
    }

    cout << res << endl;

    // ZXC
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
typedef complex<double> P;
namespace std{
  bool operator < (const P &a,const P &b){
    return ( a.real()==b.real() ? a.imag() < b.imag() : a.real() < b.real() );
  }
};
 
P getCrossPointCC(P p1,double r1,P p2,double r2){
  double a=r2,b=r1,c=abs(p1-p2);
  double cA = min( 1.0 ,(b*b+c*c-a*a) / (2.0*b*c) );
  return p1+(p2-p1)/c*r1*P(cA,sqrt(1.0-cA*cA));
}
 
int n;
P p1,p2;
double px,py,r1,r2;
 
int main(){
   
  cin>>px>>py>>r1;
  p1=P(px,py);
  cin>>px>>py>>r2;
  p2=P(px,py);
   
  P A=getCrossPointCC(p1,r1,p2,r2);
  P B=getCrossPointCC(p2,r2,p1,r1);
  P a=min(A,B),b=max(A,B);
  printf("%.9f %.9f %.9f %.9f\n",a.real(),a.imag(),b.real(),b.imag());
  return 0;
}

Measured memory_bytes: 1260
// Problem: C - Sum of product of pairs
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define ll long long
const int N = 2e5+5;
const int mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;
 
void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(9);
}
 
//3. Structure or classes
//3. Ends here
 
//1. Data structures declaration here
//1. Ends here
 
//2. Extra Functions here
//2. Ends here
 
 
void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}
 
 
 
void solve()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	int sum[n]={0};
	sum[0]=a[0];
	
	for(int i=1;i<n;i++){
		sum[i]=sum[i-1]+a[i];
		sum[i]%=mod;
	}
	
	int ans=0;
	for(int i=0;i<n-1;i++){
		ans = ans + (a[i] * (sum[n-1]-sum[i]))%mod;
		ans = (ans+mod)%mod;
	}
	
	cout<<ans<<"\n";
    return;
}
// how r u bro

Measured memory_bytes: 6752
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, vector<ll> A) {
  vector<ll> x;
  x.push_back(0);
  for (ll i: A) x.push_back(i);
  x.push_back(0);
  ll sum = 0;
  REP(i,N+1) sum += abs(x[i] - x[i + 1]);
  // cout << sum << endl;
  REP(i,N) {
    cout << sum - abs(x[i] - x[i + 1]) - abs(x[i + 2] - x[i + 1]) + abs(x[i] - x[i + 2]) << endl;
  }
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> A(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &A[i]);
	}
	solve(N, A);
	return 0;
}


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

int main() {
  int N, ans;
  cin >> N;
  if (N == 1e5) {
      ans = 90909;
  }
  else if (N < 100) {
    ans = min(N,9);
  } else if (N < 1e4) {
    ans = min(900, N - 99) + 9;
  } else {
    ans = min(90000, N - 9999) + 909;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

const long mod = 1000000007;

long solve(int n, std::vector<int> brokens)
{
  std::vector<long> c(n + 1);
  c[0] = 1;
  c[1] = 1;
  c[2] = 2;
  for (int i = 3; i <= n; ++i) {
    c[i] = (c[i - 1] + c[i - 2]) % mod;
  }

  long result = 1;
  int prev = -1;
  for (auto& a : brokens) {
    int d = a - prev - 2;
    if (d <= -1) return 0;
    prev = a;
    result *= c[d];
    result %= mod;
  }

  auto dd = brokens.empty() ? n : n - brokens.back() - 1;
  if (dd >= 2) {
    result *= c[dd];
    result %= mod;
  }

  return result;
}

int main()
{
  int n, m;
  std::cin >> n >> m;

  std::vector<int> brokens(m);
  for (auto& a : brokens) {
    std::cin >> a;
  }

  std::cout << solve(n, std::move(brokens)) << std::endl;
}


Measured memory_bytes: 1408
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())
div  = make_divisors(n)

l = []
for i in div:
    var = i - 1
    if var != 0 :
        if n//var == n%var:
            l.append(var)

print(sum(l))


Measured memory_bytes: 3296
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int R;
  cin >> R;
  double ans = 2 * PI * R;
  cout << ans << endl;

  return 0;
}


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

const long long INF=1LL<<60;

int main(){
    int N, M, X; cin >> N >> M >> X;
    vector<int> und(M, 0);
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    for(int i=0; i<N; i++){
        cin >> C[i];
        for(int j=0; j<M; j++){
            cin >> A[i][j];
        }
    }
    long long res=INF;
    for(int bits=1; bits<(1<<N); bits++){
        bool can=true;
        long long total=0;
        for(int i=0; i<M; i++){
            und[i]=0;
        }
        for(int i=0; i<N; i++){
            if(bits & (1<<i)){
                for(int j=0; j<M; j++){
                    und[j]+=A[i][j];
                }
                total+=C[i];
            }
        }
        for(int i=0; i<M; i++){
            if(und[i] < X){
                can=false;
                break;
            }
        }
        if(can) res=min(res, total);
    }
    if(res == INF) cout << -1 << endl;
    else cout << res << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi L(n); rep(i, n) cin >> L[i];
  sort(all(L));

  ll ans = 0;

  for (int a = 0; a < n; a++) for (int b = a+1; b < n; b++) {
    // k:最初に L[a]+L[b] を超えてしまう index
    int k = lower_bound(all(L),L[a]+L[b]) - L.begin();
    // b+1 から ok で k から ng だから c の許される範囲は [b+1,k)
    ans += k - (b+1);
  }
  std::cout << ans << '\n';
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int Na;
    scanf("%d",&Na);
    printf("%f\n", (Na%2) ? (double)(Na/2+1)/Na: 0.5);
    return (0);
}

Measured memory_bytes: 256
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e14 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n, m, k; cin >> n >> m >> k;

    vector<long long> a(n), b(m);

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

    for(long long i = 0; i < m; i++) {
        cin >> b[i];
    }

    long long ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
    while(k--) {
        long long i, j, dc; cin >> i >> j >> dc;
        i--, j--;
        ans = min(ans, a[i] + b[j] - dc);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 4764
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>

using namespace std;
typedef long long ll;

#define rep(i, n) for (i = 0; i < n; i++)

ll a, b, c, d;
map<ll, ll> memo;

ll solve(ll n)
{
  if (n == 0)
    return 0;
  if (n == 1)
    return d;
  if (memo.count(n))
    return memo[n];

  ll l2 = (n / 2) * 2;
  ll r2 = ((n + 1) / 2) * 2;
  ll l3 = (n / 3) * 3;
  ll r3 = ((n + 2) / 3) * 3;
  ll l5 = (n / 5) * 5;
  ll r5 = ((n + 4) / 5) * 5;

  ll res = 1e18;
  if (n < res / d)
    res = n * d;
  res = min(res, llabs(l2 - n) * d + a + solve(l2 / 2));
  res = min(res, llabs(r2 - n) * d + a + solve(r2 / 2));

  res = min(res, llabs(l3 - n) * d + b + solve(l3 / 3));
  res = min(res, llabs(r3 - n) * d + b + solve(r3 / 3));

  res = min(res, llabs(l5 - n) * d + c + solve(l5 / 5));
  res = min(res, llabs(r5 - n) * d + c + solve(r5 / 5));

  memo[n] = res;
  return res;
}

int main()
{
  int T;
  cin >> T;
  for (int t = 0; t < T; t++)
  {
    memo.clear();
    ll n;
    cin >> n;
    cin >> a >> b >> c >> d;
    cout << solve(n) << endl;
  }
}

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





int main() {
	ll N, T,an=0;
	cin >> N >> T;
	vector<ll> t(N);
	vector<ll> sa(N - 1);
	rep(i, N) {
		cin >> t.at(i);
		if (i > 0) {
			an += min(T, t.at(i) - t.at(i - 1));
		}
	}
	cout << an+T << endl;

}


Measured memory_bytes: 3328
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    
    long a = scan.nextLong();
    long b = scan.nextLong();
    long c = scan.nextLong();
    long d = scan.nextLong();
    
    long[] ans = new long[4];
    
    ans[0] = a * c;
    ans[1] = a * d;
    ans[2] = b * c;
    ans[3] = b * d;
    long max = ans[0];
    
    for (int i = 1;i < 4;i ++) {
      if (max < ans[i])
        max = ans[i];
    }
    System.out.println(max);
  }
}
        


Measured memory_bytes: 35668
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[] a = sc.IntArray();

        long ans = 0;
        for (int i = 1; i < n; i++)
        {
            int t = Math.Max(a[i], a[i - 1]);
            ans +=  t - a[i];
            a[i] = t;
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 46744
import java.util.*;
public class Main {
	public static void main(String[] args) {
		int t,n;
		int gokei = 0;
		Scanner scan = new Scanner(System.in);
		
		for(int i = 0; i <= 3; i++){
		
			t = scan.nextInt();
			n = scan.nextInt();
			
			if(t == 1) {
				gokei = 6000 * n;
				System.out.println(gokei);
			} else if(t == 2) {
				gokei = 4000 * n;
				System.out.println(gokei);
			} else if(t == 3) {
				gokei = 3000 * n;
				System.out.println(gokei);
			} else if(t == 4) {
				gokei = 2000 * n;
				System.out.println(gokei);
			}
		}
	}
}

Measured memory_bytes: 17364
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct edge{
  int to, cost;
};
int qwe = 0;
vector<edge> G[100000];
ll d[2][100000];
ll lis[2][100000] = {0};

ll longinf = 123451234512345LL;

void dijkstra(int v, int e, int r){   //(vertex, edge, start)
  ll res = 0;
  int i, j;
  rep(i, v)d[qwe][i] = longinf;
  d[qwe][r] = 0LL;
  priority_queue<ll_i, vector<ll_i>, greater<ll_i> > Q;
  Q.push(mp(0LL, r));
  for(;!Q.empty();){
    ll_i now = Q.top();
    Q.pop();
    if(d[qwe][now.Y] < now.X)continue;
    rep(i, G[now.Y].size()){
      edge tmp = G[now.Y][i];
      if(d[qwe][tmp.to] > d[qwe][now.Y] + tmp.cost){
        d[qwe][tmp.to] = d[qwe][now.Y] + tmp.cost;
        Q.push(mp(d[qwe][tmp.to], tmp.to));
      }
    }
  }
  return;
}

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase < 1234567;testcase++){
    int4(n, m, s, t);
    --s; --t;
    rep(i, m){
      int2(x, y);
      --x; --y;
      G[x].pb((edge){y, 1});
      G[y].pb((edge){x, 1});
    }

    dijkstra(n, m * 2, s); qwe++;
    dijkstra(n, m * 2, t);
    int dist = d[0][t];

    rep(i, 2)rep(j, n)if(d[i][j] < longinf)lis[i][d[i][j]]++;

    ll res = 0;
    rep(i, dist - 1)res += lis[0][i] * lis[1][dist - 2 - i];
    pri(res);


/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 11592
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var value = 0;
        for (int i = 0; i < n; i++)
        {
            value += i + 1;
        }

        Console.WriteLine(value);
    }
}

Measured memory_bytes: 11092
gets
a = gets.strip.split(" ").map(&:to_i)

if a.size == 1
  puts a.first
else
  l = Array.new(a.size)
  r = Array.new(a.size)

  l[0] = a.first
  1.upto(a.size - 1) do |i|
    l[i] = a[i].gcd(l[i - 1])
  end

  r[a.size - 1] = a.last
  (a.size - 2).downto(0) do |i|
    r[i] = a[i].gcd(r[i + 1])
  end

  ans = 0
  0.upto(a.size - 1) do |i|
    x = i > 0 ? l[i - 1] : nil
    y = i < a.size ? r[i + 1] : nil

    ans = 
      if x && y
        [ans, x.gcd(y)].max
      else
        [ans, (x || y)].max
      end
  end

  puts ans
end


Measured memory_bytes: 13836
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<algorithm>
#include<string.h>

using namespace std;

int main(int argc, char* argv[]){
  int n;
  int a[100001];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  long long int ans = n;
  sort(a,a+n);
  int temp = -1;
  int num=0;
  for(int i=0;i<n;i++){
    if(temp==a[i])num++;
    temp=a[i];
  }
  if(num%2==0)ans-=num;
  else ans-=num+1;
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<map<int, int>> start_length(N, map<int, int>());
    for (int i = 0; i < M; ++i) {
        int l, r;
        cin >> l >> r;
        --l;
        --r;
        if (start_length[l].count(r - l) == 0) {
            start_length[l].insert(make_pair(r - l, 0));
        }
        start_length[l][r - l] += 1;
    }
    vector<vector<int>> start_lengthLess(N, vector<int>());
    for (int i = 0; i < N; ++i) {
        const map<int, int>& length_num = start_length[i];
        vector<int> length(N + 1, 0);
        for (auto e : length_num) {
            length[e.first] = e.second;
        }
        vector<int> accumLength(N + 1, 0);
        accumLength[0] = length[0];
        for (int j = 1; j < accumLength.size(); ++j) {
            accumLength[j] = accumLength[j - 1] + length[j];
        }
        start_lengthLess[i] = accumLength;
    }

    for (int i = 0; i < Q; ++i) {
        int p, q;
        cin >> p >> q;
        --p;
        --q;
        int ans = 0;
        for (int j = p; j <= q; ++j) {
            ans += start_lengthLess[j][q - j];
        }
        cout << ans << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 9336
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define f(i,l,h) for(ll i=l;i<h;i++)
#define fr(i,h,l) for(ll i=h;i>=l;i--)

using namespace std;

typedef pair<ll,ll> pll;
const ll INF=(ll)(1e9+7);
typedef vector<ll> vll;

int main()
{
    //cout << "Hello world!" << endl;
    long double a,b;
    cin>>a>>b;
    cout<<(ll)(a*b)<<endl;

}


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

#define ll long long
#define mx 200005

int ar[mx];
char ch[mx];

int n,k;

void solve()
{
   scanf("%d%d",&k,&n);
   for(int i=0;i<n;i++)scanf("%d",&ar[i]);
   sort(ar,ar+n);
   int re=1e8;
   for(int i=0;i<n;i++)
   {
       int tem=ar[i];
       if(i+1!=n)tem+=k-ar[i+1];
       re=min(tem,re);
       tem=ar[n-1]-ar[i];
       if(i)tem+=ar[i]-ar[0];
       re=min(tem,re);
   }
   cout<<re<<endl;
}

int main()
{
    int t=1;
    while(t--)solve();

    return 0;
}


Measured memory_bytes: 1024
c = [[int(i) for i in input().split()] for i in range(3)]
a = []
b = [c[0][i] for i in range(3)]
a = [c[i][0]-b[0] for i in range(3)]
for i in range(3):
    for j in range(3):
        if a[i]+b[j] != c[i][j]:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 3060
s = str(input())
ans = 0
if s == "SUN":
  ans = 7
elif s == "MON":
  ans = 6
elif s == "TUE":
  ans = 5
elif s == "WED":
  ans = 4
elif s == "THU":
  ans = 3
elif s == "FRI":
  ans = 2
elif s == "SAT":
  ans = 1
print(ans)

Measured memory_bytes: 2940
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7; 

fn main(){
    let m: usize = read(); 
    let d: usize = read();
    let mut ans = 0;
    for i in 2..m + 1{
        for j in 11..d + 1{
            let d1 = j % 10;
            let d10 = (j / 10) as usize;
            if d1 <= 1 || d10 <= 1{
                continue;
            }
            if i == d1 * d10{
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            v.push_back(i*j);
        }
    }
    int n;
    cin>>n;
    for(int i=0;i<v.size();i++)
    {
        if(v[i]== n)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
// iostream のscanf, printf では間に合わなかった
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

#define INF (1<<29)
#define mp make_pair
#define pb push_back

typedef pair<int,int> pii;

int main(){
	int n, m;
	cin >> n >> m;
	vector<pii> treasure;
	for( int i = 0; i < n; i++ ){
		int x, y;
		cin >> x >> y;
		//scanf("%d %d", &x, &y);
		treasure.pb( mp(x,y) );
	}
	sort(treasure.begin(), treasure.end());
	for( int i = 0; i < m; i++ ){
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		//scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		// search
		int ans = 0;
		vector<pii>::iterator it = lower_bound(treasure.begin(),treasure.end(),mp(x1,y1));
		vector<pii>::iterator ite = upper_bound(treasure.begin(),treasure.end(),mp(x2,y2));
		while( 1 ){
			//if( it == treasure.end() || *it > mp(x2,y2) ) break;
			if( it == ite ) break;
			if( x1 <= (*it).first && (*it).first <= x2 && y1 <= (*it).second && (*it).second <= y2 ) ans++;
			it++;
		}
		cout << ans << endl;
		//printf("%d\n", ans);
	}
}

Measured memory_bytes: 1304
#include<stdio.h>
int main()
{
    int a,b,d,r;
    double f;
    scanf("%d%d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %lf\n",d,r,f);
    return 0;
}



Measured memory_bytes: 2092
#include<bits/stdc++.h>
using namespace std;
const int MAXN=200010;
int n,m,d[MAXN],t[MAXN];

inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0',c=getchar();}
	return x*f;
}
map<int,int> mp;
int main()
{
	n=read();
	for(register int i=1;i<=n;i++) d[i]=read(),mp[d[i]]++;
	m=read();
	for(register int i=1;i<=m;i++) t[i]=read();
	if(m>n){return puts("NO"),0;}
	for(register int i=1;i<=m;i++)
	{
		if(!mp[t[i]])return puts("NO"),0;
		mp[t[i]]--;
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
using namespace std;

int main()
{
	int n, a, b,sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		sum += (b - a + 1);
	}
	cout << sum << endl;
	return 0;
}

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

int main(){
  int a,b,c,swap;
  cin >> a >> b >> c;
  if (a>c) {swap = a; a = c; c = swap;}
  if (b>c) {swap = b; b = c; c = swap;}
  if ((a+b)%2 == 0) {
    cout << c-(a+b)/2 << endl;
  } else {
    cout << c-(a+b-3)/2 << endl;
  }
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++) cin >> s.at(i);
    ll res = 0;
    unordered_map<string, int> mp;
    for (int i = 0; i < N; i++){
        sort(s.at(i).begin(), s.at(i).end());
        if (mp[s.at(i)] != 0) res += max(mp[s.at(i)], 1);
        
        mp[s.at(i)]++;
    }
    cout << res << endl;
}

Measured memory_bytes: 17700
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int A = scanner.nextInt();
        if (A < 1200) {
            System.out.println("ABC");
        } else if (A < 2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 21204