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

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    unordered_map<int, int> counter1;
    unordered_map<int, int> counter2;

    
    for(size_t i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        
        if(i % 2 == 0) {
            if(!counter1[tmp]) {
                counter1[tmp] = 1;
            } else {
                counter1[tmp]++;
            }

        } else {
            if(!counter2[tmp]) {
                counter2[tmp] = 1;
            } else {
                counter2[tmp]++;
            }
        }
    }

    int c1, c2, v1, v2;

    c1 = c2 = -1;

    for(auto it: counter1) {
        if(it.second > c1) {
            c1 = it.second;
            v1 = it.first;
        }
    }

    for(auto it: counter2) {
        if(it.second > c2) {
            c2 = it.second;
            v2 = it.first;
        }
    }

    if(v1 == v2) {
        // find 2nd largest val
        counter1[v1] = -1;
        counter2[v2] = -1;

        int backup = c1;

        c1 = c2 = -1;

        for(auto it: counter1) {
            if(it.second > c1) {
                c1 = it.second;
                v1 = it.first;
            }
        }

        for(auto it: counter2) {
            if(it.second > c2) {
                c2 = it.second;
                v2 = it.first;
            }
        }

        int resolver = max(c1, c2);

        // only one and same val in the sequence
        if(resolver == -1) {
            resolver = 0;
        }

        int ans = (n - resolver - backup);
        cout << ans << "\n";
    } else {
        cout << n - c1 - c2 << "\n";
    }
    

    return 0;
}

Measured memory_bytes: 4376
S = input()

m = int(S[-1])
# print(m)

if m == 2 or m == 4 or m == 5 or m == 7 or m == 9:
    print("hon")
elif m == 0 or m == 1 or m == 6 or m == 8:
    print("pon")
else:
    print("bon")

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

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

    string s;
    cin >> s;

    int t = 0, tb = 0;
    for(int i=0; i<n; ++i) {
        char x = s[i];
        if(x=='c') {
            cout << "No" << endl;
        }
        else if(x=='a'&&t<a+b) {
            cout << "Yes" << endl;
            t++;
        }
        else if(x=='b'&&t<a+b&&tb<b){
            cout << "Yes" << endl;
            t++;
            tb++;
        }
        else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 896
#from numpy import arange as ar
#from numpy import count_nonzero as ct 
N=int(input())
A=list(map(int,input().split()))
L= [i+A[i] for i in range(N)]
R= [i-A[i] for i in range(N)]
L_dict={}
R_dict={}
count = 0
for i in range(N):
  if L[i] in L_dict:
    L_dict[L[i]] += 1
  else:
    L_dict[L[i]]  = 1
  if R[i] in R_dict:
    R_dict[R[i]] += 1
  else:
    R_dict[R[i]]  = 1
for i in L_dict.keys():
  if i in R_dict:
    count += L_dict[i] * R_dict[i]
print(count)
    

Measured memory_bytes: 58308
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; string S; 
	cin >> N >> S; 
	if(N % 2 == 1){
		cout << "No" << endl; return 0; 
	}
	if(S.substr(0, N/2) == S.substr(N/2, N/2)){
		cout << "Yes" << endl; return 0; 
	}
	cout << "No" << endl; return 0; 
}

Measured memory_bytes: 256
def readinput():
    l,r,d=map(int,input().split())
    return l,r,d

def main(l,r,d):
    ql=(l-1)//d
    qr=r//d
    ans=qr-ql
    return ans

