akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(3)
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define rint register int
#define INF ((1 << 30) - 1)
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define Pair pair < int, int >
#define mst(a,b) memset(a,b,sizeof(a))
#define foR(i, k, j) for(rint i = (k); i >= (j); i--)
#define For(i, k, j) for(rint i = (k); i <= (j); i++)
#define Foe(i, u) for(rint i = lst[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)
//#define int long long
const int P = 1000000007; //
using namespace std;
inline void ckmax(int &a, int b) {a = max(a, b);}
inline void ckmin(int &a, int b) {a = min(a, b);}
inline void mulmod(int &a, int b) {a = 1ll * a * b % P;}
inline void addmod(int &a, int b) {int t = a + b; a = (t >= P ? t - P : t); }
inline int ksm(int a, int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline int inv(int a) {return ksm(a, P-2);}

inline void printarray(int *a, int n) {For(i, 1, n) fprintf(stderr, "%d ", a[i]); fprintf(stderr, "\n");}
namespace FastIO {
    const int SIZE=1<<16; char buf[SIZE], obuf[SIZE], str[64]; int bi=SIZE, bn=SIZE, opt;
    int read(char *s) {
        while (bn) {for (;bi<bn&&buf[bi]<=' ';bi++);if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}
        int sn=0;while (bn) {for (;bi<bn&&buf[bi]>' ';bi++) s[sn++]=buf[bi];if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}s[sn]=0;return sn;
    }
    bool read(int& x) {if(x)x=0;int bf=0,n=read(str); if(!n) return 0; int i=0; if (str[i]=='-') bf=1,i=1; for(x=0;i<n;i++) x=x*10+str[i]-'0'; if(bf) x=-x; return 1;}
    void write(int x) {
        if(!x) obuf[opt++] = '0'; else {if(x<0) obuf[opt++]='-',x=-x;int sn=0; while(x)str[sn++]=x%10+'0',x/=10;for (int i=sn-1;i>=0;i--) obuf[opt++]=str[i];}
        if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}
    }
    void write(char x) {obuf[opt++]=x;if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}}
    void Fflush() { if (opt) fwrite(obuf, 1, opt, stdout); opt=0;}
};
const int MAXN = 2e5 + 5;
struct Node {
	int x, y, id;
	bool operator < (const Node &b) const {return x < b.x;}
}a[MAXN];
int n, f[MAXN], siz[MAXN];
inline int find(int x) {
	while(x != f[x]) x = f[x] = f[f[x]];
	return x;
}
inline void merge(int x, int y) {
	x = find(x), y = find(y);
	if(x != y) siz[x] += siz[y], f[y] = x;
} 
int s[MAXN], top, v[MAXN], ans[MAXN];
signed main()
{
    #ifndef ONLINE_JUDGE
        file("pro");
    #endif
    FI(n);
    For(i, 1, n) FI(a[i].x), FI(a[i].y), a[i].id = i, f[i] = i, siz[i] = 1;
	sort(a + 1, a + 1 + n);
	For(i, 1, n) {
		int y = a[i].y;
		while(top && v[top] < a[i].y) {merge(i, s[top]); ckmin(y, v[top]); top--; }
		s[++top] = i, v[top] = y;
	}
	For(i, 1, n)
		ans[a[i].id] = siz[find(i)];
	For(i, 1, n)
		FO(ans[i]), FO('\n');
	
    return FastIO::Fflush(), 0;
}
/*
Think twice :
mod ?
INF ?
n = 1 ?
long long ?
Fastio::Fflush() ?

*/


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

int main(){
    int N;
    cin >> N;
    int mo = 0;
    while(mo < N) {
        mo += 1000;
    }
    cout << mo - N << endl;
}

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

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int ans=1e9;
  for(int i=0;i<=max(x,y);++i){
    ans=min(ans,2*i*c+max(0,x-i)*a+max(0,y-i)*b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

typedef int64_t ll;


#define SPRE(x) setprecision(x) // 精度を指定

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

	string a,b,c;
	cin >> a >> b >> c;
	if(a.back() != b[0] || b.back() != c[0])
		cout << "NO\n";
	else
		cout << "YES\n";
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, a, b;

void solve() {
    int res0 = min(a, b);
    int res1 = max(0, b - (n - a));
    cout << res0 << " " << res1 << endl;
}

void input() {
    cin >> n >> a >> b;
}

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

    input();
    solve();
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * https://abc076.contest.atcoder.jp/tasks/abc076_d
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		char[] T = sc.next().toCharArray();
		sc.close();
		
		boolean f = false;
		for(int s=S.length-T.length; s>=0; s--){
			f = true;
			for(int i=0; i<T.length; i++){
				char c1 = S[s+i];
				char c2 = T[i];
				if(c1!='?'&&c1!=c2){
					f=false;
					break;
				}
			}
			if(f){
				for(int i=0; i<T.length; i++){
					S[s+i] = T[i];
				}
				break;
			}
		}
		
		String ans = "UNRESTORABLE";
		if(f){
			ans = new String(S);
			ans = ans.replaceAll("\\?", "a");
		}
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 23764
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
  int x[101],top=0,i;
  char s[101];
  while(scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      top--;
      x[top]=x[top]+x[top+1];
    }
    else if ( s[0] == '-' ){
      top--;
      x[top]=x[top]-x[top+1];
    }
    else if ( s[0] == '*' ){
      top--;
      x[top]=x[top]*x[top+1];
    } 
    else {
      top++; 
      x[top] = atoi(s);
    } 
  }
  printf("%d\n",x[1]);
  return 0;
}


