akhauriyash/Code-Regression huggingface dataset:
/**
 * @author Video Vocabulary
 * @date 2020-07-05 18:00:53
 */
#include <bits/stdc++.h>

using namespace std;

void solve() {
    
}

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

    int n;
    cin >> n;
    string s;
    int AC = 0, WA = 0, TLE = 0, RE = 0;
    while (n--) {
        cin >> s;
        if (s == "AC") AC++;
        if (s == "WA") WA++;
        if (s == "TLE") TLE++;
        if (s == "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: 3656
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z << '\n';
}


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

int main()
{
	int n;
	cin >> n;
	string a, b, c;
	cin >> a >> b >> c;
	int xx = 0;
	for (int i = 0; i < a.size(); i++)
	{
		int x = 0;
		if (a.at(i)!=b.at(i))
		{
			x++;
		}
		if (a.at(i)!=c.at(i))
		{
			x++;
		}
		if (b.at(i)!=c.at(i))
		{
			x++;
		}
		if (x==2)
		{
			x=1;
		}
		if (x==3)
		{
			x = 2;
		}
		xx += x;
	}

	cout << xx << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>

using namespace std;

void output(int, int, int, int);

#define MAX 100
#define INF (1 << 21)

int SIZE;
int R[MAX + 2];
int C[MAX + 1][MAX + 1];
int B[MAX + 1][MAX + 1];

void compute() {
	for (int i = 1; i <= SIZE; i++)
		for (int j = 1; j <= SIZE; j++) C[i][j] = INF;

	for (int i = 1; i <= SIZE; i++) C[i][i] = 0;

	for (int j = 1; j <= SIZE - 1; j++) {
		for (int i = 1; i <= SIZE - j; i++) {
			for (int k = i + 1; k <= i + j; k++) {
				int cost = C[i][k - 1] + C[k][i + j] + R[i] * R[k] * R[i + j + 1];
				if (cost < C[i][i + j]) {
					C[i][i + j] = cost;
					B[i][i + j] = k;
				}

			}
		}
	}
}


void input() {
	int r, c;
	cin >> SIZE;
	for (int i = 1; i <= SIZE; i++) {
		cin >> r;
		cin >> c;
		R[i] =r;
	}
	R[SIZE + 1] = c;

}

void output() {
	cout << C[1][SIZE] << endl;
}

int main() {
	input();
	compute();
	output();
}





Measured memory_bytes: 3188
/**
* Motto:   fight till end
* Author: fyter_112
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define mod 1000000007
int32_t main()
{
  fast;
  int t;
//  cin>>t;
//  while(t--)
  {
    map<int,char>m;
    map<char,int>mc;
    int c=1,col=0;;
    for(char i = 'a' ; i <= 'z' ; i++)
    {
      m[c]=i;
      mc[i]=c;
      c++;
    }
    string s;
    cin>>s;
    c=0;
    while(s[c]<='9' && s[c]>='0')
    {
      col*=10;
      col+=(int)s[c]-48;
      c++;
    }
    string str="";
    while(col>0)
    {
      c=col%26;
      if(c==0)
      {
        c=26;
      }
      str+=m[c];
      col=col/26;
      if(c==26)
      {
        col=col-1;
      }
    }
    reverse(all(str));
    cout << str <<'\n';
  }
}


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

int main(void)
{
    int N, temp;
    string S;
    cin >> N >> S;

    for (int i = 0; i < S.size(); i++) {
        S[i] += N;
        while (S[i] > 'Z') {
            temp = S[i] - 'Z';
            S[i] = 'A' + temp-1;
        }
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#! /usr/bin/env python
#-*- coding: utf-8 -*-

''' ?????\????????? '''

#
# ?¨??????????O()


def insertion_sort(A, N):

    for i in range(N):
        tmp = A[i]
        j = i - 1

        while j >= 0 and A[j] > tmp:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = tmp

        print(' '.join(map(str, A)))

    return A


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    # N = 6
    # A = [5, 2, 4, 6, 1, 3]
    array_sorted = insertion_sort(A, N)

Measured memory_bytes: 7672
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;

int main() {
    string S;
    cin >> S;
    set<char> m;
    for (char c : S) {
        m.insert(c);
    }
    for (char c = 'a'; c <= 'z'; ++c) {
        if (m.count(c) == 0) {
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}


Measured memory_bytes: 512
from collections import deque

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

d = deque()
d.append(A[1])
d.append(A[1])
ans = A[0]
for i in range(2, len(A)):
    ans += d.popleft()
    d.append(A[i])
    d.append(A[i])

print(ans)

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

signed main() {
    string s;
    cin >> s;
    if (s.front() != '1' || s.back() != '0') {
        cout << -1 << endl;
        return 0;
    }
    int n = s.size() - 1;
    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[n - i - 1]) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector<int> a;
    for (int i = 0; i < n; i++) {
        if (s[i] == '1') a.push_back(i + 1);
    }
    a.push_back(n + 1);

    vector<pair<int, int>> ans;
    for (int i = 1; i < a.size(); i++) {
        ans.push_back({a[i - 1], a[i]});
        int r = a[i] - a[i - 1] - 1;
        int v = a[i - 1] + 1;
        for (int j = 0; j < r; j++) {
            ans.push_back({v, a[i]});
            v++;
        }
    }

    for (auto&& p : ans)
        cout << p.first << " " << p.second << endl;
    return 0;
}

Measured memory_bytes: 4144
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    string s;
    cin >> s;
    s = '#' + s;

    int dp[s.length()+1][2];
    dp[0][0] = 0;
    dp[0][1] = 1;
    for (int i = 1; i < s.length(); i++) {
        if (s[i] == '9') {
            dp[i][0] = min(dp[i-1][0] + 9, dp[i-1][1] + 1);
            dp[i][1] = dp[i-1][1];
        } else {
            dp[i][0] = min(dp[i-1][0] + s[i] - '0', dp[i-1][1] + 10 + '0' - s[i]);
        }   dp[i][1] = min(dp[i-1][0] + s[i] + 1 - '0', dp[i-1][1] + 10 + '0' - s[i] - 1);
    }

    cout << dp[s.length()-1][0] << endl;

    return 0;
}


Measured memory_bytes: 9160
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int H, W, i, j, ic, jc;
    string S[30][30];
    char jans;

    cin >> H >> W;

    for(i=1; i<=H; i++){
        for(j=1; j<=W; j++){
            cin >> S[i][j];

            if(S[i][j] == "snuke"){
                ic = i;
                jc = j;
            }
        }
    }

    jans = 'A'+jc-1;

    cout << jans << ic << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> r(n,vector<int>(0));
  vector<int> a(n,-1);
  rep(i,n-1){
    int f,g;
    cin >> f >> g;
    r[f-1].push_back(g-1);
    r[g-1].push_back(f-1);
  }
  int u=1,uu=0;
  queue<pp> q;
  q.push(mk(0,1));
  a[0]=1;
  while(!q.empty()){
    int f=q.front().first,g=q.front().second;
    q.pop();
    rep(i,r[f].size()){
      if (a[r[f][i]]==-1){
        if (g==1){
          q.push(mk(r[f][i],2));
          a[r[f][i]]=2;
          uu++;
        }
        else {
          q.push(mk(r[f][i],1));
          a[r[f][i]]=1;
          u++;
        }
      }
    }
  }
  int k=n/3,kk=n/3,x=n/3,xx=0,yy=0;
  if (n%3==1) k++;
  if (n%3==2){
    k++;
    kk++;
  }
  int p,o;
  if (u<k){
    p=u;
    o=x-p;
    xx=uu-kk-o;
  }
  else if (uu<kk){
    o=uu;
    p=x-o;
    yy=u-k-p;
  }
  else{
    p=u-k;
    o=uu-kk;
  }
  rep(i,n){
    if (a[i]==1 && p>0){
      a[i]=3;
      p--;
    }
    if (a[i]==2 && o>0){
      a[i]=3;
      o--;
    }
    if (a[i]==1 && yy>0){
      a[i]=2;
      yy--;
    }
    if (a[i]==2 && xx>0){
      a[i]=1;
      xx--;
    }
  }
  int t=1,tt=2,ttt=3;
  rep(i,n){
    if (a[i]==1){
      a[i]=t;
      t+=3;
    }
    if (a[i]==2){
      a[i]=tt;
      tt+=3;
    }
    if (a[i]==3){
      a[i]=ttt;
      ttt+=3;
    }
  }
  rep(i,n){
    cout << a[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 15092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    char a;
    cin >> a;
    if (a <= 'Z') {
        cout << "A" << endl;
    } else cout << "a" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<vector<pair<int, int>>> G;

G graph;
queue<pair<int,int>> node;
vint Ans;
vector<bool> flag;


void DFS2()
{
	//node.firstは辺番号、secondは色
	//Ans[x] xは番号、値は色
	node.push({ 0,0 });
	Ans.push_back(1);

	while (node.size())
	{
		int k = 1;
		int nodenum = node.front().first;
	//	print(nodenum)
		int color = node.front().second;
		
		node.pop();
		for (int i = 0; i < graph[nodenum].size(); i++)
		{
			int edgenum = graph[nodenum][i].second;
			if (flag[edgenum])
			{
				continue;
			}
			if (k == color)
			{
				k++;
			}
			node.push({ graph[nodenum][i].first,k });
	//		print((graph[nodenum][i].second))
			Ans[edgenum] = k;
			flag[edgenum] = true;
			k++;
		}
	}
}

int main()
{
	int n;
	cin >> n;
	graph.resize(n);
	Ans.resize(n);
	flag.resize(n);
	rep(i, n-1)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back({ b,i });
		graph[b].push_back({ a,i });
	//	Connect[a].push_back(b);
	//	edge[{a, b}] = i;
	//	edge[{b, a}] = i;
	}
	DFS2();
	auto itr = max_element(Ans.begin(), Ans.end());
	cout << *itr << endl;
	rep(i, n-1)
	{
		cout << Ans[i] << endl;
	}
}


Measured memory_bytes: 7168
<?php
$n=trim(fgets(STDIN));
if($n==1){
  echo trim(fgets(STDIN))==1?0:1;
}else{
  $a=explode(" ",trim(fgets(STDIN)));
  $a=array_count_values($a);
  $ans=0;
  foreach($a as $k=>$v){
    if($k<=$v){
      $ans+=$v-$k;
    }else{
      $ans+=$v;
    }
  }
  echo $ans;
}

Measured memory_bytes: 19188
from collections import deque
dq = deque()
for mak in range(int(input())) :
    com = input().split()
    if   com[0] == 'insert'      : dq.appendleft(com[1])
    elif com[0] == 'deleteFirst' : dq.popleft()
    elif com[0] == 'deleteLast'  : dq.pop()
    else : 
        if com[1] in dq :
            dq.remove(com[1])
print(' '.join(dq))



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

int main(){
  int N;
  int ans=0;
  cin>>N;
  int a[N];
  for(int i=0; i<N; ++i){
    cin>>a[i];
    for(int j=0; j<30; ++j){
      if(a[i]%2==0){
        a[i] /= 2;
        ans += 1;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for(int i=a;i<b;i++)
#define repds(i,a,b) for(int i=a+1;i<=b;i++)
#define rep(i,N) repd(i,0,N)
#define reps(i,N) repds(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){rep(i,N+1){rep(j,M+1){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
typedef pair<int,int> P;
const int INF=100000000;
const int dx[4]={ 0, 1, 0,-1};
const int dy[4]={ 1, 0,-1, 0};
//--------------------------------------//
int n;

int main(){
	cin>>n;
	while(1){
		if(n%4==0) {
			cout<<"Yes"<<endl;
			break;
		}
		n-=7;
		if(n<0) {
			cout<<"No"<<endl;
			break;
		}
	}
	return 0;
}


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

rate = [0 for _ in range(8)]
free = 0
for a in A:
    r = a // 400
    if r >= 8:
        free += 1
    else:
        rate[r] += 1

a1 = 0
for r in rate:
    if r != 0:
        a1 += 1
a2 = free + a1
if a1 == 0:
    a1 = 1
print(a1, a2)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int ask(int l,int r){
	putchar('?');
	for(int i=l;i<=r;++i)
		cout<<" "<<i;
	cout<<endl;
	fflush(stdout);
	string res;cin>>res;
	return res=="Red";
}
int ask(int l,int r,int x){
	putchar('?');
	if(l<=x && x<=r){
		for(int i=l;i<x;++i)
			cout<<" "<<i;
		for(int i=x+1;i<=r;++i)
			cout<<" "<<i;
	}
	else{
		for(int i=l+1;i<r;++i)
			cout<<" "<<i;
		cout<<" "<<x;
	}
	cout<<endl;
	fflush(stdout);
	string res;cin>>res;
	return (res=="Red")^(l<=x && x<=r);
}
int ans[2005];
int main(){
	int n;cin>>n;
	int res=ask(1,n),l=1,r=n,fin=1;
	while(l<=r){
		int mid=(l+r)>>1;
		if(ask(mid,mid+n-1)==res) fin=mid,l=mid+1;
		else r=mid-1;
	}
	ans[fin]=res; ans[fin+n]=res^1;
	for(int i=1;i<=n+n;++i)
		if(i!=fin && i!=fin+n) ans[i]=ask(fin,fin+n,i);
 	cout<<"! ";
	for(int i=1;i<=n+n;++i)
		cout<<(ans[i]?"R":"B");
	return 0;
	return 0;
}


Measured memory_bytes: 3784
//新幹線からAC

#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
using namespace std;
    
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
    
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
    
class fact {
public:
    int fmod = 1e9+7;
    vector<int> fac, inv;
    fact (int n, int Mod = 1e9+7) {
        fmod = Mod;
        fac = vector<int>(n,0);
        inv = vector<int>(n,0);
        fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
        for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
    }
    ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
    ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
    
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return (a / GCD(a,b)) * b;}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}

bool solve() {
	string s; cin >> s;
	rep (i, 19) {
		if (s[i] == ',') cout << " ";
		else cout << s[i];
	}
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();    
}
    


Measured memory_bytes: 256
/*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

int main() {
	int a, b, c;
	int count;
	while (cin >> a >> b)
	{
		// ??\???
		c = a + b;
		count = 0;

		// ?????°??????
		do
		{
			c = c / 10;
			count++;
		} while (c > 0);
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 2924
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
typedef long long ll;
using namespace std;

// 10^18 までありえる．
ll X, Y;

int main()
{
  cin >> X >> Y;

  // A[1] = X
  // A[i+1] = 2 * A[i]
  ll cnt = 1;
  ll a = X;
  while (true) {
    a = a * 2;
    if (a > Y) break;
    else ++cnt;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = [int(i) for i in input().split()]

if N >= M:
    print("0")
    exit()

ans = 0
X.sort()
P = [(X[i+1]-X[i]) for i in range(M-1)]
P.sort()
for i in range(M-N):
    ans += P[i]
print(ans)


Measured memory_bytes: 13840
#include <bits/stdc++.h>
using namespace std;
const int maxn = 11000;
int h,w,n;
int p[maxn];
int s[110][110];

int main ()
{
    scanf("%d %d %d",&h,&w,&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&p[i]);
    }
    int cnt = 1;
    for(int i=1;i<=h;i++)
    {
        if(i %2 ==  1)
        {
            for(int j=1;j <= w;j++)
            {
                if( p[cnt] )
                {
                    s[i][j] = cnt;
                    p[cnt]--;
                }
                if(p[cnt] == 0)
                    cnt++;
            }
        }
        else
        {
            for(int j=w;j>=1;j--)
            {
                if( p[cnt] )
                {
                    s[i][j] = cnt;
                    p[cnt]--;
                }
                if(p[cnt] == 0)
                    cnt++;
            }
        }
    }
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(j != 1)
                printf(" ");
            printf("%d",s[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 384
import math
a,b,h,m = map(int,input().split())
H = 30*h+0.5*m
M = 6*m
if 0<=H<=90:
    H = (90-H)
else:
    H = 450-H
if 0<=M<=90:
    M = (90-M)
else:
    M = 450-M
x_1 = math.cos(math.radians(H))*a
y_1 = math.sin(math.radians(H))*a
x_2 = math.cos(math.radians(M))*b
y_2 = math.sin(math.radians(M))*b
X = abs(x_1-x_2)
Y = abs(y_1-y_2)
dis = math.sqrt(X**2+Y**2)
print(dis)

Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, g, b;
  cin >> r >> g >> b;

  int num = g * 10 + b;

  if (num % 4 == 0){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
// AtCoder-Template.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define FORREV(i,N,_cnt) for(auto i=N-1,cnt=_cnt; cnt > 0; --i, --cnt)
#define ALL(x) x.begin(), x.end()

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T& a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T& a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
	ifstream ifs("in.txt");
	cin.rdbuf(ifs.rdbuf());
#endif
	ll N; cin >> N; vector<ll> A(N); FOR(i, N) cin >> A[i];
	deque<ll> Q;
	//if (N % 2 == 1) reverse(ALL(A));
	FOR(i, N) {
		if (i % 2 == 0) { // back 
			Q.push_back(A[i]);
		} 
		else Q.push_front(A[i]);
	}
	if (N % 2 == 1) {
		FOR(i, N) { if (i != 0) cout << " "; cout << Q.back(); Q.pop_back(); } cout << endl; exit(0);
	}
	FOR(i, N) {
		if (i != 0) cout << " ";
		cout << Q.front(); Q.pop_front();
	} cout << endl;

	return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define REP1(i,n) for(int (i)=(1);(i)<(n);++i)
#define ll long long

int main(){
    int n,k,buf=0;
    double ans=0,memo=1;
    cin >> n >> k;
    int v[n+2];
    
    REP1(i,n+1){
        v[i]=i;
        while (v[i]<k){
            v[i] *=2;
            buf++;
        }
        v[i]=buf;
        buf=0;
    }

    REP1(i,n+1){
        buf = v[i];
        while(buf){
            memo *=0.5;
            buf--;
        }
        ans += memo;
        memo = 1;
    }

    cout << setprecision(19) << ans/n << endl;

    return 0;
}

Measured memory_bytes: 640
/*
  Date: 9/19/2020 20:09:55
  Description:
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 100;
int n, d[2][N], cnt = 1, k;

int main() {
	scanf("%d", &n);
	--n;
	scanf("%d%d", &d[0][0], &d[1][0]);
	while (n--) {
		++k;
		scanf("%d%d", &d[0][k%2], &d[1][k%2]);
		(d[0][k%2] == d[1][k%2] && d[0][(k-1)%2] == d[1][(k-1)%2]) ? cnt++ : cnt = 1;
		if (cnt >= 3)
			break;
	}
	cnt == 3 ? puts("Yes") : puts("No");
	return 0;
}


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

int main(){
    char shape;
    int n, x;
    bool card[4][13] = {};
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> shape >> x;
        if (shape == 'S') card[0][x - 1] = true;
        else if (shape == 'H') card[1][x - 1] = true;
        else if (shape == 'C') card[2][x - 1] = true;
        else if (shape == 'D') card[3][x - 1] = true;
    }
    for (int i = 0; i < 4; i++){
        for (int j = 1; j <= 13; j++){
            if (card[i][j-1] == false){
                if (i == 0) cout << "S" << " " << j << endl;
                else if (i == 1) cout << "H" << " " << j << endl;
                else if (i == 2) cout << "C" << " " << j << endl;
                else if (i == 3) cout << "D" << " " << j << endl;
            }
        }
    }
}


Measured memory_bytes: 3092
use std::io::*;
use std::str::FromStr;

fn main() {
	let n: usize = read();
	let k: usize = read();
	let mut v = Vec::new();
	for _ in 0..n { v.push(0.0) }
	let mut p: f64;
	let mut sum: f64 = 0.0;
	let mut max: f64;
	for i in 0..k {
		p = read();
		v[i] = p;
		sum += p;
	}
	max = sum;
	for i in 0..n-k {
		p = read();
		v[i+k] = p;
		sum = sum + p - v[i];
		if max < sum {
			max = sum;
		}
	}
	println!("{}", (max+(k as f64))/2.0)
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}



Measured memory_bytes: 6396
/*
 * 
 * 
         _Likhon_
 *
 * 
 */ 

#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	
   int  n, k,i,p[1000],temp,sum=0;
   cin>>n>>k;
   for(i=0; i<n; i++)
   {
	   cin>>p[i];
   }
   for (int i = 0; i < n; i++) 
        {
            for (int j = i + 1; j < n; j++) { 
                if (p[i] > p[j]) 
                {
                    temp = p[i];
                    p[i] = p[j];
                    p[j] = temp;
                }
            }
		}
   for(i=0; i<k; i++)
   {
	   sum = sum+p[i];
   }
   cout<<sum<<"\n";
    return 0;
}












Measured memory_bytes: 3588
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int lMonth = 4280;
		while(scan.hasNext()){
			int water = scan.nextInt();
			if(water == -1){
				break;
			}
			int price = 1150;
			if(water > 30){
				price += 160 * water - 2150;
			}else if(water > 20){
				price += 140 * water - 1550;
			}else if(water > 10){
				price += 125 * (water - 10);
			}
			System.out.println(lMonth - price);
		}
	}
}

