akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

/////////////////////////////////
#define MAX_V 10005//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
//辺を表す構造体{行き先、容量、逆辺}
struct edge{int to,cap,rev;};
vector<edge> G[MAX_V];
bool used[MAX_V];//dfsですでに調べたかのフラグ
//fromからtoへの流量capの辺をグラフに追加
void add_edge(int from,int to,int cap){
    G[from].push_back((edge){to,cap,static_cast<int>(G[to].size())});
    G[to].push_back((edge){from,0,static_cast<int>(G[from].size()-1)});
}
//増加パスをdfsで探す
int dfs(int v,int t,int f){
    if(v==t)return f;
    used[v]=true;
    for(int i=0;i<G[v].size();i++){
        edge &e=G[v][i];
        if(!used[e.to]&&e.cap>0){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int flow=0;
    while(1){
        memset(used,0,sizeof(used));
        int f=dfs(s,t,inf);
        if(f==0)return flow;
        flow+=f;
    }
}
/////////////////////////////////////////////
int h,w;

int main(){
    cin>>h>>w;
    char map[h][w+1];
    for(int i=0;i<=h-1;i++)cin>>map[i];
    for(int i=0;i<=h-1;i++){
        for(int j=0;j<=w-1;j++){
            if(map[i][j]=='o'){
                add_edge(i,j+h,1);
                add_edge(j+h,i,1);
            }else if(map[i][j]=='S'){
                add_edge(h+w,i,inf);
                add_edge(h+w,j+h,inf);
            }else if(map[i][j]=='T'){
                add_edge(i,h+w+1,inf);
                add_edge(j+h,h+w+1,inf);
            }
        }
    }
    int ans=max_flow(h+w,h+w+1);
    if(ans>=inf)cout<<-1<<endl;
    else cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const int MOD = 2019;
int N; // 2*10e5
string S;
ll dp[200005];
ll dp2[200005]; // keta


void init() {
  dp2[0] = 1ll;
  rep(i, N) {
    if (i==0) continue;
    dp2[i] = (dp2[i-1]*10)%MOD;
  }
} 
int main() {
  INCANT;
  cin >> S;
  N = S.size();
  init();
  dp[N-1] = S[N-1]-'0';
  for(int i=N-1; i>=0; i--) {
    if (i==N-1) continue;
    int d = S[i]-'0';
    int keta = N-1 - i;
    dp[i] = (dp2[keta]*d+dp[i+1])%MOD;
  }
  ll SUM=0ll;
  rep(i, 2019) {
    ll tmp=0ll;
    rep(j, N) if (dp[j]==i) tmp++;
    if (i==0) SUM+=tmp*(tmp+1)/2;
    else SUM+=tmp*(tmp-1)/2;
  }
  cout << SUM << endl;
  return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,m;cin>>n>>m;
    vector<ll> t(n,1);
    vector<bool> used(n,false);
    used[0]=true;
    rep(i,m){
        int x,y;cin>>x>>y;x--;y--;
        if(used[x])used[y]=true;
        if(t[x]==1)used[x]=false;
        t[x]--;t[y]++;
    }
    ll res=0;
    rep(i,n)if(used[i])res++;
    cout<<res<<endl;
}

Measured memory_bytes: 3968
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int n;int a=0,b=0,ab=0;int count=0;
	string ss;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>ss;
		int len=ss.length();
		if(ss[0]=='B') b++;
		if(ss[len-1]=='A') a++;
		if(ss[0]=='B'&&ss[len-1]=='A') ab++;
		for(int j=1;j<len;j++)
		{
			if(ss[j]=='B'&&ss[j-1]=='A')count++;
		}
	}
	if(a==b&&b==ab&&b!=0) count--;
	cout<<count+min(a,b)<<endl;
	return 0;
}

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

#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 repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

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

    int ans = 0;
    rep(i,3) if(s[i] == '1') ans++;

    cout << ans << endl;
}


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

def f(a, b):
    x = int(max(a, b))
    return len(str(x))

