akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
pair<ll,ll> merge(pair<ll,ll> a,pair<ll,ll> b){
    pair<ll,ll> res(a.fi+b.fi,a.se+b.se+1);
    if(res.fi>=10){
        (res.fi%=10)+=1;
        res.se++;
    }
    return res;
}
pair<ll,ll> f(ll n,ll m){
    if(m==1){
        return {n,0};
    }
    if(m%2==0){
        auto p=f(n,m/2);
        return merge(p,p);
    }else{
        return merge(f(n,m-1),f(n,1));
    }
}
int main(){
    int n;
    cin>>n;
    pair<ll,ll> ans(0,0);
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        ans=merge(ans,f(a,b));
    }
    cout<<ans.se-1<<endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
ten=[1]
p=1
mod=10**9+7
for i in range(n-1):
    p*=10
    p%=13
    ten.append(p)
ten=ten[::-1]
dp=[0]*13
dp[0]=1
for t,c in zip(ten,s):
    newdp=[0]*13
    if c!='?':
        c=t*int(c)%13
        for i in range(13):
            newdp[(i+c)%13]=dp[i]
    else:
        for c in range(10):
            c*=t
            for i in range(13):
                newdp[(i+c)%13]+=dp[i]
                newdp[(i+c)%13]%=mod
    dp=newdp

print(newdp[5])

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

using namespace std;
const int N = 1000005;

string s1, s2, s3;

void init(){
	cin >> s1 >> s2 >> s3;
	cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
}

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

Measured memory_bytes: 256
n, m = map(int, input().split())
py = sorted([[i] + list(input().split()) for i in range(m)], key=lambda x: (int(x[1]), int(x[2])))

x = 1
a = 1
ans = []
for i, p, y in py:
    if x != int(p):
        x = int(p)
        a = 1
    
    ans.append([i, p.zfill(6)+str(a).zfill(6)])
    a += 1

for i, v in sorted(ans):
    print(v)

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

int main(){
  ll h, w;
  cin >> h >> w;
  rep(i, 0, h){
    rep(j, 0, w){
    string s;
    cin >> s;
      if(s == "snuke") {
        cout << (char)(j + 'A');
        cout << i+1 << endl;
        return 0;
      }
    }
  }
    return 0;
}


Measured memory_bytes: 3584
# Take the input K
# Take the inpus S

#Compare the length of S with K and put in in length
#If length<=K... print all
#If length>K... print some of the character

K = int(input()) # 0(1)
S = input() #0(1)
second_answer = [] #0(1)
x = 0 #0(1)

length = len(S) #0(1)

if length <= K : 
    print(S) #0(1)
else:
    while x<K : #0(K)
        print(S[x], end= (""))
        x += 1
    print("...")

Measured memory_bytes: 9052
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Set<String> S = new HashSet<>();
		for(int i=0; i<N; i++) {
			String s = sc.next();
			S.add(s);
		}
		sc.close();

		System.out.println(S.size());
	}

}

Measured memory_bytes: 77260
import java.io.*;
import java.util.*;
class Main
{

    static int gcd=1;
    static int get_GCD(int a, int b, int c){
        int minimum=(Math.min(a,b)==Math.min(a,c))? a: Math.min(b,c);
        for(int i=1;i<=minimum;i++)
        {
            if (a%i==0 && b%i==0 && c%i==0)
                gcd=i;
        }
        return gcd;
    }
        public static void main(String []args)throws IOException
        {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int n=Integer.valueOf(br.readLine());
            int sum=0;
            for(int i=1;i<=n;i++)
            {
                for(int j=1;j<=n;j++)
                    {
                    for(int k=1;k<=n;k++)
                          sum+=get_GCD(i,j,k);
                        }
                    }
                    System.out.println(sum);           
                        
        }
    }


Measured memory_bytes: 32640
# coding: utf-8
# Your code here!
S = input()
bin_list = [0, 0, 0]
for i in range(8):
    bin_list = [0, 0, 0]
    now = i
    # bitmapに変換
    for x in range(3):
        amari = now % 2
        now = now // 2
        if amari == 1:
            bin_list[x] = "+"
        else:
            bin_list[x] = "-"
    formula = S[0] + bin_list[0] + S[1] + bin_list[1] + S[2] + bin_list[2] + S[3]
    if eval(formula) == 7:
        print(formula + "=7")
        break

Measured memory_bytes: 3064
#!usr/bin/env python3

def area_circumference():
    a, b = [int(i) for i in input().split()]
    return a, b

def main():
    a, b = area_circumference()
    print(str(a*b) + ' ' + str((a+b) * 2))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7652
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    } else {
        cout << min(a-1, n-b) + (b-a-1)/2 + 1 << endl;
    }
}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int ans  =0;
    int z = min(max(k, 0LL), a);
    k-=z;
    ans += z;
    z = min(max(k, 0LL), b);
    k -= z;
    ans -=k;
    cout << ans << "\n";
    return 0;
}



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