Measured memory_bytes: 2144
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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 pfcount[100];

int main() {
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    int x = i;
    for(int y = 2; y * y <= x; y++) {
      while(x % y == 0) {
        x /= y;
        pfcount[y]++;
      }
    }
    if(x > 1) pfcount[x]++;
  }

  ll ans = 0;
  // x^2 * y^4 * z^4
  for(int i = 1; i < 100; i++) {
    if(pfcount[i] < 2) continue;
    for(int j = 1; j < 100; j++) {
      if(pfcount[j] < 4) continue;
      for(int k = 1; k < 100; k++) {
        if(i == j || i == k || j == k) continue;
        if(k > j) continue;
        if(pfcount[k] < 4) continue;
        ans++;
      }
    }
  }

  // x^2 * y^24
  for(int i = 1; i < 100; i++) {
    if(pfcount[i] < 2) continue;
    for(int j = 1; j < 100; j++) {
      if(i == j) continue;
      if(pfcount[j] < 24) continue;
      ans++;
    }
  }

  // x^4 * y^14
  for(int i = 1; i < 100; i++) {
    if(pfcount[i] < 4) continue;
    for(int j = 1; j < 100; j++) {
      if(i == j) continue;
      if(pfcount[j] < 14) continue;
      ans++;
    }
  }

  // x^74
  for(int i = 1; i < 100; i++) {
    if(pfcount[i] < 74) continue;
    ans++;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define _GLIBCXX_DEBUG

int main(){
  
  char a, b, c, d;
  cin >> a >> b >> c >> d;

  int arr[4] = {a - '0', b - '0', c - '0', d - '0'};

  rep(i, (1 << 3)){
    bitset<3> bs(i);
    int ans = arr[0];
    char c[3];

    rep(j, 3){
      if(bs[j]){
        ans += arr[j+1];
        c[j] = '+';
      }
      else{
        ans -= arr[j+1];
        c[j] = '-';
      } 
    }

    if(ans == 7){
      cout << arr[0];
      rep(j, 3) cout << c[j] << arr[j+1];
      cout << "=7" << endl;
      return 0;
    }
    
  }  

}


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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a.at(a.size()-1)==b.at(0)&&c.at(0)==b.at(b.size()-1)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, hi):
    ans = 0
    for i in range(max(hi)):
        flg = False
        for n in range(N):
            if hi[n] != 0:
                if not flg:
                    flg = True
                    ans += 1
                hi[n] -= 1
            else:
                flg = False
    print(ans)


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    hi = [int(i) for i in input().split()]
    # Bi = [int(i) for i in input().split()]
    # ABi = [[int(i) for i in input().split()] for _ in range(N)]
    solve(N, hi)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;


void solve()
{
    int w, h, n; cin >> w >> h >> n;
    int s[4] = {0, w, 0, h};
    REP(i, n)
    {
        int x, y, a; cin >> x >> y >> a;
        if(a == 1) s[0] = max(s[0], x);
        else if(a == 2) s[1] = min(s[1], x);
        else if(a == 3) s[2] = max(s[2], y);
        else s[3] = min(s[3], y);
    }

    int x = s[1] - s[0], y = s[3] - s[2];
    if(x <= 0 || y <= 0) cout << 0 << endl;
    else cout << x * y << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

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

namespace AtCoder_Beginner_Contest_131
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var ABCD = Sarray();
            var A = ABCD[0];
            var B = ABCD[1];
            var C = ABCD[2];
            var D = ABCD[3];
            var lcm = Lcm(C, D);
            var Cnum = B / C - (A-1) / C;
            var Dnum = B / D - (A-1) / D;
            var CDnum = B / lcm - (A-1) / lcm;
            WriteLine(B - A + 1 - (Cnum + Dnum - CDnum));
        }
        public static long Gcd(long m, long n)
        {
            long temp;
            while (m % n != 0)
            {
                temp = n;
                n = m % n;
                m = temp;
            }
            return n;
        }
        public static long Lcm(long m, long n)
        {
            return m * n / Gcd(m, n);
        }
    }
}