results = []

for i in range(1, int(n ** (1/2)) + 1):
    if n % i == 0:
        a = i
        b = n / i
    result = f(a, b)
    results.append(result)

print(min(results))

Measured memory_bytes: 9968
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    ll x;
    cin>>x;
    ll ok=INF;
    ll ng=0;
    while(ok-ng>1){
        ll mid=(ok+ng)/2;
        if(mid*(mid+1)/2>=x){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout<<ok<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	string S;
	cin >> S;
	int ans = 0;
	rep(i, S.size()) {
		if (S[i] == '+')ans++;
		else ans--;
	}
	cout << ans;
}

Measured memory_bytes: 256
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int dp[310][310];

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

	int N, K;
	int H[310];

	cin >> N >> K;
	rep(i, 1, N+1)
	{
		cin >> H[i];
	}
	H[0] = 0;
	N++;

	rep(i, 0, 310)rep(j, 0, 310)dp[i][j] = INF;
	dp[0][1] = 0;

	//rep(i, 1, N)rep(j, 0, i)rep(k, max(0LL, j - K), j + 1)
	rep(i, 1, N)rep(j, 0, i)rep(k, 1, j + 2)
	{
		chmin(dp[i][k + 1], dp[j][k] + max(0LL, H[i] - H[j]));
	}

	int ans = INF;
	if (K >= N-1)ans = 0;
	else
	{
		rep(i, 0, N)
		{
			chmin(ans, dp[i][N - K]);
		}
	}

	cout << ans << endl;

	return 0;
}

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

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

    priority_queue<int> red;
    priority_queue<int, vector<int>, greater<int>> white;
    for(int i=0; i<N; i++){
        if(S[i]=='R'){
            red.push(i);
        }else{
            white.push(i);
        }
    }

    int min_index_white = N;
    int max_index_red = -1;
    int count = 0;
    while(!white.empty()){

        if(red.empty()){
            break;
        }

        min_index_white = white.top();
        max_index_red = red.top();

        if(min_index_white > max_index_red){
            break;
        }

        white.pop();
        red.pop();
        count++;
    }

    cout << count << endl;
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  if (n <= k) {
    cout << 0;
    return 0;
  }
  vector<long> hn(n);
  rep(i, n) {
    cin >> hn[i];
  }
  sort(hn.begin(), hn.end());
  reverse(hn.begin(), hn.end());
  long sum = 0;
  rep(i, k) {
    hn[i] = 0;
  }
  rep(i, n) {
    sum += hn[i];
  }
  cout << sum ;
  
}


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

using namespace std;

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

int main(){
    long long a=read(),b=read();
    cout<<(a-1)*(b-1);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	static int f(String t){
		int c=0;
		for(int i=1;i<t.length();++i){
			if(t.charAt(i-1)==t.charAt(i)){
				++c;
				++i;
			}
		}
		return c;
	}

	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		String t=s.next();
		long k=s.nextInt()-1,a=f(t),b=f(t+t)-a,c=f(t+t+t)-a;
		System.out.println(k/2*c+k%2*b+a);
	}
}


Measured memory_bytes: 21844
from fractions import gcd