int main(){
    int x, n, p[110], q[110];
    rep(i,109) q[i] = 1;
    cin >> x >> n;
    rep(i,n){
        cin >>p[i];
        q[p[i]] = 0;
    }
    int diff = 100000;
    int ans;
    rep(i,105){
        if(q[i] == 0) continue;
        if(abs(x-i) < diff){
            diff = abs(x-i);
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  f              first
#define  s              second
#define  pb             push_back
#define  INPa(a,n)      foo(i,1,n) cin>>a[i];
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ll   MOD   =  1e+9 + 7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5 + 8;

vll adj[N]; ll vis[N];
ll dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
string s, t;


/***************************************** FUNCTION IMPLEMENTATIONS **************************************/



/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc) {
    cin >> s >> t;
    foo(i, 0, s.size() - 1) {
        if (s[i] == t[i]) continue;
        else {
            cout << "No\n";
            return;
        }
    }
    if (s.size() + 1 == t.size()) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

int main() {
    SPEED;

    //cin>>test_cases;
    foo(i, 1, test_cases) {
        MAIN(i);
    }
}

Measured memory_bytes: 8344
Scanf.scanf "%d %d" (fun n k ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in

    let d = Array.make (n + 1) 0 in
    for i = 1 to n do
        d.(i) <- d.(i - 1) + a.(i - 1)
    done;

    let lim = n * (n + 1) / 2 in
    let s = Array.make lim 0 in
    let rec loop_i i idx =
        let rec loop_j j idx =
            if j > n then loop_i (i + 1) idx else
                let () = s.(idx) <- d.(j) - d.(i) in
                loop_j (j + 1) (idx + 1)
        in
        if i = n then () else
            loop_j (i + 1) idx
    in
    loop_i 0 0;

    let rec loop s s2 lim target t2 i acc =
        if t2 = 0 then target else
        if i = lim then (
            let t3 = t2 lsr 1 in
            if acc >= k then loop s2 (Array.make acc 0) acc (target lor t3)         t3 0 0
                        else loop s  s2                 lim (target lor t3 lxor t2) t3 0 0
        ) else
            if s.(i) land target = target then (
                s2.(acc) <- s.(i);
                loop s s2 lim target t2 (i + 1) (acc + 1)
            ) else (
                loop s s2 lim target t2 (i + 1) acc
            )
    in
    let s2 = Array.make lim 0 in
    let target = loop s s2 lim (1 lsl 40) (1 lsl 40) 0 0 in
    Printf.printf "%d\n" target
)

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

int main(){
    while(true){
        unsigned n, a[50000], sum=0;
        cin >> n;
        if(n==0)
            break;

        for(int i=0;i<n;i++){
            cin >> a[i];
            sum+=a[i];
        }

        sort(a,a+n);

        unsigned ave = sum/n;

        int i=0;
        while(ave>=a[i]&&i<n)
            i++;
        
        cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
// #define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

struct UF{
    vector<int> par;
    vector<int> sz;
    UF(){}
    UF(int n){
        par.resize(n);
        sz.resize(n, 1);
        rep(i, 0, n) par[i] = i;
    }
    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

struct edge{
    int u, v, cost;
};

bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}


signed main(){
    int n;
    cin >> n;
    vector<int> y, x;
    vector<P> dx, dy;  
    vector<edge> es;
    rep(i, 0, n){
        int ix, iy;
        cin >> ix >> iy;
        x. push_back(ix);
        y. push_back(iy);
        dx. push_back(P(ix, i));
        dy. push_back(P(iy, i));
    }
    sort(all(dx));
    sort(all(dy));
    rep(i, 0, n - 1){
        int now = dx[i].second;
        int next = dx[i + 1].second;
        int cost = min(abs(x[now] - x[next]), abs(y[now] - y[next]));
        es. push_back((edge){now, next, cost}); 
    }
    rep(i, 0, n - 1){
        int now = dy[i].second;
        int next = dy[i + 1].second;
        int cost = min(abs(x[now] - x[next]), abs(y[now] - y[next]));
        es. push_back((edge){now, next, cost}); 
    }
    sort(all(es), comp);
    UF uf(n);
    int ans = 0;
    rep(i, 0, es.size()){
        edge e = es[i];
        if(!uf.same(e.u, e.v)){
            uf.unite(e.u, e.v);
            ans += e.cost;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7768
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  int ans = 0;
  for (int i=0; i<n; i++) {
    int x;
    cin >> x;
    if (x>=k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int t,h[1001],n,a;
	double te[1001];
	cin>>n>>t>>a;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
		te[i]=t-0.006*h[i];
		te[i]=abs(a-te[i]);
	}
	double mn=1000001,mni;
	for(int i=1;i<=n;i++)
	if(te[i]<mn)mn=te[i],mni=i;
	cout<<mni;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MAXN=2e5+51;
vector<ll>v;
queue<ll>q;
ll kk;
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
inline void bfs()
{
	ll top;
	while(!q.empty())
	{
		top=q.front(),q.pop();
		if(top%10==9)
		{
			q.push(top*10+8),q.push(top*10+9);
			v.push_back(top*10+8),v.push_back(top*10+9);
		}
		if(top%10==0)
		{
			q.push(top*10),q.push(top*10+1);
			v.push_back(top*10),v.push_back(top*10+1);
		}
		if(top%10!=9&&top%10!=0)
		{
			for(register int i=-1;i<=1;i++)
			{
				q.push(top*10+(top%10)+i);
				v.push_back(top*10+(top%10)+i);
			}
		}
		if(v.size()>=kk)
		{
			printf("%lld\n",v[kk-1]);
			exit(0);
		}
	}
}
int main()
{
	kk=read();
	if(kk<=9)
	{
		return printf("%d\n",kk),0;
	}
	for(register int i=1;i<=9;i++)
	{
		v.push_back(i),q.push(i);
	}
	bfs();
}

Measured memory_bytes: 1620
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int64 div_ceil(int64 lhs, int64 rhs){ return (lhs-1)/rhs + 1; }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s; cin >> s;
    uint oddN =div_ceil(s.size(), 2);
    uint evenN=s.size()/2;
    
    int odd0=0, odd1=0;
    int even0=0, even1=0;
    for(uint i=0; i<s.size(); ++i){
        if(i%2==0){ if(s[i]=='0'){ ++odd0;  }else{ ++odd1;  }
        }   else  { if(s[i]=='0'){ ++even0; }else{ ++even1; } }
    }
    cout << min(oddN-odd0 + evenN-even1, oddN-odd1 + evenN-even0) << endl;
    
    return 0;
}

Measured memory_bytes: 512
import math
n=int(input())

ans=0
for a in range(1,n+1):
  for b in range(1,n+1):
    d=math.gcd(a,b)
    if d==1:
      ans+=n
      continue
    if d==2:
      ans+=n//2*3+n%2
      continue
    if d==3:
      ans+=n//3*5+n%3
      continue
    if d==5:
      ans+=n//5*9+n%5
      continue
    for c in range(1,n+1):
      ans += math.gcd(c,d)

print(ans)

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

class Node {
public:
	int data;
	Node* next;
	Node* prev;
	Node(){
		data = 0;
		next = 0;
		prev = 0;
	}
};

class LinkedList {
public:
	Node dummy;
	LinkedList(){
		dummy.data = 0;
		dummy.prev = &dummy;
		dummy.next = &dummy;
	}
	void insert(int x){
		Node* p = &dummy;
		Node* q = dummy.next;
		Node* s = new Node;
		s->data = x;
		s->prev = p;
		s->next = q;
		p->next = s;
		q->prev = s;
	}
	void del(int x){
		Node* n = dummy.next;
		while(n!=&dummy){
			if(n->data != x){
				n = n->next;
				continue;
			}
			n->prev->next = n->next;
			n->next->prev = n->prev;
			delete n;
			break;
		}
		return;
	}
	void delF(){
		Node* n = dummy.next;
		n->prev->next = n->next;
		n->next->prev = &dummy;
		delete n;
	}
	void delL(){
		Node* n = dummy.prev;
		n->next->prev = n->prev;
		n->prev->next = &dummy;
		delete n;
	}
	void print(){
		Node* n = dummy.next;
		while(n!=&dummy){
			cout << n->data;
			if(n->next!=&dummy)
				cout << ' ';
			n = n->next;
		}
		cout << endl;
	}
};

int main(){
	int n, x;
	string input;
	LinkedList list;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> input;
		if(input == "insert"){
			cin >> x;
			list.insert(x);
		} else if(input == "delete"){
			cin >> x;
			list.del(x);
		} else if(input == "deleteFirst")
			list.delF();
		else if(input == "deleteLast")
			list.delL();
	}

	list.print();
}



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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

ll cnt[100000][26];

int main()
{
	int N;
	string S;
	ll ans = 0;

	cin >> N >> S;
	rep(i, N) cnt[i][S[i] - 'a']++;

	rep(j, 26) rrepc(i, N - 2, 0) {
		cnt[i][j] += cnt[i + 1][j];
	}

	rep(i, N) {
		if (i == N - 1) ans = (ans + 1) % MOD;
		else {
			ll add = 1;
			bool found = false;

			rep(j, 26) {
				if (j == S[i] - 'a') continue;
				if (cnt[i + 1][j] != 0) {
					found = true;
					add = (add * (1 + cnt[i + 1][j])) % MOD;
				}
			}

			if (!found) add = 1;

			ans = (ans + add) % MOD;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 20736
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

@njit((i8, i8[:]), cache=True)
def main(N,A):
  Amax = np.max(A)
  lis = np.zeros(Amax+1, np.int64)
  for i in range(N):
    lis[A[i]] += 1
  setwise = False
  for t in range(2,Amax+1):
    cnt = np.sum(lis[t:Amax+1:t])
    if cnt==N:
      return 'not'
    if 2<=cnt<N:
      setwise=True
  if setwise==True:
    return 'setwise'
  return 'pairwise'

N = int(input())
A = np.array(list(map(int, input().split())))
print(main(N,A)+' coprime')



Measured memory_bytes: 216812
'use strict'
function otoshidama(stdin) {
  const inputs = stdin.split(' ')
  const n = inputs[0]
  const y = inputs[1]
  for (let i = 0;i <= n;i++) {
    const remain = y - 10000 * i
    if (remain === 0 && n === i) {
      return console.log(n, 0, 0)
    } else if (remain <= 0 && i < n) {
      break
    }
    for (let j = 0;j <= n - i;j++) {
      const sen = n - i - j
      const result = remain - 5000 * j - 1000 * sen
      if (result === 0) {
        return console.log(i, j, sen)
      } else if (result < 1000) {
        break
      }
    }
  }
  return console.log(-1, -1, -1)
}
otoshidama(require('fs').readFileSync(0, 'utf8'))


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define F first
#define S second

const int maxN = 1e5;
const int inf = 0x3f3f3f3f;
typedef long long ll;

int k;
int dp[maxN];

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  cin >> k;

  queue< pii > q;
  memset(dp, inf, sizeof dp);

  for (int d = 1; d < 10; ++d) {
    dp[d % k] = min(dp[d % k], d);
    q.push({d, d % k});
  }

  while (!q.empty()) {
    pii t = q.front(); q.pop();
    int du = t.S, min_sum = t.F;
    if (min_sum > dp[du]) continue;

    for (int d = 0; d < 10; ++d) {
      int new_du = (du * 10 + d) % k;

      if (dp[new_du] > dp[du] + d) {
        dp[new_du] = dp[du] + d;
        q.push( {dp[new_du], new_du});
      }
    }
  }

  cout << dp[0];
  return 0;
}


Measured memory_bytes: 5180
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define 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 llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007


/*nまでの素数を列挙して配列に保持*/
vector<int> Eratosthenes(int n,vector<int>& arr){

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

	for(int i = 2; i < sqrt(n); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) < n; j++){
				arr[i *(j + 2)] = 0;
			}
		}
    }
    return arr;
}


int main(){


    int n;
    int tmp = 10000000;
    vector<int> arr(tmp);


    arr = Eratosthenes(tmp,arr);/*50000までの素数を列挙*/    
   
    while(cin >> n,n){
        while(n-8>=2){

            if(arr[n] && arr[n-2] && arr[n-6] && arr[n-8]){
                cout << n << endl;
                break;
            }else{
                n--;
            }
        }
    }  
    
    
    return 0;
}




Measured memory_bytes: 80880
import sys
input=sys.stdin.readline
from collections import deque

class LCA:
    def __init__(self,v,Edges,root=0):
        self.v=v
        self.Edges=Edges
        self.maxLog=18
        self.Parent=[[-1]*v for _ in range(self.maxLog+1)]
        self.Depth=[0]*v
        self.__bfs(root)
        for i in range(self.maxLog):
            for j in range(v):
                if self.Parent[i][j]!=-1:
                    self.Parent[i+1][j]=self.Parent[i][self.Parent[i][j]]
    def __bfs(self,root):
        Visited=[False]*self.v
        Visited[root]=True
        q=deque([root])
        while q:
            fr=q.pop()
            for to in self.Edges[fr]:
                if Visited[to]:
                    continue
                self.Parent[0][to]=fr
                self.Depth[to]=self.Depth[fr]+1
                Visited[to]=True
                q.append(to)
    def lca(self,a,b):
        if self.Depth[a]>self.Depth[b]:
            a,b=b,a
        for i in range(self.maxLog):
            if (self.Depth[b]-self.Depth[a])&(1<<i):
                b=self.Parent[i][b]
        if a==b:
            return b
        for i in reversed(range(self.maxLog-1)):
            if self.Parent[i][a]!=self.Parent[i][b]:
                a=self.Parent[i][a]
                b=self.Parent[i][b]
        return self.Parent[0][a]
    def dist(self,a,b):
        lca=self.lca(a,b)
        return self.Depth[a]+self.Depth[b]-2*self.Depth[lca]

def main():
    n,u,v=map(int,input().split())
    u-=1; v-=1
    Edges=[[] for _ in range(n)]
    for _ in range(n-1):
        x,y=map(lambda i: int(i)-1,input().split())
        Edges[x].append(y)
        Edges[y].append(x)
    L=[]
    for i in range(n):
        if len(Edges[i])==1:
            L.append(i)
    lca=LCA(n,Edges,v)
    ans=0
    for l in L:
        if lca.dist(u,l)>=lca.dist(v,l):
            continue
        ans=max(ans,lca.dist(v,l)-1)
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 85844
#include <iostream>
#include <string>

using namespace std;

class DLinkList
{
private:
	struct ListNode{
		ListNode *prior, *next;
		int val;
		ListNode(int v) :prior(NULL), next(NULL), val(v){};
	};

private:
	ListNode *head;
	int len;

public:
	DLinkList()
	{
		head = new ListNode(-1);
		head->prior = head;
		head->next = head;

		len = 0;
	}

	ListNode *search(int v)
	{
		ListNode *p = head->next;
		while (p != head && p->val != v)
			p = p->next;
		return p;
	}

	void del_helper(ListNode *p)
	{
		if (p == head) return;
		p->prior->next = p->next;
		p->next->prior = p->prior;
		delete p;
		len--;
	}

	void del_first()
	{
		del_helper(head->next);
	}

	void del_last()
	{
		del_helper(head->prior);
	}

	void del_x(int v)
	{
		del_helper(search(v));
	}

	void insert(int val)
	{
		ListNode *node = new ListNode(val);

		node->next = head->next;
		head->next->prior = node;

		head->next = node;
		node->prior = head;

		len++;
	}

	void print()
	{
		ListNode *p = head->next;
		int count = 0;
		while (count++ < len - 1)
		{
			cout << p->val << " ";
			p = p->next;
		}
		if (len - 1 >= 0) cout << p->val << endl;
	}
};






int main()
{
	ios_base::sync_with_stdio(false);

	DLinkList l;
	string str;
	int val;
	cin >> str;
	while (cin >> str)
	{
		if (str == "insert")
		{
			cin >> val;
			l.insert(val);
		}
		else if (str == "delete")
		{
			cin >> val;
			l.del_x(val);
		}
		else if (str == "deleteFirst")
			l.del_first();
		else if (str == "deleteLast")
			l.del_last();
	}
	l.print();
}

Measured memory_bytes: 34376
#include<bits/stdc++.h>
using namespace std;
#define asll unsigned long long
#define ll long long //20190711
#define pii pair<int,int>
#define st first
#define nd second
#define jn <<" "<< 			//20190830
#define ml <<endl; 			//20190831->20190903
#define co cout<<           //20190903

asll am[200005];
asll jml=0;
asll M=1e9+7;				//20190518->20190821
int n;						//20190831

bool cmp(int x,int y){
	return x>y;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	srand(time(0));			//20190709
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>am[i];
	}
	
	sort(am,am+n,cmp);
	
	jml=0;
	int j=0;
	for(int i=0;i<n;i++){
		if(i!=0){
			jml+=am[(i)/2];
		}
		
	}
	cout<<jml<<endl;
	
	
}



Measured memory_bytes: 5208
import sys

def gcd(m, n):
    if n != 0:
        return gcd(n, m % n)
    else:
        return m

for line in sys.stdin.readlines():
    m, n = map(int, line.split())
    g = gcd(m, n)
    l = m * n // g    # LCM
    print(g, l)

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 200005;
int N;
int A[MAX_N];

signed main()
{
  cin >> N;
  REP(n,N) {
    cin >> A[n];
  }

  sort(A, A+N, greater<int>());

  queue<int> S;
  int ans = 0;
  REP(n,N) {
    if (n == 0) {
      S.push(A[n]);
    } else {
      ans += S.front(); S.pop();
      S.push(A[n]); S.push(A[n]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6464
import sys
def input(): return sys.stdin.readline().rstrip()
class UnionFind():
    def __init__(self, n):
        self.n=n
        self.parents=[-1]*n # 親(uf.find()で経路圧縮して根)の番号。根の場合は-(そのグループの要素数)
    def find(self,x):
        #グループの根を返す
        if self.parents[x]<0:return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        #要素x,yのグループを併合
        x,y=self.find(x),self.find(y)
        if x==y:return
        if self.parents[x]>self.parents[y]:#要素数の大きい方をxに
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x #要素数が大きい方に併合
    def size(self,x):
        #xが属するグループの要素数
        return -self.parents[self.find(x)]
    def same(self,x,y):
        #xとyが同じグループ？
        return self.find(x)==self.find(y)
    def members(self,x):
        #xと同じグループに属する要素のリスト
        root=self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]
    def roots(self):
        #全ての根の要素のリスト
        return [i for i, x in enumerate(self.parents) if x<0]
    def group_count(self):
        #グループの数
        return len(self.roots())
    def all_group_members(self):
        #各ルート要素のグループに含まれる要素のリストの辞書
        return {r: self.members(r) for r in self.roots()}
    def all_group_members_list(self):
        #各ルート要素のグループに含まれる要素のリストのリスト
        #[[0, 2], [1, 3, 4, 5]]
        return list(self.all_group_members().values())
    def __str__(self):
        #各ルート要素のグループに含まれる要素のリストをprint()
        return '\n'.join('{}: {}'.format(r,self.members(r)) for r in self.roots())

def main():
    n,m,k=map(int,input().split())
    AB=[tuple(map(int,input().split())) for i in range(m)]
    CD=[tuple(map(int,input().split())) for i in range(k)]
    un=UnionFind(n)
    friend=[[] for _ in range(n)]
    for a,b in AB:
        un.unite(a-1,b-1)
        friend[a-1].append(b-1)
        friend[b-1].append(a-1)
    blockc=[0]*n
    for c,d in CD:
        if un.same(c-1,d-1):
            blockc[c-1]+=1
            blockc[d-1]+=1
    for i in range(n):
        print(un.size(i)-1-blockc[i]-len(friend[i]))
 
if __name__=='__main__':
    main()

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end



int main(){
    int a,b,x; scanf("%d%d%d",&a,&b,&x);
    double s=x*1.0/a;
    if(s>=a*b*1.0/2){
        s=a*b-s; s/=a*1.0/2;
        printf("%.12f\n",atan(s*1.0/a)*180/M_PI);
    }
    else{
        s/=b*1.0/2;
        printf("%.12f\n",90-atan(s*1.0/b)*180/M_PI);
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define hello777 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#include <string>
#define pie 3.14159265358979323846
constexpr int MOD = 1e9+7;
const int MAX= 1e5+5;
using namespace std;


ll gcd(int a, int b)
{ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
// 
//ll lcm(int a, int b)  
// {  
//    return a/gcd(a, b) *b;  
// }
//  
//int prime(int n)
//{
//	rep(i,2,n+1)
//	{
//		if(n%i==0)return i;
//	}
//	
//vector<unordered_set<int> > prime_factors(MAX,unordered_set<int>());
//int primes[MAX];
//int prefix[MAX][6];
//void sieve(){
//    //primes i stores the largest prime factor of a number....
//    for(int i=2;i<MAX;++i){
//        if(primes[i]!=0){
//            continue;
//        }
//        primes[i] = i;
//        for(int j=2*i;j<MAX;j+=i){
//            primes[j] = i;
//        }
//    }
//    
//    for(int i=2;i<MAX;++i){
//        int current = i;
//        
//        while(current!=1){
//            prime_factors[i].insert(primes[current]);
//            current = current/primes[current];
//        }
//    }
//    
//    for(int i=1;i<MAX;++i){
//        for(int k=1;k<=5;++k){
//            prefix[i][k] = prefix[i-1][k] + (prime_factors[i].size()==k);
//        }
//    }
//    
//}
void solve() 
{
	int n,x,t;
	cin>>n>>x>>t;
	int ans=0,k=0;
	while(n>k)
	{
		k+=x;
		ans+=t;
	}
	cout<<ans<<endl;
}

int main()
{
	hello777;
	int q=1;
	
//    cin>>q;
    while(q--)
    {   
      solve();
    }
}


Measured memory_bytes: 3612
N=int(input())
v=list(map(int,input().split()))

v.sort()

s=0
for i in range(0,N):
    if i==0:
        s=s+v[0]
    else:
        s=s+v[i]*(2**(i-1))
print('{:.5g}'.format(s/(2**(N-1))))


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

namespace _20200412_ABC162A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadStringList(1);

            char[] cArray = input[0].ToCharArray();

            string output = "No";
            if (cArray.Any(a => a == '7'))
            {
                output = "Yes";
            }

            Console.WriteLine(output);
        }

        private static List<string> ReadStringList(int numberOfLines)
        {
            var stringList = new List<string>();

            for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++)
            {
                stringList.Add(Console.ReadLine().Trim());
            }

            return stringList;
        }

    }
}


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

using namespace std;
const int M = 6;

const int N = 1e3 + 10;
int solved()
{
    int n,m;
    int s[M],c[M];
    cin >> n >> m;
    for(int i = 0;i < m;i++)cin >> s[i] >> c[i];

    int ans = -1;
    
    for(int i = 1000;i >= 0;i --)
    {
        bool ok = true;
        string S = to_string(i);
        if(S.size() != n) ok = false;
        for(int j = 0;j < m;j++)
        {
            if((S[s[j] - 1] - '0') != c[j])
            {
                ok = false;
                break;
            }
        }
        if(ok)ans = i;
    }
    if(n > 1&& m == 1 && c[0] == 0 && s[0] == 1)ans = -1;
    cout << ans;
}

int main()
{
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#endif
    solved();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 6
 
typedef struct{
  double x;
  double y;
}XY;
 
void koch(int,XY,XY);
 
int main()
{
  int n,i;
 
  XY p1 = {0.0,0.0},p2 = {100.0,0.0};
  scanf("%d",&n);
  printf("%.8f %.8f\n",p1.x,p1.y);
  koch(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);
 
  return 0;
}
 
void koch(int n,XY p1,XY p2)
{
  XY s,t,u;
 
  if(n == 0) return;
 
  s.x = (2 * p1.x + 1 * p2.x) / 3;
  s.y = (2 * p1.y + 1 * p2.y) / 3;
  t.x = (1 * p1.x + 2 * p2.x) / 3;
  t.y = (1 * p1.y + 2 * p2.y) / 3;
  u.x = (t.x - s.x) * 1 / 2 - (t.y - s.y) * sqrt(3) / 2 + s.x;
  u.y = (t.x - s.x) * sqrt(3) / 2 + (t.y - s.y) * 1 / 2 + s.y;
 
  koch(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
 
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
 
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
 
  koch(n-1,t,p2);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long int arr[n],flag=1;
    for(int i=0;i<n;i++)
    arr[i]=0;
    long long temp=0,count=1;
    
    for(int i=0;i<n-1;i++)
    {
        cin>>temp;
        arr[temp]++;
    }
    for(int i=1;i<n;i++)
    {
        cout<<arr[i]<<"\n";
    }
    cout<<"0";

}

Measured memory_bytes: 5160
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  int K,T;
  cin >> K >> T;
  priority_queue<int> que;

  for(int i = 0;i < T;i++){
    int a;
    cin >> a;
    que.push(a);
  }

  int ans = que.top();
  que.pop();
  while(!que.empty()){
    int a = que.top();
    ans -= a;
    que.pop();
  }

  if(ans - 1 <= 0)cout << 0 << endl;
  else cout << ans - 1 << endl;


}


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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int A,B,C;
	cin >> A >> B >> C;
	if(A+B+C >= 22){
		cout << "bust\n";
		return 0;
	}

	cout << "win\n";

	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILL(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  int n,k,q;
  cin >> n >> k >> q;
  vector<int> v(n,0);
  vector<bool> a(n,true);
  REP(i,q){
    int j;cin >> j;
    j--;
    v[j]++;
  }
  REP(i,n){
    if(q - k - v[i] >= 0)a[i] = false;
  }
  REP(i,n){
    if(a[i])cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

struct node {
  int id;
  int weight;
  struct node *next;
};
struct node **list;
long int *pass, *dist;

void Insert(int, int, int);
int Bellman(int, int, int);

int main(void)
{
  int i, v, e, r, s, t, d;
  scanf("%d %d %d", &v, &e, &r);
  pass = (long int*)malloc(sizeof(long int) * v);
  dist = (long int*)malloc(sizeof(long int) * v);
  list = (struct node**)malloc(sizeof(struct node*) * v);
  for (i = 0; i < v; i++) list[i] = NULL;
  for (i = 0; i < e; i++) {
    scanf("%d %d %d", &s, &t, &d);
    Insert(s,t,d);
  }
  if (Bellman(r, v, e) == 1) {
    for (i = 0; i < v; i++) {
      if (dist[i] == INT_MAX) printf("INF\n");
      else printf("%ld\n", dist[i]);
      free(list[i]);
    }
  } else {
    printf("NEGATIVE CYCLE\n");
    for (i = 0; i < v; i++) {
      free(list[i]);
    }
  }
  free(pass);
  free(dist);
  free(list);
  return 0;
}

void Insert(int a, int b, int weight)
{
  struct node *p = (struct node*)malloc(sizeof(struct node));
  p->id = b;
  p->weight = weight;
  p->next = list[a];
  list[a] = p;
}

int Bellman(int p, int size, int esize)
{
  int i;
  for (i = 0; i < size; i++){
    dist[i] = INT_MAX;
    pass[i] = 0;
  }
  dist[p] = 0;
  while (1) {
    int flag = 0;
    for (i = 0; i < size; i++){
      struct node *n;
      if (dist[i] == INT_MAX) continue;
      for (n = list[i]; n != NULL; n = n->next) {
        int w = n->weight;
        if (w + dist[i] < dist[n->id]) {
          dist[n->id] = w + dist[i];
          pass[n->id]++;
          if (pass[n->id] >= esize) {
            return 0;
          }
          flag = 1;
        }
      }
    }
    if (!flag) break;
  }
  return 1;
}


Measured memory_bytes: 2056
#include"bits/stdc++.h"
using namespace std;

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a > k) {
		puts(":(");
	}
	else {
		puts("Yay!");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iomanip>
#define ll long long int
#define add push_back

using namespace std; 

int giveDif(string s1, string s2){
    int answ = 0;
    for(int i = 0; i < s1.length(); i++){
        if(s1[i] != s2[i])
            answ++;
    }
    return answ;
}

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

    int T;  
    //cin >> T;
    T = 1;
    while(T--){
        string s,t; cin >> s >> t;
        int answ = 1000;
        for(int i = 0; i <= s.length() - t.length(); i++){
            string str = s.substr(i, t.length());
            answ = min(answ, giveDif(t,str));
        }
        cout << answ << endl;
        
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0; i<n; i++) cin >> d[i];
  sort(d.begin(), d.end());
  int ans=1;
  for(int i=n-1; i>0; i--) {
  	if(d[i] > d[i-1]) ans++;
  }
  cout << ans << endl;
}

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





int main() {
  int n;
  cin>>n;
  
  int64_t x,y;
  x=2;
  y=1;
  
  for (int i=0;i<n;i++){
    int64_t z=x+y;
    x=y;
    y=z;
  }
  cout<<x<<endl;
  
  
}

  













Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

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

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 1000000007;


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

	ll a, b, k;
	cin >> a >> b >> k;
	
	if (a > k) {
		a -= k;
	}
	else {
		k -= a;
		a = 0;
		b = max((ll)0, b - k);
	}

	cout << a << " " << b << "\n";

	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();
		char[] C = sc.next().toCharArray();
		sc.close();

		int rCnt = 0;
		for (int i = 0; i < N; i++) {
			if (C[i] == 'R') {
				rCnt++;
			}
		}

		int cnt = 0;
		for (int i = 0; i < rCnt; i++) {
			if (C[i] == 'W') {
				cnt++;
			}
		}

		System.out.println(cnt);
	}
}


Measured memory_bytes: 41096
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint dp[1001001],sum[1001001];
lint mo=1000000007;
int main()
{
	int n;cin>>n;
	memset(dp,0,sizeof(dp));
	memset(sum,0,sizeof(sum));
	dp[0]=1;sum[0]=1;
	REP(i,1,n){
		dp[i]+=dp[i-1];dp[i]%=mo;
		if(i>=3) dp[i]+=sum[i-3];dp[i]%=mo;
		sum[i]=sum[i-1]+dp[i];sum[i]%=mo;
	}
	lint out=0;
	rep(i,n){
		if(i==n-1){
			out+=dp[i]*n;out%=mo;continue;
		}
		lint bo=n-i-3;if(bo<0) bo=0;
		lint t=bo*(n-1)+(n-1-bo)*n;t%=mo;
		//cout<<i<<' '<<dp[i]<<' '<<bo<<' '<<t<<endl;
		out+=t*dp[i];out%=mo;
	}
	cout<<out<<endl;
}


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

int main(void) {
  int N;
  cin >> N;
  long long ans = 0;
  vector<vector<long long>> cnt(11, vector<long long>(11, 0));
  for (int i = 1; i <= N; i++) {
    string s = to_string(i);
    int start = s[0] - '0';
    int end = s[s.length() - 1] - '0';
    cnt[start][end]++;
  }

  for (int i = 1; i <= 10; i++) {
    for (int j = 1; j <= 10; j++) {
      ans += cnt[i][j] * cnt[j][i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
w_c=0
e_c=0
ans=n
for i in s:
  if i == 'E':
    e_c+=1
for i in s:
  if i == 'E':
    e_c-=1
  k=w_c+e_c
  if ans > k:
    ans = k
  if i == 'W':
    w_c+=1
print(ans)

Measured memory_bytes: 3676
W,H,N=map(int,input().split())
x=[0]*N
y=[0]*N
a=[0]*N
H_min=0
H_max=H
W_min=0
W_max=W

for i in range(N):
  x[i],y[i],a[i] = map(int,input().split())
  if a[i]==1:
    W_min=max(x[i],W_min)
  elif a[i]==2:
    W_max=min(x[i],W_max)
  elif a[i]==3:
    H_min=max(y[i],H_min)
  else:
    H_max=min(y[i],H_max)

height = max(0,H_max-H_min)
width = max(0,W_max-W_min)
print(height*width)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int fact(int n){
  int ans=1;
  for(int i=0;i<n;i++)ans=ans*(i+1);
  return ans;
}

int main(){
    
  int n,a,b; cin>>n;
  
  vector<int> v(n);
  for(int i=0;i<n;i++) v[i] = i+1;
  
  int memo=0;
  vector<vector<int>> jis(fact(n), vector<int>(n));

  do {    
    for(int i=0;i<n;i++) jis[memo][i]=v[i];
    memo++;
  } while(next_permutation(v.begin(), v.end()));
  
  vector<int> p(n);
  for(int i=0;i<n;i++) cin>>p[i];

  for(int i=0;i<fact(n);i++) if(p==jis[i]) a=i;
     
  for(int i=0;i<n;i++) cin>>p[i];
  for(int i=0;i<fact(n);i++) if(p==jis[i]) b=i;

  cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 3072
N = int(input())
s = input()
t = input()

def ok(n):
  for i in range(N - n):
    if s[i+n] != t[i]: return False
  return True

for i in range(N):
  if ok(i):
    print(2 * i + N - i)
    break
else: print(2 * N)


Measured memory_bytes: 2940