akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_069
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            int fourCnt=0;
            int twoCnt=0;
            for (int i = 0; i < n; i++)
            {
                if (array[i] % 4 == 0)
                {
                    fourCnt++;
                }
                else if (array[i] % 2 == 0)
                {
                    twoCnt++;
                }
            }
            if (fourCnt >= n / 2)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                int remain = n - fourCnt * 2;
                if (2 <= remain && remain <= twoCnt)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }

        private static string Read() { return Console.ReadLine(); }
        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: 18400
#include <bits/stdc++.h>
using namespace std;


int main(){
int N;
cin >>N;
vector<int>all(200);
int A=0;
int B=0;
for(int i =0;i<N;i++){
cin>>all.at(i);
}
sort(all.begin(),all.end(),greater<int>());
 for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) { 
            A += all[i];
        }
        else {
            B += all[i];
        }
    }
    cout << A - B << endl;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

# (Q - 正解数)点減る

N,K,Q = map(int,readline().split())
P = [0] * N
for i in range(Q):
  P[int(readline()) - 1] += 1

for p in P:
  if K - (Q - p) > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 9892
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)


int main() {
	int h, w;
	cin >> h >> w;
	string s[h];

	rep(i, h) {
		cin >> s[i];
	}

	vector<vector<int> > vl(h,vector<int> (w, 0));
	vector<vector<int> > hl(h,vector<int> (w, 0));

	rep(y, h) {
		int cur = 0;
		int count = 0;
		rep(x, w) {
			if (s[y][x] == '.') {
				count++;
			} else if (s[y][x] == '#') {
				while(cur < x) {
					hl[y][cur] = count;
					cur++;
				}
				count = 0;
				cur = x + 1;
			}
		}
		while(cur < w) {
			hl[y][cur] = count;
			cur++;			
		}
	}

 
	rep(x, w) {
		int cur = 0;
		int count = 0;
		rep(y, h) {
			if (s[y][x] == '.') {
				count++;
			} else if (s[y][x] == '#') {
				while(cur < y) {
					vl[cur][x] = count;
					cur++;
				}
				count = 0;
				cur = y + 1;
			}
		}
		while(cur < h) {
			vl[cur][x] = count;
			cur++;			
		}
	}

	int ans = 0;

	rep(y, h) {
		rep(x, w) {
			ans = max(ans, hl[y][x] + vl[y][x] - 1);
		}
	}
	cout << ans << endl;



	
	return 0;
}

Measured memory_bytes: 35712
#include <iostream>
#include <set>
#include <vector>
#include <map>
using namespace std;

