akhauriyash/Code-Regression huggingface dataset:
n=int(input())
l=list(map(int,input().split()))

min=0
ans=True

for i in range(n):
    if l[i]-1>=min:
        min=l[i]-1
    elif l[i]>=min:
        min=l[i]
    else:
        ans=False

        
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14100
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a+b>=c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
   
    
    return 0;
   
}






Measured memory_bytes: 256
import copy
H, W, K = map(int, input().split())

count = 0

res = 0

c = []
for j in range(H):
    s = list(map(str, input()))
    c.append(s)
    count += s.count("#")

m = 0
for i in range(2 ** H):
    t = copy.deepcopy(c)
    count_tmp = copy.deepcopy(count)
    for j in range(H):
        if((i>>j) & 1):
            for a in range(W):
                if t[j][a] == "#":
                    t[j][a] = "@"
                    count_tmp -= 1
    for k in range(2 ** W):
        count_tmp2 = copy.deepcopy(count_tmp)
        t2 = copy.deepcopy(t)
        for l in range(W):
            if((k>>l) & 1):
                for b in range(H):
                    if t2[b][l] == "#":
                        t2[b][l] = "@"
                        count_tmp2 -= 1
        m += 1
        if count_tmp2 == K:
            res += 1

print(res)


Measured memory_bytes: 9356
#include<cstdio> 
#include<cstring> 
#include<cmath> 
#include<iostream> 
using namespace std;
int main()
{
	int n,k,t,b=0;
	cin>>n>>k;
	int a[n+10];
	int i,j;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(j=1;j<n;j++)
		for(i=0;i<n-j;i++)
			if(a[i]<a[i+1])
			{
				t=a[i];
				a[i]=a[i+1];
				a[i+1]=t;	
			}
	for(i=k-1;i>=0;i--)
		b=b+a[i];
	cout<<b;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    vector<int> a(n);
    map<int, int> left, right;
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        if(i + a[i] < n) right[i + a[i]]++;
        if(i - a[i] > 0) left[i - a[i]]++;
    }

    int64_t ans = 0;
    for (auto i = 0; i < n; i++) ans += (int64_t)left[i] * right[i];

    cout << ans << endl;
    return 0;
}

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

cnt = [0] * ((10 ** 6) + 1)

for elem in a:
  cnt[elem] += 1

unique = []
appear = []

for i in range((10 ** 6) + 1):
  if cnt[i] == 1:
    unique.append(i)
  if cnt[i] >= 1:
    appear.append(i)
    
cnt = [0] * ((10 ** 6) + 1)

for elem in appear:
  for m in range(elem * 2, (10 ** 6) + 1, elem):
    cnt[m] = 1
    
ans = 0

for elem in unique:
  if cnt[elem] == 0:
    ans += 1
    
print(ans)

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

using namespace std;

#define INF 210000000
#define int long long

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

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

signed main() {
		int n;
		cin >> n;
		vector<int> a;
		vector<int> s;
		for(int i=0;i<n;i++){
				int tmp;
				cin >> tmp;
				a.push_back(tmp);
				s.push_back(tmp);
		}
		sort(s.begin(),s.end());
		for(auto& A : a){
				if(A < s[n/2]) cout << s[n/2] << endl;
				else cout << s[n/2-1] << endl;
		}

}



Measured memory_bytes: 5476
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 3e5+10, M = 1e6+10;
struct P {
	int h, w;
}a[N];
int h, w, m;
int fx[N], fy[N];
int main() {
	cin>>h>>w>>m;
	int mx1 = 0, mx2 = 0;
	for(int i = 1;i <= m;i++) {
		cin>>a[i].h>>a[i].w;
		fx[a[i].h]++;
		fy[a[i].w]++;
		mx1 = max(mx1, fx[a[i].h]);
		mx2 = max(mx2, fy[a[i].w]);
	}
	int cnt1 = 0, cnt2 = 0, cnt = 0;
	for(int i = 0;i < N;i++) {
		if(fx[i] == mx1) cnt1++;
		if(fy[i] == mx2) cnt2++;
	}
	for(int i = 1;i <= m;i++) {
		if(fx[a[i].h] == mx1&&fy[a[i].w]== mx2) cnt++;
	}
	cout<<mx1 + mx2 - (cnt == ((ll)cnt1 * cnt2));
	return 0;
}