Measured memory_bytes: 13396
from collections import Counter

n = int(input())
l = []
for i in range(n):
    l.append(input())
n = int(input())
l2 = []
for i in range(n):
    l2.append(input())
l = Counter(l)
l2 = Counter(l2)
m = [0]
for i in l.keys():
    try:
        m.append(l[i] - l2[i])
    except:
        pass
print(max(m))

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

typedef long long ll;

using namespace std;

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;

    int x_max = x;
    int y_min = y;

    for (int i = 0; i < n; i++) {
        int xi;
        cin >> xi;

        if (x_max < xi) {
            x_max = xi;
        }
    }

    for (int i = 0; i < m; i++) {
        int yi;
        cin >> yi;

        if (y_min > yi) {
            y_min = yi;
        }
    }

    if (x_max < y_min) {
        cout << "No War";
    } else {
        cout << "War";
    }


    return 0;
}

Measured memory_bytes: 3640
#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>;

int main() {
  int n;
  cin >> n;
  vector<ll> l(n+1);
  l[0] = 2;
  l[1] = 1;
  for (int i = 2; i <= n; ++i) l[i] = l[i-1] + l[i-2];
  cout << l[n] << endl;
  return 0;
}

Measured memory_bytes: 3564
#include<cstdio>

int main(){
	int n,k=100000;
	scanf("%d",&n);
	for(;n>0;n--){
		k+=k/20;
		if(k%1000){
			k+=1000;
		}
		k-=k%1000;
	}
	printf("%d\n",k);
	return 0;
}

Measured memory_bytes: 0
#include <string.h>

#include <algorithm>
#include <iostream>
#include <vector>

#define rep1(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define MOD 1000000007

using namespace std;
using ll = long long;

long long modinv(long long, long long);

int main(void) {
  int S;
  cin >> S;
  int n = S / 3;

  ll sum = 0;
  ll bunshi = 1;
  ll bunbo1 = 1;
  ll bunbo2 = 1;
  ll bunboProduct;
  ll temp;

  if (n <= 0) {
    cout << 0 << endl;
    return 0;
  }

  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }

  for (int i = 2; i <= n; i++) {
    for (int j = S - 2 * i - 1; j > 0; j--) {
      bunshi *= j;
      bunshi %= MOD;
    }

    for (int j = i - 1; j > 0; j--) {
      bunbo1 *= j;
      bunbo1 %= MOD;
    }
    for (int j = (S - 3 * i); j > 0; j--) {
      bunbo2 *= j;
      bunbo2 %= MOD;
    }

    bunboProduct = bunbo1 * bunbo2;
    bunboProduct %= MOD;

    temp = bunshi * modinv(bunboProduct, MOD);
    temp %= MOD;

    sum += temp;
    sum %= MOD;
    bunshi = 1;
    bunbo1 = 1;
    bunbo2 = 1;
  }

  cout << (sum + 1) << endl;
  return 0;
}

//(a/b)%MODの方法
// a * modinv(b, MOD) % MOD;

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int inf = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	char a;
	int count = 0;
	rep(i, H) {
		rep(j, W) {
			cin >> a;
			if (a == '#')count++;
		}
	}
		cout << (count == H + W - 1 ? "Possible" : "Impossible") << endl;
	return 0;
}

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

using namespace std;


void answer(){
    int n,ans=0,m;
    cin>>n>>m;
    ans = max(0,n-2*m);
    cout<<ans<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        answer();
    return 0;
}

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

long long const mod = 998244353;
long long A[3100] = {};
long long dp[3100][3100] = {};
long long sum[3100] = {};

int main() {
    int N, S; cin >> N >> S;
    for(int i=1; i<=N; ++i) cin >> A[i];

    for(int i=1; i<=N; ++i) {
        for(int j=1; j<=S; ++j) {
            if(j < A[i]) {
                continue;
            } else if(j == A[i]) {
                dp[i][j] = i;
            } else {
                dp[i][j] = sum[j - A[i]];
            }
        }
        for(int j=1; j<=S; ++j) sum[j] = (sum[j] + dp[i][j]) % mod;
    }

    long long res = 0;
    for(int i=1; i<=N; ++i) res = (res + dp[i][S] * (N + 1 - i) % mod) % mod;
    cout << res << '\n';        
}

Measured memory_bytes: 73856
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n, k, x, y,z;
	    scanf("%d", &n);
		scanf("%d", &k);
		scanf("%d", &x);
		scanf("%d", &y);
			if (n > k)
		{
			z = x * k + y * (n - k);
			printf("%d\n", z);
		}
		else
		{
			z = n * x;
			printf("%d\n", z);
		}
	system("pause");
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    ll resh=0, resw=0, resn=0;
    for(ll h=1; h<=3500; h++){
        for(ll w=h; w<=3500; w++){
            if(4*h*w-n*(h+w)==0 || 4*h*w-n*(h+w)<0) continue;
            if((n*h*w)%(4*h*w-n*(h+w))==0){
                resh = h;
                resw = w;
                resn = (n*h*w)/(4*h*w-n*(h+w));
                break;
            }
        }
        if(resh!=0) break;
    }
    cout << resh << " " << resw << " "  << resn << endl;
}