int a[2][1000];

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[0][i];
    }
    for(int i = 0; i < n; i++){
        cin >> a[1][i];
    }
    // i番目で下に降りる
    int max = 0;
    for(int i = 0; i < n; i++){
        int count = 0;
        int col = 0;
        for(int row = 0; row < n; row++){
            if(row == i){
                count += a[col][row];
                col = 1;
            }
            count += a[col][row];
        }
        if(max < count){
            max = count;
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

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

int main(void) {
    int N;
    int sum = 0;

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

    if((sum - *max_element(L.begin(),L.end())) > (sum/2)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	map<int,int> mp;
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		ans += mp[i-a];
		mp[i+a]++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 20484
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

const LL mod = 998244353;

int a, b, c, d;
LL dp[3005][3005];

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif

  scanf("%d%d%d%d", &a, &b, &c, &d);
  dp[a][b] = 1;
  for (int i = a; i <= c; i++) {
    for (int j = b; j <= d; j++) {
      if (i == a && j == b) continue;
      dp[i][j] = (dp[i - 1][j] * j + dp[i][j - 1] * i) % mod;
      dp[i][j] -= (i-1)*(j-1)*dp[i-1][j-1];
      dp[i][j] = (dp[i][j] % mod + mod) % mod;
    }
  }
  cout << dp[c][d] << endl;


#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 73924
#include <bits/stdc++.h>
using namespace std;
constexpr int dx[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
constexpr int dy[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
int main() {
    int H, W, N;
    map<int,map<int,int>>mp;
    int cnt[10] = {};
    cin >> H >> W >> N;
    long long ans0 = (long long)(H - 2) * (W - 2);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        for (int j = 0; j < 9; j++) mp[a+dy[j]][b+dx[j]]++;
    }
    for (auto &rows : mp) {
        int y = rows.first;
        if (y < 2 || H - 1 < y) continue;
        for (auto &col : rows.second) {
            int x = col.first;
            if (x < 2 || W - 1 < x) continue;
            cnt[col.second]++;
            ans0--;
        }
    }
    cout << ans0 << endl;
    for (int i = 1; i < 10; i++) cout << cnt[i] << endl;
    return (0);
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define lo long long
using namespace std;
int a,b,c;
int main(){
	scanf("%d %d %d",&a,&b,&c);
	int t=a-b;
	c-=t;
	c=max(c,0);
	printf("%d\n",c);
	return 0;
}




Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void solve(){
	int n = read.to!int;
	long[] as;
	foreach(_; 0 .. n) as ~= read.to!long;
	
	long[] sums = [0];
	foreach(a; as) sums ~= sums[$ - 1] + a;
	
	long best = sums[$ - 1];
	int i, k;
	foreach(j; 1 .. n - 1){
		while(sums[i] < sums[j] - sums[i]) i += 1;
		if(sums[i - 1] > sums[j] - sums[i]) i -= 1;
		
		while(sums[k] - sums[j] < sums[n] - sums[k]) k += 1;
		if(sums[k - 1] - sums[j] > sums[n] - sums[k]) k -= 1;
		
		long[] xs = [sums[i], sums[j] - sums[i], sums[k] - sums[j], sums[n] - sums[k]];
		xs.sort();
		
		best = min(best, xs[3] - xs[0]);
	}
	
	best.writeln;
	
}

/*

(0 .. i), (i .. j), (j .. k), (k .. n) という4つに分けると考える

jを固定すると、iは(0 .. i)と(i .. j)の差が最小になるようにとればよい
kは(j .. k)と(k .. n)の差が最小になるようにとればよい

jを変えながら調べていく
このときjを増加させるとiとkも単調増加であることに注意してO(1)

*/


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

namespace _1_7_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int r = int.Parse(str[0]);
            int c = int.Parse(str[1]);
            int[,] bar = new int[r+1,c+1];
            string[] strA = new string[c];
            int sumC = 0;
            int sumR = 0;
            //for (int i = 0; i < r; i++)
            //{
            //    bar[i] = new int[c+1];
            //}
            //r行c列のAベクトルを読み込む
            for (int i = 0; i < r; i++)
            {
                strA = Console.ReadLine().Split(' ');
                for (int j = 0; j < c; j++)
                {
                    bar[i,j] = int.Parse(strA[j]);
                }
            }

            for (int i = 0; i < r; i++)
            {
                for (int j = 0; j < c; j++)
                {
                    sumC = sumC + bar[i,j];
                }
                bar[i,c] = sumC;
                sumC = 0;
            }
            for ( int j = 0; j < c+1; j++)
            {
                for (int i = 0; i < r+1; i ++)
                {
                    sumR = sumR + bar[i,j];
                }
                bar[r,j] = sumR;
                sumR = 0;
            }


            for (int i = 0; i < r + 1; i++)
            {
                for (int j = 0; j < c ; j++)
                {
                    Console.Write("{0} ",bar[i,j]);
                }
                Console.WriteLine(bar[i,c]);
            }
        }
    }
}



Measured memory_bytes: 17964
#include<cstdio>
#include<iostream>
const long long Maxn=1000000+10;
long long a[Maxn],cnt[Maxn][2];
long long n,ans;
inline long long read()
{
	long long s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
int main()
{
	n=read();
	for(long long i=1;i<=n;++i)
	{
		a[i]=read();
		if(i-a[i]>=0)++cnt[i-a[i]][1];
		if(i+a[i]<=n)++cnt[i+a[i]][0];
	}
	for(long long i=1;i<=n;++i)
	{
		if(i-a[i]>=0)ans+=cnt[i-a[i]][0];
		if(i+a[i]<=n)ans+=cnt[i+a[i]][1];
	}
	printf("%lld\n",ans>>1);
	return 0;
}

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

four_count = 0
even_count = 0

for i in a:
    if i % 4 == 0:
        four_count += 1
    elif i % 2 == 0:
        even_count += 1

if four_count >= n // 2:
    print('Yes')
elif n - four_count*2 <= even_count:
    print('Yes')
else:
    print('No')

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int cnt[10] = {};
    cnt[a]++, cnt[b]++, cnt[c]++;
    int two = 0, one = 0;
    for(int i = 0; i < 10; i++){
        if(cnt[i]==2)   two++;
        else if(cnt[i]==1)  one++;
    }
    cout << (two==1&&one==1 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
	w = input()
	uniq = []
	cnt = []
	for i in w:
		if i not in uniq:
			uniq.append(i)
	for i in uniq:
		cnt.append(w.count(i))
	ans = "Yes"
	for i in cnt:
		if i % 2 != 0:
			ans = "No"
			break
	print(ans)
resolve()

Measured memory_bytes: 38516
#include <iostream>
#include <cstring>

using namespace std;

typedef long long ll;

int n;
ll k;
const ll mod = (ll)1e9 + 7;

struct matrix{
	ll a[55][55];
	ll *operator [](int x){
		return a[x];
	}
	void setval(ll val){
		memset(a, 0, sizeof(a));
		for(int i = 0 ; i < n ; ++i){
			a[i][i] = val;
		}
	}
};

matrix operator *(matrix x, matrix y){
	matrix ret;
	ret.setval(0);
	for(int i = 0 ; i < n ; ++i){
		for(int j = 0 ; j < n ; ++j){
			for(int v = 0 ; v < n ; ++v){
				ret[i][j] = (ret[i][j] + (x[i][v] * y[v][j]) % mod) % mod;
			}
		}
	}
	return ret;
}

matrix operator ^(matrix x, ll y){
	matrix ret;
	ret.setval(1);
	while(y){
		if(y & 1){
			ret = ret * x;
		}
		x = x * x;
		y >>= 1;
	}
	return ret;
}

matrix a;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
for(int i = 0 ; i < n ; ++i){
	for(int j = 0 ; j < n ; ++j){
		cin >> a[i][j];
	}
}
a = a ^ k;
ll sol = 0;
for(int i = 0 ; i < n ; ++i){
	for(int j = 0 ; j < n ; ++j){
		sol = (sol + a[i][j]) % mod;
	}
}
cout << sol << endl;

return 0;
}



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


int main(){

 int X,Y,a,b;
  cin >> X >> Y;
  a=(Y-2*X)/2;
  b=X-a;
  
  
  if(a>=0 && b>=0 && Y%2==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}

Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] h = new int[N + 1];
		h[0] = 0;
		
		for(int i = 1; i <= N; i++) {
			h[i] = sc.nextInt();
		}
		
		Arrays.sort(h);
		
		int hmax = 0;
		int hmin = 0;
		double min = Math.pow(10, 10);
		
		for(int i = 1; i <= (N - K + 1); i++) {
			min = Math.min(h[i + K - 1] - h[i], min);
		}
		
		System.out.println((int)min);
		
	}
}


Measured memory_bytes: 50400
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [A, B] = string_to_int(inputs[0])
    S = inputs[1]
    code = S.split('-')
    if len(code) != 2 or len(code[0]) != A or len(code[1]) != B:
        return 'No'
    return 'Yes'


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)


Measured memory_bytes: 3812
sx,sy,tx,ty = map(int,input().split(" "))
dx = ['R','L']
dy = ['U','D']

ans = dx[0] * (tx-sx) + dy[0] * (ty - sy)
ans += dx[1] * (tx-sx) + dy[1] * (ty - sy)
ans += (dy[1] + dx[0] * (tx-sx+1) + dy[0] * (ty - sy + 1) + dx[1])
ans += (dy[0] + dx[1] * (tx-sx+1) + dy[1] * (ty - sy + 1) + dx[0])

print(ans)

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

int main() {
    string s;
    cin >> s;
    string s1 = "";
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A') {
            s1 += 'A';
        } else if (s[i] == 'B' && s[i + 1] == 'C') {
            s1 += 'K';
            i++;
        } else {
            s1 += 'N';
        }
    }
    ll ans = 0, ca = 0;
    for (int i = 0; i < s1.size(); i++) {
        if (s1[i] == 'A') {
            ca++;
        } else if (s1[i] == 'K') {
            ans += ca;
        } else if (s1[i] == 'N') {
            ca = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;} cout << endl;
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

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

    int n;
    cin >> n;
    vi a(1 << n);
    rep(i, 1 << n) cin >> a[i];

    while (a.size() > 1) {
        vi b;
        for (int i = 0; i < a.size(); i += 2) {
            if (a[i] == a[i + 1]) {
                b.emplace_back(a[i]);
            } else {
                b.emplace_back(abs(a[i] - a[i + 1]));
            }
        }
        a = b;
    }

    cout << a[0] << endl;
}