a, b, c, d = map(int, input().split())
lcm = c * d // gcd(c, d)
x = b - (b // c) - (b // d) + (b // lcm)
y = (a - 1) - ((a - 1) // c) - ((a - 1) // d) + ((a - 1) // lcm)
print(x - y)

Measured memory_bytes: 5304
v = 10
H, W = map(int, input().split())
c = [list(map(int,input().split())) for _ in range(v)]
A = [list(map(int,input().split())) for _ in range(H)]

for k in range(v):
    for i in range(v):
        for j in range(v):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for Ai in A:
    for a in Ai:
        if a == -1:
            continue
        ans += c[a][1]

print(ans) 


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);

template<class T>
bool liner_search(std::vector<T> &vec, T t) {
  for (T v: vec) {
    if (v == t) return true;
  }
  return false;
}

int main(){
  int n;
  scanf("%d", &n);

  vector<int> v(n);

  REP (i, n) {
    scanf("%d", &v[i]);
  }

  int q;
  scanf("%d", &q);

  vector<int> t(q);
  REP (i, q) {
    scanf("%d", &t[i]);
  }
  int sum = 0;

  for (int a: t) {
    bool flag = liner_search(v, a);
    if (flag) sum++;
  }

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



Measured memory_bytes: 3220
N = int(input())
A = list(map(int,input().split()))
a,b = 0,-1
for i in range(N):
    if i == 0:
        b = A[i]
    else:
        if b > A[i]:
            a += b-A[i]
        b = max(b,A[i])
print(a)

Measured memory_bytes: 32148
//ABC133B
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(){
	int n, d;
	scanf("%d %d",&n, &d);
	int a[n][d];
	int i, j, k, l;
	int sigma, count=0;
	for(i=0;i<n;i++){
		for(j=0;j<d;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			sigma = 0;
			for(k=0;k<d;k++){
				sigma = sigma + (a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			for(l=1;l<=sigma;l++){
				if(l*l==sigma){
					count++;
				}
			}
		}
	}
	printf("%d",count);
	return 0;
}

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

using namespace std;
#define int long long
struct MT
{
    int ma[55][55];
};
int n,base=1e9+7,k;
MT goc;
MT nhan(MT a,MT b)
{
    MT q;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            int res=0;
            for(int h=1;h<=n;h++)
            {
                res=(res+(a.ma[i][h]*b.ma[h][j])%base)%base;
            }
            q.ma[i][j]=res;
        }
    }
    return q;
}
MT lt(int k)
{
    if(k==1) return goc;
    MT q=lt(k/2);
    if(k%2==0) return nhan(q,q);
    else return nhan(nhan(q,q),goc);
}
main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin>>goc.ma[i][j];
        }
    }
    int kq=0;
    MT qw=lt(k);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++) kq=(kq+qw.ma[i][j])%base;
    }
    cout<<kq;
}