Measured memory_bytes: 19228
#include<stdio.h>
int main(){
  int h,w,n,i,j,k,nk,M=1e9+7,d[110][10]={1};
  scanf("%d %d %d",&h,&w,&n);
  for(i=0;i<h;i++){
    for(j=0;j<(1<<(w-1));j++){
      for(k=0;k<w-1;k++){
	if((j&(1<<k))&&(j&(1<<(k+1))))goto NEXT;
      }
      //if(i==0)printf("%d\n",j);
      for(k=0;k<w;k++){
	nk=k;
	if(   j&(1<< k   ))nk=k+1;
	if(k&&j&(1<<(k-1)))nk=k-1;
	//printf("%d %d\n",nk,k);
	d[i+1][nk]=(d[i+1][nk]+d[i][k])%M;
      }
    NEXT:;
    }
  }
  /*for(i=0;i<=h;i++){
    for(j=0;j<w;j++)printf("%d ",d[i][j]);printf("\n");
    }
    printf("%d\n",n);//*/
  printf("%d\n",d[h][n-1]);
  return 0;
}


Measured memory_bytes: 128
//Created by Aminul on 8/15/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        String s = in.next();
        if (s.contains("RRR")) pw.println(3);
        else if (s.contains("RR")) pw.println(2);
        else if (s.contains("R")) pw.println(1);
        else pw.println(0);

        pw.close();
    }

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

