akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int okashi[200];

int main(void)
{
    int n, k;
    cin >> n >> k;
    REP(i, k)
    {
        int d;
        cin >> d;
        REP(j, d)
        {
            int pos;
            cin >> pos;
            pos--;
            okashi[pos]++;
        }
    }
    int cnt = 0;
    REP(i, n)
    {
        if (okashi[i] == 0)
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3624
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	t = readline() |> chomp
	l = length(t)
	for i in 1:l
		print(t[i]=='?' ? 'D' : t[i])
	end
	println("")
end

main()

Measured memory_bytes: 155568
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>

using namespace std;


int main(){
    
    long int W, H, x, y;
    double S;
    
    cin >> W >> H >> x >> y;
    
    S = double(W*H);
    S = S/2;
    
    
    if (W%2 == 0 && H%2 == 0) {
        if (x == W/2 && y == H/2) {
            cout << setprecision(18) << S << " "  << 1 << endl;
        }else{
            cout << setprecision(18)<< S << " " << 0 << endl;
        }
    }else{
        cout << setprecision(18)<< S << " " << 0 << endl;
    }
    
    
    return 0;
    
}

Measured memory_bytes: 256
N=int(input())

ans=0

Total=0

for i in range(1,N+1):
  #print(i)
  Quo=N//i
  #print(Quo)
  Total+= i*(1+Quo)*Quo/2
  #print(i*(1+Quo)*Quo/2)
 
print(int(Total))

Measured memory_bytes: 73196
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
using namespace std;
#define MAX 100009
#define MOD 1000000007
#define EPS 0.0000000001
int main()
{
    long long int A,B,N;
    scanf("%lld %lld %lld",&A,&B,&N);
    long long int x=min(B-1,N);
    long long int ans=(A*x)/B-A*(x/B);
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3792
#include <stdio.h>

int all(int a[],int key,int now,int end,int sum)
{
	int x;
	if(now == end) return sum==key;
	else
	{
		x=all(a,key,now+1,end,sum+a[now])+all(a,key,now+1,end,sum);
	}
	return x>=1;
}

int main()
{
	int n,q,i;
	int a[21],b[201];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&b[i]);
		if( all(a,b[i],0,n,0) ) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}


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

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define repinv(i, st, n) for (int i = ((n)-1); i >= (st); --i)
#define MEM(a, b) memset(a, b, sizeof(a));
#ifdef LOCAL
#define debug(x) std::cerr << #x << ": " << x << endl
#else
#define debug(x) 860111
#endif
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileIO(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

//mt19937 mrand(random_device{}());
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
pii operator+(const pii&x, const pii&y) { return mp(x.X+y.X, x.Y+y.Y);}
pii operator-(const pii&x, const pii&y) { return mp(x.X-y.X, x.Y-y.Y);}
//INT_MAX, ULLONG_MAX, LLONG_MAX or numeric_limits<int>::min()

inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}

//------------------------------------------------------------------------//
int T;
const int maxn = 2e6+7;
int n;
int a[maxn];

//has 1 => can be 0 or 1
//contribution of parity to see is 0 or 1
//no 1 => can be 0 or 2, see a/2 is 0 or 1 to decide

//parity of C(n,k) can be found by lucas theorem
//my first thought is remember how much 2 factor u have with least significant bit function
//and use C(n, k) = C(n, k-1)*k/(n-k+1)

//such a beautiful problem
//learned : lucas theorem is useful, contribution thinking, stay orginized!

bool C(int n, int k){ return (n&k) == k;} //corollary of Lucas theorem
// =>　(ni, ki), ki = 1 => ni = 1, ki = 0 => ni = 0or1 => no 2

//check T
void solve()
{
	int cur = 0;
	string s;
	bool noone = 1;
	cin >> n; cin >> s; rep(i, 0, n) a[i] = s[i]-'0'-1, noone &= a[i]!=1;
	if(noone) rep(i, 0, n) a[i] >>= 1;
	int par = 0;
	rep(i, 0, n) par ^= C(n-1, i)*(a[i]&1);
	cout << par*(noone+1) << endl;
  return;
}


signed main()
{
  fastIO();
  T = 1;
  //cin >> T; //this
  while(T--) solve();
  return 0;
}


/*
15
132123321111222
*/


Measured memory_bytes: 5404
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
        int ans = a + b;
        if (ans > 23) {
          ans -= 24;
        }
    
		// 出力
		System.out.println(ans);
	}
}

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

