akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n, l;
	int min=1000;
	int add=0;
	int sum=0;

	scanf("%d %d",&n,&l);

	for(int i=l; i<l+n; i++){
		sum+=i;
		if(min>abs(i)){
			min=abs(i);
			sum-=i;
			sum+=add;
			add=i;
		}
	}

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

	return 0;
}

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

int main(){
    string s;
    cin >> s;
    for(int i=0; i<s.size()-1; i++){
        if(s[i] == s[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

int main(){
	ll n, a; cin >> n >> a;
	cout << n*n - a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <utility>
#include <iomanip>
#define input(x) cin >> x
#define print(x) cout << x << endl
#define rep(a,n) for(int i = a; i < n; i++)
#define ll long long int
using namespace std;

int main(){
    string s; int ans = 700;
    input(s);
    rep(0,3){
        if (s[i]=='o') ans += 100;
    }
    print(ans);
    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  int p[n];
  int count = 0;
  for(int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for(int i = 0; i < n - 1; i++) {
    if(p[i] != i + 1) {
      count++;
    }
  }
  if(count <= 2) {
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100001
 
 struct P{
          char name[10];
          int time;
          };

 struct P q[MAX];
 int head,tail;

 int init(){
        return head=tail=0;
        }

 int empty(){
        return head==tail;
        }

 int full(){
        return head==(tail+1)%MAX;
        }

 void enqueue(struct P x){
        if(full())return;

        q[tail]=x;
        tail=(tail+1)%MAX;
        }

 struct P dequeue(){
        if(empty())return;

        struct P x=q[head];
        head=(head+1)%MAX;
        return x;
        }

 int main(){
      int n,lim,ttt,sum=0,i;
      init();
      scanf("%d%d",&n,&lim);
      for(i=0;i<n;i++){
                scanf("%s %d",&q[i].name,&q[i].time);
                }
      head=0;tail=n;
      while(head != tail){
                     struct P c=dequeue();
                     ttt=(c.time<lim)?c.time:lim;
                     c.time-=ttt;
                     sum+=ttt;
                     if(c.time>0)enqueue(c);
                     else {printf("%s %d\n",c.name,sum);}
                     }
      return 0;
      }




      


Measured memory_bytes: 3304
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// llの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
using namespace std;
void dfs(){ 
  return;
}
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  ll n,k; cin >> n >>k;
  vector<ll> a=vector<ll>(n);
  vector<ll> time=vector<ll>(n+1,-1);
  vector<ll> mitisuzi;
  REP(i,n) cin >> a[i];
  ll v=0;
  mitisuzi.PB(0);
  do{
    time[v]=SIZE(mitisuzi); 
    mitisuzi.PB(a[v]);
    v=a[v]-1;
  }while(time[v]==-1); 
  ll c=SIZE(mitisuzi)-time[v];
  ll l=time[v];
  //cout << c << l;
  //for(int i:mitisuzi) cout << i << endl;
  if(k<=l) cout << mitisuzi[k] << endl;
  else{
    k=k-l;
    k%=c;
    cout << mitisuzi[l+k]<< endl;
  }
  

  return 0;
}


Measured memory_bytes: 8436
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
typedef pair<int, int> P;
vector<P> G[100010];
bool head[100010];
int d[100010];
bool dfs(int x, int head, int depth) {
    //visited[x] = true;
    d[x] = depth;
    for(auto to: G[x]) {
        if(d[to.first] == INF) {
            if(!dfs(to.first, head, depth + to.second)) 
            return false;
        } else if(d[to.first] !=  depth + to.second) return false;

        
    }
    return true;
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    rep(i, 100010) head[i] = true;
    rep(i, M) {
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        G[l].push_back({r,  d});
        head[r] = false;
    }
    rep(i, N) d[i] = INF;
    rep(i, N) {
        if(!head[i]) continue;
        if(!dfs(i, i, 0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, N) {
        if(!head[i] && d[i] == INF) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


    return 0;
}


Measured memory_bytes: 10880
#include <iostream>
#include <cstdlib>
using namespace std;
int main(void){
    int n,t=0,x=0,y=0;
    string ans = "Yes";
    cin>>n;
    for(int i=0;i<n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        
        if(a-t>=abs(b-x)+abs(c-y)&&(a-t)%2==(abs(b+c-x-y))%2){
            t=a;
            x=b;
            y=c;
        }else{
            ans="No";
            i=n;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int H, W, i, j;
    char ANS[52][52], S[51];

    scanf("%d %d", &H, &W);

    for(i = 0; i < W+2; i++){
        ANS[0][i] = '0';
        ANS[H+1][i] = '0';
    }

    for(i = 1; i <= H; i++){
        ANS[i][0] = '0';
        scanf("%s", S);
        for(j = 0; j < W; j++){
            if(S[j] == '.') ANS[i][j + 1] = '0';
            else ANS[i][j + 1] = '#';
        }
        ANS[i][W+1] = '0';
    }

    for(i = 1; i <= H; i++){
        for(j = 1; j <= W; j++){
            if(ANS[i][j] == '#'){
                if(ANS[i-1][j-1] != '#') ANS[i-1][j-1] += 1;
                if(ANS[i-1][j  ] != '#') ANS[i-1][j  ] += 1;
                if(ANS[i-1][j+1] != '#') ANS[i-1][j+1] += 1;
                if(ANS[i+1][j-1] != '#') ANS[i+1][j-1] += 1;
                if(ANS[i+1][j  ] != '#') ANS[i+1][j  ] += 1;
                if(ANS[i+1][j+1] != '#') ANS[i+1][j+1] += 1;
                if(ANS[i  ][j-1] != '#') ANS[i  ][j-1] += 1;
                if(ANS[i  ][j+1] != '#') ANS[i  ][j+1] += 1;
            }
        }
    }

    for(i = 1; i <= H; i++){
        for(j = 1; j <= W; j++){
            printf("%c", ANS[i][j]);
        }
        printf("\n");
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] H = new int[N];
		for(int i=0; i<H.length; i++) {
			H[i] = scan.nextInt();
			
		}
		scan.close();
		int r=1;
		
		for(int i=1; i<N; i++) {
			for(int j=0; j<i; j++) {
				if(H[i]<H[j]) {
					break;
				}
				if(j==i-1) {
					r++;
				}
			}
		}

		System.out.println(r);

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int>> comp;
const int max_mask = (1<<21);
const int mod = 1e9 + 7;
int dp[21][max_mask];


int count(int i, int mask) {
	if(i == n) {
		return 1;
	}
	if(dp[i][mask] != -1) {
		return dp[i][mask];
	}
	int r = 0;
	for(int j = 0; j < m; ++j) {
		if(((mask >> j)&1) and comp[i][j]) {
			int new_mask = mask^(1 << j);
			r += count(i + 1, new_mask);
			r %= mod;
		}
	}
	return dp[i][mask] = r;
}


int main() {
	cin >> n;
	m = n;
	comp.assign(n, vector<int>(m));
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			cin >> comp[i][j];
		}
	}
	memset(dp, -1, sizeof(dp));

	int mask = (1 << m) - 1;

	cout << count(0, mask) << endl;


    return 0;
}

Measured memory_bytes: 175636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
ll dp[N],a[N],sum[N];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum[i]=(i>2?sum[i-2]:0)+a[i];
    }
    for(int i=2;i<=n;i++){
        if(i&1) dp[i]=max(dp[i-1],dp[i-2]+a[i]);
        else dp[i]=max(sum[i-1],dp[i-2]+a[i]);
    }
    cout<<dp[n];
}


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

int main(){
  string s, t, u;
  int a, b;
  cin>>s >>t >>a >>b >>u;
  if(s==u){
    cout<<a-1<<" "<<b<<endl;
  }else{
    cout<<a<<" "<<b-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

// Aliases
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
using ull = unsigned long long;

using std::cout;
using std::cerr;
using std::cin;
using std::endl;
using std::string;
using std::vector;
using std::array;
template <class T>
using matrix = vector<vector<T>>;
template <class T>
constexpr T inf = std::numeric_limits<T>::max();
template <class T>
constexpr T neg_inf = -std::numeric_limits<T>::max();
template <class T>
constexpr T pi = static_cast<T>(3.141592653589793);

template <class T = i64>
vector<T> read_vector(const u64 n)
{
    vector<T> vec;
    vec.reserve(n);
    for (u64 i = 0; i < n; i++)
    {
        T v;
        cin >> v;
        vec.emplace_back(v);
    }

    return vec;
}

template <class T>
void print(const vector<T>& vec, const bool new_line = false)
{
    const u64 n = vec.size(); 
    if (new_line)
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << '\n'; }
        }
    }
    else
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << ' '; }
        }
    }

    cout << endl;
}

int main()
{
    ll n;
    cin >> n;
    ll min_cnt = n;
    bool flag = false;
    for (ll i = 2; i <= std::sqrt(n); i++)
    {
        if (n % i == 0)
        {
            min_cnt = std::min(min_cnt, i + n / i);
            flag = true;
        }
    }
    
    if (flag)
    {
        cout << min_cnt - 2 << endl;
    }
    else
    {
        cout << min_cnt - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys

a = []
for i in range(5):
	a.append(int(raw_input()))
k = int(raw_input())
b = np.array(a)

for i in range(5):
	for j in range(5-i):
		if a[i+j] - a[i] > k:
			print ':('
			sys.exit()

print 'Yay!'

Measured memory_bytes: 16084
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

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

    map<char, int> mci;
    REP(i, N) {
        cin >> S;
        mci[S[0]]++;
    }

    ll ans = 0;
    vector<char> target = {'M', 'A', 'R', 'C', 'H'};
    REP(i, 5) REP(j, i) REP(k, j)
        ans += (ll)mci[target[i]] * mci[target[j]] * mci[target[k]];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
    int len;
    char S[20],T[20];
    scanf("%s%s",S,T);
    len=strlen(S);
    for(int i=0;i<len;++i){
        if(S[i]!=T[i]){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");

    return 0;
}

Measured memory_bytes: 2084
#include <stdio.h>
int main(void){
    // Here your code !
    int h,w;
    char a;
    int i;
    int j;
    scanf("%d %d", &h, &w);
    for( i = 0; i < h + 2; ++i){
        for( j = 0; j < w + 2; ++j ){
            if( i == 0  ||  i == h+1 || j == 0 || j == w+1 ){
                printf("#");
            }else{
                scanf("%c", &a);
                if( a != '\n'){
                    printf("%c", a);
                }else{
                    scanf("%c", &a);
                    printf("%c", a);
                }
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  string s;
  cin >> s;

  int n = s.size();
  if(s[n-1] == 's') cout << s << "es" << endl;
  else cout << s << "s" << endl;

  return 0;
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int n, ans = 99999999, tmp = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, 110) {
        rep(j, n) { tmp += pow(a[j] - i, 2); }
        ans = min(ans, tmp);
        tmp = 0;
    }

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

Measured memory_bytes: 3628
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(map(int, input().split()), reverse=True)

AB = [0]*(X*Y)
i = 0
for a in A:
  for b in B:
    AB[i] = a+b
    i += 1
AB.sort(reverse = True)

ans = [0]*(K*Z)
j = 0
for ab in AB[:K]:
  for c in C:
    ans[j] = ab+c
    j += 1

ans.sort(reverse=True)
print(*ans[:K], sep="\n")

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

typedef valarray<double> Point;

double dot(const Point &a, const Point &b){
	return (a * b).sum();
}

double dist2(const Point &a, const Point &b){
	return dot(a - b, a - b);
}

int n, q;
Point p[50];
double r[50];
long long l[50];
Point s, t;

long long calc()
{
	static const double EPS = 1e-12;
	Point v = (t - s);
	long long res = 0;
	for (int i = 0; i < n; i++){
		double left = 0.0, right = 1.0;
		for (int j = 0; j < 100; j++){
			double mid = (left + right) / 2;
			double d1 = dist2(s + v * mid, p[i]);
			double d2 = dist2(s + v * (mid + EPS), p[i]);
			if (d1 > d2) left = mid;
			else right = mid;
		}
		//printf("%.20f\n", dist2(s + v * left, p[i]));
		if (dist2(s + v * left, p[i]) < r[i] * r[i] + 1e-4) res += l[i];
	}
	return res;
}

int main()
{
	double x, y, z;
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; i++){
		scanf("%lf %lf %lf %lf %lld", &x, &y, &z, r + i, l + i);
		p[i] = {x, y, z};
	}
	for (int i = 0; i < q; i++){
		scanf("%lf %lf %lf", &x, &y, &z);
		s = {x, y, z};
		scanf("%lf %lf %lf", &x, &y, &z);
		t = {x, y, z};
		printf("%lld\n", calc());
	}
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<ll,ll>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):0;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;
        while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}
        return ans;
    }
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

	int a[N],b[N],c[N];
	void main()
	{
		int n=qread();write(n*n*n);
	}
};
int main()
{
	srand(time(0));
	mine::main();
}

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

int main() {
    int n, m;
    int matrix[100][100];
    int vector[100];
    int answer[100];

    cin >> n >> m;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++)  {
            cin >> matrix[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        cin >> vector[i];
    }
    for(int i = 0; i < n; i++){
        answer[i] = 0;
        for(int j = 0; j < m; j++){
            answer[i] += (matrix[i][j] * vector[j]);
        }
    }
    for(int i = 0; i < n; i++){
        cout << answer[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>

int main(void){
    int N, A, B;
    int taku, buss, ans;

    scanf("%d %d %d", &N, &A, &B);

    taku = B;
    buss = A * N;
    if(taku<buss)
        ans = taku;
    else
        ans = buss;

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



Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(){
    int a, b, c,d;
    while(scanf("%d%d%d%d", &a, &b, &c, &d) != -1){
        int sum = 0;
        sum += min(a, b);
        sum += min(c, d);

        printf("%d\n", sum);
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define en "\n"
using namespace std;

int main()
{
    int n,k,len,tm,ans=0;
    cin>>n>>k;
    k--;
    for(int i=0;i<n;i++)
    {
        cin>>tm;
        if(tm==1)len=i;
    }
    ans+=(len/k+(n-len-1)/k);
    if(len%k+(n-len-1)%k<=k&&len%k+(n-len-1)%k)ans++;
    else if(len%k+(n-len-1)%k>k)ans+=2;

    cout<<ans<<en;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int N,i,j,v,k;
  int A[1000];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);
  for(i=1;i<=N-1;i++){
    v=A[i];
    j=i-1;
  while(j>=0&&A[j]>v){
    A[j+1]=A[j];
    j--;
    A[j+1]=v;
  }
  for(k=0;k<N-1;k++){
    printf("%d ",A[k]);
  }
  printf("%d\n",A[N-1]);
  }
  return 0;
}


Measured memory_bytes: 2084
N = int(input())
A = [int(_) for _ in input().split()]

from collections import Counter

def solve(N, A):
    cs = Counter(A)
    k = list(cs.keys())
    v = list(cs.values())
    # print(k, v)
    if len(k) == 1 and A[0] == 0:
        return True
    if len(k) == 3 and k[0] ^ k[1] ^ k[2] == 0 and v[0] == v[1] == v[2]:
        return True
    if len(k) == 2 and k[0] == 0 and v[0] * 2 == v[1]:
        return True
    if len(k) == 2 and k[1] == 0 and v[1] * 2 == v[0]:
        return True
    return False

if solve(N, A):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 60784
#import <iostream>
using namespace std;

int calc(int x,int y){
	if(1<=y && y<10)return x*10+y;
	else if(10<=y && y<100)return x*100+y;
	else if(100<=y && y<1000)return x*1000+y;
	else if(1000<=y && y<100000)return x*10000+y;
	else return x*100000+y;
}

int main(){
	int n,min1=2000000000,min2=2000000000,min3=2000000000,check;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i!=j){
				check=calc(a[i],a[j]);
				if(check<=min1){
					min3=min2;
					min2=min1;
					min1=check;
				}else if(check<=min2){
					min3=min2;
					min2=check;
				}else if(check<min3){
					min3=check;
				}
			}
		}
	}
	cout << min3 <<endl;
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
string S,T;
int A[10060];
int B[10060];
int L[10060],R[10060];
int N;
int n1,n0;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S>>T;
	N=S.size();
	
	n1=count(ALL(S),'1');
	n0=count(ALL(T),'0');
	if(n1 && n0==N) return _P("-1\n");
	if(S==T) return _P("0\n");
	
	int mi=1<<30;
	for(int loop=0;loop<2;loop++) {
		int pre=-1;
		FOR(i,5*N) {
			A[i]=S[i%N]=='1';
			B[i]=T[i%N]=='1';
			if(B[i]) pre=i;
			L[i]=pre;
		}
		pre=5*N;
		for(i=5*N-1;i>=0;i--) {
			if(B[i]) pre=i;
			R[i]=pre;
		}
		
		//left
		FOR(i,N) {
			int tar=0,shiftmi=101010;
			vector<pair<int,int>> V;
			FOR(j,N) {
				x=2*N+j;
				y=2*N+j-i;
				if(A[x]!=B[y]) {
					tar++;
					if(L[x]<y) V.push_back({y-L[x],R[x]-x});
				}
			}
			if(V.empty()) {
				shiftmi=0;
			}
			else {
				int RR[2020]={};
				int lma=0,rma=0;
				sort(ALL(V));
				FORR(v,V) lma=max(lma,v.first),rma=max(rma,v.second);
				shiftmi=min(lma,rma);
				for(r=V.size()-1;r>=0;r--) {
					RR[r]=max(RR[r+1],V[r].second);
					shiftmi=min(shiftmi,V[r].first+RR[r+1]);
				}
			}
			mi=min(mi,tar+i+2*shiftmi);
		}
		reverse(ALL(S));
		reverse(ALL(T));
	}
	
	
	cout<<mi<<endl;
	
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
  char str[256];
  char result[65536];
  int m,f,r;
  int i;

  memset(result, 0, sizeof(result));
  for (;;) {
    fgets(str, sizeof(str), stdin);
    sscanf(str, "%d %d %d", &m,&f,&r);
    if ((m&f&r) == -1) break;

    if ((m == -1 || f == -1) || (m+f < 30)) {
      strncat(result, "F", 1);
      continue;
    }

    if (m+f >= 80) {
      strncat(result, "A", 1);
    } else if (m+f >= 65) {
      strncat(result, "B", 1);
    } else if (m+f >= 50) {
      strncat(result, "C", 1);
    } else if ((m+f >= 30) && (r >= 50)) {
      strncat(result, "C", 1);
    } else {
      strncat(result, "D", 1);
    }
  }
  for (i=0; i< strlen(result); i++) {
    printf("%c\n", result[i]);
  }
  return 0;
}

Measured memory_bytes: 684
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;


ll bs[100000+10];
ll ls[100000+10];
ll us[100000+10];
int n;
ll X;

int is[100000+10]; // xxxの降順
int used[100000+10];
int counter;
ll cs[100000+10];


bool isOK(ll m) {
  ll D = 0;
  REP(i, n) {
    D -= ls[i] * bs[i];
  }
  ll r = m % X;
  if(r != 0) {
    REP(i1, n) { // is[i1]は中途半端な点取る
      int ii1 = is[i1];
      ll DD = D;
      if(i1 < m/X) {
        DD += cs[m/X+1] - (ls[ii1]*bs[ii1]+us[ii1]*(X-bs[ii1]));
      } else {
        DD += cs[m/X];
      }
      if(r <= bs[ii1]) {
        DD += ls[ii1]*r;
      } else {
        DD += ls[ii1]*bs[ii1] + us[ii1]*(r-bs[ii1]);
      }
      if(DD >= 0) {
        // cerr << "> " << m << " " << i1 << " " << D << " " << DD << endl;
        return true;
      }
    }
    return false;
  } else {
    D += cs[m/X];
    return D >= 0;
  }
}

int main(void) {
  scanf("%d%lld", &n, &X);
  REP(i, n) {
    scanf("%lld%lld%lld", &bs[i], &ls[i], &us[i]);
    is[i] = i;
  }
  sort(is, is + n, [](int i1, int i2) { return bs[i1]*ls[i1]+(X-bs[i1])*us[i1] > bs[i2]*ls[i2]+(X-bs[i2])*us[i2]; });
  REP(i, n) {
    cs[i+1] = cs[i] + bs[is[i]]*ls[is[i]]+(X-bs[is[i]])*us[is[i]];
    // cerr << is[i] << " " << cs[i+1] - cs[i] << endl;;
  }

  ll left = -1;
  ll right = X * n;
  while(left + 1 < right) {
    ll md = (left + right) / 2;
    if(isOK(md)) {
      right = md;
    } else {
      left = md;
    }
  }
  cout << right << endl;
  
  return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    long long i,n,ans,cnt1,cnt2,cnt3,mod=1e9+7;
    cin >> n;
    if(n == 1)cout << 0;
    else
    {
        cnt1=cnt2=cnt3=1;
        for(i=1;i<=n;i++)
        {
            cnt1=(cnt1*10)%mod;
            cnt2=(cnt2*9)%mod;
            cnt3=(cnt3*8)%mod;
        }
        ans=(cnt1+cnt3-2*cnt2)%mod;
        cout << (ans+mod)%mod;;
    }
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	ll n,t;
	cin >> n>>t;
	ll ans  = 0;
	vector<ll> T(n);
	for(int i = 0;i<n;i++)
	{
		cin >> T[i];
	}

	for(int i = 0;i<n-1;i++)
	{
		ans +=	min(t,T[i+1]-T[i]);
	}
	cout<<ans+t<<endl;



	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
int main() {
  ll X, t;
  cin >> X >> t;
  cout << max<ll>(X - t, 0) << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

vector<ll> a, result, lis;
vector<vector<ll>> adj;

void dfs(ll n=0, ll p=-1) {
  auto pos = lower_bound(all(lis),a[n]);
  ll pos_def = *pos;
  *pos = a[n];
  result[n] = lower_bound(all(lis),LLINF) - lis.begin();
  for (auto x: adj[n]) {
    if (x==p) continue;
    dfs(x, n);
  }
  // cout << n << ":"; debug(all(lis));
  *pos = pos_def;
}

int main() {
  int N; cin >> N;
  a.resize(N); rep(i,N) cin >> a[i];
  adj.resize(N);
  rep(i,N-1) {
    ll u, v; cin >> u >> v; u--; v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  result.resize(N); lis.resize(N,LLINF);
  dfs();
  rep(i,N) cout << result[i] << endl;
  // cout << result << endl;
  return 0;
}

Measured memory_bytes: 30428
#include <stdio.h>
#define Not_Found 0
#define Found 1
#define MAX 10000
#define max 500

int n;

int LinerSearch(int *,int);

int main(){

	int S[MAX],T[max],q,count,i;

	scanf("%d",&n);
	for( i = 0; i < n; i++) scanf("%d",&S[i]);
	scanf("%d",&q);
	for( i = 0; i < q; i++){
		scanf("%d",&T[i]);
		if(LinerSearch(S,T[i]) == Found) count++;
	}

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

	return 0;

}


int LinerSearch(int *A,int key){

	int i = 0;
	
	for( i = 0; i < n; i++){
		 if(A[i] == key) return Found; 
	}
	return Not_Found;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  char x, y;
  cin >> x >> y;

  if (x < y) cout << "<" << endl;
  else if (x == y) cout << "=" << endl;
  else cout << ">" << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数
int n[1000][1000];
int v[1000][1000];

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int h, w;
	char a[1000][1001];
	//*
	scanf("%d%d", &h, &w);
	REP(i, h) {
		scanf("%s", &a[i]);
	}
	/*/
	h = 5;
	w = 10;
	REP(i, h) {
		REP(j, w) {
			a[i][j] = '.';
			if (i == 0 && j == 1)a[i][j] = '#';
		}
	}
	//*/
	REP(i, h) {
		REP(j, w) {
			if (a[i][j] == '#') {
				n[i][j] = 0;
				continue;
			}
			n[i][j] = 1e9;
		}
	}

	REP(i, h) {
		REPS(j, w-1) {
			if (n[i][j] < n[i][j - 1] - 1) {
				RREP(k, j) {
					if (n[i][k] <= n[i][k + 1] + 1)break;
					n[i][k] = n[i][k + 1] + 1;
				}
			}
		}
	}
	/*
	REP(i, h) {
		REP(j, w) {
			printf("%d", n[i][j]);
		}
		puts("");
	}
	puts("");
	//*/
	REP(i, h) {
		RREP(j, w-1) {
			if (n[i][j] < n[i][j + 1] - 1) {
				FOR(k, j+1, w) {
					if (n[i][k] <= n[i][k - 1] + 1)break;
					n[i][k] = n[i][k - 1] + 1;
				}
			}
		}
	}
	/*
	REP(i, h) {
		REP(j, w) {
			printf("%d", n[i][j]);
		}
		puts("");
	}
	puts("");
	//*/
	REP(i, w) {
		REPS(j, h - 1) {
			if (n[j][i] < n[j-1][i] - 1) {
				RREP(k, j) {
					if (n[k][i] <= n[k+1][i] + 1)break;
					n[k][i] = n[k+1][i] + 1;
				}
			}
		}
	}
	/*
	REP(i, h) {
		REP(j, w) {
			printf("%d", n[i][j]);
		}
		puts("");
	}
	puts("");
	//*/
	REP(i, w) {
		RREP(j, h-1) {
			if (n[j][i] < n[j + 1][i] - 1) {
				FOR(k, j+1, h) {
					if (n[k][i] <= n[k - 1][i] + 1)break;
					n[k][i] = n[k - 1][i] + 1;
				}
			}
		}
	}
	/*
	REP(i, h) {
		REP(j, w) {
			printf("%d", n[i][j]);
		}
		puts("");
	}
	puts("");
	//*/

	int ans = 0;
	REP(i, h) {
		REP(j, w) {
			ans = Max(ans, n[i][j]);
		}
	}
	PRINTD(ans);
}


Measured memory_bytes: 6912
#[allow(dead_code)]
fn main() {
    let s: Vec<i64> = i::s().iter().map(|c| *c as i64 - '0' as i64).collect();

    let case = (0..s.len() - 1).fold(1, |x, _| x * 2);
    let mut ans = 0;
    for mut i in 0..case {
        let mut cur = s[0];
        for j in 1..s.len() {
            if i % 2 == 1 {
                ans += cur;
                cur = s[j];
            } else {
                cur = cur * 10 + s[j];
            }
            i >>= 1;
        }
        ans += cur;
        //println!("{}", ans);
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Dice dice = new Dice(sc);
        String[] point = sc.next().split("");
        for(String p:point){
            dice.roll(p);
        }
        System.out.println(dice.dice.get(0));
    }
}

class Dice{
    static ArrayList<String> dice = new ArrayList<>();
    static final int[] EAST = {2,5,3,0};
    static final int[] WEST = {3,5,2,0};
    static final int[] SOUTH = {1,5,4,0};
    static final int[] NORTH = {4,5,1,0};
    static String g;
    
    public Dice(Scanner sc){
        for(int i = 0; i < 6; i++){
            dice.add(sc.next());
        }
    }
    public static void roll(String point){
        g = dice.get(0);
        switch(point){
            case "E":
                for(int i:EAST){
                    g = dice.set(i,g);
                } break;
            case "W":
                for(int i:WEST){
                    g = dice.set(i,g);
                } break;
            case "S":
                for(int i:SOUTH){
                    g = dice.set(i,g);
                } break;
            case "N":
                for(int i:NORTH){
                    g = dice.set(i,g);
                } break;
        }
    }
}

Measured memory_bytes: 26020
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
using namespace std;
#define MOD 1000000007
class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}


int main() {
	double n, t, a;
	cin >> n >> t >> a;
	double *h = new double[(int)n];
	int num;
	double min = INT_MAX;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		if (abs(a - (t - h[i] * 0.006)) < min) {
			min = abs(a - (t - h[i] * 0.006));
			num = i + 1;
		}
	}
	cout << num;
	



	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a[5],k;
	scanf("%d",&a[0]);
	scanf("%d",&a[1]);
	scanf("%d",&a[2]);
	scanf("%d",&a[3]);
	scanf("%d",&a[4]);
	int min=9,i=0,t=0,n=0,s=0;
	for(i=0;i<5;i++)
	{
		s=a[i]%10;
		if(min>s&&s!=0)
		{
			min=s;
			t=i;
		}
		
	}
	for(i=0;i<5;i++)
	{
		s=a[i]%10;
		if(s&&i!=t)
		{
			n=n+10-s+a[i];
		}
		else
		{
			n=n+a[i];
		}
		
	}
	printf("%d\n",n);
	
	return 0;
	
 } 

Measured memory_bytes: 128
N,Q=map(int,input().split())
S=input()
t=[0]*(N+1)
for i in range(N):
  t[i+1]=t[i] +(1 if S[i:i+2]=='AC' else 0)
for j in range(Q):
  l,r=map(int,input().split())
  print(t[r-1]-t[l-1])

Measured memory_bytes: 7748
'use strict'
function main(input) {
  let ans = -1
  let arr = []
  const calc = (p, n) => p > n ? p + n * 2 : n + p * 2

  input = input.trim().split('\n')
  const NK = input[0].split(' ').map(v => v - 0)
  input = input[1].split(' ').map(v => v - 0)
  for (let i = NK[1] - 1; i < NK[0]; i++) {
    const j = i - NK[1] + 1
    const p = input[j] < 0 ? Math.abs(input[j]) : 0
    const n = input[i] > 0 ? Math.abs(input[i]) : 0
    const move = calc(p, n)
    if (!~ans || move < ans) ans = move
  }
  console.log(~ans ? ans : 0)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 19532
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <queue>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << endl;
}


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

int main() {
  int r, c, M[101][101];

  cin >> r >> c;
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++) cin >> M[i][j];

  for (int i = 0; i < r; i++) M[i][c] = 0;
  for (int j = 0; j < c; j++) M[r][j] = 0;
  M[r][c] = 0;
  
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++) {
      M[i][c] += M[i][j];
      M[r][j] += M[i][j];
      M[r][c] += M[i][j];
    }

  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      if(j) cout << " ";
      cout << M[i][j];
    }
    
  cout << endl;
  
  }

  return 0;
}

Measured memory_bytes: 3124
#include<stdio.h>
int main(void){
	int N,i,j,ans,max,min,flag=0;
	scanf("%d",&N);
	int A[N];
	for(i=0;i<N;i++){
		scanf("%d",A+i);
	}
	min = A[0];
	for(i=1;i<N;i++){
		ans = A[i]-min;
		if(flag==0){
			max = ans;
			flag=1;
		}
		if(max < ans) max = ans;
		if(min > A[i]) min = A[i];
	}
	printf("%d\n",max);
	return 0;
}


Measured memory_bytes: 2624
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define REPS(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define RREP(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define RREPS(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define BIT(n) ((int)(1) << (n))
#define ALL(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
  int n,r;
  cin >> n >> r;
  if(n >= 10){
	cout << r << endl;
  } else {
    cout << r + 100 * (10 - n) << endl;
  }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_B
 * 
 * @author chrone
 * 
 */
public class Main {
    
    private final static String SPACE = " ";
    
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            while ((sStr = stdReader.readLine()) != null) {
                String[] inputs = sStr.split(" ");
                
                double r = Double.valueOf(inputs[0]);

                String area = String.format("%.5f", r*r*Math.PI);
                System.out.println(area);
                System.out.print(SPACE);
                String length = String.format("%.5f", 2*Math.PI*r);
                System.out.print( length );

            }
            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 24656
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> c(H);
	vector<vector<int>> n(H, vector<int>(W, 0)), s(H + 1, vector<int>(W + 1, 0));
	for (int i = 0; i < H; i++)cin >> c[i];
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++) {
		n[i][j] = c[i][j] - '0';
	}
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++) {
		s[i + 1][j + 1] = s[i][j + 1] + s[i + 1][j] - s[i][j] + n[i][j];
	}

	ll ans = INF;
	for (int i = 0; i < (1 << (H - 1)); i++) {
		//i の n bitが立っている -> nとn+1の間で割る
		vector<int> div,pos;
		for (int j = 0; j <= H; j++) {
			if (i & (1 << j))pos.push_back(j + 1);
		}
		pos.push_back(H);
		pos.push_back(0);
		sort(pos.begin(), pos.end());
		div = vector<int>(pos.size() - 1, 0);

		ll tmp = div.size() - 1;
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < div.size(); k++) {
				div[k] += s[pos[k + 1]][j + 1] - s[pos[k]][j + 1] - s[pos[k + 1]][j] + s[pos[k]][j];
			}
			if (*max_element(div.begin(), div.end()) > K) {
				for (int k = 0; k < div.size(); k++) {
					div[k] = 0;
				}
				tmp++;
				for (int k = 0; k < div.size(); k++) {
					div[k] += s[pos[k + 1]][j + 1] - s[pos[k]][j + 1] - s[pos[k + 1]][j] + s[pos[k]][j];
				}
				for (int k = 0; k < div.size(); k++) {
					if (div[k] > K)tmp += INF;
				}
			}
		}
		for (int k = 0; k < div.size(); k++) {
			if (div[k] > K)tmp += INF;
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using llint = long long int;
using namespace std;

bool isdiv9(string s) {
    llint n = 0;
    for (auto ch : s) {
        n += (ch - '0');
    }
    return n % 9 == 0;
}

int main() {
    fastIO;
    string s;
    cin >> s;
    if (isdiv9(s))
        cout << "Yes";
    else
        cout << "No";
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll f = 0, t = 0, o = 0;
    REP(i, N) {
        cin >> A[i];
        ll n = 0;
        while (A[i] % 2 == 0) {
            n++;
            A[i] /= 2;
        }
        if (n >= 2)
            f++;
        else if (n == 1)
            t++;
        else
            o++;
    }

    if (o != 0) {
        if (o - f > 1 || f == 0) {
            cout << "No" << endl;
            return 0;
        }
        if (o - f == 1 && t > 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
N,A,B,C,D=gets.split.map(&:to_i)
S='-' + gets.chomp

ret = if C<D
        !S[A..B].include?('##') && !S[C..D].include?('##')
      else
        !S[A..C].include?('##') && S[B-1..D+1].include?('...')
end

puts (ret ? 'Yes' : 'No')


Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int a, b;
    cin >> a >> b;
    if (a < b * 2)
        cout << 0;
    else
        cout << a - b * 2;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  ll n;
  cin >> n;
  ll mn = 1e15 + 1;
  for (int i = 0; i < 5; ++i) {
    ll a;
    cin >> a;
    mn = min(mn, a);
  }
  cout << (n + mn - 1) / mn + 4 << endl;
  return 0;
}

Measured memory_bytes: 256