Measured memory_bytes: 27044
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int a[N],c[N];
int n,m,v[20];
int f[N],ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		a[x]^=z; a[y]^=z;
	}
	for (int i=0;i<n;i++)
		c[a[i]]++;
	for (int i=1;i<16;i++){
		ans+=c[i]/2;
		if (c[i]&1) v[m++]=i;
	}
	f[0]=0;
	for (int i=1;i<1<<m;i++){
		int k=0,x=0;
		for (int j=0;j<m;j++)
			if ((i>>j)&1){
				x^=v[j];
				k++;
			}
		f[i]=(x?100:k-1);
		for (int p=i-(i&(-i)),j=p;;j=(j-1)&p){
			f[i]=min(f[i],f[j]+f[i^j]);
			if (!j) break; 
		}
	}
	printf("%d",ans+f[(1<<m)-1]);
}

Measured memory_bytes: 768
from math import ceil
N = int(input())
dia = [0]*(N-1)
for i in range(N-1):
    c,s,f = map(int,input().split())
    dia[i] = (c,s,f)
for i in range(N-1):
    time = 0
    for j in range(i,N-1):
        c,s,f = dia[j]
        if time > s:
            x = (time - s)/f
            s += ceil(x)*f
        time =  s + c
    print(time)
print(0)










Measured memory_bytes: 42204
#include <stdio.h>

