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

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename T>
void in(T& x) {
    std::cin >> x;
}

template <typename T>
void out(const T H) {
    std::cout << H;
}

template <typename T1, typename... T2>
void out(const T1 H, const T2... T) {
    std::cout << H << " "; out(T...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& v) {
    return os << "(" << v.first << " " << v.second << ")";
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    os << "[ "; for (auto &i: v) os << i << " "; return os << "]";
}

template <typename T>
void eout(const char *s, const T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define err(args...)      eout(#args, args)

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()
#define lla(v)            (v).rbegin(), (v).rend()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

const int INF           = 2147483647;
const long long int LNF = 9223372036854775807LL;

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N  = 505050;
const int MD = 1000*1000*1000 + 7;

int solve();
int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0);
    //std::cout.tie(0);

    //inn(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}

int solve() {
    inn(n);
    vi a(n); rep(i, n) in(a[i]);

    int c = 0;
    rep(i, n) c += (a[i] != i + 1);

    out(c <= 2 ? "YES" : "NO");

    return 0;
}


Measured memory_bytes: 256
from collections import deque


def dfs(start):
    link = {start}
    S = deque()
    # child = deque()
    visited[start] = 1
    S.append(start)
    while len(S) > 0:
        node = S.pop()
        # child.clear()
        for f in friend[node]:
            if visited[f] == 0:
                S.append(f)
                visited[f] = 1
                link.add(f)
    for i in link:
        res[i] = len(link) - len(link & friend[i]) - len(link & block[i]) - 1


N, M, K = map(int, input().split())
Friend = [list(map(int, input().split())) for _ in range(M)]
Block = [list(map(int, input().split())) for _ in range(K)]
visited = [0 for _ in range(N + 1)]
res = [0 for _ in range(N + 1)]

friend = [set() for _ in range(N + 1)]
block = [set() for _ in range(N + 1)]

for a, b in Friend:
    friend[a].add(b)
    friend[b].add(a)

for a, b in Block:
    block[a].add(b)
    block[b].add(a)

for i in range(1, N + 1):
    if visited[i] == 1:
        continue
    dfs(i)

print(*res[1:])


Measured memory_bytes: 136964
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint N, K;
	cin >> N >> K;
	lint n = N;
	if (K < N)
	{
		n = N - K * ((lint)(N / K));
	}
	cout << min(n, abs(n - K)) << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a,b,c,d,e;
    int A,B;
    
    cin >>a>>b>>c>>d>>e;
    
    A=min(a,min(b,c));
    B=min(d,e);
    
    cout <<A+B-50<<endl;
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		for (int i=0; i<N; i++) {
			int tmpA = sc.nextInt();
			if (tmpA%2 == 0) {
				if(tmpA % 5 == 0 || tmpA % 3 ==0);
				else {
					System.out.println("DENIED");
					return ;
				}
			}
		}
		
		System.out.println("APPROVED");

		sc.close();

	}
}

Measured memory_bytes: 22612
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>

#define INF 100100100
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

 
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22){
        cout << "bust"<< endl;
        return 0;
    }
    cout << "win"<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(a,b) for (int i=a; i<b; i++)
using namespace std;

int main()
{
    int q,sum[100002];
    bool prime[100002], like2017[100002];
    prime[1]=false; prime[2]=true;
    rep(3,100001) {if (i%2) prime[i]=true; else prime[i]=false;}
    sum[1]=0;
    rep(2,100001)
    {
        if(prime[i]) for (int j=i+i; j<=100000; j+=i) prime[j]=false;
        if (prime[i] && prime[(i+1)/2]) like2017[i]=true;
        else like2017[i]=false;
        if (like2017[i]) sum[i]=sum[i-1]+1;
        else sum[i]=sum[i-1];
    }
    cin>>q;
    int l[q], r[q];
    rep(0,q) cin>>l[i]>>r[i];
    rep(0,q) cout<<sum[r[i]]-sum[l[i]-1]<<"\n";
    return 0;
}


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

