akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  A, B, C, K = map(int, input().split())
  c = min(A, K)
  K -= (A + B)

  if K > 0:
    c -= K

  print(c)


if __name__ == '__main__':
  main()


Measured memory_bytes: 61640
import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer x = Integer.parseInt(scanner.next());
        String[] s = scanner.next().split("");

        int half =  x / 2;
        if (x % 2 != 0) {
            System.out.println("No");
            System.exit(0);
        }
        boolean flag = true;
        for(int i = 0; i < half; i++) {
            if(!(s[i].equals(s[half+i]))) {
                flag = false;
                break;
            }
        }

        if (flag && half != 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23124
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	  public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int m = sc.nextInt();
	    
	    if (n == m) System.out.println("Yes");
	    else System.out.println("No");
	    
	  }
	}

Measured memory_bytes: 23892
// https://qiita.com/e869120/items/eb50fdaece12be418faa
// https://atcoder.jp/contests/abc106/tasks/abc106_b
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;

int count(int x) {
    int res = 0;
    for(int i = 1; i <= x; i++) {
        if (x % i == 0) ++res;
    }
    return res;
}

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

    int ans = 0;
    rep(i, 1, n+1) {
        if (i % 2 == 0) continue;
        if (count(i) == 8) ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		boolean[][] card = new boolean[4][13];
		int n = sc.nextInt();
		for (int i=0; i<n; i++) {
			String s = sc.next();
			int a = sc.nextInt()-1;
			if (s.equals("S")) {
				card[0][a] = true;
			}
			else if (s.equals("H")) {
				card[1][a] = true;
			}
			else if (s.equals("C")) {
				card[2][a] = true;
			}
			else if (s.equals("D")) {
				card[3][a] = true;
			}
		}
		
		for (int i=0; i<4; i++) {
			for (int j=0; j<13; j++) {
				if (card[i][j] == false) {
					System.out.println((i==0?"S":i==1?"H":i==2?"C":"D")+" "+(j+1));
				}
			}
		}

	}
}


Measured memory_bytes: 26180
#include<iostream>

using namespace std;

int main(void)

{
    unsigned long long int a, i, sum = 0;
    cin>>a;
    for(i = 1; i <= a; i++){
        if(i%3 == 0 || i%5 == 0){

        }
        else{
            sum += i;
        }
    }
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 3192
from sys import exit
from itertools import product

N, M = map(int, input().split())

light = {}

for i in range(M):
    light[i] = list(map(int, input().split()))
    light[i].pop(0)

p = list(map(int, input().split()))

count = 0
for i in product([1, 0], repeat=N):
    clear = True
    for j in range(M):
        s = 0
        for k in light[j]:
            if i[k - 1] == 1:
                s += 1

        if s % 2 != p[j]:
            clear = False
            break
    if clear:
        count += 1

print(count)


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int MOD = 1e9+7;

long modpow(long m,long p) {
     if(p==0) return 1;
     if(p%2) return m * modpow(m,p-1) % MOD;
     else {
        long res = modpow(m,p/2);
        return res * res % MOD;
     }
}

long calcComb(int a,int b) {
     if( b > a - b) return calcComb(a,a-b);
     long mul = 1;
     long div = 1;
     for(int i=0;i<b;i++) {
        mul *= (a-i);
        div *= (i+1);
        mul %= MOD;
        div %= MOD;
     }
     long res = mul * modpow(div,MOD-2) % MOD;
     return res;
}

int N,M;
int main () {
    cin >> N >> M;
    long ans = 1;
    for(int i=2;i*i<=M;i++) {
        if( M % i == 0) {
            int cnt = 0;
            while(M % i ==0) M/=i,cnt++;
            ans *= calcComb(cnt+N-1,N-1);
            ans %= MOD;
        }

    }
    if(M != 1) {
        ans *= calcComb(N,N-1);
        ans %= MOD;
    }

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


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b, c, ab, ac, bc, ans;

    scanf("%d %d %d", &a, &b, &c);
    ab = a + b;
    ac = a + c;
    bc = b + c;
    
    if(ab <= ac){
        ans = ab;
    }else{
        ans = ac;
    }
    if(bc <= ans){
        ans = bc;
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
	int i,j,k,x,n;
	int a[4][13]={0};
	char m;
	cin >> n;
	for( k=0;k<n;k++ ){
		cin >> m >> x;
		if( m == 'S')
			a[0][x-1]=1;
		else if( m == 'H')
			a[1][x-1]=1;
		else if( m == 'C')
			a[2][x-1]=1;
		else if( m == 'D')
			a[3][x-1]=1;
	}
		
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if( a[i][j] ) continue;
				if( i==0 ) m = 'S';
				else if( i==1 ) m = 'H';
				else if( i==2 ) m = 'C';
				else if( i==3 ) m = 'D';
					cout << m << " " << j+1 << endl;
		}	
	}
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;

	int ans = 0;
	for (auto i = 0u; i < S.size(); ++i) {
		ans += S[i] == T[i];
	}
	cout << ans << endl;
}


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

int main() {
  const double pi=3.1415926535897932;
  
  double A,B;
  cin >> A >> B;
  double H,M;
  cin >> H >> M;
  
  double a,b;
  a=(H/6.00+M/360.00)*pi;
  b=pi*M/30.00;
  cout << setprecision(24) << sqrt(A*A+B*B-2.00*A*B*cos(b-a)) << endl;
}




