akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
using namespace std;
int main() {
    int n, b, k;
    cin >> n >> k;
    int h[n];
    for (int i=0;i<n;i++) {
        cin >> b;
        h[i] = b;
    }
    long long int dp[1000000];
    for (int i=0;i<n;i++) {
        dp[i] = 1000000000;
    }
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for (int t=1;t<k+1;t++) {
            dp[i+t] = min(dp[i+t], dp[i] + abs(h[i+t]-h[i]));
        //dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i]));
        //dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k]-h[i]));
        }
    }

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


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

typedef long long ll;

ll t1,t2,a1,a2,b1,b2;
ll x,y;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    x=t1*(a1-b1);
    y=t2*(b2-a2);
    if(x<0){
        x=-x;y=-y;
    }
    if(x>y){
        cout<<0<<endl;
        return 0;
    }
    if(x==y){
        cout<<"infinity"<<endl;
        return 0;
    }
    cerr<<x<<' '<<y<<endl;
    cout<<x/(y-x)*2+((bool)(x%(y-x)))<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 100002;
ll x,y,ans=1;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>x>>y;
	while(1){
		x*=2;
		if(x>y)break;
		else ans++;
	}
	pri(ans);
	return 0;
}


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

int main() {
    int N;
    cin>>N;
    int W;
    cin>>W;
    long long dp[N+1][W+1];
    int arr[N+1][2];
    for(int i=1;i<=N;i++)
        cin>>arr[i][0]>>arr[i][1];
    for(int i=0;i<=N;i++){
        for(int j=0;j<=W;j++){
            if(i==0 || j==0)
                dp[i][j]=0;
            else{
                if(arr[i][0]<=j){
                    dp[i][j]=max(dp[i-1][j],dp[i-1][j-arr[i][0]]+arr[i][1]);
                }
                else
                    dp[i][j]=dp[i-1][j];
            }
        }
    }
    // for(int i=0;i<=N;i++){
    //     for(int j=0;j<=W;j++)
    //         cout<<dp[i][j]<<" ";
    //     cout<<"\n";    
    // }
    cout<<dp[N][W];
	return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>

int main() {
    double a, b, h, m;
    std::cin >> a >> b >> h >> m;

    static const double pi = 3.141592653589793;
    double b_x = b * std::sin(2 * m / 60 * pi);
    double b_y = b * std::cos(2 * m / 60 * pi);
    
    double a_x = a * std::sin(((2 * h / 12) + (2 * m / (60 * 12))) * pi);
    double a_y = a * std::cos(((2 * h / 12) + (2 * m / (60 * 12))) * pi);
    
    double dist = std::sqrt(((a_x - b_x) * (a_x - b_x)) + ((a_y - b_y) * (a_y - b_y)));
    
    std::cout << std::fixed << std::setprecision(10) << dist << std::endl;
    
    return 0;
}

Measured memory_bytes: 4100
n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(q)]

def dfs(num_l):
  if len(num_l)==n:
    global ans
    t_ans=0
    for a,b,c,d in l:
      a-=1
      b-=1
      if num_l[b]-num_l[a]==c:
        t_ans+=d
    ans=max(t_ans,ans)
    return

  for i in range(num_l[-1],m+1):
    dfs(num_l+[i])

ans=0
for i in range(1,m+1):
  dfs([i])

print(ans)

Measured memory_bytes: 9068
//author : 'Amit Singh Sansoya @amit3200'
//it was all meant to happen as i was all talk!
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
lld n;
vector<lld> arr;
vector<vector<lld>> dp;
lld ans=LONG_LONG_MIN;
lld dfs(lld i,lld j){
	if(i>=n || j<0)
		return 0;
	if(dp[i][j]!=LONG_LONG_MIN){
		return dp[i][j];
	}
	if(i==j){
		dp[i][j]=arr[i];
		return arr[i];
	}
	dp[i][j]=max(arr[i]-dfs(i+1,j),arr[j]-dfs(i,j-1));
	return dp[i][j];
}