Measured memory_bytes: 3624
// Author: droftware
#include <bits/stdc++.h>

#define forn(i,a,n) for(int i=a;i<(int)n;i++)
#define DRT()  int t; cin>>t; while(t--)

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif
using namespace std;

const int N = 1e5+5;
vector<int> graph[N];
int dp[N];

int dfs(int x){
	if(dp[x] != 0)
		return dp[x];
	int q = 0;
	for(int node:graph[x]){
		q = max(q, dfs(node));
	}
	return dp[x] = q + 1;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	forn(i,1,n+1){
		dp[i] = 0;
	}
	forn(i,0,m){
		int a,b;
		cin>>a>>b;
		graph[a].push_back(b);
	}
	int res = 0;
	forn(i,1,n+1){
		res = max(res, dfs(i));
	}
	cout<<res-1<<endl;
}
	
	



Measured memory_bytes: 8192
// Problem : A - Darker and Darker
// Contest : AtCoder - AtCoder Grand Contest 033
// URL : https://atcoder.jp/contests/agc033/tasks/agc033_a
// Memory Limit : 1024 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
int x[]={-1,1,0,0},y[]={0,0,-1,1};
int h,w;
int a[1000][1000]={0};
bool valid(int x,int y)
{
	if(x>=0 && x<h && y>=0 && y<w && a[x][y]!=1)
		return true;
	return false;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	cin>>h>>w;
	stack<pi> v,cv;
	loop(i,h)
		loop(j,w)
		{
			char c;
			cin>>c;
			if(c == '#')
			{
				a[i][j]=1;
				v.push({i,j});
			}
		}
		int ans=0;
	for(int j=0;!v.empty(); j++)
	{
		while(!v.empty())
		{
			pi p;
			p=v.top();
			v.pop();
			loop(i,4)
			{
				if(valid(p.f+x[i],p.s+y[i]))
				{
					cv.push({p.f+x[i],p.s+y[i]});
					a[p.f+x[i]][p.s+y[i]]=1;
				}
			}
		}
		ans=j;
		while(!cv.empty())
		{
			v.push(cv.top());
			cv.pop();
		}
	}
	cout<<ans<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 15516
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class4
    {
        static void Main()
        {
            string S = Console.ReadLine();
            string R;
            if (S == "Sunny")
                R = "Cloudy";
            else if (S == "Cloudy")
                R = "Rainy";
            else
                R = "Sunny";
            Console.WriteLine(R);
        }
        
        
    }
}


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

int main(){
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d,vector<int>(26));
  int i,j;
  for(i=0;i<26;i++){
    cin >> c.at(i);
  }
  
  for(j=0;j<d;j++){
    for(i=0;i<26;i++){
      cin >> s.at(j).at(i);
    }
  }
  
  
  vector<int> last(26,-1);
  for(j=0;j<d;j++){
    vector<int> v(26);
    for(i=0;i<26;i++){
      v.at(i)=s.at(j).at(i);
      int k;
      for(k=0;k<26;k++){
        if(k!=i){
          v.at(i) -= c.at(k)*(j-last.at(k));
        }
      }
    }
    int max=v.at(0),type=0;
    for(i=0;i<26;i++){
      if(max<=v.at(i)){
        max=v.at(i);
        type=i;
      }
    }
    last.at(type)=j;
    cout << type+1 << endl;
  }
}

Measured memory_bytes: 3684
import java.util.Scanner;


//Print a Rectangle
//
//たてH cm よこ W cm の長方形を描くプログラムを作成して下さい。
//
//1 cm × 1cm の長方形を '#'で表します。
//Input
//
//入力は複数のデータセットから構成されています。各データセットの形式は以下のとおりです：
//
//H W
//
//H, W がともに 0 のとき、入力の終わりとします。
//Output
//
//各データセットについて、H × W 個の '#' で描かれた長方形を出力して下さい。
//
//各データセットの後に、１つの空行を入れて下さい。
//Constraints
//
//H, W ? 300
//Sample Input
//
//3 4
//5 6
//2 2
//0 0
//
//Sample Output
//
//####
//####
//####
//
//######
//######
//######
//######
//######
//
//##
//##


