akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define maxn 1007
#define ll long long int
using namespace std;

int a[maxn][maxn]={0},ans;
char c;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

inline void writ(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) writ(x/10);
	putchar(x%10+'0');
}
inline void write(int x){writ(x);putchar('\n');}

int main()
{
	int n=read(),m=read();
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j)
			{cin>>c;if (c=='.') a[i][j]=0;else a[i][j]=1;}
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j)
			if (a[i][j]==1)
			{
				ans=1;
				if (a[i-1][j]==1||a[i][j-1]==1||a[i+1][j]==1||a[i][j+1]==1) ans=0;
				if (ans) {puts("No\n");return 0;}
			}
	puts("Yes\n");
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define eps 1e-6
#define INF (1<<20)
#define PI acos(-1.0)
#define MAX 100005
#ifdef LOCAL
//#include<windows.h>
#endif // LOCAL
using namespace std;

int main(int argc,char argv[])
{
    #ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("out.bat","w",stdout);
    #endif // LOCAL
    vector<int> v;
    v.reserve(10);
    for(int i(0);i!=10;++i)
    {
        int x;
        scanf("%d",&x);
        v.push_back(x);
    }
    sort(v.begin(),v.end(),greater<int>());
    printf("%d\n%d\n%d\n",v[0],v[1],v[2]);
    return 0;
}

Measured memory_bytes: 1208
import Control.Monad
main = do
    a <- replicateM 5 readLn
    let s = sum (map ((*10) . ceiling . (/10) . fromIntegral) a)
    let m = maximum $ 0:[10 - (x `mod` 10) | x <- a , x `mod` 10 > 0]
    print $ s - m

Measured memory_bytes: 508
package main

import (
  "fmt"
)

func main() {
  var N, M int
  fmt.Scan(&N, &M)
  S := make([]int, N)
  T := make([]int, M)
  p := 1000000007
  var x int
  for i := 0; i < N; i++ {
    fmt.Scan(&x)
    S[i] = x
  }
  for i := 0; i < M; i++ {
    fmt.Scan(&x)
    T[i] = x
  }
  DP := make([][]int, N + 1)
  for i := 0; i < N + 1; i++ {
    DP[i] = make([]int, M + 1)
  }
  for i := 0; i < N + 1; i++ {
    DP[i][0] = 1
  }
  for j := 0; j < M + 1; j++ {
    DP[0][j] = 1
  }
  for i := 0; i < N; i++ {
    for j := 0; j < M; j++ {
      DP[i + 1][j + 1] = DP[i + 1][j] + DP[i][j + 1] - DP[i][j]
      if S[i] == T[j] {
        DP[i + 1][j + 1] += DP[i][j]
      }
      if DP[i + 1][j + 1] < 0 {
        DP[i + 1][j + 1] += p
      } else {
        DP[i + 1][j + 1] %= p
      }
    }
  }
  fmt.Println(DP[N][M])
}

Measured memory_bytes: 33792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define rep(i, start, end) for(int i = start; i < end; ++i)
using namespace std;
using namespace __gnu_pbds;
void OJ();

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
        tree_order_statistics_node_update>;

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

    int x, y;
    cin >> x >> y;

    for ( int i = 0; i <= x; ++i ){
        int a = i , b = x - i;

        int tot = a * 2 + b * 4;
        if ( tot == y ){
            return cout << "Yes" , 0;
        }
    }
    cout << "No";
    return 0;
}

void OJ(){
#ifndef ONLINE_JUDGE
    freopen( "C:\\Users\\ehab\\Desktop\\Code Forces\\CF\\in.txt" , "r" , stdin  );
    // freopen( "C:\\Users\\ehab\\Desktop\\Code Forces\\CF\\out.txt", "w" , stdout );
#endif // ONLINE_JUDGE
}
/*ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }*/

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

using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int dp[n+1];
    dp[0]=0;
    dp[1]=0;
    for(int i=2;i<=n;i++){
        dp[i] = INT_MAX;
        for(int j=1;j<=k && j<=i;j++)
            dp[i] = min(dp[i],abs(arr[i-1]-arr[i-j-1])+dp[i-j]);
    }
    cout<<dp[n]<<"\n";
}