int main(){
	cin>>n;
	dp.resize(n+1,vector<lld>(n+1,ans));
	for(int i=0;i<n;i++){
		int data;
		cin>>data;
		arr.push_back(data);
	}
	ans=dfs(0,n-1);
	cout<<ans<<"\n";
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  string s, t; cin >> s >> t;
  int a, b; cin >> a >> b;
  string u; cin >> u;
  if (u == s) a--;
  if (u == t) b--;
  cout << a << ' ' << b;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
using namespace std;
using P = pair<int,int>;
using ll = long long;
int main(){
    int n;
    cin>>n;
    if(n%1000==0)cout<<0<<endl;
    else cout<<(n/1000+1)*1000-n<<endl;
}



Measured memory_bytes: 3632
using System;
using System.Linq;

namespace ABC052_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var max = 0;
            for (var i = 1; i <= n; i ++)
            {
                var str = s.Substring(0, i);
                var I = str.Count(x => x == 'I');
                var D = str.Count(x => x == 'D');
                var num = I - D;
                max = Math.Max(max, num);
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <tuple>
using namespace std;
int main(void){
 int N;
 cin>>N;
 char str[N][15];
 for(int i=0;i<N;i++){
     cin>>str[i];
 }
 long mcount=0,acount=0,rcount=0,ccount=0,hcount=0;
 for(int i=0;i<N;i++){
     if(str[i][0]=='M'){mcount++;}
     if(str[i][0]=='A'){acount++;}
     if(str[i][0]=='R'){rcount++;}
     if(str[i][0]=='C'){ccount++;}
     if(str[i][0]=='H'){hcount++;}
 }
 long ans=0;
 for(int i=0;i<2;i++){
     for(int j=0;j<2;j++){
         for(int k=0;k<2;k++){
             for(int l=0;l<2;l++){
                 for(int m=0;m<2;m++){
                     if(i+j+k+l+m==3){
                         long c=1;
                         if(i!=0){c*=i*mcount;}
                         if(j!=0){c*=j*acount;}
                         if(k!=0){c*=k*rcount;}
                         if(l!=0){c*=l*ccount;}
                         if(m!=0){c*=m*hcount;}
                         ans+=c;
                     }
                 }
             }
         }
     }
 }
 cout<<ans;
 return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {
  std::string S; std::cin >> S;

  std::unordered_map<char,int> k;
  for(int i=0; i<S.size(); i++) {
    if ( k.count(S[i]) == 0 ) k[S[i]] = 1;
  }

  std::string ans;
  for(char c = 'a'; c <= 'z'; c++) {
    if ( k.count(c) != 0 ) continue;
    ans.push_back(c); break;
  }

  if ( ans.size() == 0 ) std::cout << "None" << std::endl;
  else std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 512
N,M = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
  d = []
  for j in range(M):
    d_x = abs(S[i][0] - P[j][0])
    d_y = abs(S[i][1] - P[j][1])
    d.append(d_x + d_y)
  print(d.index(min(d)) + 1)
  

Measured memory_bytes: 3064
use proconio::*;

fn main() {
    input! {
        n: usize,
    };
    let mut ans = [0; 10001];

    for x in 1..=100 {
        for y in x..=100 {
            for z in y..100 {
                let t = x * x + y * y + z * z + x * y + y * z + x * z;
                if t <= n {
                    ans[t] += if x == y && y == z {
                        1
                    } else if x == y || y == z || x == z {
                        3
                    } else {
                        6
                    }
                }
            }
        }
    }

    for a in &ans[1..=n] {
        println!("{}", a);
    }
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin>>n;
    map<int,int> mii;
    rep(i,n){
        int x;
        cin>>x;
        mii[x]++;
        mii[x-1]++;
        mii[x+1]++;
    }
    int ans = 0;
    for(auto u:mii){
        if(ans<u.second) ans = u.second;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n][3];
  for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
      cin>>a[i][j];
  for(int i=1;i<n;i++)
  {
     a[i][0]=a[i][0]+max(a[i-1][1],a[i-1][2]);
     a[i][1]=a[i][1]+max(a[i-1][0],a[i-1][2]);
    a[i][2]=a[i][2]+max(a[i-1][1],a[i-1][0]);
  }

  int x=-1;
  for(int i=0;i<3;i++)
  x=max(x,a[n-1][i]);
  cout<<x<<endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;cin>>n>>l;
  vector<string> s(n);
  for(int i=0;i<n;i++)cin>>s.at(i);
  sort(s.begin(),s.end());
  string a=s.at(0);
  for(int j=1;j<n;j++)a+=s.at(j);
  cout<<a<<endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18



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

	vector<int> tb(n + 1);

	for (int i = 0; i < n; i++) {
		int buf; cin >> buf;

		tb[buf]++;
	}

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


	int cnt = 0;
	for (int i = 0; i <= n; i++) {
		if (tb[i])cnt++;
	}

	if (k >= cnt) {
		cout << 0 << endl;
		return 0;
	}

	int ans = 0;
	for (int i = 0; i <= n; i++) {
		if (tb[i]) {
			cnt--;
			ans += tb[i];
		}

		if (cnt<=k) {
			cout << ans << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int[][] price = new int[3][26];

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = Integer.parseInt(line);
			if (n == 0) {
				break;
			}
			//
			for (int i = 0; i < 3; i++) {
				for (int j = 1; j < 26; j++) {
					switch (i) {
						case 0:
							price[i][j] = price[i][j - 1] + 380;
							if (j % 5 == 0) {
								price[i][j] -= 380;
							}
							break;
						case 1:
							price[i][j] = price[i][j - 1] + 550;
							if (j % 4 == 0) {
								price[i][j] -= 330;
							}
							break;
						case 2:
							price[i][j] = price[i][j - 1] + 850;
							if (j % 3 == 0) {
								price[i][j] -= 306;
							}
							break;
					}
				}
			}
			int min = Integer.MAX_VALUE;
			for (int i = 0; i < n / 200 + 1; i++) {
				for (int j = 0; j < n / 300 + 1; j++) {
					for (int k = 0; k < n / 500 + 1; k++) {
						if (i * 200 + j * 300 + k * 500 == n) {
							int sum = price[0][i] + price[1][j] + price[2][k];
							if (sum < min) {
								min = sum;
							}
						}
					}
				}
			}
			System.out.println(min);
		}
	}
}

Measured memory_bytes: 18624
"use strict"

function main(input) {

  input = input.split(' ').map(v => ~~v)
  const x = input[0]
  const y = input[1]
  const a = [1, 3, 5, 7, 8, 10, 12]
  const b = [4, 6, 9, 11]
  // const c = [2]

  // console.log(a.indexOf(x), a.indexOf(y), b.indexOf(x), b.indexOf(y))
  if ((a.indexOf(x) >= 0 && a.indexOf(y) >= 0) ||
    (b.indexOf(x) >= 0 && b.indexOf(y) >= 0)) {
    console.log('Yes')
    return
  }
  console.log('No')
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<stdio.h>
     
    char s[14];
     
    int main(void) {
    	scanf("%s", s);
    	for(int i=13; i>3; --i) {
    		s[i+1] = s[i];
    	}
    	s[4] = ' ';
    	printf("%s\n", s);
    	return 0;
    }

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
     cin>>a; cin>>b; cin>>c;
      if(a>=b){
          cout<< "No";
      }
       else if (b>=c){
           cout<<"No";
       }
      else {
          cout<<"Yes";
          
      }cout<< endl;
      return 0;
}



Measured memory_bytes: 3084
#include<stdio.h>
#include<math.h>
int main()
{
	int n;
	int t,x,y;
	bool flag=true;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++)
	{
		scanf("%d%d%d",&t,&x,&y);
		if(x+y<=t&&(t-(x+y))%2==0);
		else
		{
			flag=false;
		}
	}
	if(flag==true) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200105;
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;
}
struct RES{
	int x,y;
}res[N];
int k,x,y,sx,sy,len;
RES calc(int x,int y)
{
	if(x>y){
		RES ret=calc(y, x);
		return (RES){ret.y, ret.x};
	}
	if(x<0){
		RES ret=calc(-x, y);
		return (RES){-ret.x, ret.y};
	}
	if(x+y>=2*k) return (RES){x, y-k};
	if(x+y==k) return (RES){0, 0};
	//x+y=k or x+y=k+1
	int t=k-(x+y)/2;
	return (RES){-t, y-k+x+t};
}
int main()
{
//	freopen("F.out","w",stdout);
	k=read(); x=read(); y=read();
	if(!(k&1)&&(x+y)&1)return puts("-1"),0;
	res[++len]=(RES){x, y};
	while(res[len].x || res[len].y){
		res[len+1]=calc(res[len].x, res[len].y); len++;
	}
	printf("%d\n",len-1);
	for(int i=len-1; i>=1; i--) printf("%d %d\n",res[i].x,res[i].y);
}

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

using namespace std;

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

    int maior = a + b;

    if(a + (a - 1) > maior)
        maior = a + (a - 1);

    if(b + (b -1) > maior)
        maior = b + (b - 1);

    cout << maior << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
    string S;
    int a = 0,  b = 0;

    cin >> S;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '0') a++;
        else b++;
    }

    cout << 2*min(a, b) << endl;

    
    return 0;
}

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