Measured memory_bytes: 8316
#include<iostream>
using namespace std;
int main(){
int r,c;
cin>>r>>c;
r++;
c++;
int a[r][c];


for(int i=0;i<r-1;i++){
 for(int j=0;j<c-1;j++){
  cin>>a[i][j];
 }
}


for(int i=0;i<r-1;i++){
int y=0;
 for(int j=0;j<c-1;j++){
y = y + a[i][j];
 }
a[i][c-1]=y;
}


for(int j=0;j<c;j++){
int t =0;
 for(int i=0;i<r-1;i++){
t = t + a[i][j];
 }
a[r-1][j] = t;
}


for(int i=0;i<r;i++){
 for(int j=0;j<c-1;j++){
  cout<<a[i][j]<<" ";
 }
 cout<<a[i][c-1]<<endl;
}


}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ld long double
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int N = 105;
int n, p;
ld t[N], v[N], s[N], ans, curv;
int main()
{
    IO;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> t[i];
        s[i] = s[i - 1] + t[i];
    }
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    for(ld i = 0.5; i <= s[n]; i += 0.5)
    {
        while(i > s[p])
            p++;
        ld vel = v[p];
        for(int j = 0; j < n + 2; j++)
        {
            if(j < p)
                vel = fminl(vel, v[j] + i - s[j]);
            else if(j > p)
                vel = fminl(vel, v[j] + s[j - 1] - i);
        }
        ans += (vel + curv) / 2;
        curv = vel;
    }
    cout << fixed << setprecision(15) << ans / 2;
}


Measured memory_bytes: 892
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
 
public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    System.out.println(n%2!=0?(double)(n/2+1)/n:"0.5");
  }
}


Measured memory_bytes: 21972
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>

using namespace std;

int gcd(int n, int m) {
    if (n == 0)
        return m;
    return gcd(m % n, n);
}

int bit_count(int i) {
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    i = (i + (i >> 4)) & 0x0f0f0f0f;
    i = i + (i >> 8);
    i = i + (i >> 16);
    return i & 0x3f;
}

int main() {
    string s;
    cin >> s;

    int win = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'o') win++;
    }
    if (8 <= win+15-s.size()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

int main()
{
	int x;
	cin>>x;
	
	int v=0,j=2;
	if(x<4) v=1;
	else{
		for(int i=2;pow(i,2)<=x;i++){
			for(j=2;pow(i,j)<=x;j++){
				if(pow(i,j)>v) v=pow(i,j);
			}
		}
	}
	
	cout<<v<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#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>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)
 
ll n, k;
pair<int, int> ab[100000];
 
int main(int argc, char **argv) {
	cin >> n >> k;
	REP(i, n) cin >> ab[i].first >> ab[i].second;
	sort(ab, ab + n);
	REP(i, n) {
		k -= ab[i].second;
		if (k <= 0) {
			cout << ab[i].first << endl;
			break;
		}
	}
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

ll d[300][300];
ll ans[300][300];

int main() {
  int N, M, L;
  cin >> N >> M >> L;

  rep(i, N) rep(j, N) {
    d[i][j] = INF;
    ans[i][j] = INF;
  }

  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    d[a - 1][b - 1] = d[b - 1][a - 1] = c;

    if (c <= L) {
      ans[a - 1][b - 1] = ans[b - 1][a - 1] = 0;
    }
  }

  rep(k, N) rep(i, N) rep(j, N) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }

  rep(i, N) rep(j, N) if (d[i][j] <= L) ans[i][j] = 0;

  rep(k, N) rep(i, N) rep(j, N) {
    ans[i][j] = min(ans[i][j], ans[i][k] + ans[k][j] + 1);
  }

  int Q;
  cin >> Q;
  rep(i, Q) {
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    if (ans[s][t] == INF)
      cout << "-1" << endl;
    else
      cout << ans[s][t] << endl;
  }
}


Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		System.out.println(n * 800 - (n / 15)*200);
		
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 23252
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]"):

    dp = []
    for _ in range(N):
        l = [0]*3
        dp.append(l)

    dp[0][0], dp[0][1], dp[0][2] = a[0], b[0], c[0]
    for i in range(1, N):
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i]
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i]
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i]
    
    
    print(max(dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, a, b, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 34636
N, K = map(int, input().split())
V = list(map(int, input().split()))
 
ans = 0
for a_plus_b in range(min(N, K) + 1): # a, bの全組み合わせで実施
    for a in range(a_plus_b + 1):
        b = a_plus_b - a
        gems = V[:a] # 左からa番目までを取得
        if b > 0:
            gems += V[-b:] # 右からb番目までを取得
        gems.sort()
        negative_gems = [g for g in gems if g < 0]
        ans = max(ans, sum(gems) - sum(negative_gems[:K - a_plus_b])) # K-(a+b)までネガティブのものを捨てられる 
print(ans)

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

using namespace std;

typedef long long ll;

int main()
{
	int n;
	cin >> n;
	
	vector<int> v(n);
	unordered_map<int, int> mxx;
	for(int i = 0; i < n; i++)
	{
		cin >> v[i];
		mxx[v[i]]++;
	}

	int p = 0;
	sort(v.begin(), v.end());
	vector<int> is(1000001);
	for(int i = 0; i < n; i++)
	{
		if(is[v[i]])
			continue;

		if(mxx[v[i]] == 1)
			p++;
		
		for(int i2 = 1; i2 * v[i] < 1000001; i2++)
		{
			is[i2 * v[i]] = 1;
		}
	}

	cout << p << endl;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
ll lcm(ll x, ll y) { return x/gcd(x, y)*y; }

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

    ll n, m;
    string s, t;
    cin >> n >> m >> s >> t;

    ll g = gcd(n, m);
    ll l = lcm(n, m);
    bool flag = true;
    rep(i, g) {
        if(s[i*n/g] != t[i*m/g]) flag = false;
    }
    cout << (flag ? l : -1) << '\n';
    return 0;
}

Measured memory_bytes: 640
n = gets.chomp.to_i
xn, yn, hn = [], [], []
si = -1
n.times do |i|
    xn[i], yn[i], hn[i] = gets.chomp.split(" ").map(&:to_i)
    si = i if hn[i] > 0
end

(100+1).times do |x|
    (100+1).times do |y|
        h = hn[si] + (x - xn[si]).abs + (y - yn[si]).abs
        flag = true
        n.times do |i|
            flag = false if hn[i] > 0 && h - hn[i] != (x - xn[i]).abs + (y - yn[i]).abs
            flag = false if hn[i] == 0 && h > (x - xn[i]).abs + (y - yn[i]).abs
        end
        if flag
            puts [x, y, h].join(' ')
            exit
        end
    end
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define fr(i,n) for(int i = 0;i<n;++i)
#define fri(i,a,b) for(int i= a;i<=b;++i)
#define fro(i,a,b) for(int i= a;i>=b;--i)
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define fi first
#define se second
#define pb(x) push_back(x)
#define  mp(x,y) make_pair(x,y)
#define endl  "\n"
#define  ii  pair<int,int>
#define  LL  long long
#define  maxm(a,b,c)  max(a,max(b,c))
int q1,q2,a[100010],dp[100010];
int yo(int n,int k)
{	
	for(int i=0;i<100010;++i)
	dp[i]=1e9;
	dp[1]=0;
	fri(i,1,n){
		for(int j=i+1;j<=min(i+k,n);++j)
		{	
			dp[j] = min(dp[j],dp[i]+abs(a[j]-a[i]));
		}
	}
	return dp[n];
}
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<n+1;++i)cin>>a[i];
	cout<<yo(n,k);
}

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

