akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){

    int n, flag;
    long long ans = 0;

    cin >> n;
    int a[n + 5], b[n + 5], c[n + 5], dp[n + 5][3];
    for(int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];
    memset(dp, 0, sizeof(dp));
    for(int i = 1; i <= n; i++){
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll t;
ll ret = 0;
string s;
ll A, B, C;

void input() {
  IN(N);
}

void solve() {
  bool ok = false;
  if (N%10 == 7) ok = true;
  if ((N/10)%10 == 7) ok = true;
  if (N/100 == 7) ok = true;
  PRINT(ok?"Yes":"No");
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K;
    cin>>N>>K;
    
    vector<int> nums(N);
    rep(i,N) cin>>nums[i];
    sort(all(nums));
    
    int ans=INF;
    rep(i,N-K+1){
        int tmp=nums[i+K-1]-nums[i];
        chmin(ans,tmp);
    }
    cout1(ans)
}

Measured memory_bytes: 640
using System;

class Program
{
    static void Main()
    {
        for (;;)
        {
            string[] str = Console.ReadLine().Split(' ');
            int H = int.Parse(str[0]);
            int W = int.Parse(str[1]);
            if (W == 0 && H == 0) { break; }
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (i == 0 || i == H - 1 || j == 0 || j == W - 1)
                    {
                        Console.Write("#");
                    }
                    else Console.Write(".");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 13896
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
using namespace std;

struct crop{
  double e;
  string name;
  crop(double e, string n) :e(e), name(n){}

  bool operator<(const crop& c) const {
    return e != c.e ? e > c.e : name < c.name;
  }
};

int main(){
  
  for(int n;cin>>n,n;){
    vector<crop> l;
    for(int i=0;i<n;i++){
      string str;
      int p,a,b,c,d,e,f,s,m;
      cin>>str>>p>>a>>b>>c>>d>>e>>f>>s>>m;
      int syuunyuu = s*f*m-p;
      l.push_back(crop(((double)syuunyuu)/((double)a+b+c+(d+e)*m), str));
    }
    //cout << kane[0].first << " " << kane[0].second << endl;

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

    for(int i=0;i<(int)l.size();i++) cout << l[i].name << endl;

    cout << '#' << endl;
  }

  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <list>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n;
  cin >> n;
  std::list<int> B;
  for(int i=0;i<n;++i){
    int a;
    cin >> a;
    if(i%2){
      B.push_front(a);
    }else{
      B.push_back(a);
    }
  }

  if(n%2){
    reverse(B.begin(),B.end());
  }
  for(const auto &b:B){
    cout << b << " ";
  }
  
  return 0;
}

Measured memory_bytes: 8448
//#include <iostream>
//#include<vector>
//using namespace std;
//#include<algorithm>
//
//
//// vectorからindex番目の要素を削除する
//template<typename T>
//void remove(std::vector<T>& vector, unsigned int index)
//{
//    vector.erase(vector.begin() + index);
//}
//int main()
//{
//    int n, a;
//    vector<int>A;
//    cin >> n; 
//    bool chofuku = false;
//    bool ok = true;
//    for (int i = 0; i < n; i++) {
//        chofuku = false;
//        ok = true;
//        scanf("%d", &a);
//        for (int j = 0; j < A.size(); j++) {
//            if (A[j] == a) {
//                remove(A, j);
//                j--;
//                chofuku = true;
//            }
//            else if (A[j] > a) {
//                if (A[j] % a == 0) {
//                    remove(A, j);
//                    j--;
//                }
//            }
//            else {
//                if (a % A[j] == 0) {
//                    ok = false;
//                    break;
//                }
//            }
//        }
//        if (chofuku == false && ok==true) {
//            A.emplace_back(a);
//        }
//        
//    }
//   
//    cout << A.size() << endl;
// ////   sort(A.begin(), A.end());
// //   //auto itrr = A.begin();
// //   int i = 0;
// //   //while (itrr != A.end()) {//
// //   while(i<A.size()){
// //       chofuku = false;
// //       //for (auto itr = ++itrr; itr != A.end(); itr++) {
// //       //    int youso = *itrr;
// //       //    if (youso == (*itr)) {
// //       //        chofuku = true;
// //       //        A.erase(itr);
// //       //    }
// //       //    else if ((*itr) % youso == 0) {
// //       //        A.erase(itr);
// //       //    }
// //       //    
// //       //}
// //       for (int j = 0; j < A.size(); j++) {
// //           if (i != j) {
// //               int youso = A[i];
// //               if (youso == A[j]) {
// //                   chofuku = true;
// //                   remove(A, j);
// //                   if(i>j)i--;
// //                   j--;
// //               }
// //               else if (A[j] % youso == 0) {
// //                   remove(A, j);
// //                   if(i>j)i--;
// //                   j--;
// //               }
// //           }
// //       }
//
// //       if (chofuku) {
// //           //A.erase(itrr);
// //           remove(A, i);
// //       }
// //       else {
// //           i++;
// //       }
//
//   // }
//  //  cout << A.size() << endl;
//    
//}
//
//

//ans

#include<iostream>
#include<vector>
#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 M = 1000005;

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	vector<int> cnt(M);
	for (int x : a) {
		if (cnt[x] != 0) {
			cnt[x] = 2;
			continue;
		}
		for (int i = x; i < M; i += x)cnt[i]++;
	}
	int ans = 0;
	for (int x : a) {
		if (cnt[x] == 1)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7944
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define SUM(n) ((n)+1)*(n)/2
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = (1e9)+7;
#define all(v) v.begin(),v.end()
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

  lol n, k;
  cin >> n >> k;
  vector<pii> pi;
  int a,b;
  reps(i,n){
    cin >> a >> b;
    pi.emplace_back(a,b);
  }
  sort(all(pi));
  lol sum = 0;
  rep(i,n){
    sum += pi[i].se;
    if(sum >= k){
      cout << pi[i].fi << '\n';
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y>>z;
std::cout << (x+y)*z/2 << '\n';
}


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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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 <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) {
        is >> x;
    }
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int a, b, c;
    cin >> a >> b >> c;

    cout << max(0, c - (a - b)) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int [] value = new int[n];
		int [] cost = new int[n];
		int [] profit = new int[n];
		int total_profit = 0;

		for(int i = 0; i < n; i++) {
			value[i] = sc.nextInt();
		}

		for(int i = 0; i < n; i++) {
			cost[i] = sc.nextInt();
		}

		for(int i = 0; i < n; i++) {
			profit[i] = value[i] - cost[i];
			if(profit[i] >= 0) {
				total_profit += profit[i];
			}
		}

		System.out.println(total_profit);
	}
}

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

int bubbleSort(vector<string> &C, int N) {
  for (int i = 0; i < N; i++) {
    for (int j = N - 1; i < j; j--) {
      if (C.at(j).at(1) < C.at(j - 1).at(1)) {
        swap(C.at(j), C.at(j - 1));
      }
    }
  }
}

int selectionSort(vector<string> &C, int N) {
  int minj;

  for (int i = 0; i < N; i++) {
    minj = i;

    for (int j = i; j < N; j++) {
      if (C.at(j).at(1) < C.at(minj).at(1)) {
        minj = j;
      }
    }

    if (i != minj) {
      swap(C.at(i), C.at(minj));
    }
  }
}

int outputVector(vector<string> vec, int N) {
  for (int i = 0; i < N; i++) {
    if (i != N - 1) {
      cout << vec.at(i) << " ";
    } else {
      cout << vec.at(i) << endl;
    }
  }
}

// Stable かどうか出力
int outputStable(vector<string> vec, vector<string> stable, int N) {
  bool ans = true;

  // bubbleSort は 安定なソート なので、比較
  for (int i = 0; i < N; i++) {
    if (vec.at(i) != stable.at(i)) ans = false;
  }

  cout << (ans ? "Stable" : "Not stable") << endl;
}

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

  vector<string> A(N), B(N);

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    B.at(i) = A.at(i);
  }

  bubbleSort(A, N);
  outputVector(A, N);
  // bubbleSort は 安定なソート
  cout << "Stable" << endl;

  selectionSort(B, N);
  outputVector(B, N);
  outputStable(B, A, N);
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int dp[MX];

int main() {
  int n;
  scanf("%d",&n);
  int k;
  scanf("%d",&k);
  vi h(n);
  cin>>h;
  h.pb(INF);
  h.pb(INF);
  h.pb(INF);
  rep(i,n) dp[i] = INF;
  dp[0] = 0;
  rep(i,n) {
    rrep(j,k) if (i+j < n) {
      mins(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int H, W = 0;
    cin >> H >> W;
    
    vector<vector<int>> field(H+2, vector<int>(W+2, 1));
    
    for(int i = 0; i < H; i++){
        string s;
        cin >> s;
        for(int j = 0; j < W; j++){
            if(s[j] == '.')
                field[i+1][j+1] = 0;
        }
    }
    vector<vector<int>> count_width(H, vector<int>(W, 0));
    for(int i = 1; i < H+1; i++){
        vector<int> idx;
        for(int j = 0; j < W+2; j++){
            if(field[i][j] == 1)
                idx.push_back(j);
        }
        for(int j = 0; j < idx.size()-1; j++){
            for(int k = idx[j]+1; k < idx[j+1]; k++){
                count_width[i-1][k-1] = idx[j+1] - idx[j] - 1;
            }
        }
    }
    vector<vector<int>> count_height(H, vector<int>(W, 0));
    for(int i = 1; i < W+1; i++){
        vector<int> idx;
        for(int j = 0; j < H+2; j++){
            if(field[j][i] == 1)
                idx.push_back(j);
        }
        for(int j = 0; j < idx.size()-1; j++){
            for(int k = idx[j]+1; k < idx[j+1]; k++){
                count_height[k-1][i-1] = idx[j+1] - idx[j] - 1;
            }
        }
    }
    int max = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(count_width[i][j] + count_height[i][j] > max)
                max = count_width[i][j] + count_height[i][j] ;
        }
    }
    cout << max - 1;
}


Measured memory_bytes: 47360
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	a = inputInt()

	print(a + (a**2) + (a**3))



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 77200
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @a = gets.split(//).map(&:to_i)
  end

  def solve
    a.sum % 9 == 0
  end

  def show(ans)
    puts ans ? "Yes" : "No"
  end
end

Problem.new.instance_eval do
  show(solve)
end

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

int main()
{
    int n, m;
    cin >> n >> m;
    int lmax = 0;
    int rmin = numeric_limits<int>::max();
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        lmax = max(lmax, l);
        rmin = min(rmin, r);
    }
    cout << max(rmin - lmax + 1, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}


int main() {
    LL N, P;
    cin >> N >> P;
    bool all_even = true;
    REP(i, N) {
        LL A;
        cin >> A;
        if (A % 2 == 1) all_even = false;
    }

    LL ans = 1;
    if (all_even) {
        if (P == 1) {
            ans = 0;
        } else {
            REP(i, N) {
                ans *= 2;
            }
        }
    } else {
        REP(i, N - 1) {
            ans *= 2;
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,n,m,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        ll ans=0;
        cin>>n>>m>>k;
        if(n==0)
            ans = 1+(m/k);
        else
            ans = (m/k) - ((n-1)/k);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3604
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int N, A, B, ans = 0;
        cin >> N >> A >> B;
        rep2(i, 1, N + 1)
        {
                int w = 0, j = i;
                while (j > 0)
                {
                        w += j % 10;
                        j /= 10;
                }

                if (A <= w && w <= B)
                {
                        ans += i;
                }
        }

        cout << ans << endl;

        return 0;
}


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

class Program
{
	static void Main(string[] args)
	{
		//文字列を読み込む
		string[] S = Console.ReadLine().Split(' ');
		int A = int.Parse(S[0]);
		int B = int.Parse(S[1]);

		//あり得る元の価格をそれぞれリストに格納
		List<double> A_list = new List<double>();
		List<double> B_list = new List<double>();

		//A、Bそれぞれについて、元の価格の下限値・上限値を設定
		//下限値は切り捨て
		double A_min = Math.Floor(A / 0.08);
		double B_min = Math.Floor(B / 0.1);
		//上限値は切り上げ
		double A_max = Math.Ceiling((A+1) / 0.08);
		double B_max = Math.Ceiling((B+1) / 0.1);

		//各ループ処理でリストに追加
		for(double i=A_min; i<=A_max; i++){
				if(i >= A/0.08 && i < (A+1)/0.08){
						A_list.Add(i);
				}
		}

		for(double i=B_min; i<=B_max; i++){
				if(i >= B/0.1 && i < (B+1)/0.1){
						B_list.Add(i);
				}
		}

		//ループ処理で最小値を出力
		//該当結果があるか判定する変数を定義
		bool matched = false;
		for(int i=0; i<A_list.Count(); i++){
				//既に最小値が発見されている場合
				if(matched){
						break;
				}

				double num = A_list[i];
				if(B_list.Contains(num)){
						matched = true;
						Console.WriteLine(num);
				}
		}

		//該当結果がない場合
		if(!matched){
				Console.WriteLine(-1);
		}


	}
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, A);
  print(N % 500 <= A ? "Yes" : "No");
}


Measured memory_bytes: 384
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}
bool ta[101][101];
int step1(int gre, int less) {
	
	less--;

	int col = 0;
	while (gre > less)
	{
		for (size_t i = 0; i < 100 && gre > less; i += 2)
		{
			ta[i][col] = true;
			gre--;
		}
		col += 2;
	}
	return col;
}

void step2(int v,int start) {

	int len = (100 - start);
	int half = len / 2;
	for (size_t i = 0; i < 100; i++)
	{
		for (size_t j = start; j < start + half; j++)
		{
			ta[i][j] = true;
		}
	}
	v--;
	if (v <= 0) return;
	for (size_t i = 0; i < 100; i += 2)
	{
		ta[i][start + half - 1] = false;
		ta[i][start + half] = true;
		v--;
		if (v == 0) return;
	}
	
	bool even = true;
	int c = 1;
	while (v > 0)
	{
		// 右側から
		for (size_t i = even; i < 100; i += 2)
		{
			ta[i][start + half + c] = true;
			v--;
			if (v == 0) return;
		}

		for (size_t i = even; i < 100; i += 2)
		{

			ta[i][start + half - 1 - c] = false;
			v--;
			if (v == 0) return;
		}
		c++;
		even = !even;
	}
}
void solv() {
	int a, b;
	cin >> a >> b;
	int less = min(a, b);
	int gre = max(a, b);
	int start = 0;
	if (less != gre) {
		start = step1(gre, less);
	}
	if (start > 0 && less > 1) {
		
		step2(less - 1, start);
	}
	else if(start == 0) step2(less, start);

	cout << 100 << " " << 100 << endl;
	for (size_t i = 0; i < 100; i++)
	{
		string res = "";
		for (size_t j = 0; j < 100; j++)
		{
			res += (a == gre) ? ta[i][j] ? "." : "#"
				: ta[i][j] ? "#" : ".";
		}
		cout << res << endl;
	}
}


int main() {
	solv();

	return 0;
}


Measured memory_bytes: 256
#C
line = [int(x) for x in input().split()]

l = [int(x) for x in input().split()]

total  = 0
maxx = -99999999999

for i in range(0, line[1]-1):
    total = total + (l[i+1] - l[i])
    if maxx < (l[i+1] - l[i]):
        maxx = (l[i+1] - l[i])

yeet = (l[0] + (line[0]-l[line[1]-1]))
total = total + yeet

if maxx < yeet:
        maxx = yeet


print(total - maxx)



Measured memory_bytes: 26444
/* 1C Floyd Warshall w/ negative-cycle detection
 * Constraints
 * 1 ≤ |V| ≤ 100
 * 0 ≤ |E| ≤ 9900
 * -2 × 10^7 ≤ di ≤ 2 × 10^7
 */

#include <algorithm>
#include <cstring>
#include <iostream>
#include <limits>
#include <map>
using namespace std;

#define INF numeric_limits<int>::max()

int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> adj[n + 1];
  for (int src, dst, cost; cin >> src >> dst >> cost;) {
    adj[src + 1][dst + 1] = cost;
  }

  // dp[u][v][k] = shortest u-v path with intermediate nodes
  //               of ID at most k
  int dp[101][101][101];
  for (int i = 0; i < 101; ++i)
    for (int j = 0; j < 101; ++j)
      for (int k = 0; k < 101; ++k)
        dp[i][j][k] = INF;

  for (int u = 1; u <= n; ++u) {
    dp[0][u][u] = 0;
    for (auto vcost : adj[u]) {
      dp[0][u][vcost.first] = vcost.second;
    }
  }

  for (int k = 1; k <= n; ++k) {
    for (int u = 1; u <= n; ++u) {
      for (int v = 1; v <= n; ++v) {
        dp[k][u][v] = dp[k - 1][u][v];
        if (dp[k - 1][u][k] != INF and dp[k - 1][k][v] != INF)
          dp[k][u][v] = min(dp[k - 1][u][v], dp[k - 1][u][k] + dp[k - 1][k][v]);
      }
    }
  }

  for (int u = 1; u <= n; ++u) {
    for (int t = 1; t <= n; ++t) {
      for (auto v_costtv : adj[t]) {
        if (dp[n][u][t] == INF)
          continue;
        if (dp[n][u][t] + v_costtv.second < dp[n][u][v_costtv.first]) {
          cout << "NEGATIVE CYCLE\n";
          exit(0);
        }
      }
    }
  }

  for (int u = 1; u <= n; ++u) {
    for (int v = 1; v <= n; ++v) {
      if (v > 1)
        cout << " ";
      if (dp[n][u][v] == INF) {
        cout << "INF";
      } else {
        cout << dp[n][u][v];
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 7496
n=int(input())
a=list(map(int,input().split()))
ans=0
minuscnt,zero_cnt=0,0
for aa in a:
  if aa<0:
    minuscnt+=1
  elif aa==0:
    zero_cnt+=1
sum_a=0
min_a=10**18
for aa in a:
  sum_a+=abs(aa)
  min_a=min(min_a,abs(aa))

if minuscnt%2==0 or zero_cnt>0:
  print(sum_a)
else:
  print(sum_a-2*min_a)


Measured memory_bytes: 14452
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll LCM(ll a,ll b){
    return a*b/__gcd(a,b);
}
int main()
{
    int a,b;
    cin >> a >> b;
    ll lcm = LCM(a,b);
    cout << lcm << endl;

}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
r = dict([(chr(i), 50) for i in range(ord("a"), ord("z") + 1)])

for i in range(N):
  c = Counter(list(input()))
  for k, v in r.items():
    r[k] = min(v, c.get(k, 0))

ans = ""
for i in range(ord("a"), ord("z") + 1):
  ans += chr(i) * r[chr(i)]
print(ans)

Measured memory_bytes: 3316
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
string S;
signed main(){
    cin >> N >> S;
    rep(i, S.size()){
        cout << (char)((S[i]-'A'+N)%26+'A');
    }
    cout << endl;
}

Measured memory_bytes: 256
import math
 
def combination_count(n,k):
    if k > n or k < 0:
        return 0
    if n == 0 or k == 0:
        return 1
    
    s = math.factorial(n)
    t = math.factorial(k)
    u = math.factorial(n-k)
    
    return s//(t*u)
    
n,k = map(int,input().split())
 
mod = 10**9 + 7
 
for i in range(1,k+1):
    x = combination_count(n-k+1,i) * combination_count(k-1, i-1)
    print(x%mod)

Measured memory_bytes: 3316
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

int keta(double x) {
	return ceil(log10(x + 1));
}

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

	for (long long i = ceil(sqrt(n)); i >= 1; i--) {
		if (n%i == 0) {
			cout << keta(i > n / i ? i : n / i) << endl;
			break;
		}
	}
//	cin >> n;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int n;
    cin >> n;
    double sum = 0;
    rep(i,n) {
        double x;
        string u;
        cin >> x >> u;
        if(u=="JPY") {
            sum += x;
        } else {
            sum += x*380000;
        }
    }
    printf("%.5f",sum);
    printf("\n");

}

Measured memory_bytes: 3788
def main():
    o = input()
    e = input()

    ans = [None] * (len(o) + len(e))
    ans[::2] = o
    ans[1::2] = e
    print(*ans, sep='')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3060
def main()->None:
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    S = input()
    sorted_s = sorted(S)
    flag = False
    for i in alphabet:
        if i not in sorted_s:
            flag = True
            break
    if flag:print(i)
    else:print("None")



if __name__ == "__main__":
    main()

Measured memory_bytes: 4404
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <queue>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<string> S(N);

    for(int i = 0; i < N; i++){
        cin >> S[i];
    }

    int ans = -1;
    for(int start = 0; start < N; start++){
        vector<int> num(N, -1);
        queue<int> q;
        q.push(start);
        num[start] = 1;

        int maxNum = 1;
        bool isOk = true;
        while(!q.empty() && isOk){
            int temp = q.front();
            q.pop();
            int tempNum = num[temp];

            for(int i = 0; i < N; i++){
                if(S[temp][i] == '1'){
                    if(num[i] == -1){
                        num[i] = tempNum + 1;
                        maxNum = max(maxNum, tempNum + 1);
                        q.push(i);
                    }
                    else{
                        if(num[i] % 2 == (tempNum + 1) % 2){
                            continue;
                        }
                        else{
                            isOk = false;
                            maxNum = -1;
                            break;
                        }
                    }
                }
            }
        }

        ans = max(ans, maxNum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long total=1;
		for(int i=1;i<=n;i++){
			total*=i;
			total%=1000000007;
		}
		System.out.println(total);
		
			

	}
}


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

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


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

using namespace std;
typedef long long LL;

const int N = 1e6 + 5;
bool np[N + 10];
LL prime[N + 10], mu[N + 10];
int getMu()
{
    int cnt = 0;
    np[0] = np[1] = true;
    mu[1] = 1;
    for (int i = 2; i < N; ++i)
    {
        if (!np[i])
            prime[++cnt] = i, mu[i] = -1;
        for (int j = 1; j <= cnt && i * prime[j] < N; ++j)
        {
            np[i * prime[j]] = true;
            if (i % prime[j] == 0)
            {
                mu[i * prime[j]] = 0;
                break;
            }
            else
            {
                mu[i * prime[j]] = -mu[i];
            }
        }
    }
    return cnt;
}
int a[N];
int vis[N + 10];
int main()
{
    int n;
    int cntpri = getMu();
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", a + i);
    }
    int flag1 = a[1];
    for (int i = 2; i <= n; i++)
    {
        flag1 = __gcd(flag1, a[i]);
    }
    int flag2 = 1;
    for (int i = 1; i <= n; i++)
    {
        int ii = 1;
        int tmpi = a[i];
        while (prime[ii] * prime[ii] <= (LL)tmpi)
        {
            if (tmpi % prime[ii] == 0)
            {
                vis[prime[ii]]++;
                if (vis[prime[ii]] == 2)
                {
                    flag2 = 0;
                    break;
                }
                while (tmpi % prime[ii] == 0)
                {
                    tmpi /= prime[ii];
                }
            }
            ii++;
        }
        if (tmpi > 1)
        {
            vis[tmpi]++;
            if (vis[tmpi] == 2)
            {
                flag2 = 0;
                break;
            }
        }
        if (flag2 == 0)
            break;
    }
    if (flag2 == 1)
    {
        printf("pairwise coprime\n");
    }else if (flag1 == 1)
    {
        printf("setwise coprime\n");
    }else
    {
        printf("not coprime\n");
    }
    // int T;
    // cin >> T;
    
}

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

int main() {
	// your code goes here
	int n,i,c[30],max,ans=1;
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> c[i];
		if(i==1){
			max=c[i];
		} else {
			if(max<=c[i]){
				ans++;
				max=c[i];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define srtarr(x, n) sort(x, x+n)
#define dsrtarr(x, n) sort(x, x+n, greater<>());
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007

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

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

using namespace std;
/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */


int main() {
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, s.size()){
        mp[s[i]]++;
    }
    if(mp.size() != 2){
        cout << "No" << endl;
        return 0;
    }
    for(auto e: mp){
        if(e.second != 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}




Measured memory_bytes: 256
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

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

#endif  // end of use_templates


int main()
{
    ll h, w, k;
    cin >> h >> w >> k;
    ll result = 0;
    vector<string> m(h);
    rep(i, h) {
        cin >> m[i];
    }
    rep(hh, 1 << h) {
        rep(ww, 1 << w) {
            vector<string> mm = m;
            for (ll i = 0, ii = 1; ii < (1 << h); ++i, ii <<= 1) {
                if (hh & ii) {
                    rep(www, w) {
                        mm[i][www] = 'o';
                    }
                }
            }
            for (ll j = 0, jj = 1; jj < (1 << w); ++j, jj <<= 1) {
                if (ww & jj) {
                    rep(hhh, h) {
                        mm[hhh][j] = 'o';
                    }
                }
            }

            ll count = 0;
            rep(i, h) {
                rep(j, w) {
                    if (mm[i][j] == '#') {
                        ++count;
                    }
                }
            }
            if (count == k) {
                ++result;
            }
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int check(int n){
	int i;
	if(n == 2) return 1;
	if(n < 2 || n % 2 == 0) return 0;
	for(i = 3; i <= sqrt((double)n); i += 2){
		if(n % i == 0) return 0;
	}
	return 1;
}

int main(){
	int n, i;
	int *a;
	int prime = 0;

	scanf("%d", &n);
	a = (int*)malloc(sizeof(int)*n);

	for(i = 0; i < n; i++){
		scanf("%d", a+i);
		prime += check(*(a+i));
	}

	printf("%d\n", prime);

	return 0;
}

Measured memory_bytes: 628
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define mp make_pair
#define ff first
#define ss second
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b;
	cin>>a>>b;
	if(a<=9 and b<=9){
		cout<<a*b;
		return 0;
	}
	cout<<-1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long 
#define f(j) for(ll i=0;i<j;i++)
#define pb(i) push_back(i)
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;    
typedef vector<vector<long long> > matrix; 
vector<int>	adj[100001];
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	// faster
	int n,m,a,b,ecount[100001]={0},node;
	cin>>n>>m;
	f(m){
		cin>>a>>b;
		adj[a].pb(b);
		ecount[b]++;
	}
	int distance[100001]={0};
	int start,ans=0;
	queue<int>	q;
	for(int i=1;i<=n;i++)
		if(ecount[i]==0)
			q.push(i);
	while(!q.empty()){
		node = q.front();
		q.pop();
		for(int i=0;i<adj[node].size();i++){
			ecount[adj[node][i]]--;
			distance[adj[node][i]]=max(distance[adj[node][i]],distance[node]+1);
			ans = max(ans,distance[adj[node][i]]);
			if(!ecount[adj[node][i]])
				q.push(adj[node][i]);
		}
	}
	cout<<ans<<"\n";
return 0;	
}

Measured memory_bytes: 9744
px = 0
py = 0
pt = 0
n = int(input())

for _ in range(n):
	nt, nx, ny = list(map(int,input().split()))
	dt, dx, dy = abs(nt - pt), abs(nx - px), abs(ny - py)
	if dx + dy > dt or (dx + dy - dt) % 2 == 1:
		print("No")
		exit()
	else:
		pt,px,py = nt, nx, ny
    
print("Yes")

Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;
const double eps = 1e-10;

LL n;
double ans,r;

struct Point{
	double x,y;
}s[55];

double dist(LL x,LL y){
	return sqrt((s[x].x - s[y].x) * (s[x].x - s[y].x) + (s[y].y - s[x].y) * (s[y].y - s[x].y));
}

LL judge(double rr){
	for(LL i = 1;i <= n;i ++){
		if(dist(i,n + 1) > rr + eps) return 0;
	}
	return 1;
}

Point mkpoint(double x,double y){
	Point ret;
	ret.x = x; ret.y = y;
	return ret;
}

Point waixin(Point a,Point b,Point c){ 
  double a1 = b.x - a.x, b1 = b.y - a.y, c1 = (a1*a1 + b1*b1)/2.0; 
  double a2 = c.x - a.x, b2 = c.y - a.y, c2 = (a2*a2 + b2*b2)/2.0; 
  double d = a1*b2 - a2*b1;
  if(d < eps && d > -eps) return mkpoint(-10000.0,-10000.0);
  return mkpoint(a.x + (c1*b2 - c2*b1)/d, a.y + (a1*c2 -a2*c1)/d); 
}

int main(){
	cin >> n; ans = 1e6;
	for(LL i = 1;i <= n;i ++) cin >> s[i].x >> s[i].y;
	for(LL i = 1;i <= n;i ++){
		s[i].x += 1001.0;
		s[i].y += 1001.0;
	}
	
	// 2 points
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			if(i == j) continue;
			s[n + 1].x = (s[i].x + s[j].x) / 2.0; s[n + 1].y = (s[i].y + s[j].y) / 2.0;
			r = dist(i,j) / 2.0;
			if(judge(r)) ans = min(ans,dist(i,j) / 2.0);
		}
	}
	//
	
	// 3 points
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			for(LL k = 1;k <= n;k ++){
				if(i == j || j == k || k == i) continue;
				s[n + 1] = waixin(s[i],s[j],s[k]);
//         		x=((C1*B2)-(C2*B1))/((A1*B2)-(A2*B1))
//          	y=((A1*C2)-(A2*C1))/((A1*B2)-(A2*B1))
//				cout << s[n + 1].x << ' ' << s[n + 1].y << endl;
				r = dist(n + 1,j);
//				cout << r << endl;
				if(judge(r)) ans = min(ans,dist(n + 1,i));
			}
		}
	}
	//
	printf("%.10lf\n",ans);
	return 0;
}




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

using namespace std;

const int maxn = 100010;
const int inf = 0x3f3f3f3f;

int src, sink;

int n, l[maxn<<1], L[maxn<<1], Q[maxn<<1], r, fa[maxn], p[maxn], vis[maxn], e;
vector<int> vec[maxn];

struct Edge {
	int v, c, x;
} E[maxn<<3];

inline void addEdge(int u, int v, int c) {
	E[e].v = v; E[e].x = l[u]; E[e].c = c; l[u] = e++;
	E[e].v = u; E[e].x = l[v]; E[e].c = 0; l[v] = e++;
}

int _bfs() {
	memset(L, -1, sizeof(L));
	int s = 0, t = 0, u;
	L[src] = 0; Q[t++] = src;
	while (s < t) {	
		u = Q[s++];
		for (int p = l[u]; p >= 0; p = E[p].x) {
			if (E[p].c && L[E[p].v] == -1) {
				L[Q[t++] = E[p].v] = L[u] + 1;
			}
		}
	}
	return L[sink] != -1;
}

int _find(int u, int in) {
	if (u == sink) return in;
	int w = 0, t;
	for (int p = l[u]; p >= 0 && w < in; p = E[p].x) {
		if (L[E[p].v] == L[u] + 1 && E[p].c) {
			if ((t = _find(E[p].v, min(in-w, E[p].c)))) {
				E[p].c -= t;
				E[p^1].c += t;
				w += t;
			}
		}
	}
	if (w < in) L[u] = -1;
	return w;
}

int dinic() {
	int res = 0, t;
	while (_bfs()) {
		while ((t = _find(src, inf))) {
			res += t;
		}
	}
	return res;
}

int main() {
	memset(l, -1, sizeof(l));
	scanf("%d", &n);
	src = n-1+n+1; sink = n-1+n+2;
	for (int i = 1; i <= n-1; i++) {
		int c = 0; scanf("%d", &c);
		for (int j = 1; j <= c; j++) {
			int w; scanf("%d", &w);
			addEdge(i, n-1+w, 1);
			vec[w].push_back(i);
		}
		addEdge(src, i, 1);
	}
	for (int i = 1; i <= n; i++) addEdge(n-1+i, sink, 1);
	int c = dinic();
	if (c < n-1) {puts("-1"); return 0;}
	for (int i = 1; i <= n-1; i++) {
		for (int _p = l[i]; _p >= 0; _p = E[_p].x) {
			if (!E[_p].c && E[_p].v >= n) {
				p[i] = E[_p].v - n  + 1;
				vis[p[i]] = 1;
			}
		}
	}
	for (int i = 1; i <= n; i++) if (!vis[i]) r = i;
	for (int i = 1; i <= n; i++) vis[i] ^= 1;
	int s = 0, t = 0, u;
	Q[t++] = r;
	while (s < t) {
		u = Q[s++];
		for (int i = 0; i < vec[u].size(); i++) {
			int v = vec[u][i];
			if (!vis[p[v]]) {
				vis[p[v]] = 1;
				fa[p[v]] = u;
				Q[t++] = p[v];
			}
		}
	}
	for (int i = 1; i <= n; i++) if (!vis[i]) {puts("-1"); return 0;}
	for (int i = 1; i <= n-1; i++) printf("%d %d\n", p[i], fa[p[i]]);
	return 0;
}

Measured memory_bytes: 20608
#include<bits/stdc++.h> 
using namespace std; 
#define LL long long int
struct Node
{
    LL index;
    LL val;
};
int main() 
{ 
  
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    LL N;
    cin>>N;
    map<string,LL> hash;
    while(N--)
    {
        string S;
        cin>>S;
        hash[S]+=1;
    }
    cout<<"AC"<<" x "<<hash["AC"]<<endl;
    cout<<"WA"<<" x "<<hash["WA"]<<endl;
    cout<<"TLE"<<" x "<<hash["TLE"]<<endl;
    cout<<"RE"<<" x "<<hash["RE"]<<endl;
}

Measured memory_bytes: 3652