Measured memory_bytes: 4228
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

D = []
import math

for i in range(N):
  x, y = xy[i]
  t = math.atan2(y, x)
  t = math.degrees(t)
  if t < 0:
    t += 360
  D.append([t, x, y])

import copy
D.sort()
D = D + copy.deepcopy(D)
for i in range(N, N + N):
  D[i][0] += 360

ans = 0
for i in range(N):
  x, y = 0, 0
  d = D[i][0]
  for j in range(i, i + N):
    t = D[j][0]
    if t - d > 180:
      break
    x += D[j][1]
    y += D[j][2]
    l = (x ** 2 + y ** 2) ** (1 / 2)
    ans = max(ans, l)

print(ans)

Measured memory_bytes: 39536
h,w=map(int,input().split())
S=[]
S.append("."*(w+2))
for i in range(h):
    S.append("."+input()+".")
S.append("."*(w+2))

#print(S)
    

no=0
for i in range(h):
    for j in range(w):
        #no=0
        if S[i][j]=="#" and S[i][j-1]=="." and S[i][j+1]=="." and S[i-1][j]=="." and S[i+1][j]=="." :
            no=1

if no==1 :
    print("No")
else :
    print("Yes")


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 4 * N;

int n, m;
int h[N], e[M], w[M], ne[M], idx;
int dist[N], q[N];
bool st[N];

void add(int a, int b, int c)
{
	e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++ ;
}

bool bfs(int u)
{
	st[u] = true;
	dist[u] = 0;
	int hh = 0, tt = -1;
	q[ ++ tt] = u;
	
	while (hh <= tt)
	{
		int t = q[hh ++ ];
		
		for (int i = h[t]; ~i; i = ne[i])
		{
			int j = e[i];
			if (!st[j])
			{
				q[ ++ tt] = j;
				st[j] = true;
				dist[j] = dist[t] + w[i];
			}
			else if (dist[t] + w[i] != dist[j]) return false;
		}
	}
	return true;
}

int main()
{
	memset(h, -1, sizeof h);
	scanf("%d%d", &n, &m);
	
	for (int i = 0; i < m; i ++ )
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		add(a, b, c), add(b, a, -c);
	}
	
	for (int i = 1; i <= n; i ++ )
		if (!st[i] && !bfs(i))
		{
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 6144
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#include <time.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;


int main(int argc, char* argv[])
{
    int n; ll D,A;
    scanf("%d%lld%lld", &n, &D, &A);

    vector<pair<ll,ll> > z;
    int i;
    for(i=0; i<n; i++) {
        ll x,h;
        scanf("%lld%lld", &x, &h);
        z.push_back(make_pair(x,h));
    }
    sort(z.begin(),z.end());

    ll cnt=0;
    vector<pair<ll,ll> > vv;
    auto it=z.begin();

  for(; it!=z.end(); ++it) {
        ll x=it->first;
        ll tmp=it->second;
        ll now=cnt*A;

        pair<ll,ll> aa=make_pair(x,-LINF);
        int k=lower_bound(vv.begin(), vv.end(), aa)-vv.begin();

    if(k>0) {
            now-=vv[k-1].second;
        }
        tmp-=now;
        if(tmp>0) {
            ll num=(tmp-1+A)/A;
            cnt+=num;
            ll val=(vv.empty()? 0: vv.back().second)+num*A;
            vv.push_back(make_pair(x+D*2, val));
        }
  }
    printf("%lld\n", cnt);


    return 0;
}


Measured memory_bytes: 12012
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,ans=1;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		if(k<ans)
			ans+=k;
		else
			ans+=ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] a = sc.next().split("");
        String[] b = sc.next().split("");
        Arrays.sort(a);
        Arrays.sort(b, Comparator.reverseOrder());
        String one = "";
        String two = "";
        for (String tmp : a) {
            one += tmp;
        }
        for (String tmp : b) {
            two += tmp;
        }
        if (one.compareTo(two) < 0) {
            System.out.println("Yes");    
        } else {
            System.out.println("No");
        }
        
    }
}


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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        f: [[i64; 10]; n],
        p: [[i64; 11]; n],
    }
    const INF: i64 = 100000000000000000;
    let mut ans = -INF;

    for j in 1..(1<<10) {
        let mut sum = 0;
        for i in 0..n {
            let mut pc=0;
            for k in 0..10 {
                if (j & (1<<k))!=0 && f[i][k]==1 {
                    pc+=1;
                }
            }
            sum += p[i][pc];
        }
        ans = std::cmp::max(ans, sum);
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
// {{{ by WangYenJen
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll;
typedef pair<int,int> pii;
// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))
// input
inline bool SR(int &x) {
	return scanf("%d",&x) == 1;
}
inline bool SR(ll &x) {
	return scanf("%lld",&x) == 1;
}
inline bool SR(double &x) {
	return scanf("%lf",&x) == 1;
}
inline bool SR(char *s) {
	return scanf("%s",s) == 1;
}
inline bool RI() {
	return true;
}
template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
	return SR(x) && RI(tail...);
}
// output
inline void SP(const int x) {
	printf("%d",x);
}
inline void SP(const ll x) {
	printf("%lld",x);
}
inline void SP(const double x) {
	printf("%.16lf",x);
}
inline void SP(const char *s) {
	printf("%s",s);
}
inline void PL() {
	puts("");
}
template<typename I , typename... T> inline void PL(const I x , const T... tail) {
	SP(x);
	if(sizeof...(tail)) putchar(' ');
	PL(tail...);
}
// debug
#define WangYenJen
#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
    cerr << s << " = " << x << endl;
}
template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
    int c = 0;
    while(*s != ',' || c != 0) {
        if(*s == '(' || *s == '[' || *s == '{') c++;
        if(*s == ')' || *s == ']' || *s == '}') c--;
        cerr << *s++;
    }
    cerr << " = " << x << " , ";
    _DOING(s + 1 , tail...);
}
#define debug(...) \
do {\
    fprintf(stderr , "%s:%d - ",__PRETTY_FUNCTION__,__LINE__);\
    _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);