int main()
{
int num[99];
int loop;
cin>>loop;
for(int i = 0;i<loop;i++){
	cin>>num[i];
}
int max = num[0];
int min = num[0];
for(int i=0;i<loop;i++){
	if(num[i]<min){
		min=num[i];
	}
	if(num[i]>max){
		max=num[i];
	}
}
cout<<max-min;

}

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

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, dummy;
cin >> n;
vector <int> t(n);
for (int i = 0; i < n; ++i){
cin >> t[i];
}
int sum = accumulate(t.begin(),t.end(), 0);
cin >> m;
for (int j = 0; j < m; ++j){
int p, x;
cin >> p >> x;
cout << sum - t[p-1] + x << "\n";
}
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;



public class Main{


	public static void main(String[] args){

		Scanner scan=new Scanner(System.in);

		while(true){
		int mid_score=scan.nextInt();
		int final_score=scan.nextInt();
		int re_score=scan.nextInt();

		if(mid_score==-1&&final_score==-1&&re_score==-1){break;}

		System.out.println(grading(mid_score, final_score, re_score));

		}

		scan.close();
	}

	public static char grading(int mid_score, int final_score, int re_score){
		char char_grading='0';
		int total_score=0;
		total_score=(mid_score+final_score);

		if(mid_score==-1||final_score==-1||total_score<30){
			char_grading='F';

		}else if((total_score>=30&&total_score<50) && re_score<50){
			char_grading='D';

		}else if(((total_score>=30&&total_score<50) && re_score>=50) || (total_score>=50&&total_score<65)){
			char_grading='C';
		}else if(total_score>=65&&total_score<80){
			char_grading='B';
		}else if(total_score>=80){
			char_grading='A';
		}




		return char_grading;
	}


}