if __name__=='__main__':
    l,r,d=readinput()
    ans=main(l,r,d)
    print(ans)


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
ll k;
string s;
int main()
{
    while(cin>>s>>k)
    {
        int sz=s.size();
        ll cnt=0;
        int num;
        for(int i=0;i<sz;i++)
        {
            if(s[i]=='1')
                cnt++;
            else
            {
                num=s[i]-'0';
                break;
            }
        }
        if(k<=cnt)
        {
            printf("1\n");
            continue;
        }
        printf("%d\n",num);

    }
    return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  
  vector<int> vec(n);
  
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += vec.at(i);
  }
  
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(sum % (4 * m) == 0){
      if(vec.at(i) >= sum / (4 * m)){
      ans++;
      }
    }else{
      if(vec.at(i) >= 1 + sum / (4 * m)){
        ans++;
      }
    }
  }
  
  if(ans >= m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int w,h,sx,sy,gx,gy,n;
int f[128][128];

int dx[] = { 0, 1, 0,-1};
int dy[] = { 1, 0,-1, 0};

bool dfs(int x, int y)
{
	if(f[y][x]==0)
	{
		return false;
	}
	if(x==gx && y==gy)
	{
		return true;
	}

	int c = f[y][x];
	f[y][x] = 0;
	for(int i=0; i<4; i++)
	{
		int nx = x+dx[i];
		int ny = y+dy[i];

		if(f[ny][nx]==c)
		{
			if(dfs(nx,ny))
			{
				return true;
			}
		}
	}

	return false;
}

int main()
{
	while(cin >> w >> h, w||h)
	{
		for(int y=0; y<128; y++)
		for(int x=0; x<128; x++)
		{
			f[y][x] = 0;
		}

		cin >> sx >> sy >> gx >> gy >> n;
		for(int i=0; i<n; i++)
		{
			int c,d,xx,yy,px,py;
			cin >> c >> d >> xx >> yy;

			px = (1-d)*2;
			py = (  d)*2;

			for(int y=0; y<2; y++)
			for(int x=0; x<2; x++)
			{
				f[yy   +y][xx   +x] = c;
				f[yy+py+y][xx+px+x] = c;
			}
		}
		
		cout << (dfs(sx,sy)?"OK":"NG") << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

string s;
ll ans;

void dfs(ll i,ll now,ll sum)
{
    if(i == s.size()){
        ans += now + sum;
        return;
    }
    dfs(i+1,0,sum+now*10+(s[i]-'0'));
    if(i+1 == s.size()) return;
    dfs(i+1,now*10+(s[i]-'0'),sum);
}

int main()
{
    cin >> s;
    dfs(0,0,0);
    cout << ans << endl;
    return 0;
}

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

bool dp[101][10010];

int N;
int s[100];

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

	cin >> N;
	for(int i = 0; i < N; i++) {
		cin >> s[i];
	}

	dp[0][0] = 1;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j <= 10000; j++) {
			if(dp[i][j] == 0) continue;
			dp[i + 1][j] = 1;
			dp[i + 1][j + s[i]] = 1;
		}
	}

	int ans = 0;
	for(int j = 0; j <= 10000; j++) {
		if(dp[N][j] && j % 10 != 0) ans = max(ans, j);
	}
	cout << ans << endl;
}

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

#include <iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
	long long n;

	cin >> n;

	long long waru = 1000000007;

	long long ans1,ans2,ans3,ans4,ansx,ansz;
	ans1 = 1;
	ans2 = 1;
	ans3 = 1;
	ans4 = 1;
	//ans = n * (n - 1) % waru;

	for (int i = 0; i < n ; i++) {
		ans1 = (ans1 * 10) % waru;
		ans2 = (ans2 * 9) % waru;
		ans3 = (ans3 * 9) % waru;
		ans4 = (ans4 * 8) % waru;
		ansz = (ans2 + ans3 - ans4);
	}
	//cout << ans1 - ans2 - ans3 + ans4 << endl;
	ansx = ans1;
	ans1 -= ans2;
	ans1 %= waru;
	ans1 += ans4;
	ans1 %= waru;
	ans1 -= ans3;
	ans1%=waru;

	if (ans1 < 0)ans1 += waru;
	//cout << (ansx-ans2-ans3+ans4)%waru << endl;
	cout << ans1 << endl;

	return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9+5;
typedef long long ll;

int main() {
  ll N;
  cin>>N;
  string s;
  cin>>s;
  ll r=0,g=0,b=0;
  for(int i=0;i<N;i++){
    if(s[i]=='R'){
      r++;
    }
    else if(s[i]=='G'){
      g++;
    }
    else{
      b++;
    }
  }
  ll ans=r*g*b;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(s[i]==s[j]){
        continue;
      }
      ll k=2*j-i;
      if(k>=N) continue;
      else if(s[j]!=s[k]&&s[k]!=s[i]){
        ans--;
      }
      
    }
  }
  cout<<ans<<endl;
        
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

const ll MOD = 1000000007;

struct mint {
    ll x;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    mint operator-() const {
        return mint(-x);
    }
    mint &operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t / 2);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

ostream &operator<<(ostream &os, const mint &a) {
    return os << a.x;
}

int main() {
    int N;
    cin >> N;
    mint zero = 0;
    map<pair<ll, ll>, ll> mp;
    rep(i, N) {
        ll A, B;
        cin >> A >> B;
        if (A == 0 && B == 0) {
            zero = zero + 1;
            continue;
        }
        if (A == 0) {
            ++mp[{0, -1}];
            continue;
        } else if (B == 0) {
            ++mp[{1, 0}];
            continue;
        }

        ll g = abs(gcd(A, B));
        if ((A > 0 && B > 0) || (A < 0 && B < 0)) {
            ++mp[{abs(A) / g, abs(B) / g}];
        } else {
            ++mp[{abs(A) / g, -abs(B) / g}];
        }
    }

    mint ans = 1;
    map<pair<ll, ll>, bool> visited;
    for (auto [p, count] : mp) {
        ll A = p.first;
        ll B = p.second;
        if (count == 0 || visited[{A, B}]) {
            continue;
        }
        
        ll VS = ((B>=0)?mp[{B,-A}]:mp[{-B,A}]);
        if (B >= 0) {
            visited[{A, B}] = visited[{B, -A}] = true;
        } else {
            visited[{A, B}] = visited[{-B, A}] = true;
        }

        mint c1 = mint(2).pow(count) - 1;
        mint c2 = mint(2).pow(VS) - 1;
        ans *= (c1 + c2 + 1);
    }
    cout << ans - 1 + zero << endl;
}