int main(void){

	int a, b;
	int sum = 0;
	int digit;

	while (scanf("%d %d", &a, &b) != EOF){
		digit = 0;
		sum = a + b;
		while (sum != 0){
			sum /= 10;
			++digit;
		}
		printf("%d\n", digit);
		
	}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
int n,t,a,b,m=100000;
int main()
{ cin>>n>>t;
  for(int i=1;i<=n;i++)
  { cin>>a>>b;
     if(b<=t && a<m)
        m=a;
  }
  if(m==100000)
     cout<<"TLE";
  else
     cout<<m;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
a = list(map(int, input().split()))

ans = pow(10, 18)

for i in range(2 ** N):
    cost = 0
    cnt = 0
    highest = 0
    for j in range(N):
        if (i >> j) & 1:
            cnt += 1
            if highest >= a[j]:
                cost += highest - a[j] + 1
                highest += 1

        highest = max(highest, a[j])
    if cnt >= K:
        ans = min(cost, ans)

print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int a[300][300];

void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);
    int i, j;
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);  a[i][j]--;
        }
    }

    int l = 0, r = n;   //r:ok
    while (r - l > 1) {
        int mm = (l + r) / 2;

        vector<int> curr(n);
        vector<int> flag(m);
        int fin = 0;
        while (1) {
            vector<vector<int> > z(m);
            for (i = 0; i < n; i++) {
                while (curr[i] < m && flag[a[i][curr[i]]]) {
                    curr[i]++;
                }
                if (curr[i] == m) {
                    fin = 1;
                    break;
                }
                int tmp = a[i][curr[i]];
                assert(flag[tmp] == 0);
                z[tmp].push_back(i);
            }
            if (fin) {
                break;
            }
            int del = 0;
            for (i = 0; i < m; i++) {
                if (z[i].size() > mm) {
                    for (j = 0; j < (int)z[i].size(); j++) {
                        int id = z[i][j];
                        curr[id]++;
                    }
                    flag[i] = 1;
                    del = 1;
                    break;
                }                
            }
            if (del == 0) {
                break;
            }
        }
        if (fin) {
            l = mm;
        }
        else {
            r = mm;
        }
    }
    printf("%d\n", r);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort( a, a+3 );
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}