Measured memory_bytes: 26080
let n = read_int () in
if List.exists (fun x -> x = n mod 10) [2;4;5;7;9] then
  print_endline "hon"
else if List.exists (fun x -> x = n mod 10) [0;1;6;8] then
  print_endline "pon"
else
  print_endline "bon"


Measured memory_bytes: 3596
#include<iostream>

using namespace std;

string s;
int main () {
    cin >> s;
    int l = s.size();
    int cnt = 0;
    for(int i=0; i<l; i++) if(s[i] == '0') cnt++;
    cout << min(cnt,l-cnt) * 2 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int x, a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x >> a >> b;
	x -= a;
	cout << x % b << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
using namespace std;
int main() {
    vector<array<int, 2>> v;
    while (true) {
        int H, W;
        cin >> H >> W;
        if (H < 3 && W < 3) break;
        v.push_back(array<int, 2> { H, W });
    }
    
    for (auto a : v) {
        int H = a[0];
        int W = a[1];
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if (i == 0 || i == H - 1) {
                    cout << "#";
                } else {
                    if (j == 0 || j == W -1) {
                        cout << "#";
                    } else {
                        cout << ".";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}



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

int main()
{
int n,res=0,j=0;
cin>>n;
vector<int> a(n),b(n),c(n-1);
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n;i++)
cin>>b[i];
for(int i=0;i<n-1;i++)
cin>>c[i];
res+=b[a[0]-1];
for(int i=1;i<n;i++)
{
if(a[i-1]+1==a[i])
res+=b[a[i]-1]+c[a[i-1]-1];
else
res+=b[a[i]-1];
}
cout<<res<<endl;
return 0;
}


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

int main(){
    int a, b;
    const int c = 50;
    cin >> a >> b;

    int count = 0;
    for(int i = 0; i < c; i++){
        count++;
        if((a - 1) * i + a >= b){
            break;
        }
    }

   if(b == 1){
     cout << 0 << endl;
   }else{
     cout << count << endl;
   }

}

Measured memory_bytes: 256
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto s = sort!"a < b"(readln.chomp.to!dstring.dup).array;
    auto t = sort!"a > b"(readln.chomp.to!dstring.dup).array;
    writeln(s < t ? "Yes" : "No");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    double T, A;
    cin >> N >> T >> A;
    int ans;
    double g = 1000;
    for (int i = 1; i <= N; i++) {
        double H;
        cin >> H;
        double k = abs((T - H * 0.006) - A);
        if (g > k) {
            g = k;
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  long int H,W;
  
  scanf("%ld %ld",&H,&W);
  
  if(H == 1 || W == 1) printf("1\n");
  else if(H*W % 2 == 1) printf("%ld\n",H*W/2+1);
  else printf("%ld\n",H*W/2);
  
  return 0;
  
}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<iomanip>
#define pi 3.141592653589
using namespace std;
int main()
{
  double a, b, h, m, x;
  cin >> a >> b >> h >> m;
  
 h= (h*5)+(m/12); 
 if(m==0)
  {
  	if(h<=6)
  	m=0;
  	else
  	m=60;
 } 
x=fabs(h-m)*6.0*(pi/180);
cout << fixed;
cout << setprecision(20);
  cout << pow(((pow(a,2)+pow(b,2))-(2*a*b*cos(x))),0.5) << endl;
  return 0;
} 
	



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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int n;
    cin>>n;
    int d=n%10;
    if(d==5||d==2||d==4||d==7||d==9)
        cout<<"hon"<<endl;
    if(d==0||d==1||d==6||d==8)
        cout<<"pon"<<endl;
    if(d==3)
        cout<<"bon"<<endl;
    return 0;
}


Measured memory_bytes: 3624
import math
from functools import reduce
from collections import deque

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

a,p = get_nums_l()

p += a*3

print(p//2)

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

int main(void) {
  long long int a, b;
  long long int buf[2], temp;

  while (scanf("%lld %lld", &a, &b) != EOF) {
    if (a < b) {
      buf[0] = a;
      buf[1] = b;
    } else {
      buf[0] = b;
      buf[1] = a;
    }

    while ((buf[1] % buf[0]) != 0) { // GCD
      temp = buf[0];
      buf[0] = (buf[1] % buf[0]);
      buf[1] = temp;
    }
    buf[1] = a * b / buf[0]; // LCM

    printf("%lld %lld\n", buf[0], buf[1]);
  }
  
  return 0;
}
 

Measured memory_bytes: 596
N = int(input())

dp = [[0] * 3 for _ in range(N)]

a, b, c = map(int, input().split())
dp[0][0], dp[0][1], dp[0][2] = a, b, c

for i in range(1, N):
    a, b, c = map(int, input().split())
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c
print(max(dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]))

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int A, B; cin >> A >> B;
	string S; cin >> S;

	int a = 0, b = 0;
	bool c = (S[A] == '-');

	REP(i,A){
		if(S[i]>='0' and S[i] <='9') a++;
	}

	FOR(i,A+1,A+1+B){
		if(S[i]>='0' and S[i] <='9') b++;
	}
	
	if(c and A == a and B == b) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;

}


Measured memory_bytes: 3560
#include <iostream>

using namespace std;

int main(){
    long long N, P;
    while(cin >> N >> P){
        long long res = 1;
        for(long long d=2;d*d<=P;d++){
            if(P%d) continue;
            int cnt = 0;
            while(P%d == 0){
                ++cnt;
                P /= d;
            }
            for(int i=0;i<cnt/N;i++) res *= d;
        }
        if(P > 1 && N == 1) res *= P;
        cout << res << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int e;
main()
{
	while(cin>>e,e)
	{
		int x,y,z,m=e;
		for(z=0;z*z*z<=e;z++)
		{
			for(y=0;y*y+z*z*z<=e;y++)
			{
				m=min(m,y+z+e-z*z*z-y*y);
			}
		}
		cout<<m<<endl;
	}
}


Measured memory_bytes: 3004
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_034
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            string s = Read();
            long nowAs = 0;
            long res = 0;
            for(int i = 0; i < s.Length - 1; i++)
            {
                if (s[i] == 'A') nowAs++;
                else if (s[i] == 'B' && s[i + 1] == 'C')
                {
                    res += nowAs;
                    i++;
                }
                else
                {
                    nowAs = 0;
                }
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11616
N = int(input())
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9]
C = [x * y for x in a for y in b ]

if N in C:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String YYMM = sc.nextLine();
        int flag = 0;
        int YY = Integer.parseInt(YYMM.substring(0,2));
        int MM = Integer.parseInt(YYMM.substring(2));

        if(YY > 12 || YY < 1){
            flag = -1;
        }
        
        if(MM > 12 || MM < 1){
            if(flag != -1){
                flag += 1;
            }else{
                flag = 2;
            }
        }

        if(YYMM.equals("0000")){
            flag = 2;
        }

        switch(flag){
            case 0:
                System.out.println("AMBIGUOUS");
                break;
            case 1:
                System.out.println("MMYY");
                break;
            case -1:
                System.out.println("YYMM");
                break;
            case 2:
                System.out.println("NA");
                break;
        }
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;


int main()
{
    ll n,k,x,y=0;
    cin>>n>>k;

    x=(n/k);
    if(k%2==0) y=(n/k)+(n%k>=k/2);
    cout<<x*x*x+y*y*y<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>    // 10????????? cout << setprecision(10) << double;
#include <queue>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (???test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// ??\??????push_back(d)???array[d]???????????????1??????§?????????
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// ??????§????¢??´????°???Greatest Common Divisor???
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// ?????°?????¢??????°???Least Common Multiple???
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y???´???????????????´?????????
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

// vector???¨???
// vec[i][j]?????????????\????????\?????????¨??????vec???????????????????????????????????????.

#define INF 1000000

// ------------------- include, typedef, define END. -------------------


LL solve(int N) {
	LL ans = 0;
	FOR(i, 1, N / 2+1) {
		LL nowSum = 0;
		FOR(j, i, N) {
			nowSum += j;
			if (nowSum == N) {
				ans++;
				break;
			}else if(nowSum>N){
				break;
			}
		}
	}
	return ans;
}

int main() {

	int N;

	while (cin >> N, N) {
		//cin >> N;

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

Measured memory_bytes: 1156
button_size = list(map(int, input().split(" ")))
diff = button_size[0] - button_size[1]
if diff >= 2:
    print(button_size[0]*2 - 1)
    exit()
if diff > -2:
    print(button_size[0] + button_size[1])
    exit()
print(button_size[1]*2 -1)

Measured memory_bytes: 3060
N, L = map(int, input().split())
lin = []
a = []
for i in range(N):
    lin.append(L)
    L += 1
for i in range(len(lin)):
    b = abs(lin[i])
    a.append(b)
if sum(lin) < 0:
    print(sum(lin) + min(a))
else:
    print(sum(lin) - min(a))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll n;
vector<ll>adj[100100];
ll dp[100100];
ll visited[100100];
ll p=1000000007;
ll pa[100100];
ll dfs(ll x,ll par)
{
    pa[x]=par;
    if(visited[x]==1)
    {
        return dp[x];
    }
    visited[x]=1;
    if(adj[x].size()==1 && adj[x][0]==par)
    {
        dp[x]=2;
        return dp[x];
    }
    ll countb=1;
    ll countw=1;
    ll flag=0;
    for(auto j:adj[x])
    {
        if(j==par)
        {
            continue;
        }
        countw=countw*dfs(j,x)%p;
        for(ll k:adj[j])
        {
            if(k!=x)
            {
                countb=countb*dp[k]%p;
            }
        }
    }
    dp[x]=(countb+countw)%p;
    return dp[x];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    ll x,y;
    for(ll i=1;i<n;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    cout<<dfs(1,0);
}

Measured memory_bytes: 14976
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    string str;
    cin>>str;
    long long i,a[str.size()],cnt=0,sum=0;
    for(i=0;i<str.size();i++)
    {
        if(str[i]=='B')
        {
            cnt++;
        }
        a[i]=cnt;
    }
    for(i=0;i<str.size();i++)
    {
        if(str[i]=='W')
        {
            sum=sum+a[i];
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 5284
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat() float64 {
	sc.Scan()
	i, _ := strconv.ParseFloat(sc.Text(), 64)
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	x := -1*nextFloat() + nextFloat()
	minDiff := math.Inf(1)
	var ans int

	for i := 0; i < n; i++ {
		h := nextFloat()
		if diff := math.Abs(x*500 + h*3); diff < minDiff {
			minDiff = diff
			ans = i
		}
	}

	fmt.Println(ans + 1)
}


Measured memory_bytes: 640
using System;

class Program
{

    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        if (n == 1) Console.WriteLine("Hello World");
        else if (n == 2)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            Console.WriteLine(a + b);
        }
    }

}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
 
int main(void){
    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World" << endl;
        return 0;
    }
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 1e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
const int MOD = 998244353;

int n,k; 
int a[maxN];
ll c[maxN];
unordered_map<int,int> mp1;
unordered_map<int,int> mp2;
int main()
{
	//scanf("%d",&n);
	n = 3;
	for(int i=1;i<=3;i++)
	{
		scanf("%d",&a[i]);
	}
	int sum;
	scanf("%d",&sum);
	int ans = 0;
	for(int i=0;i<=3000;i++)
	{
		for(int j=0;j<=3000;j++)
		{
			int tmp = i*a[1]+j*a[2];
			if(sum - tmp <0) continue;
			if((sum - tmp)%a[3] == 0)
				ans ++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int i,n,x,a[109],temp;
	scanf("%d%d",&n,&x);
	a[0]=0;
	for (i=0;i<n;i++)
	{
		scanf("%d",&temp);
		a[i+1]=a[i]+temp;
	}
	int s=0;
	for (i=0;i<=n;i++)
	{
		if (a[i]>x) break;
	}
	printf("%d\n",i);
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    vector<ll> a(7, 0);
    REP(i, 7) cin >> a[i];

    ll res = 0;
    res += a[1];

    ll cand1, cand2;
    if(a[0] > 0 && a[3] > 0 && a[4] > 0){
    	cand1 = 3;
    	cand1 += (a[0]-1)/2*2;
    	cand1 += (a[3]-1)/2*2;
    	cand1 += (a[4]-1)/2*2;
    }else{
    	cand1 = 0;
    }
    cand2 = 0;
    cand2 += (a[0])/2*2;
    cand2 += (a[3])/2*2;
    cand2 += (a[4])/2*2;

    cout << res + max(cand1, cand2) << endl;
    return 0;
}

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

using namespace std ;

const int MAX = 2e5 + 10 ;

string s ;
int n ;

int arr[MAX] ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	long long ans = 0 ;
	for(int i = 1 ; i < n ; ++i)
	{
		ans += max(0 , arr[i-1] - arr[i]) ;
		arr[i] = max(arr[i] , arr[i-1]) ;
	}
	return cout<<ans<<"\n" , 0 ;
}

Measured memory_bytes: 4432
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

int main(){
    int N, Y;
    cin >> N >> Y;

    int ans=0;
    for(int x=0; x<=N; x++){
        for(int y=0; y<=N-x; y++){
            int z = N - x - y;
            if(10000*x + 5000*y + 1000*z ==  Y){
                cout << x <<" " << y << " " << z << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		Dice dice = new Dice(scn.nextInt(), scn.nextInt(), scn.nextInt(), scn.nextInt(), scn.nextInt(), scn.nextInt());
		String a = scn.next();
		char[] b = a.toCharArray();
		for (int i = 0; i < b.length; i++) {
			dice.roll(b[i]);
		}
		System.out.println(dice.getTop());
	}
}

class Dice {
	int[] number = new int[6];

	Dice(int a, int b, int c, int d, int e, int f) {
		number[0] = a;
		number[1] = b;
		number[2] = c;
		number[3] = d;
		number[4] = e;
		number[5] = f;
	}

	public void roll(char cd) {
		int tmp = 0;
		switch (cd) {
		case 'N':
			tmp = number[0];
			number[0] = number[1];
			number[1] = number[5];
			number[5] = number[4];
			number[4] = tmp;
			break;
		case 'S':
			tmp = number[0];
			number[0] = number[4];
			number[4] = number[5];
			number[5] = number[1];
			number[1] = tmp;
			break;
		case 'E':
			tmp = number[0];
			number[0] = number[3];
			number[3] = number[5];
			number[5] = number[2];
			number[2] = tmp;
			break;
		case 'W':
			tmp = number[0];
			number[0] = number[2];
			number[2] = number[5];
			number[5] = number[3];
			number[3] = tmp;
			break;
		}
	}

	public int getTop() {
		return number[0];
	}
}


Measured memory_bytes: 26336
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int a,b,c;
	cin>>a;
	
	int x;
	cin>>x;
	if(a<x){b=x;}
	else {
		b=a;
		a=x;
	}
	
	int y;
	cin>>y;
	if(b<y){c=y;}
	else if(a<y && y<=b){
		c=b;
		b=y;
	}
	else{
		c=b;
		b=a;
		a=y;
	}
	cout<<c-a;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int stlen = s.size();
    for (int i = stlen -3; i > 0; i-= 2){
        if (i < 0) break;
        if (s.substr(0, i/2) == s.substr(i/2+1, i/2)){
            cout << i + 1 << endl;
            break;
        }

    }
}



Measured memory_bytes: 256
#include <stdio.h>


void print_array(int a[], int len);
void insertionSort(int a[], int len);

void insertionSort(int a[], int len) {
    int i, v, j;
    for(i = 1; i < len; i++ ) {
        print_array(a,len);
        v = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
    }
}

void print_array(int a[], int len) {
    int i;
    printf("%d",a[0]);
    for(i = 1; i < len; i++ ) {
        printf(" %d",a[i]);
    }
    puts("");
}

int main(void) {
    int array[1000];
    int v, i, j, tmp, length;
    scanf("%d",&length);
    for(i = 0; i < length; i++ ) {
        scanf("%d",&array[i]);
    }
    insertionSort(array,length);
    print_array(array, length);
    v = array[i];
    j = i;
    return 0;
}

Measured memory_bytes: 616
N = list(input())
a = 0
ans = 0
old = N[0]
for i in range(1, 4):
    if N[i] == old:
        a += 1
    else:
        a = 0
    if ans < a:
      ans = a
    old = N[i]
if ans > 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9056
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	_ = sc.NextInt()
	a := sc.NextIntArray()
	N := len(a)
	if N == 1 {
		fmt.Println(1)
		return
	}
	s := a[0]
	up := true
	changed := true
	count := 1
	for i := 1; i < N; i++ {
		if changed {
			if s < a[i] {
				up = true
				changed = false
			} else if s > a[i] {
				up = false
				changed = false
			}
		} else if s <= a[i] && up || s >= a[i] && !up {
			changed = false
		} else if s <= a[i] {
			changed = true
			count++
		} else if s >= a[i] {
			changed = true
			count++
		}
		s = a[i]
	}
	fmt.Println(count)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 7168
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#define SIZE 505
#define INF 100000000

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll A[SIZE][SIZE];

ll get_value(int x,int y)
{
	if(x==-1||y==-1) return 0;
	return A[x][y];
}
int main()
{
	int H,W,h,w;
	scanf("%d %d %d %d",&H,&W,&h,&w);
	if(H%h==0&&W%w==0)
	{
		puts("No");
	}
	else if(H%h!=0)
	{
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				int x=i-h,y=j-w;
				if(x<=-2) A[i][j]=INF;
				else
				{
					A[i][j]=get_value(x,j)-j-1;
				}
			}
		}
		puts("Yes");
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				if(j!=0) printf(" ");
				ll gt=A[i][j];
				if(i>0) gt-=A[i-1][j];
				if(j>0) gt-=A[i][j-1];
				if(i>0&&j>0) gt+=A[i-1][j-1];
				printf("%lld",gt);
			}puts("");
		}
	}
	else
	{
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				int x=i-h,y=j-w;
				if(y<=-2) A[i][j]=INF;
				else
				{
					A[i][j]=get_value(i,y)-i-1;
				}
			}
		}
		puts("Yes");
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				if(j!=0) printf(" ");
				ll gt=A[i][j];
				if(i>0) gt-=A[i-1][j];
				if(j>0) gt-=A[i][j-1];
				if(i>0&&j>0) gt+=A[i-1][j-1];
				printf("%lld",gt);
			}puts("");
		}
	}
	return 0;
}


Measured memory_bytes: 2688
#include<stdio.h>

unsigned short scan_sentence(unsigned char * str, unsigned short length_max);
void count_alphabet(unsigned char * str, unsigned short * num_check, unsigned short length);

int main(){

	unsigned short usW_D_length;
	unsigned char ubW_D_str[1200];
	unsigned short usW_D_num_check[26];
	unsigned short usW_C_i;
	
	for(usW_C_i = 0;usW_C_i < 1200;usW_C_i++){
		ubW_D_str[usW_C_i] = 0;
	}
	for(usW_C_i = 0;usW_C_i < 26;usW_C_i++){
		usW_D_num_check[usW_C_i] = 0;
	}
	
	usW_D_length = scan_sentence(ubW_D_str, 1200);
	
	count_alphabet(ubW_D_str, usW_D_num_check, usW_D_length);
	
	for(usW_C_i = 0;usW_C_i < 26;usW_C_i++){
		printf("%c : %d\n", (usW_C_i + 97), *(usW_D_num_check + usW_C_i));
	}
	
	return 0;
}

/* 関数名：文字列入力 */
/* 概要：文字列を入力する。その長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short scan_sentence(unsigned char * str, unsigned short length_max)
{
	unsigned short count_text = 0;
	unsigned short usW_C_i;

	for(usW_C_i = 0;usW_C_i < length_max;usW_C_i++){
		scanf("%c", str + usW_C_i);
		if(*(str + usW_C_i) == EOF){
			break;
		}
		count_text++;
	}

	return count_text;
}

/* 関数名：アルファベットカウント */
/* 概要：渡された文字列に各アルファベットが何文字含まれるか調べる */
/* 引数：文字列が格納された配列の先頭アドレス、アルファベットの数を記録する配列の先頭アドレス、文字列の長さ */
/* 戻り値：なし */
void count_alphabet(unsigned char * str, unsigned short * num_check, unsigned short length)
{
	unsigned short usW_C_i;
	char alphabet;
	for(usW_C_i = 0;usW_C_i < length;usW_C_i++){
		if(((65 <= *(str + usW_C_i)) && (*(str + usW_C_i) <= 90)) || ((97 <= *(str + usW_C_i)) && (*(str + usW_C_i) <= 122))){
			alphabet = *(str + usW_C_i) & 0x1F;
			*(num_check + (alphabet - 1)) += 1;
		}
	}
}




Measured memory_bytes: 2036
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer nums[] = new Integer[n];
		for(int i=0; i<n; i++) {
			nums[i] = sc.nextInt();
		}

		for(int i=n-1; i>=0; i--) {
			System.out.print(nums[i]);
			if(i!=0) System.out.print(" ");
		}

		System.out.println("");

		sc.close();
	}

}



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

