akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        Map<Integer,Integer>hm=new HashMap<Integer,Integer>();
        for(int i=0;i<n;++i){
            int x=sc.nextInt();
            hm.put(x,hm.getOrDefault(x,0)+1);
        }
        int ans=0;
        for(Map.Entry<Integer,Integer> e:hm.entrySet()){
            int k=e.getKey();
            int v=e.getValue();
            if(v<k)ans+=v;
            else ans+=v-k;
        }
        out.println(ans);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 45708
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
    int a;
    cin>>a;
    cout<<a+(a*a)+(a*a*a);

}






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

int main() {
	int W, H, x, y;
	cin >> W >> H >> x >> y;

	double s = (double) W * (double) H / 2.0;

	int res = 0;
	if(x * 2 == W && y * 2 == H) res = 1;
	cout << fixed << setprecision(9) << s << " " << res << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>

#define N 300005
#define M 8000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

int i,j,m,n,p,k,t[3],a[N];

int main()
{
		scanf("%d",&n);
		if (n==1)
		{
				puts("Yes");
				return 0;
		}
		for (i=1;i<=n;++i)
		{
				scanf("%d",&a[i]);
				int f=0;
				for (;a[i]%2==0;) a[i]/=2,f++;
				t[min(2,f)]++;
		}
		if (t[0]<=t[2]||(t[0]==t[2]+1&&t[1]==0)) printf("Yes\n");
		else printf("No\n"); 
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
#A=[int(input()) for i in range(M)]
A=set()
for i in range(M):
    a=int(input())
    A.add(a)
mod=10**9+7
dp=[0]*(N+1)
dp[0]=1
for i in range(1,N+1):
    if i in A:
        continue
    if i==1:
        dp[1]=dp[0]
        continue
    dp[i]=dp[i-1]+dp[i-2]
    dp[i]%=mod
print(dp[N])

Measured memory_bytes: 46808
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}

const ll MAX = 1e18;

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

    if(abs(a-b) > MAX) cout << "Unfair" << endl;
    else{
        if(k%2 == 0) cout << a-b << endl;
        else cout << b-a << endl;
    }
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin>>n>>s;
    int cnt=1;
    for(int i=1;i<s.size();i++){
        if(s[i]!=s[i-1])cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 512
#abc113c

n,m=map(int,raw_input().split())
py=[]
for i in xrange(m):
 p,y=map(int,raw_input().split())
 py.append([i,p,y])
py=sorted(py,key=lambda x:(x[1],x[2]))
pn=[0]*(n+1)
res=[""]*m
for j in range(m):
 i,p,y=py[j]
 pn[p]+=1
 res[i]="%06d%06d"%(p,pn[p])
for x in res:
 print x


Measured memory_bytes: 37284
/********************************************
 *Author*        :XzzF
 *Created Time*  : 2018年06月17日 星期日 13时34分06秒
 * Ended  Time*  : 2018年06月17日 星期日 13时35分27秒
*********************************************/

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;

int A, B;

int main()
{
	while(scanf("%d %d", &A, &B) != EOF)
	{
		if(A > 8 || B > 8) printf(":(\n");
		else printf("Yay!\n");
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
ll dp[222][111111];
int main(){
  ll n,x,p=1e9+7;
  cin>>n>>x;
  vector<ll> s(n);
  for(int i=0;i<n;i++)cin>>s[i];
  
  sort(all(s));
  reverse(all(s));
  dp[0][x]=1;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<=x;j++){
	 if(dp[i][j]==0)continue;
	 (dp[i+1][j%s[i]]+=dp[i][j])%=p;
	 (dp[i+1][j]+=dp[i][j]*(n-i-1)%p)%=p;
    }
  }
  ll ans=0;
  for(ll i=0;i<=x;i++){
    (ans+=i*dp[n][i]%p)%=p;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 174336
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		//	Scanner sc = new Scanner(System.in);//入力
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		//渡される定数
		String[] Aandb = (input.readLine()).split("\\s");//入力数値をスペース前後で分割
		int n = Integer.parseInt(Aandb[0]);//配列n(前)
		int m = Integer.parseInt(Aandb[1]);//配列m(後)

		//CはAとbの掛け算
		//for(int i =1;i<m;i++){
		//C +=A*b}

		//n*mである行列Aの計算
		int[][] A = new int[n][m];//Aの要素nとm
		String[] z = null; //実行データ用　文字列として使っているため0でなくnull
		for (int i = 0; i < n; i++) {//nのループ
			z = (input.readLine()).split("\\s");//入力を半角スペースで分轄
			for (int j = 0; j < m; j++) {//mのループ
				A[i][j] = Integer.parseInt(z[j]);//文字列から数値に変換
			}
		}

		//m*1であるベクトルbの計算
		int[] b = new int[m];//bの要素m
		for (int k = 0; k < m; k++) {
			b[k] = Integer.parseInt(input.readLine());//文字列から数値に変換

		}

		//A*bの積C
		for (int l = 0; l < n; l++) {
			int C = 0;//合計の初期化
			for (int s = 0; s < m; s++){
				C += (A[l][s] * b[s]);
			}
			System.out.println(C);//出力
		}
	}
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  ll ans=divisor(n-1).size();
  auto v=divisor(n);
  for(auto e:v){
    if(e==1) continue;
    ll tmp=n;
    while(tmp%e==0){
      tmp/=e;
    }
    if(tmp%e==1) ans++;
  }
  cout<<ans-1<<endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();

    System.out.println(a > b ? "a > b" : a < b ? "a < b" : "a == b");

    sc.close();
  }
}


Measured memory_bytes: 26140
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N, K;
    cin >> N >> K;

    vector<char> D(K);
    for(auto& d:D){
        cin >> d;
    }

    bool flag=0;
    for(int i=N; true; i++){
        string S=to_string(i);
        flag=1;
        for(auto d:D){
            if(S.find(d)!=string::npos){
                flag=false;
                break;
            }
        }
        if(flag){
            cout << S << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string trange1(string s){
	string t;
	for(int i=s.size()-1;i>=0;i--) t+=s[i];
	return t;
}
string trange2(string s){
	string t;
	for(int i=0;i<s.size();i++){
		if(s[i]=='b') t+='d';
		else if(s[i]=='d') t+='b';
		else if(s[i]=='p') t+='q';
		else t+='p';
	}
	return t;
}
string s,t;
int main(){
    cin>>s;
    t=s;
    s=trange1(s);
    s=trange2(s);
    if(t==s) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int maxn=1e6+7;
int main()
{
	ull n;cin>>n;ull sum=0ull;
	for(ull i=1ull;i<sqrt(n);i++)
	{
		if(n%i==0ull)
		{
			ull m=n/i-1ull;
			if(m<=i) break;
			sum+=m;
		}
	}
	cout<<sum<<endl; 
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

int t[30][3];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n;
	a=0;
	for(i=0;i<3;i++){
		for(j=0;j<n-i/2;j++){
			cin>>t[j][i];
		}
	}
	
	for(i=0;i<n;i++){
		a+=t[i][1];
		b=t[i][0]-1;
		if(i!=n-1 && t[i][0]+1==t[i+1][0]){
			a+=t[b][2];
		}
	}
	cout<<a<<endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(M)]

adj = [[] for _ in range(N)]
for a,b in ab:
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
    

def dfs(x,s,flags):
    vlist = adj[x]
    flags = list(flags)
    flags[x] = False
    flags = tuple(flags)
    if sum(flags) == 0:
        return 1
    s = 0
    for v in vlist:    
        if flags[v]:
            s += dfs(v,s,flags)
    return s        

Flag = [True] * N
Flag[0] = False
ans = dfs(0,0,tuple(Flag))
print(ans)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


# X%M + X^(2)%M + X^(4)%M + X^(8)%M ...
# 重要な性質X^(k)%M for k=[0,M-1]は循環する
# X^(k) = X^(c*M+k) (mod M)
# = X^(k%M)

# X(0%M)%M + X^(2%M)%M + X^(4%M)%M + X^(8%M)%M ...

# あまりの循環テーブルT
# T[0%M] + T[2%M] + T[4%M] ...
# T[2^(0)%M] + T[2^(1)%M] + T[2^(2)%M] ...(M)  ... (循環するので×だけ) (N%M) ...
# N//M回循環する
# 2のべき乗をMで割ったテーブル
# 正確には違ったね

# (X^2*k) = (X^2)^k
# (X^2)^kが循環する

N, X, M = ints()
A = [X]
for i in range(M):
    A.append(pow(A[-1], 2, M))  # 循環は単純ではないのか

# 早期終了
if N < M:
    exit(sum(A[:N]))

if M == 1:
    exit(0)

# 非ループ部分とそれ以外の検出
visited = set()
for i in range(M):
    if A[i] in visited:
        len_total = i
        break
    visited.add(A[i])
# i番目の要素が初めて出てくるところを改めて探す
s = A.index(A[len_total])
cut = A[:s]
loop = A[s:len_total]
# print(cut)
# print(loop)
# print(A) #ok
ans = sum(cut)
N -= len(cut)

ans += sum(loop) * (N // len(loop))
ans += sum(loop[:N % len(loop)])
print(ans)


Measured memory_bytes: 82604
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

void solve()
{
	int n,k;
	cin>>k>>n;
	int a[n];
	for(int i=0;i<n;i++){cin>>a[i];}
	int d[n];
	//for(int i=0;i<n;i++){if(a[i]==0)a[i]=k;}
	if(a[0]==0)
	d[0]=a[0]+k-a[n-1];
	else
	d[0]=k-a[n-1]+a[0];
	//cout<<d[0]<<" ";
	for(int i=1;i<n;i++)
	{
		d[i]=a[i]-a[i-1];
		//cout<<d[i]<<" ";
	}
	sort(d,d+n);
	cout<<k-d[n-1];
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

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

  int pass[200000] = {0};
  int a[m] , b[m];
  for(int i = 0;i < m;i ++){
    scanf("%d %d",&a[i],&b[i]);
    if(a[i] == 1){
      pass[b[i]] ++;
    }
  }

  int flag = 0;
  for(int i = 1;i <= m;i ++){
    if(a[i] == n){
      if(pass[b[i]] != 0){
        flag = 1;
        i += m+1;
      }
    }
    else if(b[i] == n){
      if(pass[a[i]] != 0){
        flag = 1;
        i += m+1;
      }
    }
  }

  if(flag == 0){
    printf("IMPOSSIBLE\n");
  }
  else{
    printf("POSSIBLE\n");
  }

  return 0;
}

Measured memory_bytes: 2560
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

const int N=200010;
int a[N];
ll s1[N],s2[N];

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

int main()
{
	int L,n;scanf("%d%d",&L,&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	s1[0]=0;for (int i=1;i<=n;i++) s1[i]=s1[i-1]+a[i];
	s2[0]=0;for (int i=1;i<=n;i++) s2[i]=s2[i-1]+L-a[i];
	ll ans=0;
	for (int i=1;i<=n;i++)
	{
		int j=(i+n)/2;
		ll t=(s1[j]-s1[i-1])*2+(s2[n]-s2[j])*2;
		if ((i+n)%2==0) t=t-a[j]; else t=t-L+a[j+1];
		ans=max(ans,t);
	}
	for (int i=1;i<=n;i++)
	{
		int j=i/2+1;
		ll t=(s1[j-1])*2+(s2[i]-s2[j-1])*2;
		if ((1+i)%2==0) t=t-(L-a[j]); else t=t-a[j-1];
		ans=max(ans,t);
	}
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 4096
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cctype>
#include <cstdio>
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(c>=a && c<=b){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 256
N=int(input())
x = []
u = []
for _ in range(N):
    xt,ut = input().split()
    xt = float(xt)
    x.append(xt)
    u.append(ut)
ans = 0
for i in range(N):
    if u[i] =="JPY":
        ans += x[i] 
    else:
        ans += x[i]*380000
print(ans)

Measured memory_bytes: 3064
### input test
"""
N = 6
rawP = [
(16,24,0),
(2,3,0),
(2,1,0),
(1,2,0),
(3,2,0),
(2,2,1),
]
# => expected(2,2,1)
###
"""
N = int(input())
rawP = [tuple(map(int, input().split())) for _ in range(N)]


###
# get 1 index where h is not 0
# N < 101*101 ==> h > 0 at least 1 point
P = []
for i in range(N):
    if rawP[i][2] > 0:
       P.append(rawP[i])
REGi = len(P)-1

# if only 1 point (h>0) given, that is the center
if len(P) == 1:
    print(*P[REGi])
    exit(0)

def dist(p1, p2):
    return abs(p1[0]-p2[0])+abs(p1[1]-p2[1])

def is_correct_center(cx, cy):
    now_C = (cx, cy, 0)  # Is this the center?
    # get first sample where h is not 0
    reg_D = dist(P[REGi], now_C)
    reg_H = P[REGi][2]
    for i in range(len(P)):
        now_D = dist(P[i], now_C)
        now_H = P[i][2]
        # higher_H if nearer_D
        if (- now_D + reg_D) != (now_H - reg_H):
            return False
    return True

def get_answers(cx, cy):
    H = P[REGi][2] + dist(P[REGi], (cx, cy, 0))
    return cx, cy, H

### Start from here...
for cx in range(101):
    for cy in range(101):
        if is_correct_center(cx, cy):
            print(*get_answers(cx, cy))
            exit(0)


Measured memory_bytes: 3064
n = int(input())
a = list(map(int, [input() for i in range(n)]))
ans = 1
hikari = 1
for i in range(n):
        hikari = a[hikari -1]
        if hikari == 2:
                print(ans)
                exit()
        else:
                ans  += 1
print(-1)

Measured memory_bytes: 20084
using System;

namespace ABC121_a
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int m; 
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            string[] array2 = Console.ReadLine().Split(' ');
            int c = int.Parse(array2[0]);
            int d = int.Parse(array2[1]);
            m = a * b - b * c - a * d + c * d;
            Console.WriteLine(m);
        }
    }
}


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

using namespace std;

typedef vector<int> vi;
typedef set<int> si;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#define FIT(it, v) for (typeof((v).begin())it = (v).begin(); it != (v).end(); ++it)
#define FITD(it, v) for (typeof((v).rbegin())it = (v).rbegin(); it != (v).rend(); ++it)
template<typename T> T gcd(T a, T b) { return (b == 0) ? abs(a) : gcd(b, a % b); }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> inline T mod(T a, T b) { return (a % b + b) % b; }
template<typename T> inline T sqr(T x) { return x * x; }
template<typename T> inline string toString(const T& x) { ostringstream os; os << x; return os.str(); }
inline ll toInt(const string& s) { istringstream is(s); ll x; is >> x; return x; }
inline ld toDouble(const string& s) { istringstream is(s); ld x; is >> x; return x; }
inline string toLower(string s) { FIT(it, s) *it = tolower(*it); return s; }
inline string toUpper(string s) { FIT(it, s) *it = toupper(*it); return s; }

int main()
{
    //freopen("input.txt","r",stdin);
    string st;
    cin>>st;
    cout<<st.substr(0,4)<<" "<<st.substr(4,st.size()-1)<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
	int k;
	int n[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5,
			1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2,
			2, 5, 4, 1, 4, 1, 51 };

	scanf("%d", &k);


	printf("%d", n[k-1]);


	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define N 100005
long long dp[N],w[N],val[N];
int main(){
	int n,W;
	scanf("%d %d",&n,&W);
	for(int i=0;i<n;i++) scanf("%lld %lld",&w[i],&val[i]);
	for(int i=0;i<n;i++){
		for(int j=W;j>=w[i];j--){
			dp[j]=max(dp[j],dp[j-w[i]]+val[i]);
		}
	}
	long long ma=0;
	for(int i=0;i<=W;i++){
		ma=max(ma,dp[i]);
	}
	cout<<ma;
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    string s;
    cin >> s;
    string t;
    cin >> t;

    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    string o, e;
    cin >> o >> e;
    if(o.size()-e.size()==1){
        rep(i, e.size()){
            cout << o[i] << e[i];
        }
        cout << o[o.size()-1];
    }else{
        rep(i, e.size()){
            cout << o[i] << e[i];
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,ll> P;
typedef vector<P> vip;

void solve(){
    string a;cin>>a;
    int cnt=0;
    fol(i,3){
        if(a[i]=='1') cnt++;
    }
    cout << cnt << endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
F=->z,c{f=G[c].size==2?1:0;r=[0,c];G[c].map{|e|e!=z&&(x,y=F[c,e];r=[r,[x+f,y]].max)};r}
N=gets.to_i
G=N.times.map{[]}
(N-1).times{a,b=gets.split.map &:to_i;G[a-1]<<b-1;G[b-1]<<a-1}
p F[-1,F[-1,0][1]][0]+G.count{|e|e.size==1}

Measured memory_bytes: 14844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        FastReader f = new FastReader();
        // int [] arr = { 1 , 6 , 120 , 496 , 2016, 8128 ,32640 , 130816};
        
        String s = f.next();
        byte aCounter=0 , bCounter=0 , cCounter=0;
        for(byte i =0;i<3 ; i++){
            switch(s.charAt(i)){
                case'a':
                    aCounter++;
                    break;
                case'b':
                    bCounter++;
                    break;
                case'c':
                    cCounter++;
                    break;
            }
        }
        if(aCounter!=0 && bCounter!=0 && cCounter!=0)System.out.println("Yes");
        else { System.out.println("No");}
    
}

     
     
     
 }

class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        byte nextByte() 
        { 
            return Byte.parseByte(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    
}


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

int main(){
  ll q;
  while(cin>>q){
    if(q==-1)break;
    double x=q/2.0;
    while(fabs(pow(x, 3.0)-q)>=0.00001*q){
      x=x-(pow(x, 3.0)-q)/(3.0*x*x);
    }
    printf("%.8f\n", x);
  }
  return 0;
}

Measured memory_bytes: 1268
n, k = map(int, input().split())

if k > (n-1)*(n-2)//2:
  print(-1)
else:
  ans = []
  for i in range(n-1):
    ans.append("{} {}".format(1, i+2))
  u = 2
  v = 3
  for _ in range((n-1)*(n-2)//2 - k):
    ans.append("{} {}".format(u, v))
    v += 1
    if (v > n):
      u += 1
      v = u + 1

  print(len(ans))
  for s in ans:
    print(s)


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

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

using namespace std;

typedef long long ll;

int Q;

ll A,B;

int main(){
	cin>>Q;
	REP(q,Q){
		cin>>A>>B;
		if (A<B) swap(A,B);
		ll lb=B,ub=A+1;
		while(ub-lb>1){
			ll mid=(lb+ub)/2;
			if (mid*mid<A*B){
				lb=mid;
			}else{
				ub=mid;
			}
		}
		ll ans=2*(lb-1);
		if (lb*(lb+1)<A*B){
			ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
typedef long long lint;
using namespace std;

int main()
{
	lint N,a;
	map<lint,lint> m;
	lint ans=0;
	
	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> a;
		m[a]++;
	}
	
	for(pair<lint,lint> i:m)
	{
		if(i.second>i.first)
			ans+=i.second-i.first;
		else if(i.second<i.first)ans+=i.second;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
struct Dice {
	int V[6];
	void role(char c) {
		int a;
		if (c == 'E') {
			a = V[0];
			V[0] = V[3];
			V[3] = V[5];
			V[5] = V[2];
			V[2] = a;
		}
		if (c == 'N') {
			a = V[0];
			V[0] = V[1];
			V[1] = V[5];
			V[5] = V[4];
			V[4] = a;
		}
		if (c == 'S') {
			a = V[0];
			V[0] = V[4];
			V[4] = V[5];
			V[5] = V[1];
			V[1] = a;
		}
		if (c == 'W') {
			a = V[0];
			V[0] = V[2];
			V[2] = V[5];
			V[5] = V[3];
			V[3] = a;
		}
		if (c == 'R') {
			a = V[1];
			V[1] = V[2];
			V[2] = V[4];
			V[4] = V[3];
			V[3] = a;
		}
		if (c == 'L') {
			a = V[1];
			V[1] = V[3];
			V[3] = V[4];
			V[4] = V[2];
			V[2] = a;
		}
	}
	int top() {
		return V[0];
	}
	int right() {
		return V[2];
	}
	int left() {
		return V[3];
	}
	int front() {
		return V[1];
	}
	int back() {
		return V[4];
	}
	int bottom() {
		return V[5];
	}
};

bool same(Dice a, Dice b) {
	for (int i = 0; i < 6; i++) if (a.V[i] != b.V[i])
		return false;
	return true;
}

int main() {

	Dice d[100];
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 6; j++)
			cin >> d[i].V[j];
	}
		
	bool b = false;

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = 0; k < 4; k++) {
				d[j].role('N');
				for (int l = 0; l < 4; l++) {
					d[j].role('R');
					if (same(d[i], d[j])) {
						b = true;
					}
				}
			}

			d[j].role('E');
			for (int k = 0; k < 4; k++) {
				d[j].role('R');
				if (same(d[i], d[j])) {
					b = true;
				}
			}

			d[j].role('W');
			d[j].role('W');
			for (int k = 0; k < 4; k++) {
				d[j].role('R');
				if (same(d[i], d[j])) {
					b = true;
				}
			}
			d[j].role('E');
		}
	}

	if (b)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}


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

void Main()
{
    string s;
    int q;
    cin >> s >> q;
    int r = 0;
    string sa, sb;
    for (int i = 0; i < q; i++)
    {
        int t, f;
        char c;
        cin >> t;
        if(t == 1) r++;
        else{
            cin >> f >> c;
            if(f == 1 && r % 2 == 0 || f == 2 && r % 2 == 1) sa = sa + c;
            else sb = sb + c;
        }
    }
    if(r % 2 == 1)
        swap(sa, sb);
    for (auto i = sa.rbegin(); i != sa.rend(); i++)
        cout << *i;
    if(r % 2 == 1)
        for (auto i = s.rbegin(); i != s.rend(); i++)
            cout << *i;
    else
        cout << s;
    cout << sb << endl;
    
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 4584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 200001
#define vmax 10000
#define sentinel 2000000000
constexpr long long int inf = 1000000000000;
constexpr long long int rinf = -(INT64_MAX);
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

ll cnt;
int l;
int a[1000000];
int n;
vector<int> g;

void insertionsort(int a[],int n,int g){
    for(int i=g;i<n;i++){
        int v=a[i];
        int j=i-g;
        while(j>=0&&a[j]>v){
            a[j+g]=a[j];
            j=j-g;
            cnt++;
        }
        a[j+g]=v;
    }
}

void shellsort(int a[],int n){
    int h=1;
    while(h<=n){
        g.push_back(h);
        h=3*h+1;
    }

    for(int i=g.size()-1;i>=0;i--){
        insertionsort(a,n,g[i]);
    }
}

int main() {
    cin>>n;
    rep(i,n) scanf("%d",&a[i]);
    cnt=0;

    shellsort(a,n);

    cout<<g.size()<<endl;
    for(int i=g.size()-1;i>=0;i--){
        printf("%d",g[i]);
        if(i) printf(" ");
    }
    printf("\n");
    printf("%d\n",cnt);
    rep(i,n){
        printf("%d\n",a[i]);
    }
    return 0;
}



Measured memory_bytes: 7120
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;

double calc(int i)
{
    return (i+1)/(double)2;
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    int maxSum = 0;
    int startIdx = 0;
    int sum = 0;
    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        v[i] = t;
        if(i < k)
        {
           sum += t; 
        }
        else
        {
            sum = sum - v[i-k] + t;
            if(maxSum < sum)
            {
                maxSum = sum;
                startIdx = i-k+1;
            }
        }
    }
    double ans = 0;
    for(int i = 0; i < k; ++i)
    {
        ans += calc(v[startIdx+i]);
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
ac=[0 for i in range(n+1)]
wa=[0 for i in range(n+1)]
for i in range(m):
    s,t=input().split()
    if t=="WA":
        if ac[int(s)]==0:
            wa[int(s)]+=1
    else:
        if ac[int(s)]==0:
            ac[int(s)]+=1
s=0
for i in range(n+1):
   s+=ac[i]*wa[i]
print(str(sum(ac))+" "+str(s))

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

int main() {
long long a[26]={0},n;
string s;
cin>>s;
n=s.length();
for(int i=0;i<n;i++){
    a[s[i]-'a']++;
}
n=n*(n-1)/2;
for(int i=0;i<26;i++){
    n-=a[i]*(a[i]-1)/2;
}
cout<<n+1<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1];
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

lin n;
lin x;
lin a[101];

int main(void)
{
    cin >> n >> x;
    rep(i,n)
    {
        cin >> a[i];
    }

    sort(a, a+n);

    lin res = 0;
    rep(i,n)
    {
        if(x < a[i])
        {
            x = 0;
            break;
        }

        res++;
        x -= a[i];

        if(x == 0)
            break;
    }

    if(x > 0)
        res--;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
a = list(map(int, input().split())) 

b = list(accumulate(a))
ma = b[-1]
mi = 10**10
for sunuke in b[:N-1]:
    arai = ma - sunuke
    if abs(sunuke - arai) < mi:
        mi = abs(sunuke - arai)
print(mi)

Measured memory_bytes: 30680
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include<algorithm>
#include <set>
#include <stack>
#include <cmath>
#include <stdlib.h>
#include <functional>
using namespace std;
int main()
{
    int n,arr[100]={0};
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    long long small,t=1000;
    small=arr[0];
    for(int i=0;i<n;i++)
    {
        long long q=0;
        if(arr[i]>small)
        {
            q=t/small;
            t-=q*small;
            t+=q*arr[i];
            small=arr[i];
        }
        else if(arr[i]<small)
        {
            small=arr[i];
        }
    }
    cout<<t;
    return 0;
}


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

int digits (int n) {
  int ret=0;
  for (int i=0; i<5; i++) {
    ret+=n%10;
    n/=10;
  }
  return ret;
}

int main() {
  int n;
  cin>>n;
  int ans=1e9;
  for (int i=1; i<=n/2; i++) {
    ans=min(ans,digits(i)+digits(n-i));
  }

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

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] p = new int[n];
    for(int i = 0;i<n;i++)p[i]=sc.nextInt();
    int count = 0;
    for(int i = 0;i<n;i++){
      if(p[i]-i!=1)count++;
    }
    if(count==2||count==0){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 35828
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[1000010],b[1000010],c[1000010];
int main()
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	printf("%d\n",min(n*a,b));
}

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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

using namespace std;

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

    int x, y;
    cin >> x >> y;
    if (y & 1) {
        cout << "No";
    } else if (x * 2 <= y && y <= x * 4) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 3640
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
 
using namespace std;
 
typedef long long LL;
 
const int inf = 1 << 30;
const int maxn=2e6+5;
 
struct edges{
	int to,nxt;
}ed[maxn<<1];
int head[maxn],ecnt=0;
int n,k,a[maxn],de[maxn];
int ans[maxn];
 
void add(int x,int y){
	ed[++ecnt].to=y;ed[ecnt].nxt=head[x];head[x]=ecnt;
}
 
struct segm{
	int mn;
}se[maxn<<2];
 
void build(int x,int y,int num){
	if(x==y){
		se[num].mn=inf;return ;
	}
	int mid=x+y>>1;
	build(x,mid,num<<1);build(mid+1,y,num<<1|1);
	se[num].mn=min(se[num<<1].mn,se[num<<1|1].mn);
}
 
void update(int l,int to,int x,int y,int num){
	if(x==y){
		se[num].mn=to;return ;
	}
	int mid=x+y>>1;
	if(l<=mid)update(l,to,x,mid,num<<1);
	else update(l,to,mid+1,y,num<<1|1);
	se[num].mn=min(se[num<<1].mn,se[num<<1|1].mn);
}
 
int query(int l,int r,int x,int y,int num){
	if(l>r)return 0;
	if(l<=x && y<=r)return se[num].mn;
	int mid=x+y>>1;
	if(r<=mid)return query(l,r,x,mid,num<<1);
	else if(l>mid)return query(l,r,mid+1,y,num<<1|1);
	else return min(query(l,r,x,mid,num<<1),query(l,r,mid+1,y,num<<1|1));
}
 
void topo(){
	priority_queue<int,vector<int>,greater<int> >Q;
	for(int i=1;i<=n;i++){
		if(de[i]==0)Q.push(i);
	}
	int idx=0;
	while(!Q.empty()){
		int tp=Q.top();Q.pop();ans[tp]=++idx;
		for(int i=head[tp];i!=-1;i=ed[i].nxt){
			int u=ed[i].to;
			-- de[u];
			if(!de[u])Q.push(u);
		}
	}
}
 
int main(){
	memset(head,-1,sizeof head);
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		a[x]=i;
	}
	build(1,n,1);
	
	for(int i=n;i>=1;i--){
		int u=query(a[i]+1,min(a[i]+k,n),1,n,1);
		int v=query(max(1,a[i]-k+1),a[i]-1,1,n,1);
		if(u>=1&&u<=n)add(a[i],a[u]), ++ de[a[u]];
		if(v>=1&&v<=n)add(a[i],a[v]), ++ de[a[v]];
		update(a[i],i,1,n,1);
	}
	topo();
	for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
 
	return 0;
}

Measured memory_bytes: 40500
N=int(input())
AC=0
WA=0
TLE=0
RE=0
for i in range(N):
    result=input()
    if result=="AC":
        AC+=1
    elif result == "WA":
        WA+=1
    elif result == "TLE":
        TLE += 1
    else:
        RE+=1

print("AC x "+str(AC))
print("WA x "+str(WA))
print("TLE x "+str(TLE))
print("RE x "+str(RE))


Measured memory_bytes: 9200
#include <iostream>
#include <algorithm>
#include <vector>

#define what_is(x) cerr << #x << " is " << x << endl;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

const int N = 100005;
int a[N];
bool dp[N];

int main() {

    int n, k; cin >> n >> k;
    rep (i, 0, n) cin >> a[i];
    dp[0] = false;
    for (int i = 1; i < N; ++i) {
        bool winning = false;
        for (int j = 0; j < n; ++j) {
            if (i-a[j] >= 0 && !dp[i-a[j]]) {
                winning = true;
                break;
            }
        }
        dp[i] = winning;
    }
    if (dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;

    return 0;
}

Measured memory_bytes: 384
n,a=map(int,input().split())
*x,=map(int,input().split())
dp=[[[0]*(n*50+1) for i in range(n+1)] for _ in range(n+1)]

for i in range(n+1):
    for j in range(n+1):
        for k in range(n*50+1):
            if i==0 and j==0 and k==0:
                dp[i][j][k]=1
            elif i and k<x[i-1]:
                dp[i][j][k]=dp[i-1][j][k]
            elif i and j and k>=x[i-1]:
                dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]]

v=0
for i in range(1,n+1):
    v+=dp[n][i][i*a]
print(v)

Measured memory_bytes: 92636
#include<bits/stdc++.h>
using namespace std;
int main (){
    int n;cin>>n;
    set<string>S;
    while(n--){
        string s;cin>>s;
        S.insert(s);
    }
    cout<<(int)S.size()<<endl;
   // main();
    return 0;
}


Measured memory_bytes: 19220
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long int ll;

int main(){
    int n;  cin >> n;
    vector<ll>b(n-1);
    rep(i, n-1)cin >> b[i];
    //solve
    vector<ll>a(n);
    ll ans = 0;
    rep(i, n-1){
	if(i==0){
	    a[i] = b[i];
	    a[i+1] = b[i];
	}else{
	    if(a[i] < b[i]){
		a[i+1] = b[i];
	    }else{
		a[i] = b[i];
		a[i+1] = b[i];
	    }
	}
	ans += a[i];
    }
    cout << ans + a[n-1] << endl;
    return 0;
}



Measured memory_bytes: 256
n,m=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
a=0
mod=10**9+7
for i in range(n):
    a+=i*p[i]-(n-i-1)*p[i]
    a%=mod
b=0
for i in range(m):
    b+=i*q[i]-(m-i-1)*q[i]
    b%=mod
print((a*b)%mod)

Measured memory_bytes: 18624
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9+7;

int main() {
    string S;
    cin >> S;
    int g_only_sum = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'p') g_only_sum--;
    }
    int p_max_cnt = (int)S.size() / 2;
    cout << g_only_sum + p_max_cnt << endl;
    return 0;
}


Measured memory_bytes: 512
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

int N;
string S;
int Q;

vector<int> ans;

void solve(){
	vector<set<int>> alpha_position(26);
	for(int s=0;s<N;s++){
		alpha_position[S[s]-'a'].insert(s);
	}
	for(int q=0;q<Q;q++){
		int query_type;cin >> query_type;
		if(query_type==1){
			int i;char c;cin >> i >> c;
			i--;
			alpha_position[S[i]-'a'].erase(i);
			alpha_position[c-'a'].insert(i);
			S[i] = c;
		}
		if(query_type==2){
			int l,r;cin >> l >> r;
			l--;r--;
			int counter = 0;
			for(int i='a';i<='z';i++){
				auto left = alpha_position[i-'a'].lower_bound(l);
				if(left==alpha_position[i-'a'].end()) continue;
				if((*left) <= r) counter++;
			}
			ans.push_back(counter);
		}
	}
}
 
int main(){
	cin >> N;
	cin >> S;
	cin >> Q;
 
	solve();

	for(int i=0;i<ans.size();i++)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 24452
import numpy as np

A, B, H, M = (int(x) for x in input().split())

theta_H = (H/12 + M/60/12) * 2*np.pi
theta_M = M/60 * 2*np.pi
theta = abs(theta_H - theta_M)

len_sq = A**2 + B**2 - 2*A*B*np.cos(theta)
print(np.sqrt(len_sq))

Measured memory_bytes: 27200
#include<stdio.h>
int main(void){
	int a;
	int b;
	int c;

	scanf("%d %d %d",&a,&b,&c);

	if (a <= b) {
		if (c <= a) {
			printf("%d %d %d\n",c,a,b);
		}
		else if (b <= c) {
			printf("%d %d %d\n", a, b, c);
		}
		else {
			printf("%d %d %d\n", a, c, b);
		}
	}
	else {
		if (c <= b) {
			printf("%d %d %d\n", c, b, a);
		}
		else if (a <= c) {
			printf("%d %d %d\n", b, a, c);
		}
		else {
			printf("%d %d %d\n", b, c, a);
		}
	}
	
	return 0;
	}

Measured memory_bytes: 596
using System;

class C
{
	static void Main()
	{
		var k = int.Parse(Console.ReadLine());

		var r = 0;
		for (int a = 1; a <= k; a++)
			for (int b = 1; b <= k; b++)
			{
				var g = Gcd(a, b);
				for (int c = 1; c <= k; c++)
					r += Gcd(g, c);
			}
		Console.WriteLine(r);
	}

	static int Gcd(int a, int b) { for (int r; (r = a % b) > 0; a = b, b = r) ; return b; }
}


Measured memory_bytes: 27372