Measured memory_bytes: 53456
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using i64 = int64_t;

constexpr int INF = 1 << 25;
constexpr int MOD = 1000000007;

bool solve(vector<int> &A, int i, int m) {
  if (m == 0) return true;
  if (m < 0 || i >= A.size()) return false;
  return solve(A, i+1, m) || solve(A, i+1, m-A[i]);
}

int main() {
  int n, q, m;
  cin >> n;
  vector<int> A(n);
  REP(i, n) cin >> A[i];
  cin >> q;
  REP(i, q) {
    cin >> m;
    cout << (solve(A, 0, m) ? "yes" : "no") << endl;
  }  
}



Measured memory_bytes: 3080
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

# aa
# 1 2 4 5
# 2 3 1 6
# 3 4 2 7
# 4 1 3 8
# 5 8 6 1
# 6 5 7 2
# 7 6 8 3
# 8 7 5 4
#

def main():
    rr = []
    k = [
            [2, 4, 5],
            [3, 1, 6],
            [4, 2, 7],
            [1, 3, 8],
            [8, 6, 1],
            [5, 7, 2],
            [6, 8, 3],
            [7, 5, 4]
        ]
    for i in range(8):
        for j in range(3):
            k[i][j] -= 1
    ptn = []
    for i in range(8):
        for j in range(3):
            t = [-1] * 8
            t[0] = i
            t[1] = k[i][j]
            t[3] = k[i][(j+1)%3]
            for l in range(8):
                if l == i:
                    continue
                if t[1] in k[l] and t[3] in k[l]:
                    t[2] = l
                    break
            for l in range(4):
                kl = k[t[l]]
                for m in range(3):
                    if kl[m] not in t:
                        t[l+4] = kl[m]
                        break
            ptn.append(t)

    def f(a):
        s = set()
        r = 0
        tc = 0
        for t in itertools.permutations(a):
            tc += 1
            if t in s:
                continue
            r += 1
            for p in ptn:
                s.add(tuple(t[p[i]] for i in range(8)))
        return r

    while True:
        a = LS()
        if len(a) == 0:
            break
        rr.append(f(a))

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 16592
import math

def f(n,k,s):
  if s== 10**9:
    return [s if i<k else s-1 for i in range(n)]
  return [s if i<k else s+1 for i in range(n)]
  
    

n,k,s= map(int,input().split())

ans = f(n,k,s)

s= ""

for a in ans:
  s += str(a)+" "
  
print(s)

  



Measured memory_bytes: 10008
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 200005
using namespace std;
typedef long long ll;
struct data{
	int a,b;
}d[maxn];
bool cmp(const data &x,const data &y){
	return x.b-x.a > y.b-y.a;
}
ll ans,sum;
int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&d[i].a,&d[i].b);
		sum += (ll)d[i].a;
	}
	sort(d+1,d+n+1,cmp);
	if(d[1].a==d[1].b){
		puts("0");
		return 0;
	}
	int j;
	ans = 2000000000ll;
	for(j=1;d[j].b>=d[j].a;j++);
	for(;j<=n;j++){
		ans = min(ans,(ll)d[j].b);
	}
	printf("%lld\n",sum - ans);
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dictionary
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var dict = new HashSet<string>();

            for(var i = 0; i < n; i++)
            {
                var cmd = Console.ReadLine().Split(' ');
                if (cmd[0] == "insert")
                    insert(dict, cmd[1]);
                else
                    find(dict, cmd[1]);
            }
        }

        static void insert(HashSet<string> dict, string str)
        {
            dict.Add(str);
        }

        static void find(HashSet<string> dict, string str)
        {
            if (dict.Contains(str))
                Console.WriteLine("yes");
            else
                Console.WriteLine("no");
        }
    }
}



Measured memory_bytes: 50420
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N;
	int minimum = BIG_NUM,sum = 0,tmp;

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);
		sum += tmp;
		sum %= 2;
		minimum = min(minimum,tmp);
	}

	if(N%2 == 1){

		if(sum%2 == 1){

			printf("First\n");

		}else{

			printf("Second\n");
		}
	}else{

		minimum %= 2;
		if(sum%2 == 0 && minimum%2 == 0){

			printf("Second\n");
		}else{

			printf("First\n");
		}
	}

	return 0;
}



Measured memory_bytes: 3144
import math
A,B,H,M = map(int, input().split())
time = H * 60 + M

Asita = time / 720
Bsita = (time % 60) / 60
sita = abs(Asita - Bsita) * 2 * math.pi

if sita > math.pi:
  sita = 2 * math.pi - sita

if sita <= math.pi * 0.5:
  Ans = ( A**2 + B**2 - 2 * A * B * abs(math.cos(sita)))**0.5