Measured memory_bytes: 4336
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[13];
void A()
{
	int x;
	a[1]++;
	if(a[a[0]+1]>0)
	a[0]++;
	for(x=1;x<=a[0];x++)
	{
		if(a[x]>9||(a[x]>a[x+1]+1&&x!=a[0]))
		a[x]=0,a[x+1]++;
		else
		break;
	}
	if(a[a[0]+1]>0)
	a[0]++,x=a[0];
	for(int i=x-1;i>=1;i--)
	a[i]=max(a[i+1]-1,0ll);
}
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	A();
	for(int i=a[0];i>=1;i--)
	printf("%lld",a[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stack>
using namespace std;
int main(void){
    long long N;
    cin >> N;
    stack<long long> A,B;
    A.push(N);
    B.push(1);
    long long x;
    double y;
    for(double i = 2; i <= sqrt(N); i++){
        x = N / i;
        y = N / i;
        if (x == y) {
        A.push(x);
        B.push(i);
        //out << x << " " << i << endl;
        }
    }
    cout << A.top() + B.top() - 2 << endl;
}


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

struct query {
    int a, b, c, d;
};

ll check(vector<int> a, int N, vector<query>& R, int M) {
    if (a.size() == N) {
        ll ans = 0;
        for (auto q : R) {
            if (a[q.b] - a[q.a] == q.c) {
                ans += q.d;
            }
        }
        return ans;
    }

    ll ret = 0;
    for (int i = a.back(); i <= M; i++) {
        a.push_back(i);
        ret = max(ret, check(a, N, R, M));
        a.pop_back();
    }
    return ret;
}

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<query> R(Q);
    for (int i = 0; i < Q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;
        b--;
        R[i] = query({a, b, c, d});
    }

    ll ans = 0;
    for (int i = 1; i <= M; i++) {
        ans = max(ans, check({i}, N, R, M));
    }
    cout << ans << endl;
}


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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */


// 入力
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {

    int N;
    cin >> N;

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

    /**
     * 2段階の9通り検討する
     */

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


    for (int i = 1; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                changeMaximum(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) {
        changeMaximum(res, dp[N][j]);
    }
    cout << res << endl;

}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    string s;
    cin >> s;
    ll n = s.size();
    ll firstL = n - 1, firstR = 0;
    REP(i, n){
        if(s[i] == 'L'){
            firstL = i;
            break;
        }
    }
    REP(i, n){
        if(s[i] == 'R') firstR = i;
    }
    vll dist(n);
    dist[0] = firstL;
    REP(i, n){
        if(s[i] == 'L'){
            if(s[i - 1] == 'R') dist[i] = i - 1;
            else dist[i] = dist[i - 1];
        }
    }
    REPR(i, n){
        if(s[i] == 'R'){
            if(s[i + 1] == 'R') dist[i] = dist[i + 1];
            else dist[i] = i + 1;
        }
    }
    vll res(n);
    REP(i, n){
        ll cost = dist[i] - i;
        if(cost > 0){
            if(cost % 2) res[dist[i] - 1]++;
            else res[dist[i]]++;
        }
        else{
            if(cost % 2) res[dist[i] + 1]++;
            else res[dist[i]]++;
        }
    }
    REP(i, n) cout << res[i] << " ";
    cout << endl;
    return 0;
}

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

grid=[]

for i in range(2):
    array=input().split()
    grid.append(array)


for i in range(2):
    for j in range(n):
        grid[i][j]=int(grid[i][j])


def aa(i,k):
    if k<=i:
        return 0
    if k>i:
        return 1

sum=[]


for i in range(n):
    sum.append(0)

# i magarutoko
for i in range(n):
    for k in range(n):
        sum[i]+=grid[aa(i,k)][k]
    sum[i]+=grid[1][i]

print(max(sum))



Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nd = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nd[0];
        var d = nd[1];

        Console.WriteLine((n + d * 2) / (d * 2 + 1));
    }
}


