akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S,class T>ostream&operator<<(ostream&os,map<S,T>d){bool a=1;for(auto v:d){os<<(a?"":" ")<<v;a=0;}return os;};
template<class S>ostream&operator<<(ostream&os,set<S>d){bool a=1;for(auto v:d){os<<(a?"":" ")<<v;a=0;}return os;};
template<class S>auto&operator<<(ostream&os,vector<S>d){bool a=1;for(auto v:d){os<<(a?"":" ")<<v;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vl a(n);
    cin>>a;
    sort(all(a));
    ll ans=LINF;
    rep(c,300){
        ll p=c-150,val=0;
        rep(i,n){
            val += abs(p-a[i])*abs(p-a[i]);
        }
        chmin(ans,val);
    }
    puta(ans);
    return 0;
}

Measured memory_bytes: 256
require("fs").readFileSync("/dev/stdin",'utf8').trim().split(/\s/).map(function(i){j=i.split(',');for(s=0,m=n=10;m--;)j[m]=s-=j[m];for(a=-j[11],s*=a/(a-j[n]);j[--n]>=s;);console.log(++n);})

Measured memory_bytes: 7644
#include <stdio.h>
#define N 100000

int A[N];

int partition(int A[], int p, int r){
  int i, j, x, temp1, temp2;

  x = A[r];
  i = p-1;
  for(j=p; j<r; j++){
    if(A[j]<=x){
      i = i+1;
      temp1 = A[i];
      A[i] = A[j];
      A[j] = temp1;
    }
  }
  temp2 = A[i+1];
  A[i+1] = A[r];
  A[r] = temp2;
  return i+1;
}

int main(){

  int i, n, x, ans;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }

  x = A[n-1];
  ans = partition(A, 0, n-1);

  for(i=0; i<n; i++){
    if(i == ans) printf("[");
    printf("%d", A[i]);
    if(i == ans) printf("]");
    if(i<n-1) printf(" ");
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 992
#include<stdio.h>
int main(void){
    int k;
    char s[101];
    scanf("%d",&k);
    scanf("%s",s);
    int i;
    i=0;
    while(s[i]!='\0'){
        ++i;
    }
    if(i<=k){
        printf("%s\n",s);
    }else{
        for(i=0;i<k;++i){
        printf("%c",s[i]);
        }
        printf("...\n");
    }
    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
string S,ans="WA";
int i,cnt=0,upper=0;
int main(){
  cin>>S;
  int len=S.size();
  if(S[0]=='A'){
    for(i=2;i<len-1;++i){
      if(S[i]=='C'){
        ++cnt;
      }
    }
    if(cnt==1){
      for(i=0;i<len;++i){
        if(isupper(S[i])){
          ++upper;
        }
      }
      if(upper==2){
        ans="AC";
      }
    }
  }
  cout<<ans;
  return 0;
}

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

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

	int64_t ans;
	int64_t minimum = min(a, b);
	for (int64_t i = 1; i <= minimum; i++) {
		if (a % i == 0 && b % i == 0) {
			ans = i;
		}
	}
	ans = a * b / ans;

	cout << ans << endl;
}


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

int main() {
	char s[100001];
	int flag;
	int len;
	int loop;
	int ans = 0;
	scanf("%s", s);
	len = strlen(s);

	if (s[0] == 'B')flag = 0;
	if (s[0] == 'W')flag = 1;
	for (loop = 0; loop < len; loop++) {
		if (s[loop] == 'B'&&flag == 1) {
			ans++; flag = 0;
		}
		else if (s[loop] == 'W'&&flag == 0) {
			ans++; flag = 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = pow(10,9);
const int nil = -1;
set<string> st;
string tmpstr;
int i, n, m, k, ans = 1;

int main() {
    scanf(" %d", &n);
    rep(0,n) {
        cin >> tmpstr;
        st.insert(tmpstr);
    }
    printf("%lu\n", st.size());
}

Measured memory_bytes: 19320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << " "
#define debugln(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define vvdebug(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int N; cin >> N;
	string S; cin >> S;	
	vector<bool> a(10); // a[i]:既にiが出現したか
	vector<vector<bool>> b(10, vector<bool>(10)); // b[i][j]:既にiの後にjが出現したか
	vector<vector<vector<bool>>> c(10, vector<vector<bool>>(10, vector<bool>(10))); // c[i][j][k]:既にiの後にjが出現し，その後にkが出現したか
	for (char ch : S) {
		int x = ch - '0';
		rep(i, 10) rep(j, 10) if (b.at(i).at(j)) c.at(i).at(j).at(x) = true;
		rep(i,10) if (a.at(i)) b.at(i).at(x) = true;
		a.at(x) = true;
	}
	int ans = 0;
	rep(i, 10) rep(j, 10) rep(k, 10) ans += c.at(i).at(j).at(k);
	cout << ans << endl;	
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        xn:[usize;n],
    }
    let mut ans = 0;
    for i in 0..n {
        for j in i+1..n{
            ans += xn[i] * xn[j]
        } 
    }
    println!("{}",ans);
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**6)

def search(values,hp,vp,item):
	if not (0<=hp<len(values)): return
	if not (0<=vp<len(values[hp])): return
	if item!=values[hp][vp]: return
	values[hp][vp]=True
#	for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]:
#		search(values,hp+dh,vp+dv,item)
	search(values,hp-1,vp,item)
	search(values,hp+1,vp,item)
	search(values,hp,vp-1,item)
	search(values,hp,vp+1,item)

def solve(values):
	count,valid_items=0,set(['@','#','*'])
	for i in range(len(values)):
		for j in range(len(values[i])):
			if values[i][j] in valid_items:
				search(values,i,j,values[i][j])
				count+=1
	return count

def main():
	line = input().strip()
	while line!='0 0':
		H,W = list(map(int,line.split(' ')))
		values = list()
		for _ in range(H):
			values.append(list(input().strip()))
		print(solve(values))
		line = input().strip()

if __name__=='__main__':
	main()

Measured memory_bytes: 15644
n=int(input())

a=list(map(int,input().split()))
b=[0]*n
cen=n//2
if n%2:#n%2==1
    for i in range(0,n):
        if i%2==1:
            b[cen+(i+1)//2]=a[i]
        else:
            b[cen-(i+1)//2]=a[i]
else:
    for i in range(0,n):
        if i%2==1:
            b[cen-(i+1)//2]=a[i]
        else:
            b[cen+(i+1)//2]=a[i]
"""
for i in range(n):
    b.append(a[i])
    b.reverse()
"""
for i in range(n):
    print(b[i],end=" ")

Measured memory_bytes: 26180
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<long long, long long>
#define ff first
#define ss second

const int MAXN = 1e7;
ll f[MAXN+1];

void precalcolo(){
    for(int i = 1; i <= MAXN; i++){
        f[i]++;
        for(int j = 2*i; j <= MAXN; j += i) f[j]++;
    }
}

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    precalcolo();
    int N; cin >> N;
    ll ans = 0;
    for(int i = 1; i <= N; i++){
        ans += i * f[i];
    }
    cout << ans;
}

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

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

using namespace std;

#define MAX 10010

int n,m;
vector<string> c;
int sum[MAX][2];

void pre(char v,int dir,int sp,int type) {
  for(int cur=sp;0<=cur&&cur<n;cur+=dir) {
    int prev = cur - dir;
    if( 0 <= prev && prev < n ) sum[cur][type] = sum[prev][type];
    rep(j,m) if( c[j][cur] == v ) ++sum[cur][type];
  }
}

void compute() {
  pre('E',+1,0,0);
  pre('W',-1,n-1,1);
  int L = -1, R = 0;
  int mini = sum[0][1];
  rep(i,n-1) {
    if( mini > sum[i][0] + sum[i+1][1] ) {
      mini = sum[i][0] + sum[i+1][1];
      L = i, R = i + 1;
    }
  }
  if( mini > sum[n-1][0] ) {
    mini = sum[n-1][0];
    L = n-1, R = n;
  }
  cout << L+1 << " " << R+1 << endl;
}

int main() {
  cin >> n >> m;
  c.resize(m);
  rep(i,m) cin >> c[i];
  compute();
  return 0;
}

Measured memory_bytes: 2328
# -*- coding: utf-8 -*-


def main():
    r, g, b, n = map(int, input().split())
    ans = 0

    for i in range(3000 + 1):
        for j in range(3000 + 1):
            diff = n - (r * i + g * j)

            if diff >= 0 and (diff % b == 0):
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73500
#include <iostream>
#include <vector>

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

  int64_t N,M,K;
  std::cin>>N>>M>>K;

  std::vector<int64_t> A(N+1,0);
  for(int64_t i=0;i!=N;i++)
  {
    std::cin>>A[i+1];
    A[i+1]+=A[i];
  }
  
  std::vector<int64_t> B(M+1,0);
  for(int64_t i=0;i!=M;i++)
  {
    std::cin>>B[i+1];
    B[i+1]+=B[i];
  }
  
  int64_t result=0;
  int64_t j=M;
  for(int64_t i=0;i<=N;i++)
  {
    if(A[i]>K)
      break;
      
    for(;j>=0;j--)
    {
      if(B[j]>K)
        continue;
      
      if(A[i]+B[j]<=K)
      {
        result=std::max(result,i+j);
        break;
      }
    }
  }

  std::cout<<result<<std::endl;

  return 0;
}

Measured memory_bytes: 6368
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <limits>

using ld = long double;
using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	/* constant */
	constexpr double epsilon = std::numeric_limits<double>::epsilon();

	/* math */
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	ul inline digit(const ul &num){ return static_cast<ul>(std::log10(num+epsilon))+1; }

	/* algorithm */
	ul gcd(const ul &a,const ul &b) { return (!b) ? a : gcd(b,a%b); } // NOTE: a > b

	/* string */
	inline ul same_char_count(const std::string s,const char &ch){ return std::count(std::cbegin(s),std::cend(s),ch); }
}

// std::cout << std::fixed << std::setprecision(15) << std::endl;

int main(int argc,char *argv[])
{
	std::string abcd;
	std::cin >> abcd;

	constexpr int bit = 3;

	for(int i = 0;i < (1<<bit);++i)
	{
		std::bitset<bit> bs(i);
		std::string ans;
		ans.push_back(abcd[0]);
		int tmp = abcd[0]-'0';
		for(int j = 0;j < bit;++j)
		{
			if(bs.test(j))
			{
				tmp += (abcd[j+1]-'0');
				ans.push_back('+');
			}
			else
			{
				tmp -= (abcd[j+1]-'0');
				ans.push_back('-');
			}
			ans.push_back(abcd[j+1]);
		}
		if(tmp==7){ std::cout << ans << "=" << tmp << std::endl; break; }
	}

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

const int N=510;
const double INF=1e17;
double dp[N][N];

int main(){
  int n,m;
  cin>>n>>m;
  vi a(n);
  rep(i,n)cin>>a[i];
  vector<double>acc(n+1);
  rep(i,n)acc[i+1]=acc[i]+a[i];
  rep(i,N)rep(j,N)dp[i][j]=-INF;
  dp[0][0]=0;
  rep(i,n+1){
    if(i==0)continue;
    rep(j,i+1){
      rep(k,i+1){
	if(j>=1){
	  dp[i][j]=max(dp[i][j],dp[i-k][j-1]+(acc[i]-acc[i-k])/k);
	}
      }
    }
  }
  double ma=-INF;
  rep(i,m+1)ma=max(ma,dp[n][i]);
  printf("%.14f\n",ma);
}



Measured memory_bytes: 5268
#include <bits/stdc++.h> 
using namespace std; 
 
int main() 
{ 

    string s;
    cin>>s;

    long yy=stol(s.substr(0,2));
    long mm=stol(s.substr(2,2));

    bool flg_yymm=false;
    bool flg_mmyy=false;

    if(yy>=00&&yy<=99&&mm>=01&&mm<=12)
        flg_yymm=true;
    if(mm>=00&&mm<=99&&yy>=01&&yy<=12)
        flg_mmyy=true;

    if(flg_yymm&&flg_mmyy)
        cout<<"AMBIGUOUS"<<endl;
    else if(flg_yymm)
        cout<<"YYMM"<<endl;
    else if(flg_mmyy)
        cout<<"MMYY"<<endl;
    else
        cout<<"NA"<<endl;

    return 0; 
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;

ll mod = 1000000000 + 7;
int main(){
    ll N;
    cin >> N;

    ll pow = 1;

    for (ll i = 1; i <= N; ++i) {
        pow = pow*i % mod;
    }

    cout << pow << 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 rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

const Int MOD = 998244353;

int main(){
    Int N, S;
    cin >> N >> S;
    vector<Int> A(N);
    rep(i,N) cin >> A[i];

    vector<vector<Int>> dp(N, vector<Int>(3010,0));

    dp[0][0] = 2;
    dp[0][A[0]] = 1;

    rep1(i,N-1) {
        rep(j,3002) {
            dp[i][j] = (dp[i-1][j] * 2) % MOD;
            if (j >= A[i]) {
                dp[i][j] = (dp[i][j] + dp[i-1][j-A[i]]) % MOD;
            }
        }
    }

    cout << dp[N-1][S] << endl;
}

Measured memory_bytes: 74020
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
   
    int x;
    cin>>x;
    int fx=0;
    int xx=x;
    while(xx>0){
        fx+=xx%10;
        xx/=10;
    }
    if(x%fx==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
return 0;
}


Measured memory_bytes: 256
// B - String Palindrome
#include <bits/stdc++.h>
using namespace std;
string S;

bool ok(int r){// [l=0,r)
	string s = S.substr(0, r);
	string t(s.rbegin(), s.rend());
	return s==t;
}

int main(){
	cin>>S;
	int n = S.size();
	puts(ok(n) && ok((n-1)/2)? "Yes":"No");
}

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

typedef long long ll;

int n, m, s, t, a, b, v[100005][3];
vector<int> g[100005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
        cin >> a >> b, g[a].push_back(b);
    cin >> s >> t;
    queue<pair<int, int>> q;
    q.push({s, 0});
    v[s][0] = 1;

    while (!q.empty())
    {
        auto tr = q.front();
        q.pop();
        if (tr.first == t && tr.second % 3 == 0)
            return cout << tr.second / 3 << endl, 0;
        for (int i : g[tr.first])
            if (!v[i][(tr.second + 1) % 3])
                q.push({i, tr.second + 1}), v[i][(tr.second + 1) % 3] = 1;
    }
    cout << -1 << endl;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

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

    int n, k;
    string s;
    cin >> n >> k >> s;

    string ans = "";
    k--;
    for (int i = 0; i < s.size(); ++i) {
        if (i == k) {
            ans += char(s[i] - 'A' + 'a');
        } else {
            ans += s[i];
        }
    }

    cout << ans << endl;
    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 = sc.nextInt();
        int i;
        long T[] = new long[N];
        long gcd;
        long lcm;
        long a,b,r;
        for(i=0;i<N;i++) T[i] = sc.nextLong();

        for(i=1;i<N;i++){
            a = T[i-1];
            b = T[i];
            while(b!=0){
                r = a%b;
                a = b;
                b = r;
            }
            gcd = a;
            lcm = T[i-1]/a;
            lcm *= T[i];
            T[i] = lcm;
        }
        // 出力                                                                 
        System.out.println(T[N-1]);
    }
}


Measured memory_bytes: 23764
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long A, B;
  scanln(A, B);
  foreach(i; 1..1000+1) {
    if ((i*0.08).to!long == A && (i*0.10).to!long == B) {
      i.writeln;
      return;
    }
  }
  writeln(-1);
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


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

int main() {
  int n,ans=1;
  cin >> n;
  vector<int>a(n);
  for (int i = 0; i < n; i++)
  {
      cin>>a[i];
  }
  
  sort(a.begin(),a.end());
  for (int i = 1; i < n; i++)
  {
      if (a[i-1]<a[i]){
          ans++;
      }
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    long long int a,b,c,d,ans,ansa,ansb,ansc,ansd;
    scanf("%lld",&a);
    scanf("%lld",&b);
    scanf("%lld",&c);
    scanf("%lld",&d);

    ansa=a*c;
    ansb=a*d;
    ansc=b*c;
    ansd=b*d;

    ans=ansa;
    if(ans<ansb){
        ans=ansb;
    }
  	if(ans<ansc){
        ans=ansc;
    }
  	if(ans<ansd){
        ans=ansd;
    }

    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2156
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N, M;
	cin >> N >> M;
	int N2 = (N - 1) / 2;
	vi a(N2), b(N2);
	rep(i, N2) {
		if (i % 2 == 0) {
			a[i] = (N2 + 1) / 2 - (i / 2);
			b[i] = (N2 + 1) / 2 + (i / 2) + 1;
		}
		else {
			a[i] = a[i - 1] + N2;
			b[i] = b[i - 1] + N2 + 1;
		}
	}
	rep(i, M) {
		cout << a[i] << " " << b[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3836
n, m = gets.split.map(&:to_i)
ships = []
m.times { ships << gets.split.map(&:to_i) }
first_ships = ships.select { |i| i[0] == 1 || i[1] == 1 }
second_ships = ships.select { |i| i[0] == n || i[1] == n }
first_ships.each do |first_ship|
  first_ship.delete(1)
end
first_ships.flatten! unless first_ships.empty?
second_ships.each do |second_ship|
  second_ship.delete(n)
end
second_ships.flatten!.sort! unless second_ships.empty?

ans = "IMPOSSIBLE"
first_ships.each do |first_ship|
  if first_ship == second_ships.bsearch { |i| i >= first_ship }
    ans = "POSSIBLE"
    break
  else
    next
  end
end

puts ans


Measured memory_bytes: 19416
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
#define MAX 150000


vector<int> sosuu(MAX,1);
vector<int> pnum;

void ini(){
	sosuu[0] = 0;
	sosuu[1] = 0;
	for(int i=2;i<MAX;i++){
		for(int j=2*i;j<MAX;j+=i){
			sosuu[j] = 0;
		}
	}
	for(int i=2;i<MAX;i++){
		if(sosuu[i]) pnum.push_back(i);
	}
	return;
}

bool solve(){
	int n, p;
	cin>> n>> p;
	if(n==-1 && p==-1) return false;
	
	vector<int> a;
	for(int i=0;i<MAX;i++){
		if(pnum[i] > n){
			for(int j=i;j<i+p;j++) a.push_back( pnum[j] );
			break;
		}
	}
	vector<int> ans;
	for(int i=0;i<a.size();i++){
		for(int j=i;j<a.size();j++){
			ans.push_back( a[i] + a[j] );
		}
	}
	sort(ans.begin(), ans.end());
	cout<< ans[p-1]<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	ini();
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1940
A,B,C=map(int,input().split())
K=int(input())
i=0
while i<K:
    if A>=B:
        i+=1
        B*=2
    else:
        break
while i<K:
    if B>=C:
        i+=1
        C*=2
    else:
        break

print('YNeos'[(A>=B)or(B>=C)::2])

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  vector<vl> c(3, vl(3));
  rep(i, 3) rep(j, 3) cin >> c[i][j];
  vl a(3, 0), b(3, 0);
  rep(j, 3) {
    b[j] = c[0][j];
    c[1][j] -= b[j];
    c[2][j] -= b[j];
  }
  bool ok = true;
  rep2(i, 1, 3) rep(j, 2) if(c[i][j] != c[i][j + 1]) ok = false;
  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N = int(input())
temp_min = sum(map(int, str(1))) + sum(map(int, str(N - 1)))
for A in range (2, N):
    x = sum(map(int, str(A))) + sum(map(int, str(N - A)))
    if x < temp_min:
        temp_min = x
print(temp_min)

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

ll dp1[3030][3030],dp2[3030][3030];

int main(){
    ll n,t;cin>>n>>t;
    ll a[3030],b[3030];
    rep(i,0,n)cin>>a[i]>>b[i];
    
    rep(i,0,n){
        rep(j,0,t+1){
            dp1[i+1][j]=dp1[i][j];
            if(j-a[i]>=0)dp1[i+1][j]=max(dp1[i+1][j],dp1[i][j-a[i]]+b[i]);
        }
    }
    for(int i=n-1;i>=0;i--){
        rep(j,0,t+1){
            dp2[i+1][j]=dp2[i+2][j];
            if(j-a[i]>=0)dp2[i+1][j]=max(dp2[i+1][j],dp2[i+2][j-a[i]]+b[i]);
        }
    }
    /*rep(i,0,n+1){
        rep(j,0,t+1){
            cout<<dp2[i][j]<<" ";
        }
        cout<<endl;
    }*/
    ll an=0;
    rep(i,1,n+1){
        rep(j,0,t){
            an=max(an,dp1[i-1][j]+dp2[i+1][t-1-j]+b[i-1]);
        }
    }
    cout<<an<<endl;
}

    









Measured memory_bytes: 143616
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String W = line.toUpperCase();

        int count = 0;
        while(!((line = sc.nextLine()).equals("END_OF_TEXT"))) {
          String[] l = line.split(" ");
          for(int i = 0; i < l.length; i++) {
            if(W.equals(l[i].toUpperCase())) {
              count++;
            }
          }
        }

        System.out.println(count);

//        String line = sc.nextLine();
//        char[] W = line.toCharArray(); //word
//
//        int count = 0;
//        while(!((line = sc.nextLine()).equals("END_OF_TEXT"))) {
//          char[] T = line.toCharArray();
//
//          for(int i = 0; i < T.length; i++) {
//            if(Character.toUpperCase(T[i]) == Character.toUpperCase(W[0]) && i + W.length - 1 < T.length) {
//              for(int j = 0; j < W.length; j++) {
//                if(Character.toUpperCase(T[i + j]) != Character.toUpperCase(W[j])) {
//                  break;
//                } else if(j == W.length - 1) {
//                  count++;
//                }
//              }
//            }
//          }
//        }
//
//        System.out.println(count);
    }
}

Measured memory_bytes: 26016
import io
import math

nim, delta = list(map(int, input().split()))

xen = [list(map(int,input().split())) for _ in range(nim)]

counter = 0

for i in range(nim):
    for j in range(i + 1, nim):
        pio = 0
        for k in range(delta):
            pio += (xen[i][k] - xen[j][k]) ** 2
        root = pio ** 0.5
        if root.is_integer():
            counter += 1
print(counter)

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

int main() 
{
    int n;
    long long int sum=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            sum+=a[i]*a[j];
        }
    }
    cout<<sum;
    
	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int countDigit(int n)
{
  int digit = 1;
  clock_t start,end;

  start = clock();

  while((n /= 10) != 0)
    digit++;

  end = clock();
  return digit;
  //printf("countDigit()          digit::%d  time::%dms\n",digit,(int)(end - start));
}

int main()
{
  int keta = 0;
      int f = 10000;
  long n; cin >> n;
  reps(i,sqrt(n)+1){
    if(n % i != 0) continue;
    long a = i;
    long b = n /a;
    //cout << a << "," << b << endl;
    keta = countDigit(max(a,b));
    //cout << "大きい方の桁数：" << keta << endl;

    chmin(f,keta);
  }
  cout << f;
    return 0;
}

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

using namespace std;



class Node{
//ノードはポインタでもっておこう
public:
  ///ノードの番号
  int num;
  //そのノードの親
  //rootの場合はnullptr
  Node* p=nullptr;
  //そのノードの子
  //葉でなければ少なくとも一つ持つ
  Node* l=nullptr;Node*r=nullptr;
};



//vpはpreorderな配列
//viはinorderな配列
//次の配列呼ぼうとした時に0または1なら終了
//nは配列の長さ

int vec_find(vector<int> v,int x,int v_begin,int n){
  for(int i=v_begin;i<n+v_begin;i++){
    if(v[i]==x){return i;}
  }
}


//確実にindexを間違えているのはわかる

void reconstruct_tree(vector<int> vp,int vp_begin,vector<int> vi,int vi_begin,vector<Node>& vn,int n){
  int c=vec_find(vi,vp[vp_begin],vi_begin,n);
  //cout << c << endl;
  if(vi_begin<=c<=vi_begin+n-1){
    if(c!=vi_begin){
      //cout << vi[c] << " " << vi[vi_begin] << endl;
      vn[vi[c]-1].l=&vn[vp[vp_begin+1]-1];
      vn[vp[vp_begin+1]-1].p=&vn[vi[c]-1];
      reconstruct_tree(vp,vp_begin+1,vi,vi_begin,vn,c-vi_begin);
    }
    if(c!=vi_begin+n-1){
      //cout << vi[c] << " " << vi[c+1] << endl;
      vn[vi[c]-1].r=&vn[vp[vp_begin+(c-vi_begin+1)]-1];
      vn[vp[vp_begin+(c-vi_begin+1)]-1].p=&vn[vi[c]-1]; reconstruct_tree(vp,vp_begin+(c-vi_begin+1),vi,c+1,vn,n-(c-vi_begin)-1);
    }
  }
}

void pos_calc(Node n,vector<int>& v){
  if(n.l!=nullptr){
    pos_calc(*(n.l),v);
  }
  if(n.r!=nullptr){
    pos_calc(*(n.r),v);
  }
  v.push_back(n.num);
}

Node root_Node(vector<Node> vn){
  int lv=(int)(vn.size());
  for(int i=0;i<lv;i++){
    if(vn[i].p==nullptr){return vn[i];}
  }
}

int main(){
  int n;cin >> n;
  vector<Node>v(n);for(int i=0;i<n;i++){v[i].num=i+1;}
  vector<int>v1(n);for(int i=0;i<n;i++){cin >> v1[i];}
  vector<int>v2(n);for(int i=0;i<n;i++){cin >> v2[i];}
  //どのイテレータの範囲(なんばんめか)の部分木を見るかを考える
  reconstruct_tree(v1,0,v2,0,v,n);
  /*
  for(int i=0;i<n;i++){
    if(v[i].l!=nullptr){cout << i+1 << " " << v[i].l->num <<  " ";}
    if(v[i].r!=nullptr){cout << v[i].r->num << endl;}
  }
  */
  //cout << 0;
  vector<int> pos;
  pos_calc(root_Node(v),pos);
  for(int i=0;i<n;i++){
    if(i!=n-1)cout << pos[i] << " ";
    else cout << pos[i] << endl;
  }

}



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

#define lli long long int



int main() {
	lli n;cin>>n;
	vector<lli> v(n+1);
	vector<lli> mem(n+1,LONG_LONG_MAX);
	int i = 0;
	while(i < n) cin>> v[i++];
	mem[0] = 0;
	for( i=0;i<n;i++){
		if(i+1 < n) mem[i+1] = min(mem[i+1],mem[i] + abs(v[i]-v[i+1]));
		if(i+2 < n) mem[i+2] = min(mem[i+2],mem[i] + abs(v[i]-v[i+2]));
	}
	cout<<mem[n-1]<<'\n';
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

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

int main()
{
    string x;
    cin >> x;
    int s_cnt = 0;
    int len = x.size();
    for (char c : x)
    {
        if (c == 'S')
        {
            ++s_cnt;
        }
        else
        {
            if (s_cnt > 0)
            {
                --s_cnt;
                len -= 2;
            }
        }
    }
    cout << len << endl;
    return 0;
}


Measured memory_bytes: 3728
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        sc.close();

        if(A >= B){
            System.out.println("delicious");
        } else if(B-A <= X){
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
   }
}

Measured memory_bytes: 21844
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		char[][] map=new char[h][w];
		int[][] side=new int[h][w];
		int[][] row=new int[h][w];
		for(int i=0; i<h; i++){
			String s=sc.next();
			for(int j=0; j<w; j++){
				map[i][j]=s.charAt(j);
			}
		}
		for(int i=0; i<h; i++){
			int cou=0;
			for(int j=0; j<w; j++){
				if(map[i][j]=='.'){
					cou++;
					side[i][j]=cou;
				}else{
					cou=0;
				}
			}
			for(int k=w-1; k>=1; k--){
				if(map[i][k]=='#'){
					continue;
				}
				side[i][k-1]=side[i][k];
			}
		}
		for(int i=0; i<w; i++){
			int cou=0;
			for(int j=0; j<h; j++){
				if(map[j][i]=='.'){
					cou++;
					row[j][i]=cou;
				}else{
					cou=0;
				}
			}
			for(int k=h-1; k>=1; k--){
				if(map[k][i]=='#'){
					continue;
				}
				row[k-1][i]=row[k][i];
			}
		}
		long ans=0;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				ans=Math.max(ans,side[i][j]+row[i][j]-1);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 92160
N, K, S = map(int, input().split())

V = [0] * (N + 1)

if K == 0 and S == 1000000000:
    for i in range(N):
        V[i] = 999999999


if K > 0:
    V[1] = S
    K -= 1
else:
    V[1] = S + 1


if S >= 10 ** 9:
    flag = 1
else:
    flag = 0

for i in range(2, N + 1):
    if K > 0:
        V[i] = V[i - 1] + S
        K -= 1
    else:
        if flag:
            V[i] = V[i - 1] + (S - 1)
        else:
            V[i] = V[i - 1] + (S + 1)

ans = [0] * N
for i in range(N):
    ans[i] = V[i + 1] - V[i]

print(*ans)


Measured memory_bytes: 14532
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 99999999999999999
#define MOD 1000000000

void func()
{
    ll n,m;
    cin>>n>>m;
    vector<ll> adj[n+1];
    loop(i,0,m){
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    queue<ll> q;
    bool visited[n+1]={false};
    ll parent[n+1];

    visited[1]=true;//start node
    parent[1]=0;
    q.push(1);
    while(!q.empty())
    {
        ll s=q.front();q.pop();

        for(auto u:adj[s])
        {
            if(visited[u]) continue;
            visited[u]=true;
            parent[u]=s;
            q.push(u);
        }
    }
    cout<<"Yes"<<"\n";
    loop(i,2,n+1){
        cout<<parent[i]<<"\n";
    }
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif

    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 13204
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

vector<int> g[200000];
ll s[200000];
ll ans[200000];

void solve(int v, int p, ll a) {
  a += s[v];
  ans[v] = a;
  FOR(it, g[v]) {
    if (*it == p) continue;
    solve(*it,v,a);
  }
}

int main() {
  int n, Q;
  while(input(n,Q)) {
    REP(i,n-1) {
      int a,b;
      input(a,b);
      a--;b--;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    REP(i,Q) {
      int p,x;
      input(p,x);
      p--;
      s[p] += x;
    }
    solve(0,-1,0);
    REP(i,n) printf("%lld%c",ans[i],i!=n-1?' ':'\n');
  }
}


Measured memory_bytes: 25600
N = int(input())
H = list(map(int,input().split()))

res = 0
cnt = 0
for i in range(N):
    if i == 0:
        continue
    prev = H[i-1]
    if prev >= H[i]:
        cnt += 1
        if i == N-1:
            if cnt > res:
                res = cnt
    else:
        if cnt > res:
            res = cnt
        cnt = 0
print(res)

Measured memory_bytes: 14252
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DColoringDominoes solver = new DColoringDominoes();
        solver.solve(1, in, out);
        out.close();
    }

    static class DColoringDominoes {
        private static final int MOD = (int) 1e9 + 7;

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            String s1 = in.string(), s2 = in.string();
            int m = 0;
            boolean[] v = new boolean[n];
            int i = 0;
            while (i < n) {
                if (s1.charAt(i) == s2.charAt(i)) {
                    i++;
                } else {
                    v[m] = true;
                    i += 2;
                }
                m++;
            }
            long ans = v[0] ? 6 : 3;
            for (i = 1; i < m; i++) {
                if (v[i]) {
                    if (v[i - 1]) {//横横
                        ans *= 3;
                        ans %= MOD;
                    } else {//縦横
                        ans *= 2;
                        ans %= MOD;
                    }
                } else {
                    if (v[i - 1]) {//横縦
                        //pass
                    } else {//縦縦
                        ans *= 2;
                        ans %= MOD;
                    }
                }
            }
            out.println(ans);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int sum=0;
  for(int i=0;i<s.size();i++){
    sum+=s.at(i)-'0';
  }
  if(sum%9==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  
  for (int i=0; i<N; i++) 
    cin >> a.at(i);
  
  int f=0;
  int c=1;
  b.at(0) = 1;
  for (int i=0; i<N; i++) {
    f = a.at(f) - 1;
    if (f == 1)
      break;
    else if (b.at(f) == 0) {
      b.at(f) = 1;
      c += 1;
    }
    else {
      c = -1;
      break;
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3

import sys

def main():
    n, k = [int(x) for x in sys.stdin.readline().split()]
    hs = [int(x) for x in sys.stdin.readline().split()]

    hs.sort(reverse=True)
    print(sum(hs[k:]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 26740
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  vector<vector<int>> c(4,vector<int> (4));
  for(int i=1; i<=3; i++){
    for(int j=1; j<=3; j++){
      cin >> c[i][j];
    }
  }
  bool can = false;
  for(int i=0; i<=c[1][1]; i++){
    for(int j=0; j<=c[1][2]; j++){
      for(int k=0; k<=c[1][3]; k++){
        bool temp=true;
        for(int l=1;l<=3;l++){
          if(c[l][1]-i==c[l][2]-j && c[l][2]-j==c[l][3]-k){
          }else{
            temp = false;
          }
        }
        if(temp){
          can = true;
        }
      }
    }
  }
  if(can){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256