public class Main {
    public static void main(String[] args) {

    	/*Scanner = テキスト入力を扱うためのクラス
		 *キーボードからの入力を受けつける場合は
		 *System.inを使って下記のように記述
		 */
		Scanner scan = new Scanner(System.in);

		//forループ文用に変数準備
		int i;
		int j;

		/*while文で無限ループ設定
		 * if文でbreakをかける
		 * 求められている通りになったがコードが無駄に多いように思える
		 * 後程修正を行えるか試す
		 */

		while(true){
			int H = scan.nextInt();
			int W = scan.nextInt();

		//Constraintsの条件も追加しました。
			if(H == 0 && W == 0 || H >= 300 || W >= 300)break;
			for(j = 0; j < H; j++){
				for(i = 0; i < W; i++){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
    }
}

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

using namespace std;

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

	int N, K;
	cin >> N >> K;
	vector<int> v(N);
	for(auto &i : v) cin >> i;

	vector<int> dp(K+1, 0);

	for(int i=1; i<=K; i++)
		for(int j=0; j<N; j++)
			if(i-v[j] >= 0 && dp[i-v[j]] == 0) dp[i] = 1;
	cout << (dp[K] == 1 ? "First" : "Second");
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    string s,t;cin>>s>>t;
    if(s==t.substr(0,t.size()-1)&&s.size()==t.size()-1)co("Yes");
    else co("No");
}


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

int main() {
  string S;
  cin >> S;
  
  if(S[0] == 'R'){
    if(S[1] == 'R'){
      if(S[2] =='R'){
        cout << 3 << endl;
      } else {
        cout << 2 << endl;
      }
    } else {
      cout << 1 << endl;
    }
  } else {
    if(S[1] =='R'){
      if(S[2] == 'R'){
        cout << 2 << endl;
      } else {
        cout << 1 << endl;
      }
    } else if(S[2] == 'R'){
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }
}


Measured memory_bytes: 3592
from itertools import product

S = input()
n = len(S) - 1
ans = 0
for p in product([True, False], repeat=n):
    x = 0
    s = ''
    for i in range(n):
        s += S[i]
        if p[i]:
            x += int(s)
            s = ''
    s += S[-1]
    x += int(s)
    ans += x
print(ans)

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

using namespace std;

int n, q;
int s[100000], t[50000];

int bsearch(int target) {

    int left = 0;
    int right = n;
    int mid;

    while(left < right) {
        mid = (left + right) / 2;

        if(s[mid] == target) {
            return 1;
        } else if(s[mid] < target) {
            left = mid + 1;
        } else {
            right = mid;
        }
    }

    return 0;

}

int main() {

    int sum = 0;

    cin >> n;

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

    cin >> q;

    for(int i = 0; i < q; ++i) {
        cin >> t[i];
        sum += bsearch(t[i]);
    }

    cout << sum << endl;

}

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

typedef long long int ll;
using namespace std;

int main()
{

    ll H, N;
    cin >> H >> N;

    ll inf = 999999999;

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

    vector<ll> dp(H + 1, inf);

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

        cin >> A[i] >> B[i];
    }

    dp[0] = 0;

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

        for (int j = 0; j <= H; j++)
        {

            int nj = min(j + A[i], H);
            dp[nj] = min(dp[nj], dp[j] + B[i]);
        }
    }

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	double a[1005];
	double y=1;
	int sum=0;
	for(int i=1;i<=1000;i++)
	{
		sum+=i;
		a[i]=sum*y/i;
	}
	//cout<<a[6];
	int n,k;
	cin>>n>>k;
	int b[200005];
	vector<double>c;
	for(int i=1;i<=n;i++)
	cin>>b[i];
	for(int i=1;i<=k;i++)
	{
		y+=a[b[i]];
	}
	c.push_back(y);
	for(int i=k+1;i<=n;i++)
	{
		y=y-a[b[i-k]]+a[b[i]];
		c.push_back(y);
	}
	y=0;
	for(vector<double>::iterator it=c.begin();it!=c.end();it++)
    if(*it>y)
    y=*it;
	printf("%0.12f",y-1);
} 

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

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

    long n = 1;
    long s = 1;
    while (h != 1) {
        n *= 2;
        s += n;
        h /= 2;
    }

    cout << s << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n,k;
	cin>>n>>k;
	Matrix pos(2*k,Array(2*k,0));
	REP(i,n){
		ll x,y;
		string c;
		cin>>x>>y>>c;
		if(c=="W"){
			pos[x%(2*k)][y%(2*k)]++;//(x,y)W->(x%2k, y%2k)Wと同じ
		}else{
			pos[(x+k)%(2*k)][y%(2*k)]++;//(x,y)B->(x+k,y)Wと同じ
		}
	}

	Matrix sum(4*k+1,Array(4*k+1,0));
	
	REP(i,4*k){
		REP(j,4*k){
			sum[i+1][j+1]=sum[i+1][j]+sum[i][j+1]-sum[i][j] + pos[i%(2*k)][j%(2*k)];//累積和
		}
	}