Measured memory_bytes: 3448
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    string s;
    fi>>s;
    int n = s.length();
    int N = 1 << (n - 1);
    ll ans = 0;
    for (int mask = 0;mask < N;++mask)
    {
        ll cnt = 0;
        for (int i = 0;i < n;++i)
        {
            cnt = cnt * 10 + s[i] - '0';
            if ((mask >> i) & 1)
                ans += cnt,cnt = 0;
        }
        ans += cnt;
        cnt = 0;
    }
    fo << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
using Int = long long;
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main()
{
    int a, b, c; cin >> a >> b >> c;
    cout << ((b - a == c - b) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;
string st1,st2;
int main(){
	cin>>st1>>st2;
	for(int i=0;i<max(st1.length(),st2.length());i++) {
		if(st1[i]>='a'&&st1[i]<='z') cout<<st1[i];
		if(st2[i]>='a'&&st2[i]<='z') cout<<st2[i];
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e6+9;
const int mod=1e9+7;
using namespace std;
int main()
{
	int k,a,b,cnt=1;
	scanf("%d%d%d",&k,&a,&b);
	while(1)
	{
		int num=cnt*k;
		if(num>=a&&num<=b)
		{
			puts("OK");break;
		}
		if(num>b)
		{
			puts("NG");break;
		}
		cnt++;
	}
}

Measured memory_bytes: 3660
n = int(input())
A = list(map(int, input().split()))
nums = [n - i for i in range(1, n)]
flag = 1
exchange = 0

while flag == 1:
    flag = 0
    for j in nums:
        if A[j] < A[j - 1]:
            A[j], A[j - 1] = A[j - 1], A[j]
            exchange += 1
            flag = 1
        else:
            pass
        
print(*A)
print(exchange)


Measured memory_bytes: 5608
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 500005
#define bug printf("bug\n")
#define ll long long
ll n,arr[M],dp[M];
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&arr[i]);
    dp[2] = abs(arr[2]-arr[1]);
    for(int i=3;i<=n;i++)
    {
        ll r1 = dp[i-1]+abs(arr[i-1]-arr[i]);
        ll r2 = dp[i-2]+abs(arr[i-2]-arr[i]);
        dp[i] = min(r1,r2);
    }
    cout << dp[n] << "\n";
    return 0;
}


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

def get_ans(i):
    ans = i*(N+1) - i**2 +1
    ans = max(0,ans)
    return ans

ans=0
for i in range(K,N+2):
    ans_= get_ans(i)
    ans+=ans_
#     print(ans_,ans)
    
print(ans%(10**9+7))

Measured memory_bytes: 9108
import math

n,d =map(int,input().split())

i=0
cnt=0
while i < n:
  xi,yi=map(int,input().split())
  
  xy=math.sqrt(xi**2+yi**2)
 
  if xy<=d:
    cnt=cnt+1
  
  
  i=i+1  
print(cnt)  



Measured memory_bytes: 9016
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main () {
	int n, k;
	cin >> n >> k;
	double avg[n];
	for(int i = 0; i < n; i++) {
		int pi; 
		cin >> pi;
		double sum = (double)(pi * (pi + 1)) / 2;
		avg[i] = sum / pi;
	}
	double ans = 0;
	double cur = 0;
	int l = 0;
	for(int i = 0; i < k; i++) {
		cur += avg[i];
	}
	ans = cur;
	for(int i = k; i < n; i++) {
		cur += avg[i];
		cur -= avg[l];
		l += 1;
		ans = max(cur, ans);
	}
	printf("%.12f\n", ans);
	return 0;
}

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

int main(void){

    vector<int> input(10,0);
    
    int times;
    cin >> times;

    while(times > 0){

        for(int i = 0;i < 10;i++){
            cin >> input[i];
        }
        vector<int> a(10,0);
        vector<int> b(10,0);
        a[0] = input[0];
        int j = 1,k = 0,flag = 1;
                
        for(int i = 1;i < 10;i++){

            if(a[j-1] < input[i] && b[k] < input[i]){
                a[j++] = input[i];
            }else if(b[k] < input[i]){
                b[k] = input[i];
            }else{
                flag = 0;
                break;
            }
        }

        if(flag){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
        times--;
    }




    return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <cstring>
using namespace std;
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
int w,h,xg,yg,xs,ys,n,fld[101][101];
bool dfs(int x,int y,int c){
	if(c==0||fld[x][y]!=c)return false;
	if(x==xg&&y==yg)return true;
	fld[x][y]=0;
	for(int i=0;i<4;i++)if(dfs(x+dx[i],y+dy[i],c))return true;
	return false;
}
int main(){
	while(cin>>w>>h,w,h){
		cin>>xs>>ys>>xg>>yg>>n;
		for(int i=0;i<n;i++){
			int x,y,cc,d,r,l;
			cin>>cc>>d>>x>>y;
			if(d){r=4;l=2;}else{r=2;l=4;}
			for(int j=x;j<x+l;j++)for(int k=y;k<y+r;k++)fld[j][k]=cc;
		}
		if(dfs(xs,ys,fld[xs][ys]))cout<<"OK"<<endl;
		else cout<<"NG"<<endl;
	}
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    vector<ll> dpl(n), dpr(n);
    dpl[0] = a[0];
    REP(i, n-1) dpl[i+1] = __gcd(dpl[i], a[i]);
    dpr[n-1] = a[n-1];
    REPD(i, n-1) dpr[i] = __gcd(dpr[i+1], a[i+1]);
    ll ans = max(dpl[n-1], dpr[0]);
    for(ll i = 1; i < n-1; i++) ans = max(ans, __gcd(dpl[i], dpr[i]));
    cout << ans;
    return 0;
}

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

int main(){
  int N; cin >> N;
  vector<int> a(N);
  for(auto &it: a)
    cin >> it;

  int now = 1;
  int ans = 0;
  
  for(int i=0; i<N; i++){
    if(a.at(i) == now){
      now++;
    }else{
      ans++;
    }
  }
  if(now == 1){
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
 
ll N;
int main() {
    cin >> N;
    for(int i=1; i<=9; i++) {
        for(int j=1; j<=9; j++) {
            if (N == i*j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
 
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate

n,m,k=map(int, input().split())
a = [0] + list(accumulate(map(int,sys.stdin.readline().rstrip().split())))
b = [0] + list(accumulate(map(int,sys.stdin.readline().rstrip().split())))
ans = 0
j = m

#print(a,b)

for i,item in enumerate(a):
        if k<item:
            break
        while k<item+b[j]:
            j -= 1
        ans = max(ans,i+j)

print(ans)

Measured memory_bytes: 48288
/* ex5_4 "ATCoder"
    dada__      */
#include<stdio.h>
#include<string.h>

int main(void){
    char *ptr, *ptr2, sequence1[11], part_seq[11]="",longest_seq[11]="";
    scanf("%s", sequence1);//文字列の入力
    ptr=sequence1; //ptrに入力文字列の先頭アドレスを代入
    ptr2=part_seq; //ptr2に部分文字列の先頭アドレスを代入

    while(*ptr){
        while(*ptr){
            //文字列に'A','C','G','T'がでるまでptrを移動 
            if(*ptr!='A'&&*ptr!='C'&&*ptr!='G'&&*ptr!='T') ptr++;
            else break;
        }

        while(*ptr){
            //文字列が'A','C','G','T'の間は部分文字列としてコピー
            if(*ptr=='A'||*ptr=='C'||*ptr=='G'||*ptr=='T'){
                *ptr2++ = *ptr++;
            }else{//'A','C','G','T'以外で部分文字列終了
                *ptr2='\0'; break;
            }
        }
        //最長部分文字列の更新
        if(strlen(part_seq)>strlen(longest_seq)) strcpy(longest_seq,part_seq);
        //ptr2を部分文字列の先頭に移動
        ptr2-=strlen(part_seq);
    }
    //最長の部分文字列の長さを出力
    printf("%d\n", strlen(longest_seq));
    return 0;

}

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


typedef long long ll;
typedef unsigned long long ull;
typedef pair<long long, long long> pii;
typedef vector<long long> vll;
typedef vector<int> vi;
#define pb push_back
#define mod  1000009
#define PI 2*acos(0.0)
#define REP(i,a,b) for (i = a; i <= b; i++)
#define f(i,b) for (i = 0; i < b; i++)


bitset<100000001> b;
ll ara[10000000];
vector<pair<ll,ll> > p;
vll v;
map<ll,ll> m;




void SieveOfEratosthenes()
{

	b.set();
	ll n=sqrt(1000009);

	for (ll p=2; p*p<=n; p++)
	{
		if (b[p] == 1)
		{
			for (ll i=p*2; i<=n; i += p)
				b[i] = 0;
		}
	}
    ll i=0;
	for (ll p=2; p<=n; p++)
	if (b[p])
		{
		    ara[i]=p;i++;
		}
}




main()
{
    //SieveOfEratosthenes();
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,x,p=-1,i,sum=0;
    cin >> n;
    f(i,n)
    {
        cin >> x;
        if(x>p)
            p=x;
        sum+=p-x;
    }
    cout << sum << endl;

}


Measured memory_bytes: 3604
import std.algorithm, std.array, std.conv, std.range, std.stdio, std.string;
void main()
{
    auto buf = readln.chomp.split.to!(int[]);
    auto a = readln.chomp.split.to!(long[]).sort!((x, y) => x > y);
    solve(buf[0], buf[1], buf[2], buf[3], a).writeln;
}
long solve(S)(in int problems, in long judges, in int votes, in int contest, S scores)
{
    if (possible(scores.length-1, problems, judges, votes, contest, scores))
        return scores.length;
    size_t leftPossible = contest - 1, rightImpossible = scores.length - 1;
    while (leftPossible + 1 < rightImpossible)
    {
        immutable size_t mid = leftPossible + (rightImpossible - leftPossible) / 2;
        if (possible(mid, problems, judges, votes, contest, scores))
            leftPossible = mid;
        else
            rightImpossible = mid;
    }
    return leftPossible + 1;
}

bool possible(S)(in size_t i, in int problems, in long judges, in int votes, in int contest, S scores)
{
    if (scores[i] + judges < scores[contest-1])
        return false;
    long s;
    foreach (j; contest-1..i)
        s += scores[i] + judges - scores[j];
    s += (contest-1) * judges;
    s += (problems-i) * judges;
    bool ret = votes * judges <= s;
    stderr.writefln("p(%d) = %d", i, ret);
    return ret;
}


Measured memory_bytes: 4404
#include <stdio.h>

int main() {
    int date, week, goal;
    int sum;
    int login;
        
    scanf("%d %d %d", &date, &week, &goal);
    
    sum = 0;
    login = 0;
    do {
        login++;
        sum += date;
        if(login % 7 == 0)  sum += week;
    } while(sum < goal);

    printf("%d\n", login);

    return 0;
}


Measured memory_bytes: 2096
// https://atcoder.jp/contests/abc152/tasks/abc152_c

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    string row = "##";
    for (int i = 0; i < w; i++)
    {
        row += "#";
    }
    cout << row << endl;

    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        cout << "#" + s + "#" << endl;
    }

    cout << row << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n;i++)
using namespace std;
int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  int joi; cin>>joi;
  int x=joi*a;
  int y=0;
  if(joi>=c){y+=b;y+=d*(joi-c);}
  else y=b;
  cout<<min(x,y)<<endl;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    int n;
    cin>>n;
    int num=n%100;int check=n/100;
    int count=0;
    for(int i=5;i>=1 && num>0;i--)
    {
        count+=num/i;
        num=num%i;
    }
    if(check<count)
    cout<<0<<endl;
    else
    cout<<1<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3624
import java.util.Scanner;

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

    int A = scanner.nextInt();
    int B = scanner.nextInt();
    if (B == 1) System.out.println(0);
    else System.out.println((B - 2) / (A - 1) + 1);
  }
}


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

struct UnionFind{
    vector<int> par;
    
    UnionFind(int n) : par(n,-1) { }
    void init(int n) { par.assign(n,-1); }
    
    int root(int x){
        if(par[x]<0) return x;
        else return par[x]=root(par[x]);
    }
    
    bool issame(int x,int y){
        return root(x)==root(y);
    }
    
    bool merge(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(par[x]>par[y]) swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }
    
    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    int N,M,ans=0;
    cin>>N>>M;
    int nu[N];
    UnionFind uf(N);
    
    for(int i=0;i<N;i++) cin>>nu[i];
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        uf.merge(a,b);
    }
    for(int i=0;i<N;i++){
        if(uf.issame(i,nu[i]-1)) ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1024
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

import math
#mod = 10**9+7



def main():
  n = int(input())
  while True:
    if math.sqrt(n) == int(math.sqrt(n)):
      print(n)
      exit()
    n -=1
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int N;
int d[MAX];
vector<P> adj[MAX]; //<隣接地点,その地点の最短距離>
void dijkstra(int s){
    priority_queue<P> PQ; //<最短距離*-1,場所>
    int color[MAX];
    for(int i=0;i<N;i++){
        d[i]=INF;
        color[i]=WHITE;
    }
    
    d[s]=0;
    PQ.push(make_pair(0,0));
    color[0]=GRAY;
    
    while(!PQ.empty()){
        P f=PQ.top(); PQ.pop();
        int u=f.second; //次に行く場所の候補
        
        color[u]=BLACK;
        
        if(d[u]<f.first*(-1)) continue; //候補の今の時点の最短距離が、記録されてるのより小さい
        
        for(int j=0;j<adj[u].size();j++){
            int v=adj[u][j].first; //uのj番目の隣接地点のインデックス
            if(color[v]==BLACK) continue; //もう行った
            if(d[v]<=d[u]+adj[u][j].second)continue;//vにはもっと早い行き方がある
            d[v]=d[u]+adj[u][j].second;
            PQ.push(make_pair(d[v]*(-1),v));
            color[v]=GRAY;
        }
        
    }
}


int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    int k,u,v,c;
    
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>v>>c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra(0);
    for(int i=0;i<N;i++)
        cout<<i<<" "<<(d[i]==INF?-1:d[i])<<"\n";
    
    return 0;
}



Measured memory_bytes: 10124
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

const limit = 1000000000
func main() {
  S := NextInt()
  x := S / limit
  y := S % limit
  if y > 0 {
    x += 1
    y = limit - y
  }
  ans := strings.Join([]string{"0 0 1", strconv.Itoa(limit), strconv.Itoa(x), strconv.Itoa(y)}, " ")
  Write(ans)
  Output()
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define LLFOR(i, a, b) for(long long i = (a); i < (b); ++i)
#define LLRFOR(i, a, b) for(long long i = (a); i >= (b); i--)
#define SORT(v, n) sort(v, v+n)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define LLREP(i, n) for(long long i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)
#define LLRREP(i, n) for(long long i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T MAX(T a,T b){if(a>b){return a;}return b;}
template <typename T>
inline T MIN(T a,T b){if(a<b){return a;}return b;}
template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

signed main(void){
	cin.tie(0);
   ios::sync_with_stdio(false);
   
   int n;
   char s[100];
   cin >> n;
   REP(i, n) cin >> s[i];

   bool four = false;
   REP(i, n){
      if(s[i] == 'Y') four = true;
   }

   if(four == true) cout << "Four" << endl;
   else cout << "Three" << endl;

	rtn 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n;
  vector<string>s(n);
  for(int i=0;i<n;i++)cin>>s.at(i);
  cin>>m;
  vector<string>t(m);
  for(int i=0;i<m;i++)cin>>t.at(i);
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  vector<pair<int,string>>a(1);
  a.at(0).first=1;a.at(0).second=s.at(0);
  int c=0;
  if(n>1){
    for(int i=1;i<n;i++){
      if(s.at(i)==a.at(c).second)a.at(c).first++;
      else{
        pair<int,string>p(1,s.at(i));
        a.push_back(p);
        c++;
      }
    }
  }
  int x=c;
  for(int i=0;i<m;i++){
    for(int j=0;j<=x;j++){
      if(t.at(i)==a.at(j).second){
        a.at(j).first--;
        break;
      }
      else if(j==x){
        pair<int,string>p(-1,t.at(i));
        a.push_back(p);
        x++;
        c=x;
      }
    }
  }
  sort(a.begin(),a.end());
  cout<<max(0,a.at(x).first)<<endl;
}

Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()
import fractions
gcd=fractions.gcd
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0
n=I()
s=input()

t=s.replace('ABC','0')
ans=t.count('0')

print(ans)



Measured memory_bytes: 64876
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		String ans = "Yay!";
		
		if (a > 8 || b > 8) {
			ans = ":(";
		}
		System.out.println(ans);
	}
}


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

bool cmp(char a, char b)
{
	return a>b;
}

int main()
{
    string s, t;
    cin >> s;
    cin >> t;
    
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), cmp);
    
    if(s<t)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
      
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	int n;
	int K;
	string N;
	cin >> n >> K >> N;
	if (N[K - 1] == 'A') {
		N[K - 1] = 'a';
	}
	if (N[K - 1] == 'B') {
		N[K - 1] = 'b';
	}
	if (N[K - 1] == 'C') {
		N[K - 1] = 'c';
	}
	cout << N;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "7 2 5", "3" ].solve == "Yes" );
	assert( [ "7 4 2", "3" ].solve == "No" );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto a = 0L;
	auto b = 0L;
	auto c = 0L;
	input.front.formattedRead!"%s %s %s"( a, b, c );
	input.popFront;
	auto k = input.front.to!( long );
	
	auto i = 0L;
	while( b <= a )
	{
		b *= 2;
		i++;
		if( k < i ) return "No";
	}
	while( c <= b )
	{
		c *= 2;
		i++;
		if( k < i ) return "No";
	}
	return "Yes";
}


Measured memory_bytes: 2880
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;
ll par[100010],ran[100010],num[100010];
ll root(ll x) {
	return par[x] == x ? x : par[x] = root(par[x]);
}
bool same(ll x, ll y) {
	return root(x) == root(y);
}
void unite(ll x, ll y) {
	x = root(x);
	y = root(y);
	if (x == y)return;
	if (ran[x] < ran[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (ran[x] == ran[y])ran[x]++;
	}
}
int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	bool f = 0;
	if (abs(a - c) <= d)f = 1;
	if ((abs(a - b) <= d) && (abs(b - c) <= d))f = 1;
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int M,N;
int W[100];

bool C(int x){
    int cnt=0;
    int cur=0;
    while(cur<N){
        int next=cur;
        int sum=0;
        while(next<N&&sum+W[next]<=x)sum+=W[next++];
        cur=next;
        cnt++;
    }
    return cnt<=M;
}

signed main(){
    while(cin>>M>>N,M||N){
        rep(i,N)cin>>W[i];
        int lb=*max_element(W,W+N)-1,ub=1500000;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            if(C(mid))ub=mid;
            else lb=mid;
        }
        cout<<ub<<endl;
    }
    return 0;
}

Measured memory_bytes: 1156
import numpy as np
n,m=map(int,input().split())
a=np.zeros(n)
b=np.zeros(n)
for i in range(n):
    a[i],b[i]=map(int,input().split())
x=np.argsort(a)
ans=0
i=0
while m>0:
    ans+=a[x[i]]*min(b[x[i]],m)
    m-=b[x[i]]
    i+=1
print(int(ans))
    


Measured memory_bytes: 14812
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String var;
		String type;

		while (true) {
			var = sc.next();
			type = sc.next();
			if (type.equals("X")) {
				break;
			}

			int n = 0;
			for (int i = 0; i < var.length(); i++) {
				if (var.charAt(i) == '_') {
					n = 3;
				}
			}
			if (n != 3) {
				if ('A' <= var.charAt(0) && var.charAt(0) <= 'Z') {
					n = 1;
				} else if ('a' <= var.charAt(0) && var.charAt(0) <= 'z') {
					n = 2;
				}
			}

			if (type.equals("U")) {
				if (n == 1) {
				} else if (n == 2) {
					String v = var.substring(0, 1);
					v = v.toUpperCase();
					var = v + var.substring(1);
				} else {
					String v = var.substring(0, 1);
					v = v.toUpperCase();
					var = v + var.substring(1);
					for (int i = 0; i < var.length(); i++) {
						if (var.charAt(i) == '_') {
							v = var.substring(i + 1, i + 2);
							v = v.toUpperCase();
							var = var.substring(0, i) + v + var.substring(i + 2);
							i--;
						}
					}
				}
			} else if (type.equals("L")) {
				if (n == 1) {
					String v = var.substring(0, 1);
					v = v.toLowerCase();
					var = v + var.substring(1);
				} else if (n == 2) {
				} else {
					for (int i = 0; i < var.length(); i++) {
						if (var.charAt(i) == '_') {
							String v = var.substring(i + 1, i + 2);
							v = v.toUpperCase();
							var = var.substring(0, i) + v + var.substring(i + 2);
							i--;
						}
					}
				}
			} else if (type.equals("D")) {
				if (n == 1) {
					String v = var.substring(0, 1);
					v = v.toLowerCase();
					var = v + var.substring(1);
					for (int i = 0; i < var.length(); i++) {
						if ('A' <= var.charAt(i) && var.charAt(i) <= 'Z') {
							v = var.substring(i, i + 1);
							v = v.toLowerCase();
							var = var.substring(0, i) + '_' + v + var.substring(i + 1);
						}
					}
				} else if (n == 2) {
					for (int i = 0; i < var.length(); i++) {
						if ('A' <= var.charAt(i) && var.charAt(i) <= 'Z') {
							String v = var.substring(i, i + 1);
							v = v.toLowerCase();
							var = var.substring(0, i) + '_' + v + var.substring(i + 1);
						}
					}
				} else {
				}
			}
			System.out.println(var);
		}
	}
}