else:
  Ans = ( A**2 + B**2 + 2 * A * B * abs(math.cos(math.pi - sita)))**0.5
print(Ans)

Measured memory_bytes: 9520
#include<bits/stdc++.h>
using namespace std;
const int nmax = 2e5+10;
const int INF = 0x3f3f3f3f;
typedef long long ll;
int a[nmax],n;
int main(){
    scanf("%d",&n);
    ll temp = 0;
    for(int i = 1;i<=n;++i){
        scanf("%d",&a[i]); a[i] -= i; temp += a[i];
    }
    sort(a+1,a+1+n);
    if(n % 2 == 0){
        ll mid[3] = {0}; mid[0] = a[n/2], mid[1] = a[n/2 +1], mid[2] = (mid[0] + mid[1]) / 2;
        ll ans[3] = {0,0,0};
        for(int i = 1;i<=n;++i){
            for(int j = 0;j<3;++j){
                ans[j] += abs(a[i] - mid[j]);
            }
        }
        sort(ans,ans+3);
        printf("%lld\n",ans[0]);
    }else{
        ll mid = a[(n+1)/2],ans = 0;
        for(int i = 1;i<=n;++i){
            ans += abs(mid - a[i]);
        }
        printf("%lld\n",ans);
    }
    return 0;
}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int inp[110][2];

ll dp[110][100010];

int main(){


    int n;
    cin>>n;

    int w;
    cin>>w;

    for(int i = 1; i <= n; i++) {
        cin>>inp[i][0]>>inp[i][1];
    }

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= w; j++) {
            if(j >= inp[i][0]) {
                dp[i][j] = max(dp[i][j], dp[i-1][j-inp[i][0]] + inp[i][1]);
            }
            dp[i][j] = max(dp[i][j] , dp[i-1][j]);
        }
    }

    cout<<dp[n][w]<<endl;
    


}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]++;
    }
    ll ans = 0;
    rep(i, k) {
        ans += p[i];
    }
    ll now = ans;
    for(int i = k; i < n; i++) {
        now -= p[i - k];
        now += p[i];
        if(now > ans) ans = now;
    }
    double aout = (double)ans / 2;
    cout << fixed << setprecision(100);
    cout << aout << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 1024
#include<atcoder/all>
using namespace atcoder;

#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    scc_graph G(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        G.add_edge(a, b);
    }
    vector<vector<int>> g = G.scc();
  	cout << g.size() << endl;
    rep(i, g.size()){
        cout << g[i].size();
        rep(j, g[i].size())cout << " " << g[i][j];
        cout << endl;
    }
}


Measured memory_bytes: 40108
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define ABSS(a, b) (a > b ? a - b : b - a)

int main(void) {
	uint32_t N;
	uint32_t A[100];
	uint32_t max = 0;

	scanf("%"PRIu32"\n", &N);
	for (uint32_t idx = 0; idx < N; idx++) {
		scanf(idx != N - 1 ? "%"PRIu32" " : "%"PRIu32, &(A[idx]));
	}

	for (uint32_t i = 0; i < N - 1; i++) {
		for (uint32_t j = i + 1; j < N; j++) {
			const uint32_t diff = ABSS(A[i], A[j]);
			if (diff > max) {
				max = diff;
			}
		}
	}

	printf("%"PRIu32, max);

	return 0;
}


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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
def main():
    s = list(str(input()))
    s.reverse()
    for i in range(len(s)):
        s[i] = int(s[i])
    s += [0]
    m = len(s)

    dp = [[10**7, 10**7] for _ in range(len(s)+5)]
    # dp[i][0]: 繰り下がりなし
    # dp[i][1]: 繰り下がりあり

    dp[0][0] = 0

    for i in range(m):
        for j in range(2):
            nd = s[i]
            if j == 1:
                nd += 1
            if dp[i+1][0] >= dp[i][j]+nd:
                dp[i+1][0] = dp[i][j]+nd
            if dp[i+1][1] >= dp[i][j]+10-nd:
                dp[i+1][1] = dp[i][j]+10-nd
    #print(dp)
    print(dp[m][0])

if __name__ == '__main__':
    main()