Measured memory_bytes: 3096
<?php
/**
 * ABC128
 * D - equeue
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d", $n, $k);
$v = array_map('intval', explode(' ', trim(fgets(STDIN))));

$r = min($n, $k);
$point_max = 0;
for ($a = 0; $a <= $r; $a++) { // Aの数
    for ($b = 0; $b <= $r - $a; $b++) { // Bの数
        $hands = [];
        // Aの操作
        for ($i = 0; $i < $a; $i++) {
            $hands[] = $v[$i];
        }
        // Bの操作
        for ($i = 0; $i < $b; $i++) {
            $hands[] = $v[$n - 1 - $i];
        }
        // C・Dの操作
        sort($hands);
        $s = min($k - $a - $b, $a + $b);
        for ($i = 0; $i < $s; $i++) {
            if ($hands[$i] >= 0) {
                break;
            }
            unset($hands[$i]);
        }
        $point_max = max(array_sum($hands), $point_max);
    }
}

echo $point_max, PHP_EOL;


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define name "a"
using namespace std;
int n,m;
string s,t;
void nhap(){
    cin >> n >> m;
    getline(cin,s);
    getline(cin,s);
    getline(cin,t);
}
long long ucln(long long a,long long b){
    while (b > 0){
        a = a % b;
        swap(a,b);
    }
    return(a);
}
void xuli(){
    long long l = 1ll * n * m / ucln(n,m);
    //cout << l << endl;
    int j = 1 ;
    for (int i = 1 ; i <= n ; i++){
        while (1ll * (j - 1) * (l / m ) + 1 < 1ll * (i -1) * (l / n) + 1) j++;
        //cout << i * (l / n)<< " " << j * (l / m )<< endl;
        if (1ll * (j - 1) * (l / m ) == 1ll * (i - 1) * (l / n)){
            if (s[i -1 ]!=t[j - 1]){
                cout << -1;
                return;
            }
        }
    }
    cout << l;
}
int main(){
  //  freopen(name".inp","r",stdin);
   // freopen(name".out","w",stdout);
    nhap();
    xuli();
}


Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

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

    int cnt = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (500 * i + 100 * j + 50 * k == x) cnt++;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())

items=[]
for i in range(m):
    p,y=map(int,input().split())
    items.append((p,y,i))
items.sort()

now=0
p1=items[0][0]
ans=[]
for p,y,ind in items:
    if p==p1:
        now+=1
        tmp=str(p*10**6+now)
        tmp=(12-len(tmp))*"0"+tmp
        ans.append((ind,tmp))
    else:
        now=1
        p1=p
        tmp=str(p*10**6+now)
        tmp=(12-len(tmp))*"0"+tmp
        ans.append((ind,tmp))

ans.sort()
for _ , j in ans:
    print(j)

Measured memory_bytes: 39248
def solve():
    n = int(input())
    ary = []
    for i in range(n):
        t,x,y = map(int, input().split(' '))
        ary.append([t,x,y])

    f = True
    for a in ary:
        time = a[0]
        distance = a[1] + a[2]
        max_distance = time
        if ( (time % 2) != (distance % 2) or distance > max_distance):
            print("No")
            f = False
            break
    if (f):
        print("Yes")
solve()

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};


/*
    ref: ??????????§??????¨??£??°(?????¨) https://tomcatowl.github.io/blog/2016/12/12/ds-and-alg-1/
*/

