akhauriyash/Code-Regression huggingface dataset:
def examA():
    A, B = LI()
    ans = A*B
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    for a in A:
        if a==0:
            print(0)
            return
    ans = 1
    for a in A:
        ans *= a
        if ans>10**18:
            print(-1)
            return
    print(ans)
    return

def examC():
    A, B = LSI()
    ans =math.floor(int(A)*float(B))
    print(ans)
    return

def examD():
    def factorization(n):
        arr = defaultdict(int)
        temp = n
        for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr[i] = cnt
        if temp != 1:
            arr[temp] = 1
        if arr == []:
            arr[n] = 1
        return arr
    C = [0,1,3,6,10,15,21,28,36,45]
    N = I()
    F = factorization(N)
    ans = 0
    #print(F)
    for f in F.values():
        for i in range(10):
            if C[i]>f:
                ans += i-1
                break
    print(ans)
    return

def examE():
    N = I()
    A = [0]*N
    B = [0]*N
    for i in range(N):
        A[i],B[i] = LI()
    A.sort()
    B.sort()
    if N%2==0:
        L = (A[N//2-1] + A[N//2])/2
        R = (B[N//2-1] + B[N//2])/2
        ans = int((R-L)*2) +1
    else:
        L = A[N//2]
        R = B[N//2]
        ans = (R-L)+1

    print(ans)
    return

def examF():
    inv = pow(2,mod2-2,mod2)
    N, S = LI()
    A = LI()
    dp = [[0]*(S+1)for _ in range(N+1)]
    dp[0][0] = pow(2,N,mod2)
    for i in range(N):
        a = A[i]
        for s in range(S+1):
            dp[i+1][s] += dp[i][s]
            dp[i+1][s] %= mod2
            if (s+a<=S):
                dp[i+1][s+a] += dp[i][s]*inv%mod2
                dp[i + 1][s+a] %= mod2
   # print(dp)
    ans = dp[-1][-1]%mod2
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 1<<60
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examF()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

int main(){
  int n;
  cin >> n;
  
  vector<int> a(n), b(n);
  for ( int i = 0; i < n; i++ ){
    cin >> a[i];
    b[i] = a[i];
  }
    
  sort(a.begin(), a.end());
  
  int x = 0;
  for ( int i = 0; i < n; i++ )
    if ( a[i] != b[i] ) x++;
  
  if ( x < 3 ) cout << "YES" << endl;
  else cout << "NO" << endl;
    
}

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

using namespace std;

#define bug(x) cerr << #x << " = " << x << '\n'
#define ll     long long
#define x      first
#define y      second
#define eb     emplace_back
#define maxn
#define mod    1000000007

int main() {
        #ifndef ONLINE_JUDGE
            //freopen(".inp","r",stdin);
        #endif // ONLINE_JUDGE

//        ios_base::sync_with_stdio(0);
//        cin.tie(0); cout.tie(0);

        int n, x, t;
        cin >> n >> x >> t;
        cout << (ll) t * ((n / x) + (bool) (n % x));
}





Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

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

	int n, m, result = 0;
	unordered_map<string, int> a;

	cin >> n;
	for (int i = 0; i < n; ++i) {
		string tmp;
		cin >> tmp;
		if (a.count(tmp) == 0) {
			a[tmp] = 1;
		}
		else {
			a[tmp]++;
		}
	}

	cin >> m;
	for (int i = 0; i < m; ++i) {
		string tmp;
		cin >> tmp;
		if (a.count(tmp) == 0) {
			a[tmp] = -1;
		}
		else {
			a[tmp]--;
		}
	}

	for (pair<string, int> p : a) {
		if (result < p.second) {
			result = p.second;
		}
	}

	cout << result << endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Reflection;
using System.Collections.Generic;
using System.Text;
using System.Linq;
 
namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] sortArray = str.Select(s => int.Parse(s)).ToArray();
            int executeNum = 0;
            for (int i = 0; i < n - 1; ++i)
            {
                int minj = i;
                for (int j = i+1; j < n ; ++j)
                {
                    if (sortArray[j] < sortArray[minj])
                    {
                        minj = j;
                        
                    }
                    
                }
                if(sortArray[minj] < sortArray[i])
                {
                    swap(ref sortArray[i], ref sortArray[minj]);
                    ++executeNum;
                }
                
            }
            for (int i = 0; i < n; ++i)
            {
                Console.Write(sortArray[i]);
                if (i != n - 1)
                {
                    Console.Write(" ");
                }
            }
            Console.Write("\n");
            Console.WriteLine(executeNum);
        }
        public static void swap(ref int x ,ref int y)
        {
            int temp = x;
            x = y;
            y = temp;
        }
    }
}

Measured memory_bytes: 9620
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

#define MOD 100000

int main(){
	int dp[101][101][4];
	for(int i=0;i<101;i++){
		dp[i][0][0]=1;
		dp[0][i][1]=1;
	}
	for(int i=1;i<101;i++){
		for(int j=1;j<101;j++){
			dp[i][j][0]=(dp[i-1][j][0]+dp[i-1][j][3])%MOD;
			dp[i][j][1]=(dp[i][j-1][1]+dp[i][j-1][2])%MOD;
			dp[i][j][2]=dp[i][j-1][0]%MOD;
			dp[i][j][3]=dp[i-1][j][1]%MOD;
		}
	}
	while(1){
		int h,w;
		scanf("%d %d",&h,&w);
		if(w==0&&h==0) break;
		h--;
		w--;
		printf("%d\n",(dp[h][w][0]+dp[h][w][1]+dp[h][w][2]+dp[h][w][3])%MOD);
	}
}


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

using namespace std;

int main() {
    vector<long long> a(5);
    long long min;
    long long time;
    long long n; cin >> n;
    for (int i = 0; i < a.size(); i++){
        cin >> a[i];
        if (i==0){
            min = a[i];
        }else {
            if (min > a[i]){
                min = a[i];
            }
        }
    }
    time = (n + (min -1))/min + 4;
    cout << time << endl; 
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int sum = 0;
    int m = i;
    while(m > 0) {
      int n = m % 10;
      sum += n;
      m = (m-n)/10;
    }
    if (A <= sum && sum <= B) {
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define mod 1000000007
#define LLMAX 1e18; 
#define p(x) cout<<x<<" ";
#define p2(x,y) cout<<x<<" "<<y<<" "
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<" "
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
 
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define pi pair<ll,ll>
#define ppi pair<ll,pi>
#define pb push_back
#define all(v) v.begin(), v.end() 

ll dp[100005];
ll solve(ll * v,ll n,int k){
  if(n<=0)
    return LLMAX;
  if(n==1)
    return 0;
  if(dp[n]!=-1)
    return dp[n];
  ll result=LLMAX;
  for(int i=1;i<=k&&n-1-i>=0;i++)
   result=min(result,abs(v[n-1]-v[n-1-i])+solve(v,n-i,k));
  dp[n]=result;
return dp[n];
} 

int main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout<<fixed<<setprecision(6);

// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
  
    ll t=1;
    //cin>>t;
    
    while(t--)
    {
      ll n,k;
      cin>>n>>k;
    ll v[100005];
      memset(dp,-1,sizeof(dp));
      F(i,0,n-1) cin>>v[i];
      cout<<solve(v,n,k);

    }
        
}

Measured memory_bytes: 9600
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System;

public class P
{
    public int d { get; set; }
    public int id { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var d = new List<int>[n + 1];
        for (int i = 1; i <= n; i++) d[i] = new List<int>();
        var dn = new string[n + 1];
        Console.ReadLine();
        dn[1] = Console.ReadLine().Trim();
        for (int i = 2; i <= n; i++)
        {
            var k = int.Parse(Console.ReadLine().Trim());
            var m = Console.ReadLine().Trim();
            dn[i] = m;
            d[k].Add(i);
        }
        print(d, dn);
    }
    static void print (List<int>[] d, string[] dn)
    {
        var sb = new StringBuilder();
        var st = new Stack<P>();
        st.Push(new P { d = 0, id = 1 });
        while (st.Count() > 0)
        {
            var w = st.Pop();
            var d2 = new string('.', w.d);
            sb.Append(d2 + dn[w.id] + "\n");
            var dc = d[w.id].Count();
            if (dc > 0)
            {
                d[w.id].Reverse();
                foreach (var x in d[w.id])
                    st.Push(new P { d = w.d + 1, id = x });
            }
        }
        Console.Write(sb);
    }
}


Measured memory_bytes: 22356
#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>;

void Main()
{
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k ==0) {
            cout << "OK" << endl;
            return;
        }
    }
    cout << "NG" << endl;
}

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

Measured memory_bytes: 3640
H, W = map(int, input().split())

As = []
for _ in range(H):
    a = list(map(int, input().split()))
    As.append(a)

ans = []
isFromExist = False
x = 0
y = 0
vec = 1
count = 0
while count < H*W:
    if not isFromExist:
        if As[y][x] % 2 == 1:
            from_yx = [y, x]
            isFromExist = True
    else:
        now = [y, x]
        ans.append(from_yx + now)
        if As[y][x] % 2 == 1:
            isFromExist = False
        else:
            from_yx = now

    if vec == 1 and x == W-1:
        vec = -1
        y += 1
    elif vec == -1 and x == 0:
        vec = 1
        y += 1
    else:
        x += vec * 1
    count += 1


N = len(ans)
print(N)
for i in range(N):
    for j in range(4):
        if j == 3:
            print(ans[i][j] + 1)
        else:
            print(ans[i][j] + 1, '', end='')


Measured memory_bytes: 27196
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int w, h;
    cin >> w >> h;
    vector<P> input;
    for(int i = 0; i < w; ++i){
        int p;
        cin >> p;
        input.emplace_back(p, 0);
    }
    for(int i = 0; i < h; ++i){
        int q;
        cin >> q;
        input.emplace_back(q, 1);
    }
    sort(input.begin(), input.end());

    int a = w + 1, b = h + 1;
    ll ans = 0;
    for(int i = 0; i < w + h; ++i){
        int cost = input[i].first, id = input[i].second;
        if(id == 0){
            ans += (ll)cost * b;
            --a;
        }
        else{
            ans += (ll)cost * a;
            --b;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <stdio.h>
#include <math.h>

#define N 500000

int cnt = 0;

void merge(int *A, int left, int mid, int right) {
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1], R[n2];


	for (i = 0; i < n1; i++) {
		L[i] = A[left+i];
	}

	for (i = 0; i < n2; i++) {
		R[i] = A[mid+i];
	}

	L[n1] = INFINITY;
	R[n2] = INFINITY;
	i = 0;
	j = 0;
	for (k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
			cnt++;
		} else {
			A[k] = R[j];
			j++;
			cnt++;
		}
	}
}

void mergeSort(int *A, int left, int right) {
	int mid;

	if (left+1 < right) {
		mid = (left + right)/2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main() {
	int i, n;
	int S[N];

	scanf("%d", &n);

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

	mergeSort(S ,0, n);

	for (i = 0; i < n; i++) {
		printf("%d", S[i]);
		if (i < n-1) printf(" ");
	}
	printf("\n%d\n", cnt);

	return 0;
}

Measured memory_bytes: 4508
#include <iostream>

int main(){
	using namespace std;
	int r = 0;
	string str;
	int i , leng;
	cin >> str;
	leng = str.length();
		for (i = 0; i < leng; i += 2) {
			if (str[i] != 'R' && str[i] != 'U' && str[i] != 'D') {
				r++;
			}
		}

	for (i = 1; i < leng; i += 2) {
		if (str[i] != 'L' && str[i] != 'U' && str[i] != 'D') {
			r++;
		}
	}
	if (r == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    int res=0;
    if(n>=m){
        cout << res << endl;
        return 0;
    }
    vector<int> x(m);
    for(int i=0;i<m;i++){
        cin >> x[i];
    }
    sort(x.begin(),x.end());
    priority_queue<int> q;
    for(int i=0;i<m-1;i++){
        q.push(x[i+1]-x[i]);
    }
    int ans=x[m-1]-x[0];
    for(int i=0;i<n-1;i++){
        ans-=q.top();
        q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1276
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a;
    cin >> a;
    if(a == 9 || a == 19 || a == 29 || a == 39 || a == 49 || a == 59 || a == 69){
        cout << "Yes" << endl;
    }
    else if(a == 79 || a == 89 || a == 99 || a == 91 || a == 92 || a == 93 || a == 94){
        cout << "Yes" << endl;
    }
    else if(a == 95 || a == 96 || a == 97 || a == 98 || a == 90){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

int main() {
    // a, b, cを入れる変数
    int a, b, c;
    // 答えの約数の数を入れる変数
    int sum = 0;

    cin >> a >> b >> c;

    // aからbまでの数を一つずつ見ていく
    for (int i = a; i <= b; ++i) {
        if(c % i == 0){
            ++sum;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    int N = (int)S.size();
    vector<int> ans(N);

    int R = 0, L = 0;
    for (int l = 0, r = 0; l < N; l = r, R = 0, L = 0) {
        for (; r < N && S[r] == 'R'; r++) R++;
        for (; r < N && S[r] == 'L'; r++) L++;
        ans[l + R - 1] = ((R + 1) / 2) + (L / 2);
        ans[l + R] = (R / 2) + ((L + 1) / 2);
    }
    for (int i = 0; i < N; i++) {
        cout << ans[i];
        if (i != N - 1) cout << " ";
    }
    cout << endl;
}


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

int main() {
  string S; string T;
  cin>>S; cin>>T;
  if(S.at(0)==T.at(2)&&S.at(2)==T.at(0)&&S.at(1)==T.at(1))
    cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int N, ctr = 0;
	cin >> N;
	bool res = false;
	forn(i, N)
	{
		int u, v;
		cin >> u >> v;
		if (u == v)
			++ctr;
		else
			ctr = 0;
		if (ctr == 3)
			res = true;
	}
	if (res)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e18+1e18;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

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

	vll A(N + 2, 0);
	repn(i, N) cin >> A[i];

	ll s = 0;
	rep(i, N+1)s += abs(A[i] - A[i + 1]);

	repn(i, N) {
		ll ans = s - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 4000
#include<stdio.h>
using namespace std;

int main(){
  double r, area, l, pi;
  scanf("%lf", &r);
  pi = 3.141592653589;
  area = r * r * pi;
  l = 2 * r * pi;
  printf("%.6lf %.6lf\n", area, l);
  return 0;
}


Measured memory_bytes: 2684
#include <stdio.h>

int main(void)
{
  int flagA=0,flagB=0,flagC=0,i;
  char abc[4];
  
  scanf("%s",abc);
  
  for(i=0;i<3;i++)
  {
    if(abc[i]=='a')
      flagA += 1;
  }
  
  for(i=0;i<3;i++)
  {
    if(abc[i]=='b')
      flagB += 1;
  }
  
  for(i=0;i<3;i++)
  {
    if(abc[i]=='c')
      flagC += 1;
  }
  
  if(flagA==1&&flagB==1&&flagC==1)
  printf("Yes");
  else
  printf("No");
  
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;

  int rec = 1;
  REP(i, s.size()){
    if(i == a){
      if(s[i] != '-') rec = 0;
    }
    else{
      if(s[i] == '-') rec = 0;
    }
  }
  if(rec) cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 256
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

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

const int N = 1e5 + 5;
const ll inf = 1e16;

ll g[N], s[N], b[N], best[N];

int main()
{
	int x, y, z;
	cin >> x >> y >> z;
	int n = x + y + z;
	ll ans = 0;
	vector <pll> v;
	for (int i = 1; i <= n; ++i)
	{
		cin >> g[i] >> s[i] >> b[i];
		ans += b[i];
		g[i] -= b[i];
		s[i] -= b[i];
		b[i] = 0;
		v.pb({g[i] - s[i], i});
	}

	sort(v.begin(), v.end());
	priority_queue <int, vector <int>, greater <int>> q;
	ll sum = 0;
	for (int i = 1; i <= n; ++i)
	{
		int j = v[i - 1].second;
		if (q.size() < y)
		{
			q.push(s[j]);
			sum += s[j];
		}

		else if (q.top() < s[j])
		{
			sum += s[j] - q.top();
			q.pop();
			q.push(s[j]);
		}

		if (q.size() >= y)
			best[i] = sum;

		else
			best[i] = -inf;
	}

	while (!q.empty())
		q.pop();

	sum = 0;
	for (int i = n; i >= 1; --i)
	{
		int j = v[i - 1].second;
		if (q.size() < x)
		{
			q.push(g[j]);
			sum += g[j];
		}

		else if (q.top() < g[j])
		{
			sum += g[j] - q.top();
			q.pop();
			q.push(g[j]);
		}

		if (q.size() >= x)
			best[i - 1] += sum;

		else
			best[i - 1] = -inf;
	}

	ll temp = -inf;
	for (int i = 1; i < n; ++i)
		temp = max(temp, best[i]);

	cout << ans + temp << endl;
}

Measured memory_bytes: 5872
#include <cstdio>
#include <algorithm>
using namespace std;
#define maxn 500010

int n,m,a[maxn];
struct que{int x,y,pos;}ask[maxn];
int last[maxn],ans[maxn];
int tr[maxn];
void add(int x,int y){for(;x<=maxn-5;x+=(x&-x))tr[x]+=y;}
void Add(int x,int y){add(x,1);add(y+1,-1);};
int sum(int x){int re=0;for(;x>=1;x-=(x&-x))re+=tr[x];return re;}
bool cmp(que x,que y){return x.y<y.y;}

int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=m;i++)scanf("%d %d",&ask[i].x,&ask[i].y),ask[i].pos=i;
	sort(ask+1,ask+m+1,cmp);
	int now=1;for(int i=1;i<=n;i++){
		Add(last[a[i]]+1,i);last[a[i]]=i;
		while(now<=m&&ask[now].y==i)ans[ask[now].pos]=sum(ask[now].x),now++;
		if(now>m)break;
	}
	for(int i=1;i<=m;i++)printf("%d\n",ans[i]);
}

Measured memory_bytes: 17216
#include <stdio.h>

int main()
{
  int n, i, j, flag = 1, temp, cnt = 0;
  int a[100];

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

  i = 0;
  while (flag) {
    flag = 0;
    for (j = n - 1; j > i; j--) {
      if (a[j] < a[j - 1]) {
        temp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = temp;
        cnt++;
        flag = 1;
      }
    }
    i++;
  }

  for (i = 0; i < n; i++) {
    if (i == 0) {
      printf("%d", a[i]);
    } else {
      printf(" %d", a[i]);
    }
  }
  puts("");
  printf("%d\n", cnt);

  return 0;
}

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

using namespace std;
#define tam 100001
int dp[tam],A[tam],n,pr=0;
int solver(int index)
{
    if(dp[index] != -1)
        return dp[index];
    if(index <= 1)
        return dp[index] = abs(A[0]-A[index]);
    return dp[index] = min(solver(index-1) + abs(A[index]-A[index-1]),
    solver(index-2) + abs(A[index]-A[index-2]));
}
int main()
{
    cin>>n;
    for(int i = 0;i < n;i++)
        cin>>A[i];
    memset(dp,-1,sizeof dp);
    dp[0] = 0; 
    cout<<solver(n-1)<<"\n";
    return 0;
}


Measured memory_bytes: 7508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int N = 2e5 + 5;
ll a[N];

int main()
{
    ll n, sum = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		sum += a[i];
		sum %= mod;
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		sum = (sum - a[i] + mod) % mod;
		ans += sum * a[i] % mod;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5152
#include <iostream>
#include <algorithm>
#include <bitset>

int main()
{
	int n;
	std::cin >> n;
	
	std::bitset<4000010> bit;
	bit[0] = 1;
	
	int sum = 0;
	for (int i = 0; i < n; ++i)
	{
		int x;
		std::cin >> x;
		
		bit |= bit << x;
		sum += x;
	}
	
	for (int i = (sum + 1) / 2;; ++i)
	{
		if (bit[i])
		{
			std::cout << i;
			return 0;
		}
	}
	
	
	/*
	int max = 1 << n;
	int otherArr[10010] = { 0 };
	int cnt = 0;
	for (int i = 1; i < max; ++i)
	{
		int sum = 0;
		for (int j = 0; j < n; ++j)
		{
			if (i & (1 << j))
				sum += a[j];
		}
		
		otherArr[i - 1] = sum;
	}
	
	std::sort(otherArr, otherArr + max - 1);
	for (int i = 0; i < max - 1; ++i)
	{
		std::cout << otherArr[i] << " ";
	}
	
	std::cout << "\nAND THE ANSWER IS: ";
	std::cout << otherArr[(max - 1) / 2];*/
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

set<string> s;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	forn(i,0,n){
		string t; cin>>t;
		s.insert(t);
	}
	
	cout<<s.size()<<'\n';
	
	return 0;
}


Measured memory_bytes: 19240
#include<iostream>
#include<algorithm>
#define ll long long

using namespace std;

int main(){
  ll N;
  cin >> N;
  int cnt = 0;
  for(int i=1;i < N;i++){
    for(int j=1;i*j < N;j++){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <fstream>
#include <string>
#include <sstream>


using namespace std;

struct data {
	int x, y;
};

int main() {
	while (true) {
		int n;
		int a[405][405];
		int l = 200;
		int r = 200;
		int u = 200;
		int d = 200;
		cin >> n;
		if (n == 0) {
			break;
		}
		struct data data[201];
		data[0].x = 200;
		data[0].y = 200;
		int nn, dd;
		for (int i = 1; i < n; i++) {
			cin >> nn >> dd;
			if (dd == 0) {
				data[i].x = data[nn].x - 1;
				data[i].y = data[nn].y;
			}
			if (dd == 1) {
				data[i].x = data[nn].x;
				data[i].y = data[nn].y+1;
			}
			if (dd == 2) {
				data[i].x = data[nn].x + 1;
				data[i].y = data[nn].y;
			}
			if (dd == 3) {
				data[i].x = data[nn].x;
				data[i].y = data[nn].y - 1;
			}
		}
		for (int i = 0; i < n; i++) {
			l = min(data[i].x, l);
			r = max(data[i].x, r);
			u = min(data[i].y, u);
			d = max(data[i].y, d);
		}
		cout << r - l + 1 <<" " << d - u +1 << endl;
	}
}



Measured memory_bytes: 3052
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int a, b;
	cin >> a >> b;
	if(a%2 == 0 || b%2 == 0) cout << "Even" << endl;
	else cout << "Odd" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 500005
#define ba 47
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,K,q[MAXN],deg[MAXN],ans[MAXN];
vector<int> to[MAXN];
struct node {
    int v,l,r;
}tr[MAXN * 4];
void update(int u) {
    tr[u].v = min(tr[u << 1].v,tr[u << 1 | 1].v);
}
void build(int u,int l,int r) {
    tr[u].l = l;tr[u].r = r;tr[u].v = N + 1;
    if(l == r) return; 
    int mid = (l + r) >> 1;
    build(u << 1,l,mid);
    build(u << 1 | 1,mid + 1,r);
    update(u);
}
void add(int u,int x,int v) {
    if(tr[u].l == tr[u].r) {tr[u].v = v;return;}
    int mid = (tr[u].l + tr[u].r) >> 1;
    if(x <= mid) add(u << 1,x,v);
    else add(u << 1 | 1,x,v);
    update(u);
}
int Query(int u,int l,int r) {
    l = max(l,1);r = min(r,N);
    if(r < l) return N + 1;
    if(l == tr[u].l && r == tr[u].r) return tr[u].v;
    int mid = (tr[u].l + tr[u].r) >> 1;
    if(r <= mid) return Query(u << 1,l,r);
    else if(l > mid) return Query(u << 1 | 1,l,r);
    else return min(Query(u << 1,l,mid),Query(u << 1 | 1,mid + 1,r));
}
set<int> S;
void Solve() {
    read(N);read(K);
    int a = 0;
    build(1,1,N);
    for(int i = 1 ; i <= N ; ++i) {
	read(a);q[a] = i;
    }
    for(int i = N ; i >= 1 ; --i) {
	int r = Query(1,q[i] + 1,q[i] + K - 1);
	if(r != N + 1) {
	    to[q[i]].pb(q[r]);
	    ++deg[q[r]];
	}
	int l = Query(1,q[i] - K + 1,q[i] - 1);
	if(l != N + 1) {
	    to[q[i]].pb(q[l]);
	    ++deg[q[l]];
	}
	add(1,q[i],i);
    }
    for(int i = 1 ; i <= N ; ++i) {
	if(!deg[i]) S.insert(i);
    }
    int cnt = 0;
    while(S.size()) {
	int u =  *S.begin();
	S.erase(S.begin());
	ans[u] = ++cnt;
	for(auto v : to[u]) {
	    if(!(--deg[v])) {
		S.insert(v);
	    }
	}
    }
    for(int i = 1 ; i <= N ; ++i) {
	out(ans[i]);enter;
    }
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 59776
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}

int main(){
    ll N; cin >> N;
    vector<vector<pair<ll,ll>>> G(N);
    for(int i = 0; i < N-1; i++){
        ll a,b,w; cin >> a >> b >> w;
        a--; b--;
        w %= (ll)2;
        G[a].push_back({b,w});
        G[b].push_back({a,w});
    }
    vector<ll> dist(N,-1);
    queue<ll> que;
    for(ll v = 0; v < N; v++){
        if (dist[v] != -1) continue;
        dist[v] = 1;
        que.push(v);
        while(que.size()){
            ll s = que.front();
            que.pop();
            for(ll nv = 0; nv < G[s].size(); nv++){
                if (dist[G[s][nv].first] == -1){
                    dist[G[s][nv].first] = dist[s]+G[s][nv].second;
                    dist[G[s][nv].first] %= 2;
                    que.push(G[s][nv].first);
                } 
            }
        }
    }
    for(int i = 0; i < N; i++){
        cout << dist[i] << endl;
    }
}


Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
#define FOR(n) for(int i=0;i<n;i++)
#define For(i,n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
int main()
{ int n;
cin>>n;
if(n%2!=0)
cout<<(n/2)+1;
else
cout<<n/2;














return 0;
}

Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#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
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n,x,t;
  cin >> n >> x >> t;
  cout << ((n+x-1)/x)*t;


return 0;
}
///....


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#ifndef DBG
#define dbg(...)
#else
#define dbg(...) {cerr << "\033[1;96m"; ostream& cout = cerr; \
(void)(cout); __VA_ARGS__; cerr << "\033[0m";} 
#endif
#define ddmp(...) dbg(dmp(__VA_ARGS__))
#define prt(...) print(cout, __VA_ARGS__)
#define dprt(...) dbg(print(cerr, __VA_ARGS__))
#define dmp(...) print(cerr, #__VA_ARGS__, '=', __VA_ARGS__)
#define all(...) begin(__VA_ARGS__), end(__VA_ARGS__)
#define whr() __LINE__,  __PRETTY_FUNCTION__
using namespace std; using ll = long long;
template< typename... t > using V = vector< t... >;
template< typename t > void print(ostream& os, const t& a)
{os << a <<  '\n';} template< typename t, typename... v >
void print(ostream& os, const t& a, v&&... b){os << a << ' '; print(os, b...);}

int n, k;

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

    cin >> n >> k;

    int pz = -1;
    for (int i = 1; i <= n; ++i)
    {
        int v; cin >> v;
        if (v == 1)
        {
            pz = i; break;
        }
    }

    int res = 1e9;

    for (int i = 1; i <= n - k + 1; ++i)
        if (pz - i + 1 <= k)
        {
            int r = i + k - 1;
            int l = i - 1;
            r = n - r;

            int q = k - 1;
            res = min(res, 1 + ((l + q - 1) / q) + ((r + q - 1) / q));
        }

    prt(res);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;

int main(){
    int n;
    cin >>n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int max=0;
    int min=1e9;
    for(int i=0; i<n; i++){
        if(max<a[i]){
            max = a[i];
        }
        if(a[i]<min){
            min = a[i];
        }
    }
    cout << abs(max-min) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int S;
  scanf("%d",&S);
  if(0 <= S&&86400 > S){
    int h = S / 3600;
    int m = S % 3600;
    int x = m / 60;
    int s = m % 60;
    printf("%d:%d:%d\n",h,x,s);
  }
  return 0;
}

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

using namespace std;

int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	vector<vector <int> > s(m);
	int k;
	int p[n];
	for(int i=0;i<m;i++){
		scanf("%d",&k);
		s[i].resize(k);
		for(int j=0;j<k;j++){
			scanf("%d",&s[i][j]);
			s[i][j]--;
		}
	}
	for(int i=0;i<m;i++)scanf("%d",&p[i]);
	
	int ans=0;
	//2^10は1024！！！！
	for(int i=0;i<(1<<n);i++){
		bool ok = true;
		for(int j=0;j<m;j++){
			int count=0;
			for(int id : s[j]){
				if((i>>id) & 1)count++;
			}
			if((count%=2)!=p[j])ok=false;
		}
		if(ok)ans++;
	}
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>

int main()
{
	unsigned long long N;
	std::cin >> N;

	std::set<int> X;
	for (int i = 0; i < N; ++i) {
		int A;
		std::cin >> A;

		X.insert(A);
	}

	if (X.size() == N) {
		std::cout << "YES";
	}
	else {
		std::cout << "NO";
	}



	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
#include <cstring>


struct State {
    int dist, cnt, x, y, dir;
};
bool operator<(const State &a, const State &b) {
    return std::make_pair(a.dist, a.cnt)
        < std::make_pair(b.dist, b.cnt);
}
bool operator>(const State &a, const State &b) {
    return std::make_pair(a.dist, a.cnt)
        > std::make_pair(b.dist, b.cnt);
}

int main() {
    int H, W, K; std::cin >> H >> W >> K;
    using P = std::pair<int, int>;
    P s, t;
    std::cin >> s.first >> s.second >> t.first >> t.second;
    std::vector<std::string> board(H + 2);
    for (int i = 1; i <= H; i++) {
        std::cin >> board[i];
        board[i] = '@' + board[i] + '@';
    }
    board[0] = board[H + 1] = std::string(W + 2, '@');
    std::vector<std::vector<std::vector<P>>>
        dist(H + 2,
            std::vector<std::vector<P>>(W + 2,
                std::vector<P>(5, {1e9, 1e9})));
    std::priority_queue<State, std::vector<State>, std::greater<State>> que;
    que.push({0, 0, s.first, s.second, 4});
    dist[s.first][s.second][4] = { 0, 0 };
    std::vector<int> dx = { 1, 0, -1, 0, 1 };
    while (!que.empty()) {
        State state = que.top();
        que.pop();

        P cur = dist[state.x][state.y][state.dir];
        for (int i = 0; i < 4; i++) {
            int nx = state.x + dx[i], ny = state.y + dx[i + 1];
            if (board[nx][ny] == '@') continue;
            P nxt = cur;
            if (state.dir == i && cur.second < K) {
                nxt.second++;
            }
            else {
                nxt.first++;
                nxt.second = 1;
            }
            if (dist[nx][ny][i] <= nxt) continue;
            dist[nx][ny][i] = nxt;
            que.push({ nxt.first, nxt.second, nx, ny, i });
        }
    }
    int ans = 1e9;
    for (int i = 0; i < 4; i++) {
        ans = std::min(ans, dist[t.first][t.second][i].first);
    }
    std::cout << (ans != 1e9 ? ans : -1) << std::endl;
    return 0;
}

Measured memory_bytes: 287464
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int count[32];
bool isv[32];

int maxn;
vector<int> to[32];

void dfs(int f)
{
	isv[f] = true;
	for(int i=0;i<to[f].size();++i){
		if(!isv[to[f][i]])dfs(to[f][i]);
	}
}

int main(void){
	while(1){
		cin >> maxn;
		if(maxn == 0) return 0;
		string str;
		for(int i=0;i<32;++i){
			to[i].clear();
			isv[i]=true;
			count[i]=0;
		}
		int f,t;
		for(int i=0;i<maxn;++i){
			cin >> str;
			f = str[0] - 'a';
			t = str[str.size()-1] - 'a';
			to[f].push_back(t);
			++count[f];--count[t];isv[f]=isv[t]=false;
		}
		dfs(f);
		bool flag = true;
		for(int i=0;i<32;++i){
			if(!isv[i] | count[i] != 0){
				cout << "NG" << endl;
				flag = false;
				break;
			}
		}
		if(flag)
			cout << "OK" << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){

int a[26]={0};
string s;

cin>>s;

int n = s.length();

int i;
int j;
for(i=0;i<n;i++){
j = s[i]-'a';
a[j]++;
if(a[j]>=2){
cout<<"no"<<endl;
return 0;
}
}
cout<<"yes"<<endl;
return 0;


}




Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
} 
int main(){
    ll n,m;cin >> n >> m;
    vvl g(n);
    rep(i,m){
        ll a,b;cin >> a >> b;a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    vl d(n,-1);d[0]=0;
    queue<ll> que;que.push(0);
    bool ok=true;
    while(!que.empty()){
        ll v=que.front();que.pop();
        for(auto nv:g[v]){
            if(d[nv]!=-1){
                if(d[v]==d[nv])ok=false;
                continue;
            }
            d[nv]=d[v]^1;
            que.push(nv);
        }
    }
    if(ok){
        ll ans=0;
        rep(i,n)if(d[i])ans++;
        ans*=(n-ans);
        cout << ans-m <<endl;
    }
    else{
        cout << n*(n-1)/2-m <<endl;
    }
} 

Measured memory_bytes: 10080
# from collections import deque
from collections import Counter
from scipy.misc import comb
# from copy import deepcopy

n = int(input())
a = list(map(int, input().split()))
C = Counter(a)
S = 0
for key in C:
    S += comb(C[key], 2, exact=True)

for k in range(n):
    A = a[k]
    print(S - C[A] + 1)

Measured memory_bytes: 36520
K, A, B = list(map(int, input().split(" ")))

def main():
    if B - A <= 2 or A - 1 >= K:
        return 1 + K
    
    tmp = K - A + 1
    if tmp % 2 == 0:
        out = A + tmp // 2 * (B-A)
    else:
        out = A + (tmp-1) // 2 *(B-A) + 1
    return out

out = main()
print(out)

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

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

int main() {
    int64_t s;
    cin >> s;
    int64_t q = sqrt(s);
    if (q * q == s) {
        cout << make_tuple(0, 0, q, 0, 0, q) << '\n';
    } else {
        cout << make_tuple(q, q+1, 0, (q+1)*(q+1)-s, q+1, 0) << '\n';
    }
}


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

int		main()
{
	int k, a, b; cin >> k  >>  a >> b;
	for (int i = a; i <= b; i++)
	{
		if (i % k == 0)
		{
			cout << "OK" << endl;
			return 0;
		}
	}	
	cout << "NG" << endl;
}



Measured memory_bytes: 3632
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNextDouble()){
			double a = sc.nextDouble();
			double x = a * 2;
			a += x;
			for(int i = 3; i <= 10; i++){
				if(i % 2 == 0){
					x = x * 2;
					a += x;
				}else{
					x = x / 3;
					a += x;
				}
			}
			System.out.println(a);
		}
		sc.close();
	}
}

Measured memory_bytes: 19068
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
#include <map>
#include <queue>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

int cmp(pair<int,int>a,pair<int,int>b){
        if(a.first!=b.first)
        return a.first<b.first;
        else
        return a.second>b.second;
}
int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>aa(n);
    int i=1;
    
    for(auto it=aa.begin();it!=aa.end();it++)
        {
            int a;
            cin>>a;
            it->first=a;
            it->second=i;
            i++;
        }
    sort(aa.begin(),aa.end(),cmp);
    
    for(auto it=aa.begin();it!=aa.end();it++)
        cout<<it->second<<" ";
    
    
    return 0;
}






Measured memory_bytes: 1536
#include <stdio.h>
int main(){
int a,b;
	scanf("%d%d",&a,&b);
	//printf("%d %d",a,b);
	if(a>=2*b){
		printf("%d\n",a-2*b);
	}
	else
	{
		printf("0");
	}
return 0;
}

Measured memory_bytes: 128