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

int main(void){
    
    int n,i;
    int a[120];
    scanf("%d",&n);
    
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
        if(a[i]%2==0)
            if((a[i]%3!=0) && (a[i]%5!=0)){
                printf("DENIED\n");
                return 0;
            }
    printf("APPROVED\n");
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        boolean[] used = new boolean[N];
        PriorityQueue<Dish> takahashi_list = new PriorityQueue<>(new TakahashiComparator());
        PriorityQueue<Dish> aoki_list = new PriorityQueue<>(new AokiComparator());
        for (int i = 0; i < N; i++) {
            Dish d = new Dish(i, scan.nextInt(), scan.nextInt());
            takahashi_list.add(d);
            aoki_list.add(d);
        }
        long takahashi_point = 0;
        long aoki_point = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                while (!takahashi_list.isEmpty()) {
                    Dish d = takahashi_list.poll();
                    if (used[d.id]) {
                        continue;
                    }
                    used[d.id] = true;
                    takahashi_point += d.A;
                    break;
                }
                continue;
            }
            while (!aoki_list.isEmpty()) {
                Dish d = aoki_list.poll();
                if (used[d.id]) {
                    continue;
                }
                used[d.id] = true;
                aoki_point += d.B;
                break;
            }
        }
        System.out.println(takahashi_point - aoki_point);
    }
    class TakahashiComparator implements Comparator<Dish> {
        @Override
        public int compare(Dish o1, Dish o2) {
            long o1_point = o1.A + o1.B;
            long o2_point = o2.A + o2.B;
            if (o1_point != o2_point) {
                return -Long.compare(o1_point, o2_point);
            }
            if (o1.B != o2.B) {
                return Long.compare(o1.B, o2.B);
            }
            if (o1.A != o2.A) {
                return Long.compare(o1.A, o2.A);
            }
            return Integer.compare(o1.id, o2.id);
        }
    }
    class AokiComparator implements Comparator<Dish> {
        @Override
        public int compare(Dish o1, Dish o2) {
            long o1_point = o1.A + o1.B;
            long o2_point = o2.A + o2.B;
            if (o1_point != o2_point) {
                return -Long.compare(o1_point, o2_point);
            }
            if (o1.A != o2.A) {
                return Long.compare(o1.A, o2.A);
            }
            if (o1.B != o2.B) {
                return Long.compare(o1.B, o2.B);
            }
            return Integer.compare(o1.id, o2.id);
        }
    }
    class Dish {
        int id;
        long A;
        long B;
        Dish(int id, long A, long B) {
            this.id = id;
            this.A = A;
            this.B = B;
        }
    }
}


Measured memory_bytes: 95080
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <map>
#include <cstring>

//typedef
typedef std::vector< int > vi;

int main(int argc, char* argv[]) {
  int N, M;

  std::string str;
  std::map< std::string, int > mm;
  std::map< std::string, int >::iterator itr;
  
  getline(std::cin, str);
  sscanf(str.c_str(), "%d", &N);

  for (int i = 0; i < N; i++) {
    getline(std::cin, str);
    //std::cout << mm[str] << std::endl;
    mm[str] = mm.count(str) == 1 ? mm[str] + 1 : 1;
    //std::cout << mm[str] << std::endl;
  }

  getline(std::cin, str);
  sscanf(str.c_str(), "%d", &M);

  for (int i = 0; i < M; i++) {
    getline(std::cin, str);
    mm[str] = mm.count(str) == 1 ? mm[str] - 1 : 1;    
  }

  int max_num = 0;
  for (itr = mm.begin(); itr != mm.end(); itr++) {
    //std::cout << itr->first << " " << itr->second << std::endl;
    max_num = itr->second > max_num ? itr->second : max_num;
  }

  std::cout << max_num << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  int64_t n,x;
  cin>>n>>x;

  vector<int64_t> a(n+1);


  for(int i=0;i<n;i++){
      cin>>a.at(i);
  }
  a.at(n)=x;
  sort(a.begin(),a.end());

//  for(int i=0;i<=n;i++){
//      cout<<a.at(i)<<" ";
//  }
//  cout<<endl;

  int64_t gcd_wk;
  if(n==1){
    gcd_wk=a.at(1)-a.at(0);
  }
  else{
  gcd_wk=gcd(a.at(1)-a.at(0),a.at(2)-a.at(1));
//  cout<<"gcd="<<gcd_wk<<endl;
  for(int i=2;i<n;i++){
    gcd_wk=gcd(a.at(i+1)-a.at(i),gcd_wk);
//    cout<<"gcd="<<gcd_wk<<endl;
  }
  }

  cout<<gcd_wk<<endl;

	return 0;
}

Measured memory_bytes: 3964
def main():
    N, K = map(int, input().split())
    ans = 0
    for i in range(1, N + 1):
        tmp = 1 / N
        cnt = i
        while cnt < K:
            tmp /= 2
            cnt *= 2
        ans += tmp
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 8928
s = input()

if s[0]=="W":
    l = [1]
else:
    l = [0,1]

for i in range(1,len(s)):
    if s[i]==s[i-1]:
        l[-1]+=1
    else:
        l.append(1)