/*
struct Monoid {
    using T = _underlying_set_;                                 // ??¢??????????????°????????????
    T operator() (const T &a, const T &b) { return _a_op_b_; }  // ???????????? 
    static constexpr T identity() { return _identity_element; } // ?????????
};
*/

template<class Monoid>
class SegmentTree {
private:
    using T = typename Monoid::T;
    Monoid op;
    const int n;
    vector<T> dat;
    void prop_to(int i) { dat[i] = op(dat[2*i], dat[2*i+1]); }

public:
    SegmentTree(int _n) : n(_n), dat(2*_n, op.identity()) {}
    SegmentTree(const vector<T> &v) : n(v.size()), dat(2*n)
    {
        copy(v.begin(), v.end(), dat.begin() + n);
        for (int i=n-1; i>0; i--) prop_to(i);
    }

    void update(int i, const T &x)
    {
        dat[i += n] = x;
        while (i >>= 1) prop_to(i);
    }

    T get(int i) { return dat[i + n]; }

    T accumulate(int l, int r) // [l, r)
    {
        T acc_l = op.identity(), acc_r = op.identity();
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) acc_l = op(acc_l, dat[l++]);
            if (r & 1) acc_r = op(dat[r-1], acc_r);
        }
        return op(acc_l, acc_r);
    }
};