int main(){
  int n;
  while(cin>>n,n){

    int ans=0;
    for(int i=0;i<=54;i++)
      for(int j=0;j<=96;j++){
	int a=i*i*i+(j*(j+1)*(j+2)/6);
	if(n-a>=0&&n-a<n-ans)ans=a;
	
      }
    cout <<ans<<endl;

  }

  return 0;
}

Measured memory_bytes: 2964
#include <stdio.h>

int main() {
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    if ((x >= r) && (x + r <= w) && (y >= r) && (y + r <= h)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2112
// https://atcoder.jp/contests/abc157/tasks/abc157_e

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define ITR(c,it)  for(auto it = c.begin(); it != c.end(); it++)
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 500000;
const int Q_MAX = 20000;

int N;
string S;
int Q;

set<int> idx[26];

void dump() {
#if DEBUG
  REP(j, 26) {
    if (idx[j].empty()) continue;
    cout << (char) ('a' + j) <<  ": ";
    ITR(idx[j], it) cout << *it << " ";
    cout << endl;
  }
#endif
}

int main() {
  cin >> N;
  cin >> S;
  cin >> Q;

  REP(i, S.size()) {
    idx[S[i] - 'a'].insert(i);
  }

  dump();

  REP(q, Q) {
    int typ;
    int i;
    char c;
    int l, r;
    cin >> typ;
#if DEBUG
    cout << "typ: " << typ << endl;
#endif
    if (typ == 1) {
      cin >> i >> c;
      i--;
      if (S[i] != c) {
        idx[S[i] - 'a'].erase(i);
        S[i] = c;
        idx[S[i] - 'a'].insert(i);
      }
      dump();
    }
    if (typ == 2) {
      cin >> l >> r;
      int k = 0;
      REP(j, 26) {
        if (idx[j].lower_bound(l - 1) != idx[j].lower_bound(r)) k++;
      }
      cout << k << endl;
    }
  }
}


Measured memory_bytes: 24196
#include <bits/stdc++.h>
//#define int long long
using namespace std;

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int N;
  cin >> N;
  VI V(N);
  VI C(N);
  REP(i, N) cin >> V.at(i);
  REP(i, N) cin >> C.at(i);

  int ans=0;

  REP(i, N) ans += max(V.at(i)-C.at(i), 0);

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[100004];
int b[100004];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n + 1) cin >> a[i];
  REP(i, n) cin >> b[i];

  ll ans = 0;
  REP(i, n) {
    int sb = min(a[i], b[i]);
    b[i] -= sb;
    a[i] -= sb;
    ans += sb;
    sb = min(a[i + 1], b[i]);
    b[i] -= sb;
    a[i + 1] -= sb;
    ans += sb;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
ans = 2000
H = int(input())
W = int(input())
N = int(input())
for nh in range(H+1):
    for nw in range(W+1):
        white = (H-nh)*(W-nw)
        if H*W-white>=N:
            ans = min(ans, nh+nw)
print(ans)

Measured memory_bytes: 3060
// 2019/06/30
// AtCoder Beginner Contest 092 - B

#include <bits/stdc++.h>
using namespace std;

int main() {
    // Input
    int n, d, x, a, wa, ans;
    cin >> n;
    cin >> d >> x;
    ans = 0;

    for(int i = 0; i < n; i++){
        cin >> a;
        wa = floor(d / a) + 1;
        if(d % a == 0){
            wa -= 1;
        }
        ans += wa;
    }

    ans += x;

    // Output
    cout << ans << endl;
}


Measured memory_bytes: 256
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let a = readInt()[0]
    print(a + a*a + a*a*a)
}
main()


Measured memory_bytes: 13604
/**
*    author:  yuya1234
*    created: 17.07.2020 13:51:35
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
long double eps = 1.0E-14;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>T lcm(T a,T b){return gcd(a,b)*(a/gcd(a,b))*(b/gcd(a,b));}

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

  ll x;
  cin>>x;

  ll ans=(x/11)*2;
  ll mod=x%11;

  if(((x/11)%2==0 && mod>6) || ((x/11)%2==1 && mod>5))ans+=2;
  else if(mod>0)ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3620
#include <string>
#include <cstring>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;

int main(){
    int x, y, z;
    scanf("%d%d%d",&x, &y, &z);
    printf("%d %d %d\n",z, x, y);
    return 0;
}

Measured memory_bytes: 3808
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    x = input()
    k = int(x,2)
    c = x.count('1')
    kp = k%(c+1)
    if c > 1:
        kn = k%(c-1)
    
    for i in range(n):
        cnt = 1
        if x[i] == '1':
            if c == 1:
                print(0)
                continue
            mod = c-1
            tmp = (kn - pow(2,n-i-1,mod))%mod
            while 1:
                if tmp == 0:
                    break
                tmp = tmp%format(tmp, 'b').count('1')
                cnt+=1
        else:
            mod = c+1
            tmp = (kp + pow(2,n-i-1,mod))%mod
            while 1:
                if tmp == 0:
                    break
                tmp = tmp%format(tmp, 'b').count('1')
                cnt+=1
        print(cnt)


if __name__ == '__main__':
    main()

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

int main()
{
    int sum, result;
    int n, m,  i, a;
    vector <int> v;

    cin >> n >> m;

    sum = 0;
    for (i = 0; i < m; i++)
    {
        cin >> a;
        sum = sum + a;
    }

    result = n - sum;

    if (result < 0)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << result << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
import sys

input = sys.stdin.readline


def g(n):
    if n == -1:
        return 0
    if n == 0:
        return 0
    if n == 1:
        return 1

    b = bin(n)[2:]
    res = 0
    # xxxx10: 01, 10
    if b[-2:] == "10":
        res += 3
    # xxxx11: 01, 10, 11
    elif b[-2:] == "11":
        pass
    # xxxx00 or xxxx01
    else:
        res += int(b[-1])

    for i in range(len(b) - 2):
        if b[i] == "0":
            continue
        if b[-1] == "0":
            res += 1 << (len(b) - 1 - i)
    return res


def main():
    A, B = map(int, input().split())

    if A == B:
        ans = A
    else:
        ans = g(A - 1) ^ g(B)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9156
using System;
using System.Collections.Generic;

namespace MSTrust2019D
{
    class Program
    {
        private static int Solve(int n, string s)
        {
            //var set = new HashSet<string>();
            //var sndset = new HashSet<string>();
            var fst = new bool[10];
            var snd = new bool[10, 10];
            var count = new bool[10, 10, 10];

            foreach (var c in s.ToCharArray())
            {
                int v = c - '0';
                for (int i = 0; i < 10; ++i)
                {
                    for (int j = 0; j < 10; ++j)
                    {
                        if (snd[i, j])
                        {
                            //set.Add(i.ToString() + j.ToString() + v.ToString());
                            count[i, j, v] = true;
                        }
                    }
                }

                //foreach (var t in sndset)
                //{
                //    set.Add(t + v.ToString());
                //}

                for (int i = 0; i < 10; ++i)
                {
                    if (fst[i])
                    {
                        snd[i, v] = true;
                        //sndset.Add(i.ToString() + v.ToString());
                    }
                }

                fst[v] = true;

            }
            //return set.Count;
            int ans = 0;
            foreach (var x in count) ans += x ? 1 : 0;
            return ans;
        }

        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            var n = Convert.ToInt32(line);
            string s = Console.ReadLine();
            Console.WriteLine(Solve(n, s));
        }
    }
}


Measured memory_bytes: 13268
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		sc.close();
		if(k==1) System.out.println(0);
		else System.out.println(n-k);
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll d,n; cin>>d>>n;
    map<ll,ll> mp;
    rep(i,n){
        if(d==0){
            if(n!=100) mp[i]=i+1;
            else mp[i]=101;
        }else if(d==1){
            if(n!=100) mp[i]=100*(i+1);
            else mp[i]=100*101;
        }else{
            if(n!=100) mp[i]=10000*(i+1);
            else mp[i]=10000*101;
        }
    }
    cout<<mp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

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

    int A[N+1];
    int B[N+1];
    int C[N];

    for (int i = 1; i <= N; ++i) {
        std::cin >> A[i];
    }

    for (int i = 1; i <= N; ++i) {
        std::cin >> B[i];
    }

    for (int i = 1; i <= N-1; ++i) {
        std::cin >> C[i];
    }

    int sum = 0, prev = 0;
    for (int i = 1; i <= N; ++i) {
        sum += B[A[i]];
        if (A[i] == (prev + 1) && i != 1) {
            sum += C[prev];
        }

        prev = A[i];
    }

    std::cout << sum << std::endl;

    return 0;
}


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

#define double long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }
                                   
 
  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=2e18+18;
  const int N=2e6+25;
  const int M=2e4;
  
  vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

 void fft()           
 { 
    string s; cin>>s;
    int n;
    bool f=true;
    
    n=Z(s);
    for(int i=0;i<n/2;++i){
        if(s[i]!=s[n-i-1]) {
          f=false; break;
        }
    }
    
    string t,k; rep(i,0,(n-1)/2) t+=s[i];
    
    rep(i,(n+3)/2-1,n) k+=s[i];

    n=Z(t);
    for(int i=0;i<n/2;++i){
        if(t[i]!=t[n-i-1]) {
          f=false; break;
        }
    }

    n=Z(k);
    for(int i=0;i<n/2;++i){
        if(k[i]!=k[n-i-1]) {
          f=false; break;
        }
    }

    if(f) cout<<"Yes";
    else cout<<"No";


 }     

signed main()
{ 
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  
   
   int t=1;                         
//   cin>>t;

  rep(i,1,t+1)
  { // cout<<"Case #"<<i<<": ";
   fft();
   if(i<t)
   cout<<nl;
  }
  
 
 return 0; 
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<unordered_set>

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

  unordered_set<string> ST;
  int N;
  cin >> N;

  for(int i = 0; i < N; i++) {
    string BUFF, c;
    cin >> BUFF >> c;
    if(BUFF == "insert") {
      ST.insert(c);
    } else {
      if (ST.find(c) != ST.end()) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    }
  }
}


Measured memory_bytes: 28908
#include<iostream>
#include<string>
const int MAX_NUM_OF_STR = 1010;
using namespace std;

int main(){
	int cnt = -1, len = 0, tango = 0;
	string str[MAX_NUM_OF_STR], max, maxlen;
	
	while(cin >>str[tango]){
		int tmpcnt = 0;
		for(int i = 0; i <= tango; i++){
			if(str[i] == str[tango]){
				tmpcnt++;
			}
		}
		if(cnt < tmpcnt){
			max = str[tango];
			cnt = tmpcnt;
		}
		
		if(str[tango].size() > (unsigned)len){
			len = str[tango].size();
			maxlen = str[tango];
		}
		tango++;
	}
	cout <<max <<" " <<maxlen <<endl;
	return 0;
}

Measured memory_bytes: 0
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInt >>= putStrLn . which "ABC" "ARC" . ( < 1200 )


Measured memory_bytes: 508
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nm = IO.RSLong;

            if (nm[0] == 1 && nm[1] == 1)
            {
                WriteLine(1);
                return;
            }
            if (nm[0] == 1)
            {
                WriteLine(nm[1] - 2);
                return;
            }
            if (nm[1] == 1)
            {
                WriteLine(nm[0] - 2);
                return;
            }
            //2*2以上では外周に隣接するマスは4or6回ひっくり返すので必ず表
            WriteLine((nm[0] - 2) * (nm[1] - 2));
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define NewNode (ListNode *)malloc(sizeof(ListNode))
#define Mem(a,b) memset(a,b,sizeof(a))
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 1e9 + 7;
const double II = 3.1415926535;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int n,k;
    cin >> n >> k;
    if(k > n)
        cout << 1 << endl;
    else
    {
        ll sum = 0,Min = 0,Max = 0,num1 = k,num2 = n-k;
        for(int j = 0,a = k;a > 0;a--,j++)
            Min += j;
        for(int j = n,a = k;a > 0;a--,j--)
            Max += j;
        for(int i = k;i <= n+1;i++)
        {
            sum += (Max-Min+1);
            sum %= mod;
            Min += num1;
            Max += num2;
            num1++;num2--;
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int n, a[110];

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", a+i);
	vector <int> ans;
	int c[110] = {};
	rep(tt, n) {
		int f = 0;
		for(int i=n;i;i--) if(c[i] == 0) {
			int cnt = 0;
			for(int j=1;j<i;j++) cnt += c[j];
			if(cnt == a[i] - 1) {
				ans.pb(a[i]); c[i] = 1; f = 1; break;
			}
		}
		if(f == 0) {
			puts("-1");
			return 0;
		}
		
	}
	for(int e : ans) printf("%d\n", e);
	return 0;
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    d,x = f()
    ans = 0
    for i in range(n):
        a = f()[0]
        ans += (d+a-1)//a
    
    print(ans + x)


solve()


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

int main(){

	string deck;
	string dummy;

	int stimes, h;

	while(cin >> deck && deck != "-"){
		cin >> stimes;
		for(int i=0; i<stimes; ++i){
			cin >> h;
			dummy = deck.substr(0,h);
			deck.erase(deck.begin(), deck.begin()+h);
			deck += dummy;
		}

		cout << deck << endl;
	}

	return 0;
}



Measured memory_bytes: 3176
// https://atcoder.jp/contests/aising2019/tasks/aising2019_c
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

class UnionFind {
private:
  vector<ll> parent;
  vector<ll> rank;

public:
  UnionFind(ll size) : parent(size), rank(size, 0) {
    for (ll i = 0; i < size; i++) {
      parent[i] = i;
    }
  }

  ll find(ll x) {
    if (parent[x] == x) {
      return x;
    } else {
      return parent[x] = find(parent[x]);
    }
  }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rank[x] < rank[y]) {
      parent[x] = y;
    } else {
      parent[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(ll x, ll y) {
    return find(x) == find(y);
  }
};

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

  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  vi dx = {0, 0, 1, -1};
  vi dy = {1, -1, 0, 0};
  UnionFind uf(h*w);
  rep(i, h) rep(j, w) rep(k, 4) {
    int ni = i+dx[k];
    int nj = j+dy[k];
    if (0 <= ni && ni < h && 0 <= nj && nj < w && s[i][j] != s[ni][nj]) {
      uf.unite(i*w + j, ni*w + nj);
    }
  }

  vector<ll> black(h*w, 0), white(h*w, 0);
  rep(i, h) rep(j, w) {
    if (s[i][j] == '#') black[uf.find(i*w + j)]++;
    else white[uf.find(i*w + j)]++;
  }

  ll ans = 0;
  rep(i, h*w) {
    ans += black[i] * white[i];
  }
  cout << ans << endl;
}


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



int main(int argc, const char * argv[]) {
    
    int a;
    int b;
    
    cin >> a >> b;
    
    
    if (a<b) {
        
        cout << "a < b" <<endl;
    }else if(a > b){
        
        
        cout << "a > b" <<endl;
    }else{
        
        cout << "a == b" <<endl;
    
    }

   return 0;
}


Measured memory_bytes: 3084
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n];
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i = 0;i<n; i++) {
            t[i] = Math.abs(sc.nextInt());
            a[i] = Math.abs(sc.nextInt());
            if(i>0) a[i] = Math.abs(a[i] - a[i-1]);
            b[i] = sc.nextInt();
            if(i>0) b[i] = Math.abs(b[i] - b[i-1]);
            if(i>0) t[i] = Math.abs(t[i] - t[i-1]);
        }
        for(int i = 0; i<n; i++) {
            //System.out.println(i);
            if(a[i]+b[i] > t[i]) {
                System.out.println("No");
                return;
            }
            if((a[i]+b[i])%2==t[i]%2) continue;
            else {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
        return;

    }
}

Measured memory_bytes: 92052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


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


Measured memory_bytes: 3084
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int C[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N, M;
  while (cin >> N >> M) {
    vector<int> A(M);
    for (int i = 0; i < M; i++) cin >> A[i];
    sort(A.rbegin(), A.rend());
    vector<int> dp(N + 1, -1);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
      if (dp[i] < 0) continue;
      for (int x : A) {
        if (i + C[x] > N) continue;
        chmax(dp[i + C[x]], dp[i] + 1);
      }
    }
    string res;
    for (int rem = N; rem > 0;) {
      for (int x : A) {
        if (rem - C[x] < 0) continue;
        if (dp[rem] - 1 == dp[rem - C[x]]) {
          res += char('0' + x);
          rem -= C[x];
          break;
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, M;
int L[303030], R[303030];
int ans[101010];
int ans2[101010];
vector<int> app[101010];

struct segtree
{
	static const int DEPTH = 18;
	static const int N = 1 << DEPTH;

	int data[2 * N];

	void init()
	{
		for (int i = 0; i < 2 * N; ++i) data[i] = 0;
	}
	void incl(int p, int v)
	{
		p += N;
		while (p) {
			data[p] += v;
			p >>= 1;
		}
	}
	int query(int L, int R)
	{
		L += N;
		R += N;
		int ans = 0;
		while (L < R) {
			if (L & 1) ans += data[L++];
			if (R & 1) ans += data[--R];
			L >>= 1; R >>= 1;
		}
		return ans;
	}
};
segtree seg;
vector<int> divs[101010];

int main()
{
	seg.init();

	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; ++i) {
		scanf("%d%d", L + i, R + i);
	//	--L[i];
		ans2[R[i] - L[i] + 1] += 1;
		app[L[i]].push_back(R[i] - L[i] + 2);
		app[R[i] + 1].push_back(-(R[i] - L[i] + 2));
	}
	for (int i = 1; i <= M; ++i) {
		for (int j = i; j <= M; j += i) divs[j].push_back(i);
	}
	for (int i = 1; i <= M; ++i) {
		for (int a : app[i]) {
			if (a >= 1) {
				seg.incl(a, 1);
			} else {
				seg.incl(-a, -1);
			}
		}
		for (int d : divs[i]) {
			ans[d] += seg.query(1, d + 1);
		}
	}
	for (int i = M - 1; i >= 1; --i) ans2[i] += ans2[i + 1];

	for (int i = 1; i <= M; ++i) printf("%d\n", ans[i] + ans2[i]);
	return 0;
}


Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector <ll> v
#define vii vector<pair<ll,ll>>v
#define pb push_back
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define while_ int t;cin>>t;while(t--)
#define vmax 100000
using namespace std;
 
 
 
ll maxP(ll W, ll n, ll w[], ll v[])
{
 
  ll dp[n+1][vmax+1];
  for(int i=0;i<=vmax;i++)
  dp[1][i]=1000000009;
  dp[1][0]=0;
  dp[1][v[0]]=w[0];
 
  for(ll an=2;an<=n;an++)
  {
      for(ll av=0;av<=vmax;av++)
      {
          if(v[an-1]>av) dp[an][av]=dp[an-1][av];
          else
          dp[an][av]=min(dp[an-1][av],w[an-1]+dp[an-1][av-v[an-1]]);
      }
  }
  ll ans=0;
  f(i,0,vmax+1)
  if(dp[n][i]<=W)
   ans=i;
  return ans;
 
}
 
int main() {
    fastio
   
    ll n,W;
    cin>>n>>W;
    ll w[n],v[n];
    f(i,0,n) cin>>w[i]>>v[i];
    cout<<maxP(W,n,w,v);
   
}

Measured memory_bytes: 78336
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  8 20:59:57 2020

@author: naoki
"""
import sys
string = str(input())

if ("hhii") in string:
    print("No")
    sys.exit()

while "hi" in string:
    place = string.index("hi")
    string = list(string)
    del string[place]
    del string[place]
    string = ''.join(str(n) for n in string)

if len(string) == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include <stdio.h>

int N;
int C[500];
int S[500];
int F[500];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N-1; i++) scanf("%d %d %d", &C[i], &S[i], &F[i]);
	for (int i = 0; i < N-1; i++)
	{
		int cur = S[i] + C[i];
		for (int j = i + 1; j < N-1; j++)
		{
			if (cur >= S[j])
			{
				if((cur-S[j])%F[j] == 0) cur = S[j] + F[j] * ((cur-S[j])/F[j]) + C[j];
				else cur = S[j] + F[j] * ((cur - S[j]) / F[j] + 1) + C[j];
			}
			else cur = S[j] + C[j];
		}
		printf("%d\n", cur);
	}
	printf("0\n");
	return 0;
}

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

#define INF (1<<30)

int dp[1000000];

int main(){
	int n;	cin>>n;

	for(int i=0;i<1000000;i++)dp[i]=INF;
	dp[0]=0;

	for(int i=0;i<n;i++){
		dp[i+1]=min(dp[i+1], dp[i]+1);

		for(int j=1;j<=7;j++){
			int x=pow(6,j);
			dp[i+x]=min(dp[i+x], dp[i]+1);

			x=pow(9,j-1);
			dp[i+x]=min(dp[i+x], dp[i]+1);
		}
	}

	cout<<dp[n]<<endl;



	return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  string s = readString();
  if (s == "Sunny")
    std::cout << "Cloudy" << std::endl;
  else if (s == "Cloudy")
    std::cout << "Rainy" << std::endl;
  else
    std::cout << "Sunny" << std::endl;
}


Measured memory_bytes: 2304
#include<stdio.h>
#include<string.h>
int main()
{int n,i,j,w,h;char str[105][105];

scanf("%d%d",&h,&w);
getchar();
for(i=0;i<h+2;i++)
for(j=0;j<w+2;j++)
str[i][j]='#';
for(i=1;i<h+1;i++){
for(j=1;j<w+1;j++)
scanf("%c",&str[i][j]);
getchar();}
for(i=0;i<h+2;i++){
for(j=0;j<w+2;j++)
printf("%c",str[i][j]);
printf("\n");}
return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define REP(i,n,N) for(int i=(n); i<(N); i++)
#define RREP(i,n,N) for(ll i=(N-1); i>=n; i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
const int inf=1e9;

int dp[1010][1010];
int N;
int C[1010], W[1010];
int sum[1010];
int main() {
    cin>>N;
    REP(i,0,N){
        cin>>C[i]>>W[i];
    }
    REP(i,0,N) REP(j,i,N) dp[i][j] = j-i+1;
    REP(i,0,N) sum[i+1] = sum[i] + W[i];
    REP(k,1,N){
        REP(L,0,N-k){
            int R = L + k;
            if(dp[L+1][R]==1 && sum[R+1]-sum[L+1] <= C[L]){
                dp[L][R] = min(dp[L][R], dp[L+1][R]);
            }
            if(dp[L][R-1]==1 && sum[R]-sum[L] <= C[R]){
                dp[L][R] = min(dp[L][R], dp[L][R-1]);
            }
            REP(i,L,R) {
                dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R]);
            }
        }
    }
    p(dp[0][N-1]);

    return 0;
}


Measured memory_bytes: 7064
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<array>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

static const int N=100;
static const int white=0;
static const int gray=1;
static const int black=2;
int color[N],nt[N];
int mp[N][N];
int n,d[N],f[N],tt;
int next(int r){
    
    for(int i=nt[r];i<n;i++){
        nt[r]=i+1;
        if(mp[r][i])return i;
        
    }
    return -1;
    
}

void dfs_visit(int r){
    rep(i,n){nt[i]=0;}
    stack<int> s;
    s.push(r);
    d[r]=++tt;
    color[r]=gray;
    
    while(!s.empty()){
        int u=s.top();
        int v=next(u);
        if(v!=-1){
            if(color[v]==white){
            d[v]=++tt;
            color[v]=gray;
            s.push(v);
            }
        }else{
            f[u]=++tt;
            color[u]=black;
            s.pop();
        }
    }
}



void dfs(){
    tt=0;
    rep(i,n){
        color[i]=white;nt[i]=0;
    }
    rep(i,n){
        if(color[i]==white){
            dfs_visit(i);
            
        }
    }
    rep(i,n){
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
}


int main(){
    cin>>n;
    rep(i,N){
        rep(j,N){
            mp[i][j]=0;
        }
    }
    rep(i,n){
        int a,b;
        cin>>a>>b;
        a--;
        rep(i,b){
            int c;
            cin>>c;
            c--;
            mp[a][c]=1;
        }
    }
    dfs();
    return 0;
}



Measured memory_bytes: 3140
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
        ll a,b;
        cin>>a>>b;
        ((a-(b<<1)) < 0)?cout<<"0":cout<<(a-(b<<1));
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

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

using namespace std;

int main(void) {
    string s; cin >>s;
    string ance;
    int n = 3;

    for(int tmp = 0; tmp < (1 << n); ++tmp) {
        int sum = s[0] - '0' ;
        ance = s[0];
        for(int i = 0; i < n; ++i) {
            if(tmp & (1 << i)) {
                int sint = s[i+1] - '0';
                sum += sint;
                ance += "+";
                ance += s[i+1];
            }else {
                int sint = s[i+1] - '0';
                sum -= sint;
                ance += "-";
                ance += s[i+1];
            }
        }
        if(sum==7) {
            ance += "=7";
            cout << ance << endl;
            goto rikacy;
        }
    }
    rikacy:
    return 0;
}



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

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

bool findprime(ll n){
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			if(st.find(i)!=st.end()){
				return false;
			}
			while(n%i==0){
				n/=i;
			}
			st.insert(i);
		}
	}
	if(n>1){
		if(st.find(n)!=st.end()){
			return false;
		}
		st.insert(n);
	}
	return true;
}

int main(){
 ll n;
 cin>>n;
 vector<ll> v(n);
 for(ll i=0;i<n;i++) cin>>v[i];
 int state=0;
 for(ll i=0;i<n;i++){
 	ll p=v[i];
 	if(!findprime(p)){
		state++;break;
	}
 }
 if(state==0){
 	cout<<"pairwise coprime"<<endl;
 }
 else{
 	ll g=gcd(v[0],v[1]);
 	for(ll i=2;i<n;i++)
 		g=gcd(g,v[i]);
 	if(g==1){
 		cout<<"setwise coprime"<<endl;	
	}	
	else{
		cout<<"not coprime"<<endl;
	}
 }
 
 return 0;
}



Measured memory_bytes: 11128
def get_new_lucas(l_i_1, l_i_2):
    """
    get a new Lucas number L_i

    l_i_1: L_(i-1),
    l_i_2: L_(i-2)
    """
    return l_i_1 + l_i_2


def main():
    n = int(input())
    tmp_l_i_1 = 1
    tmp_l_i_2 = 2
    for i in range(n):
        if i == 0:
            new_lucas_num = 1
        if i >= 1:
            new_lucas_num = get_new_lucas(tmp_l_i_1, tmp_l_i_2)
            tmp_l_i_2 = tmp_l_i_1
            tmp_l_i_1 = new_lucas_num
        
    print(new_lucas_num)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
N,C=map(int,input().split())
M=10**5+2
dp=[[0]*(M) for i in range(30)]
for i in range(N):
    s,t,c = map(int,input().split())
    c=c-1
    dp[c][s-1]+=1
    dp[c][t]-=1
for c in range(30):
    for i in range(1,M):
        dp[c][i]+=dp[c][i-1]
ans=0
for i in range(M):
    t=0
    for c in range(30):
        if dp[c][i]>0:
            t+=1
    ans=max(t,ans)
#print(dp[0][:15])
#print(dp[1][:15])
print(ans)

Measured memory_bytes: 70872
#define _CRT_SECURE_NO_WARNINGS
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cctype>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
const ll mod = 1000000007;
const double eps = 1e-6;
const double PI = acos(-1);
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
const int iadd[] = {0, 1, 0, -1}, jadd[] = {1, 0, -1, 0};
const int inf = 0x3f3f3f3f;
const int maxn = 1e3 + 5;
int x, t;

void solve(){
	int res = x - t;
	if(res < 0) res = 0;
	printf("%d\n", res);
}
int main(){
	scanf("%d %d", &x, &t);
	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(b*2>=a){
    cout<<0<<endl;
  }
  else{
    cout<<a-b*2<<endl;
  }
  
  return 0;
}

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

int main()
{
    long x;
    cin >> x;
    long ans = 1;
    for (long b = 2; b <= x; b++) {
        for (long p = 2; pow(b, p) <= x; p++) {
            ans = max(ans, (long)pow(b, p));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384