	ll ans=0;
	REP(i,2*k){
		REP(j,2*k){
			//(i,j)->(i+k,j+k)がWの時
			ll now = sum[i+k][j+k]-sum[i+k][j]-sum[i][j+k]+sum[i][j]
				+sum[i+2*k][j+2*k]-sum[i+2*k][j+k]-sum[i+k][j+2*k]+sum[i+k][j+k];
			chmax(ans,now);
		}
	}	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 156800
def slove():
    import sys
    input = sys.stdin.readline
    x = int(input().rstrip('\n'))
    cnt = (x + 10) // 11 * 2
    if x % 11 <= 6 and x % 11 != 0:
        print(cnt-1)
    else:
        print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
using System;

class Program
    {
        static void Main()
        {
            Console.ReadLine();
            int[] num = TypeConverter.arrayStrToInt(Console.ReadLine().Split(' '));

            Array.Reverse(num);

            Console.WriteLine(string.Join(" ", TypeConverter.arrayIntToStr(num)));
        }
    }

    class TypeConverter
    {
        static public int[] arrayStrToInt(string[] str)
        {
            return Array.ConvertAll<string, int>(str,
                delegate(string value)
                {
                    return int.Parse(value);
                }
            );
        }

        static public string[] arrayIntToStr(int[] x)
        {
            return Array.ConvertAll<int, string>(x,
                delegate(int value)
                {
                    return value.ToString();
                }
            );
        }
    }

Measured memory_bytes: 5656
#include <iostream>

using namespace std;

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

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

    if ((a == b || b == c || c == a) && (a != b || b != c || c != a)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline().strip())

array = [None for _ in range(2**N)]
for i in range(int(2**N)):
    array[i] = int(sys.stdin.readline().strip())

for stage in range(N):
    for i in range(int(2**(N-stage-1))):
        tmp = abs(array[i*2] - array[i*2+1])
        array[i] = tmp if tmp != 0 else array[i*2]
        #print(array)

print(array[0])

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  st s;
  cin >> s;
  vst check = {"dream", "dreamer", "erase", "eraser"};
  reverse(all(s));
  vrep(i, check) reverse(all(i));
  
  ll count = 0;
  bool ans = 1;
  while(count < s.size()){
    bool flag = 0;
    vrep(i, check){
      if(i == s.substr(count, i.size())){
        count += i.size();
        flag = 1;
      }
    }
    if(!flag){
      ans = 0;
      break;
    }
  }
  cout << (ans ? "YES" : "NO") << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            int H = int.Parse(s[0]);
            int W = int.Parse(s[1]);

            int count = 0;

            bool[][] panel = new bool[W][];
            for(int i=0;i<W;i++)
            {
                panel[i] = new bool[H];
            }

            var x = new List<int>();
            var y = new List<int>();

            for(int i=0;i<H;i++)
            {
                char[] data = Console.ReadLine().ToCharArray();

                for (int j=0;j<W;j++)
                {
                    if (data[j] == '.')
                    {
                        panel[j][i] = true;
                        count++;
                    }
                    else
                    {
                        x.Add(j);
                        y.Add(i);
                        panel[j][i] = false;
                    }
                }
            }

            while(count !=0)
            {
                ans++;

                var x2 = new List<int>();
                var y2 = new List<int>();


                for (int i=0;i<x.Count;i++)
                {
                    if(x[i] !=0)
                    {
                        if(panel[x[i]-1][y[i]])
                        {
                            panel[x[i] - 1][y[i]] = false;
                            count--;
                            x2.Add(x[i] - 1);
                            y2.Add(y[i]);
                        }
                    }
                    if (x[i] != W-1)
                    {
                        if (panel[x[i] + 1][y[i]])
                        {
                            panel[x[i] + 1][y[i]] = false;
                            count--;
                            x2.Add(x[i] + 1);
                            y2.Add(y[i]);
                        }
                    }
                    if (y[i] != 0)
                    {
                        if (panel[x[i]][y[i]-1])
                        {
                            panel[x[i]][y[i]-1] = false;
                            count--;
                            x2.Add(x[i]);
                            y2.Add(y[i]-1);
                        }
                    }
                    if (y[i] != H-1)
                    {
                        if (panel[x[i]][y[i] + 1])
                        {
                            panel[x[i]][y[i] + 1] = false;
                            count--;
                            x2.Add(x[i]);
                            y2.Add(y[i] + 1);
                        }
                    }
                }

                x = x2;
                y = y2;
            }




            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 36308
n, k = map(int, input().split())
p = list(map(int,input().split()))
q = [(x+1)/2 for x in p]
q1 = sum(q[:k])
ans = q1

for i in range(n-k):
  x = q1-q[i] +q[i+k]
  q1 = x
  if ans < x:
    ans = x
  
print(ans)

Measured memory_bytes: 32024
def main():
    n, k, s = map(int, input().split())

