akhauriyash/Code-Regression huggingface dataset:
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Addition and Subtraction Easy
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  printf("%d\n", (op == '+') ? a + b : a - b);
  return 0;
}


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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

ll N, K, A;
ll ans = 0, pre = 0;
map<int, ll> cnts;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> N >> K;
	vl prefs(N + 1); prefs[0] = 0;
	cnts.insert({0, 1});
	F0R(i, N) {
		cin >> A; A--;
		pre += A; pre %= K;
		prefs[i + 1] = pre;
		if(i >= K - 1) {
			cnts[prefs[i - K + 1]]--;
		}
		
		if (cnts.count(pre)) {
			ans += cnts[pre]; cnts[pre]++;
		} else {
			cnts.insert({pre, 1});
		}
			
	}
	
	
	
	cout << ans;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 14464
#include "bits/stdc++.h"
using namespace std;

int main() {
	string S;
	cin >> S;
	string Scopy = S;
	reverse(S.begin(),S.end());
	if (S ==Scopy) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No"<<endl;
	}
}

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

int main()
{
  int n,m,sum=0;

  scanf("%d",&n);

  int t[n+1];
  
  for (int i=1;i<=n;i++) {
    scanf("%d",&t[i]);
    sum+=t[i];
  }

  scanf("%d",&m);

  int p,x;
  
  for (int i=1;i<=m;i++) {
    scanf("%d %d",&p,&x);
    printf("%d\n",sum-t[p]+x);
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  int ans=700;
  
  if(s[0]=='o') ans+=100;
  if(s[1]=='o') ans+=100;
  if(s[2]=='o') ans+=100;
  
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
using namespace std;

int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << '\n';
}


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

int main()
{
	int w, n;
	cin >> w;
	int* num = new int[w];
	for (int i = 0; i < w; i++) {
		num[i] = i + 1;
	}
	for (cin >> n; n--;) {
		int a, b;
		char c;
		cin >> a >> c >> b;
		int tmp = num[a - 1];
		num[a - 1] = num[b - 1];
		num[b - 1] = tmp;
	}
	for (int i = 0; i < w; i++) {
		cout << num[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
def main():
  n,k,*t=map(int,open(0).read().split())
  e=tuple(set()for _ in[0]*n)
  for a,b in zip(t[::2],t[1::2]):
    e[a-1].add(b-1)
    e[b-1].add(a-1)
  c,q=k,[0]
  while q:
    v,i=q.pop(),1
    for w in e[v]:
      c=c*(k-i-(v>0))%(10**9+7)
      e[w].remove(v)
      q+=w,
      i+=1
  print(c)
main()

Measured memory_bytes: 47976
N = int(input())

INF = 10 ** 9 + 7
G = [[int(_) for _ in input().split()] for _ in range(N)]
G2 = [G[_].copy() for _ in range(N)]

for k in range(N):
    for i in range(N):
        for j in range(N):
            G2[i][j] = min(G2[i][j], G2[i][k] + G2[k][j])
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if i == j: continue
        if G2[i][j] < G[i][j]:
            print(-1)
            exit()
        elif G2[i][j] == G[i][j]:
            v = G2[i][j]
            for k in range(N):
                if i == j or i == k or j == k: continue
                if G2[i][k] + G2[k][j] == G2[i][j]:
                    v = 0
                    break
            ans += v
print(ans)


Measured memory_bytes: 76100
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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

  int n;
	cin >> n;

	vector<int> p(n);
	rep(i,n) cin >> p[i];

	vector<int> q(n);
		int m = INF;
	rep(i, n) {
		q[i] = min(p[i], m);
		m = q[i];
	}

	//debug(q);

	int ans = 0;
	rep(i, n) {
		if (p[i] <= q[i]) ans++;
	}
	
		std::cout << ans << endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 200001;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x) {
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int main(){
  ll a, b, c;
  fastScan(a);
  fastScan(b);
  fastScan(c);
  if(b >= c){
    printf("%lld\n", b + c);
  } else {
    printf("%lld\n", b + b + min(a, (c - b)) + ((c - b) > a));
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll int a,b,c,d,sum=0,i,j;
  cin>>a>>b;

  for(i=1;i<=b;i++)
  {
      cin>>c;
      sum=sum+c;
  }

  if((a-sum)>=0)
    cout<<a-sum<<endl;
  else
    cout<<"-1"<<endl;

    return 0;
}


Measured memory_bytes: 3548
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
	char bname[3];
	int bcnt[4] = {0};
	while(scanf("%*d,%s%*c", bname) != EOF){
		if(!strcmp(bname,"A")) bcnt[0]++;
		if(bname[0]=='B') bcnt[1]++;
		if(bname[1]=='B') bcnt[2]++;
		if(bname[0]=='O') bcnt[3]++;
	}
	cout << bcnt[0] << endl << bcnt[1] << endl << bcnt[2] << endl << bcnt[3] << endl;
	return 0;
}

Measured memory_bytes: 1208
A,B,M = map(int,input().split())
rei = list(map(int,input().split()))
ren = list(map(int,input().split()))
rrw = []
for i in range(M):
    rrw.append(list(map(int,input().split())))
saiyasu = min(rei) + min(ren)
for j in range(M):
    onedan = rei[(rrw[j][0])-1] + ren[rrw[j][1]-1] - rrw[j][2]
    if onedan < saiyasu:
        saiyasu = onedan

print(saiyasu)

Measured memory_bytes: 38492
N,K = (int(i) for i in input().split())

h = []
for i in range(N):
    H = int(input())
    h.append(H)


h.sort()
#print(h)
smallest = 10**9

for i in range(N-K+1):
    #print(h[i+K-1],h[i])
    diff = h[i+K-1] - h[i]
    if diff < smallest:
        smallest = diff

print(smallest)

Measured memory_bytes: 7384
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	int sum=0;
	for(int i=1;i<=k;i++){
		sum+=a[i];
	}
	cout<<sum;

	return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int week = sc.nextInt();
		double debt = 100000;
		for(int i = 0 ; i < week ; i++){
			debt = debt * 1.05;
			double a = debt/1000;
			a = Math.ceil(a);
			debt = a * 1000;
		}

		System.out.printf("%.0f",debt);
System.out.println();
		sc.close();
	}

}

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


int main(){
    int n,l;
    cin>>n>>l;
    int a[n];
    for(int i=0;i<n;i++){
        a[i]=i+l;
    }
    sort(a,a+n);
    int sum=0;
    if(l>=0){
        for(int i=0;i<n;i++){
            sum+=a[i];
        }
        cout<<sum-l;
        return 0;
    }
    else{
        for(int i=0;i<n;i++){
            sum+=a[i];
        }
        cout<<sum-min(n+l-1,0);
    }

    return 0;
}

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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

bool check(int p, vector<int>& v){
    for(int i : v){
        if(p <= i) break;
        if(p%i == 0) return false;
    }
    return true;
}
int main(void){
    int n; cin >> n;
    int N = 1e+4;
    vector<int> prime(N+1, 1); prime[0] = 0; prime[1] = 0;
    for(int i=2; i<sqrt(N)+1; i++){
        if(prime[i] == 0) continue;
        for(int j=i+i; j<=N; j+=i) prime[j] = 0;
    }

    vector<int> prm;
    REP(i,N){
        if(prime[i+1]) prm.push_back(i+1);
    }
    int ans = 0;
    REP(i,n){
        int p; cin >> p;
        if(check(p,prm)) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;

int main(){
	long long n,y;
	cin>>n>>y;
	y /= 1000;
	y = y - n;
	if (y < 0){
		cout<<-1<<" "<<-1<<" "<<-1<<endl;
		return 0;
	}
	long long nx = 0 ;
	while ( y - 9 * nx >= 0){
		if ((y - 9 * nx) % 4 == 0){
			long long ny = (y - 9 * nx)/4;
			if ((ny >= 0) && (n - nx - ny >= 0)) {
				cout<<nx<<" "<<ny<<" "<< n - nx - ny<<endl;
				return 0;
			}
		}
		nx++;
	}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int N, Q, ans;
vector<int> S(100010);

void binary(int key){
    int left = 0, right = N, middle;
    while(left < right){
        middle = (left + right)/2;
        if(S[middle] == key){
            ans++;
            return;
        } else if(S[middle] < key){
            left = middle + 1;
        } else {
            right = middle;
        }
    }
}

int main(){
    cin >> N;
    rep(i, N) cin >> S[i];
    cin >> Q;
    ans = 0;

    rep(i, Q){
        int t;
        cin >> t;
        binary(t);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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 ll INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n;
    cin >> n;
    pair<ll,ll> g[n];
    vector<ll> ki[n];
    for (ll i=0;i<n-1;i++){
        ll a,b;
        cin >> a >> b;
        g[i]=make_pair(a-1,b-1);
        ki[b-1].push_back(i);
        ki[a-1].push_back(i);
    }
    ll color[n];
    fill(color,color+n,-1);
    queue<ll> que;
    que.push(0);
    color[0]=1;
    bool visited[n];
    fill(visited,visited+n,true);
    visited[0]=false;
    while(!que.empty()){
        ll pa=que.front();
        ll x=g[pa].first;
        que.pop();
        ll p=1;
        for (ll i=0;i<ki[x].size();i++){
            if (visited[ki[x][i]]){
                if (p==color[pa])p++;
                que.push(ki[x][i]);
                color[ki[x][i]]=p;
                p++;
                visited[ki[x][i]]=false;
            }
        }
        x=g[pa].second;
        p=1;
        for (ll i=0;i<ki[x].size();i++){
            if (visited[ki[x][i]]){
                if (p==color[pa])p++;
                que.push(ki[x][i]);
                color[ki[x][i]]=p;
                p++;
                visited[ki[x][i]]=false;
            }
        }
    }
    ll ans=0;
    for (ll i=0;i<n-1;i++){
        ans=max(ans,color[i]);
    }
    cout << ans << endl;
    for (ll i=0;i<n-1;i++){
        cout << color[i] << endl;
    }
    return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) cin >> B.at(i);

  int ans = 0;
  for (int k = 0; k <= 30; k++) {
    vector<int> C(N), D(N);
    for (int i = 0; i < N; i++) {
      C.at(i) = A.at(i) & ((1 << (k+1)) - 1);
      D.at(i) = B.at(i) & ((1 << (k+1)) - 1);
    }
    sort(C.begin(), C.end());
    sort(D.begin(), D.end());
    int p = 0; 
    int q = 0; 
    int r = 0; 
    for (int i = N-1; i >= 0; i--) {
      function<int(int,int)> upd = [&](int j0, int t) {
	for (int j = j0; j < N; j++) {
	  if (C.at(i) + D.at(j) >= (t << k)) return j;
	}
	return N;
      };
      p = upd(p, 1);
      q = upd(q, 2);
      r = upd(r, 3);
      int x = ((q - p) + (N - r)) % 2;
      ans = ans ^ (x << k);
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define kaj_start int main()
#define kaj_shesh return 0

kaj_start{
    int n, k;
    cin >> n >> k;
    int temp = 0, c = 0, result = 0;

    if(k == 1) {
        cout << 0;
    }else if(k == n) {
        cout << 0;
    }else {
        temp = k - 1;
        c = n - temp;
        result = c - 1;
        cout << result;
    }
    kaj_shesh;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int p,q,r;
scanf("%d%d%d",&p,&q,&r);
if(p==5)
{
    if(q==5)
    {
        if(r==7)
        {
            printf("YES");
        }
        else if(r==5)
        {
            printf("NO");
        }
    }
    else if(q==7)
    {
        if(r==5)
        {
            printf("YES");
        }
        else if(r==7)
        {
            printf("NO");
        }
    }
}
else if(p==7)
{
     if(q==5)
    {
        if(r==5)
        {
            printf("YES");
        }
        else if(r==7)
        {
            printf("NO");
        }
    }
    else if(q==7)
    {
        printf("NO");
    }
}
return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int a[n];
    rep(i,n)
    {
        cin>>a[i];
    }
    int b[n];
    int k=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]%2==0)
        {
            b[k]=a[i];
            k++;
        }
    }

    bool flag = 1;
    
    for(int i=0;i<k;i++)
    {
        if(b[i]%3==0 || b[i]%5==0)
        {
            flag = 1;
        }
        else
        {
            flag = 0;
            break;
        }
    }

    if(flag)
    {
        cout<<"APPROVED"<<endl;
    }
    else
    {
        cout<<"DENIED"<<endl;
    }
   

    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int cnt = 0;
    for (int r = 0; r <= N; r++) {
        for (int g = 0; g <= N; g++) {
            int x = r * R;
            int y = g * G;
            if ((N - x - y) >= 0 && (N - x - y) % B == 0) {
                cnt++;
                // cout << r << g << (N - x - y) / B << endl;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
//#include "oj/atcoder.h"
//#include "std.h"
#include <stdlib.h>
#include <stdbool.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#include <float.h>

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define SWAP(T,a,b) do { T _tmp=a; a=b; b=_tmp; } while (0)

//#include "oj/io.h"

void print_ai(int *a, int n) {
	for (int i=0; i<n; i++) {
		if (i) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
}

void scan_ai(int *a, int n) {
	for (int i=0; i<n; i++)
		scanf("%d", &a[i]);
}

//#include "oj/debug.h"

void print_hr() {
	printf("---------------------------\n");
}




int main() {
	long q, h, s, d, n;
	while (scanf("%ld %ld %ld %ld %ld", &q, &h, &s, &d, &n)==5) {
		q *= 4;
		h *= 2;
		if (q < s) s = q;
		if (h < s) s = h;
		long s1 = s*n, s2 = n/2*d + (n%2)*s;
		if (s2 < s1) s1 = s2;
		printf("%ld\n", s1);
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n , max = -1 , sum = 0;
  int l[15];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> l[i];
    if(max < l[i]) max = l[i];
    sum += l[i];
  }
  sum -= max;
  if(max < sum){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

namespace abc061_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            if (c >= a && c <= b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;


int main() {
	//スターグラフにK本足すか、完全グラフからK本引く
	int n, k;
	cin >> n >> k;
	if (k > (n - 1) * (n - 2) / 2) {
		cout << -1 << endl;
		return 0;
	}
	vector<pair<int, int>>v;
	repp(i, 1, n) {
		//ウニグラフを作る
		v.emplace_back(0, i);
	}int cnt = 0;
	if (cnt == (n - 1) * (n - 2) / 2 - k) {
		cout << n * (n - 1) / 2 - k << endl;
		repp(i, 0, v.size())cout << v[i].first + 1 << " " << v[i].second + 1 << endl;
		return 0;
	}

	repp(j, 1, n)repp(l, j+1, n) {
		v.emplace_back(j, l);
		++cnt;
		if (cnt == (n - 1) * (n - 2) / 2 - k) {
					cout << n * (n - 1) / 2 - k << endl;
					repp(i, 0, v.size())cout << v[i].first + 1 << " " << v[i].second + 1 << endl;
					return 0;
				}
			}
}

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

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	long long n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0)
		cout << (b - a) / 2;
	else
	{
		cout << min((b - (a - 1) - 1) / 2 + a - 1 + 1, (n - a - (n - b)) / 2 + n - b + 1);
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a;
		int b;
		int c;
		int N = stdIn.nextInt();
		int count = 0;
		int box;
		while (true) {
			if(N<=0){
			break;
			}
			a = stdIn.nextInt();
			b = stdIn.nextInt();
			c = stdIn.nextInt();
			if (a < b) {
				box = a;
				a = b;
				b = box;
			}
			if (a < c) {
				box = a;
				a = c;
				c = box;
			}
			a = a * a;
			b = b * b;
			c = c * c;
			if (a == b + c)
				System.out.println("YES");
			else
				System.out.println("NO");
			count=count+1;
			if (count == N){
				break;
			}
		}
	}
}

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

const int INF = 100000;

int R,C;
char field[100][100];
int  table[100][100];
int dx[4]{0,-1,0,1};
int dy[4]{1,0,-1,0};
queue<pair<int,int>> L;

void bfs(){
    while(L.size()){
        int a = L.front().first - 1,b = L.front().second - 1;
        L.pop();
        if(a == R-1 && b == C - 1){
            break;
        }
        for(int i = 0;i < 4;i++){
            int ny = a + dy[i],nx = b + dx[i];
            if(0 <= ny && ny < R && 0 <= nx && nx < C){
                if(field[ny][nx] == '.' && table[ny][nx] == INF){
                    table[ny][nx] = table[a][b] + 1;
                    L.push(make_pair(ny+1,nx+1));
                }
            }
        }
    }
    return ;
}

int main(){
    cin >>R>>C;
    int cnt = 0;
    for(int i = 0;i<R;i++){
        string S;
        cin >> S;
        for(int j = 0;j < C;j++){
            field[i][j] = S[j];
            if(field[i][j] == '.')cnt++;
        }
    }
    
    for(int i = 0;i < 100;i++){
        for(int j = 0;j < 100;j++){
            table[i][j] = INF;
        }
    }
    L.push(make_pair(1,1));
    table[0][0] = 0;
    bfs();
    if(table[R-1][C-1] == INF){
        cout << -1 << endl;
    }else{
    cout << cnt - table[R-1][C-1] - 1<< endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int64_t N,D,ans=0; cin>>N>>D;
  rep(i,N){
    int64_t a,b; cin>>a>>b;
    if(a*a+b*b<=D*D) ans++;
  }
  cout<<ans;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsinged long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;
int n;
ll a[200005];
ll b[200005];
ll T;
int id[200005];
ll dp[40];

int compare(int i,int j)
{
	return a[i]*b[j]+b[i]<a[j]*b[i]+b[j];
}

int main()
{
//	freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>n>>T;
	int k=0;
	vector <ll> vec;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
		a[i]++;
		b[i]+=a[i];
		if(a[i]==1) vec.push_back(b[i]);else id[k++]=i;
	}
	sort(id,id+k,compare);
	reverse(id,id+k);
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for(int i=0;i<k;i++)
	{
		for(int j=38;j>=0;j--)
		{
			chmin(dp[j],T+1);
			chmin(dp[j+1],dp[j]*a[id[i]]+b[id[i]]);
		}
	}
	sort(all(vec));
	int res=0;
	int have=vec.size();
	ll sum=0;
	for(auto x:vec)
	{
		sum+=x;
	}
	for(int i=0;i<40;i++)
	{
		if(dp[i]>T) break;
		while(sum+dp[i]>T)
		{
			sum-=vec[have-1];
			have--;
		}
		chmax(res,i+have);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 5104
#include <stdio.h>

int main(void) {
  char line[10];
  FILE* fp = stdin;
  if(!fgets(line, 10, fp)) return 0;
  char* tmp;
  int flag = 0;
  // consider "100..0". for special case
  if(line[0] == '1') {
    tmp = line; tmp++;
    flag = 1;
    for(; *tmp != '\n'; tmp++) {
      if(*tmp != '0') {
        flag = 0; break;
      }
    }
  }
  int res;
  if(flag) {
    res = 10;
  } else {
    char* tmp;
    res = 0;
    for(tmp = line; *tmp != '\n'; tmp++) {
      res += *tmp - '0';
    }
  }
  printf("%d\n", res);
  return 0;
}

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

int main() {
    ll h;
    cin >> h;
    ll ans = 1;
    ll p = 2;
    while(true){
        if(h<=1) break;
        h /= 2;
        ans += p;
        p *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  map<char,int>mp;
  for(int i=0;i<s.size();i++){
    mp[s[i]]++;
  }
  if(mp.size()!=2){
    cout<<"No"<<endl;
    return 0;
  }
  for(auto a:mp){
    if(a.second!=2){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3576
#!/usr/bin/env python
# coding: utf-8

# In[23]:


X,K,D = map(int, input().split())


# In[25]:


if abs(X) >= K*D:
    ans = abs(X) - K*D
else:
    cnt = abs(X)//D
    if (K-cnt)%2 == 0:
        ans = abs(X) - cnt*D
    else:
        ans = min(abs(abs(X) - (cnt+1)*D), abs(X) - (cnt-1)*D)
print(ans)


# In[ ]:






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

int main(){
	int N;
	cin >> N;
	vector <int> v(N);
	
	for(int i = 0; i < N; i++){
		cin >> v[i];
	}
	
	sort(v.begin(), v.end());
	
	long long int ans = 0;
	
	
	for(int i = N-1; i >= 2; i--){
		for(int j = 0; j < i; j++){
			auto mid = upper_bound(v.begin() + j + 1, v.begin() + i, v[i] - v[j]);
			ans += (v.begin() + i) - mid;
		}
	}
	
	cout << ans << endl;
	return 0;
}	 


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 200000
using namespace std;
typedef long long LL;
struct node
{
	int to;
	node *nxt;
}edges[MAXN*2+5];
node *ncnt=&edges[0],*Adj[MAXN+5];
int n,sum,siz[MAXN+5],mx[MAXN+5],smx[MAXN+5];
int l[MAXN+5],r[MAXN+5];
LL ans=0;
char str[MAXN+5];
void AddEdge(int u,int v)
{
	node *p=++ncnt;
	p->to=v;
	p->nxt=Adj[u];
	Adj[u]=p;
	
	node *q=++ncnt;
	q->to=u;
	q->nxt=Adj[v];
	Adj[v]=q;
}
void DFS1(int u,int fa)
{
	siz[u]=str[u]-'0';
	for(node *p=Adj[u];p!=NULL;p=p->nxt)
	{
		int v=p->to;
		if(v==fa)
			continue;
		DFS1(v,u);
		siz[u]+=siz[v];
		if(mx[v]+1>mx[u])
			smx[u]=mx[u],mx[u]=mx[v]+1;
		else if(mx[v]+1>smx[u])
			smx[u]=mx[v]+1;
	}
}
void DFS2(int u,int fa,int len)
{
	r[u]=len>mx[u]?mx[u]:max(len,smx[u]);
	l[u]=str[u]-'0'?0:(sum-siz[u]?len:MAXN+5);
	if(fa!=-1)
	{
		if(len-1==mx[u])	ans++;
		else if(len-1<mx[u])	ans+=siz[u]<sum;
		else	ans+=siz[u]>0;
	}
	for(node *p=Adj[u];p!=NULL;p=p->nxt)
	{
		int v=p->to;
		if(v==fa)
			continue;
		if(siz[v])
			l[u]=min(l[u],mx[v]+1);
		if(mx[u]==mx[v]+1)
			DFS2(v,u,max(len,smx[u])+1);
		else
			DFS2(v,u,max(len,mx[u])+1);
	}
}
int main()
{
	scanf("%d",&n);
	int u,v;
	for(int i=1;i<n;i++)
	{
		scanf("%d %d",&u,&v);
		AddEdge(u,v);
	}
	scanf("%s",str+1);
	for(int i=1;i<=n;i++)
		sum+=str[i]-'0';
	DFS1(1,-1);
	DFS2(1,-1,0);
	for(int i=1;i<=n;i++)
		if(l[i]<=r[i])
			ans+=r[i]-l[i]+1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 19200
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
bool sortbysecdesc(const pair<string,ll> &a,const pair<string,ll> &b)
{
       return a.second>b.second;
}
int main() {
	ll a,b;cin>>a>>b;
	cout<<a*b/__gcd(a,b)<<endl;
	return 0;
}


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

int main(){
        int N;
        cin>>N;
        int A,B;
        if(N<=10){
                A=1;
        }else if(N<=100){
                A=10;
        }else if(N<=1000){
                A=100;
        }else if(N<=10000){
                A=1000;
        }else{
                A=10000;
        }
        B=N-A;
        int ans=1;
        while(B>0){
                ans+=B%10;
                B/=10;
        }
        cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    int n;
    cin>>n;
    map<string,int>mp;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    int m=0;
    for(auto x:mp)
    m=max(m,x.second);
    for(auto x:mp)
    if(x.second==m)
    cout<<x.first<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

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


Measured memory_bytes: 19260
#include <iostream>
#include <math.h>
#include <cstdio>
using namespace std;
 
int main() {
int n;
double p;
while(cin>>n){
    if(n==0){
        break;
    }
    double ji=0,hei=0,ans;
    for(int k=0;k<n;k++){
        cin>>p;
        ji=ji+p*p;
        hei=hei+p;
    }
    ji=ji/n;
    hei=(hei/n)*(hei/n);
    ans=sqrt(ji-hei);
printf("%.7lf\n",ans);
}
    return 0;
}

Measured memory_bytes: 1248
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n, m, t;
int a[100];
int b[40000];

int main(){
  cin >> n >> m >> t;
  rep(i, n){
    cin >> a[i];
    rep(j, a[i] - m, a[i] + m) b[j] = 1;
  }
  int res = t;
  rep(i, t) res -= b[i];
  cout << res << endl;
}

Measured memory_bytes: 3244
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;
 
signed main(void) {
  int i,j;
  int n;
  cin>>n;
  vi v(n);
  rep(i,n)cin>>v[i];
  vector<vi> dp(n,vi(21,0));
  dp[0][0]=1;
  rep(i,n-1)rep(j,21)if(dp[i][j]>0){
    if(j+v[i]<=20)dp[i+1][j+v[i]]+=dp[i][j];
    if(j-v[i]>=0)dp[i+1][j-v[i]]+=dp[i][j];
  }
  if(v[0])cout<<dp[n-1][v[n-1]]<<endl;
  else cout<<dp[n-1][v[n-1]]/2<<endl;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N;
    string S;
    cin >> N >> S;
    int x = 0;
  int xmax = 0;
    for(int i = 0;i < N; i++){
        if(S[i] == 'I'){
            x++;
            xmax = max(x,xmax);
          
        }
        else {
            x--;
           
        }
    }
    cout << xmax << endl;
}


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

int main(){
  int n;cin>>n;
  vector<int> a(n,0);
  REP(i,n-1){
    int t;cin>>t;
    a[t-1]++;
  }
  REP(i,n) cout<<a.at(i)<<endl;
}

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

int main() {
  int n,k,i,j,ans;
  cin >> n >> k;
  vector<int> a(n);
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(i=k;i<n;i++){
    if(a.at(i-k)<a.at(i)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 4032
n = int(input())
town_map = []

total_length = 0
for i in range(n):
    position = list(map(int, input().split()))
    town_map.append(position)
    for j in range(i):
        total_length += ((position[0] - town_map[j][0]) ** 2 + (position[1] - town_map[j][1]) ** 2) ** (1/2)

print(total_length * 2 / n)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#define df 0
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

li inv(li a){
  if(a==1)return 1;
  return ((MOD-(MOD/a))*inv(MOD%a))%MOD;
}

li combin(int n,int r){
  if(n<r or r<0) return 0;
  int a=1;li s=1; li in=1;
  rep(i,r){
    s*=n-a+1;
    s%=MOD;
    in*=a;
    in%=MOD;
    a++;
  }
  //  if(df)printf("[%d/%d]",s,in);
  return s*inv(in)%MOD;
}

li g(int r,int c){
  li s=combin(r+c+2,c+1)+MOD-1;
  return s%MOD;
}


int main(){
  // int r2; cin >>r2;
  int r1,r2,c1,c2; cin >>r1 >>c1 >>r2 >>c2;
  if(df){
    rep(i,r2){
      printf("%d ",inv(i+1));
    }
  }
  if(df){
    rep(i,r2){
      rep(j,i+1){
	printf("%d ",combin(i,j));
      }
      printf("\n");
    }
  }
  r1--;c1--;
  li s=g(r2,c2)-g(r2,c1)-g(r1,c2)+g(r1,c1);
  if(df)printf("%ld %ld %ld %ld\n",g(r2,c2),g(r2,c1),g(r1,c2),g(r1,c1));
  printf("%ld",((s%MOD)+MOD)%MOD);
}

/// confirm df==0 ///


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc092/tasks/arc093_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int N, a, d, la = 0, A[100001], D[100001];
ll sum = 0;

int main()
{
  cin >> N;
  A[0] = 0;
  REP(i, N)
  {
    cin >> a;
    d = abs(la - a);
    A[i + 1] = a;
    D[i] = d;
    sum += d;
    la = a;
  }
  A[N + 1] = 0;
  d = abs(A[N]);
  D[N] = d;
  sum += d;

  REP(i, N)
  {
    ll c = sum - (D[i] + D[i + 1]) + abs(A[i] - A[i + 2]);
    cout << c << '\n';
  }

  return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;
int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0;
	ll n, m, h, w, X;
	ll k;
	ll insuusyurui[1000] = {};
	ll insuukazu[1000] = {};
	ll memo[4000] = {};
	ll memo2[4000] = {};
	string s;
	cin >> a;
	for (int i = a; i < 10000; i++)
	{
		if ((i - (i % 100)) / 100 == i%10 && ((i % 100) - (i % 10)) / 10 == i % 10)
		{
			cout << i << endl;
			return 0;
		}
	}
	//cout << endl;

	//cout << sum << endl;
	//cout <<  endl;

	return 0;
}

//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}




//
//ll insuusyurui[1000] = {};
//ll insuukazu[1000] = {};
//ll memo[4000] = {};
//ll memo2[4000] = {};
//cin >> n;
//cin >> m;
//a = 2;
//// √n ≧ a ( n ≧ a * a ) の間ループ処理
//while (n >= a * a) {
//	// a で割り切れたら、a は素因数
//	// そして、割られる数を a で割る
//	// a で割り切れなかったら、 a を 1 増加させる
//	if (n % a == 0) {
//		printf("%d * ", a);
//		insuukazu[c]++;
//		n /= a;
//	}
//	else {
//		a++;
//		//if (insuukazu[c] != 0)
//		{
//			c++;
//			//cout << c << endl;
//
//		}
//	}
//}
//printf("%d\n", n);
//for (int i = 0; i < c; i++)
//{
//	//cout << insuukazu[i] << endl;
//}
//
//cout << "Yes" << endl;

Measured memory_bytes: 256
using System;

namespace aoj5a
{
    class Program
    {
        static int Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            

            for(int i = 3 ; i <= n ; i++)
            {
                bool Nabeatsu = false;
                if ( i % 3 == 0)
                {
                    Nabeatsu = true;
                }
                else
                {
                    int j = i ;
                    do
                    {
                        if (j % 10 == 3)
                        {
                            Nabeatsu = true;
                            break;
                        }
                        j /= 10;
                    } while (j > 0);
                }
                Console.Write( Nabeatsu ? (" " +i.ToString()) : "");
            }
            Console.WriteLine();
            return 0;
        }
    }
}

Measured memory_bytes: 9308
fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val blueCards = (1..n).map { readLine()!! }
    val m = readLine()!!.toInt()
    val redCards = (1..m).map { readLine()!! }
    val ans = Math.max(blueCards.union(redCards).map { w->blueCards.count { it == w } - redCards.count { it == w } }.max()!!, 0)
    println(ans)
}


Measured memory_bytes: 37172
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;

const ll M = (1000000000 + 7);

class Felmat
{
  ll M;
  vector<ll> fac;  // n! (mod M)
  vector<ll> ifac; // k!^{M-2} (mod M)

public:
  Felmat(ll max_nk, ll m)
  {
    M = m;
    fac.reserve(max_nk + 1);
    ifac.reserve(max_nk + 1);
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < max_nk; i++) {
      fac[i + 1] = fac[i] * (i + 1) % M;              // n! (mod M)
      ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M)
    }
  }
  ll mpow(ll x, ll n)
  { // x^n (mod M)
    ll ans = 1;
    while (n != 0) {
      if (n & 1)
        ans = ans * x % M;
      x = x * x % M;
      n = n >> 1;
    }
    return ans;
  }
  ll minv(ll a)
  { // 1/a (mod M)
    ll b = M, u = 1, v = 0;
    while (b) {
      ll tmp = a / b;
      a -= tmp * b;
      swap(a, b);
      u -= tmp * v;
      swap(u, v);
    }
    u %= M;
    if (u < 0)
      u += M;
    return u;
  }
  ll mfac(ll x)
  { // n! (mod M)
    int i;
    return fac[x];
  }
  ll mifac(ll x)
  { // 1/n! (mod M)
    int i;
    return ifac[x];
  }
  ll comb(ll n, ll k)
  { // nCk (mod M)
    if (n == 0 && k == 0)
      return 1;
    if (n < k || n < 0)
      return 0;
    ll tmp = ifac[n - k] * ifac[k] % M;
    return tmp * fac[n] % M;
  }
  ll perm(ll n, ll k)
  { // nPk (mod M)
    if (n < k)
      return 0;
    ll tmp = ifac[n - k] % M;
    return tmp * fac[n] % M;
  }
};

int main()
{
  ll N, A, B, C;
  cin >> N >> A >> B >> C;
  // cout << N << A << B << C << endl;
  Felmat fm(N * 2, M);
  vector<long long> a(2 * N);
  long long aa = A * fm.mpow(A + B, M - 2);
  for (int i = 0; i < 2 * N; i++) {
    a[i] = fm.mpow(aa % M, i);
  }
  vector<long long> b(2 * N);
  long long bb = B * fm.mpow(A + B, M - 2);
  for (int i = 0; i < 2 * N; i++) {
    b[i] = fm.mpow(bb % M, i);
  }
  long long div = 100 * fm.mpow(A + B, M - 2) % M;
  ll ans;
  for (long long i = N; i < 2 * N; i++) {
    long long c = fm.mfac(i - 1) * fm.mifac(N - 1) % M * fm.mifac(i - N) % M;
    // cout << i << ":" << c << ":" << div << endl;
    ans += c * a[N] % M * b[i - N] % M * i % M * div % M;
    ans %= M;
    ans += c * a[i - N] % M * b[N] % M * i % M * div % M;
    ans %= M;
    // cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6528
c = []
for i in range(3):
    tmp = list(map(int, input().split()))
    c.append(tmp)
    
x = c[0][0] * 2 - c[1][0] - c[2][0]
y = c[0][1] * 2 - c[1][1] - c[2][1]
z = c[0][2] * 2 - c[1][2] - c[2][2]

o = c[0][2] * 2 - c[0][1] - c[0][0]
p = c[1][2] * 2 - c[1][1] - c[1][0]
q = c[2][2] * 2 - c[2][1] - c[2][0]

if x == y == z and o == p == q:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

ll gcd(ll a, ll b)
{
	if (a < b) swap(a, b);
	return (a%b ? gcd(a%b, b) : b);
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b)*b;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll n, m;
	cin >> n >> m;
	vi a(n);
	REP(i, n) cin >> a[i];
	vector<ld> p(n);
	REP(i, n)
	{
		ld a; cin >> a;
		p[i] = a / 100.0;
	}
	vector<ll> cnt(1 << n);
	REP(i, 1 << n)
	{
		ll t = 1;
		bool f = false;
		REP(j, n)
		{
			if (!((i >> j) & 1)) continue;
			ll tmp = a[j] / gcd(t, a[j]);
			if (t > LLONG_MAX / tmp) f = true;
			else t *= tmp;
		}
		if (f) cnt[i] = 0;
		else cnt[i] = m / t;
	}

	REP(i, n)REP(j, 1 << n) if (j & 1 << i) cnt[j] -= cnt[j ^ 1 << i];

	ld ans = 0;
	REP(i, 1 << n)
	{
		ld exp = 1.0;
		REP(j, n)
		{
			if ((i >> j) & 1) exp *= p[j];
			else exp *= 1.0 - p[j];
		}
		ans += exp * (m - abs(cnt[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11068
#include <iostream>
#include <list>
#include <vector>
#include <queue>

using namespace std;

int main(void) {
	int num, i, a, b, c;
	cin >> num;
	vector<list<pair<int, int>>> d(num + 1);
	vector<int> ans(num + 1, -1);
	for (i = 0; i < num - 1; i++) {
		scanf("%d%d%d", &a, &b, &c);
		c &= 1;
		d[a].push_back(make_pair(b, c));
		d[b].push_back(make_pair(a, c));
	}
	queue<int> que;
	a = 1;
	ans[1] = 0;
	while (true) {
		c = ans[a];
		for (auto itr = d[a].begin(); itr != d[a].end(); itr++) {
			if (ans[(*itr).first] < 0) {
				que.push((*itr).first);
				ans[(*itr).first] = c ^ (*itr).second;
			}
		}
		if (que.empty())
			break;
		a = que.front();
		que.pop();
	}
	for (i = 1; i <= num; i++)
		printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 8704
use std::io::{Read, stdin};
use std::str::FromStr;

fn main() {
    let n: i64 = read();
    let mut v: Vec<i64> = Vec::new();
    v = dfs(0, v, n);
    println!("{}", v.len())
}

fn dfs(x: i64, mut v: Vec<i64>, n: i64) -> Vec<i64>{
    if x <= n{
        if 0 < x && is_357(x){
            v.push(x);
        }
        v = dfs(x*10 + 3, v, n);
        v = dfs(x*10 + 5, v, n);
        v = dfs(x*10 + 7, v, n);
    }
    v
}

fn is_357(x: i64) -> bool {
    let s : String = x.to_string();
    let mut is3:bool = false;
    let mut is5:bool = false;
    let mut is7:bool = false;
    for c in s.chars(){
        if c == '3'{
            is3 = true;
        }
        if c == '5'{
            is5 = true;
        }
        if c == '7'{
            is7 = true;
        }
    }
    is3 && is5 && is7
}

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")
}

Measured memory_bytes: 4352
m,k =map(int,input().split())
if k>=2**m:
  print(-1)
elif [m,k]==[0,0]:
  print("0 0")
elif [m,k]==[1,0]:
  print("0 0 1 1")
elif [m,k]==[1,1]:
  print(-1)

else:
  l=[]
  for iii in range(2**m):
    if iii!=k:
      l.append(iii)
  out=" ".join(map(str,l[::-1]+[k]+l+[k]))
  print(out)
  

Measured memory_bytes: 26812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
const int inf = 1001001001;
 
int main(){

    int n,d;
    cin >> n >> d;
    rep(i,inf){
        if(i*(2*d+1)>=n){
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 384