Measured memory_bytes: 17236
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
if n%1000==0:
    ans=0
else:
    ans=(n//1000+1)*1000-n
print(ans)

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

using namespace std;

using int64 = long long;


int N, X[100000];
int dp[1 << 16];
int ok[1 << 16];

int rec(int bit) {
  if(~dp[bit]) return dp[bit];
  int ret = ok[bit];
  for(int i = bit; i > 0; i = (i - 1) & bit) {
    if(i == bit) continue;
    int other = i ^bit;
    ret = min(ret, rec(i) + rec(other));
  }
  return dp[bit] = ret;
}


int main() {
  cin >> N;
  for(int i = 1; i < N; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    X[x] ^= z;
    X[y] ^= z;
  }
  int bit = 0, ret = 0;
  for(int i = 0; i < N; i++) {
    if(X[i] == 0) continue;
    if(bit & (1 << X[i])) ++ret;
    bit ^= 1 << X[i];
  }
  memset(dp, -1, sizeof(dp));
  for(int i = 1; i < (1 << 16); i++) {
    ok[i] = ok[i & (i - 1)] + 1;
  }
  for(int i = 1; i < (1 << 16); i++) {
    int v = 0;
    for(int j = 0; j < 16; j++) {
      if((i >> j) & 1) v ^= j;
    }
    if(v == 0) --ok[i];
  }
  cout << ret + rec(bit) << endl;
}


Measured memory_bytes: 1152