Measured memory_bytes: 13268
fn main() {
    let v = read_vec::<u32>();
    let x = v[0];
    let y = v[1];

    let g1 = vec![1, 3, 5, 7, 8, 10, 12];
    let g2 = vec![4, 6, 9, 11];
    let g3 = vec![2];

    yn(g1.contains(&x) && g1.contains(&y)
        || g2.contains(&x) && g2.contains(&y)
        || g3.contains(&x) && g3.contains(&y));
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.swing.text.Segment;

public class Main {
	
	public static final long INF = Long.MAX_VALUE / 2 - 1;
	
	public static void main(String[] args) throws IOException {
		try(Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			long[][] in_adj = new long[N][N];
			long[][] wf_adj = new long[N][N];
			for(int i = 0; i < N; i++){
				for(int j = 0; j < N; j++){
					in_adj[i][j] = wf_adj[i][j] = sc.nextLong();
				}	
			}
			
			int[][] nexts = new int[N][N];
			for(int i = 0; i < N; i++){
				for(int j = 0; j < N; j++){
					nexts[i][j] = j;
				}
			}
			
			for(int k = 0; k < N; k++){
				for(int i = 0; i < N; i++){
					for(int j = 0; j < N; j++){
						if(wf_adj[i][j] >= wf_adj[i][k] + wf_adj[k][j]){
							if(i != k && j != k){
								nexts[i][j] = nexts[i][k];
							}
							wf_adj[i][j] = wf_adj[i][k] + wf_adj[k][j];
						}
					}
				}
			}
			
			long answer = 0;
			for(int i = 0; i < N; i++){
				for(int j = 0; j < N; j++){
					if(in_adj[i][j] != wf_adj[i][j]){
						System.out.println(-1);
						return;
					}
				}
			}
			
			for(int i = 0; i < N; i++){
				for(int j = i + 1; j < N; j++){
					//System.out.println(i + " " + j + " " + nexts[i][j]);
					
					if(nexts[i][j] == j){
						answer += wf_adj[i][j];
					}
				}
			}
			
			System.out.println(answer);
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 34608
H, W, N = map(int, input().split())
sh, sw = map(int, input().split())

S = input()
T = input()

def canTakaWin(toS, isInc, toT, R, c):
    now = c

    for s, t in zip(S, T):
        if s == toS:
            now = (now + 1) if isInc else (now - 1)

        if not 0 < now <= R:
            return True

        if t == toT:
            now = (now + 1) if not isInc else (now - 1)
            now = max(1, now)
            now = min(R, now)

    return False

ans = False
ans = ans or canTakaWin('U', False, 'D', H, sh)
ans = ans or canTakaWin('D', True, 'U', H, sh)
ans = ans or canTakaWin('L', False, 'R', W, sw)
ans = ans or canTakaWin('R', True, 'L', W, sw)

print('NO' if ans else 'YES')


Measured memory_bytes: 3784
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int64_t dps(int64_t);

map<int64_t, int64_t> dp;

int main()
{
    int64_t H;
    cin >> H;

    cout << dps(H) << endl;
}

int64_t dps(int64_t now)
{
    if (now == 1)
    {
        return 1;
    }
    if (dp.count(now))
    {
        return dp.at(now);
    }
    int64_t cnt = 1;
    rep(i, 2)
    {
        cnt += dps(now / 2);
    }
    dp[now] = cnt;
    return cnt;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair <ll,ll> pii;
ll N, D, A;
pii monsters[200005];
ll diff[200005];
ll nxt[200005];
ll INF = 0x3f3f3f3f3f3f3f3f;
queue <ll> radius;
ll tot = 0;
int main() {
    cin >> N >> D >> A;
    for (int i=0; i<N; i++){
        scanf("%lld %lld", &monsters[i].first, &monsters[i].second);
    }
    sort(monsters, monsters+N);
    monsters[N].first = INF;

    radius.push(0);
    for (int i=1; i<=N; i++){
        while (!radius.empty() && monsters[radius.front()].first + 2*D < monsters[i].first){
            int a = radius.front();
            radius.pop();
            nxt[a] = i;
        }
        radius.push(i);
    }
    radius.pop(); //get rid of INF element

    ll bombs = 0;
    for (int i=0; i<N; i++){
        bombs += diff[i];
        ll add = max(0LL, monsters[i].second - bombs);
        ll multiples = (add+A-1)/A;
        tot += multiples;
        bombs += multiples*A;
        diff[nxt[i]] -= multiples*A;
    }
    cout << tot << endl;
    return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
int main(){
int n;
cin>>n;
vector<double> a(n);
for(int i=0;i<n;i++)cin>>a.at(i);
sort(a.begin(),a.end());
double ans=0.0;
ans+=a.at(0);
for(int i=1;i<n;i++){
    ans+=a.at(i);
    ans/=2;
}
printf("%.7f\n",ans);
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for C - Walking Takahashi
	var X, K, D float64
	fmt.Scanf("%f %f %f", &X, &K, &D)

	A := math.Abs(X)
	B := float64(int(A) % int(D))
	C := math.Min(B, math.Abs(B-2*D))
	Z := math.Min(math.Abs(B-D), math.Abs(B+D))

	E := float64(int(A) / int(D))

	if A >= K*D {
		fmt.Println(int(A - K*D))
	} else if (int(K-E))%2 == 0 {
		fmt.Println(int(C))
	} else {
		fmt.Println(int(Z))
	}
}


Measured memory_bytes: 1840
#include<bits/stdc++.h>
#define ull unsigned long long 
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
int main()
{
    fastio;
    ull r,d,x,i;
    cin>>r>>d>>x;
    for (i=0;i<10;i++)
    {
        x= r*x-d;
        cout<<x<<endl;
    }
}

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

typedef struct {
    int x = 0;
    int y = 0;
} Point;

int main()
{
    int W, H, N, x, y, a, w, h;
    cin >> W >> H >> N;
    Point min, max;
    max.x = W;
    max.y = H;
    for(int p=0; p<N; p++){
        cin >> x >> y >> a;
        switch(a){
            case 1:
                min.x = std::max(x, min.x);
                break;
            case 2:
                max.x = std::min(x, max.x);
                break;
            case 3:
                min.y = std::max(y, min.y);
                break;
            case 4:
                max.y = std::min(y, max.y);
                break;
        }
    }
    
    w = max.x - min.x;
    h = max.y - min.y;
    cout << std::max(w, 0) * std::max(h, 0) << endl;
    return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var chk1 = S[0] == 'A';
		var chk2 = S.Substring(2, S.Length - 3).Count(c => c == 'C') == 1;
		var chk3 = S.Count(c => c >= 'a' && c <= 'z') == S.Length - 2;
		Console.WriteLine(chk1 && chk2 && chk3 ? "AC" : "WA");
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#define pb push_back
#define mp make_pair
using namespace std;
const int N=2e3+5;

int n;
int z,w;
int a[N];

int dp[N][3];
bool vis[N][3];

int ans;

int abs(int x)
{
    if(x < 0)
     return -x;
    return x;
}

int rec(int cards,int p)
{
    if(vis[cards][p])
        return dp[cards][p];

    if(cards == 1)
    {
        dp[cards][p]=abs(a[n-1]-a[n]);
        vis[cards][p]=true;

        return dp[cards][p];
    }

    int i;
    int x=a[n-cards];

    dp[cards][p]=abs(x-a[n]);
    for(i=1;i<cards;i++)
    {
       if(p == 1)
           dp[cards][p]=max(dp[cards][p],rec(i,2));
       else
           dp[cards][p]=min(dp[cards][p],rec(i,1));
    }

    vis[cards][p]=true;
    return dp[cards][p];
}


int main()
{
    int i;

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

    rec(n,1);

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

    return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if X == 500*a + 100*b + 50*c:
                count+=1
print(count)

Measured memory_bytes: 9188
from itertools import permutations
 
N, M, R = map(int, input().split())
r = [a-1 for a in [int(x) for x in input().split()]]
d = [[float("inf")]*N for _ in range(N)]

for i in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c

for a in range(N):
    d[a][a] = 0

res = float("inf")

for k in range(N):
    for i in range(N):
        for j in range(N):
            if d[i][k]+d[k][j] < d[i][j]:
                d[i][j] = d[i][k]+d[k][j]

for p in permutations(r):
    distance = 0
    for i in range(len(p)-1):
        distance += d[p[i]][p[i+1]]
    res = min(distance, res)

print(res)



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

int main() {
	int ans, num; char cha; cin >> ans;
	while (1) {
		cin >> cha;
		if (cha != '=') {
			cin >> num;
			if (cha == '+') ans += num;
			if (cha == '-') ans -= num;
			if (cha == '*') ans *= num;
			if (cha == '/') ans /= num;
		}
		else break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3076
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF 1000000000
#define SZ 20

int mat[SZ+1][2*SZ+1];  //no-shade:0, shade:plus, mat[height][width+20]

int main(){
  int r,n;
  while(scanf("%d %d",&r,&n), r|n){
    // initialize
    rep(i,SZ+1){
      rep(j,2*SZ+1){
	mat[i][j]=0;
      }
    }

    // input provess for imosu
    rep(i,n){
      int xl, xr, h;
      scanf("%d %d %d", &xl, &xr, &h);
      mat[0][xl+20]++;
      mat[0][xr+20]--;
      mat[h][xl+20]--;
      mat[h][xr+20]++;
    }
    
    // imosu
    rep(i,SZ){
      repl(j,1,2*SZ){
	mat[i][j] += mat[i][j-1];
      }
    }
    rep(i,2*SZ){
      repl(j,1,SZ){
	mat[j][i] += mat[j-1][i];
      }
    }

    // debug
    /*
    rep(i,SZ){
      rep(j,2*SZ){
	printf("%d", mat[SZ-i-1][j]);
      }printf("\n");
    }
    */

    // move sun from bottom
    int t=0;
    int w;
    double res=20;
    while(t<20){
      w=0; //width
      while(w<r){
	if(mat[t][20+w]>0 && mat[t][19-w]>0){
	  w++;
	}else{
	  break;
	}
      }
      if(w==0){
	res=min(res, (double)t);
	break;
      } else if(w==r){
	t++;
	continue;
      } else {
	res = min(res, (double)(r+t) - sqrt(r*r-w*w));
	t++;
      }
    }

    printf("%.4f\n", res);
  }
  return 0;
}

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

#define ll long long int
#define INF 1000000007



int main(){
	string s;
	cin >> s;
	int arr[256] = { 0 };
	int n = s.length();
	if( n == 0 ){
		cout << "Yes";
		return 0;
	}
	if( n == 1 ){
		cout << "No";
		return 0;
	}	
	int ans = 1;
	for ( int i = 0; i < n; i++ )
		arr[ (int)s[i] ]++;
	for ( int i = 0; i < 256; i++ ){
		if( arr[i]%2 != 0 ){
			ans = 0;
			break;
		}
	}
	if( ans == 1 )
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int[][] matrix = new int[14][14];
		int x = 0;
		int y = 0;
		int size = 0;
		int blank = 0;
		int maxValue = 0;

		while (sc.hasNext()) {
			String inputData[] = sc.next().split(",");

			x = Integer.parseInt(inputData[0]) + 2;
			y = Integer.parseInt(inputData[1]) + 2;
			size = Integer.parseInt(inputData[2]);

			switch (size) {
			case 1:
				spillInk1(x, y, matrix);

				break;
			case 2:
				spillInk2(x, y, matrix);

				break;
			case 3:
				spillInk3(x, y, matrix);
			}

		}

		for (int i = 2; i < 12; i++) {
			for (int j = 2; j < 12; j++) {
				if (matrix[i][j] == 0) {
					blank++;
				}
				if (maxValue < matrix[i][j]) {
					maxValue = matrix[i][j];
				}
			}
		}

		System.out.println(blank);
		System.out.println(maxValue);
	}

	static int[][] spillInk1(int x, int y, int[][] matrix) {
		matrix[x][y]++;
		matrix[x + 1][y]++;
		matrix[x - 1][y]++;
		matrix[x][y + 1]++;
		matrix[x][y - 1]++;

		return matrix;
	}

	static int[][] spillInk2(int x, int y, int[][] matrix) {
		spillInk1(x, y, matrix);

		matrix[x + 1][y + 1]++;
		matrix[x - 1][y - 1]++;
		matrix[x + 1][y - 1]++;
		matrix[x - 1][y + 1]++;

		return matrix;
	}

	static int[][] spillInk3(int x, int y, int[][] matrix) {
		spillInk2(x, y, matrix);

		matrix[x][y + 2]++;
		matrix[x][y - 2]++;
		matrix[x + 2][y]++;
		matrix[x - 2][y]++;

		return matrix;
	}

}

Measured memory_bytes: 25920
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N;
	int d[110];

	cin >> N;
	for (int i = 0; i < N; i++)cin >> d[i];

	int cnt[110] = { 0 };
	for (int i = 0; i < N; i++) {
		cnt[d[i]] = 1;
	}
	int res = 0;
	for (int i = 0; i < 110; i++) {
		if(cnt[i]==1){
			res++;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import setrecursionlimit
setrecursionlimit(4100000)

#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod

n = int(input())
mod = 10 ** 9 + 7
if n == 1:
    print(0)
else:
    ans = (mod_pow(10, n, mod) - (2 * mod_pow(9, n, mod) - mod_pow(8, n, mod))) % mod 
    print(ans)

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll x;
  cin >> x;
  ll ans;
  ll i = x;
  while(true){
    bool sosu = true;
    for(ll j = 2; j<sqrt(i); j++){
      if(i%j==0){
        sosu = false;
        break;
      }
    }

    if(sosu)
      break;
    i++;
  }

  cout << i << endl;
}


Measured memory_bytes: 256
n = int(input())
a_list = [int(x) for x in input().split()]

a_sum = sum(a_list)
f = a_sum // n
c = (a_sum + n - 1) // n
b = f if abs(a_sum - f * n) < abs(a_sum - c * n) else c

ans = 0
for a in a_list:
    ans += (a - b) ** 2
print(ans)

Measured memory_bytes: 9180
#include <stdio.h>
 
int main(){
	
	long long int n, sum=0;
	
	
	scanf("%lld", &n);
	
	for (int i=n; i>=1; i--){
		
		if(i%3!=0 && i%5!=0){
			sum=sum+i;
		n--;
		
		}		
	}
	
	printf("%lld", sum);
	
	return 0;
}

Measured memory_bytes: 1700
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt(); //??¶?????°
		int m = sc.nextInt(); //?§?????????°
		int i;
		int max=0;
		int mmax=0;
		int kyoginm=0;
		int result=0;

		int[] kyogi = new int[n];
		int[] hu = new int[m];
		int[] score = new int[n];

		for(i = 0; i < n; i++){
			kyogi[i] = sc.nextInt();
			score[i] = 0;//?????¨
		}

		for(i = 0; i < m; i++){
			hu[i] = sc.nextInt(); //??????
		}


		for(i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(hu[i] >= kyogi[j]){
					score[j] = score[j]+1;
					break;
				}
			}
		}

		for(i = 0; i < n; i++){
			if(max < score[i]){
				max = score[i];
				result = i+1;
			}
		}

		System.out.println(result);

	}
}

Measured memory_bytes: 34236
#include <stdio.h>

const int Mod = 1000000007;

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] = (BIT[i] + k) % Mod;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = 0;
	while (r > 0) {
		sum = (sum + BIT[r]) % Mod;
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int n;
	scanf("%d", &n);
	if (n == 1) {
		printf("1\n");
		fflush(stdout);
		return 0;
	}

	int i, BIT[1000001] = {}, tmp = (int)((long long)n * n % Mod);
	add_BIT(n, BIT, 1, n);
	add_BIT(n, BIT, 2, tmp);
	for (i = 3; i <= n; i++) {
		tmp = (int)((tmp + sum_BIT(BIT, i - 3) + (long long)(i - 3) * (n - 1) + (long long)(n - i + 2) * n) % Mod);
		add_BIT(n, BIT, i, tmp);
	}
	printf("%d\n", tmp);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 5636
#include<bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pi acos(-1)
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000001
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<pll,ll>
#define vplll vector<plll>
#define vpll vector<pll>
using namespace std;
using namespace std::chrono; 
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);


int main()
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll len;
    string str;
    cin>>len>>str;
    map<ll,ll>onedig;
    map<ll,ll>twodig;
    map<ll,ll>threedig;
    ll val;
    for(ll i=0;i<len;i++)
    {
        val=str[i]-'0';
        for(auto it:twodig)
        {
            threedig[10*it.first+val]+=it.second;
        }
        for(auto it:onedig)
        {
            twodig[10*it.first+val]+=it.second;
        }
        onedig[val]++;
    }
    ll ans=0;
    for(auto it:threedig)
    {
        ans++;
    }
    cout<<ans;
    return 0;
}
    

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

int main(void){
    int n;
    cin >> n;
    double sum;
    for(int i=0;i<n;i++){
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY"){
            sum += x;
        }else{
            sum += x * 380000;
        }
    }
    printf("%.7f\n",sum);
    return 0;
}

Measured memory_bytes: 256
import sys
#input = sys.stdin.buffer.readline

def main():
    S = input()
    l = len(S)
    MOD = 10**9+7
    dp = [[0 for _ in range(3)] for _ in range(2)]
    cq = 1
    for st in S:
        if st == "A":
            dp[1][0] = dp[0][0]+cq
            dp[1][1] = dp[0][1]
            dp[1][2] = dp[0][2]
        elif st == "B":
            dp[1][0] = dp[0][0]
            dp[1][1] = dp[0][0]+dp[0][1]
            dp[1][2] = dp[0][2]
        elif st == "C":
            dp[1][0] = dp[0][0]
            dp[1][1] = dp[0][1]
            dp[1][2] = dp[0][1]+dp[0][2]
        else:
            dp[1][0] = dp[0][0]*3+cq
            dp[1][1] = dp[0][1]*3+dp[0][0]
            dp[1][2] = dp[0][2]*3+dp[0][1]
            cq *= 3
            cq %= MOD
        for i in range(3):
            dp[0][i] = dp[1][i]%MOD
    
    print(dp[0][-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll A, B, N;
	cin >> A >> B >> N;

	ll x = min(N, B - 1);
	cout << (ll)floor((double)A * x / B) - A * (ll)floor((double)x / B) << endl;
	
	return 0;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    for (unsigned long i = 0; i <= N; ++i) {
        auto t = i * 27 / 25;
        if (t == N){
            cout << i << endl;
            return 0;
        }
    }
    puts(":(");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int a, b, ans;

	scanf("%d", &a);
	scanf("%d", &b);

	if (a%2 != b%2)
		printf("IMPOSSIBLE\n");
	else {
		ans = (a + b) / 2;
		printf("%d\n", ans);
	}
		return 0;
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> p(n);
	for( auto &k : p ) cin >> k;
	bool flag = false;
	int cnt = 0;
	for( int i = 0; i < n; ++i ){
		if( p[i] == i+1 ){
			if( !flag ){
				++cnt;
				flag = true;
			}
			else flag = false;
		} else {
			flag = false;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
using namespace std;

int main()
{
  while (1)
  {
    int a, b;
    char op;
    scanf("%d %c %d", &a, &op, &b);
    if (op == '?')
      break;
    switch (op)
    {
    case '+':
      printf("%d\n", a + b);
      break;
    case '-':
      printf("%d\n", a - b);
      break;
    case '*':
      printf("%d\n", a * b);
      break;
    case '/':
      printf("%d\n", a / b);
      break;
    default:
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 2612
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, A);
    CIN(int, B);
    CIN(int, C);

    if (B < C) swap(B, C);
    if (A < B) swap(A, B);

    int ans;
    int temp = A - B + A - C;
    if ( temp % 2 == 0 ) {
        ans = temp / 2;
    } else {
        ans = (temp + 3) / 2;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double

using namespace std;

    const ll N = 1e5 + 7;
    const ll mod = 1e9 + 7;
    const ld eps = 1e-9;



void solve(){
    int n;
    cin >> n;
    if(n >= 30){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while(tt --){
            solve();
    }
}

/**

**/


Measured memory_bytes: 3648
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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



int main() {

	long long n, d; cin >> n >> d;
	vector<vector<long long>> v(n, vector<long long>(d, 0));

	for (long long i = 0; i <= n - 1; i++) {
		for (long long j = 0; j <= d - 1; j++) cin >> v[i][j];
	}


	auto is_dist_int = [&](vector<long long> a, vector<long long> b) -> bool {
		long long res = 0;
		for (long long i = 0; i < d; i++) {
			res += (a[i] - b[i]) * (a[i] - b[i]);
		}

		long long temp = sqrt(res);

		return (temp * temp == res);
	};

	long long ans = 0;

	for (long long i = 0; i <= n - 2; i++) {
		for (long long j = i + 1; j <= n - 1; j++) {
			if (is_dist_int(v[i], v[j])) ans++;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3136
using System;

class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int n = int.Parse(input[0]);
    int k = int.Parse(input[1]);
    int[] l = new int[n];
    string[] input2 = Console.ReadLine().Split(' ');
    for (int i = 0; i < n; i++)
    {
      l[i] = int.Parse(input2[i]);
    }
    Array.Sort(l);
    Array.Reverse(l);
    int ans = 0;
    for (int i = 0; i < k; i++)
    {
      ans += l[i];
    }
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 27216
n = int(input())
rolls = []
for i in range(n):
    rolls.append([int(x) for x in input().split()])

for i in range(n-2):
    # print(i)
    r1, r2, r3 = rolls[i:i+3]
    # print(r1, r2, r3)
    if r1[0] == r1[1] and r2[0] == r2[1] and r3[0] == r3[1]:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 62412
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <queue>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ul;
typedef pair<int,int> P;
#define X first
#define Y second

const int mod = 998244353;


void go() {
	int n,k;
	cin >> n >> k;
	map<int,int> cnt;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		cnt[x]++;
	}
	vector<int> a;
	for(auto ite : cnt) {
		a.push_back(ite.Y);
	}
	sort(a.begin(),a.end());
	int res = 0;
	int m = cnt.size();
	for(int i = 0; i < m-k; i++) res += a[i];
	cout << res << endl;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	// int t; cin >> t; for(;t--;)
	go();
	return 0;
}




Measured memory_bytes: 10744
#include<bits/stdc++.h>
using namespace std;
#define LL long long 
#define pb push_back
#define mem(a, b) memset(a, b, sizeof(a)) 

const int N = 1e5 + 5;
int a[N];
int main() {
	int n;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	int ans = 0; 
	for (int i = 1; i <= n + 1; i++) ans += abs(a[i] - a[i - 1]);
	for (int i = 1; i <= n; i++) {
		if(a[i] > max(a[i+1], a[i-1]))printf("%d\n", ans - (a[i] - a[i-1] + a[i] - a[i+1] - abs(a[i+1] - a[i-1])));
		else if(a[i] < min(a[i+1], a[i-1]))printf("%d\n", ans - (a[i-1] - a[i] + a[i+1] - a[i] - abs(a[i+1] - a[i-1])));
		else printf("%d\n",ans); 
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

class Candle {
 public:
  long long value;
  int a_i, b_i, c_i;
  Candle(long long value,
         int a_i,int b_i,int c_i) :
    value(value),
    a_i(a_i),
    b_i(b_i),
    c_i(c_i) {};

  bool operator < (const Candle &c) const {
    return c.value > value;
  }
};

class CandleCompare {
public:
  bool operator()(const Candle &left,
                  const Candle &right) {
    return (left.a_i + left.b_i*1000 + left.c_i*1000000 <
            right.a_i + right.b_i*1000 + right.c_i*1000000);
  }
};

int main() {
  int X,Y,Z;
  long long K;
  cin >> X >> Y >> Z >> K;
  long long A[X];
  long long B[Y];
  long long C[Z];

  for (int i = 0; i < X; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < Y; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < Z; i++) {
    cin >> C[i];
  }
  sort(A, A+X, greater<long long>());
  sort(B, B+Y, greater<long long>());
  sort(C, C+Z, greater<long long>());
  priority_queue<Candle> q;
  Candle candle(A[0]+B[0]+C[0], 0, 0, 0);
  set<Candle, CandleCompare> s;
  //bool registered[X*Y*Z] = {false};
  //registered[0][0][0] = true;
  q.push(candle);
  s.insert(candle);
  for (long long i = 0; i < K; i++) {
    Candle top_candle = q.top();
    q.pop();
    cout << top_candle.value << endl;
    int a_i = top_candle.a_i;
    int b_i = top_candle.b_i;
    int c_i = top_candle.c_i;
    if (a_i+1 < X) {
      Candle new_candle(A[a_i+1]+B[b_i]+C[c_i],
                        a_i+1, b_i, c_i);
      if (s.find(new_candle) == s.end()) {
        q.push(new_candle);
        s.insert(new_candle);
      }
    }
    if (b_i+1 < Y) {
      Candle new_candle(A[a_i]+B[b_i+1]+C[c_i],
                        a_i, b_i+1, c_i);
      if (s.find(new_candle) == s.end()) {
        q.push(new_candle);
        s.insert(new_candle);
      }
    }
    if (c_i+1 < Z) {
      Candle new_candle(A[a_i]+B[b_i]+C[c_i+1],
                        a_i, b_i, c_i+1);
      if (s.find(new_candle) == s.end()) {
        q.push(new_candle);
        s.insert(new_candle);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include<vector>
#include<algorithm>
#include<queue>
#include<stdio.h>
using namespace std;
//结点数最大值 
const int maxn = 1000;
//结点权值最大值 
const int INFTY = 1000000;
//first是下一个结点位置,second是权值 
vector< pair<int,int> > g[maxn];
//parent是父节点,d是当前最短边,is是是否使用过 
int parent[maxn],d[maxn],is[maxn];
//结点数 
int n;
//初始化函数 
void Init(){
	for(int i = 0;i<n;++i){
		//父节点全设置为不存在 
		parent[i] = -1;
		//全设置为最大距离 
		d[i] = INFTY;
		//为输入边和权值做好准备 
		g[i].clear();
		//初始化各边使用状态 
		is[i] = false;
	}
}
int prim(){
	//最小生成树总权值 
	int ans = 0;
	//存储边 
	priority_queue< pair<int,int> >q;
	pair<int,int> work;
	//将0起点的存进去 
	for(int i = g[0].size()-1;i>=0;--i){
		work= g[0][i];
		parent[work.first] = 0;
		//最大堆变最小堆 
		work.second*=-1;
		swap(work.first,work.second);
		q.push(work);
	}
	is[0] = true;
	
	while(q.size()){
		work = q.top();q.pop();
		//to是结点号,v是权值 
		int to = work.second,v = -1*work.first;
		//距离过大或者目标节点已被标记则略过 
		if(d[to]<to||is[to])continue;
		is[to] = true;
		//展示选择的边 
		//printf("%d --> %d:%d\n",parent[to],to,v);
		ans+=v;
		//将当前结点to的边加进队列 
		for(int i  = g[to].size()-1;i>=0;--i){
			work= g[to][i];
			//如果权值比当前的还要大或者目标结点已经被标记过了则跳过 
			if(is[work.first]||d[work.first]<work.second)continue;
			parent[work.first] = to;
			work.second*=-1;
			swap(work.first,work.second);
			q.push(work);
		}
	}
	return ans;
}
int main(){
	int m,a,b,c;
	scanf("%d",&n);
	Init();
	for(int i = 0;i<n;++i){
		for(int j = 0;j<n;++j){
		scanf("%d",&a);
		if(a==-1)continue; 
		g[i].push_back(make_pair(j,a));
		}
	}
	printf("%d\n",prim());
	return 0;
}
//test:
/*
6 10
0 1 2
0 3 1
1 3 3
1 2 1
1 4 2
3 2 2
3 5 2
2 4 5
2 5 3
4 5 1
*/


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

int main(){
    int h,n,sum=0;
    cin>>h>>n;
    vector<int>a(1000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum<h){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
   return 0;
}

Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define YES(c) if(c)co("YES");else co("NO")
#define Yes(c) if(c)co("Yes");else co("No")
#define yes(c) if(c)co("yes");else co("no")
#ifdef LOCAL_tqk
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

bool f(int n){
    if((n/10000 == n%10)&&((n/1000)%10 == (n%100)/10)) return 1;
    return 0;
}

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

    int a,b,ans=0;
    cin>>a>>b;
    repi(i,a,b+1) if(f(i))ans++;
    co(ans);
}

Measured memory_bytes: 256