int main(){
int N;
  string S,T;
  cin >> N;
  cin >> S >> T;
  string ans;
  for(int i=0; i < N;i++){
   
    ans += S[i];
    ans += T[i];
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
x,y=map(int,input().split())
c=0
if x==1:
    c+=300000
elif x==2:
    c+=200000
elif x==3:
    c+=100000

if y==1:
    c+=300000
elif y==2:
    c+=200000
elif y==3:
    c+=100000

if x==1 and y==1:
    c+=400000
print(c)

Measured memory_bytes: 3060
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int X = stdIn.nextInt();
        int B = stdIn.nextInt();
        int C = stdIn.nextInt();
        stdIn.close();
 
        if (X == B && B != C) {
            System.out.println("Yes");
        } else if(X == C && B != C) {
            System.out.println("Yes");
        } else if(B == C && X != C) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22996
N = int(input())
G = {}
for i in range(1,N+1):
    a = int(input())
    G[i] = a
cur = 1
hist = [0 for _ in range(N+1)]
hist[cur] = 1
cnt = 0
while True:
    cur = G[cur]
    cnt += 1
    if cur == 2:break
    if hist[cur]==1:break
    hist[cur]=1
if cur==2:
    print(cnt)
else:
    print(-1)

Measured memory_bytes: 17892
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=998244353,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

ll dp[3333][3333];
        
void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[n];
  rep(i,n) R a[i];
  ll ans=0;
  rep(i,n) {
    dp[i+1][a[i]]+=i+1;
    if(a[i]==m) {
      ans+=(i+1)*(n-i);
      ans%=MAX;
    }
    rep(j,m) {
      dp[i+1][j]+=dp[i][j];
      dp[i+1][j]%=MAX;
      if(j+a[i]<m) {
        dp[i+1][j+a[i]]+=dp[i][j];
        dp[i+1][j+a[i]]%=MAX;
      }
      if(j+a[i]==m) {
        ans+=dp[i][j]*(n-i);
        ans%=MAX;
      }
    }
  }
  pr(ans);
}

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


Measured memory_bytes: 80128
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from fractions import*\n"
"a,b,c,d=map(int,input().split())\n"
"a-=1\n"
"e=c*d//gcd(c,d)\n"
"print(b-a-b//c+a//c-b//d+a//d+b//e-a//e)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 9864
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 3e3 + 5;
int n, m, dp[N][N];
string s, t;

void solve(int i, int j) {
	if (!~i || !~j)
		return;
	if (s[i] == t[j]) {
		solve(i - 1, j - 1);
		cout << s[i];
		return;
	}
	dp[i + 1][j] > dp[i][j + 1]? solve(i, j - 1): solve(i - 1, j);
}

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

	cin >> s >> t;
	n = s.size(), m = t.size();
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			dp[i + 1][j + 1] = (s[i] == t[j]? dp[i][j] + 1: max(dp[i][j + 1], dp[i + 1][j]));
	solve(n - 1, m - 1);

	return 0;
}


Measured memory_bytes: 35712
#include <stdio.h>
int main(void){
    // Your code here!
    int n,a[1000]={0},cnt=0,max=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n+1;i++){
        if(a[i]==1)cnt++;
        else{
            if(cnt>max)max=cnt;
            cnt=0;
        }
    }
    printf("%d\n",max+1);
    return 0;
    
}


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

using namespace std;