Measured memory_bytes: 167804
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
/// age ye mosh dp ro baze dashti dp tedad baz shodeye baste nashode yadet nare !!
/// joooob zadam
const int N=5003;
ll dp[N][N];
ll last[N][N];
ll b[N][N];
ll a[N];
int32_t main(){
    ll n,a1,b1;
    cin >> n >> a1 >> b1 ;
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    for (int i=1;i<=n;i++){
        for (int j=0;j<N;j++){
            if (a[i]<j){
                last[i][j]=i;
            }
            else{
                last[i][j]=last[i-1][j];
            }
            if (a[i]>j){
                b[i][j]=b[i-1][j]+1;
            }
            else{
                b[i][j]=b[i-1][j];
            }
        }
    }
    a[0]=0;
    memset(dp,69,sizeof dp);
    for (int i=0;i<N;i++){
        dp[0][i]=0;
    }
    for (int i=1;i<=n;i++){
        for (int j=0;j<N;j++){
            ll l=last[i][j];
          //  for (int k=i;k>0;k--){
            //    if (a[k]<j){
                 //   l=k;
                   // break;
           //     }
           // }
            if (!l){
                dp[i][j]=0;
                continue;
            }
            dp[i][j]=dp[l-1][j]+b1;
            //ll z=0;
            ll z=b[l][a[l]]-b[l][j-1];
          //  for (int k=1;k<l;k++){
            //    if (a[k]>a[l] && a[k]<j){
                    //z++;
              //  }
          //  }
            dp[i][j]=min(dp[i][j],dp[l-1][a[l]]+z*a1);
            //cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    cout << dp[n][N-1];
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >>c;
    priority_queue<ll> p;
    priority_queue<ll> q;
    priority_queue<ll> r;
    ll tmp;
    int pcnt=0,qcnt=0,rcnt=0;
    rep(i,0,a){cin >> tmp; p.push(tmp);}        
    rep(i,0,b){cin >> tmp; q.push(tmp);}        
    rep(i,0,c){cin >> tmp; r.push(tmp);}
    ll ans = 0;
    rep(i,0,x+y){
        if(pcnt<x && (qcnt==y || p.top()>=q.top()) && p.top()>=r.top()){
            pcnt++;
            ans += p.top();
            p.pop();
        }else if(qcnt<y && q.top()>=r.top()){
            qcnt++;
            ans += q.top();
            q.pop();
        }else{
            if(!r.empty()){
                ans += r.top();
                r.pop();
            }else{
                if(qcnt==y ||(pcnt<x && p.top()>=q.top())){
                    pcnt++;
                    ans += p.top();
                    p.pop();
                }else{
                    qcnt++;
                    ans += q.top();
                    q.pop();
                }
            }
        }
    }
    cout << ans << endl;

}

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

int main() {
  int n,m;
  cin >> n >> m;
  for(int i=0; i<n; i++) {
    if(i) cout << " ";
    if(i<=n/2) cout << 0;
    else cout << m;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1164
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    h = list(map(int, input().rstrip('\n').split()))
    mh = 0
    cnt = 0
    for v in h:
        if v >= mh:
            cnt += 1
        mh = max(mh, v)
    print(cnt)


if __name__ == '__main__':
    slove()


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


    int getsum(string n)
    {
    int sum = 0;
    for (int i=0;i<n.size();i++)
    {
     sum = sum + n[i]-'0';
    }
    return sum;
    }


int main()

{
    string n;
    cin>>n;
    int p=getsum(n);

    
     if(p%9)
    {
        cout<<"No"<<endl;
    }

    else cout<<"Yes"<<endl;




    }


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;
using tTree=__gnu_pbds::tree< ll , __gnu_pbds::null_type, less< ll >, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n;
  cin>>n;
  using pa=pair<ll,ll>;
  vector<pa> vec(n);
  ll lM=LLONG_MIN,rm=LLONG_MAX;
  rep(i,n){
    cin>>vec[i].first>>vec[i].second;
    lM=max(lM,vec[i].first);
    rm=min(rm,vec[i].second);
  }
  sort(begin(vec),end(vec));

  vector<ll> umin(n);
  vector<ll> dmin(n);

  rep(i,n){
    if(i==0) dmin[i]=vec[i].second;
    else dmin[i]=min(dmin[i-1],vec[i].second );
  }
  rep_r(i,n){
    if(i==n-1) umin[i]=vec[i].second;
    else umin[i]=min(umin[i+1],vec[i].second );
  }
  /*
  for(auto x:umin) cout << x << " ";
  cout << endl;
  for(auto x:dmin) cout << x << " ";
  cout << endl;
  */
  ll ans=0;

for(ll i=0;i<n;i++) ans=max(ans, max(rm-lM+1,0LL) + ( vec[i].second-vec[i].first +1) );

for(ll i=0;i<n-1;i++){
  ans = max(ans, max(dmin[i]-vec[i].first+1,0LL)+max( umin[i+1]-vec[n-1].first+1,0LL )  );
 }

  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 3456
#include<cstdio>
using namespace std;
int main(){
    int a,b,d,r;
    double f;
    scanf("%d %d" ,&a ,&b);
    d = a/b;
    r = a%b;
    f = (double)a/(double)b;
    printf("%d %d %.5lf\n" ,d ,r ,f);
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    int Alice=0,Bob=0;
    for(int i=0;i<N;i++){
        if(i%2==0){
            Alice+=vec[i];
        }
        else
        {
            Bob+=vec[i];
        }
    }
    cout << Alice - Bob << endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,Q;
char  S[505050];
set<ll> st[33];
ll i, j, k;
int main(){
    scanf("%lld%s", &N, S);
    fornum(i,0,30){
        st[i].insert(1e9);
    }
    fornum(i,0,N){
        st[S[i] - 'a'].insert(i + 1);
    }


    scanf("%lld", &Q);
    while(Q--){
        ll t, a,b;
        char bb[5];
        scanf("%lld",&t);
        if(t==1){
            scanf("%lld%s", &a, bb);
            st[S[a - 1] - 'a'].erase(a);
            S[a - 1] = bb[0];
            st[bb[0] - 'a'].insert(a);
        }else{
            scanf("%lld%lld", &a, &b);
            ll ans = 0;
            fornum(i,0,30){
                if(*st[i].lower_bound(a)<=b){
                    ++ans;
                }
            }
            printf("%lld\n", ans);
        }

    }
    return 0;
}

Measured memory_bytes: 24320
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 0, INF = 1e9;

/*******************************************************************************
 *
 *
 *
 ******************************************************************************/

int main() {
    int a = read<int>();
    cout << a * a * 3 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long
#define rep(i, a, b) for(ll i = (ll)a; i < (ll)b; i++)
using namespace std;

int main() {
  int x, t;
  cin >> x >> t;
  if(x > t) cout << x -t << "\n";
  else cout << 0 << "\n";
}


Measured memory_bytes: 3608
N, K = map(int, input().split())
h_list=[]
for i in range(N):
  h_list.append(int(input()))

h_list.sort(reverse=True)

#print(h_list)

min = h_list[0] - h_list[N-1]

for i in range(N-K+1):
  diff = h_list[i] - h_list[i+K-1]
  #print(h_list[i],",",h_list[i+K-1])
  if min>diff:
    min = diff
    
print(min)

Measured memory_bytes: 7384
using System;
using System.Collections.Generic;


public class D
{	
	public static void Main()
	{
		string[] args;
		
		args = Console.ReadLine().Split(' ');
		long X = Int64.Parse(args[0]);
		long Y = Int64.Parse(args[1]);
		long Z = Int64.Parse(args[2]);
		long K = Int64.Parse(args[3]);

		long[] A = new long[X];
		args = Console.ReadLine().Split(' ');
		for(int i = 0; i < X; i++)
			A[i] = Int64.Parse(args[i]);
		
		long[] B = new long[Y];
		args = Console.ReadLine().Split(' ');
		for(int i = 0; i < Y; i++)
			B[i] = Int64.Parse(args[i]);
		
		long[] C = new long[Z];
		args = Console.ReadLine().Split(' ');
		for(int i = 0; i < Z; i++)
			C[i] = Int64.Parse(args[i]);
		
		List<long> AB = new List<long>((int)(X * Y));
		for(int i = 0; i < X; i++)
		{
			for(int j = 0; j < Y; j++)
				AB.Add(A[i] + B[j]);	
		}
		AB.Sort();
		AB.Reverse();
		
		List<long> ABC = new List<long>((int)(Math.Min(3000, X * Y) * Z));
		for(int i = 0; i < Math.Min(3000, X * Y); i++)
		{
			for(int j = 0; j < Z; j++)
				ABC.Add(AB[i] + C[j]);			
		}
		ABC.Sort();
		ABC.Reverse();
		
		for(int i = 0; i < K; i++)
			Console.WriteLine(ABC[i]);		
	}	
}





Measured memory_bytes: 42720
<?php
while(true){
    //??\???
    list($manCount) = stdInput();
    if ($manCount == 0){
        exit;
    }
    
    $array = [];
    for ($i=0;$i<$manCount;$i++){
        $array = array_merge($array,stdInput());
    }
    
    //??????????????¨
    sort($array);
    $count=0;
    $answer=0;
    $countArray = [];
    for($i=0;$i<$manCount-1;$i++){
        $count+=$array[$i];
        $answer+=$count;
    }
    
    
    // ??????
    echo $answer,PHP_EOL;
}

// ??¢??°
function stdInput(){
    return explode(" ", trim(fgets(STDIN)));
}

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

int main(void) {
    unsigned int A, B, C, K;
    long sum = 0;
    cin >> A >> B >> C >> K;

    if (K >= A) {
        K = K - A;
        sum += A;
    } else {
        sum += K;
        cout << sum << endl;
        return 0;
    }
    if (K >= B) {
        K = K - B;
    } else {
        cout << sum << endl;
        return 0;
    }
    if (K >= C) {
        sum -= C;
    } else {
        sum -= K;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3560
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const int INF = 2000000000;

    ll N,M;
    ll A[101],B[101],C;
    bool F=false;
    ll ans=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>M>>C;
    REP(i,M)cin>>B[i];
    REP(i,N){
        ll sum=C;
        REP(j,M){
            int a;
            cin>>a;
            sum+=a*B[j];
        }
        if(sum>0)ans++;
    }

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


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

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();
	constexpr double pi = std::acos(-1.0);

	/* 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); }
	ul lcm(const ul &a,const ul &b) { return (a/gcd(a,b))*b; } // a/gcd(a,b)*b <=> (a*b)/gcd(a,b)
	std::vector<bool> eratosthenes(const ul &n)
	{
		std::vector<bool> prime_candidate(n,true);
		prime_candidate[0] = prime_candidate[1] = false;
		for(ul i = 2;i*i < n;++i)
		{
			if(!prime_candidate[i]) continue;
			for(ul j = 2;i*j < n;++j) prime_candidate[i*j] = false;
		}
		return prime_candidate;
	}
	ll rho_method(const ll &n)
	{
		auto f = [&](const ll &xi){ return (xi*xi+1)%n; };
		ll x = 2, y = 2, d = 1;
		while(d == 1)
		{
			x = f(x);
			y = f(f(y));
			d = lamlib::gcd(lamlib::abs(x-y),n);
		}
		return d;
	}
	// 素因数分解(試し割)
	std::vector<ll> prime_factorization_trial(const ll &n)
	{
		ll num = n;
		std::vector<ll> prime;
		for(ll i = 2;i*i <= n;++i)
		{
			while((num%i) == 0)
			{
				prime.emplace_back(i);
				num /= i;
			}
		}
		if(num > 1) prime.emplace_back(num);
		return prime;
	}

	/* 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[])
{
	// constant
	const ll type = 26;

	// input
	ll d;
	std::cin >> d;
	std::vector<ll> c(type,0);
	for(ll i = 0;i < type;++i) std::cin >> c[i];
	std::vector<ll> s(d*type,0);
	for(ll i = 0;i < d;++i) for(ll j = 0;j < type;++j) std::cin >> s[i*type+j];
	std::vector<ll> t(d,0);
	for(ll i = 0;i < d;++i) std::cin >> t[i];

	// output
	std::vector<ll> last(type,0);
	ll satisfaction = 0, score = 0;
	for(ll i = 0;i < d;++i)
	{
		satisfaction += s[i*type+(t[i]-1)];
		
		last[(t[i]-1)] = i+1;
		
		ll decline = 0;
		for(ll j = 0;j < type;++j) decline += c[j]*((i+1)-last[j]);
		satisfaction -= decline;

		std::cout << satisfaction << std::endl;
	}

	std::cerr << "satisfaction: " << satisfaction << std::endl;
	std::cerr << "score: "<< score << std::endl;

	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll ans = 1, found = 0, kam = 1e18;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        ll x;
        cin >> x;
        if(x == 0) return cout << 0, 0;
        if( kam / ans >= x) ans *= x;
        else found = 1;
    }
    if(found) cout  << -1;
    else cout << ans;

    return 0;

}


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

int main() {
  int N,K;
  cin>>N>>K;
  
  vector<int> vec(N);
  for(int i=0;i<N;++i){
    cin>>vec[i];
  }
  
  sort(vec.begin(),vec.end(),greater<int>());
  
  int max=0;
  for(int i=0;i<K;++i){
    max=max+vec[i];
  }
  
  cout<<max<<endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int y=0;
  
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    if(K< 2*x){
      y += 2*(K-x);
    }
    else{
      y += 2*x;
    }
  }
  cout << y << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    for(ll res=a;res<=a*b;res+=a){
        if(res%b==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

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

#define ll long long int

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    ll dp[n+1],arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(arr[1]-arr[2]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n]<<endl;
    return 0;
}


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

int main()
{
    int n, m, sum = 0;
    cin >> n;
    vector<int> t(n);
    for (int i = 0; i < n; i++)
    {
        cin >> t[i];
        sum += t[i];
    }
    cin >> m;
    vector<int> p(m), x(m);
    for (int i = 0; i < m; ++i)
        cin >> p[i] >> x[i];
    for (int i = 0; i < m; ++i)
    {
        int j = p[i] - 1;
        cout << sum - t[j] + x[i] << endl;
    }
}

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

mod = 10**9 + 7
dp = [[0] * W for _ in range(H+1)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        for bit in range(1 << (W-1)):
            ok = True
            for k in range(W-2):
                if bit & (1 << k) and bit & (1 << (k+1)):
                    ok = False
            if not ok:
                continue

            jj = j
            if j > 0 and bit & (1 << (j-1)):
                jj -= 1
            elif j < W - 1 and bit & (1 << j):
                jj += 1
            dp[i+1][jj] += dp[i][j]
            dp[i+1][jj] %= mod


print(dp[H][K-1])


Measured memory_bytes: 9172
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
        int a[] = new int[6];
    for(int i = 0; i < 6; i++){
      a[i] = sc.nextInt();
    }
    int n = sc.nextInt();
    for(int i = 0; i < n; i++){
      int b = sc.nextInt();
      int c = sc.nextInt();
      if((b == a[1] && c == a[2]) || (b == a[2] && c == a[4]) || (b == a[4] && c == a[3]) || (b == a[3] && c == a[1] )){
        System.out.println(a[0]);

      }else if((b == a[2] && c == a[1]) || (b == a[4] && c == a[2]) || (b == a[3] && c == a[4]) || (b == a[1] && c == a[3] )){
        System.out.println(a[5]);

      }else if((b == a[0] && c == a[3]) || (b == a[3] && c == a[5]) || (b == a[5] && c == a[2]) || (b == a[2] && c == a[0] )){
        System.out.println(a[1]);

      }else if((b == a[3] && c == a[0]) || (b == a[5] && c == a[3]) || (b == a[2] && c == a[5]) || (b == a[0] && c == a[2] )){
        System.out.println(a[4]);

      }else if((b == a[0] && c == a[1]) || (b == a[1] && c == a[5]) || (b == a[5] && c == a[4]) || (b == a[4] && c == a[0] )){
        System.out.println(a[2]);

      }else{
        System.out.println(a[3]);
      }
    }
  }
}


Measured memory_bytes: 26116
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




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

  ll N ; cin >> N ;

  ll ans = 0;
  rep(i,N){
    ll l, r;
    cin >> l >> r;
    ans += ((r-l+1));
  }
  cout << ans << endl;
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int r = scanner.nextInt();

        if(n <= 10){
            int i = 100 * (10-n);
            System.out.println(r+i);
        } else {
            System.out.println(r);
        }
    }
}

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

import sys

input = iter(sys.stdin.read().splitlines()).__next__

N, X = map(int, input().split())
L = list(map(int, input().split()))

P = [0]
for d in L:
   P.append(P[-1] + d)

res = len( [1 for x in P if x <= X] )
print(res)

   

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

int main(){
  int n;
  cin >> n;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  sort(an.begin(),an.end());
  int ans = 0;
  vector<bool> ansis(1000001,true);
  for(int i=0; i<n; ++i){
    if(ansis[an[i]]) ++ans;
    else continue;
    for(int j= an[i]; j<=1000000; j += an[i]){
      ansis[j] = false;
    }
    if(i<n-1 && an[i] == an[i+1]) --ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4312
def tax(p,x):
    return p*(100+x) // 100 # 整数除算

def solve(X,Y,S):
    ans = 0
    oldsum = 0
    newsum = 0
    for a in range(1,S):
        for b in range(1,S-a+1): #税抜き価格a,bの総和はS以下である
            oldsum = tax(a,X)+tax(b,X) #税制改定前の税込合計額
            if oldsum == S: # 新税でのtax(a,Y)+tax(b,Y) について検討 
                newsum = tax(a,Y)+tax(b,Y) 
                if newsum > ans:
                    ans =newsum
            if oldsum > S:
                break # b増加ならばsum増加のため
    return ans

while True:
    X,Y,S = map(int, input().split())
    if X == 0:
        break
    print(solve(X,Y,S))


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> st(N+1,0);
    for(int i=1;i<=N;i++){
        int temp;
        cin>>temp;
        st[temp]=i;
    }
    for(int i=1;i<=N;i++){
        cout<<st[i]<<" ";
    }
    return 0;
    
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x7f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
const int mod = 1e9+7;
const int maxn = 1e5+5;
const double EPS = 1e-6;
using namespace std;
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
int v[maxn];
int main()
{
    map<ll,int> mp;
    int n;
    scanf("%d",&n);
    int sum=0;
    rep(i,0,n)
    {
        ll a;
        scanf("%lld",&a);
        if(mp[a]==0)
        {
            mp[a]=1;
            sum++;
        }else
        {
            mp[a]=0;
            sum--;
        }
    }
    printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;

bool operator<(tuple<int, int> &l, tuple<int, int> &r)
{
    if (get<0>(l) == get<0>(r)) return get<1>(l) < get<1>(r);
    else return get<0>(l) < get<0>(r);
}

bool byYX(tuple<int, int> &l, tuple<int, int> &r)
{ 
    if (get<1>(l) == get<1>(r)) return get<0>(l) < get<0>(r);
    else return get<1>(l) < get<1>(r);
}
int main(void)
{
  int n;
  cin >> n;
  vector<tuple<int, int>> vab, vcd;
  REP(i,n){
    int x, y;
    cin >> x >> y;
    vab.push_back(make_tuple(x, y));
  }
  REP(i,n){
    int x, y;
    cin >> x >> y;
    vcd.push_back(make_tuple(x, y));
  }
  sort(vab.begin(), vab.end(), byYX);
  sort(vcd.begin(), vcd.end(), byYX);
  set<tuple<int, int>> q;
  int j = 0;
  int answer = 0;
  REP(i,n){
    while(j<n && byYX(vab[j], vcd[i])){
      q.insert(vab[j]); 
      ++j;
    }
    auto ite = q.upper_bound(vcd[i]);
    if(ite == q.begin()) continue;
    q.erase(--ite);
    ++answer;
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256