akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;

    vector<string> X;

    rep(i, 1 << 4){
        string tp = "";
        if(i & (1 << 0)) tp += "A";
        tp += "KIH";
        if(i & (1 << 1)) tp += "A";
        tp += "B";
        if(i & (1 << 2)) tp += "A";
        tp += "R";
        if(i & (1 << 3)) tp += "A";

        X.pb(tp);
    }

    for(auto x : X) if(x == S) drop("YES");
    drop("NO");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <queue>

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

using namespace std;

int DX[4] = {-1, 0, 0, 1};
int DY[4] = {0, -1, 1, 0};

string a[1000];
queue<pair<int, int>> q;
int d[1000][1000];

bool isfree(int m, int n, int x, int y) {
  return (x >= 0 && x < m && y >= 0 && y < n && a[x][y] == '.');
}

bool isexit(int m, int n, int x, int y) {
  return (x == 0 || y == 0 || x == m-1 || y == n-1);
}

int minstep(int m, int n, int k, int x, int y) {
  if (isexit(m, n, x, y)) return 0;
  int ans = (x - 1) / k + 1;
  ans = min(ans, (y - 1) / k + 1);
  ans = min(ans, (m - 1 - x - 1) / k + 1);
  ans = min(ans, (n - 1 - y - 1) / k + 1);
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  int m, n, k;
  while (cin >> m >> n >> k) {
    int sx, sy, x, y, newx, newy;
    while (!q.empty()) q.pop();
    FOR(i, 0, m-1) cin >> a[i];
    FOR(i, 0, m-1) FOR(j, 0, n-1) if (a[i][j] == 'S') {
      sx = i; sy = j;
      d[i][j] = 0;
      q.push(make_pair(i, j));
    } else d[i][j] = -1;

    while (!q.empty()) {
      pair<int, int> e = q.front(); q.pop();
      x = e.first; y = e.second;
      if (d[x][y] == k) continue;
      FOR(dir, 0, 3) {
        newx = x + DX[dir]; newy = y + DY[dir];
        if (isfree(m, n, newx, newy) && d[newx][newy] == -1) {
          d[newx][newy] = d[x][y] + 1;
          q.push(make_pair(newx, newy));
        }
      }
    }

    int res = m * n;
    FOR(i, 0, m-1) FOR(j, 0, n-1) if (d[i][j] != -1) {
      res = min(res, 1 + minstep(m, n, k, i, j));
    }
    cout << res << endl;
  }
  return 0;
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int IINF = 2002002002;
constexpr ll LINF = 9009009009009009009LL;

//===




int main()
{
	int N; 
	cin >> N; 
	cout << N * N * N << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar1[2000000];
int main()
{
    ll test,n,k,i;
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        cin>>ar1[i];
    }
    sort(ar1+1,ar1+n+1);
    ll ans=9999999999999;
    for(i=k;i<=n;i++)
    {
        ans=min(ans,ar1[i]-ar1[i-k+1]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
#define int long long int
#define double long double
using namespace std;
#define INT_MAX 1000000005
#define INF 1000000005
const int MAX_N = 1 << 17;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

signed main()
{
int n;
std::cin >> n;
std::vector<int> p;
std::vector<int> a;
std::vector<int> b;
for(int i = 0; i < n; i++){
    int temp;
    std::cin >> temp;
    temp--;
    p.push_back(temp);
    a.push_back(i * 20000 + 1);
    b.push_back(i * 20000 + 1);
}
std::sort(b.begin(),b.end(),std::greater<int>());
int sum = 0;
for(int i = 0; i < n; i++){
    b[p[i]] += i;
}
for(int i = 0; i < n - 1; i++){
    std::cout << a[i] << " ";
}
std::cout << a[n - 1] << std::endl;
for(int i = 0; i < n - 1; i++){
    std::cout << b[i] << " ";
}
std::cout << b[n - 1] << std::endl;


return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    long long x, n;
    cin >> x >> n;
    if(n == 0){
        cout << x << endl;
        return 0;
    }

    vector<long long> p(n);

    for(long long i = 0; i < n; i++){
        cin >> p[i];
    }

    sort(p.begin(), p.end());

    long long distance = 1e9;
    long long minv = 1e9;

    for(long long i = 0; i <= 200; i++){
        if(binary_search(p.begin(), p.end(), i) == false){
            distance = min(distance, abs(x-i));
        }
    }

    for(long long i = 0; i <= 200; i++){
        if(binary_search(p.begin(), p.end(), i) == false){
            if(distance == abs(x-i)){
                minv = min(minv, i);
            }
        }
    }

    cout << minv << endl;

    return 0;

    
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
#define fi first
#define se second
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    Int r;
    cin >> r;
    dump(r * r);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(input().split())
A_ = A.copy()
for i in range(N):
    for j in range(N - 1, i, -1):
        if A_[j][1] < A_[j - 1][1]:
            A_[j], A_[j - 1] = A_[j - 1], A_[j]
s = ''
for a in A_:
    s += a + ' '
print(s.rstrip())
print('Stable')


for i in range(N):
    minj = i
    for j in range(i, N):
        if A[j][1] < A[minj][1]:
            minj = j
    A[i], A[minj] = A[minj], A[i]

s_ = ''
for a in A:
    s_ += a + ' '
print(s_.rstrip())
if A == A_:
    print('Stable')
else:
    print('Not stable')



Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
#define llt long long int
char c[4]={'E','W','N','S'};
int gcd(int a ,int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
int main(){
	llt k,ans=0,a,b,c;
	cin>>a>>b>>c>>k;
	if(a>=k) ans=k;
	else if(a+b>=k) ans=a;
	else ans=a-(k-a-b);
	cout<<ans<<endl;

}


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



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    // LL t; cin>>t;
    // while(t--){
        
    // }
    LL n;cin>>n;
    LL sum=0;
    for(int i=1;i<n;i++){
        sum+=(n-1)/i;
    }
    cout<<sum;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=0;//答えを入れる変数
    for(int i=a;i<=b;i++){
        if(c%i==0)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3092
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		while(true){
			List<Integer> pourTimeList = new ArrayList<Integer>();
			int count = stdIn.nextInt();
			if(count == 0){
				break;
			}
			for(int i = 0;i < count; i++){
				pourTimeList.add(stdIn.nextInt());
			}
			Collections.sort(pourTimeList);
			long waitTime = 0;
			for(int i = 0;i < pourTimeList.size() - 1; i++){
				waitTime += pourTimeList.get(i) * (pourTimeList.size() - i - 1);
			}
			System.out.println(waitTime);
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = 1000000007;
ll mpow(ll a,ll b){ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
/*template*/

int main()
{
  ll x;cin>>x;
  ll now=100;
  ll ans=0;
  while(now<x){
    now=now*1.01;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX



 
void solve()
{
    int x = 100;
    int r;
    cin >> r;
    int tot = 0;
    while(x<r)
    {
        tot++;
        x += x/100;
    }

    cout << tot << endl;
}


signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vvi a,b;

int main(){
	cin>>n;
	a=b=vvi(n);
	for(int i=0;i<n;i++){
		int m;
		cin>>m;
		a[i]=b[i]=vi(m);
		for(int j=0;j<m;j++){
			cin>>a[i][j]>>b[i][j];
			a[i][j]--;
		}
	}
	int res=0;
	for(int i=0;i<1<<n;i++){
		int t=0,B=1;
		for(int j=0;j<n;j++) if(i&1<<j){
			t++;
			for(int k=0;k<a[j].size();k++){
				if((i&1<<a[j][k])&&b[j][k]==0) B=0;
				if(!(i&1<<a[j][k])&&b[j][k]==1) B=0;
			}
		}
		res=max(res,t*B);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = "";
        for (int i = 0; i < n; i++) {
            str += sc.next();
        }
        
        String ans = "Three";
        if (str.contains("G") && str.contains("W") && str.contains("Y") && str.contains("P")) {
            ans = "Four";
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 39476
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int h, w, a, b;

signed main() {
	cin >> h >> w >> a >> b;
	cout << h*w - a*w - b*h + a*b << endl;
}

Measured memory_bytes: 256
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-15 11:17:28
**/
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int D, N;
    cin >> D >> N;
    vector<int> x(102,0);
    rep(i, x.size()){
        x[i] = i;
        if(D == 1){
            x[i] *= 100;
        }
        if(D == 2){
            x[i] *= 10000;
        }
    }
    if(N ==100) N++;
    cout << x[N] << endl;
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    int N,K;
    cin >> N >> K;

    if(N>100000||N<1)return 0;
    if(K>500 || K<1)return 0;

    int i = 0;
    int h[N];
    int count = 0;

    for(i=0;i<N;i++){
        cin >> h[i];
        if(h[i]>500||h[i]<1)return 0;
        //cout << a[i];
        if (h[i]>=K){
        	count++;
        }
    }
    output(count,0);
    return 0;
}


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

long long n,m;
vector<pair<long long,long long>> d;

long long  solve();

int main(){
    cin >> n >> m;
    d.resize(n);
    for(int i = 0;i < n;++i)cin >> d[i].first >> d[i].second;
    cout << solve() << endl;
}

long long solve(){
    sort(d.begin(),d.end());
    long long ans = 0,p = 0;
    for(int i = 0;i < n;++i){
        long long now = min(m-p,d[i].second);
        ans += d[i].first * now;
        p += now;
    }
    return ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

map<int, int> m;

bool comp(int a, int b) {
  return m[a] < m[b];
}

int main(int argc, char* argv[]) {
  int N, K;
  cin >> N >> K;

  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    if (m.find(a[i]) == m.end())
      m[a[i]] = 0;
    ++m[a[i]];
  }

  sort(a.begin(), a.end());
  vector<int>::iterator r = unique(a.begin(), a.end());
  a.erase(r, a.end());

  sort(a.begin(), r, comp);

  int total = a.size();
  int c = 0;
  if (total <= K) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < a.size() - 1; ++i) {
    total -= 1;
    c += m[a[i]];
    if (total <= K) {
      cout << c << endl;
      return 0;
    }
  }

  cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 10368
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Tenka1_2019
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = new int[n];
            int sum = 0;
            for(int i = 0; i < n; i++)
            {
                array[i] = ReadInt();
                sum += array[i];
            }
            int max = sum / 2 + 1;
            //val, count
            long mask = 998244353;
            long[] dp = new long[max + 1];
            dp[0] = 1;
            for(int i = 0; i < n; i++)
            {
                long[] next = new long[max + 1];
                for(int j = 0; j <= max; j++)
                {
                    next[j] += dp[j] * 2;
                    next[j] %= mask;
                    int nextVal = Min(j + array[i], max);
                    next[nextVal] += dp[j];
                    next[nextVal] %= mask;
                }
                dp = next;
            }
            long res = 1;
            for(int i = 0; i < n; i++)
            {
                res *= 3;
                res %= mask;
            }
            res -= dp[max] * 3;
            if (sum % 2 == 0)
            {
                res -= dp[max - 1] * 3;
                long[] dp2 = new long[max + 1];
                dp2[0] = 1;
                for(int i = 0; i < n; i++)
                {
                    long[] next2 = new long[max + 1];
                    for(int j = 0; j <= max; j++)
                    {
                        next2[j] += dp2[j];
                        next2[j] %= mask;
                        int nextVal = Min(j + array[i], max);
                        next2[nextVal] += dp2[j];
                        next2[nextVal] %= mask;
                    }
                    dp2 = next2;
                }
                res += dp2[sum / 2] * 3;
            }
            while (res < 0) res += mask;
            res %= mask;
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;

//=================================================================
// Begginer Contest 116 B
int main(){
    vector<int> v(1000000, 0);
    int s;
    cin >> s;
    v[s] = 1;

    for(int i=2;i<1000000;i++){
        if(s%2==0){
            s = s/2;
        }else{
            s = 3*s+1;
        }

        if(v[s]!=0){
            v[s] = i;
            break;
        }
        v[s]=i;
    }
    cout << v[s] << endl;
}

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

LL N;
LL A[200000];

LL ans = 0;

//xがdを何個約数に持つかを返す
LL divide(LL x,LL d){
	if(x==0) return 0;
	for(LL i=0;;i++){
		if(x%d!=0) return i;
		x/=d;
	}
}

void solve(){
	//2の約数をi個、5の約数をj個持つような数の個数をdivisor[i][j]とおく
	vector<vector<LL>> divisor(19,vector<LL>(19,0));
	for(int i=0;i<N;i++){
		LL d_2 = min(18LL,divide(A[i],2));
		LL d_5 = min(18LL,divide(A[i],5));
		divisor[d_2][d_5]++;
	}

	for(int i=0;i<N;i++){
		LL d_2 = min(18LL,divide(A[i],2));
		LL d_5 = min(18LL,divide(A[i],5));
		for(int i=18-d_2;i<=18;i++){
			for(int j=18-d_5;j<=18;j++){
				ans += divisor[i][j];
				if(i==d_2 && j==d_5) ans--;
			}
		}
	}

	ans/=2;
}
 
int main(){
   	cin >> N;
	for(int i=0;i<N;i++){
    	string s; cin >> s;

        LL x = 0;
        bool f = false;
        int rest = 9;
        for(int j=0;j<s.size();j++){
            if (s[j] != '.') {
                x = x * 10LL + ((LL)(s[j] - '0'));
                if (f) rest--;
            }
            else f = true;
        }
        for(int _=0;_<rest;_++) x *= 10LL;

    	A[i] = x;
    }
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4732
import itertools
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,MOD = map(int,input().split())
if N == 1:
    print(1)
    exit()
graph = [set() for _ in range(N)]
for row in sys.stdin.readlines():
    x,y = map(int,row.split())
    graph[x-1].add(y-1)
    graph[y-1].add(x-1)

ldp = [None] * N
rdp = [None] * N

def dfs_1(v=0,parent=None):
    # 子ごとに、そこを黒くして適切 or 完全白
    graph[v].discard(parent)
    ldp[v] = [1] * (len(graph[v])+1)
    rdp[v] = [1] * (len(graph[v])+1)
    vals = [dfs_1(w,v)+1 for w in graph[v]]
    for i,x in enumerate(vals,1):
        ldp[v][i] = ldp[v][i-1] * x % MOD
    for i,x in enumerate(reversed(vals),1):
        rdp[v][-i-1] = rdp[v][-i] * x % MOD
    return ldp[v][-1]

dfs_1()

dp = [None] * N
q = [(0,1)]
while q:
    v,x = q.pop()
    dp[v] = x*ldp[v][-1]%MOD
    for w,L,R in zip(graph[v],ldp[v][:-1],rdp[v][1:]):
        q.append((w,x*L*R%MOD+1))

print('\n'.join(map(str,dp)))

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=402;
const ll INF=(1LL<<50);
ll dp[MAX][MAX],T[MAX+1];

ll cost(int a,int b){
    if(dp[a][b]!=INF) return dp[a][b];
    else{
        ll ans=INF*1000;
        for(int i=a+1;i<=b-1;i++){
            ans=min(ans,cost(a,i)+cost(i,b)+T[b-1]-T[a-1]);
        }
        return dp[a][b]=ans;
    }
}

int main(){
    
    int N;cin>>N;
    ll S[N];
    for(int i=0;i<N+2;i++){
        for(int j=0;j<N+2;j++){
            dp[i][j]=INF;
        }
    }
    for(int i=0;i<N;i++){
        cin>>S[i];
        dp[i+1][i+2]=S[i];
    }
    T[0]=0;
    for(int i=1;i<N+1;i++){
        T[i]=T[i-1]+S[i-1];
    }
    
    cout<<cost(1,N+1)-T[N]<<endl;
    
    
}


Measured memory_bytes: 1536
def resolve():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()
    ans = 0
    for start in range(K):
        dp = [[0] * 3 for _ in range(2)]
        switch = 0
        for i in range(start, len(T), K):
            hand = T[i]
            prev = switch ^ 1
            dp[switch][0] = max(dp[prev][1], dp[prev][2])
            dp[switch][1] = max(dp[prev][0], dp[prev][2])
            dp[switch][2] = max(dp[prev][0], dp[prev][1])
            if hand == 's':
                dp[switch][0] += R
            elif hand == 'p':
                dp[switch][1] += S
            else:
                dp[switch][2] += P
            switch ^= 1
        ans += max(dp[switch^1])
    print(ans)
resolve()

Measured memory_bytes: 48860
N, M, C = map(int, input().split())
blist = list(map(int, input().split()))
alist = []
for i in range(N):
    alist.append(list(map(int, input().split())))

counter = 0
for a in alist:
    ans = 0
    for j in range(M): 
        ans += a[j] * blist[j]
    ans += C
    if ans > 0:
        counter += 1

print(counter)

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

int main() {
  string S;
  cin >> S;
  string out = "No";
  vector<char> a(4);
  for(int i = 0; i < 4; i++){
    a.at(i) = S.at(i);
  }
 
  if(a.at(0) == a.at(1)){
    if(a.at(2) == a.at(3)){
      out = "Yes";
    }
  }else if(a.at(0) == a.at(2)){
    if(a.at(1) == a.at(3)){
      out = "Yes";
    }
  }else if(a.at(0) == a.at(3)){
    if(a.at(1) == a.at(2)){
      out = "Yes";
    }
  }
 if(a.at(0) == a.at(1)){
    if(a.at(1) == a.at(2)){
      if(a.at(2) == a.at(3)){
        out = "No";
      }
    }
 }
  cout << out << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int gcd(int x,int y){
	return y? gcd(y,x%y) : x;
}
int main(){
	int x,y;
	cin>>x>>y;
	cout<<gcd(x,y)<<endl;
	return 0;
}


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


int main() {
  int x,y,z; cin >> x >> y >> z;

  cout << (x-z) / (y+z) << endl;

  return 0;

}
  

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

int main(){
  ll a,i,b,c,d;
  char s;
  string t;
  s='a';
  cin >> a;
  i=1;
  while(a>0){
    if((a%26==0)&&(a>0)){
      t="z"+t;
      a-=26;
    }
    else{
      t=char(s+a%26-1)+t;
      a-=a%26;
    }
    a=a/26;
  }
  cout << t;
}

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

int main(){
    int n,d;
    cin>>n>>d;
    vector<vector<int>> x(n,vector<int>(d));
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>x[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1; j<n;j++){
            int dis=0;
            for(int k=0;k<d;k++){
                dis += pow(x[j][k]-x[i][k], 2);
            }
            int z=sqrt(dis);
            if(dis ==z*z) ans++;
        }
    }
    cout<< ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A,B;
    cin >> A>>B;
    cout << (A - 1) * (B - 1) << endl;
}

Measured memory_bytes: 3644
s=[0,0]
for i in range(int(input())):
	r=input().split()
	if r[0]<r[1]:
		s[1]+=3
	elif r[1]<r[0]:
		s[0]+=3
	else:
		s[0]+=1
		s[1]+=1
print(str(s[0])+' '+str(s[1]))


Measured memory_bytes: 5596
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

a,b = myinput()

if a<=(2*b):
    print(0)
    exit()
else:
    ans = a - 2*b
    print(ans)
    exit()

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

string s;
int main()
{
    set<char> st;
    for(char c = 'a';c <= 'z';c++)
    {
        st.insert(c);
    }

    cin >> s;
    for(char c : s)
    {
        st.erase(c);
    }

    if(st.empty())
    {
        cout << "None" << endl;
    }
    else
    {
        cout << *(st.begin()) << endl;
    }

}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
N = int(input())
dictS = {}
for x in range(N):
    tmp = input().rstrip()
    if tmp in dictS:
        dictS[tmp] = dictS[tmp]+1
    else:
        dictS[tmp]=1
        
max_n =max(dictS.values())
maxIndex = [x for x in dictS.items() if x[1] ==max_n ]
ans_list = []
for x in maxIndex:
    ans_list.append(x[0])
ans_list.sort()
for x in ans_list:
    print(x)

Measured memory_bytes: 46168
x_1,x_2,x_3,x_4,x_5=map(int,input().split())
if x_1==0:
    print("1")
if x_2==0:
    print("2")
if x_3==0:
    print("3")
if x_4==0:
    print("4")
if x_5==0:
    print("5")


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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = I()
print(lst[k-1])


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

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;
static const bool DEBUG = false;

//?????§??¬?´???°
int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }

void f(int h, int w) {
	int g = gcd(h, w);
	if (g != 1) {
		f(h / g, w / g);
		return;
	}
	if (h == w) {
		cout << "1 0" << endl;
		return;
	}
	int a = h*w;
	if (a % 2) {
		cout << a / 2 + 1 << " " << a / 2 << endl;
	}
	else {
		cout << "1 1" << endl;
	}
}

signed main() {
	int T; cin >> T;
	rep(i, 0, T) {
		int h, w; cin >> h >> w;
		f(h, w);
	}
	return 0;
}

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

int main(){
  while(1){
    int point_a=0,point_b=0;
    string str;

    cin>>str;

    if(str[0]=='0')
      break;

    for(int i=1;i<str.size();i++){
      if(str[i]=='A')
        point_a++;
      else
        point_b++;
    }
    
    if(point_a>point_b)
      point_a++;
    else
      point_b++;
    
    cout<<point_a<<" "<<point_b<<endl;
  }

  return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int gcd(int m, int n)
{
	// 引数に０がある場合は０を返す
	if ((0 == m) || (0 == n))
		return 0;

	// ユークリッドの方法
	while (m != n)
	{
		if (m > n) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int main() {
	long long int n;
	long long int m;
	cin >> n;
	cin >> m;

	char s[100005];
	char t[100005];
	
	for (int i = 1; i < n+1; i++) {
		cin >> s[i];
	}
	for (int i = 1; i < m+1; i++) {
		cin >> t[i];
	}
	if (n == m) {
		for (int i = 1; i < n+1; i++) {
			if (s[i] != t[i]) { cout << -1; return 0; }
			if (i == n)cout << n;
		}
	}
	if (n < m) {
		if (m%n == 0) {
			for (int i = 1; i < n+1; i++) {
				int r = m / n;
				if(s[i]!=t[r*(i-1)+1]) { cout << -1; return 0; }
				if (i == n )cout << m;
			}
		}
		else {
			int q = gcd(n, m);
			int q1 = n / q;
			int q2 = m / q;
			for (int i = 1; i < q + 1; i++) {
				if(s[q1*(i-1)+1]!=t[q2*(i-1)+1]) { cout << -1; return 0; }
				long long int y= m * n / q;
				if (i == q)cout << y;
			}
		}
	}
	if (n > m) {
		if (n%m == 0) {
			for (int i = 1; i < m+1; i++) {
				int r = n / m;
				if (t[i] != s[r*(i - 1) + 1]) { cout << -1; return 0; }
				if (i == m )cout << n;
			}
		}
		else {
			int q = gcd(n, m);
			int q1 = n / q;
			int q2 = m / q;
			for (int i = 1; i < q + 1; i++) {
				if (s[q1*(i - 1) + 1] != t[q2*(i - 1) + 1]) { cout << -1; return 0; }
				long long int y = m * n / q;
				if (i == q)cout << y;
			}
		}
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int sum(vector<Int> &a, Int l, Int r){
	return a[r] - (l-1 >= 0 ? a[l-1] : 0);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n;
	string s;
	cin >> n >> s;

	vector<Int> a(n);
	for(Int i=0; i<n; ++i)
		if(s[i] == 'M')
			a[i] = 1;
	for(Int i=1; i<n; ++i)
		a[i] += a[i-1];

	vector<Int> di, ci;
	for(Int i=0; i<n; ++i){
		if(s[i] == 'D') di.push_back(i);
		if(s[i] == 'C') ci.push_back(i);
	}

	Int q; cin >> q;
	while(q--){
		Int k; cin >> k;
		if(di.size() == 0){
			cout << 0 << "\n";
			continue;
		}
		Int ans = 0, tmp = 0;
		size_t j = 0;
		queue<Int> q;
		while(j < ci.size() && ci[j] < di[0]) ++j;
		while(j < ci.size() && ci[j] < di[0]+k){
			q.push(ci[j]);
			tmp += sum(a, di[0], ci[j]);
			++j;
		}
		ans += tmp;
		for(size_t i=1; i<di.size(); ++i){
			while(!q.empty() && q.front() < di[i]){
				Int p = q.front(); q.pop();
				tmp -= sum(a, di[i-1], p);
			}
			tmp -= q.size() * sum(a, di[i-1], di[i]);
//			cout << i << " " << di[i] << " " << tmp << "\n";
			while(j < ci.size() && ci[j] < di[i]) ++j;
			while(j < ci.size() && ci[j] < di[i]+k){
				q.push(ci[j]);
				tmp += sum(a, di[i], ci[j]);
				++j;
			}
			ans += tmp;
		}
		cout << ans << "\n";
	}
}

Measured memory_bytes: 25004
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
  static Integer arr[];
  static int b[];
  static class FastReader{
    StringTokenizer st;
    BufferedReader in;
    public FastReader() {
    in = new BufferedReader(new InputStreamReader(System.in));
    }
    
    String next() {
      while (st == null|| !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(in.readLine());
        } catch(IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }
    
    int nextInt(){
      return Integer.parseInt(next());
    }
    
    long nextLong(){
      return Long.parseLong(next());
    }
    
    double nextDouble(){
      return Double.parseDouble(next());
    }
    
    String nextLine(){
      String str = "";
      try {
        str = in.readLine();
      } catch(IOException e){
        e.printStackTrace();
      }
      return str;
    }
  }
  
  public static void main(String[] args){
    FastReader sc = new FastReader();
    String s = sc.next();
    if(s.contains("7"))
    {
      System.out.println("Yes");
    }else System.out.println("No");
    
  }
}

Measured memory_bytes: 32796
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            long N = in.nextLong();
            long min = (long) 1e18;
            for (int i = 1, sqrt = (int) (Math.sqrt(N) + 1); i <= sqrt; i++) {
                if (N % i == 0) {
                    min = Math.min(min, i - 1 + (N / i) - 1);
                }
            }
            System.out.println(min);
        }
    }
}


Measured memory_bytes: 27256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m=map(int,input().split())
XY=[tuple(map(int,input().split())) for i in range(m)]
G=[[] for i in range(n)]
for x,y in XY:
  x-=1; y-=1
  G[x].append(y)

def Topological_Sort(G):
    # DAGの隣接リストを受け取って、トポロジカルソートしたリストを返す
    V=len(G)
    div=[0]*V
    for gi in G:
        for ei  in gi:
            div[ei]+=1
    used=[0]*V
    result=[]

    def bfs(node):
        que = collections.deque([node])
        used[node] = 1
        while que:
            tmp = que.popleft()
            result.append(tmp)
            for v in G[tmp]:
                div[v] -= 1
                if div[v] == 0 and not used[v]:
                    que.append(v)
                    used[v] = 1

    for i in range(V):
        if div[i]==0 and not used[i]:
            bfs(i)
    return result
DAG = Topological_Sort(G)
dp=[0]*n
for ni in DAG:
  for vi in G[ni]:
    dp[vi] = max(dp[vi],dp[ni]+1)
print(max(dp))


Measured memory_bytes: 78940
number=input()
list(number)
number=list(map(int,number))
a=[]
def f(i,s):
    if i==len(number):
        return s==7
    if f(i+1,s+number[i]):
        a.append("+")
        return True  
    if f(i+1,s-number[i]):
        a.append("-")
        return True

if f(1,number[0]):
    print(str(number[0])+a[2]+str(number[1])+a[1]+str(number[2])+a[0]+str(number[3])+"=7")
else:
    print("no")

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

int main() {
  int A, B;
  cin >>A>>B;

  if ( A>=10){
    cout<<-1<<endl;
  }
  else if(B>=10){
    cout <<-1<<endl;
  }
  else{
  cout<<A*B<<endl;
  }
}

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

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define fst first
#define snd second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(void) {
	int x, y, s;
	while (cin >> x >> y >> s, s) {
		int ans = 0;
		for (int a = 1; a < s; a++) {
			for (int b = 1; b < s; b++) {
				int s1 = a * (100 + x) / 100 + b * (100 + x) / 100;
				int s2 = a * (100 + y) / 100 + b * (100 + y) / 100;
				if (s1 == s) {
					ans = max(ans, s2);
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
	int max1=0, ar[200002], max2=0, maxcounter, n, i;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%d", ar+i);
		if(ar[i]>max1)
		{
			max2 = max1;
			max1 = ar[i];
			maxcounter = 1;
		}
		else if(ar[i] == max1)
			maxcounter++;
		else if(ar[i]>max2)
			max2 = ar[i];
	}
	if(maxcounter>1)
		while(n--) printf("%d\n", max1);
	else
	{
		for(i=0; i<n; i++)
		{
			if(ar[i]==max1)
				printf("%d\n", max2);
			else 
				printf("%d\n", max1);
		}
	}
	return 0;
}

Measured memory_bytes: 2432
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
if (a < b && b < c){
System.out.println("Yes"); 
}else {
System.out.println("No");
}
}
}


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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(){
    ll n;
    cin >> n;
    vector<int> a(n, 0);
    for (int i = 0; i < n; i++) cin >> a[i];

    int index = 1;
    int ans = 0;
    for (int i = 0; i < n; i++){
        if(a[i] != index) ans++;
        else index++;
    }
    index--;
    if(index) cout << n - index << endl;
    else cout << -1 << endl;
    return 0;
}

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

int main() {
  long long Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  vector<long long> p = { 8*Q, 4*H, 2*S, D };
  sort(p.begin(), p.end());
  long long ans = 0;
  ans += p.at(0) * (N / 2);
  if (N % 2 == 1) {
    vector<long long> q = { 4*Q, 2*H, S };
    sort(q.begin(), q.end());
    ans += q.at(0);
  }
  cout << ans << endl;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

#define NIL NULL

void insert(int);
void inorder(Node);
void preorder(Node);

Node root;

int main()
{
  int n, i, x;
  char com[20];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s", com);

    if( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }

    else if( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}
void insert(int k)
{

  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;

}

void inorder(Node root)
{

  if(root != NIL){
    inorder(root->left);
    printf(" %d", root->key);
    inorder(root->right);
  }

}

void preorder(Node root)
{

  if(root != NIL){
    printf(" %d", root->key);
    preorder(root->left);
    preorder(root->right);
  }

}

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

using namespace std;
typedef long long ll;

ll N,K;
ll A[200000];
vector<ll> v;
int check[200000];

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i]--;
    }
    int p = 0;
    while(check[p] == 0){
        check[p]++;
        v.push_back(p);
        p = A[p];
    }
    ll q;
    for(int i=0;i<v.size();i++){
        if(p == v[i]) q = i;
    }
    if(K <= q){
        cout << v[K] + 1 << endl;
        return 0;
    }
    K -= q;
    ll ind = K % (v.size() - q);
    cout << v[q + ind]+1 << endl;
    return 0;
}

Measured memory_bytes: 7628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;
const int MAX_N = 2e5;

int main(){
  ll n, m, k;
  cin >> n >> m >> k;
  ll a[220000], b[220000];
  a[0] = 0; b[0] = 0;
  rep(i, n){
    ll p;
    cin >> p;
    a[i+1] = a[i] + p;
  }
  rep(i, m){
    ll p;
    cin >> p;
    b[i+1] = p + b[i];
  }
  int ans = 0;
  int j = m;

  for(int i = 0; i <= n; i++){
    if(a[i] > k) break;
    while(b[j] > k - a[i] && j >= 0){
      j--;
    }
    ans = max(ans, i + j);
  }

  cout << ans <<endl;
}
  



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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task ""

using namespace std;
typedef long long ll;

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen("A.INP", "r")){
        freopen("A.INP", "r", stdin);
        freopen("A.OUT", "w", stdout);
    }
    if (fopen(Task".INP", "r")){
        freopen(Task".INP", "r", stdin);
        freopen(Task".OUT", "w", stdout);
    }
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int &x : a){
        cin >> x;
    }
    int x = (n - k) / (k - 1);
    if ((k - 1) * x < (n - k)) ++x;
    cout << x + 1;
}


Measured memory_bytes: 640