namespace ConsoleApplication51
{
    class Program
    {
        static void Main()
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int d = (a[3] *3600 +  a[4] *60  + a[5]) - (a[0] * 3600 + a[1] * 60 + a[2]);
            int e = (b[3] * 3600 + b[4] * 60 + b[5]) - (b[0] * 3600 + b[1] * 60 + b[2]);
            int f = (c[3] * 3600 + c[4] * 60 + c[5]) - (c[0] * 3600 + c[1] * 60 + c[2]);
            Console.WriteLine("{0} {1} {2}", d / 3600, (d % 3600) / 60, (d % 3600) % 60);
            Console.WriteLine("{0} {1} {2}", e / 3600, (e % 3600) / 60, (e % 3600) % 60);
            Console.WriteLine("{0} {1} {2}", f / 3600, (f % 3600) / 60, (f % 3600) % 60);
        }
    }
}

Measured memory_bytes: 9588
#include<algorithm>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<stack>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
const double PI = acos(-1);  // PI = 3.141593...

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);

    for(int i=0; i<n; ++i) cin >> a[i];
    for(int i=0; i<n; ++i) cin >> b[i];
    for(int i=0; i<n-1; ++i) cin >> c[i];

    int ans = b[a[0]-1];
    for(int i = 1; i < n; ++i) {
        ans += b[a[i]-1];
        if(a[i] == a[i-1] + 1) {
            ans += c[a[i-1]-1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256