akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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


int main() {
	VI v(5);
	REP(i, 5) {
		cin >> v[i];
	}
	int mm = 10;
	int idx = 0;
	REP(i, 5) {
		if (mm > v[i] % 10 && v[i]%10!=0) {
			mm = v[i] % 10;
			idx = i;
		}
	}
	int sum = 0;
	REP(i, 5) {
		if (i == idx) {
			sum += v[i];
		}
		else {
			sum += (v[i] + 10 - 1) / 10*10;
		}
	}
	ANS(sum);

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N;
        int[] H,W;
        H = new int[300];
        W = new int[300];
        for(int i=0;;i++){
           
            H[i] = sc.nextInt();
            W[i] = sc.nextInt();
            if(H[i]==0 && W[i]==0){
                break;
            }
        }
        for(int i=0;;i++){
            if(H[i]==0 && W[i]==0){
                break;
            }
            for(int j=0;j<H[i]/2;j++){
                for(int l=0;l<W[i]/2;l++){
                    System.out.print("#.");
                }
                if(W[i]%2==1)   System.out.print("#");
                System.out.println();
                for(int l=0;l<W[i]/2;l++){
                    System.out.print(".#");
                }
                if(W[i]%2==1)   System.out.print(".");
                System.out.println();
            }
            if(H[i]%2==1){
                for(int l=0;l<W[i]/2;l++){
                    System.out.print("#.");
                    
                }
                if(W[i]%2==1)   System.out.print("#");
                System.out.println();
            }  
            System.out.println();

        }
        sc.close();
    }
}