rightw = sum(l[2::2])

ans = 0

for i in range(len(l)//2):
    ans += l[2*i+1]*rightw
    if i!=len(l)//2-1:
        rightw -= l[2*i+2]

print(ans)

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

typedef long long ll;

using namespace std;

string s;

ll totalSum(int in, int last)
{
    if(in == s.length())
    {
        if(last == s.length())
            return 0;
        return stoll(s.substr(last));
    }

    ll p1 = totalSum(in+1,last);
    ll p2 = totalSum(in+1,in+1) + max(0ll,(1ll<<(s.length() - in - 2))) * stoll(s.substr(last,in-last+1));
    //cout << in << " " << last << endl;
    //cout << p1 << endl;
    //cout << p2 << " " << stoll(s.substr(last,in-last+1))<< endl;
    return p1 + p2;
}

int main()
{
    cin >> s;
    cout << totalSum(0,0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
int n;
long long int a[maxn];

int pilha[maxn];
int tam;
long long int l[maxn], r[maxn];
long long int resp;

int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++){
		scanf("%lld", &a[i]);	
	}
	
	//faz o histograma, calcula l, r
	for(int i=1; i<=n; i++){
		while(tam!=0 && a[pilha[tam]]>a[i]){
			r[pilha[tam]]=i;
			tam--;	
		}
		
		l[i]=pilha[tam];
		tam++;
		pilha[tam]=i;	
	}
	while(tam!=0){
		r[pilha[tam]]=n+1;
		tam--;	
	}
	
	for(long long int i=1; i<=n; i++){
		resp+=(r[i]-i)*(i-l[i])*a[i];	
	}
	printf("%lld\n", resp);	
		
	return 0;	
}

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

int main()
{
    int D,G;
    std::vector<int> p, c;
    std::vector<int> points;

    std::cin >> D >> G;
    for(int i=0; i<D; i++) {
        int pi, ci;
        std::cin >> pi >> ci;
        p.push_back(pi);
        c.push_back(ci);
    }

    int ans = 1e9;

    for(int bit=0; bit < (1<<D); bit++){
        int sum=0;
        int num=0;
        int rest_max=-1;

        // answer fully
        for(int i=0; i<D; i++){
            if(bit & (1<<i)){
                sum+=p[i]*(i+1)*100 + c[i];
                num+=p[i];
            } else {
                rest_max = i;
            }
        }

        // answer partly
        if(sum < G){
            int point = (rest_max+1)*100;
            int need = (G - sum + point -1)/point;
            if(need >= p[rest_max]){
                continue;
            }
            num+=need;
        }
        ans = std::min(ans,num);
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
using namespace std;
#define N 32

int main(){
  vector<int> data = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  int K;
  cin >> K;
  
  cout << data.at(K-1) << endl;
}

Measured memory_bytes: 3608
n,m,c = map(int,input().split())
input_b = list(map(int,input().split()))
a_list=[input() for i in range(n)]
count = 0
for i in range(n):
  answer = c
  aitems = list(map(int,a_list[i].split()))
  for j in range(m):
    answer += input_b[j] * aitems[j]
  if answer > 0:
    count+=1
print(count)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int a, b, C;
    int deg;
    double rad;
    double PI = acos(-1);  // PI = 3.141593...
    cin >> a >> b >> C;
    deg = C;
    rad = deg * PI / 180;
    cout << 0.5 * a * b * sin(rad) << "\n";
    cout << a + b + sqrt(a * a + b * b - 2 * a * b * cos(rad)) << "\n";
    cout << (0.5 * a * b * sin(rad)) * 2.0 / a << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3640
A = list(list(map(int, input().split())) for i in range(3))
N = int(input())
B = [int(input()) for i in range(N)]
result = [[0]*3 for i in range(3)]
#print(A, N, B, result)

for i in range(3):
    for j in range(3):
        for k in range(N):
            #print(A[i][j], B[k])
            if A[i][j] == B[k]:
                result[i][j] = 1
                break
            else:
                result[i][j] = 0

if (result[0][0]==1 and result[0][1]==1 and result[0][2]==1) \
or (result[1][0]==1 and result[1][1]==1 and result[1][2]==1) \
or (result[2][0]==1 and result[2][1]==1 and result[2][2]==1) \
or (result[0][0]==1 and result[1][0]==1 and result[2][0]==1) \
or (result[0][1]==1 and result[1][1]==1 and result[2][1]==1) \
or (result[0][2]==1 and result[1][2]==1 and result[2][2]==1) \
or (result[0][0]==1 and result[1][1]==1 and result[2][2]==1) \
or (result[0][2]==1 and result[1][1]==1 and result[2][0]==1) :
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;cin>>n>>m;
    vint k(m), p(m);
    vvint s(m);
    rep(i, m){
        cin>>k[i];
        rep(j, k[i]){int tt;cin>>tt;s[i].push_back(tt);}
    }
    rep(i, m){
        cin>>p[i];
    }
    ll ans = 0;
    rep(bit, 1<<n){
        bool flag = true;
        rep(j, m){
            int tmp = 0;
            rep(l, k[j]){
                if((bit&(1<<(s[j][l]-1)))>0)tmp++;
            }
            if(tmp%2!=p[j]){flag = false;break;}
        }
        if(flag)ans++;
    }

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


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

using namespace std;

const int H = 1000 + 7;

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

int main() {
  int n, k;
  cin >> n >> k;
  int ans = n - k + 1;
  cout << ans << endl;
  return 0;
}
/*
 && ((i > 0 && s[i - 1][j] == '#') || (i < h - 1 && s[i + 1][j] == '#') || (j > 0 && s[i][j - 1] == '#') || (j < w - 1 && s[i][j + 1] == '#'))
*/


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
 
class Main {
 
	public static void main(String[] args) {
 
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
 
		String[] s = new String[k];
 
		for (int i = 0; i < k; i++) {
			s[i] = in.next();
		}
 
		long sum = n-1;
		boolean isOK = false;
 
		while (true) {
			sum ++;
			isOK = true;
 
			String sumstr = Long.toString(sum);
			
			for (int i = 0; i < sumstr.length(); i++) {
				for (int j = 0; j < k; j++) {
					if (sumstr.substring(i, i + 1).equals(s[j])) {
						isOK = false;
						break;
					}
 
				}
			}
			if (isOK == true) {
				break;
			}
		}
 
		System.out.println(sum);
		in.close();
 
	}
 
}

Measured memory_bytes: 19264
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

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

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    vector<int64_t> psum(N);
    for(int i=0; i<N; i++) {
        psum[i] = distance(upper_bound(C.begin(), C.end(), B[i]), C.end());
    }
    partial_sum(psum.rbegin(), psum.rend(), psum.rbegin());

    int64_t ans = 0;
    for(int i=0; i<N; i++) {
        ans += psum[distance(B.begin(), upper_bound(B.begin(),B.end(), A[i]))];
    }

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


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define l long long
int main()
{
    l a,b,c,d;
    cin>>a>>b>>c>>d;
    for(l i=0; i<100; i++)
    {
        if(a<=0 || c<=0)
        {
            break;
        }
        if(i%2!=0)
        {
            a-=d;
        }
        else
        {
            c-=b;
        }
    }
    if(a<=0)
    {
        cout<<"No"<<endl;
    }
    else
        cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 3604
n, m, x = map(int, input().split())
c = [0] * n
for i in range(n):
    c[i] = [int(_) for _ in input().split()]

ans = 10**10
for i in range(2 ** n):
    state = [0] * n
    for j in range(n):
        state[j] = (i >> j) & 1
    #print(state)
    num = [0] * m
    val = 0

    for j in range(n):
        if state[j] == 1:
            for k in range(m):
                num[k] += c[j][k+1]
            val += c[j][0]

    flag = True
    for j in range(m):
        if num[j] < x:
            flag = False
            break
    if flag:
        ans = min(ans, val)

if ans == 10**10:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 74024
#include<bits/stdc++.h>
#define MAXN 105
using namespace std;

int n,a[MAXN],b[MAXN];

template<typename Drake>
void Read(Drake &x){
	x=0;char ch=getchar();int f=1;
	while(!isdigit(ch)){
		if(ch=='-')f=-f;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x=x*f;
}

template<typename Drake>
void write(Drake x){
	if(x>=10)write(x/10);
	putchar((char)(x%10+'0'));
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

int main(){
	Read(n);
	for(int i=1;i<=n;++i)Read(a[i]),Read(b[i]);
	for(int i=1;i<=n-2;++i){
		if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include <bitset>
#include <cstdio>
using namespace std;
bitset<10000> b[10];
int n=0,m=0,res=0;

void Fan(int i)
{
	if (i==n)//此&#26102;，已没有b[i]了。
	{
		int r=0;
		for (int ii=0;ii<m;++ii)
		{
			int up=0;
			for (int io=0;io<n;++io)
			{
				if (b[io][ii])  //b[10][10000]
				{
					++up;
				}
			}
			r+=((up>n-up)?up:(n-up));
		}
		if (r>res)
		{
			res=r;
		}
		return ;
	}
	Fan(i+1);
	b[i].flip();
	Fan(i+1);
	b[i].flip();
}

void debug()
{
	freopen("AOJ-0525-in.txt","r",stdin);
	freopen("AOJ-0525-out.txt","w",stdout);
}

int main()
{
//	debug();
	while (scanf("%d%d",&n,&m),n)
	{
		for (int ri=0;ri<n;++ri)
		{
			for (int ci=0;ci<m;++ci)
			{
				int tmp;
				scanf("%d",&tmp);
				b[ri][ci]=(bool)(tmp);
			}
		}
		Fan(0);
		printf("%d\n",res);
		res=0;
		n=0;
	}
	return 0;
}

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

int main() {
  int n,k;
  cin>>n>>k;
  int p=0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(k-i-j>=0 &&k-i-j<=n){
        p++;
      }
    }
  }
  cout<<p<<endl;
}

Measured memory_bytes: 256
function main()
	lines=readlines()
	H,W=map(x->parse(Int,x),split(shift!(lines)))
	S=Array{Int,2}(H,W)
	for i in 1:H
		s=shift!(lines)
		for j in 1:W
			S[i,j]=s[j]=='.'
		end
	end
	dp1=copy(S)
	dp2=copy(S)
	dp3=copy(S)
	dp4=copy(S)
	for i=1:H,j=1:W
		if i>1
			dp1[i,j]=S[i,j]*(dp1[i-1,j]+1)
			dp2[H-i+1,j]=S[H-i+1,j]*(dp2[H-i+2,j]+1)
		end
		if j>1
			dp3[i,j]=S[i,j]*(dp3[i,j-1]+1)
			dp4[i,W-j+1]=S[i,W-j+1]*(dp4[i,W-j+2]+1)
		end
	end
	ans=0
	for i=1:H,j=1:W
		ans=max(ans,dp1[i,j]+dp2[i,j]+dp3[i,j]+dp4[i,j]-3)
	end
	println(ans)
end
main()


Measured memory_bytes: 271340
import Control.Applicative

main :: IO ()
main = solve <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Int
solve [a, b, c] = let cpw = 7 * a + b
                      (q, r) = c `divMod` cpw
                  in 7 * q + if r > 6 * a then 7 else (r + a - 1) `div` a



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

int main() {
    int N;
    cin >> N;
    bool can = false;
    rep(i, 9) {
        rep(j, 9) {
            if ((i + 1) * (j + 1) == N) can = true;
        }
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define repr(i, a, n) for (ll i = n - 1; (ll)a <= i; i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e14 + 99);
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
template <typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T>
T mpow(T a, T n)
{
    T res = 1;
    for (; n; n >>= 1)
    {
        if (n & 1)
            res = res * a;
        a = a * a;
    }
    return res;
}



signed main()
{
    cin.tie(0);ios::sync_with_stdio(false);
    ll n, m, l;
    cin >> n >> m >> l;
    ll dp[n][n], dp2[n][n];

    vector<vector<ll>> e(n, vector<ll>(n, INF));

    rep(i, 0, m)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        if (c > l)
            c = LINF;
        e[a][b] = c;
        e[b][a] = c;
    }

    rep(i, 0, n) rep(j, 0, n)
    {
        dp[i][j] = e[i][j];
        dp2[i][j]=INF;
        if (i == j)
        {
            dp[i][j] = 0;
            dp2[i][j]=0;
            e[i][j] = 0;
        }
    }

    rep(k, 0, n) rep(i, 0, n) rep(j, 0, n)
    {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    }

    rep(i, 0, n) rep(j, 0, n)
    {
        if(dp[i][j]<=l)dp2[i][j]=1;
    }

    rep(k, 0, n) rep(i, 0, n) rep(j, 0, n)
    {
        dp2[i][j] = min(dp2[i][j], dp2[i][k] + dp2[k][j]);
    }

    int q;
    cin >> q;
    while (q--)
    {
        ll s, g;
        cin >> s >> g;
        s--;
        g--;
        if (dp2[s][g] >= INF)
            cout << -1 << endl;
        else
            cout << dp2[s][g]-1 << endl;
    }
}

Measured memory_bytes: 2688
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>
#include <random>
#include <fstream>


using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)
#define MD 1000000007

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

	if (c <= a + b)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


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


int main()
{
    string s;
    int min;
    cin >> s;
    int n = s.length();
    string d[n];
    int f[n-2];
    rep(i,n){
        d[i]=s[i];
    }
    d[0]+=d[1];
    d[0]+=d[2];
    f[0]=atoi(d[0].c_str());
    min=abs(f[0]-753);

    rep(i,n-2){
        d[i]+=d[i+1];
        d[i]+=d[i+2];
        f[i]=atoi(d[i].c_str());
        if(min>abs(f[i]-753)){
            min=abs(f[i]-753);
        }else{
            ;
        }

    }
    printf("%d",min);
}

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



int main() {

	string s;
	cin >> s;
	int ans = 700;

	for (int i = 0; i < 3; i++){
		if (s[i] == 'o')ans += 100;
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 256
struct T{int a,b;}A[3333];long P[3333],M=1e9+7,F[2<<17],I[2<<17],X;i,j,k,t;
c(a,b)struct T*a,*b;{t=a->a-b->a?:a->b-b->b;}
p(a,b){return b?p(a%M*a%M,b/2)*(b%2?a:1L)%M:1;}
f(a,b){return F[a+b]*I[a]%M*I[b]%M;}
main(s)
{
	for(X=*F=*I=1;++t<2<<17;)I[t]=p(X=F[t]=X*t%M,M-2);
	for(k=A;~scanf("%d",k);k+=4)i++-1||gets(P);
	for(qsort(A,i/=2,8,c);j<i;P[j++]=X)
		for(X=f(s=A[k=j].a-=1,t=A[j].b-=1);k--;)X=t<A[k].b?X:(X-f(s-A[k].a,t-A[k].b)*P[k]%M+M)%M;
	printf("%d",X);
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
using namespace std;
int main() {
    string s;
    int c['z' + 1] = {};

    while (true) {    
        getline(cin ,s);
        if (s.size() == 0) break;
        for (int i = 0; i < s.size(); i++) {
            c[tolower(s[i])]++;
        }
    }
    
    for (char i = 'a'; i <= 'z'; i++) {
        cout << i << " : " << c[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3204
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        var N = cin.nextlong;
        var P = cin.nextlong;
        if (N == 1)
        {
            WriteLine(P);
            return;
        }
        else if(N >= 40)
        {
            WriteLine(1);
            return;
        }

        long ans = 1L;
        for (long i = 2; i <= 1000000; i++)
        {
            var t = 1L;
            bool flag = true;
            for (int j = 0; j < N; j++)
            {
                t *= i;
                if (j != N - 1 && P <= t)
                {
                    WriteLine(ans);
                    return;
                }
                if (P % t != 0)
                {
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                ans = i;
            }
        }

        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 13140
use proconio::{input, fastout};

const MOD: usize = 1_000_000_007;

fn modpow(mut a: usize, mut x: usize, m: usize) -> usize {
    let mut ret = 1;
    while x > 0 {
        if x & 1 == 1 { ret = ret * a % m }
        a = a * a % m;
        x >>= 1;
    }
    ret
}


fn count_gcd_is_1(n: usize, k: usize, count: &mut Vec<usize>) -> usize {
    let mut ret = modpow(k, n, MOD);
    for i in 2..=k {
        let j = k / i;
        if count[j] == 0 {
            count[j] = count_gcd_is_1(n, j, count);
        }
        ret = (ret + MOD - count[j]) % MOD;
    }
    ret
}

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut count = vec![0; k + 1];
    let mut ans = (k / 2 + 1 + k) * (k - k / 2) / 2 % MOD;

    for i in 1..=k / 2 {
        ans = (ans + i * count_gcd_is_1(n, k / i, &mut count)) % MOD
    }

    println!("{}", ans);
}

Measured memory_bytes: 2192
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll int128_t
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
// #define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
#if !defined(ONLINE_JUDGE)
#include "debugging.h"
#endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
int const mod = 998244353;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 3055;
int const inf = 2e16;


void solve(){
    int i,j;
    int x;
    cin >> x;
    int g = __gcd(360LL , x);
    int x1 = x/g;
    int y1 = 360/g;
    cout << y1 << endl;
}              



int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*

x*k = y*360

k = 360*y/x

*/

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

int main() {
	int n,m,x,y,X,Y,flag;
	int a[22][22];
	char c;
	while(1){
		flag = 0;
		X = Y = 10;
		for(int i = 0;i < 22;i++){
			for(int j = 0;j < 22;j++){
				a[i][j] = 0;
			}
		}
		cin >> n;
		if(n == 0)break;
		for(int i = 0;i < n;i++){
			cin >> x >> y;
			a[y][x] = 1;
		}
		cin >> m;
		for(int j = 0;j < m;j++){
			cin >> c >> n;
			if(c == 'N'){
				for(int i = Y;Y <= i + n;Y++){
					a[Y][X] = 0;
				}
				Y--;
			}
			else if(c == 'E'){
				for(int i = X;X <= i + n;X++){
					a[Y][X] = 0;
				}
				X--;
			}
			else if(c == 'S'){
				for(int i = Y;Y >= i - n;Y--){
					a[Y][X] = 0;
				}
				Y++;
			}
			else if(c == 'W'){
				for(int i = X;X >= i - n;X--){
					a[Y][X] = 0;
				}
				X++;
			}
		}
		for(int i = 0;i < 22;i++){
			for(int j = 0;j < 22;j++){
				if(a[i][j] == 1)flag = 1;
			}
		}
		if(flag == 0)cout << "Yes" <<endl;
		else cout <<"No"<<endl;
	}
	return 0;
}

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

#define BUF_SIZE 2500000
#define HASH_SIZE 2048

struct list {
  struct list *next;
  long num;
  long cnt;
};
// create hash
struct list *create_hashtable(int size) {
  struct list *htable = malloc(size*sizeof(struct list));
  int i;
  for(i = 0; i < size; i++) {
    htable[i].next = &htable[i];
  }
  return htable;
}

int get_key(long num) {
  return num & (HASH_SIZE-1);
}

void insert(struct list *htable, long num) {
  int key = get_key(num);
  struct list *head = &htable[key];
  struct list *elem;
  for(elem = head->next; elem != head; elem = elem->next) {
    if(elem->num == num) {
      elem->cnt++;
      return;
    }
  }

  // create
  elem = malloc(sizeof(struct list));
  elem->next = head->next;
  elem->num = num;
  elem->cnt = 1;
  head->next = elem;
  return;
}


int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  int num;

  long prev = 0;
  struct list *htable = create_hashtable(HASH_SIZE);
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  sscanf(line, "%d", &num);

  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char *tmpbuf = line;
  int i, j;
  insert(htable, 0); // cum[0] = 0;
  for(i = 0; i < num; i++) {
    char *tmp = strtok(tmpbuf, " ");
    long n = strtol(tmp, NULL, 10);
    tmpbuf = NULL;
    prev = prev + n;
    insert(htable, prev);
  }

  long ans = 0;
  for(i = 0; i < HASH_SIZE; i++) {
    struct list *tmp;
    struct list *head = &htable[i];
    for(tmp = head->next; tmp != head; tmp = tmp->next) {
      ans += (tmp->cnt - 1) * tmp->cnt /2; // nP2
    }
  }
  printf("%ld\n", ans);
}

Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <iomanip>
#include <queue>
#include <cctype>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

//vector<vector<int>> data(3, vector<int>(4));

int main(){

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

    char s;
    cin >> s;

    if (isupper(s)) {
      cout << "A" << endl;
    } else {
      cout << "a" << endl;
    }

    return 0;
}

Measured memory_bytes: 3648
s=input()
n=int(s)
s=list(s)
d=len(s)
r=0
for ii in range(d-1):
  if ii%2==0:
    r+=10**(ii+1)-10**ii
if d%2==1:
  r+=n-10**(d-1)+1
print(r)
    

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  int N; cin >> N;
  int a[N];
  for (int i = 0; i < N; i++)
    cin >> a[i];
  int c = 0;
  for (int i = 0; i < N; i++) {
    while (a[i] % 2 != 1) {
      c++;
      a[i] /= 2;
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

int A,B;
int d[11][11];
const int C = 101;
int S = 1 , T = 2 * C;
int N = T , M = 2 * (C-1) + C * C;
int e[C][C];
 
int main(){
	cin >> A >> B;
	for (int i = 1; i <= A; ++i) {
		for (int j = 1; j <= B; ++j) {
			cin >> d[i][j];
		}
	}
	rep(i,C) rep(j,C){
		for (int x = 1; x <= A; ++x) {
			for (int y = 1; y <= B; ++y) {
				e[i][j] = max(e[i][j] , d[x][y]-i*x-j*y);
			}
		}
	}

	for (int x = 1; x <= A; ++x) {
		for (int y = 1; y <= B; ++y) {
			int z = C;
			rep(i,C) rep(j,C) z = min(z,e[i][j]+i*x+j*y);
			if(z != d[x][y]) return cout << "Impossible" << endl , 0;
		}
	}
	cout << "Possible" << endl;
	cout << N << ' ' << M << endl;
	for (int i = 1; i < C; ++i) {
		cout << i << ' ' << i+1 << " X" << endl;
		cout << C+i << ' ' << C+i+1 << " Y" << endl;
	}
	rep(i,C) rep(j,C) cout << i+1 << ' ' << N-j << ' ' << e[i][j] << endl;
	cout << S << ' ' << T << endl;
	return 0;
}

Measured memory_bytes: 3684
import sys
input = sys.stdin.readline
def print_ans(N,A,B,C):
    """Test Case
    >>> print_ans(3,"3 1 2","2 5 4","3 6")
    14
    >>> print_ans(4,"2 3 4 1","13 5 8 24","45 9 15")
    74
    >>> print_ans(2,"1 2","50 50","50")
    150
    """
    A_arr = list(map(int,A.split()))
    B_arr = list(map(int,B.split()))
    C_arr = list(map(int,C.split()))
    ans = sum(B_arr)
    for i in range(N - 1):
        if A_arr[i] + 1 == A_arr[i + 1]:
            ans += C_arr[A_arr[i] - 1]
    print(ans)
if __name__ == '__main__':
    N = int(input().rstrip())
    A = input().rstrip()
    B = input().rstrip()
    C = input().rstrip()
    print_ans(N,A,B,C)

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

int solve(vector< vector<int> > mat,vector<int> A){
	int n = mat.size();
	for(int i = 0 ; i < n ; i++){
		int p = -1;
		for(int j = i ; j < n ; j++){
			if( mat[j][i] == 1 ){
				p = i;
				swap(A[i],A[j]);
				for(int k = 0 ; k < n ; k++)
					swap(mat[i][k],mat[j][k]);
				break;
			}
		}
		if( p == -1 ) continue;
		for(int j = 0 ; j < n ; j++){
			if( mat[j][i] == 1 && j != p ){
				A[j] ^= A[p];
				for(int k = 0 ; k < n ; k++){
					mat[j][k] ^= mat[p][k];
				}
			}
		}
	}
	for(int i = 0 ; i < n ; i++){
		int answer = 0;
		for(int j = 0 ; j < n ; j++){
			if( mat[i][j] ) answer++;
		}
		if( answer == 0 && A[i] == 1 ) return 0;
	}
	return 1;
	
	
}
int main(){
	int W,H,K;
	while(cin >> W >> H >> K && W){
		vector<int> A(W*H);
		for(int i = 0 ; i < H ; i++)
			for(int j = 0 ; j < W ; j++)
				cin >> A[i*W+j];
		
		vector< vector<int> > mat(H*W,vector<int>(H*W));
		for(int i = 0 ; i < H ; i++){
			for(int j = 0 ; j < W ; j++){
				for(int k = 0 ; k < H ; k++){
					for(int l = 0 ; l < W ; l++){
						int d = abs(i-k) + abs(j-l);
						if( d == K || d == 0 ){
							mat[i*W+j][k*W+l] = true;
						}
					}
				}
			}
		}
		cout << solve(mat,A) << endl;
	}
}

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

 int main()
 {
   ios::sync_with_stdio(!cin.tie(0));
   int n; cin>>n;
   long long int s=0;
   
   for(int i=1;i<=n;i++)
     for(int j=1;j<=n;j++)
       for(int k=1;k<=n;k++)
          s+= __gcd(i,__gcd(j,k));
   cout<<s;
 }

Measured memory_bytes: 3656
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		Integer[] s = {sc.nextInt(), sc.nextInt(), sc.nextInt()};
		Arrays.sort(s);
		System.out.printf("%d %d %d\n", s[0], s[1], s[2]);
	}
}




Measured memory_bytes: 26504
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	int sum[]=new int[2];
	for(int i=0;i<2;i++)
	    {
		int info,math,sci,eng;
		info=scan.nextInt();
		math=scan.nextInt();
		sci=scan.nextInt();
		eng=scan.nextInt();
		sum[i]+=info+math+sci+eng;
	    }
	if(sum[0]>sum[1] || sum[0]==sum[1])System.out.println(sum[0]);
	else if(sum[0]<sum[1])System.out.println(sum[1]);
	
    }
}

Measured memory_bytes: 17360
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> v;
  int sum=0;
  REP(i,n){
    int s;
    cin >> s;
    sum += s;
    if(s%10>0) v.push_back(s);
  }
  if(sum%10>0) cout << sum<<'\n';
  else if(v.size()==0) cout << 0 << '\n';
  else{
  	sort(ALL(v));
    cout << sum-v[0] << '\n';
  }
  return 0;
}


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

#define sz(x) int(x.size())
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef long long ll;

const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int n, m;
ll gt[maxn], igt[maxn];
ll f[31][31627 * 2];

ll Pow(ll a, ll b){
  if (b == 0) return 1;
  ll tmp = Pow(a, b / 2);
  tmp = (tmp * tmp) % mod;
  if (b % 2) return (tmp * a) % mod;
  return tmp;
}

void init(){
  const int maxp = 1e5;
  gt[0] = 1;
  for (int i = 1; i <= maxp; ++i)
    gt[i] = (gt[i-1] * i) % mod;

  igt[maxp] = Pow(gt[maxp], mod - 2);

  for (int i = maxp - 1; i >= 0; --i)
    igt[i] = (igt[i+1] * (i + 1)) % mod;
}

ll comb(int k, int n){
  return ( (gt[n] * igt[n - k]) % mod * igt[k]) % mod;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  cin >> n >> m;
  if (m == 1){
    cout << 1; return 0;
  }
  vector<int> div;

  for (int i = 1; i * i <= m; ++i){
    if (m % i == 0){
      div.push_back(i);
      if (i * i != m) div.push_back(m / i);
    }
  }

  int len = div.size();
  unordered_map<int, int> Pos;
  for (int i = 0; i < len; ++i)
    Pos[div[i]] = i;

  for (int i = 1; i < len; ++i)
    f[1][i] = 1;

  for (int k = 1; k < 30; ++k){
    for (int i = 1; i < len; ++i){
      for (int j = 1; j < len; ++j){
        if (div[j] % div[i] == 0 && div[j] / div[i] > 1)
          f[k+1][j] = (f[k+1][j] + f[k][i]) % mod;
      }
    }
  }


  init();
  ll ans = 0;
  for (int x = 1; x <= min(30, n); ++x){
    ans += f[x][Pos[m]] * comb(x, n);
    ans %= mod;
  }
  cout << ans;

}




Measured memory_bytes: 15232
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
int n, m;
int map[55][55];
int zg[55];
int x[55], y[55];
queue<int> q;
bool bfs() {
	memset(zg, 0, sizeof zg);
	q.push(1);
	zg[1] = 1;
	while(!q.empty()) {
		for(int i = 1; i <= n; i++)
			if(map[i][q.front()] == 1 && zg[i] == 0)
				q.push(i), zg[i] = 1;
		q.pop();
	}
	for(int i = 1; i <= n; i++)
		if(zg[i] == 0)
			return false; 
	return true;
}
int main() {
	int ans = 0;
	cin >> n >> m;
	for(int i = 1; i <= m; i++)
		cin >> x[i] >> y[i], map[x[i]][y[i]] = map[y[i]][x[i]] = 1;
	for(int i = 1; i <= m; i++) {
		map[x[i]][y[i]] = 0;
		map[y[i]][x[i]] = 0;
		if(bfs() == false)
			ans++;
		map[x[i]][y[i]] = 1;
		map[y[i]][x[i]] = 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var m int
	Fscan(in, &m)
	vis := make([]bool, m)
	x := 7%m
	for i := 1;;i++ {
		if x == 0 {
			Fprintln(out, i)
			return
		}
		x=(x*10+7)%m
		if vis[x] {
			break
		}
		vis[x]=true
	}
	Fprintln(out, -1)
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 2884
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, t = map(int, input().split())
    T = list(map(int, input().split()))

    res = 0
    for i in range(n - 1):
        res += t if T[i] + t <= T[i + 1] else T[i + 1] - T[i]

    print(res + t)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 25712
import java.util.*;import java.io.*;import java.math.*;

public class Main
{

    public static void process()throws IOException
    {
        int a=ni();
        pn(3*a*a);
    }


    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();

        long s = System.currentTimeMillis();
        int t=1;
        //t=ni();
        while(t-->0)
            process();

        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;
    static long mod=(long)1e9+7l;

    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } 
            catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

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

int main()
{
  string s;
  cin >> s;
  int64_t len = s.length();
  int64_t ans = 0;
  int64_t a = 0;
  int64_t i = 0;

  while (i < len) {
    if (s[i] == 'A') {
      a++;
      i++;
      continue;
    }
    if (s[i] == 'B') {
      if (i + 1 < len && s[i + 1] == 'C') {
        ans += a;
        i += 2;
      } else {
        a = 0;
        i++;
      }
      continue;
    }
    a = 0;
    i++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 644
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


class Cell{
public:
	int g;
	int a;
	Cell(){g=0;a=0;};
};

int main(){
	while(true){
		int rL,cL,ecL;
		cin >> rL >> cL >> ecL;			if(!rL&&!cL&&!ecL) return 0;
		
		int rS[rL];
		FOR(rI,0,rL) cin >> rS[rI];
		
		Cell cS[cL+1];
		FOR(ecI,0,ecL){
			int cI,g,a;
			cin >> cI >> g >> a;
			cS[cI].g = g;
			cS[cI].a = a;
		}

		double n2m2fp[cL+1][cL*100+100]; // ci==n no cell ni okane m dake motte saikoro de kuru kakuritsu
		double n2m2ep[cL+1][cL*100+100]; // ci==n no cell ni okane m dake motte tobasarete kuru kakuritsu
		FOR(n,0,cL+1) FOR(m,0,cL*100) {n2m2fp[n][m] = 0; n2m2ep[n][m] = 0;};
		n2m2fp[0][0]=1.0;

		FOR(n,0,cL){
			FOR(m,0,cL*100){
				double fp = n2m2fp[n][m], ep=n2m2ep[n][m];
				Cell c = cS[n];
				//if((fp==0)&&(ep==0)) continue;
				//if((fp!=0)||(ep!=0)) cout<<"n:"<<n<<" m:"<<m<<" fp:"<<fp<<" ep:"<<ep<<endl;
				FOR(rI,0,rL){
					int r = rS[rI];
					n2m2fp[min(cL,n+r)][m] += ep / rL;
				}

				if(c.g==0){
					FOR(rI,0,rL){
						int r = rS[rI];
						n2m2fp[min(cL,n+r)][m] += fp / rL;
					}
				}
				if(c.g==1){
					n2m2ep[min(cL,n+c.a)][m] += fp;
				}
				if(c.g==2){
					FOR(rI,0,rL){
						int r = rS[rI];
						n2m2fp[min(cL,n+r)][m+c.a] += fp / rL;
					}
				}
				if(c.g==3){
					FOR(rI,0,rL){
						int r = rS[rI];
						n2m2fp[min(cL,n+r)][max(0,m-c.a)] += fp / rL;
					}
				}
			}
		}

		double res = 0.0;
		int n = cL;
		FOR(m,0,cL*100){
			double fp = n2m2fp[n][m], ep=n2m2ep[n][m];
			//if((fp!=0)||(ep!=0)) cout<<"n:"<<n<<" m:"<<m<<" fp:"<<fp<<" ep:"<<ep<<endl;
			res += m*(fp+ep);
		}
		cout << int(res) << endl;


	}


}

Measured memory_bytes: 5224
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include <ios>
#include <iomanip>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef tuple<ll,ll,ll> Tl;

int atcoder(){
    //入力
    string s;
    ll k;
    cin >> s >> k;
    string ans = "1";
    
    ll n = min((ll)s.length(),k);
    REP(i,0,n){
        if(s[i]!='1'){ans= s[i]; break;}
    }
    
    //出力
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = long.Parse(inputs[0]);
            var m = long.Parse(inputs[1]);
            var result = n * m;
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27492
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;
use std::collections::BTreeSet;

fn main() {
    input! {
        p: [(isize, isize)]
    }
    let ans = 0;

    let mut s = BTreeSet::new();

    for &(x, y) in &p {
        s.insert(x + y);
    }

    let ans = std::cmp::max(ans, s.iter().rev().next().unwrap() - s.iter().next().unwrap());

    let mut s = BTreeSet::new();

    for &(x, y) in &p {
        s.insert(-x + y);
    }

    let ans = std::cmp::max(ans, s.iter().rev().next().unwrap() - s.iter().next().unwrap());

    let mut s = BTreeSet::new();

    for &(x, y) in &p {
        s.insert(x - y);
    }

    let ans = std::cmp::max(ans, s.iter().rev().next().unwrap() - s.iter().next().unwrap());

    let mut s = BTreeSet::new();

    for &(x, y) in &p {
        s.insert(-x - y);
    }

    let ans = std::cmp::max(ans, s.iter().rev().next().unwrap() - s.iter().next().unwrap());
    println!("{}", ans);
}


Measured memory_bytes: 22124