    maxmax = s+1
    if maxmax == 10**9+1:
        maxmax = s-1

    ans_list = [maxmax]*n

    if k == 0:
        print(*ans_list)
        exit()

    if k == 1:
        ans_list[0] = s
        print(*ans_list)
        exit()

    if s == 1:
        for i in range(k):
            ans_list[i] = 1
        print(*ans_list)
        exit()

    if k != n:
        first = s // 2
        second = s - first
        for i in range(k):
            if i % 2 == 0:
                ans_list[i] = first
            else:
                ans_list[i] = second
        ans_list[n-1] = s
    else:
        for i in range(k):
            ans_list[i] = s       
        
    print(*ans_list)
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 46268
N=int(input())
a=list(map(int,input().split()))
import collections

a=sorted(a)
mi=a[0]
g=0
k=0
t=0
gset=set()
loopnum=len(a)-1
i=1
while i<=loopnum:
    if(0<a[i]%mi<mi):
        a.append(mi)
        mi=a[i]%mi
        loopnum+=1
    i+=1
        
if(t==N-1):
    print(mi)
else:
    print(mi)

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

int main(){
  ll D,N,count=0;
  cin >> N >> D;
  cout << endl;
  
  vector<ll> x(N);
  vector<ll> y(N);
  
  
  rep(i,N){
    cin >> x.at(i) >> y.at(i);
    ll a=D*D-x.at(i)*x.at(i)-y.at(i)*y.at(i);
    if(a>=0) count++;
  }
  
  cout << count << endl;

}
  


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

const int INF = 1e9+7;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
	int n,m;
	cin >> n >> m;
	if(m == n){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    vector<int> X(M);
    for (int i = 0; i < M; ++i) {
        cin >> X[i];
    }

    sort(begin(X), end(X));

    vector<int> d(M);
    d[0] = 0;
    for (int i = 1; i < M; ++i) {
        d[i] = X[i] - X[i-1];
    }

    sort(begin(d), end(d));

    int ans = 0;
    for (int i = 0; i < M-N+1; ++i) {
        ans += d[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
using System;

namespace ABC155
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);

            if(a==b && b== c & c == a)
            {
                Console.WriteLine("No");
            }else if(a== b || a==c || b == c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }



        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

vector<vector<int>> adjacent;
vector<pair<int, int>> ans;
vector<bool>checked;

//?????????is????????????
int dfs(int now,int time = 1) {
	ans[now].first = time;
	checked[now] = true;
	for (int i = 0; i < adjacent[now].size(); i++) {
		if (!checked[adjacent[now][i]]) {
			time = dfs(adjacent[now][i], time + 1);
		}
	}
	ans[now].second = time+1;
	return time + 1;
}

int main() {
	int n;
	cin >> n;
	adjacent = vector<vector<int>>(n);
	checked = vector<bool>(n, false);
	ans.resize(n);

	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			adjacent[u - 1].push_back(v-1);
		}
	}
	
	int time = dfs(0, 1)+1;
	for (int i = 0; i < n; i++) {
		if (!checked[i])time = dfs(i, time)+1;
	}
	
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << ans[i].first << " " << ans[i].second << endl;
	}

}

Measured memory_bytes: 3112
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll N,K,cnt;
int l,r, ans = 0;
string S;
vector<pii> ranges;

void solve(){
    ranges.push_back(make_pair(0,1));

    S.push_back('1');
    bool flag = false; //Counting?

    rep(i,N+1){
        if(S[i]=='0' && !flag){
            l = i+1;
            // cout << "l is " << l << endl;
            flag = true;
        }
        else if(S[i]=='1' && flag){
            r = i+1;
            // cout << "r is " << r << endl;
            ranges.push_back(make_pair(l,r));
            flag = false;
        }
    }

    ranges.push_back(make_pair(N+1,N+2));

    // rep(i,ranges.size())
    //     printf("(%d, %d)\n",ranges[i].first, ranges[i].second);

    cnt = ranges.size() - 2;
    K = min(cnt, K);

    // printf("cnt: %lld, K: %lld\n",cnt, K);

    rep(i, cnt - K + 1)
        ans = max(ranges[i+K+1].first - ranges[i].second, ans);

    cout << ans << endl;
}

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

    solve();
}


Measured memory_bytes: 1020
#include <stdio.h>

int main(int argc, char *argv[])
{
	int k,i,total=0;
	scanf("%d",&k);
	if(k%2==0||k%5==0)goto rr;
	for(i=1;i<=1e7;i++){
		total=total*10+7;
		total%=k;
		if(!total){
			printf("%d",i);
			return 0;
		}
	}
	rr:
	printf("-1");
}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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; }

int N;
vector<int> H(100010);
vector<int> H1(100010);
vector<int> H2(100010);
int MAX_N = 100000;