Measured memory_bytes: 34092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int n = s.length;
		int ans = 0, l = 0, r = n - 1;
		while(l < r) {
			if(s[l] == s[r]) {
				l++; r--;
			} else {
				if(s[l] != 'x' && s[r] != 'x') {
					System.out.println(-1);
					return;
				} else {
					if(s[l] == 'x') {
						l++;
						ans++;
					}
					if(s[r] == 'x') {
						r--;
						ans++;
					}
				}
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    if (a % 2 == 0 || b % 2 == 0)
    {
        cout << "Even" << endl;
        return (0);
    }
    cout << "Odd" << endl;
    return (0);
}


Measured memory_bytes: 3636
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>
#include <bitset>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ll n, m;
    cin >> n >> m;
    if (n == 1 && m == 1)
    {
        cout << 1 << '\n';
        return 0;
    }
    ll per = 2 * (n - 1) + 2 * (m - 1);
    if (n == 1) per = 2;
    if (m == 1) per = 2;
    cout << n * (ll) m - per << '\n';
    return 0;
    /*
    int n, a, b;
    cin >> n >> a >> b;
    if (a * (ll) b < n || a + b > n + 1)
    {
        cout << -1 << '\n';
        return 0;
    }
    n -= a - 1;
    vector <int> arr;
    vector <int> kek;
    for (int i = n; i < n + a - 1; i++)
    {
        kek.push_back(i);
    }
    for (int i = 0; i < n; i += b)
    {
        int en = min(n - 1, i + b - 1);
        for (int j = en; j >= i; j--)
        {
            arr.push_back(j);
        }
        if (!kek.empty()) for (int x : kek) arr.push_back(x);
        kek.clear();
    }
    for (int v : arr)
    {
        cout << v + 1 << ' ';
    }
    cout << '\n';
    */
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int V, E;
ll Dist[105][105];

int Display(){
  for (int i = 0; i < V; i++){
    for (int j = 0; j < V; j++){
      if (Dist[i][j] == 1e16) printf("INF");
      else printf("%lld", Dist[i][j]);
      if (j == V - 1) printf("\n");
      else printf(" ");
    }
  }
  return 0;
}

int Solve(){
  for (int k = 0; k < V; k++){
    for (int i = 0; i < V; i++){
      for (int j = 0; j < V; j++){
        if (Dist[i][k] == 1e16 || Dist[k][j] == 1e16) continue;
        Dist[i][j] = min(Dist[i][j], Dist[i][k] + Dist[k][j]);
      }
    }
  }

  for (int i = 0; i < V; i++){
    if (Dist[i][i] != 0){
      printf("NEGATIVE CYCLE\n");
      return 0;
    }
  }
  Display();
  return 0;
}

int main(){
  scanf("%d%d", &V, &E);
  fill((ll*)Dist, (ll*)(Dist + V), 1e16);
  for (int i = 0; i < V; i++) Dist[i][i] = 0;

  for (int i = 0; i < E; i++){
    int S, T; ll D;
    scanf("%d%d%lld", &S, &T, &D);
    Dist[S][T] = D;
  }
  Solve();

  return 0;
}



Measured memory_bytes: 3296
#include<bits/stdc++.h>
#define up(j,k,i) for(ll i=j;i<k;i++)
#define down(j,k,i) for(ll i=j;i>k;i--)
#define M 1000000007
#define pp(n) printf("%lld\n",ll(n))
#define ps(n) printf("%lld ",ll(n))
#define pd(x,y) printf("%lld %lld\n",ll(x),ll(y))
#define is(n) scanf("%lld",&n)
#define inf LLONG_MAX
#define id(n,m) scanf("%lld%lld",&n,&m)
#define it(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define pb push_back
#define F first
#define S second
#define pll pair<ll,ll> 
#define db cout<<"######\n"
#define null(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,255,sizeof(a))
typedef long double ld;
typedef long long int ll;
using namespace std;
ll i,j,k,z,t,n,m,sum,ans,x,y,maxm=0,minm=inf; bool flag;
int main()
{
	string s,t;
	
	cin>>s>>t; ans=-1;
	
	for(int i=0;i+ll(t.size())-1<s.size();i++)
	{
		bool flag=true;
		
		up(0,t.size(),j)
		if(s[i+j]==t[j] or s[i+j]=='?')
		continue;
		else
		{
			flag=false;
			break;
		}
		
		if(flag)
		ans=i;
		
	}
	
	if(ans==-1)
	{
		puts("UNRESTORABLE");
		return 0;
	}	
	
	up(0,t.size(),i)
	s[ans+i]=t[i];
	
	up(0,s.size(),i)
	if(s[i]=='?')
	s[i]='a';
	
	cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> S(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S.at(i).at(j);
    }
  }
  
  vector<vector<int>> data(H+2, vector<int>(W+2,0));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S.at(i).at(j) == '#'){
        data.at(i+1).at(j+1)+=100;
        data.at(i+1).at(j)++;
        data.at(i+1).at(j+2)++;
        data.at(i).at(j+1)++;
        data.at(i+2).at(j+1)++;
        data.at(i).at(j)++;
        data.at(i+2).at(j)++;
        data.at(i+2).at(j+2)++;
        data.at(i).at(j+2)++;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data.at(i+1).at(j+1) >= 100){
        cout << '#';
      }
      else {
        cout << data.at(i+1).at(j+1);
      }
      if (j == W-1){
        cout << endl;
      }
    }
  }
}
  

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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int x,y,z;
	cin>>x>>y>>z;
	
	cout<<z<<" "<<x<<" "<<y<<endl;
}


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


