akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int a[10001];
int main() {
	int n, m;
	cin >> n >> m;
	int x, y;
	fill(a, a + n + 1, 0);
	a[0] = m;
	int sum = m;
	bool l = true;
	for (int i = 1; i <= n; i++) {
		cin >> x >> y;
		a[i] = a[i-1]+(x - y);
		sum = max(a[i], sum);
		if (a[i] < 0) l = false;
	}
	if (!l) {
		cout << 0 << endl;
	}
	else {
		cout << sum << endl;
	}
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int N,K;cin >> N >> K;
        //vector<vector<int>> vec(N, vector<int>(N, 1)
    vector<pair<int,int>> anses;
    for(int i = 0;i < N-1;i++){
        for(int j = i+1;j < N;j++){
            if(K && j != N-1){
                K--;
              //  cout<<"A"<<endl;
                continue;
            }
            anses.push_back({i+1, j+1});

        }
    }
    if(K != 0){
        cout<<-1<<endl;
    }else{
        cout<<anses.size()<<endl;
        for(int a = 0;a < anses.size();a++){
            cout<<anses.at(a).first<<" "<<anses.at(a).second<<endl;
        }
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
struct __test {} test;
using namespace std;
template <typename T>const __test &operator<<(const __test& d,
const T& v) {return cerr << "\033[31m" << v << "\033[0m",d;}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

const int N = 1e5+5;
int A[N],B[N],n;
map<int,int> loc;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> A[i];
		B[i] = A[i];
	}
	sort(B,B+n);
	for(int i = 0; i < n; ++i)
		loc[B[i]] = i;
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		ans += loc[A[i]]%2 != i%2;
	}
	cout << ans/2 << "\n";
}

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

int c[33], s[444][33];
int sco(int t, const vector<int> &v) {
    int r = 0, l = 0, d = v.size();
    for(int i = 0; i < d; i++)
        if(v[i] == t)
            r += s[i][t] - c[t] * (i + 1 - l) * (i - l) / 2, l = i + 1;
    r -= c[t] * (d + 1 - l) * (d - l) / 2;
    return r;
}
int main() {
    int d;
    cin >> d;
    for(int i = 0; i < 26; i++)
        cin >> c[i];
    for(int i = 0; i < d; i++)
        for(int j = 0; j < 26; j++)
            cin >> s[i][j];
    vector<int> ss, tt;
    int M = -1e9;
    for(int a = 10; a < 16; a++) {
        for(int b = 0; b < 4; b++) {
            for(int z = 5; z < 16; z++) {
                int r = 0, l[33] = {};
                ss.clear();
                for(int i = 0; i < d; i++) {
                    auto m = 0.;
                    int t = 0;
                    for(int j = 0; j < 26; j++) {
                        double p = s[i][j];
                        p += c[j] * (i + 1 - l[j]) * .4 * a;
                        for(int k = 1; k < z; k++)
                            if(i + k < d)
                                p -= s[i + k][j] * (z - k) * .05 / z * b;
                        if(p > m)
                            m = p, t = j;
                    }
                    ss.push_back(t);
                    r -= c[t] * (i + 1 - l[t]) * (i - l[t]) / 2;
                    l[t] = i + 1;
                    r += s[i][t];
                }
                for(int j = 0; j < 26; j++)
                    r -= c[j] * (d + 1 - l[j]) * (d - l[j]) / 2;
                if(r > M)
                    M = r, tt.swap(ss);
            }
        }
    }
    random_device rd;
    mt19937 mt(rd());
    uniform_int_distribution<> rc(0, 25), r0(0, d - 1), r2(1, 6);
    uniform_real_distribution<> ru(0, 1);
    int cnt = 0;
    auto ti = clock();
    for(;;) {
        auto T = (clock() - ti) / 1.9 / CLOCKS_PER_SEC;
        if(T > 1)
            break;
        auto U = pow(2e3, 1 - T) * pow(6e2, T);
        for(int cn = 0; cn < 100; cn++, cnt++) {
            if(rc(mt) < 13) {
                int x0 = r0(mt), xc = rc(mt);
                int z = tt[x0];
                int di = -sco(z, tt) - sco(xc, tt);
                tt[x0] = xc;
                di += sco(z, tt) + sco(xc, tt);
                if(ru(mt) > exp(di / U))
                    tt[x0] = z;
                continue;
            }
            int x2 = r2(mt);
            uniform_int_distribution<> r1(0, d - 1 - x2);
            int x1 = r1(mt);
            x2 += x1;
            int di = -sco(tt[x1], tt) - sco(tt[x2], tt);
            swap(tt[x1], tt[x2]);
            di += sco(tt[x1], tt) + sco(tt[x2], tt);
            if(ru(mt) > exp(di / U))
                swap(tt[x1], tt[x2]);
        }
    }
    M = 0;
    for(int j = 0; j < 26; j++)
        M += sco(j, tt);
    for(int i : tt)
        cout << i + 1 << '\n';
    cerr << M << endl;
    cerr << cnt << endl;
    return 0;
}