Measured memory_bytes: 8704
import java.util.Stack;
import java.util.Scanner;
import java.math.BigDecimal;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static long res = 0;
    public static void main(String[] args) throws Exception {
        int[] ary = new int[5];
        for (int i = 0; i < 5; i++) {
            ary[i] = sc.nextInt();
        }
        
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4 - i; j++) {
                if (ary[j] < ary[j+1]) {
                    int t = ary[j];
                    ary[j] = ary[j+1];
                    ary[j+1] = t;
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 5; i++) {
            sb.append(ary[i]).append(" ");
        }
        sb.delete(sb.length()-1,sb.length());
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 26156
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#n=int(input())
#import fractions
#import itertools
#import math
#lis=list(input().split())
#lis=list(map(float,input().split()))
#lis=list(map(int,input().split()))
#n=int(input())

S=input()
ans="Yes"
l=[0,0,0,0]
for i in range(4):
    for j in range(4):
        if S[j]==S[i]:
            l[i]+=1
for i in range(4):
    if l[i]!=2:
        ans="No"
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;

string s,t;
int ans;

int main(){
	cin>>s>>t;
	for(int i=0;i<s.size();++i)if(s[i]==t[i])ans++;
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
#pragma G++ optimize (2)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#define INF 0x3f3f3f3f
#define NO 30005
#define MO 100005
typedef long long ll;
using namespace std;
inline ll read()
{
	char ch = ' ', last;
	ll ans = 0;
	while (ch < '0' || ch > '9')
		last = ch, ch = getchar();
	while (ch >= '0' && ch <= '9')
		ans = ans * 10 + int(ch - '0'), ch = getchar();
	if (last == '-')
		return -ans;
	return ans;
}
void write(ll x)
{
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
//head

int y, m, d;
//variable

void init()
{
	scanf("%d/%d/%d", &y, &m, &d);
}
void ye()
{
	cout << "Heisei" << endl;
	exit(0);
}
void no()
{
	cout << "TBD" << endl;
	exit(0);
}
//functions

int main()
{
	init();
	if (y < 2019)
		ye();
	if (y > 2019)
		no();
	if (m > 4)
		no();
	if (m < 4)
		ye();
	if (d <= 30)
		ye();
	return 0;
}
//main


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<ll> dp(N+2, 0);
	ll mod=1000000007;
	dp[0]=1;
	if(M==0){
	    for(int i=0; i<N; ++i){
	        dp[i+1]=(dp[i+1]+dp[i])%mod;
	        dp[i+2]=(dp[i+2]+dp[i])%mod;
	    }
	    cout << dp[N] << endl;
	    return 0;
	}
	vector<ll> a(M);
	for(int i=0; i<M; ++i){
	    cin >> a[i];
	}
	int now=0;
	for(int i=0; i<N; ++i){
	    if(a[now]==i){
	        dp[i]=0;
	        ++now;
	    }
	    dp[i+1]=(dp[i+1]+dp[i])%mod;
	    dp[i+2]=(dp[i+2]+dp[i])%mod;
	}
	cout << dp[N] << endl;
	return 0;
}


Measured memory_bytes: 1792
import math
s = int(input())
if (s == 1000000000000000000):
    print(0, 0, 1000000000, 0, 0, 1000000000)
    exit(0)
l = int(math.log10(s))
l1 = l // 2
l2 = l - l1
d = 10 ** max(l1, l2)
b = s % d
a = s // d
print(0, 0, 1, d, a + 1, d - b)
#print((a + 1) * d - d + b)


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

const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    int cnt[n + 1]; //n!の各素因数の個数
    for (int i = 0; i <= n; i++) cnt[i] = 0;
    for (int i = 2; i <= n; i++) {
        int ni = i;
        int j = 2;
        while (j <= n) {
            if (ni % j == 0) {
                cnt[j]++;
                ni /= j;
            }
            else j++;
        }
    }
    ll ans = 1;
    for (int i = 2; i <= n; i++) {
        ans = ans * (cnt[i] + 1) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
m=[999]+[0 for i in range(n)]+[999]
m[a]=1
m[b]=2
cnt=0
while 1:
    if cnt%2==0:
        if m[a+1]==0:
            m[a]=0
            m[a+1]=1
            a+=1
        elif m[a-1]==0:
            m[a]=0
            m[a-1]=1
            a-=1
        else:
            print('Borys')
            exit()
    else:
        if m[b-1]==0:
            m[b]=0
            m[b-1]=1
            b-=1
        elif m[b+1]==0:
            m[b]=0
            m[b+1]=1
            b+=1
        else:
            print('Alice')
            exit()

    cnt+=1

Measured memory_bytes: 3064
def main2():
    #1:初期化
    s = input()
    t = input()
    v = [0] * (len(t) + 1)
    dp = [v]
    #print(v)
    #print(dp)

    #2:初期値(いらない)

    #3:dp実行部(貰うDP)
    for str1 in s:
        v = v.copy()
        dp.append(v)
        #print("in",*dp,sep="\n")
        ll, ul = 0, 0
        for j, str2 in enumerate(t, 1):
            uu = v[j]
            if str1 == str2:
                v[j] = ll = ul + 1
            elif ll > uu:
                v[j] = ll
            ul = uu
        #print(ll,ul,uu,"out",*dp,sep="\n")
            
    # #4:出力
    #print(*dp,sep="\n")
    res = ""
    s_len = len(s)
    t_len = len(t)
    while s_len > 0 and t_len > 0:
        if dp[s_len][t_len] == dp[s_len-1][t_len]:
            s_len -= 1
        elif dp[s_len][t_len] == dp[s_len][t_len-1]:
            t_len -= 1
        else:
            res = s[s_len-1] + res
            s_len -= 1
            t_len -= 1
    print(res)
        
if __name__ == '__main__':
    main2()

Measured memory_bytes: 312820
#include<bits/stdc++.h>
using namespace std;
#define int long long
main()
{
    int x,n;
    cin>>x>>n;
    map<int,int>cnt;
    int a[105];
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
    }
    int ans=INT_MAX,v;
    for(int i=x; i<=200; i++)
    {
        if(cnt[i]==0)
        {
            if(i-x<=ans)
            {
                ans=i-x;
                v=min(v,i);
            }
        }
    }
    for(int i=x-1; i>=-110; i--)
    {
        if(cnt[i]==0)
        {
            if(x-i<=ans)
            {
                ans=x-i;
                v=min(v,i);
            }
        }
    }
    cout<<v<<endl;
}



Measured memory_bytes: 3628
#include <cstdio>
#include <map>
int M[200][3],S[200];
main(){
	int n,i=0,j=0;
	for(scanf("%d",&n);i<n;i++)scanf("%d%d%d",M[i],M[i]+1,M[i]+2);
	for(;j<3;j++){
		std::map<int,int>m;
		for(i=0;i<n;i++)m[M[i][j]]++;
		for(i=0;i<n;i++)if(m[M[i][j]]<2)S[i]+=M[i][j];
	}
	for(i=0;i<n;i++)printf("%d\n",S[i]);
}

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

void solve(){
    int n;
    cin >> n;
    int h[n];

    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    int dp[n] = {0};
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for(int i=2;i<n;i++){
        dp[i] = min(abs(h[i] - h[i-2]) + dp[i-2],abs(h[i] - h[i-1]) + dp[i-1]);
    }
    cout << dp[n-1] << endl;

}

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


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

int main(){
  string s;
  cin >> s;
  int a=s.size();
  if(s[a-1]=='s') {
    s.push_back('e');
    s.push_back('s');
  }
  if(s[a-1]!='s') s.push_back('s');
  
  cout << s << endl;
  return 0;
  
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define diff(a,b) (a>b?a-b:b-a)
const int N=1e6+5;
int32_t main()
{
    IOS;
    int n;
    cin >> n;
    int a[n];
    for(int i = 0;i < n; i++)
        cin >> a[i];
    int dp[n];
    memset(dp,0,sizeof(dp));
    for(int i = 1;i < n; i++){
        if(i>1)
            dp[i] = min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
        else
            dp[i] = abs(a[i]-a[i-1]+dp[i-1]);
    }
    cout << dp[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,n)cout<<a[i]<<'\n'
#define pri3(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int n,m,_,x,y,q,key;
string s,sb;
bool ok;

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

  cin>>n>>m; V(int) p; V(V(int)) g(n),t(n); int h[n+1]={}; stack<int> st;
  h[n]=-1;
  rep(i,n+m-1){
    cin>>x>>y;
    g[--x].eb(--y); h[y]++;
    t[y].eb(x);
  }
  rep(i,n)if(!h[i])st.push(i);
  while(!st.empty()){
    x=st.top(); st.pop();
    for(auto e:g[x]){
      h[e]--; if(!h[e])st.push(e);
    }
    p.eb(x);
  }
  rep(i,n)h[p[i]]=i;
  rep(i,n){
    y=n;
    for(auto e:t[i]){
      if(h[e]>h[y])y=e;
    }
    if(y==n)pri1(0);
    else pri1(y+1);
  }
}

Measured memory_bytes: 12668
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k, s;
  cin >> n >> k >> s;

  rep(i, k) 
    cout << s << " ";
  
  rep(i, n-k) {
    ll out = (s == 1000000000)  ? 1 : s + 1;
    cout << out << " ";
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			final int MOD = 2019;
			
			int L = scan.nextInt();
			int R = scan.nextInt();
			
			if(L/MOD==R/MOD){
				int start = L%MOD;
				int last = R%MOD;
				int minmod = 2018;
				
				for(int i =start;i<=last-1;i++) {
					for(int j = start+1;j<=last;j++){
						int c = i*j%MOD;
						if(minmod>c) {
							minmod=c;
						}
						
					}
				}
				
				
				System.out.println(minmod);
				
				
				
			}else{
				
				
				System.out.println(0);
			}
			
			
		}
		
		
	}
		
	

}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 110000;

int a[maxn], b[maxn];

bool check(int n,ll m,ll v,int p,int id){
    ll tot = m * (v - 1);
    for (int i = 1;i <= n;i++) a[i] = b[i];
    a[id] += m;
    int target = a[id];
    //If some problem has even higher rating already,add them.
    for (int i = n;i >= 1;i--){
        if (i == id) continue;
        if (tot == 0) break;
        if (a[i] > a[id]){
            tot -= m;
            a[i] += m;
            
        }
    }
    //Start from lowest and help them, but never exceed a[id]
    for (int i = n;i >= 1;i--){
        if (i == id) continue;
        if (tot == 0) break;
        if (a[i] < a[id]){
            int delta = a[id] - a[i];
            tot -= min(delta,(int)min(tot,m));
            a[i] += min(delta,(int)min(tot,m));
        }
    }
    //Finally, when there are still leftovers, all that are originally greater has now been added into full; all that are less are now the same; try to make fewest exceed our target
    //Check whether left is ordered from left to right

    if (tot > 0){
        for (int i = n-1;i >= 1;i--){
            int left_cur = m - (a[i] - b[i]);
            int left_nxt = m - (a[i+1] - b[i+1]);
            if (left_cur > left_nxt && left_nxt != 0){
                cout << "error\n";
            }
        }
        for (int i = n;i >= 1;i--){
            if (i != id){
                int left = m - (a[i] - b[i]);
                a[i] += min((ll)left, tot);
                tot -= min((ll)left, tot);
            }
        }
    }
    sort(a+1,a+n+1,std::greater<int>());
    if (target >= a[p]) return true;
    return false;
    //Now sort again
}
int main(int argc, const char * argv[]) {
    int n, p;
    ll m, v;
    cin >> n >> m >> v >> p;
    for (int i = 1;i <= n;i++){
        cin >> b[i];
    }
    sort(b+1,b+n+1);
    int lower = 1;
    int upper = n;
    int ans = n;
    while (lower <= upper){
        int mid = (lower + upper) / 2;
        if (check(n,m,v,p,mid)){
            ans = mid;
            upper = mid - 1;
        }
        else{
            lower = mid + 1;
        }
    }
    cout << (n - ans + 1) << endl;
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;


typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<ld> vld;

#define fi first
#define se second

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const ll inf = ll(1e18);
//const int MOD = (1e9 + 7);

int main() 
{

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
	#ifdef DEBUG_
		freopen("input.txt","r",stdin);
		clock_t start = clock();
	#endif
	cout.setf(ios::fixed), cout.precision(20);
	//code begins here

	string st;
	cin >> st;
	ll cnt = 0;
	ll n = st.size();
	for(int i=0;i<(int)st.size()/2;i++){
		if(st[i]!=st[n-i-1]) cnt++;
	}
	cout<<cnt<<"\n";
	
	//End of code 
	#ifdef DEBUG_
		cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
	#endif
	return 0;
}



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

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

while len(x) > 1:
    i = 0
    next = []
    while i < len(x) - 1:
        next.append(gcd(x[i], x[i+1]))
        i += 2

    x = [] + next

print(x[0])

Measured memory_bytes: 14252
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

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



int main() {
	int i, j, k;
	ll N, M, K;
	ll ans = 0;
	
	cin >> N >> M;
	if (N >= 10)cout << M;
	else
		cout << M + 100 * (10 - N);


	
	return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
const ll p=1000000007;
int main(){
  ll n,x;
  cin >> n >> x;
  ll ans=0;
  ll a[n];
  rep(i,n){
    cin >> a[i];
  }
  if(a[0]>x){
    ans+=a[0]-x;
    a[0]=x;
  }
  rep(i,n-1){
    if(a[i]+a[i+1]>x){
      ans+=a[i]+a[i+1]-x;
      a[i+1]=x-a[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include <math.h>
#include<algorithm>
#include<map>
#include<string>

using namespace std;

int main(int argc,char** argv)
{

	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << c-d+b <<' '<< d+c-a <<' '<< a-d+b <<' '<< b+c-a <<' '<< endl;

	return 0;

}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int x = sc.nextInt();
        int a[] = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
 
        Arrays.sort(a);
        int count = 0;
        boolean swich = true;
        for (int i = 0; i < N; i++) {
            if (x >= a[i]) {
                x -= a[i];
                count++;
            } else {
                swich = false;
                break;
            }
        }
        if (swich && x > 0){
            count--;
        } 
        
 
        System.out.println(count);
    }
}

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

int main(){
  int N;
  cin >> N;
  int A[N];
  int count = 0;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=1;i<N-1;i++){
    if(A[i]!=min(min(A[i-1],A[i]),A[i+1])&&A[i]!=max(max(A[i-1],A[i]),A[i+1])){
      count ++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
def solve():
    M = int(input())
    G = [[] for i in range(M)]
    deg = [0]*M
    N = int(input())
    for i in range(N):
        x, y = map(int, input().split())
        G[x-1].append(y-1)
        deg[y-1] += 1
    que = deque()
    ans = []
    for i in range(M):
        if deg[i] == 0:
            que.append(i)
    while que:
        v = que.popleft()
        ans.append(v+1)
        for w in G[v]:
            deg[w] -= 1
            if deg[w] == 0:
                que.append(w)
    print(*ans, sep='\n')
solve()



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

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    a -= k;
    if(  a < 0 ){
        b += a;
        a = 0;
    }
    if( a < 0  ){
        a = 0;
    }
    if( b < 0 ){
        b = 0;
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1010
#define LL long long
#define rep(i, x, y) for(int i = (x); i <= (y); ++ i)
inline int read() {
	char ch = getchar(); int x = 0, f = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while('0' <= ch && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}
int p[M][M], q[M][M];
int T;
vector<int> G[M];
int vis[M];
inline void dfs(int st, int x, int id, int a[]) {
	if(st == x || vis[x] == T) return;
	vis[x] = T; a[x] = id;
	for(int i = 0; i < G[x].size(); ++ i) {
		dfs(st, G[x][i], id, a);
	}
}
pair<int, int> A[M*200];
int main() {
	//freopen("in.txt", "r", stdin);
	int n = read(), m = read();
	rep(i, 1, m) {
		int u = read(), v = read();
		G[u].push_back(v);
		A[i] = make_pair(u, v);
	}
	rep(i, 1, n) {
		++ T;
		int id = 0;
		for(int j = 0; j < G[i].size(); ++ j) {
			dfs(i, G[i][j], ++ id, p[i]);
		}
		reverse(G[i].begin(), G[i].end());
		++ T; id = G[i].size();
		for(int j = 0; j < G[i].size(); ++ j) {
			dfs(i, G[i][j], id --, q[i]);
		}
	}
	rep(i, 1, m) {
		int u = A[i].first, v = A[i].second;
		if((q[v][u] > 0) == (p[u][v] != q[u][v])) {
			puts("same");
		}
		else puts("diff");
	}
	return 0;
}


Measured memory_bytes: 12160
def empty(t_max):
    return [-1] * t_max


def main():

    nv, ne = map(int, input().split())

    # graph
    graph_dict = dict()
    for i in range(nv):
        graph_dict[i + 1] = dict()

    for _ in range(ne):
        u, v, d = map(int, input().split())
        graph_dict[u][v] = d
        graph_dict[v][u] = d

    # orders
    t_max = int(input())
    order_list = [[] for _ in range(t_max)]
    for t in range(t_max):
        n_new = int(input())
        for _ in range(n_new):
            new_id, dst = map(int, input().split())
            order_list[t].append([new_id, dst])

    res = empty(t_max)
    for r in res:
        print(r)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 5504
#include<stdio.h>
#define MAX 200000

int max(int a, int b) {return a > b ? a: b;}
int min(int a, int b) {return a < b ? a: b;}

int main(){
    int R[MAX], i, n;

    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &R[i]);

    int maxv = -2000000000;
    int minv = R[0];

    for(i = 1; i < n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

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

    return 0;
}


Measured memory_bytes: 2568
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        n: i64,
    }

    fn sft(n: i64, k: i64) -> i64 {
        let k_string = k.to_string();

        if k > n {
            0
        } else if k_string.contains("3") && k_string.contains("5") && k_string.contains("7") {
            1 + sft_unchecked(n, k * 10 + 3) + sft_unchecked(n, k * 10 + 5) + sft_unchecked(n, k * 10 + 7)
        } else {
            0 + sft(n, k * 10 + 3) + sft(n, k * 10 + 5) + sft(n, k * 10 + 7)
        }
    }

    fn sft_unchecked(n: i64, k: i64) -> i64 {
        if k > n {
            0
        } else {
            1 + sft_unchecked(n, k * 10 + 3) + sft_unchecked(n, k * 10 + 5) + sft_unchecked(n, k * 10 + 7)
        }
    }

    println!("{}", sft(n, 0));
}


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

int main()
{
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string r;
	cin>>r;
	if(r==s){
		cout<<a-1<<' '<<b<<'\n';
	}
	else{
		cout<<a<<' '<<b-1<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)


int main(void){
    ll x;
    cin >> x;
    for(ll a=-10000; a<=10000; a++) {
        for(ll b=-10000; b<=10000; b++) {
            double res = (double)(a-b)*(double)(a*a*a*a+a*a*a*b+a*a*b*b+a*b*b*b+b*b*b*b);
            //ll A = a*a*a*a*a;
            //ll B = b*b*b*b*b;
            if(x-0.000001 <=res && res <= x+0.000001) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3632
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i

ans = 0
(a+1).times do |i|
  (b+1).times do |j|
    (c+1).times do |k|
      ans+=1 if i * 500 + j * 100 + k * 50 == x
    end
  end
end

puts ans


Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int A, B;

void solve() {
	cin >> A >> B;
	cout << max(max(A + B, A - B), A * B) << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
using System;
using System.IO;

namespace Contest
{
    class Program
    {
        private Scanner sc;
        public void Solve()
        {
            sc = new Scanner();
            int n = sc.NextInt();
            int[] p = sc.IntArray();
            int ans = 0;
            for (int i = 1; i < n - 1; i++)
            {
                if ((p[i - 1] > p[i] && p[i] > p[i + 1]) || (p[i - 1] < p[i] && p[i] < p[i + 1]))
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }

        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private readonly char _separator;
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

string s,t = "Yes";
ll n,m,a,b;
char c;

int main () {
  cin >> c;
  printf("%c\n", c+1);
}


Measured memory_bytes: 256
def main():
    N=int(input())
    r=[]
    for i in range(0,N):
        r.append(sorted(input()))
    r.sort()
    s=1
    ans=0
    for i in range(0,N-1):
        if r[i]==r[i+1]:
            s=s+1
        else:
            ans+=s*(s-1)//2
            s=1
    print(ans+s*(s-1)//2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24652
# E - This Message Will Self-Destruct in 5s
from bisect import *
N = int(input())
A = list(map(int,input().split()))
l = []
ans = 0
for j in range(N):
    tmp = j-A[j]
    ans += bisect_right(l,tmp)-bisect_left(l,tmp)
    insort(l,A[j]+j)
print(ans)

Measured memory_bytes: 103320
a = input()
b = 0
count = 0
while True:
  if a[count] == "A":
    b = count
    break
  else:
    count += 1
count = 1
while True:
  if a[-count] == "Z":
    print(len(a)-count-b+1)
    exit()
  else:
    count += 1


Measured memory_bytes: 3512