int main() {
  vector<int> kuku;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      kuku.push_back(i*j);
    }
  }

  int n;
  cin >> n;
  string ans = "No";
  for (int x: kuku) {
    if (x == n) {
      ans = "Yes";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N){
        cin >> a.at(i);
    }
    sort(rall(a));
    int Alice = 0, Bob = 0;
    rep(i, N){
        if (i % 2 == 0){
            Alice += a.at(i);
        }
        else{
            Bob += a.at(i);
        }
    }
    cout << (Alice - Bob) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdlib>
using namespace std;
typedef long long ll;
const int N=1e5+5;
const int INF=1<<30;
vector<int>edge[N];
int deep[N];
void nosolution(){
    puts("No");
    exit(0);
}
void dfs1(int u,int fa,int d){
    deep[u]=d;
    for(int i=0,sz=edge[u].size();i<sz;i++){
        int v=edge[u][i];
        if(v==fa)
            continue;
        dfs1(v,u,d+1);
    }
}
int val[N],mn[N],mx[N];
void dfs2(int u,int fa){
    if(val[u]==-1)
        mn[u]=-INF,mx[u]=INF;
    else
        mn[u]=mx[u]=val[u];
    for(int i=0,sz=edge[u].size();i<sz;i++){
        int v=edge[u][i];
        if(v==fa)
            continue;
        dfs2(v,u);
        if(mx[v]<mn[u]-1||mn[v]>mx[u]+1)
            nosolution();
        mn[u]=max(mn[u],mn[v]-1);
        mx[u]=min(mx[u],mx[v]+1);
    }
}
int ans[N];
void dfs3(int u,int fa,int t){
    if(t+1<=mx[u])
        ans[u]=t+1;
    else if(t-1>=mn[u])
        ans[u]=t-1;
    for(int i=0,sz=edge[u].size();i<sz;i++){
        int v=edge[u][i];
        if(v==fa)
            continue;
        dfs3(v,u,ans[u]);
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    int q;
    scanf("%d",&q);
    memset(val,-1,sizeof val);
    int x;
    for(int i=1;i<=q;i++){
        scanf("%d",&x);
        scanf("%d",&val[x]);
    }
    dfs1(1,-1,1);
    for(int i=1;i<=n;i++){
        if(val[i]!=-1&&(((val[i]&1)^(deep[i]&1))!=((val[x]&1)^(deep[x]&1)))){
            nosolution();
        }
    }
    dfs2(1,-1);
    dfs3(1,-1,mx[1]-1);
    puts("Yes");
    for(int i=1;i<=n;i++)
        printf("%d\n",ans[i]);
}


Measured memory_bytes: 14592
import math
s = input()
k = int(s)
n = 3
ans={}
for i in reversed(range(1, k+1)):
    ans[i]=math.floor(k/i)**n
    l=2
    j=i*l
    while j<=k:
        ans[i]=ans[i]-ans[j]
        l +=1
        j = i*l
res=0
for i in ans:
    res+=i*ans[i]
print(res)

Measured memory_bytes: 9216
import numpy as np
import sys

def calc_dis(x, y):
    return np.sqrt(x**2 + y**2)

def main():
    data = input().split()
    n = int(data[0])
    d = int(data[1])
    data = np.zeros((n, 2))
    for i in range(n):
        s = input().split()
        data[i,0] = int(s[0])
        data[i,1] = int(s[1])
    
    tot = 0
    for i in range(n):
        dis = calc_dis(data[i,0],data[i,1])
        if dis <= d:
            tot += 1
    print(tot)

if __name__ == '__main__':
    main()

Measured memory_bytes: 29688
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 998244353
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(n)
	string ss;
	cin>>ss;
	vector<int> s(3*n);
	fo(i,3*n)
	{
		if(ss[i]=='R')
			s[i]=0;
		else if(ss[i]=='B')
			s[i]=1;
		else
			s[i]=2;
	}
	vector<vector<int>> ind(3,{-1});
	fo(i,3*n)
	{
		ind[s[i]].pb(i);
	}
	int ans=1;
	vector<int> b(3);
	vector<vector<int>> a(3,vector<int>(3));
	for(int i=3*n-1;i>=0;i--)
	{
		ans%=mod;
		ind[s[i]].pop_back();
		if(s[i]==0)
		{
			if(a[1][2])
			{
				ans*=a[1][2];
				a[1][2]--;
				continue;
			}
			if(b[1] && b[2])
			{
				if(ind[1].back()<ind[2].back())
				{
					ans*=b[1];
					a[0][1]++;
					b[1]--;
				}
				else
				{
					ans*=b[2];
					a[0][2]++;
					b[2]--;
				}
			}
			else if(b[1])
			{
				ans*=b[1];
				a[0][1]++;
				b[1]--;
			}
			else if(b[2])
			{
				ans*=b[2];
				a[0][2]++;
				b[2]--;
			}
			else
			{
				b[0]++;
			}
		}
		else if(s[i]==1)
		{
			if(a[0][2])
			{
				ans*=a[0][2];
				a[0][2]--;
				continue;
			}
			if(b[0] && b[2])
			{
				if(ind[0].back()<ind[2].back())
				{
					ans*=b[0];
					a[0][1]++;
					b[0]--;
				}
				else
				{
					ans*=b[2];
					a[1][2]++;
					b[2]--;
				}
			}
			else if(b[0])
			{
				ans*=b[0];
				a[0][1]++;
				b[0]--;
			}
			else if(b[2])
			{
				ans*=b[2];
				a[1][2]++;
				b[2]--;
			}
			else
			{
				b[1]++;
			}
		}
		else
		{
			if(a[0][1])
			{
				ans*=a[0][1];
				a[0][1]--;
				continue;
			}
			if(b[0] && b[1])
			{
				if(ind[0].back()<ind[1].back())
				{
					ans*=b[0];
					a[0][2]++;
					b[0]--;
				}
				else
				{
					ans*=b[1];
					a[1][2]++;
					b[1]--;
				}
			}
			else if(b[1])
			{
				ans*=b[1];
				a[1][2]++;
				b[1]--;
			}
			else if(b[0])
			{
				ans*=b[0];
				a[0][2]++;
				b[0]--;
			}
			else
			{
				b[2]++;
			}
		}
	}
	ans%=mod;
	for(int i=1;i<=n;i++)
	{
		ans*=i;
		ans%=mod;
	}
	cout<<ans<<'\n';
	printclock;
}

Measured memory_bytes: 6028
#include<bits/stdc++.h>
using namespace std;
long long arr[3000000],arr1[3000000],cum[3000000],cum1[3000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,m,k,i,j,x,y,z,a,b,z1,c,cc;
    cin>>n>>m>>k;
    a=0;
    for (i=1;i<=n;i++)
    {
    	cin>>arr[i];
    	cum[i]=cum[i-1]+arr[i];
	}
	for (i=1;i<=m;i++)
	{
		cin>>arr1[i];
		cum1[i]=cum1[i-1]+arr1[i];
	}
	z=0;
	for (i=0;i<=n;i++)
	{
		if (cum[i]>k)
		{
			break;
		}
	}	
	z=i-1;
	x=z;
	y=0;
	b=0;
	while (1)
	{
		if (y==m && x==0)
		{
			break;
		}
		y++;
		if (y>m)
		{
			y=m;
		}
		c=cum1[y]+cum[x];
		if (c<=k)
		{
			cc=x+y;
			z=max(z,cc);
			if (y==m)
			{
				break;
			}
		}
		else
		{
			x--;
			if (x<0)
			{
				x=0;
			}
		}
	}
	cout<<z<<endl;	
}

Measured memory_bytes: 9888
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

int main()
{
	int n;
	int d[50];
	ll ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>d[i];
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
			ans+=d[i]*d[j];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	static int N;
static final long PRIME=(long)(1e9+7);
	static long fact(int n){
		long f=1;
		for(int i=1;i<=n;i++)f=(f*i)%PRIME;
		
		return f;
		
		
	}
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			//Input
			N=Integer.parseInt(sc.next());
			int[] x= new int[N+1];
			for(int i=1;i<=N;i++)x[i]=Integer.parseInt(sc.next());
			
			//System.out.println("Input has been finished.");
			
			
			
			//calculate
			long ans=1;int irr=0;
			for(int k=1;k<N;k++){
				if(x[k]==2*(k-1-irr)){
					ans=(ans*(k-irr))%PRIME;
					irr++;
				}
			}
			ans=(ans*fact(N-irr))%PRIME;
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 50908
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String before = sc.nextLine();
		String after = "";
		char[] c = before.toCharArray();
		for (int i = 0; i < c.length; i++) {
			if (Character.isUpperCase(c[i])) {
				c[i] = Character.toLowerCase(c[i]);
			} else if (Character.isLowerCase(c[i])) {
				c[i] = Character.toUpperCase(c[i]);
			}
		}
		for (int i = 0; i < c.length; i++) {
			after += String.valueOf(c[i]);
		}
		System.out.println(after);
		sc.close();
	}
}