Measured memory_bytes: 4376
input_line = input().split()
x = int(input_line[0])
k = int(input_line[1])
d = int(input_line[2])

x = abs(x)
y = int(x/d)

if y < k:
  x -= y * d
  if (k-y) % 2 == 1:
    x -= d

else:
  x -= k*d
    
print(abs(x))


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

int main()
{
    char x[5];
    scanf("%s",&x);
    if(x[0]==x[1] && x[0]==x[2])
    printf("No\n");
    else printf("Yes\n");
    return 0;
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif

    int h,a;
    cin>>h>>a;
    cout<<(h+a-1)/a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 200005, MAXM = 3003, Mod = 1000000007 , MAXLog = 20;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    vector<pair<int, int>> arr(5);
    for (int i = 0; i < 5; ++i) {
        cin >> arr[i].second;
        arr[i].first = (10 - (arr[i].second % 10)) % 10;
    }
    sort(arr.begin(), arr.end());

    int cur = 0;
    for (int i = 0; i < 5; ++i) {
        if (cur % 10 != 0) {
            cur += 10 - (cur % 10);
        }
        cur += arr[i].second;
    }

    cout << cur << '\n';

    return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

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

void solve() {
  ll L, R;
  cin >> L >> R;
  ll ans = INF;
  for (ll i = L; i < R; i++) {
    for (ll j = i + 1; j <= R; j++) {
      ans = min(ans, (i * j) % 2019LL);
      if (ans == 0) break;
    }
    if (ans == 0) break;
  }
  cout << ans << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;

    int a[n][3];
    int dp[n][3];
    for(int i=0;i<n;i++)
    {
            cin>>a[i][0]>>a[i][1]>>a[i][2];
            dp[i][0]=dp[i][1]=dp[i][2]=INT_MIN;

    }
    
  
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {   for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(k==j)
                 continue;
                 dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);

            }
        }
    }
   
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
   



}

Measured memory_bytes: 2560
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str  = sc.nextLine();
        String[] astr = str.split(""); //状況に合わせて
        sc.close();
        Boolean flag = true;

        for(int i=0;i<astr.length;i++){
            if(i%2 == 0){
                flag = check1(astr[i]);
            }
            else{
                flag = check2(astr[i]);
            }
            if(flag == false){
                System.out.println("No");
                System.exit(0);
            }
        }
        System.out.println("Yes");
    }
    public static Boolean check1(String a){
        if(a.equals("R")||a.equals("U")||a.equals("D")){
            return true;
        }else{
            return false;
        }
    }

    public static Boolean check2(String b){
        if(b.equals("L")||b.equals("U")||b.equals("D")){
            return true;
        }else{
            return false;
        }
    }
}

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

int main()
{
    int table[] = { 0, 6000, 4000, 3000, 2000 };
    for ( int i = 0; i < 4; i++ ) {
        int t, n;
        cin >> t >> n;
        cout << table[t] * n << endl;
    }
    return ( 0 );
}



Measured memory_bytes: 3116
#include <stdio.h>
#include <math.h>

int main()
{
	int w,n,a,b,list[31],i;
	for(i=1;i<=30;i++){
		list[i]=i;
	}
	scanf("%d",&w);
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d,%d",&a,&b);
		list[0]=list[a];
		list[a]=list[b];
		list[b]=list[0];
	}
	for(i=1;i<=w;i++){
		printf("%d\n",list[i]);
	}
	return 0;
}

Measured memory_bytes: 0
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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


int main() {
    ll X,K,D;
    cin >> X >> K >> D;

    // Xの絶対値を求める
    X = abs(X);

    // ll a = K*D; これだとオーバーフローする。よって式変形で工夫する

    ll ans = 0;
    // X >= D * K （式変形） →　(X/D) >= K
    // 答えの X-DKも式変形する
    if((X/D) >= K){
        // ans = ((X/D) - K)/D;
        ans = X - D*K;
    }else{
        ll e = X/D;
        K -= e;
        X -= e*D;
        if(K%2 == 0){
            ans = X;
        }else{
            ans = abs(X-D);
        }
    }

    cout << ans << endl;
    

    
}




Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define FOR(i, s, n) for(int i=(int)(s); i<(int)(n); ++i)
#define ALL(n) (n).begin(), (n).end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;

const ll MAX_V = 100000;
const ll INF = 1e9;
const ll MOD = 998244353;