int main()
{	
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(auto &x : a)
	{
		cin >> x;
	}
	
	sort(a.begin(), a.end());
	
	for (int i = 0; i < a.size() - 1; i++)
	{
		if (a[i] == a[i + 1])
		{
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	
	return 0;
}



Measured memory_bytes: 1024
import sys
#長さK
K = int(input())

#文字列S
S = input()

#print(type(len(S)))
#print(type(K))
#print(str(S))

if len(S) <= K:
    print(S)
    sys.exit()

else:
    S = str(S)
    print(S[:K]+"...")
    sys.exit()


Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
typedef vector<i64> vi;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  string s;
  cin >> s;
  rep(i,sz(s)) s[i] = 'x';
  cout << s << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  int cost0 = A + C;
  int cost1 = A + D;
  int cost2 = B + C;
  int cost3 = B + D;
  
  int ans = min(min(min(cost0,cost1),cost2),cost3);
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 256
s = input()

ans = 0
for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        cnt = 0
        for k in ["A", "G", "C", "T"]:
            cnt += s[i:j].count(k)
        if cnt == len(s[i:j]):
            ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 61936
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = N ** 2
for i in range(1 << N):
  L = [[] for _ in range(N)]
  T = [0] * N
  t = i
  for j in range(N):
    if t & 1:
      L[j] = [A[j], 1]
      T[j] = A[j]
    else:
      L[j] = [B[j], 0]
      T[j] = B[j]
    t >>= 1
  D = [0] * N
  T.sort()
  cnt = 0
  for j in range(N):
    c = 0
    for k in range(N):
      if D[k] == 0:
        if L[j][0] == T[k] and (j + 1 - L[j][1]) % 2 == k % 2:
          D[k] = 1
          cnt += j - c
          break
      else:
        c += 1
    else:
      break
  else:
    ans = min(ans, cnt)

if ans == N ** 2:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 47324
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t="2019/04/30";
    cin >> s;
    if(s<=t){
        cout << "Heisei" << endl;
    }
    else cout << "TBD" << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////


int main() {
    ll n, k; string s;
    cin >> n >> k >> s;
    Vl v;
    if(s[0] == '0') v.push_back(0); // 端に1が0こあると考える
    ll cnt = 1;
    rep(i, 1, n){
        if(s[i]!=s[i-1]){
            v.push_back(cnt);
            cnt = 1;
        }else{
            cnt++;
        }
    }
    v.push_back(cnt);
    if(s[n-1]=='0') v.push_back(0);

    if(sz(v)/2 <= k){
        co(n);
        return 0;
    }

    // print(v);///////////////

    Vl sum(sz(v)+1);
    sum[0] = 0;
    rep(i, 0, sz(v)){
        sum[i+1] = sum[i];
        sum[i+1] += v[i];
    }
    // print(sum);

    ll ans = 0;
    rep(i, 0, sz(v)){
        if(i+2*k+1 >= sz(sum)) break;
        if(i%2 != 0) continue;
        chmax(ans, sum[i+2*k+1]-sum[i]);
    }
    co(ans);

    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	cout << "ABC" << n << endl;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {

        static long[] hai;
        static void Main(string[] args)
        {

            //var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            //var N = NK[0];
            //var K = NK[1];

            var N = long.Parse(Console.ReadLine());
            long res = 0;
            for (int i = 1; i <= N; i++)
            {
                var Y = (long)Floor((double)N/(double)i);
                res += i * Y* (Y+1)/2  ;
            }


            Console.WriteLine(res);
        }


        //約数の個数を求めるアルゴリズム
        public static long PrimeFactorization(long n)
        {
            if (hai[n] > 0) return hai[n];
            var ori = n;
            var ans = 1L;
            for (long i = 2; i * i <= n; i++)
            {
                if (n % i != 0) continue;
                long exponents = 0;

                // 割り続ける
                while (n % i == 0)
                {
                    exponents++;
                    n /= i;
                }

                ans *= (exponents+1);
                ans *= PrimeFactorization(n);
                break;
            }

            // 素数が残っている場合
            if (n != 1) ans *= 2;
            hai[ori] = ans;
            return hai[ori];
        }
    }

}


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

int main() {
	int N; cin >> N;
	vector<int>h(N); for (int i = 0; i < N; i++)cin >> h[i];
	int ans = 0;
	int active = 0;
	for (int i = 0; i < N; i++) {
		if (active >= h[i]) {
			active = h[i];
		}
		else {
			ans += h[i] - active;
			active = h[i];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    cout << (1000-(n%1000))%1000 << "\n";
    return 0;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int h, w;
    cin >> h >> w;
    vector<char> q(h * w);
    rep(i, h * w)
    {
        cin >> q[i];
        if (q[i] == '.')
            q[i] = '0';
    }
    rep(i, h * w)
    {

        if (q[i] == '#')
        {
            int x = i % w;
            int y = i / w;
            for (int dx = -1; dx <= 1; dx++)
            {
                for (int dy = -1; dy <= 1; dy++)
                {
                    int nx = x + dx;
                    int ny = y + dy;
                    if (0 <= nx && nx < w && 0 <= ny && ny < h)
                    {
                        if (q[ny * w + nx] != '#')
                        {
                            q[ny * w + nx]++;
                        }
                    }
                }
            }
        }
    }
    rep(i, h * w)
    {
        cout << q[i];
        if (i % w == w - 1)
            ed;
    }

    return 0;
}

Measured memory_bytes: 256
//  RAKSHIT KADAM

 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 3
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000004
    #define MOD  1000000007
    #define mod 998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll ter; cin>> ter; while(ter--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
 
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
 ll fact[1000005];
//ll modIN[1000005];
//void facto()
//{
//    ll lim =1000005;fact[0]=1;
//    for(ll i=1;i<lim;i++)
//    {
//        fact[i]=(fact[i-1]*i)%MOD;
//    }
//    modIN[n]=modInverse(fact[n],MOD);
//    for(ll i=n-1;i>=1;i--)
//    {
//        modIN[i] = (modIN[i+1]*(i+1))%MOD;
//    }
//}
//ll ncr(ll a,ll b)
//{
//    ll ret = 0;
//    ret = fact[a]*(modIN[b]);
//    ret%=MOD;
//    ret*=modIN[a-b];
//    ret%=MOD;
//    return ret;
//}
void solve()
{

    ll n,x,t;
    cin>>n>>x>>t;
    ll sum =0;
    ll ans=0;
    while(sum<n)
    {
        sum+=x;
        ans+=t;
    }
    cout<<ans<<endl;
}
signed main()
{
   Need_for_speed(activated);
    
//    satisfy
//    {
// solve();
//    }
//
//
    solve();
    
    return 0;
}


Measured memory_bytes: 3648
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, 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(10)

using namespace std;

typedef pair<int, int> P;


// mod
int mod = 1e9 + 7;

int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }

int mul(int x, int y) { return 1LL * x * y % mod; }

// 行列累乗
typedef vector<int> Vec;
typedef vector<Vec> Mat;

Vec mulMatVec(Mat a, Vec b) {
    int n = b.size();
    Vec ret(n, 0);
    REP(i, n)REP(j, n)ret[i] = add(ret[i], mul(a[i][j], b[j]));
    return ret;
}

Mat mulMatMat(Mat a, Mat b) {
    int n = a.size();
    Mat ret(n, Vec(n, 0));
    REP(i, n)REP(j, n)REP(k, n)ret[i][j] = add(ret[i][j], mul(a[i][k], b[k][j]));
    return ret;
}

Mat fastPow(Mat x, int n) {
    Mat ret(x.size(), Vec(x.size(), 0));
    REP(i, x.size())ret[i][i] = 1;
    while (0 < n) {
        if ((n % 2) == 0) {
            x = mulMatMat(x, x);
            n >>= 1;
        } else {
            ret = mulMatMat(ret, x);
            --n;
        }
    }
    return ret;
}

void printVec(Vec a) {
    cout << "[\t";
    REP(i, a.size())cout << a[i] << "\t";
    cout << "]" << endl;
}

void printMat(Mat a) {
    REP(i, a.size())printVec(a[i]);
}

/////////////////////////////////////



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

    int N, K;
    cin >> N >> K;

    Mat a(N, Vec(N));
    REP(i, N) REP(j, N) cin >> a[i][j];

    a = fastPow(a, K);

    Vec v(N, 1);
    v = mulMatVec(a, v);

    int ans = 0;
    REP(i, N) ans = add(ans, v[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int n,d[10][10],a,b,c;

int main(){
	while(cin>>n&&n){
		rep(i,10)fill(d[i],d[i]+10,INF);
		rep(i,10)d[i][i]=0;
		int m=0;
		rep(i,n){cin>>a>>b>>c;d[a][b]=c;d[b][a]=c;m=max(m,max(a,b));}
		m++;
		rep(k,m)rep(i,m)rep(j,m)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		int ans,ans2=INF;
		rep(i,m){
			int sum=0;
			rep(j,m)sum+=d[i][j];
			if(sum<ans2){ans2=sum;ans=i;}
		}
		cout<<ans<<" "<<ans2<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LLINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int k, x; cin >> k >> x;
	if (k * 500 >= x)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;

int main() {
  ll n,w;
  cin>>n>>w;
  ll dp[n+5][w+5];
  vector<ll> V(n);
  vector<ll> W(n);
  rep(i,n){
    cin>>W[i];
    cin>>V[i];
  }

  rep(i,n+5)rep(j,w+5)dp[i][j]=0;
  rep(i,n)rep(j,w+1){
    if (j-W[i]>=0)dp[i+1][j]=max(dp[i][j],dp[i][j-W[i]]+V[i]);
    else dp[i+1][j]=dp[i][j];
  //  cout<<dp[i+1][j]<<"i"<<(i+1)<<"j"<<j<<endl;
  }
  ll ans=0;
  rep(i,w+1)ans=max(ans,dp[n][i]);
cout<<ans;
}


Measured memory_bytes: 85408
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, x, p[200000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    p[x - 1] = i;
  }
  int t = 1, ans = 1;
  for (int i = 1; i < n; i++) {
    if (p[i] > p[i - 1]) {
      t++;
    } else {
      t = 1;
    }
    ans = max(t, ans);
  }
  cout << n - ans << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>

using namespace std;

int main()
{
	vector<int> vec;
	string s, t,ss, ans;
	bool tf;
	cin >> s >> t;
	ans = "UNRESTORABLE";
	int n, m, count, p,q;

	p = -1;
	q = 0;
	n = s.size();
	m = t.size();
	for (int i = n-m; 0<=i; i--)
	{
		count = 0;
		ss = s.substr(i, m);
		for (int x = 0; x < m; x++)
		{
		
			if (ss[x] == '?' || ss[x] == t[x])
			{
				count++;
			}
		}
		if(count==m)
		{
			vec.push_back(i);
			q++;
		}
	}
	

	if (0<q)
	{
		p = vec[0];
		ans = s;
		ans.erase(p, m);
		ans.insert(p, t);
		for (int i = 0; i < n; i++)
		{
			if (ans[i] == '?')
			{
				ans[i] = 'a';
			}
		}
	}

	cout << ans;



	return 0;
}

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
using namespace std;

int main()
{
	int S;
  	cin >> S;
  	long long i = 2;
  	vector<long long> A;
  	A.push_back(S);
  	map<long long, int> num;
  	long long answer=0;
  	long long n = 0;
  	num[S] = 1;
  	while(1){
      	n = A[i-2];
    	if(n%2){
        	A.push_back(n*3+1);
      		if(num.find(n*3+1) != num.end()){
              answer = i;
              break;
            }
      		num[n*3+1] = 1;
        } else {
    		A.push_back(n/2);
      		if(num.find(n/2) != num.end()){
              answer = i;
              break;
            }
      		num[n/2] = 1;
        }
      	i++;
    }
	cout << answer << endl;

}



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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ar array
#define int long long

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 5e5 + 5, maxa = 1 << 20, mod = 1e9 + 7;

int N, a[maxn], sx[maxn];

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  #endif // LOCAL
  cin >> N;
  for(int i = 1; i <= N; ++i){
    cin >> a[i];
    sx[i] = sx[i - 1] ^ a[i];
  }
  auto add = [&](int & x, int y)
  {
    x += y;
    if(x >= mod) x -= mod;
  };
  if(sx[N]){
    int x = 1, y = 0;
    for(int i = 1; i <= N; ++i){
      if(sx[i] == 0){
        add(x, y);
      }
      else if(sx[i] == sx[N]){
        add(y, x);
      }
    }
    cout << x;
  }
  else{
    vector<int> f(N + 5), sum(N + 5), x(maxa, 1), y(maxa), r(maxa);
    int ans = 1;
    for(int i = 1; i <= N; ++i){
      sum[i] = sum[i - 1] + (sx[i] == 0);
    }
    for(int i = 1; i <= N; ++i){
      if(sx[i]){
        (x[sx[i]] += y[sx[i]]*(sum[i]-sum[r[sx[i]]])%mod) %= mod;
        add(y[sx[i]], x[sx[i]]);
        r[sx[i]] = i;
      }
      else{
        if(i != N){
          ans = 2ll * ans % mod;
        }
      }
    }
    for(int i = 1; i < maxa; ++i)
      add(ans, y[i]);
    cout << ans;
  }
}


Measured memory_bytes: 40448
#include<stdio.h>
int main(void){
  int a,b,c,d,sum=0;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  sum+=(a<b)?a:b;
  sum+=(c<d)?c:d;
  printf("%d\n",sum);
  return 0;
}


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

long long N;
void input()
{
    cin >> N;   
}

void solve()
{
    long long num = 0;
    long long t26[13]; long long n26 = 1;
    for (int i = 0; i < 13; ++i) { t26[i] = n26; n26 *= 26; }
    long long tborder[13]; tborder[0] = 0;
    for (int i = 1; i < 13; ++i) tborder[i] = tborder[i-1] + t26[i];

    for (int i = 0; i < 13; ++i){
        // cout << tborder[i] << " ";
        if (tborder[i] < N) continue;
        N -= tborder[i-1] + 1;
        stack<char> stk;
        while (i != 0){
            stk.push('a' + N % 26);
            N /= 26;
            --i;
        }
        while (!stk.empty()){
            cout << stk.top(); 
            stk.pop();
        }
        cout << endl;
        break;
    }
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

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

int main() {
  int a,b,ans;
  cin >>a>>b;
  ans =max(a+a-1,max(a+b,b+b-1));
  cout << ans <<endl;
}



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

using namespace std;

int f(int n) {
	int cnt = 0;
	while (n % 2 == 0) {
		cnt++;
		n /= 2;
	}
	return cnt;
}

int main() {
	int n;
	scanf("%d", &n);
	vector <int> v;
	long long foo = -1;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if (x % 2 == 0) {
			v.push_back(x);
		} else {
			foo = max(foo, 1ll * x);
		}
	}
	long long ans = 0;
	for (int i = 0; i < (int)v.size(); i++) {
		ans += 1ll * f(v[i]);
	}
	cout << ans << endl;
	return 0;
}

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

int comp_as( const void *, const void * );
int comp_des( const void *, const void * );

int main( void ) {
	char aStr[ 20 ][ 7 ], min[ 7 ], max[ 7 ];
	int i, j, a0, L;

	for ( ; scanf( "%d %d", &a0, &L ), L; printf( "%d %d %d\n", j, atoi( aStr[ i ] ), i - j ) ) {
		sprintf( aStr[ 0 ], "%0*d", L, a0 );

		for ( i = 1; ; i++ ) {
			strcpy( min, aStr[ i - 1 ] );
			qsort( min, L, sizeof(char), &comp_as );

			strcpy( max, aStr[ i - 1 ] );
			qsort( max, L, sizeof(char), &comp_des );

			sprintf( aStr[ i ], "%0*d", L, atoi( max ) - atoi( min ) );

			for ( j = 0; j < i; j++ )
				if ( !strcmp( aStr[ j ], aStr[ i ] ) )
					break;
			if ( j != i )
				break;
		}
	}

	return 0;
}

int comp_as( const void *a, const void *b ) {
	return *(char *)a - *(char *)b;
}

int comp_des( const void *a, const void *b ) {
	return *(char *)b - *(char *)a;
}

Measured memory_bytes: 652
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringJoiner;

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();
        int K = scan.nextInt();
        int max = com(N-1, 2);
        if (max < K) {
            System.out.println(-1);
            return;
        }
        if (max == K) {
            System.out.println(N - 1);
            for (int i = 2; i <= N; i++) {
                System.out.printf("%d %d\n", 1, i);
            }
            return;
        }
        int remain = max - K;
        System.out.println(N - 1 + (max - K));
        for (int i = 2; i <= N; i++) {
            System.out.printf("%d %d\n", 1, i);
        }
        int gap = 1;
        while (0 < remain) {
            for (int i = 2; i <= N && 0 < remain; i++) {
                System.out.printf("%d %d\n", i, (i + gap <= N ? i + gap : i + gap - N + 1));
                remain -= 1;
            }
            gap += 1;
        }
        return;
    }
    private int com(int N, int K) {
        if (N < K) {
            return 0;
        }
        if (N == K) {
            return 1;
        }
        int d1 = 1;
        int d2 = 1;
        for (int i = 1; i <= K; i++) {
            d1 *= (N - (i - 1));
            d2 *= i;
        }
        return d1 / d2;
    }
}


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

int main() {
  ll a,b,c; cin >> a >> b >> c;
  ll sum = a+b+c;
  if(sum>=22) cout << "bust" << endl;
  else if(sum<=21) cout << "win" << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#define mprint(x) printf(FORMATCONVERSION(x),(x))
#define FORMATCONVERSION(x) _Generic((x),\
                                    int:"%d",unsigned int:"%u",\
                                    double:"%lf",long long int:"%lld",\
                                    unsigned long long int:"%llu",\
                                    unsigned long : "%lu",\
                                    long int : "%ld",\
                                    char :"%c",char*:"%s")

int main(void){
    int k,x;
    scanf("%d %d",&k,&x);
    puts((k * 500 >= x ? "Yes" : "No"));
    return 0;
}


Measured memory_bytes: 128
import collections

n,m = map(int,input().split())
s = list(str(input()))
key = collections.deque()
lis = [[] for i in range(n)]
li = [{"A":0,"B":0} for i in range(n)]

for i in range(m):
  a,b = map(int,input().split())
  lis[a-1].append(b-1)
  lis[b-1].append(a-1)
  li[a-1][s[b-1]] += 1
  li[b-1][s[a-1]] += 1
  
ans = [0 for i in range(n)]

for i in range(n):
  if li[i]["A"] == 0 or li[i]["B"] == 0:
    key.append(i)
    ans[i] = 1
    
while len(key) > 0:
  num = key.popleft()
  for nu in lis[num]:
    li[nu][s[num]] -= 1
    if li[nu]["A"] == 0 or li[nu]["B"] == 0:
      if ans[nu] == 0:
        key.append(nu)
        ans[nu] = 1

if sum(ans) == n:print("No")
else:print("Yes")

Measured memory_bytes: 102784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n;
  cin>>n;
  ll a[n+1],b[n+1];
  ll i;
  ll ans=0;
  for(i=0;i<n+1;i++) cin>>a[i];
  for(i=1;i<=n;i++) cin>>b[i];
  
  for(i=1;i<=n;i++)
  {
    if(a[i-1]>=b[i]) {ans+=b[i];}
    else if(a[i-1]<b[i])
    {
      ans+=a[i-1];
      b[i]-=a[i-1];
      a[i-1]=0;
      if(a[i]<=b[i]) {ans+=a[i];a[i]=0;}
      else {ans+=b[i];a[i]-=b[i];}
    }
  }
  cout<<ans<<" ";
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if((b-a) % 2 == 0){
            System.out.println("Alice");
        }else{
            System.out.println("Borys");
        }
    }
}


Measured memory_bytes: 23892
#include<stdio.h>

int main()
{
	int a,b,c,m,k,l;
	while((scanf("%d %d",&a,&b))!=EOF){
		k=a;
		l=b;
		while(k%l!=0){
			c=k%l;
			k=l;
			l=c;
		}
		m=a/l*b;
		printf("%d %d\n",l,m);
	}
	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>

int main(void){
	int i,j,k,w,h;
	while(scanf("%d%d",&w,&h),w,h){
		int dp[101][101][5]={0},ans=0;
		for(i=1;i<=h;i++) dp[i][1][4]=1;
		for(j=1;j<=w;j++) dp[1][j][4]=1;
		
		for(i=2;i<=h;i++){
			for(j=2;j<=w;j++){
				dp[i][j][0]=dp[i-1][j][3]+dp[i-1][j][4];
				dp[i][j][1]=dp[i][j-1][2]+dp[i][j-1][4];
				dp[i][j][2]=dp[i-1][j][0]+dp[i-1][j][2];
				dp[i][j][3]=dp[i][j-1][1]+dp[i][j-1][3];
				for(k=0;k<5;k++){
					if(dp[i][j][k]>=100000)dp[i][j][k]%=100000;
				}
			}
		}
		/*
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				printf("(%f=%f=%f=%f=%f)%d%d\n",dp[i][j][0],dp[i][j][1],dp[i][j][2],dp[i][j][3],dp[i][j][4],i,j);
			}
		}
		*/
		for(i=0;i<5;i++){
			ans+=dp[h][w][i];
		}
		ans%=100000;
		printf("%d\n",ans);
	}
	return 0;
	
}

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

char h[15] = {'a','s','d','f','g','t','r','e','w','q','z','x','c','v','b'};

int isin(char c){
    for(int i=0;i<15;++i){
        if(h[i]==c) return 1;
    }
    return 0;
}

int main(void){
    while(true){
        int cnt = 0;
        char s[40];
        cin >> s;
        if(s[0]=='#') break;
        int prev = isin(s[0]);
        for(int i=1;i<strlen(s);++i){
            int now = isin(s[i]);
            if(now!=prev){
                ++cnt;
                prev = now;
            }
        }
        cout << cnt << endl;
    }
}


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

using namespace std;

int main() {

	int n;
	cin >> n ;

	int counter = 0;
	int tcounter = 0;
	for (int i = 1; i < n+1;i=i+2) {
		counter = 0;
		for (int j = 1; j < i+1; j++) {
			if (i%j == 0) { counter++; }
		}
		if (counter == 8) {
			tcounter++;
		}
	}
	cout << tcounter << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
using namespace std;

//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
#define RREP(i, m, n) for(int i=(int)m; i>=(int)n; --i)
#define rrep(i, m) RREP(i, m, 0)

//簡略化
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> P;

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

void chmin(ll &a, const ll &b) {
  if(a>b) a = b;
}

void chmax(ll &a, const ll &b) {
  if(a<b) a = b;
}

//GCD&LCM
ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

//-----------------------

int main() {

  ll l,r, min = 2019, cnt = 0;
  cin >> l >> r;

  for(ll i=l; i<=r; ++i) {
    if(i%2019==0) {
      cout << 0 << endl;
      return 0;
    }
  }

  for(ll i=l; i<=r; ++i) {
    for(ll j=i+1; j<=r; ++j) {
      chmin(min, (i*j)%2019);
    }
  }

  cout << min << endl;

  return 0;
}


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

int main() {
  int N,M;
  cin>>N>>M;
  vector<bool>from1(N+1,false),toN(N+1,false);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    if(a==1){from1.at(b)=true;}
    if(b==1){from1.at(a)=true;}
    if(a==N){toN.at(b)=true;}
    if(b==N){toN.at(a)=true;}
  }
  for(int i=0;i<N+1;i++){
    if(toN.at(i)&&from1.at(i)){cout<<"POSSIBLE"<<endl;return 0;}
  }
  cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int N,X,m,ans=0,min=100000;
  scanf("%d%d",&N,&X);
  for(int i=0;i<N;i++){
    scanf("%d",&m);
    if(min > m) min = m;
    X -= m;
  }
  ans += N+X/min;
  printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

ll C[53][53];

void init(int n){
  C[0][0] = 1;

  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      C[i+1][j] += C[i][j];
      C[i][j+1] += C[i][j];
    }
  }
}

ll Comb(int n, int m){
  return C[n-m][m];
}

int main(){
  int n,a,b;
  ll v[100];
  
  scanf("%d%d%d",&n,&a,&b);

  init(n);
  
  for(int i=0;i<n;i++){
    scanf("%lld",v+i);
  }

  sort(v,v+n,greater<ll>());

  ll max_sum = 0;
  ll max_sum_i = 0;
  ll ans = 0;
  
  for(int i=a;i<=b;i++){

    ll sum = 0;
    
    for(int j=0;j<i;j++){
      sum += v[j];
    }

    int counter = 0,counter_need = 0;

    for(int j=0;j<n;j++){
      if(j < i) counter_need += v[i-1] == v[j];
      counter += v[i-1] == v[j];
    }

    if(max_sum_i == 0 || max_sum * i < sum * max_sum_i){
      max_sum = sum;
      max_sum_i = i;
      ans = 0;
    }

    if(max_sum * i == sum * max_sum_i){
      
      
      ans += Comb(counter, counter_need);
    }
  }

  printf("%.10lf\n",(double)max_sum / max_sum_i);
  printf("%lld\n",ans);
  
  return 0;
}


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

long long int N,M;
int even_n=1;

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

    for(int i=0; i<M; i++){
        even_n*=2;
    }
    cout<<even_n*(1900*M+(N-M)*100)<<endl;

    return 0;
}


Measured memory_bytes: 256
def solve():
    L = list(input())
    l = ['A', 'C', 'G', 'T']
    m = 0
    tmp = 0
    for i in L:
        if i in l:
            tmp += 1
            m = max(m, tmp)
        else:
            tmp = 0
    
    return m

print(solve())


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
	char c[10];
	scanf("%s",c);
	if(c[0]=='S') printf("Cloudy\n");
	else if(c[0]=='C') printf("Rainy\n");
	else if(c[0]=='R') printf("Sunny\n");
}
 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC090B
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = ReadInt;
            var B = ReadInt;

            int ans = 0;
            for (int i = A; i <= B; i++)
            {
                string s = i.ToString();

                if (s[0] == s[4] && s[1] == s[3]) ans++;
            }

            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13268