Measured memory_bytes: 31196
# https://atcoder.jp/contests/abc072/tasks/arc082_b

n = int(input())
nums = [int(i) for i in input().split()]
t = 0
for i in range(n):
    if i == n - 1 and nums[i] == i + 1:
        nums[i], nums[i - 1] = nums[i - 1], nums[i]
        t += 1
    elif nums[i] == i + 1:
        nums[i], nums[i + 1] = nums[i + 1], nums[i]
        t += 1
print(t)

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

int main()
{
  float n;
  cin>>n;
  float ans;
  ans=ceil(n/1.08);
  //cout << (n+1)/1.08 << " " << ans << " " << floor(ans*1.08) << endl;
  if(floor(ans*1.08) == n)
    cout << floor(ans)<<endl;
  else
    cout << ":(" << endl;
}

Measured memory_bytes: 256
H, W = map(int,input().split())
B = []
B.append(["." for _ in range(W+2)])
for _ in range(H):
    S = input()
    L = []
    L.append(".")
    for s in S:
        L.append(s)
    L.append(".")
    B.append(L)
B.append(["." for _ in range(W+2)])

for i in range(H):
    for j in range(W):
        if B[i+1][j+1] == "#" and B[i][j+1] == "." and B[i+2][j+1] == "." and B[i+1][j] == "." and B[i+1][j+2] == ".":
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3064
def main() -> None:
    A, B, K = map(int, input().split())
    ans = []
    for i in range(1, 101):
        if A % i == 0 and B % i == 0:
            ans.append(i)

    ans.sort(reverse=True)
    print(ans[K - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
N = int(input())
res = 0
t = float("inf")
c = 0
for _ in range(N):
  x, y = map(int, input().split())
  if x > y: t = min(y, t)
  if x == y: c += 1
  res += x
if c == N:
  print(0)
  exit(0)
print(res - t)

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

using namespace std;

int dp(int curr, int T, const vector<int>& A, const vector<int>& B, vector<vector<int>>& memo) {
    int N = A.size();
    if (curr == N) {
        return 0;
    }
    if (T <= 0) {
        return 0;
    }
    if (memo[curr][T] >= 0) {
        return memo[curr][T];
    }

    int skip = dp(curr + 1, T, A, B, memo);
    int take = dp(curr + 1, T - A[curr], A, B, memo) + B[curr];
    int ret = max(skip, take);
    memo[curr][T] = ret;
    return ret;
}

void Main() {
    int N, T;
    cin >> N >> T;
    set<pair<int, pair<int, int>>> prep;
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        prep.insert(make_pair(a, make_pair(i, b)));
    }
    vector<int> A(N, 0), B(N, 0);
    int cnt = 0;
    for (auto e : prep) {
        A[cnt] = e.first;
        B[cnt] = e.second.second;
        ++cnt;
    }

    vector<vector<int>> memo(N + 10, vector<int>(T + 10, -1));
    int ans = dp(0, T, A, B, memo);
    cout << ans << endl;
}

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


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

int main()
{
    int r,c;
    cin>>r>>c;
    vector<vector<int> >s(r+1,vector<int>(c+1,0));
    int sum=0;
    REP(i,r)//入力
    {
        REP(j,c)
        {
            cin>>s.at(i).at(j);
            sum+=s.at(i).at(j);
        }
    }
    REP(i,c)//最下面
    {
        REP(j,r)
        {
            s.at(r).at(i)+=s.at(j).at(i);
        }
    }

    REP(i,r)//最右边
    {
        REP(j,c)
        {
            s.at(i).at(c)+=s.at(i).at(j);
        }
    }
    s.at(r).at(c)=sum;

    REP(i,r+1)//出力
    {
        REP(j,c+1)
        {
            if(j==c)cout<<s.at(i).at(j);
            else cout<<s.at(i).at(j)<<" ";
            
        }
        cout<<endl;
    }
}



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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  string S;
  cin >> S;
  int N = S.length();
  int ans = 0;
  REP(i, N)
  {
    int tmp = 0;
    for (int j = i; j < N; j++)
    {
      if (S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T')
        tmp++;
      else
        break;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define int         long long 
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define trace1(x)                cerr << #x << ": " << x << "\n";
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z<<" " ;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d<<" " ;
using namespace std;

void solve(){

    string s;
    cin>>s;
    int ans=0, cur1=0, cur2=0;
    rep(i,0,sz(s))
    {
        if(s[i]=='A') 
        {
            cur1++;
        }
        else if(i<sz(s)-1 && s[i]=='B' && s[i+1]=='C')
        {
            i+=1;
            ans+=cur1;
        } 
        else cur1=0;
    }

    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 720
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define ff first
#define ss second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	El3zba;
	int n;
	cin >> n;
	map<string, LL>mpp;
	LL cnt = 0;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mpp[s]++;
	}
	for (auto&x : mpp)
	{
		LL v = x.ss;
		LL v2 = x.ss - 1;
		cnt += (v*v2) / 2;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 11264
N = int(input())
A = []
B = []
C = []
for _ in range(0,N):
    a,b,c = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)

max_a = [0] * N
max_b = [0] * N
max_c = [0] * N

max_a[0] = A[0]
max_b[0] = B[0]
max_c[0] = C[0]

for i in range(1,N):
    max_a[i] = max(max_b[i-1], max_c[i-1]) + A[i]
    max_b[i] = max(max_a[i-1], max_c[i-1]) + B[i]
    max_c[i] = max(max_a[i-1], max_b[i-1]) + C[i]

print(max(max_a[N-1], max_b[N-1], max_c[N-1]))

Measured memory_bytes: 27284
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        void Omame()
        {
            cin = new Scanner();
            string S = cin.next();
            string T = cin.next();
                Console.WriteLine(T+S);
        }
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	string w;
	cin >> w;
	int A[100] = {0};
	for (int i = 0; i < w.length(); i++) {
		A[w[i]-'a']++;
	}
	int rec = 0;
	for (int i = 0; i < w.length(); i++) {
		if (A[w[i]-'a'] % 2 != 0) {
			rec++;
		}
	}
	if (rec == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007

int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ll n, k;
	cin >> n >> k;
	ll a[n];
	for(ll i=0; i<n; i++)
		cin >> a[i];
	sort(a, a+n);
	ll ans = 0;
	for(ll i=0; i<k; i++)
		ans += a[i];
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3664
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,q = map(int, readline().split())
#*a, = map(int, readline().split())

def get(i,l,r):
    a = i-r
    b = i-l
    if b < 0: return 0
    return acc[b] - (acc[a-1] if a-1 >= 0 else 0)



n,k = map(int, readline().split())
lr = [list(map(int, readline().split())) for _ in range(k)]

dp = [0]*(n)
dp[0] = 1
acc = [1]*(n)


MOD = 998244353
for i in range(1,n):
    v = 0
    for l,r in lr:
        v += get(i,l,r)
    dp[i] = v%MOD
    acc[i] = (acc[i-1] + dp[i])%MOD
    #print(dp,acc)

print(dp[n-1]%MOD)

Measured memory_bytes: 24652
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
typedef unsigned long long int ull;

using namespace std;

int main(void){
  ull N;
  cin >> N;
  ull ans=N*(N-1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define abs(a) ((a)<0 ? -(a) : (a))
#define min(a, b) ((a)<(b) ? (a) : (b))

int main(){
  int n, k, h[100001], dp[100001];
  scanf("%d %d", &n, &k);
  for(int i=0; i<n; i++){
    scanf("%d", &h[i]);
    dp[i] = 10000*n;
  }
  dp[0] = 0;
  for(int i=1; i<n; i++){
    for(int j=1; (j<=k && i-j>=0); j++){
      dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
    }
  }

  printf("%d\n", dp[n-1]);
  return 0;
}
	 



Measured memory_bytes: 896
N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A.append(str(input()))
for i in range(M):
    B.append(str(input()))

def check(i, j, A, B, M):
    for k in range(M):
        if A[i+k][j:j+M] != B[k]:
            return False
    return True 

def Main(N, M, A, B):
    for i in range(N-M+1):
        for j in range(N-M+1):
            if A[i][j] == B[0][0]:
                if check(i, j, A, B, M):
                    return 'Yes'
    return "No"     
    
res = Main(N, M, A, B)
print(res)

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    long long N; cin >> N;

    if (N & 1) {
        cout << 0 << '\n';
        return;
    }

    long long n = N;
    int cnt = 0;
    while (n >= 5) {
        cnt++;
        n /= 5;
    }

    N /= 2;
    long long tmp = 1;
    long long ans = 0;
    for (int i = 0; i < cnt; i++) {
        tmp *= 5;
        ans += N / tmp;
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3648
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-06-17 09:17:14

---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{	
	int a, b;
	cin >> a >> b;
	cout << 10*(a>=b) << endl;
	return 0;
}

Measured memory_bytes: 256
M, D = map(int, input().split())

count = 0
for m in range(1, M + 1):
    for d in range(1, D + 1):
        d1 = int(str(d).zfill(2)[1])
        d10 = int(str(d).zfill(2)[0])
        if d1 >= 2 and d10 >= 2 and d1 * d10 == m:
            count += 1
print(count)


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, K;
	cin >> N >> K;

	if (K == 0)
	{
		cout << N * N << endl;
		return 0;
	}

	int ans = 0;
	rep(i, 1, N + 1)
	{
		if (i <= K)
		{
			ans += N;
		}
		else
		{
			ans += (N / i)*K + min(N%i, K - 1);
		}
	}

	cout << N*N-ans << endl;

	return 0;
}

Measured memory_bytes: 256
s = 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
else:
    ans = 1
print(ans)

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

//昇順
int acs(const void *a, const void *b)
{
  return *(int *)a - *(int *)b;
}

int main() {
  int N, K;
  cin >> N >> K;
  int x[N], y[N], sx[N], sy[N], xi, yi;
  for (int i=0; i<N; i++) {
    cin >> xi >> yi;
    x[i] = sx[i] = xi;
    y[i] = sy[i] = yi;
  }
  qsort(sx, N, sizeof(int), acs);
  qsort(sy, N, sizeof(int), acs);
  long ans = LONG_MAX;
  for (int lx=0; lx<N-K+1; lx++) {
    for (int rx=lx+K-1; rx<N; rx++) {
      for (int by=0; by<N-K+1; by++) {
        for (int ty=by+K-1; ty<N; ty++) {
          long Lx = sx[lx], Rx = sx[rx], By = sy[by], Ty = sy[ty];
          int cnt = 0;
          for (int i=0; i<N && cnt<K; i++) {
            if (Lx<=x[i] && x[i]<=Rx && By<=y[i] && y[i]<=Ty)
              cnt++;
          }
          if (cnt==K)
            ans = min(ans, (Rx-Lx)*(Ty-By));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 標準入力を取得
N = int(input())


def divisor_count(n: int) -> int:
    ans = 0
    i = 1
    while i * i <= n:
        if n % i == 0:
            ans += 1
            if i != n // i:
                ans += 1
        i += 1
    return ans

# 求解処理
ans = 0
for n in range(1, N + 1, 2):
    if divisor_count(n) == 8:
        ans += 1

# 結果出力
print(ans)

Measured memory_bytes: 9128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        set<int> s;
        for (int i = 0; i < n; i ++) {
                int a;
                scanf("%d", &a);
                s.insert(a);
        }
        printf("%d\n", (int) s.size());
        return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void insert(int);
void heapIncreaseKey(int*, int, int);
int extract(void);
void maxHeapify(int *, int);

int A[2000001], H;

int main()
{
  char ope[10];
  int k;

  while(1)
    {
      scanf("%s", ope);

      if(ope[0] == 'i')
	{
	  scanf("%d", &k);
	  insert(k);
	}
      else if(ope[0] == 'e' && ope[1] == 'x')printf("%d\n", extract());
      else break;
    }
  return 0;
}

void insert(int k)
{
  H++;
  heapIncreaseKey(A, H, k);
}

void heapIncreaseKey(int A[], int i, int k)
{
  int swap;
  
  A[i] = k;
  while(i>1 && A[i/2] < A[i])
    {
      swap = A[i]; A[i] = A[i/2]; A[i/2] = swap;
      i /= 2;
    }
}

int extract(void)
{
  int max;
  if(H < 1)exit(0);
  max = A[1];
  A[1] = A[H]; H--;
  maxHeapify(A, 1);
  return max;
}

void maxHeapify(int A[], int i)
{
  int l, r, largest, swap;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i])largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest])largest = r;

  if(largest != i)
    {
      swap = A[i]; A[i] = A[largest]; A[largest] = swap;
      maxHeapify(A, largest);
    }
}



Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

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

    ll ans = 1e18;
    for (ll i = 1; i*i <= n; ++i) {
        if (n % i != 0) continue;
        ans = min(ans, (i-1) + (n/i-1));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    double ans = 0.0;
    if(n % 2 == 0) {
        ans = 1.0 / 2.0;
    }else {
        ans = (double)(n/2 + 1) / (double)n;
    }

    printf("%.14f\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<P> sum(n);
  int A=0;
  int T=0;
  rep(i,n){
      cin>>a[i]>>b[i];
      sum[i].first=a[i]+b[i];
      sum[i].second=i;
  }
  sort(sum.begin(),sum.end());
  for(int i=n-1;i>=0;--i){
      if((n-1-i)%2==0){
          T+=a[sum[i].second];
      }
      else{
          A+=b[sum[i].second];
      }
  }
  cout<<T-A<<endl;
  return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n;
  cin >> n;
  vi h(n);
  REP(i,n) cin >> h[i];
  int count = 0;
  bool last = false;
  bool flag = true;
  while(flag){
    flag = false;
    last = false;
    REP(i,n){
      if(!h[i]){
        last = false;
        continue;
      }
      if(!last) count++;
      h[i]--;
      flag = true;
      last = true;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

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

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

//-----end of template-----//

int main(){
	i64 n;
	cin >> n;
	vector<i64> a(n);
	for(int i = 0; i < n; ++i) cin >> a[i];
	unordered_map<i64, i64> mp;
	i64 sum = 0, ans = 0;
	for(i64 i = 0; i < n; ++i){
		mp[sum]++;
		sum += a[i];
		ans += mp[sum];
	}
	cout << ans << endl;
}

Measured memory_bytes: 10056
const gcd = (a, b) => {
    if (b === 0) return a;
    else if (a === 0) return b;
    return gcd(b, a%b);
}

const initGCD = (n, a) => {
    let L = [...new Array(n)].fill(0)// aをiで分けたときの左部分GCD
    let R = [...new Array(n)].fill(0)// aをiで分けたときの右部分GCD
    L[0] = R[n-1] = 0
    for(let i=0; i<n-1; i++) {
        L[i+1] = gcd(L[i], a[i])
        R[n-i-2] = gcd(R[n-i-1], a[n-i-1])
    }
    return [L,R]
}

const main = (arg) => {
    const n = Number(arg.split("\n")[0])
    const a = arg.split("\n")[1].split(" ").map(Number)

    const [L,R] = initGCD(n, a)

    const m = [...new Array(n)].fill(0)// gcd when ai is excluded
    for(let i=0; i<n; i++) {
        // console.log(`L[i]=${L[i]}, R[i]=${R[i]}`)
        m[i] = gcd(L[i],R[i])
    }
    console.log(Math.max(...m))
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 45672
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    int A, B;
    cin >> A >> B;
    ans = A * B - (A + B - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#atcoder beginner contest 141

#atcoder beginner contest 141
tap = input("")
tap_num = 0
success = 0

for char in tap:
    if tap_num % 2 == 0:
        if char =="R" or char == "U" or char == "D":
            success += 1
            
    else:
        if char =="L" or char == "U" or char == "D":
            success += 1

    tap_num += 1

if success == tap_num:
    print("Yes")
else:
    print("No")
            



Measured memory_bytes: 2940
#include <cstdio>
#include <utility>
#include <string>
#include <iostream>

using namespace std;

struct team{
    string s;
    int input, point;
};

int main()
{
    bool first = 1;
    while( 1 )
    {
        int n;
        scanf( "%d", &n );
        if( n == 0 ) break;
        if( !first )
        {
            printf( "\n" );
        }
        else
        {
            first = 0;
        }
        team p[10];
        int i = 0;
        while( i < n )
        {
            string s;
            cin >> s;
            int w,l,d;
            cin >> w >> l >> d;
            p[i].s = s;
            p[i].point = 3 * w + d;
            p[i].input = i;
            i++;
        }
        for( int j = 0; j < n; j++ )
        {
            for( int k = j; k < n; k++ )
            {
                if( p[j].point < p[k].point )
                {
                    swap( p[j], p[k] );
                }
            }
        }
        for( int j = 0; j < n; j++ )
        {
            for( int k = j; k < n; k++ )
            {
                if( p[j].point == p[k].point && p[j].input > p[k].input )
                {
                    swap( p[j], p[k] );
                }
            }
        }
        for( int j = 0; j < n; j++ )
        {
            cout << p[j].s << ',' << p[j].point << '\n';
        }
    }   
    return 0; 
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define fr         first
#define se         second
#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x);
#define bb(x)      cerr<< x <<endl;
#define ii         pair<int,int>
#define vi         vector<int>
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M   = 1e7+9 ;
const ll inf = 1e19  ;
const int si = 1e5+9 ;
//////////////////////    Hi    ^_^  hack me if you can :P
string s;
int n;
ll ans;
void solve(ll i,ll a,ll b)
{
    if(i==sz(s))
    {
        ans+=a+b;
        return;
    }
    solve(i+1,a+b,s[i]-'0');
    solve(i+1,a,(s[i]-'0')+10*b);
}
int main()
{
    cin >> s;
    n =sz(s);
    solve(0,0,0);
    cout<< ans/2 ;
    r0;
}


/*

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

*/
/*
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
int mx[]= {0,0,1,1,1,-1,-1,-1};
int my[]= {1,-1,0,1,-1,0,1,-1};
bool inside (int i,int j) {return (i>=0 && i<n && j>=0 && j<m);}
*/


Measured memory_bytes: 256