int main(){
    string s; cin >> s;
    int ans = 0;
    REP(i, s.size()){
        if (s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
}

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

int main() {
	char b[] = "ACGT";
	int max = 0;
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < (int) s.size(); i++) {
		if (strchr(b, s[i]) != NULL) {
			count++;
			if (count > max)
				max = count;
		} else
			count = 0;
	}
	cout<<max<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   string s;
   cin>>s;
   long long ans=0;
   long long cnt=0;
   for(int i=0;i<s.size();i++){
      if(s[i]=='B'){
         cnt++;
      }
   }
   for(int i=0;i<s.size();i++){
      if(s[i]=='B'){
         ans+=s.size()-cnt-i;
         cnt--;
      }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    long long n;
    cin >> n;
    long long res=0;
    for(long long i=1;i*i<n;i++) if((n%i)==0&&(i<(n/i)-1)) res+=(n/i-1);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <deque>
#include <iomanip>
#include <bitset>
#include <complex>
#include <sstream>
#include <algorithm>
#include <limits>
#include <cmath>
#include <utility>
#include <tuple>
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr int mod = 1e9+7;
constexpr ld eps = 1e-10;
constexpr ld pi = acos(-1.0);

#define DUMP(a) cout << #a << ": " << (a) << endl


int main() {
    int N, A, B;
    cin >> N >> A >> B;
    string s;
    cin >> s;
    int a=0, b=0;
    for(int i=0; i<N; ++i) {
        if(s[i] == 'a') {
            if(a + b < A+B) {
                a++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else if(s[i] == 'b') {
            if(a + b < A+B && b < B) {
                b++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
}



Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>


int main()
{
	long long box,x, y, z;
	long long tmp;
	scanf("%lld %lld %lld", &x, &y, &z);
	if (x % 2 != 0 && y % 2 != 0 && z % 2 != 0) {
		tmp = x*y;
		if (y*z < tmp) tmp = y*z;
		if (z*x < tmp) tmp = z*x;
		printf("%llu\n",tmp);
	} else {
		printf("0\n");
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop for(;;)
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;
#define inf (1e9)
#define eps (1e-9)

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

template<class S, class T, class U> inline
ostream& operator<<(ostream&os, tuple<S,T,U> t) {
  return os << '('
    << get<0>(t) << ", "
    << get<1>(t) << ", "
    << get<2>(t) << ')';
}

template<class T> inline
ostream& operator<<(ostream&os, vector<T> v) {
  if (v.size() == 0) { return os << "(empty)"; }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

template<class T> inline
istream& operator>>(istream&is, vector<T>&v) {
  rep (i, v.size()) is >> v[i];
  return is;
}

//           ^   >  v   <
int dx[] = { -1, 0, 1,  0 };
int dy[] = {  0, 1, 0, -1 };

typedef vector<int> vi;


bool* PrimeSieve(int n) {
  bool*s = new bool[n];
  for (int i = 0; i < n; ++i) s[i] = true;
  s[0] = s[1] = false;
  for (int i = 2; i < n; ++i)
    if (s[i]) for (int j = i << 1; j < n; j += i) s[j] = false;
  return s;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout.setf(ios::fixed);
  cout.precision(10);
  random_device dev;
  mt19937 rand(dev());

  auto ps = PrimeSieve(50010);

  int n;
  while (cin >> n and n>0) {
    int ans = 0;
    for (int i = 2; i <= n/2; ++i) {
      int j = n - i;
      if (ps[i] and ps[j]) ++ans;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1288
X=int(input())

if X>=400 and X<=599:
    print(8)
elif X>=600 and X<=799:
    print(7)
elif X>=800 and X<=999:
    print(6)
elif X>=1000 and X<=1199:
    print(5)
elif X>=1200 and X<=1399:
    print(4)
elif X>=1400 and X<=1599:
    print(3)
elif X>=1600 and X<=1799:
    print(2)
elif X>=1800 and X<=1999:
    print(1)
    

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

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

    ll a = 0, b = 0;
    for (int i = 1; i <= n; i++) {
        if (i % k == 0) a++;
        if (k % 2 == 0 && i % k == k / 2) b++;
    }

    cout << a * a * a + b * b * b << endl;
    return 0;
}


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

const int64_t INF=10e9;

int main(){
  int N,M,R;
  cin>>N>>M>>R;
  vector<vector<int64_t>> dp(N,vector<int64_t>(N,INF));
  vector<int> r(R);

  for(int i=0;i<R;++i){
    cin>>r[i];
    --r[i];
  }

  for(int i=0;i<M;++i){
    int A,B;
    int64_t C;
    cin>>A>>B>>C;
    --A,--B;
    dp[A][B]=C,dp[B][A]=C;
  }

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

  for(int k=0;k<N;++k){
    for(int i=0;i<N;++i){
      for(int j=0;j<N;++j){
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
      }
    }
  }

  vector<int> d;
  for(int i=0;i<R;++i) d.push_back(i);
  int64_t ans=INF;
  do{
    int64_t subans=0;
    for(int i=0;i<R-1;++i) subans += dp[r[d[i]]][r[d[i+1]]];
    ans=min(ans,subans);
  }while(next_permutation(d.begin(),d.end()));

  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>    //vectorを使う
using namespace std;


int main(void){
    vector<int> l(5);
    vector<int> a(5);
    int s;
    for(int i = 0; i <5 ; ++i){
        cin >> l.at(i) ;
    }

    for(int i = 0; i <5 ; ++i){
        a.at(i) = l.at(i)%10 ;
    }
    for(int i = 0; i <5 ; ++i){
        if(a.at(i)==0){
        }else{
            l.at(i) = (l.at(i)/10+1)*10 ;
        }
    }
    
    for(int i = 0; i <5 ; ++i){
        if(a.at(i)==0){
            a.at(i)=10;
        }else{
        }
    }

    sort(a.begin(),a.end());
    s=a.at(0);

    for(int i = 0; i <5 ; ++i){
        s=s+l.at(i);
    }
    cout << s-10 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int N;
    cin >> N;
    map<int,int> D;

    REP(i,0,N){
        int tmp;
        cin >> tmp;
        if(D.find(tmp) == D.end()){
            D.insert(make_pair(tmp,1));
        }else{
            D.find(tmp)->second++;
        }
    }

    int M;
    cin >> M;
    map<int,int> T;
    REP(i,0,M){
        int tmp;
        cin >> tmp;
        if(T.find(tmp) == T.end()){
            T.insert(make_pair(tmp,1));
        }else{
            T.find(tmp)->second++;
        }
    }

    for(map<int,int>::iterator it = T.begin(); it != T.end(); it++){
        if(it->second > D.find(it->first)->second){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 18944
#include <stdio.h>

int main(){

int h,w,i,j;

    while(1)
   {
        scanf("%d %d",&h,&w);
        if((h==w) && (h==0)) break;
        
for(i=0;i<h;i++){
        for(j=0;j<w;j++){
           printf("%s","#");
        }
           printf("\n");         
    }

printf("\n");         


}
 
    return 0;
}

Measured memory_bytes: 572
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node
{
	int parent, left, right;
};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d)
{
	if (u == NIL)
	{
		return;
	}
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}

int setHeight(int u)
{
	int h1 = 0, h2 = 0;
	if (T[u].left != NIL)
	{
		h1 = setHeight(T[u].left) + 1;
	}
	if (T[u].right != NIL)
	{
		h2 = setHeight(T[u].right) + 1;
	}
	return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u)
{
	if (T[u].parent == NIL)
	{
		return NIL;
	}
	if (T[T[u].parent].left != u && T[T[u].parent].left != NIL)
	{
		return T[T[u].parent].left;
	}
	if (T[T[u].parent].right != u && T[T[u].parent].right != NIL)
	{
		return T[T[u].parent].right;
	}
	return NIL;
}

void print(int u)
{
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", getSibling(u));
	int degree = 0;
	if (T[u].left != NIL)
	{
		degree++;
	}
	if (T[u].right != NIL)
	{
		degree++;
	}
	printf("degree = %d, ", degree);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);

	if (T[u].parent == NIL)
	{
		printf("root\n");
	}
	else if (T[u].left == NIL&&T[u].right == NIL)
	{
		printf("leaf\n");
	}
	else
	{
		printf("internal node\n");
	}
}

int main()
{
	int v, l, r, root = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		T[i].parent = NIL;
	}
	for (int i = 0; i < n; i++)
	{
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if (l != NIL)
		{
			T[l].parent = v;
		}
		if (r != NIL)
		{
			T[r].parent = v;
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (T[i].parent == NIL)
		{
			root = i;
		}
	}

	setDepth(root, 0);
	setHeight(root);

	for (int i = 0; i < n; i++)
	{
		print(i);
	}
	return 0;
}


Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int K;
    string S;
    string ans;
    cin >> K >> S;
    if(S.size() <= K){
        cout << S << endl;
        return 0;
    }
    for(int i = 0; i < K; i++) ans += S[i];
    cout << ans << "..." << endl;
}

Measured memory_bytes: 3660
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    ma = max(a)
    mi = min(a)
    if mi*ma < 0:
        print(2*(n-1))
        if abs(ma) > abs(mi):
            mk = a.index(ma)
            for i in range(n):
                if i == mk:
                    continue
                print(mk+1,i+1)
                a[i] += ma
        else:
            mk = a.index(mi)
            for i in range(n):
                if i == mk:
                    continue
                print(mk+1,i+1)
                a[i] += mi
    else:
        print(n-1)
    ma = max(a)
    mi = min(a)
    if ma <= 0:
        for i in range(n-1):
            print(n-i,n-i-1)
    else:
        for i in range(n-1):
            print(i+1,i+2)


    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 38636
N, K, S = map(int, input().split())

ans_list = []
for i in range(K):
    ans_list.append(S)

if S > 10**6:
    for i in range(N - K):
        ans_list.append(1)
else:
    for i in range(N - K):
        ans_list.append(10**9)

print(*ans_list)

Measured memory_bytes: 49264
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;

using namespace std;
struct edge {long S,G,W;};

class Bellman {
private:
	vector<edge> E;
	vector<long> dist;
	vector<long> trace;
	size_t V;
public:
	Bellman() : V(0),E(0) {} 
	Bellman(size_t v) :
		V(v),E(0),dist(v,2147483647),trace(v,2147483647) {}

	size_t size() {return V;}

	void add_edge_directed(long start,long goal,long dis){
		E.push_back(edge {start,goal,dis});
	}

	void add_edge_undirected(long start,long goal,long dis){
		E.push_back(edge {start,goal,dis});
		E.push_back(edge {goal,start,dis});
	}

	bool bellman_ford(long start){ // 負の閉路->false
		bool update = true;
		long roop = 0;
		dist[start] = 0;

		while (update) {
			if (++roop > V) return false;
			update = false;

			REP(i,E.size()) {	// 辺の始点
				edge* e = &E[i];
				if (dist[e->S] == 2147483647) continue; //まだ候補すらない頂点

				if (dist[e->G] > dist[e->S] + (e->W)){
					dist[e->G] = dist[e->S] + (e->W);
					update = true;
				}

				trace[e->G] = e->S;
			}
		}
		return true;
	}

	vector<long> bellman_ford_dic(long start,long goal){ // 負の閉路->false
		vector<long> trace_result(0);
		bool update = true;
		long roop = 0;
		dist[goal] = 0; //逆から辿る。

		while (update) {
			if (++roop > V) return trace_result;
			update = false;

			REP(i,E.size()) {	// 辺の始点
				edge* e = &E[i];
				if (dist[e->S] == 2147483647) continue; //まだ候補すらない頂点

				if (dist[e->G] > dist[e->S] + (e->W)){
					dist[e->G] = dist[e->S] + (e->W);
					update = true;
				}

				else {
					if (dist[e->S] + e->W == dist[e->G] && trace[e->G] > (e->S)){
						trace[e->G] = e->S;
						update = true;
					}
				}
				trace[e->G] = e->S;	
			}
		}
		
		for (long node = start;node != goal;node = trace[node]){
			trace_result.push_back(node);
		}
		trace_result.push_back(goal);
		return trace_result; //先頭がstart,末尾がgoal
	}

	vector<long> result(void){
		return dist; // 非連結なら 2147483647 が入っている。
	}

	long result_query(long goal){
		return dist[goal];
	}

	vector<long> trace_route(long start,long goal){
		vector<long> trace_result;
		for (long node = goal;node != start;node = trace[node]){
			trace_result.push_back(node);
		}
		trace_result.push_back(start);
		return trace_result; // 先頭がgoal,末尾がstart
	}
};

int main(void){
	long V,E,R;
	long s,t,d;
	cin >> V >> E >> R;
	Bellman bl(V);
	REP(i,E){
		cin >> s >> t >> d;
		bl.add_edge_directed(s,t,d);
	}
	if (!bl.bellman_ford(R)) {
		cout << "NEGATIVE CYCLE" << endl;
		exit(0);
	}

	vector<long> ans = bl.result();

	REP(i,V){
		if (ans[i] == 2147483647) cout << "INF" << endl;
		else cout << ans[i] << endl;
	}
	return 0;
}




Measured memory_bytes: 3188
import java.util.*;

public class Main{
	public static void main(String args[]){
	
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		
		if(B-A-1 > 2*(K-1)){
			for(int i=0;i<K;i++){
				System.out.println(A+i);
			}
			for(int j=0;j<K;j++){
				System.out.println(B-K+j+1);
			}
		}else{
			for(int m=0;m<B-A+1;m++){
				System.out.println(A+m);
			}
		}
	}	
}

Measured memory_bytes: 22740
N, K = [1000, 8]
DRR = [1, 3, 4, 5, 6, 7, 8, 9]



N, K = [9999, 1]
DRR = [0]


N, K = list(map(int,input().split()))
DRR = list(map(int,input().split()))

def calculate(n, k, drr):
    dislikes = set()

    for i in range(k):
        dislikes.add(drr[i])

    while not condition(n, dislikes):
        n += 1

    print(n)
def condition(n,dislikes):
    arr = list(map(int, str(n)))

    for i in range(len(arr)):
        if  dislikes.__contains__(arr[i]):
            return False
    return True


calculate(N, K, DRR)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    int h, w;
    cin >> h >> w;
    char s[h][w];
    rep(i, 0, h) {
        rep(j, 0, w) {
            cin >> s[i][j];
        }
    }

    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, 1, -1};
    rep(i, 0, h) {
        rep(j, 0, w) {
            if (s[i][j] == '#') {
                bool found = false;
                rep(k, 0, 4) {
                    int i2 = i + dx[k];
                    int j2 = j + dy[k];
                    if (i2 < 0|| h - 1 < i2  || j2 < 0 || w - 1 < j2) continue;
                    if (s[i2][j2] == '#') found = true;
                }
                if (!found) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::BufRead;

macro_rules! readlines {
    ($cnt:expr) => {
        {
            let stdin = std::io::stdin();
            let mut handle = stdin.lock();
            let mut result = Vec::new();
            for i in 0..$cnt{
                let mut buf = String::new();
                handle.read_line(&mut buf);
                result.push(buf.trim().to_owned());
            }
            result
        }
    };
}

macro_rules! string2splittedvec {
    ($t:ty,$sep:expr,$line:expr) => {
        {
            $line.split($sep)
                .map(|s|s.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty,$line:expr) => {
        {
            string2splittedvec!($t,' ',$line)
        }
    };
    ($sep:expr,$line:expr) => {
        {
            $line.split($sep)
                .map(|s|s.to_owned())
                .collect::<Vec<_>>()
        }
    };
    ($line:expr)=>{
        {
            string2splittedvec!(' ',$line)
        }
    }
}


fn main(){
    let mut v = readlines!(2).into_iter().map(|s|{string2splittedvec!(u64,s)}).collect::<Vec<Vec<_>>>();
    let n = v[0][0];
    let m = v[0][1];
    v[1].resize(m as usize,0);
    
    let mut t = 0;
    for i in v[1].clone(){
        t+=i;
    }
    let ans = if t<=n{ (n-t)as i64}else{-1};
    println!("{}",ans);
}

Measured memory_bytes: 2200
N,M = map(int,input().split())
dic = {}

for i in range(N):
  dic[i+1] = 0

for i in range(M):
  a,b = map(int,input().split())
  dic[a] += 1
  dic[b] += 1
output = dic.values()
for item in output:
  print(item)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,M;
  cin >> N >> M;
  vi s(N),t(M);
  rep(i,N) {
    cin >> s[i];
  }
  rep(i,M) {
    cin >> t[i];
  }
  vv(ll) sum(N,vl(M,0));
  drep(i,N) {
    drep(j,M) {
      if(j+1<M&&i+1<N) {
        sum[i][j] = MOD + sum[i+1][j] + sum[i][j+1] - sum[i+1][j+1];
      } else if(j+1<M) {
        sum[i][j] = sum[i][j+1];
      } else if(i+1<N) {
        sum[i][j] = sum[i+1][j];
      }
      sum[i][j] %= MOD;
      if(s[i] != t[j]) continue;
      ll k = 1;
      if(j+1<M&&i+1<N) {
        k += sum[i+1][j+1];
      }
      sum[i][j] += k;
      sum[i][j] %= MOD;
    }
  }
  cout << (sum[0][0]+1)%MOD << endl;
  return 0;
}

Measured memory_bytes: 31616
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * ceil_(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class DStringFormation {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    deque<char> ans;
    rep(i, S.size()) {
      ans.emplace_back(S[i]);
    }
    int direction = 1;
    rep(i, Q) {
      int Query;
      cin >> Query;
      if (Query == 1) {
        direction *= -1;
      } else {
        int F;
        char C;
        cin >> F >> C;
        if (direction == 1) {
          if (F == 1) {
            ans.emplace_front(C);
          } else {
            ans.emplace_back(C);
          }
        } else {
          if (F == 2) {
            ans.emplace_front(C);
          } else {
            ans.emplace_back(C);
          }
        };
      }
    }
    if (direction == 1) {
      rep(i, ans.size()) {
        cout << ans[i];
      }
    } else {
      rep(i, ans.size()) {
        cout << ans[ans.size() - 1 - i];
      }
    }
    cout << endl;
  }
};


signed main() {
  DStringFormation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int head[100009],nxt[100009<<1],to[100009<<1],tot=0;
void add(int x,int y){
    to[++tot]=y;
    nxt[tot]=head[x];
    head[x]=tot;
}
int n,m;
int vis[100009],num[100009];
int  dfs(int x){
    if(vis[x])return num[x];
    vis[x]=1;
    for(int i=head[x];i;i=nxt[i]){
        int ver=to[i];
        num[x]=max(num[x],dfs(ver));
    }
    return ++num[x];
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int x,y;cin>>x>>y;
        add(x,y);
    }
    for(int i=1;i<=n;i++)
        if(!vis[i])dfs(i);
    cout<<*max_element(num+1,num+n+1)-1<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

const ll INF = 1e9 + 7;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char> > as(H, vector<char>(W));
  rep(i, H) rep(j, W) cin >> as[i][j];

  vector<vector<ll> > dp(H, vector<ll>(W, 0));
  rep(i, H) {
    if (as[i][0] == '#') {
      break;
    } else {
      dp[i][0] = 1;
    }
  }
  rep(j, W) {
    if (as[0][j] == '#') {
      break;
    } else {
      dp[0][j] = 1;
    }
  }

  for (int i = 1; i < H; i++) {
    for (int j = 1; j < W; j++) {
      if (as[i][j] == '#') {
        dp[i][j] = 0;
      } else {
        dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % INF;
      }
    }
  }
  cout << dp[H - 1][W - 1] << endl;
  return 0;
}

Measured memory_bytes: 11976
#include <iostream>
using namespace std;
int main(){
	long long k, a, b;
	cin >> k;
	cin >> a;
	cin >> b;
	if(a+2>=b || k < a+1){
		cout << 1+k;
	}else{
		long long nokori = k-(a-1);

		long long changeCount = nokori/2;
		long long changeFail = nokori%2;
		cout << a+changeFail+changeCount*(b-a);
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

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

    std::vector<int> presents(n);
    for (int i = 0; i < n; i++) {
        std::cin >> presents[i];
    }

    std::sort(presents.begin(), presents.end(), std::greater<int>());

    presents[0] /= 2;

    std::cout << std::accumulate(presents.begin(), presents.end(), 0) << std::endl;
}


Measured memory_bytes: 256
#include <cstdio>
 
int main()
{
    int matrix[4][4];
 
    for(int i = 1; i <= 3; i++)
        for(int j = 1; j <= 3; j++)
            scanf("%d", &matrix[i][j]);
 
    int A[4];
    int B[4];
 
    A[1] = 23;
    B[1] = matrix[1][1] - A[1];
    B[2] = matrix[1][2] - A[1];
    B[3] = matrix[1][3] - A[1];
    A[2] = matrix[2][1] - B[1];
    A[3] = matrix[3][1] - B[1];
 
    int is_possible = true;
    for(int i = 1; i <= 3; i++)
        for(int j = 1; j <= 3; j++)
            if(A[i] + B[j] != matrix[i][j])
                is_possible = false;
 
    printf(is_possible ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 128
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29



def main():
    N, M = ints_raw()
    CBs =[]
    CBs.append([0,N])
    As = ints_raw()
    As.sort()
    for _ in range(M):
        B,C = ints_raw()
        CBs.append([C,B])
    CBs.sort(reverse=True)
    ans = 0
    cb_idx = 0
    cur_cbs = CBs[cb_idx]
    for a in As:
        if a < cur_cbs[0]:
            cur_cbs[1]-=1
            ans+=cur_cbs[0]
            if cur_cbs[1] <=0:
                cb_idx+=1
                cur_cbs = CBs[cb_idx]
        else:
            ans+=a
    return ans

print(main())


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

int main()
{
  ll h,a;
  cin >> h >> a;
  ll cnt = 0;
  while(h>0)
  {
    h -= a;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// Rolling Hash
// Verified: AOJ 2444 (Substring)

struct RollingHash {
public:
    long long base_1, base_2, mod_1, mod_2;
    vector<long long> hash1, hash2, pow1, pow2;

    // init (constructor)
    RollingHash(string s) : base_1(1013), base_2(1007),
        mod_1(1000000007), mod_2(1000000009),
        hash1(s.length()+1,0), hash2(s.length()+1,0),
        pow1(s.length()+1,1), pow2(s.length()+1,1) {
            for(int i=0; i<s.length(); i++) {
                hash1[i+1] = (hash1[i]+s[i]) * base_1 % mod_1;
                hash2[i+1] = (hash2[i]+s[i]) * base_2 % mod_2;
                pow1[i+1] = pow1[i] * base_1 % mod_1;
                pow2[i+1] = pow2[i] * base_2 % mod_2;
            }
        }

    // calc str[l,r) hash (0-indexed)
    // if get(i1,j1) == get(i2,j2) -> identical string
    pair<long long, long long> get(int l, int r) {
        long long t1 = ((hash1[r] - hash1[l] * pow1[r-l]) % mod_1 + mod_1) % mod_1;
        long long t2 = ((hash2[r] - hash2[l] * pow2[r-l]) % mod_2 + mod_2) % mod_2;
        return make_pair(t1, t2);
    }
};

signed main() {
    string s; cin >> s;
    RollingHash RH(s);
    int mi = INF;
    repq(i,1,s.length() / 3) {
        if(s.length() - i*3 < 2 || (s.length() - i*3) % 2) continue;
        int j = (s.length() - i*3) / 2;
        // printf("valid: i = %lld, j = %lld\n", i, j);
        pii a = RH.get(0,i);
        pii b = RH.get(i,i+j);
        pii c = RH.get(i+j, 2*i+j);
        pii d = RH.get(2*i+j, 2*i+2*j);
        pii e = RH.get(2*i+2*j, 3*i+2*j);

        if(a == c && c == e && e == a && b == d) {
            // cout << i+j << endl;
            mi = min(mi, i+j);
        }
    }
    if(mi == INF) cout << "mitomerarenaiWA" << endl;
    else cout << "Love " << s.substr(0,mi) << "!" << endl;
    return 0;
}

Measured memory_bytes: 36152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
 
  cin>>N;//餅の数
 
  vector<int> d(N);
 
  for(int i=0;i<N;i++){
 
  cin>>d.at(i);
 
  }//各餅のサイズ
 
  set<int> m; 
  
  for(int i=0;i<N;i++){
 
    m.insert(d.at(i));    
    
  }//餅のバリエーションをカウント
   
  cout << m.size() << endl;//バリエーション数を出力
  
  return 0;
}

Measured memory_bytes: 256
def factorial(n)
  i = 1
  k = 1
  while i < n
    k *= i+1
    i += 1
  end
  k
end
n = gets.to_i
arr = []
n.times do
  arr.push(gets.chomp.split(' ').map(&:to_i))
end
i = 0
sum = 0
while i < n - 1
  j = i + 1
  while j < n
    sum += Math.sqrt((arr[i][0] - arr[j][0])**2 + (arr[i][1] - arr[j][1])**2)
    j += 1
  end
  i += 1
end
puts (sum * 2)/n


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(a==1)a+=13;
	if(b==1)b+=13;
	cout<<(a==b?"Draw"s:a>b?"Alice"s:"Bob"s)<<"\n"s;
}

Measured memory_bytes: 256
class UnionFindTree:    
    def __init__(self,n):
        self.a = [i for i in range(n)]
        self.rank = [1 for i in range(n)]

    def root(self,x):
        if self.a[x] != x:
            return self.root(self.a[x])
        return x

    def same(self,x,y):
        if self.root(x) == self.root(y):
            return 1
        else:
            return 0

    def union(self,x,y):
        rx = self.root(x)
        ry = self.root(y)
        if rx != ry:
            if self.rank[rx] < self.rank[ry]:
                self.a[rx] = ry
            else:
                self.a[ry] = rx
                if self.rank[rx] == self.rank[ry]:
                    self.rank[rx] += 1
            
                

n,q = map(int,input().split())
unionFindTree = UnionFindTree(n)

for i in range(q):
    com,x,y = map(int,input().split())
    if com == 0:
        unionFindTree.union(x,y)
    elif com == 1:
        print(unionFindTree.same(x,y))



Measured memory_bytes: 6036
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int maxCnt = n / 4;
      for(int k = 0; k <= maxCnt; k++) {
        int diff = n - k * 4;
        if(diff % 7 == 0) {
            System.out.println("Yes");
            return;
        }
      }
      System.out.println("No");
  }
}

Measured memory_bytes: 22996
import std;

void main() {
	int n;
	scanf("%d\n", &n);
	auto as = readln.chomp.split.to!(int[]);
	long count = 0;
	int[long] memj;
	foreach(i;0..as.length) {
		++memj[i-as[i]];
	}
	foreach(i;0..as.length) {
		if (i+as[i] in memj) {
			count += memj[i+as[i]];
		}
	}
	write(count);
}


Measured memory_bytes: 23600
c[100][100];n,m;u,t,l,x,y;main(){for(;scanf("%d%d",&n,&m),n;printf("%d\n",l)){int d[100]={0};for(memset(c,9,40000);m--;c[u][l]=c[l][u]=t/100-1)scanf("%d,%d,%d",&u,&l,&t);x=y=l=0;for(u=n;u--;x=t)for(d[x]=1,l+=y,y=x[*c]=**c,m=n;m--;m[*c]<y&&(t=m,y=m[*c]))!d[m]&&c[x][m]<m[*c]&&(m[*c]=c[x][m]);}exit(0);}

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

int n;
int y, m, d;

int main() {
	int i;
	cin >> n;
	for( i = 0; i < n; i++ ) {
		cin >> y >> m >> d;
		
		int j, k;
		int day = 0;
		for( j = y; j < 1000; j++ ) {
			if ( j == y ) {
				k = m;
			} else {
				k = 1;
			}
			for( ; k <= 10; k++ ) {
				if ( k % 2 || j % 3 == 0 ) {
					if ( j == y && k == m )
						day += 20 - d + 1;
					else
						day += 20;
				} else {
					if ( j == y && k == m )
						day += 19 - d + 1;
					else
						day += 19;
				}
			}
		}
		cout << day << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main()
{
	int a , b ;
	scanf("%d %d", & a , & b);
	if (a<b)
	{
	    printf("a < b\n");
	} 
	else if (a>b)
	{
		printf("a > b\n");
	}
	else if (a == b)
	{
	    printf("a == b\n");
	}
	return 0;
} 


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

#define F                      first
#define S                      second
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define pll                     pair< long long int, long long int> 
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define SZ(x)                   ((int)x.size())

#define FOR(i,a,b)              for(int i = a; i < b; ++i)
#define REV(i,a,b)              for(int i = a; i >= b; --i)
#define FORE(i,a,b)             for(int i = a; i <= b; ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve();

int main()
{
        fast;
        solve();
}

const int N = 1e5+2;
std::vector<int> adj[N];

int dp[N];

int dfs(int node) {
        if(dp[node] != -1) {
                return dp[node];
        }
        dp[node] = 0;
        for(auto i:adj[node]) {
                dp[node] = max(dp[node], 1 + dfs(i));
        }
        return dp[node];
}

void solve() {
        memset(dp,-1,sizeof(dp));
        int n,m;
        cin >> n >> m;
        FOR(i,0,m) {
                int x,y;
                cin >> x >> y;
                adj[x].pb(y);
        }        
        int ans = 0;
        FOR(i,1,n+1) {
                ans = max(ans, dfs(i));
        }
        cout << ans << endl;

}

Measured memory_bytes: 7552
n,m=map(int,input().split())
C=list(map(int,input().split()))

inf=float('inf')

DP=[[inf]*(n+1) for i in range(m+1)]

DP[0][0]=0

for i in range(m):
	for j in range(n+1):
		if j-C[i]<0:
			DP[i+1][j]=DP[i][j]
		else:
			DP[i+1][j]=min(DP[i][j],DP[i+1][j-C[i]]+1)

print(DP[m][n])


Measured memory_bytes: 43740