vector<ll> dp(100010, INF);

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> N;
    REP(i, N) {
        cin >> H.at(i);
    }
    for (int i = 0; i < N - 1; i++) {
        H1.at(i) = abs(H.at(i) - H.at(i + 1));
    }
    for (int i = 0; i < N - 2; i++) {
        H2.at(i) = abs(H.at(i) - H.at(i + 2));
    }

    dp.at(0) = 0;

    for (int i = 0; i < N; i++){
        chmin(dp.at(i + 1), dp.at(i) + H1.at(i));
        chmin(dp.at(i + 2), dp.at(i) + H2.at(i));
    }

    cout << dp.at(N-1) << endl; 

    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
using namespace std;
int main(void){
    int a = 0, b = 0, c = 0;
    cin >> a >> b >> c;

    int swp = 0;
    
    if( a > b ){
        swp = b;
        b = a;
        a = swp;
    }
    
    if( b > c ){
        swp = c;
        c = b;
        b = swp;
    }
    
    if( a > b ){
        swp = b;
        b = a;
        a = swp;
    }

    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 1164
from sys import stdin
input = stdin.readline

X,K,D = map(int, input().split())
X=abs(X)
if(X>K*D):
  print(X-K*D)
elif(X>=D):
  m = X % D
  q = X//D
  K = K-q
  if(K==0):
    print(m)
  elif(K%2==1):
    print(abs(m-D))
  else:
    print(m)
else:
  if(K%2==1):
    print(abs(X-D))
  else:
    print(X)
  
    


Measured memory_bytes: 9116
//
// Created by yjq on 2019/11/5.
//

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define  int ll
const int maxn = 4010;
int a[maxn * 2], n, x;
ll s[maxn * 2];
bool vis[maxn * 2];

struct line {
    int num, l;

    bool operator<(const line &b) const {
        return num > b.num;
    }
};

priority_queue<line> q;

ll get_ans(int t) {
    while(!q.empty())q.pop();
    int ans = s[n] + t * x;
    if (t == 0)return ans;
    for (int i = n - t + 1; i <= n; ++i)q.push({a[i], i});
    for (int i = n + 1; i <= n + n; ++i) {
        while (!q.empty() && q.top().l < i - t)q.pop();
        ans -= max(0ll, a[i] - q.top().num);
        q.push({a[i], i});
    }
    return ans;
}

//int
main() {
    __;
    cin >> n >> x;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n + n; ++i) {
        if (i > n)a[i] = a[i - n];
        s[i] = s[i - 1] + a[i];
    }
    ll ans = s[n];
    for (int y = 0; y < n; ++y) {
        ans = min(ans, get_ans(y));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	string s;
	cin >> s;
	int size = s.size();
	cout << s.front() << size - 2 << s.back() << endl;
	return 0;
}

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

int bubbleSort(int A[], int N){
    int sw = 0;
    for(int i = 0; i < N; i++){
        for(int j = N - 1; j >= i + 1; j--){
            if(A[j] < A[j - 1]){
                swap(A[j], A[j - 1]);
                sw++;
            }
        }
    }
    return sw;
}

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

    int sw = bubbleSort(A, N);

    for(int i = 0; i < N - 1; i ++){
        cout << A[i] << ' ';
    }

    cout << A[N - 1] << endl;
    cout << sw << endl;

    return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> vec1(N, 0);

    int a_i, b_i;
    for (int i = 0; i < M; ++i) {
        cin >> a_i >> b_i;
        vec1.at(a_i - 1) += 1;
        vec1.at(b_i - 1) += 1;
    }
    for (int j = 0; j < N; ++j) {
        cout << vec1.at(j) << endl;
    }
}


Measured memory_bytes: 256
a = list(input())
a.append('0')
b = list(input())
b.append('0')
c = list(input())
c.append('0')
p = 0

while True:
    if p == 0:
        y = a.pop(0)
        if len(a) == 0:
            print('A')
            exit(0)
    elif p == 1:
        y = b.pop(0)
        if len(b) == 0:
            print('B')
            exit(0)
    else:
        y = c.pop(0)
        if len(c) == 0:
            print('C')
            exit(0)
    if y == 'a':
        p = 0
    elif y == 'b':
        p = 1
    else:
        p = 2

Measured memory_bytes: 9044
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int N,M,i,temp,ans;
	vector<int> X,Dis;
	cin>>N>>M;
	for(i=0;i<M;i++){
		cin>>temp;
		X.push_back(temp);
	}
	sort(X.begin(),X.end());
	if(X.size()<=N){
		cout<<0;
	}else{
		for(i=1;i<M;i++){
			Dis.push_back(X.at(i)-X.at(i-1));
		}
		sort(Dis.begin(),Dis.end());
		ans=X.at(M-1)-X.at(0);
		for(i=0;i<N-1;i++){
			ans-=Dis.at(M-2-i);
		}
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 1400