struct RMQ {
    using T = int;
    T operator() (const T &a, const T &b) { return min(a, b); }
    static constexpr T identity() { return (1LL<<31) - 1; }
};

struct RSQ {
    using T = int;
    T operator() (const T &a, const T &b) { return a + b; }
    static constexpr T identity() { return 0; }
};

int main()
{
    ios::sync_with_stdio(false);
    
    int N, Q;
    cin >> N >> Q;

    SegmentTree<RSQ> seg_tree(N);
    rep(q, Q) {
        int C, X, Y;
        cin >> C >> X >> Y;

        if (C == 0) {
            X--;
            seg_tree.update(X, seg_tree.get(X) + Y);
        } else {
            X--, Y--;
            cout << seg_tree.accumulate(X, Y+1) << endl;
        }
    }
}

Measured memory_bytes: 3568
package main

import (
	"fmt"
)

func main() {
	var h, w, k int
	fmt.Scan(&h, &w, &k)

	c := make([]string, h)
	for i := range c {
		fmt.Scan(&c[i])
	}

	ans := 0
	for i := 0; i < 1 << h; i++ {
		for j := 0; j < 1 << w; j++ {
			cnt := 0
			for ii := 0; ii < h; ii++ {
				for jj := 0; jj < w; jj++ {
					if (i >> ii) & 1 == 0 {
						continue
					}
					if (j >> jj) & 1 == 0 {
						continue
					}
					if c[ii][jj] == '#' {
						cnt++
					}
				}
			}
			if cnt == k {
				ans++
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1768
n = int(input())
a_list = list(map(int, input().split()))

alice = 0
bob = 0

a_list.sort(reverse=True)

for x in range(0, n, 2):
    alice += a_list[x]

for y in range(1, n, 2):
    bob += a_list[y]

print(alice - bob)


Measured memory_bytes: 2940
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
A, B, C = rs_()
print('YES' if A[-1] == B[0] and B[-1] == C[0] else 'NO')

Measured memory_bytes: 63084
#include<cstdio>
#include<algorithm>
#define int long long
const int N=2e5+3,INF=1e18;
struct segment{int l,r,a;}a[N];
bool Cmp(const segment&a,const segment&b){return a.r<b.r;}
int n,m,dp[N],s,ans;
#define M (L+R>>1)
struct segment_tree{
	int mn[1<<19],lz[1<<19];
	inline void Down(int k){
		mn[k<<1]+=lz[k],lz[k<<1]+=lz[k];
		mn[k<<1|1]+=lz[k],lz[k<<1|1]+=lz[k];
		lz[k]=0;
	}
	void Add(int l,int r,int a,int L,int R,int k){
		if(l>r)return;
		if(l<=L&&R<=r){mn[k]+=a,lz[k]+=a;return;}
		Down(k);
		if(l<=M)Add(l,r,a,L,M,k<<1);
		if(r> M)Add(l,r,a,M+1,R,k<<1|1);
		mn[k]=std::min(mn[k<<1],mn[k<<1|1]);
	}
	int Min(int l,int r,int L,int R,int k){
		if(l<=L&&R<=r)return mn[k];
		int res=INF;
		Down(k);
		if(l<=M)res=std::min(res,Min(l,r,L,M,k<<1));
		if(r> M)res=std::min(res,Min(l,r,M+1,R,k<<1|1));
		return res;
	}
}t;
signed main(){
	scanf("%lld%lld",&n,&m);
	for(int j=1;j<=m;j++)
	  scanf("%lld%lld%lld",&a[j].l,&a[j].r,&a[j].a),s+=a[j].a;
	std::sort(a+1,a+1+m,Cmp);
	ans=INF;
	dp[0]=0;
	for(int i=1,j=1;i<=n+1;i++){
	  for(;j<=m&&a[j].r<i;j++)t.Add(0,a[j].l-1,a[j].a,0,n,1);
	  dp[i]=t.Min(0,i-1,0,n,1);
	  t.Add(i,i,dp[i],0,n,1);
	  ans=std::min(ans,dp[i]);
	}printf("%lld",s-ans);
	return 0;
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  int X[110];
  int res=INF;
  cin >> N;

  rep(i,N) cin >> X[i];
  sort(X,X+N);

  FOR(i,X[0],X[N-1]){
    int sum = 0;
    rep(j,N){
      sum += (X[j] - i) * (X[j] -i);
    }
    res = min(res, sum);
  }

  cout << res << endl;
}


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

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

  int n;
  cin >> n;

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

    if (a[i] == 0) {
      cout << 0 << '\n';
      return (0);
    }
  }

  ll ans = 1;
  for (int i = 0; i < n; ++i) {
    if (ans > 1000000000000000000 / a[i]) {
      cout << -1 << '\n';
      return (0);
    }

    ans *= a[i];
  }

  cout << ans << '\n';

  return (0);
}


Measured memory_bytes: 4404
# -*- coding: utf-8 -*-
"""
C - Unification
https://atcoder.jp/contests/abc120/tasks/abc120_c

"""
import sys


def solve(S):
    orig_len = len(S)
    num_value = {'0': -1, '1': 1}
    status = 0

    for s in S:
        status += num_value[s]
        #if s == '0':
        #    status -= 1
        #else:
        #    status += 1
    return orig_len - abs(status)


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3188
A, B, C = map(int, input().split())
a = A-B
b = B-C
c = A-C
if ((a == 0) and (b != 0) and (c != 0)):
    print('Yes')
elif ((a != 0) and (b == 0) and (c != 0)):
    print('Yes')
elif ((a != 0) and (b != 0) and (c == 0)):
    print ('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int n,x,d;
int main()
{
	cin>>n>>x;
	if(x==1||x==2*n-1)
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes"<<'\n';
	d=n-x,n+=n-1;
	for(int i=0;i<n;i++)
		cout<<(i-d+n)%n+1<<'\n';
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstring>
#include <vector>
#include <iomanip>
using namespace std;

void test(vector<double> &p){
	double dp[p.size()+1][p.size()+1];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1.0;
	for(int i = 1; i <= p.size(); i++){
		for(int j = 0; j <= i; j++){
			if(j==0){
				dp[i][j] = (1-p[i-1])*dp[i-1][j];
			}
			else{
				dp[i][j] =  (1-p[i-1])*dp[i-1][j] + p[i-1]*dp[i-1][j-1];
			}
		}
	}
	double ans = 0.0;
	for(int j = p.size()/2 + 1; j <= p.size(); j++){
		ans += dp[p.size()][j];
	}
	cout << setprecision(10) << ans << endl;
}

int main(){
	#ifndef ONLINE_JUDGE
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/input.txt", "r", stdin);
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/output.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	vector<double> p(n, 0);
	for(int i = 0; i < n; i++){
		cin >> p[i];
	}
	test(p);
	return 0;
}

Measured memory_bytes: 74160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  if(n%a==0) a=n/a;
  else a=n/a+1;
  if(n%c==0) c=n/c;
  else c=n/c+1;
  if(a*b>c*d) cout<<c*d<<endl;
  else cout<<a*b<<endl;
  return 0;
}



Measured memory_bytes: 3120
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
from decimal import Decimal

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def dfs(graph, start, visited):
    visited[start] = True
    ret = 0
    if all(visited):
        visited[start] = False
        return 1

    for next in graph[start]:
        if not visited[next]:
            ret += dfs(graph, next, visited)
    visited[start] = False
    return ret


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    graph = {n: [] for n in range(N)}
    visited = [False] * N
    for _ in range(M):
        a, b = il()
        graph[a - 1].append(b - 1)
        graph[b - 1].append(a - 1)

    print(dfs(graph, 0, visited))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5192
using namespace std;
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> dl;
typedef vector<ii> vii;
typedef vector<dl> vdll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define in insert
#define bs binary_search
#define INF LLONG_MAX
#define rc(s) return cout << s,0
#define int ll
const ll mod=1e9+7;
const int N=100005;
#define int ll
/*----------------------------*/ 
int arr[N],l[N],r[N];
/*----------------------------*/
int32_t main() {
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>arr[i];
	for(int i=1;i<=n;i++)l[i]=__gcd(l[i-1],arr[i]);
	for(int i=n;i>=1;i--)r[i]=__gcd(r[i+1],arr[i]);
	int ans=1;
	for(int i=1;i<=n;i++)ans=max(ans,__gcd(l[i-1],r[i+1]));
	rc(ans);
   	//THIS IS IS THE END
}

Measured memory_bytes: 2560