N = int(input())
S = [input() for _ in range(N)]
 
# 文字列にABが入ってる数 + 組み合わせて入る数
# 文字列にABが入ってる数 + f(Aで終わる数, Bで始まる数, Bで始まりAで終わる数)
sb = 0
fa = 0
sbfa = 0
for s in S:
    if s[0] == 'B' and s[-1] == 'A':
        sbfa += 1
    elif s[0] == 'B':
        sb += 1
    elif s[-1] == 'A':
        fa += 1

include = sum([x.count("AB") for x in S])

def calc_comb(sb, fa, sbfa):
    if sbfa == 0:
        return min(sb, fa)
    elif max(sb, fa)==0:
        return sbfa -1
    else:
        return sbfa + min(sb, fa)

print(include + calc_comb(sb, fa, sbfa))


Measured memory_bytes: 9792
N,M=map(int,input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]
for i in range(N-M+1):
  for j in range(len(A[i])-len(B[0])+1):
    if B[0][0]==A[i][j]:
      flag=True
      p=i
      for k in range(M):
        if not B[k]==A[p][j:j+len(B[k])]:
          flag=False
          break
        p+=1
      if flag:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 8892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, M;
    cin >> N >> M;
    VP p(M);
    rep(i, 0, M) cin >> p[i].second >> p[i].first;
    sort(ALL(p));

    ll head = -1, ans = 0;
    rep(i, 0, M){
        if(p[i].second >= head){
            head = p[i].first;
            ans++;
        }
    }  
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char s[3];
cin >> s;
int ans = 1;
REP(i,3) {
  ans *= s[i] - 'A';
}
if(ans==35904) {
  cout << "Yes" << endl;
} else {
  cout << "No" << endl;
}
return 0;
}


Measured memory_bytes: 256
'use strict';

function Main(input) {
  const p = input.split("\n").slice(1).map(x => Number(x))
  const max = Math.max.apply(null, p)
  const ans = p.reduce((x, y) => x + y) - max / 2
  console.log(ans)
};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 11468