#else
#define debug(...)
#endif
// random function
inline int RAND() {
	static int x = 880301;
	return (x = x * 0xdefaced + 1) & 0x7fffffff;
}
// }}}

const int MAX_N = 4000 + 10;
int a[MAX_N];
int main() {
    int n , x;
    RI(n , x);
    ll ans = 0;
    REP(i , n) RI(a[i]) , ans += a[i] , a[n + i] = a[i];
    REP1(i , 1 , n - 1) {
        deque<int> deq;
        ll pans = (ll)x * i;
        REP(j , n + n) {
            while(!deq.empty() && deq.front() < j - i) deq.pop_front();
            while(!deq.empty() && a[deq.back()] > a[j]) deq.pop_back();
            deq.PB(j);
            if(j >= n) pans += a[deq.front()];
        }
        ans = min(ans , pans);
    }
    PL(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{

	int n;
	cin>>n;
	int arr[n];
	bool flag=true;
	for (int i = 0; i < n; ++i)
		cin>>arr[i];
	
	for(auto i: arr){
		if(i%2==0)
		{
              if((i%3)!=0 && (i%5)!=0)
              	{flag=false;
                 break;}

			/* if((i%3)!=0){
			 	if((i%5)!=0){
			 		flag=false;
			 		break;
			 	}
			 }*/
		}
	}
	if(flag)
		cout<<"APPROVED";
	else
		cout<<"DENIED";
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int n, t, x1[15], x2[15]; string s1[15], s2[15], z;
int main() {
	cin >> n >> t;
	for (int i = 0; i < n; i++) {
		cin >> z >> s1[i];
		x1[i] = stoi(z.substr(0, 2)) * 60 + stoi(z.substr(3, 2));
		cin >> z >> s2[i];
		x2[i] = stoi(z.substr(0, 2)) * 60 + stoi(z.substr(3, 2));
	}
	int cnt = 0;
	for (int i = 1; i < n; i++) {
		if (x1[i] - x2[i - 1] >= t) cnt++;
	}
	cout << cnt << endl;
	for (int i = 1; i < n; i++) {
		if (x1[i] - x2[i - 1] >= t) cout << s1[i] << ' ' << x1[i] - x2[i - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,K;
    cin >> N>>K;
    vector<int> v(N,1);
    for (int i=0;i<K;i++){
        int d;
        cin >> d;
        for(int j=0;j<d;j++){
            int ak;
            cin >>ak;
            v[ak-1]=0;
        }
    }
    int sum=0;
    for (int i=0;i<N;i++){
        sum+=v[i];
    }
    cout << sum <<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

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

        int a, b,c, cont = 0;

        a = tx.nextInt();
        int arre[] = new int[a];
        for (int i = 0; i < a; i++) {
            arre[i]=tx.nextInt();
        }
        b = tx.nextInt();
        for (int i = 0; i < b; i++) {
            c=tx.nextInt();
            for (int j = 0; j < a; j++) {
                if (c==arre[j]) {
                    cont++;
                    break;
                    
                }
            }
        }
        System.out.println(cont);

    }

}


Measured memory_bytes: 69292
#include <iostream>
#define ll long long
using namespace std;

int main() {
  ll a,b,c;
  string k;
  // t = a, n = b, h = c
  cin >> a >> b >> c >> k;

  int f = k[(k.length() - 1)] - '0';

  if (f%2 == 0){
    cout << a-b << endl;
  }
  else{
    cout << b-a << endl;
  }
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
#include <map>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
//typedef pair<double, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
//const ll INF=1e18;
 
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};


const double INF = 1000000.0;
const int MAX_V = 35;
struct edge{ int to,cost;};
//typedef pair<int,int> P;
typedef pair<int, int> P;
typedef pair<double,P> PP;
int V,N;
//vector<edge> G[MAX_V];
double d[MAX_V][10];
int t[10];
int main(){
    int n,m,p,a,b;
    while(true){
        cin >> n >> m >> p >> a >> b;
        if(n == 0)break;
        V = m; N = n;
        for(int i = 0;i < n;i++) cin >> t[i];
        vector<edge> G[MAX_V];
        for(int i = 0;i < p;i++){
            int x,y,z;
            cin >> x >> y >> z;
            edge tmp = {y,z};
            G[x].push_back(tmp);
            edge tmp2 = {x,z};
            G[y].push_back(tmp2);
        }
        sort(t, t + n); 
        double ans = INF;
        do {
            priority_queue<PP,vector<PP>,greater<PP> > que;
            for(int i = 0;i <= V;i++){
                for(int j = 0;j <= n;j++){
                    d[i][j] = INF;
                }
            }
            d[a][0] = 0.0;
            que.push(PP(0.0,P(a,0)));
            while(!que.empty()){
                PP p = que.top(); que.pop();
                int v = p.second.first;
                if(d[v][p.second.second] < p.first)continue;
                if(p.second.second == n)continue;
                for(int i = 0;i < G[v].size();i++){
                    edge e = G[v][i];
                    if(d[e.to][p.sc.sc+1] > d[v][p.sc.sc] + ((double) e.cost) / ((double)t[p.sc.sc] ) ){
                        d[e.to][p.sc.sc+1] = d[v][p.sc.sc] + ((double) e.cost) / ((double)t[p.sc.sc] ) ;
                        que.push(PP(d[e.to][p.sc.sc+1],P(e.to,p.sc.sc+1)));
                    }
                }
            }
            double tmp = INF;
            for(int i = 0;i <= n;i++) tmp = min(tmp,d[b][i]);
            if(tmp == INF)break;
            if(ans > tmp) ans = tmp;
        } while(next_permutation(t, t + n));
        if(ans == INF){
            cout << "Impossible" << endl;
        }else{
            printf("%.3f\n",ans);
        }
    }
}



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

int v[8];
int main(){
	int n,a;
	int ans = 0,ans1 = 0;
	
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a;
		if(a<=399){
			if(!v[0]){
				v[0] = 1;
				ans++;
			}
		}
		else if(a<=799){
			if(!v[1]){
				v[1] = 1;
				ans++;
			}
		}
		else if(a<=1199){
			if(!v[2]){
				v[2] = 1;
				ans++;
			}
		}
		else if(a<=1599){
			if(!v[3]){
				v[3] = 1;
				ans++;
			}
		}
		else if(a<=1999){
			if(!v[4]){
				v[4] = 1;
				ans++;
			}
		}
		else if(a<=2399){
			if(!v[5]){
				v[5] = 1;
				ans++;
			}
		}
		else if(a<=2799){
			if(!v[6]){
				v[6] = 1;
				ans++;
			}
		}
		else if(a<=3199){
			if(!v[7]){
				v[7] = 1;
				ans++;
			}
		}
		else ans1++;
	}
	if(ans) cout << ans << " ";
	else cout << 1 << " ";
	if(ans+ans1>n) cout << n;
	else cout << ans+ans1;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
l = list(map(int,input().split()))

minusx = []
plusx = []
for x in l:
    if x < 0:
        minusx.append(x)
    else:
        plusx.append(x)

m = len(minusx)
a = len(plusx)
res = float("inf")
if m == 0:
    res = plusx[k-1]
elif a == 0:
    res = abs(minusx[-k])
else:
    for i in range(1,k+1):
        if  i <= a and  k-i <= m:
            p = plusx[i-1]
            q = abs(minusx[-(k-i)])
            t = max(p,q)+min(p,q)*2
            if t < res:
                res = t
print(res)

Measured memory_bytes: 62872
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<string>
#include<iostream>

#define maxn 200005
#define INF 0x3f3f3f3f

using namespace std;

inline long long getint()
{
    long long num=0,flag=1;char c;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
    while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();
    return num*flag;
}

int num;
int pri[maxn],np[maxn],cnt;

int main()
{
	num=getint();
	for(int i=2;i<maxn;i++)
	{
		if(!np[i])
		{
			pri[++cnt]=i;
			if(i>=num){printf("%d\n",i);return 0;}
		}
		for(int j=1;j<=cnt&&i*pri[j]<maxn;j++)
		{
			np[i*pri[j]]=1;
			if(i%pri[j]==0)break;
		}
	}
}

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

ll X;

bool is_prime(ll n) {
    if (n <= 1) return false;
    else {
        for (ll i = 2; i*i <= n; i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
}

int main() {
    cin >> X;

    while (!is_prime(X)) {
        X++;
    }

    cout << X << endl;    

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

struct manip{
    int y;
    int xs,xt;
    int val;
    manip(int y, int xs, int xt, int val):y(y),xs(xs),xt(xt),val(val){}
    manip(){}
    bool operator <(const manip &a){
        return y < a.y;
    }
};
const int size = 10003;
int field[2][10003];
manip q[20001];

int main(){
    while(1){
        int n,r;
        scanf("%d%d", &n, &r);
        if(r==0) break;

        memset(field, 0, sizeof(field));
        for(int i=0; i<n; i++){
            int xs,ys,xt,yt;
            scanf("%d%d%d%d", &xs, &ys, &xt, &yt);
            xs++; ys++; xt++; yt++;
            q[2*i] = manip(ys, xs, xt, 1);
            q[2*i +1] = manip(yt, xs, xt, -1);
        }
        sort(q, q +2*n);
        q[2*n].y = 1e9;

        int area = 0;
        int outlen = 0;
        int pt = 0;
        for(int i=0; i<size; i++){
            memcpy(field[i%2], field[1-i%2], sizeof(int)*size/*sizeof(field[0])*/);
            bool changed = false;
            int diff[10003] = {};
            while(q[pt].y == i){
                changed = true;
                diff[q[pt].xs] += q[pt].val;
                diff[q[pt].xt] -= q[pt].val;
                pt++;
            }
            if(changed){
                for(int j=0; j<size -1; j++){
                    diff[j+1] += diff[j];
                    field[i%2][j] += diff[j];
                }
            }
            for(int j=0; j<size -1; j++){
                if(field[i%2][j] > 0) area++;
                if((field[i%2][j]==0) != (field[i%2][j+1]==0)) outlen++;
                if((field[0][j]==0) != (field[1][j]==0)) outlen++;
            }
        }
        printf("%d\n", area);
        if(r==2){
            printf("%d\n", outlen);
        }
    }
    return 0;
}


Measured memory_bytes: 3004
program main
  implicit double precision (a-h, o-z)
  read (*, *) i, j
  k = ibits(i, 0, 1) * ibits(j, 0, 1)
  if (k == 0) then
    write (*, *) "Even"
  else
    write (*, *) "Odd"
  endif
  stop
end program main


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


int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int w=0,r=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='W')
        w++;
        else
        r++;
    }
    string st;
    for(int i=0;i<r;i++)
    st.push_back('R');
    for(int i=0;i<w;i++)
    st.push_back('W');
    int ans=0;
    for(int i=n-1;i>=n-w;i--)
    {
        if(s[i]!=st[i])
        ans+=1;
    }
    cout<<ans<<endl;
    //  RRWWRRRWWRR
    //  RRRRRWW
}


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

using namespace std;

int main(){
    int N,v1num=0,v2num=0;
    bool same = false,first = true;
    vector<int> v1(1e5,0), v2(1e5,0), v1m, v2m;
    cin >> N;
    for(int i=0;i<N;i++){
        int v;
        cin >> v;
        v--;
        if(i%2==0){
            v1[v]++;
        }else{
            v2[v]++;
        }
    }

    v1m = v1;
    v2m = v2;

    sort(v1m.begin(),v1m.end());
    sort(v2m.begin(),v2m.end());

    for(int i=0;i<1e5;i++){
        if(v1[i]==v2[i] && v1[i]==v1m[1e5-1]){
            if(first){
                same = true;
                first = false;
            }else{
                same = false;
            }
        }
    }

    if(same){
        cout << N-max(v1m[1e5-1]+v2m[1e5-2],v2m[1e5-1]+v1m[1e5-2]) << endl;
    }else{
        cout << N-v1m[1e5-1]-v2m[1e5-1] << endl;
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <stack>

using namespace std;

int n, m, k, x;

int chk(vector<stack<int>> tray) {
    int ret = 0;
    while (1) {
        for (int i=0; i<=1; ++i) {
            if (tray[0].size() == n+1 || tray[2].size() == n+1) return ret;
            int a = tray[i].top(); tray[i].pop();
            int b = tray[i+1].top(); tray[i+1].pop();
            if (a < b) {
                tray[i].push(a);
                tray[i].push(b);
            } else {
                tray[i+1].push(b);
                tray[i+1].push(a);
            }
            ret ++;
        }
        if (m < ret) return 15000001;
    }
}

int main() {
    while (cin >> n >> m) {
        if (!n && !m) break;
        vector<stack<int>> tray(3);
        for (int i=0; i<3; ++i) {
            cin >> k;
            tray[i].push(-1);
            for (int j=0; j<k; ++j) {
                cin >> x;
                tray[i].push(x);
            }
        }
        int ans = chk(tray);
        swap(tray[0], tray[2]);
        ans = min(ans, chk(tray));
        cout << (ans <= m ? ans : -1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define REP(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n; i++) cin >> b[i];
  vector<int> a;
  bool sw = false;

  while (!b.empty()) {
    sw = false;
    for (int j = b.size() - 1; j >= 0; j--) {
      if (b[j] == j + 1) {
        a.push_back(j + 1);
        sw = true;
        b.erase(b.begin() + j);
        break;
      }
    }
    if (!sw) break;
  }
  if (!b.empty())
    cout << "-1" << endl;
  else {
    for (int i = a.size() - 1; i >= 0; i--) cout << a[i] << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int  main()
{
  int n;
  cin>>n;
  vector<int>v;
  int i=n;
  while(i--)
  {
	int x;
    cin>>x;
    v.push_back(x);
  }
  int m;
  cin>>m;
  while(m--)
  {
	int a,b;
    cin>>a>>b;
    int temp=v[a-1];
    v[a-1]=b;
    int sum=accumulate(v.begin(),v.end(),0);
    cout<<sum<<endl;
    v[a-1]=temp;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  ll X, K, D;
  cin >> X >> K >> D;
  X = abs(X);

  if (X / D > K) {
    cout << X - D * K << endl;
  } else {
    ll p = X % D;
    K -= (X / D);
    if (K % 2 == 0) {
      cout << p << endl;
    } else {
      cout << abs(p - D) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>

using namespace std;
long long n,i,a[200005],dp[2][200005];
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    dp[0][1]=a[1];
    dp[1][1]=-a[1];
    for(i=2;i<=n;i++)
    {
        dp[0][i]=max(dp[0][i-1]+a[i], dp[1][i-1]+-a[i]);
        dp[1][i]=max(dp[0][i-1]+-a[i], dp[1][i-1]+a[i]);
    }
    cout<<dp[0][n];
    return 0;
}


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

using namespace std;

int main(void) {
  int N,M;
  cin >> N >> M;
  vector<int> A(M);
  vector< vector<int> > B(M,vector<int>(N));
  for (int i = 0; i < M; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> B[i][j];
    }
  }

  vector<int> point(N,0);
  for (int i = 0; i < M; ++i) {
    int t = A[i];
    int tp = 0;
    for (int j = 0; j < N; ++j) {
      if (B[i][j] == t) {
        ++point[j];
      }else{
        ++tp;
      }
    }
    point[t-1] += tp;


    /*
    for (int j = 0; j < N; ++j) {
      cout << B[i][j] << " ";
    }
    cout << endl;
    */
    
  }

  for (int i = 0; i < N; ++i) {
    cout << point[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3140
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
    string s;
    string pm("+++");
    cin>>s;
    int i,j,bit;
    long long ans=0,tmp;
    for(i=0;i<8;i++){
        bit=i;
        ans=s[0]-'0';
        for(j=1;j<4;j++){
        if(bit&1==1){ans-=s[j]-'0'; pm[j-1]='-';}
            else {ans+=s[j]-'0'; pm[j-1]='+';}
            bit=bit>>1;
        }
        if(ans==7)break;
    }
    cout<<s[0];
    for(i=1;i<4;i++)cout<<pm[i-1]<<s[i];
    cout<<"=7"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    int n,k,a[100005]={0},x,y;
    vector<int> b[100005];
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=k;i++){
        cin>>x>>y;
        b[x].push_back(y);
        b[y].push_back(x);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(b[i].size()==0){
            ans++;
        //    cout<<i<<endl;
        }
            
        else{
            if(b[i][0]==-1){
        //   cout<<i<<endl;
        }
            else{
                int ok=1;
                for(int j=0;j<b[i].size()&&ok;j++){
                    if(a[i]<=a[b[i][j]])ok=0;
                    else b[b[i][j]][0]=-1;
                }
                if(ok){
            ans++;
        //    cout<<i<<endl;
        }
            }
        }
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 9116
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

// Source: KACTL
struct BIT { // Operation must be reversible
    vector<ll> bit;
    BIT(int n) : bit(n) {}
    ll query(int pos) { // pos in [0, n]
        ll ans = 0;
        for (pos += 1; pos > 0; pos &= pos - 1) ans += bit[pos - 1];
        return ans;
    }
    void update(int pos, int delta) { // pos in [0, n); 
        for (; pos < sz(bit); pos |= pos + 1) bit[pos] += delta;
    }
    void range_add(int l, int r, int delta) {
        update(l, delta);
        update(r + 1, -delta);
    }
};

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

    int n, m; cin >> n >> m;
    vi a(n);
    F0R (i, n) cin >> a[i];

    ll need = 0;
    BIT count(m + 1), over(m + 1), start(m + 1);
    FOR (i, 1, n - 1) {
        if (a[i] > a[i - 1]) {
            start.range_add(a[i - 1] + 1, a[i], a[i - 1]);
            count.range_add(a[i - 1] + 1, a[i], 1);
        } else {
            start.range_add(a[i - 1] + 1, m, a[i - 1]);
            start.range_add(1, a[i], a[i - 1]);
            count.range_add(a[i - 1] + 1, m, 1);
            count.range_add(1, a[i], 1);
            over.range_add(1, a[i], 1);
        }
        need += (a[i] - a[i - 1] + m) % m;
    }

    ll best = 0;
    FOR (i, 1, m) {
        ll val = (i - 1) * count.query(i) + m * over.query(i) - start.query(i);
        // cout << i << ": " << val << endl;
        // cout << "   " << count.query(i) << " " << over.query(i) << " " << start.query(i) << endl;
        best = max(best, val);
    }
    cout << (need - best) << endl;

    return 0;
}


Measured memory_bytes: 3072
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	LL N, K;
	vector<LL>A, B;
	cin >> N >> K;
	vector<LL>scrap;
	LL bit = 0;
	scrap.push_back(K);
	bool kzero = (K == 0);
	do
	{
		scrap.push_back(K - 1);
		bit = (K & -K);
		K -= bit;
	} while (K > 0);
	int F = scrap.size();
	for (int i = 0; i < N; ++i)
	{
		int a, b;
		cin >> a >> b;
		A.push_back(a);
		B.push_back(b);
	}
	if (kzero)
	{
		LL zeroans = 0;
		for (int i = 0; i < N; ++i)
		{
			if (A[i] == 0)
			{
				zeroans += B[i];
			}
		}
		cout << zeroans << endl;
		return 0;
	}
	vector<LL>ans(F);
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < F; ++j)
		{
			if ((A[i] | scrap[j]) == scrap[j])
			{
				ans[j] += B[i];
			}
		}
	}
	LL answer = -1;
	for (int j = 0; j < F; ++j)
	{
		answer = max(answer, ans[j]);
	}
	cout << answer << endl;
	return 0;
}


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

using namespace std;

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

	vector<int> X(M);

	if (N >= M){
		cout << 0 << endl;
		return 0;
	}

	for (int m=0; m<M; m++){
		cin >> X[m];
	}

	sort(X.begin(), X.end());

	vector<int> diff_X(M-1);
	for (int m=0; m<M-1; m++){
		diff_X[m] = X[m+1] - X[m];
	}

	sort(diff_X.begin(), diff_X.end());

	int ans = 0;

	for (int m=0; m<M-N; m++){
		ans += diff_X[m];
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#define ll long long
#define INF 0x3f3f3f3f
#define N 1005
using namespace std;

int n,m,ans;

int main()
{
	cin>>n>>m;
	ans=(m*1900+100*(n-m))*pow(2,m);
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  int ans=0;
  int x;
  for(int i=1; i<=N; i++) {
    int sum=0;
    x = i;
    while(x>0) {
      sum += x%10;
      x /= 10;
    }
    if(A<=sum && sum<=B) ans+=i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <stdio.h>
using namespace std;

int char_num(char a[]){
    int num=0;
    int pop=1;
    for(int i=3;i!=0;--i){
        
        num+=(a[i-1]-'0')*pop;
        pop*=10;
    }
    
    
    return num;
}

struct Seiyaku{
    int keta;
    char ch;
};

int main(){
    
    int N,M;
    cin>>N>>M;
    char num[N];
    Seiyaku syk[M];
    
    for(int i=0;i!=M;++i){
        cin>>syk[i].keta;
        cin>>syk[i].ch;
    }
    
    int  flag=0;
    int ans=-1;
    if(N==3){
        for(char c1='1';c1<='9';++c1){
            num[0]=c1;
            for(char c2='0';c2<='9';++c2){
                num[1]=c2;
                for(char c3='0';c3<='9';++c3){
                    num[2]=c3;
                    flag=0;
                    for(int j=0;j!=M;++j){
                        if(num[syk[j].keta-1]==syk[j].ch){
                            flag+=1;
                        }
                    }
                    if(flag==M){
                        ans=char_num(num);
                        break;
                    }
                }
                if(flag==M)break;
            }
            if(flag==M)break;
        }
    }else if(N==2){
        num[0]='0';
        for(char c2='1';c2<='9';++c2){
            num[1]=c2;
            for(char c3='0';c3<='9';++c3){
                num[2]=c3;
                flag=0;
                for(int j=0;j!=M;++j){
                    if(num[syk[j].keta]==syk[j].ch){
                        flag+=1;
                    }
                }
                if(flag==M){
                    ans=char_num(num);
                    break;
                }
            }
            if(flag==M)break;
        }
    }else if(N==1){
        num[0]='0';num[1]='0';
        for(char c3='0';c3<='9';++c3){
            num[2]=c3;
            flag=0;
            for(int j=0;j!=M;++j){
                if(num[syk[j].keta+1]==syk[j].ch){
                    flag+=1;
                }
            }
            //cout<<num[0]<<num[1]<<num[2]<<endl;
            if(flag==M){
                ans=char_num(num);
                break;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define INF 0x7fffffff
using namespace std;
const int N = 1e6+5;

int main(){
    int n;
    int cnt = 0;
    string s;
    cin>>n>>s;
    int l = 0,r = n-1;
    while(l<r) {
        if(s[l]=='W'&&s[r]=='R') {
            cnt++;l++;r--;
        }
        else if(s[l]=='W'&&s[r]=='W') {
            r--;
        }
        else if(s[l]=='R'&&s[r]=='R') {
            l++;
        }
        else if(s[l]=='R'&&s[r]=='W') {
            l++;r--;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    int x;
    cin >> x;
    cout << (x ^ 1) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3608
<?php
	fscanf(STDIN,"%s",$s);
	$memo=array();
	for($i=0;$i<strlen($s);$i++){
      if(!in_array($s[$i],$memo)){
        $memo[] = $s[$i];
      }
    }

	sort($memo);
	//print_r($memo);
	$abc='a';
	for($i=0;$i<count($memo);$i++){
      if($abc!=$memo[$i]){
        echo $abc."\n";
        exit;
      }
         $abc++;
    }
	
	if(count($memo)!=26){
      echo $abc."\n";
    }else{
		echo "None\n";
    }

Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  string result;
  if (N/100 == N%10) result = "Yes";
  else result = "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        for (int i = 0; i < h; i++) {
            String s = in.next();
            System.out.println(s);
            System.out.println(s);
        }
    }

}


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

#define MAX_YEAR 1e7

int main(void){
  while(true){
    int m, n;
    cin >> m >> n;
    if(m == 0 && n == 0){ break; }

    int count = 0;
    vector<bool> eratos(MAX_YEAR, false);
    for(int i = m; count < n; i++){
      if(!eratos[i]){
        count++;
        for(int j = i; j < MAX_YEAR; j += i)
          eratos[j] = true;
      }
    }

    int ans;
    for(ans = m; eratos[ans] ; ans++);
    cout << ans << endl;
  }

  return 0;
}

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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int a;
    cin >> a;
    print(a+a*a + a*a*a);
    return 0;
}

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

typedef long long ll;
const int MAXN = 1010;
struct Cake{ long long x, y, z, sum;} c[MAXN];
const int d[8][3] = { { 1, 1, 1},
					{ 1, 1,-1},
					{ 1,-1, 1},
					{ 1,-1,-1},
					{-1, 1, 1},
					{-1, 1,-1},
					{-1,-1, 1},
					{-1,-1,-1} };

int N, M;

bool cmp(Cake a, Cake b) {
	return a.sum > b.sum? true:false;
}

int main() {
	cin >> N >> M;
	ll res = 0, tmp;
	for(int i = 1; i <= N; ++i)
		cin >> c[i].x >> c[i].y >> c[i].z;
	for(int i = 0; i < 8; ++i) {
		tmp = 0;
		for(int j = 1; j <= N; ++j)
			c[j].sum = c[j].x*d[i][0] + c[j].y*d[i][1] + c[j].z*d[i][2];
		sort(c + 1, c + N + 1, cmp);
		for(int k = 1; k <= M; ++k) tmp += c[k].sum;
		res = max(res, tmp);
	}
	printf("%lld\n", res);
	return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e4 + 5);

int n, m;
vector<int> available;
vector<int> cand;

ll dp[MAX_N];

map<int, int> cost;

vector<int> ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; ++i) {
    int tmp;
    scanf("%d", &tmp);
    available.push_back(tmp);
  }

  cost[1] = 2;
  cost[2] = 5;
  cost[3] = 5;
  cost[4] = 4;
  cost[5] = 5;
  cost[6] = 6;
  cost[7] = 3;
  cost[8] = 7;
  cost[9] = 6;

  for (auto e: available) {
    cand.push_back(cost[e]);
  }

  for (int i = 0; i <= n; ++i) {
    dp[i] = -INF;
  }

  dp[0] = 0;

  for (int i = 1; i <= n; ++i) {
    for (auto e: cand) {
      if (i - e >= 0) {
        dp[i] = max(dp[i], dp[i - e] + 1);
      }
    }
  }

  int i = n;
  while (i > 0) {
    int tmp = -1;
    int tmp_cost = 0;

    if (dp[i] - 1 == 0) { // to gracefully use all match
      for (auto e: available) {
        if (i - cost[e] == 0 && dp[i - cost[e]] == dp[i] - 1) {
          if (e > tmp) {
            tmp_cost = cost[e];
            tmp = e;
          }
        }
      }
    }
    else {
      for (auto e: available) {
        if (i - cost[e] >= 0 && dp[i - cost[e]] == dp[i] - 1) {
          if (e > tmp) {
            tmp_cost = cost[e];
            tmp = e;
          }
        }
      }
    }

    ans.push_back(tmp);
    i -= tmp_cost;
  }

  for (auto e: ans) {
    printf("%d", e);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.HashMap;


public class Main {
	public static final String EOF = System.lineSeparator();
	public static long l=0,l2=0;
	public static void main(String[] args) throws IOException {
		l = System.currentTimeMillis();
		new Main().exec();
		l2 = System.currentTimeMillis();
/*
		System.out.println((l2-l)+"msec");
//*/		
	}
	
	public void exec() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		StableChecker sc = new StableChecker();
		int n = Integer.parseInt(br.readLine());
		Card[] A = new Card[n];
		for(int i=0; i<n; i++) {
			sc.set(A[i] = new Card(br.readLine()));
		}
		quickSort(A,0,n-1);
		out.println(sc.check(A) ? "Stable" : "Not stable");
		StringBuilder sb = new StringBuilder();
		for(Card c : A) {
			c.appendStringBuilder(sb);
			sb.append(EOF);
		}
		out.print(sb);
		out.flush();
	}
	
	private void quickSort(Card[] A, int p, int r) {
		if(p < r) {
			int q = partition(A,p,r);
			quickSort(A,p,q-1);
			quickSort(A,q+1,r);
		}
	}
	
	private int partition(Card[] A, int p, int r) {
		Card x = A[r];
		int i=p;
		for(int j=i; j<r; j++) {
			if(A[j].number <= x.number) {
				Card tmp = A[i];
				A[i] = A[j];
				A[j] = tmp;
				i++;
			}
		}
		A[r] = A[i];
		A[i] = x;
		return i;
	}
}

class StableChecker { 
	HashMap<Integer,ArrayDeque<Character>> map = new HashMap<>();

	public void set(Card c) {
		if(map.containsKey(c.number)){
			map.get(c.number).add(c.suit);
		}else{
			ArrayDeque<Character> q = new ArrayDeque<>();
			q.add(c.suit);
			map.put(c.number, q);
		}
	}
	
	public boolean check(Card[] A) {
		for(Card c: A) {
			if(map.containsKey(c.number)){
				Character c2 = map.get(c.number).pop();
				if(!c2.equals(c.suit)){
					return false;
				}
			}
		}
		return true;
	}
}

class Card {
	char suit;
	int number;
	
	public Card(String str) {
		suit = str.charAt(0);
		number = Integer.parseInt(str.substring(2));
	}
	
	public void appendStringBuilder(StringBuilder sb) {
		sb.append(suit).append(" ").append(number);
	}
}

Measured memory_bytes: 56568
import Data.List

commonCharCounts :: (String, String) -> Int
commonCharCounts (c1, c2) = length $ intersect (nub c1) (nub c2)

solve :: Int -> String -> Int
solve n s = maximum $ map commonCharCounts split
  where split = [x | index <- [1..(n-1)], let x = splitAt index s]

main :: IO ()
main = do
  n <- readLn
  s <- getLine
  print $ solve n s

Measured memory_bytes: 1020
#include <iostream>

void bubbleSort(int *a, int n){

    int tmp;
    int counter = 0;

    for(int i = n-1; i > 0; i--){
        for(int j = n-1; j > n-i-1; j--){
            if(a[j] < a[j-1]){
                tmp = a[j];
                a[j] = a[j-1];
                a[j-1] = tmp;
                counter++;
            }
        }
    }

    for(int c = 0; c < n; c++){
        if(c == n-1){
            std::cout << a[c] <<std::endl;
        }else{
            std::cout << a[c] << " ";
        }
    }
    
    std::cout << counter << std::endl;

}

int main(){

    int n, tmp;
    std::cin >> n;

    int a[n];

    for(int i = 0; i < n; i++){
        std::cin >> tmp;
        a[i] = tmp;
    }

    bubbleSort(a, n);


}


Measured memory_bytes: 3088