#pragma region lib_fenwick_tree
namespace lib {
  /*
    class FenwickTree
    usage: Fenwicktree f(100), FenwickTree<long long> f(100)
  */
  template <class T = int> class FenwickTree {
    public:
    FenwickTree() {}
    FenwickTree(int s) :
        size(s), data(s + 1, (T) 0) {}
    FenwickTree(const vector<T> &d) {
      size = d.size();
      data = vector<T>(size + 1, (T) 0);
      for (int i = 0; i < size; i++) add(i, d[i]);
    }

    /* index value must be 0-indexed */
    void add(int idx, const T &diff) {
      for (idx++; idx <= size; idx += (idx & -idx)) {
        data[idx] += diff;
      }
    }

    /* sum of the interval [0, idx] (inclusive, 0-indexed) */
    T sum(int idx) {
      T ret = 0;
      for (idx++; idx > 0; idx -= (idx & -idx)) {
        ret += data[idx];
      }
      return ret;
    }

    /* sum of the interval [l, r] (inclusive, 0-indexed) */
    T rangeSum(int l, int r) {
      return sum(r) - sum(l - 1);
    }

    private:
    int size;
    vector<T> data;
  };
}  // namespace lib
#pragma endregion

int main() {
  int N, Q;
  cin >> N >> Q;
  
  vector<long long> a(N);
  for (long long &in : a) cin >> in;
  
  lib::FenwickTree<long long> f(a);
  
  while (Q--) {
    int x, y, z;
    cin >> x >> y >> z;
    if (x == 0)
      f.add(y, z);
    else
      cout << f.rangeSum(y, z - 1) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 12136
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  string s;
  cin>>s;
  if(s[0]!='A'){
    cout<<"WA\n";
    return 0;
  }

  string a,b;
  for(int i=0;i<(int)s.size();i++){
    if(i<2||i>(int)s.size()-2){
      a+=s[i];
    }else{
      b+=s[i];
    }
    if(s[i]!='A'&&s[i]!='C'&&(s[i]<'a'||s[i]>'z')){
      cout<<"WA\n";
      return 0;
    }
  }
  //cout<<a<<"\n"<<b<<"\n";
  if(count(All(a),'C')>0){
    cout<<"WA\n";
    return 0;
  }
  if(count(All(b),'C')!=1){
    cout<<"WA\n";
    return 0;
  }

  cout<<"AC\n";


  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int d=1;
  
  for(int i=1; i<N; i++){
    if(vec.at(i-1) > vec.at(i)){
      d ++;
    }
  }
  
  cout << d << endl;
  
}


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

using int64 = long long;

int main() {
  int n, m, q;
  cin >> n >> m >> q;

  vector<vector<int64>> imos(n + 1, vector<int64>(n + 1));
  for (int i = 0; i < m; ++i) {
    int l, r;
    cin >> l >> r;
    imos[l][r]++;
  }

  for (int l = n - 1; l >= 0; --l) {
    for (int r = 0; r <= n; ++r) {
      imos[l][r] += imos[l + 1][r];
    }
  }
  for (int l = 0; l <= n; ++l) {
    for (int r = 1; r <= n; ++r) {
      imos[l][r] += imos[l][r - 1];
    }
  }

  for (int i = 0; i < q; ++i) {
    int a, b;
    cin >> a >> b;
    cout << imos[a][b] << "\n";
  }

  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1E-9;
const long long INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
#define pb push_back
#define ll long long
string s;
int wasNorth , wasSouth , wasEast , wasWest;
int main()
{
	cin >> s;
	for(int i = 0; i < s.size(); i++)
	{
		if(s[i] == 'N')
		{
			wasNorth = 1;
		}
		if(s[i] == 'E')
		{
			wasEast = 1;
		}
		if(s[i] == 'S')
		{
			wasSouth = 1;
		}
		if(s[i] == 'W')
		{
			wasWest = 1;
		}
	}
	wasNorth ^= wasSouth;
	wasEast ^= wasWest;
	//cout << wasNorth << " " << wasEast << endl;
	if(!wasNorth && !wasEast)
	{
		cout << "Yes";
	}
	else
		cout << "No";
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace  std;
int n,m,k,sum;
int main()
{
	int i,j;
	scanf("%d%d%d",&n,&m,&k);
	if (k==0)
	{
		printf("Yes");
		return 0;
	}
	for (i=1;i<=n;i++)
	  for (j=1;j<=m;j++)//i+1,j-1
	  {
	  	int x=i+1,y=j-1;
	  	sum=0;
	  	sum=(m-j+1)*i;
	  	if (x<=n&&y>=1)  sum+=(n-x+1)*y;
	  	if (sum==k)  {printf("Yes");return 0;}
	  }
	printf("No");
}

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

int main() {
  int N,d1,d2,B;
  cin>>N;
  vector<int> zorome(N,0);
  for(int i=0;i<N;i++){
    cin>>d1>>d2;
    if(d1==d2){
      zorome.at(i)=1;
    }
  }
    for(int i=0;i<N-2;i++){
      if(zorome.at(i)==1&&zorome.at(i+1)==1&&zorome.at(i+2)==1){
        cout<<"Yes"<<endl;
        break;
      }else if(i==N-3){
        cout<<"No"<<endl;
      }
    }
}

Measured memory_bytes: 3620
from heapq import heappush, heappop
N, M = map(int, input().split())
heap = []
for a in map(int, input().split()):
    heappush(heap, a)
BC = [list(map(int, input().split())) for _ in range(M)]

BC = sorted(BC, key = lambda x: -x[1])
for b, c in BC:
    for _ in range(b):
        a = heappop(heap)
        if a < c:
            heappush(heap, c)
        else:
            heappush(heap, a)
            break

print(sum(heap))            

Measured memory_bytes: 36944
s = input()
k = int(input())
import math

if len(s) == 1:
    print(math.floor(k/2))
    exit()
if len(s) == 2:
    if s[0] == s[1]:
        print(k)
        exit()
    else:
        print(0)
        exit()
if len(set(list(s))) == 1:
    print(len(s) * k // 2)
    exit()

ans=0
last=s[0]
length=1
change=0
for i in range(1,len(s)):
    if s[i] == last:
        length+=1
    else:
        change += math.floor(length/2)
        length=1
    last=s[i]

change += math.floor(length/2)
ans=change*k
if s[0] != s[-1]:
    print(ans)
    exit()

l_length=1
last=s[0]
for i in range(1,len(s)):
    if s[i] == last:
        l_length+=1
    else:
        break
r_length=1
last=s[-1]
for i in range(len(s)-2,-1,-1):
    if s[i] == last:
        r_length+=1
    else:
        break

if l_length%2==1 and r_length%2==1:
    print(ans+k-1)
    exit()

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll h,w;
    cin >> h >> w;
    vector<string> g;
    for(int i = 0; i < h; i++){
        string str;
        cin >> str;
        g.push_back(str);
    }

    vector<vector<bool>> used(h,vector<bool>(w,false));

    ll ans = 0;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(used[i][j])continue;
            ll white = 0,black = 0;
            stack<pair<ll,ll>> st;
            st.push(make_pair(i,j));
            while(!st.empty()){
                auto x = st.top();
                st.pop();
                if(used[x.first][x.second])continue;
                used[x.first][x.second] = true;
                if(g[x.first][x.second] == '.'){
                    white++;
                }else{
                    black++;
                }
                if(x.first-1 >= 0){
                    if(!used[x.first-1][x.second] && g[x.first-1][x.second] != g[x.first][x.second]){
                        st.push(make_pair(x.first-1,x.second));
                    }
                }
                if(x.second-1 >= 0){
                    if(!used[x.first][x.second-1] && g[x.first][x.second-1] != g[x.first][x.second]){
                        st.push(make_pair(x.first,x.second-1));
                    }
                }
                if(x.first+1 < h){
                    if(!used[x.first+1][x.second] && g[x.first+1][x.second] != g[x.first][x.second]){
                        st.push(make_pair(x.first+1,x.second));
                    }
                }
                if(x.second+1 < w){
                    if(!used[x.first][x.second+1] && g[x.first][x.second+1] != g[x.first][x.second]){
                        st.push(make_pair(x.first,x.second+1));
                    }
                }
            }
            ans += black * white;
        }
    }

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

Measured memory_bytes: 3072
# 2020/01/19
# AtCoder Beginner Contest 089 - B

# Input
n = int(input())
s = list(input().split())

# Init Dictionary
chardict = dict(P = 0, W = 0, G = 0, Y = 0)

# Calc
for i in range(n):
    chardict[s[i]] = chardict[s[i]] + 1

zcnt = 0
for k in chardict.keys():
    if chardict[k] == 0:
        zcnt = zcnt + 1

ans = ""
if zcnt == 0:
    ans = 'Four'
elif zcnt == 1:
    ans = 'Three'

# Output
print(ans)


Measured memory_bytes: 3060
#include <iostream>

int main() {
  std::string s;
  std::cin >> s;
  auto p = s.begin();
  auto q = s.end() - 1;
  unsigned ans = 0;
  while (p < q) {
    if (*p == *q) {
      ++p;
      --q;
    } else {
      if (*p == 'x') {
        ++p;
        ++ans;
      } else if (*q == 'x') {
        --q;
        ++ans;
      } else {
        std::cout << -1 << std::endl;
        return 0;
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 888
#import<iostream>
int main(){int K,n,i=-1,j,k;std::cin>>K;std::cout<<(n=(K+3)/4*2);while(++i<n){std::cout<<'\n';j=-1;while(++j<n)std::cout<<((k=i%2*n+(i+j)%n)>=K?k-n:k)%K+1<<' ';}return 0;}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N;
    matP G(N,vp(0));
    rep(i,N) {
        G[i].emplace_back((i + 1)%N, 1);
        G[i].emplace_back((i * 10)%N, 0);
    }
    deque<P> deq;
    vector<bool> visited(N, false);
    deq.emplace_back(1,1);
    ll ans;
    while(true){
        P p = deq.front();
        deq.pop_front();
        //cout<<p.fi<<' '<<p.se<<endl;
        if(visited[p.fi]) continue;
        visited[p.fi] = true;
        if(p.fi == 0){
            ans = p.se;
            break;
        }
        for(P next : G[p.fi]){
            if(!visited[next.fi]){
                (next.se ? deq.emplace_back(next.fi, p.se + 1) : deq.emplace_front(next.fi, p.se));
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  cout << 24-n+24 << endl;
}


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

int main()
{
	auto a = vector<int>();
	a.push_back(1);
	for(auto i = 2; i < 32; ++i){
		int j = i * i;
		while(j <= 1000){
			a.push_back(j);
			j *= i;
		}
	}
	sort(a.begin(), a.end());
	int x;
	cin >> x;
	cout << *(upper_bound(a.begin(), a.end(), x) - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    int n;
    int[] as, bs;

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        n = sc.nextInt();
        as = new int[n];
        bs = new int[n];

        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
            bs[i] = sc.nextInt();
        }
        Arrays.sort(as);
        Arrays.sort(bs);

        int min, max;
        if (n % 2 == 0) {
            min = (as[n / 2 - 1] + as[n / 2]);
            max = (bs[n / 2 - 1] + bs[n / 2]);
        } else {
            min = as[n / 2];
            max = bs[n / 2];
        }

        out.println(max - min + 1);
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 62116
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
    
    void solve() throws IOException {
        for (int tc=1;tc>0;tc--) {
            int h=ni(),w=ni(),m=ni();
            int[] R=new int[h+1];
            int[] C=new int[w+1];
            HashSet<Integer>[]H=new HashSet[h+1];
            for (int i=1;i<=h;i++) H[i]=new HashSet();
            
            for (int i=0;i<m;i++) {
                int u=ni(),v=ni();
                R[u]++;
                C[v]++;
                H[u].add(v);
            }
            
            int rmax=-1;
            ArrayList<Integer>rm=new ArrayList();
            for (int i=1;i<=h;i++) {
                if (R[i]==rmax) rm.add(i);
                if (R[i]>rmax) {
                    rmax=R[i];
                    rm.clear();
                    rm.add(i);
                }
            }
            
            int cmax=-1;
            ArrayList<Integer>cm=new ArrayList();
            for (int i=1;i<=w;i++) {
                if (C[i]==cmax) cm.add(i);
                if (C[i]>cmax) {
                    cmax=C[i];
                    cm.clear();
                    cm.add(i);
                }
            }
            
            int ans=rmax+cmax-1;
            outer:
            for (Integer u:rm) {
                for (Integer v:cm)
                    if (!H[u].contains(v)) { ans++; break outer; }
            }
            
            out.println(ans);
        }
        out.flush();
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 143012
#include <iostream>

using namespace std;

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

    int max = 0, ans = 0;
    for (int i = 0; i < N; i++) {
        int cur;
        cin >> cur;
        ans += cur;
        if (cur > max)
            max = cur;

    }
    cout << ans - max / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> input = Arrays.asList(br.readLine().split(" "));
            List<Integer> numbers = new ArrayList<>();

            for (String s : input) {
                numbers.add(Integer.parseInt(s));
            }

            String result = "bust";
            if (numbers.get(0) + numbers.get(1) + numbers.get(2) <= 21) {
                result = "win";
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

int main(void)
{
    int n, c0 = 0, c1 = 0, c2 = 0, c3 = 0;
    cin >> n;

    rep(i, n)
    {
        string s;
        cin >> s;
        if (s == "AC")
            c0++;
        else if (s == "WA")
            c1++;
        else if (s == "TLE")
            c2++;
        else
            c3++;
    }

    cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;


signed main(){
	//cout << fixed << setprecision(10);
	string s,t; cin >> s >> t;
	int n = s.size();
	int cnt = MOD;
	rep(i,0,n-t.size()+1){
		int a = 0;
		//cout << i << endl;
		rep(j,0,t.size()){
			if(s[i+j] != t[j])a++;
		}
		chmin(cnt,a);
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
int main(int argc, char *argv[])
{
  int n;
  std::cin >> n;
  double s(0);
  for (int i = 0; i < n; i++)
  {
    int a_i;
    std::cin >> a_i;
    s += 1.0 / (double)a_i;
  }
  std::cout << 1.0 / s;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)


ll MOD = 1000000007;


int f(string x, string y) {
	vector<vector<int>> dp(x.size() + 1);
	rep(i, x.size() + 1) {
		dp[i].resize(y.size() + 1);
		rep(j, y.size() + 1) dp[i][j] = 0;
	}
	repi(i, 1, x.size() + 1) {
		repi(j, 1, y.size() + 1) {
			if (x[i - 1] == y[j - 1]) {
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else {
				dp[i][j] = max(dp[i][j - 1], max(dp[i - 1][j], dp[i - 1][j - 1]));
			}
		}
	}
	return dp.back().back();
}


int main() {
	int N;
	cin >> N;
	vector<pair<string, string>> s;
	rep(i,N){
		string a, b;
		cin >> a >> b;
		s.push_back(pair<string, string>(a, b));
	}
	rep(i, N) cout << f(s[i].first, s[i].second) << endl;
	return 0;
}



Measured memory_bytes: 6880
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

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

    vector<int> a(n), b(n);
    for (int i = 1; i <= n; i++)
    {
        b[i - 1] = l + i - 1;
        a[i - 1] = abs(l + i - 1);
    }

    int min_index = 0;
    for (int i = 1; i < n; i++)
    {
        if (a[min_index] > a[i])
        {
            min_index = i;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += b[i];
    }
    ans -= b[min_index];

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

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let t = read::<String>().chars().collect::<Vec<char>>();

    if s.len() < t.len() {
        println!("UNRESTORABLE");
        return;
    }
    let mut v = Vec::new();
    for i in 0..(s.len() + 1 - t.len()) {
        for j in 0..t.len() {
            if s[i+j] != t[j] && '?' != s[i+j] {
                break;
            }
            if j == t.len()-1 {
                v.push(i);
            }
        }
    }
    if v.len() == 0 {
        println!("UNRESTORABLE");
        return;
    }

    for i in 0..s.len() {
        if s[i] == '?' {
            if v[v.len()-1] <= i && i < v[v.len()-1] + t.len() {
                print!("{}", t[i-v[v.len()-1]])
            } else {
                print!("a");
            }
        } else {
            print!("{}", s[i]);
        }
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;
const int coin[6] = {500,100,50,10,5,1};

int main() {
    int X,Y,Z; cin >> X >> Y >> Z;
    X -= Z;
    int ans = X/(Y + Z);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		//int n = sc.nextInt();
		String s = sc.next();
		//long n = sc.nextLong();
		//double n = sc.nextDouble();
		
		String ans = s.substring(0,3);
		//for(int i = 0; i < ; i++)

		System.out.println(ans);
		//System.out.println("No");
		

	}
}


Measured memory_bytes: 35720
n,t = list(map(int,input().split()))
 
minc = -1
for i in range(n):
  ci,ti = list(map(int,input().split()))
  if ti <= t:
    if minc == -1:
      minc = ci
    else:
      minc = min(minc,ci)
 
if minc == -1:
  print("TLE")
else:
  print(minc)

Measured memory_bytes: 38256
mod = 1000000007
n = int(input())
arr = list(map(int, input().split()))
temp = arr[:]
for i in range(n - 2, -1, -1) :
	temp[i] += temp[i + 1]
ans = 0
for i in range(n - 1) :
	ans = (ans + (arr[i] * temp[i + 1]) % mod) % mod
print(ans % mod)

Measured memory_bytes: 31764
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 11

typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
}stack;

void initialize_stack(stack *stk);
void print_stack(stack *stk);
void push(stack *stk, char x);
void pop(stack *stk);

stack stk;

int main(void){
    char array[SIZE];
    int i=0;

    initialize_stack(&stk);
    scanf("%s",array);
    
    for(i=0;i<strlen(array);i++){
        if(array[i] == '0' || array[i] == '1'){
            push(&stk,array[i]);
        }else if(array[i] == 'B'){
            pop(&stk);
        }
    }

    print_stack(&stk);
    return 0;
}

void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[0]);
}

void push(stack *stk,char x){
    if(stk->count >= stk->size){
        printf("Error: stack overflow. (x= %c)\n",x);
    }else{
        *(stk->top) = x;
        stk->top++;
        stk->count++;
    }
}

void pop(stack *stk){
    if(stk->count>=1){
        stk->top--;
        *(stk->top) = '\0';
        stk->count--;
    } 
}

void print_stack(stack *stk){
    char *p;
    int i;
    p = stk->data;
    for(i=0;i<stk->count;i++){
        printf("%c",*p++);
    }
    printf("\n");
}

Measured memory_bytes: 1608
#include <stdio.h>
int W,H,a[50][50];
void visit(int i,int j){
  int r,ni,nj;
  int di[8]={0,-1,0,1,1,-1,1,-1};
  int dj[8]={1,0,-1,0,1,1,-1,-1};
  a[i][j]=0;
  for(r=0;r<8;r++){
    ni=i+di[r];
    nj=j+dj[r];
    if(ni<W&&nj<H&&ni>=0&&nj>=0){
    if(a[ni][nj]==1) visit(ni,nj);
    }
  }
}

main(){
  int i,j,c;
  while(1){
    c=0;
    scanf("%d%d",&H,&W);
    if(W==0&&H==0) break;
    for(i=0;i<W;i++){
      for(j=0;j<H;j++){
	scanf("%d",&a[i][j]);
      }
    }
    for(i=0;i<W;i++){
      for(j=0;j<H;j++){
	if(a[i][j]==1){
	  c++;
	  visit(i,j);
	}
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 0
#import<bits/stdc++.h>
using namespace std;
int i,k,m,n,c[100005],b[100005];
main()
{
scanf("%d%d",&n,&m);
for(;m--;b[k]=1)scanf("%d",&k);
for(*c=1;i++<n;)c[i]=b[i]?0:((i>1?c[i-2]:0)+c[i-1])%1000000007;
printf("%d",c[n]);
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CBase2Number solver = new CBase2Number();
        solver.solve(1, in, out);
        out.close();
    }

    static class CBase2Number {
        private static final long MASK = 0xAAAAAAAAAAAAAAAAL;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            out.println(Long.toString((n + MASK) ^ MASK, 2));
        }

    }
}



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

int main() {
    int n, a;
    cin >> n >> a;
    int required_coin1 = n % 500;
    if (required_coin1 <= a){
        cout << "Yes" <<endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3536
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    L = il()
    print(min(abs(sum(L[:n]) - sum(L[n:])) for n in range(N+1)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll > P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    ll n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    ll ans = 0;
    ll before = a[0];
    ll dx;
    for(int i=1;i<n;i++){
        if(before-a[i]>0){
            dx = before-a[i];
        }else{
            dx = 0;
        }
        ans += dx;
        before = a[i] + dx;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b>=c){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }


}


Measured memory_bytes: 256
while true
  l = gets.to_i
  if l == 0
    break
  end

  i = 0
  sum = 0
  sm = 0
  c = 0

  while i < 12
    mm = gets.chomp
    mm = mm.split(" ")
    sum += mm[0].to_i - mm[1].to_i
    if c == 0
      if sum >= l
        sm = i + 1
        c = 1
      end
    end
    i += 1
  end
  if c != 0
    puts sm
  else
    puts "NA"
  end
end

Measured memory_bytes: 6100
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();
        if(op.equals("+")){
            System.out.println((a+b));
        }else{
            System.out.println((a-b));
        }
        sc.close();
    }
}

Measured memory_bytes: 22612
n = int(input())
d = {}
for i in range(1, n+1):
    s, p = input().split()
    if s in d:
        d[s].append((int(p), i))
    else:
        d[s] = [(int(p), i)]

d = sorted(d.items(), key=lambda x: x[0])

for c, x in d:
    x.sort(reverse=True)
    for i in x:
        print(i[1])

Measured memory_bytes: 3064