akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
int a=100000009;
int b=2;
double aa;
double bb;
int d;
int r;
double x;
scanf("%d%d",&a,&b);
d = a / b;
r = a % b;
aa = a/10.0;
bb = b/10.0;
x = aa / bb;
printf("%d %d %.30f\n",d,r,x);}


Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> l;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    l.push_back(a);
  }
  sort(l.begin(), l.end(), greater<int>());
  int answer = 0;
  for (int i = 0; i < k; i++) {
    answer += l[i];
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int m, f, r;
    int s;
 
    while (1) {
        scanf("%d%d%d", &m, &f, &r);
        if (m == -1 && f == -1 && r == -1) break;
 
        if (m < 0 || f < 0) puts("F");
        else {
            s = m + f;
            if (s >= 80) puts("A");
            else if (s >= 65) puts("B");
            else if (s >= 50) puts("C");
            else if (s < 30) puts("F");
            else puts(r >= 50 ? "C" : "D");
        }
    }
    return 0;
}


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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A;
    cin >> N >> A;
    vector<int> x(N + 1);
    int K = A;
    for (int i = 1; i <= N; ++i) {
        cin >> x[i];
        K = max(K, x[i]);
        x[i] -= A;
    }
    K = A;
    vector<vector<ll>> dp(N + 1, vector<ll>(2*K*N + 1, 0));
    dp[0][K*N] = 1;
    for (int j = 0; j <= N; ++j) {
        for (int s = 0; s <= 2*K*N; ++s) {
            if (j >= 1 && x[j] > s) dp[j][s] = dp[j-1][s];
            if (j >= 1 && x[j] <= s) dp[j][s] = dp[j-1][s] + dp[j-1][s-x[j]];
        }
    }
    cout << dp[N][K*N] - 1 << endl;
}


Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/12/2018
 
 22:50-
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
//const int MAX_N=1e5+1;
string S;
//LL A[MAX_N];
bool solve() {
  if(SZ(S)==1) return true;
  VI cnt(3,0);
  REP(i,SZ(S))cnt[S[i]-'a']++;
//  dumpAR(cnt);
  int a=*max_element(cnt.begin(),cnt.end()),b=*min_element(cnt.begin(),cnt.end());
//  dump2(a,b);
  return a-b<=1;
}

const string yes="YES",no="NO";
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>S;
  cout<<(solve()?yes:no)<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < N; i++)
#define rep2(i, x, n) for (int i = x; i < N; i++)
using ll = long long int;
int main() {
    int N;
    cin >> N;
    int A=0, W=0, T=0, R=0;
    rep(i, N) {
        string S;
        cin >> S;
        if (S=="AC") A++;
        else if (S=="WA") W++;
        else if (S=="TLE") T++;
        else if (S=="RE") R++;
    }
    cout << "AC x " << A << endl;
    cout << "WA x " << W << endl;
    cout << "TLE x " << T << endl;
    cout << "RE x " << R << endl;
    return 0;
}

Measured memory_bytes: 3616
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>
using namespace std;
pair<long long, long long> XH[200000];
int sqrtN = 512;
struct SqrtDecomposition{
    int N, K;
    vector <long long> data;
    vector <long long> bucketAdded;
    
    SqrtDecomposition(int n){
        N = n;
        K = (N + sqrtN - 1) / sqrtN;
        data.assign(N, 0);
        bucketAdded.assign(K, 0);
    }

    long long get(int x){
        return data[x] + bucketAdded[x / sqrtN];
    }

    void add(int x, int y, int a){
        if(y - x < sqrtN){
            for(int i = x; i < y; i++){
                data[i] += a;
            }
            return;
        }
        for(int i = x / sqrtN + 1; i < y / sqrtN; i++){
            bucketAdded[i] += a;
        }

        for(int i = x; i < (x / sqrtN + 1) * sqrtN; i++){
            data[i] += a;
        }
        for(int i = y / sqrtN * sqrtN; i < y; i++){
            data[i] += a;
        }
    }
    
};
int main(){
  int N;
  long long D;
  long long A;
  cin >> N >> D >> A;
  for(int i = 0; i < N; i++){
    cin >> XH[i].first >> XH[i].second;
  }
  sort(XH, XH + N);
  SqrtDecomposition sq(N);
  long long ans = 0;
  for(int i = 0; i < N; i++){
    sq.add(i, i + 1, XH[i].second);
  }
  for(int i = N - 1; i >= 0; i--){
    long long left = sq.get(i);
    if(left < 0){
      continue;
    }
    long long cur_bomb_no;
    if(left % A == 0){
      cur_bomb_no = left / A;
    } else {
      cur_bomb_no = left / A + 1;
    }
    ans += cur_bomb_no;
    long long cur_x = XH[i].first;
    auto it = lower_bound(XH, XH + N, make_pair(cur_x - 2 * D, (long long) 0));
    sq.add(it - XH, i, - cur_bomb_no * A);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll k; cin >> k; k--;
    vll lunlun;
    queue<string> q;
    rep(i, 10) {
        q.push(to_string(i));
    }

    while (q.size()) {
        string following = q.front(); q.pop();
        if (lunlun.size() >= 1e6) break;
        if (following[0] - '0' != 0) lunlun.push_back(stoll(following));

        if (following[0] - '0' != 0) q.push(to_string(following[0] - '0' - 1) + following);
        q.push(following[0] + following);
        if (following[0] - '0' != 9) q.push(to_string(following[0] - '0' + 1) + following);
    }
    sort(all(lunlun));
    cout << lunlun[k] << endl;

    return 0;
}

Measured memory_bytes: 120424
using System;
using System.Linq;

namespace Make_Purse_Light
{
    class Program
    {
        static int[] Coins = new int[] { 10, 50, 100, 500 };
        static bool flag = false;

        private static void Main(string[] args)
        {
            while (true)
            {
                // 会計金額
                int bill = int.Parse(Console.ReadLine());
                if (bill == 0) break;

                // 所持金
                int[] ownedCoins = Console.ReadLine().Trim().Split(' ').Select(i => int.Parse(i)).ToArray();
                // 所持枚数
                int ownedMoney = GetMoney(Coins, ownedCoins);

                // お釣り
                int changeMoney = ownedMoney - bill;
                // お釣り枚数
                int[] changeCoins = Coins.Reverse<int>().Select(c => GetChange(ref changeMoney, c)).Reverse().ToArray();

                // 支払い枚数
                int[] paymentCoins = GetPayment(ownedCoins, changeCoins);

                WriteLines(paymentCoins);
            }
        }

        private static int GetChange(ref int money, int coin)
        {
            var result = money / coin;
            money = money % coin;
            return result;
        }

        private static void WriteLines(int[] paymentCoins)
        {
            if (flag) Console.WriteLine(); else flag = true;
            for (int i = 0; i < Coins.Count(); i++)
            {
                if (paymentCoins[i] > 0)
                {
                    Console.WriteLine("{0} {1}", Coins[i], paymentCoins[i]);
                }
            }
        }

        private static int GetMoney(int[] l1, int[] l2)
        {
            int result = 0;
            for (int i = 0; i < l1.Count(); i++)
            {
                result += l1[i] * l2[i];
            }
            return result;
        }


        private static int[] GetPayment(int[] l1, int[] l2)
        {
            int[] result = new int[Coins.Count()];
            for (int i = 0; i < l1.Count(); i++)
            {
                result[i] = (l1[i] - l2[i]);
            }
            return result;
        }
    }
}


Measured memory_bytes: 9864
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};

    static int n,k;
    static int[] x;

    static int h, w, d;

    public static void main(String[] args) {
        input();
        solve();
    }

    static void solve() {
        long ans = Long.MAX_VALUE;
        for(int i = 0; i < n-k+1; i++) {
            int l = x[i];
            int r = x[i + k - 1];
            if(l < 0) {
                if(r <= 0) {
                    ans = Math.min(ans, Math.abs(l));
                }else{
                    ans = Math.min(ans, 2*r + Math.abs(l));
                    ans = Math.min(ans, 2*Math.abs(l)+r);
                }
            }else{
                ans = Math.min(ans, r);
            }
        }

        print(ans);
    }

    static void input() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = in.nextInt();
        x = new int[n];
        for(int i = 0; i < n; i++) {
            x[i] = in.nextInt();
        }
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(char c) {
        System.out.println(c);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }

    static void printArray2D(int[][] array, char del) {
        int r = array.length;
        int c = array[0].length;
        for(int i = 0; i < r; i++) {
            for(int j = 0; j < c; j++) {
                System.out.format("%3d", array[i][j]);
                if(j != c-1) System.out.print(del);
                else System.out.print('\n');
            }
        }
    }
}


Measured memory_bytes: 54264
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>

using namespace std;
typedef long long ll;

#define mod 1000000007
#define INF 1000000000
#define SIZE 100

int main(){
  int a,b,c,d,e,f;

  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);

  if(a*1+b*5+c*10+d*50+e*100+f*500 >= 1000)
    puts("1");
  else
    puts("0");

  return 0;
}

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

int main( void )
{
  int N, D;
  cin >> N >> D;

  vector<int> X( N ), Y( N );
  int count = 0;
  
  for( int i = 0; i < N; i++ ) {
    cin >> X.at( i ) >> Y.at( i );
    if( sqrt( ( double )( pow( X.at( i ), 2 ) + pow( Y.at( i ), 2 ) ) ) <= D )
      count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 4836
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();

            if ((A + B) % 2 == 0) {
                System.out.println((A + B) / 2);
            } else {
                System.out.println("IMPOSSIBLE");
            }
        }
    }
}


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

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

    int ans = 1;
    sort(moti.begin(),moti.end());
    for (int i = 0; i < n - 1; i++){
        if (moti[i] != moti[i+1]){
            ans++;
        }
    }
    cout << ans << endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        double[] WHxy = ReadLine().Split(' ').Select(double.Parse).ToArray();
        double W = WHxy[0];
        double H = WHxy[1];
        double x = WHxy[2];
        double y = WHxy[3];
        if(W / 2 == x && H / 2 == y)
        {
            WriteLine($"{W * H / 2} 1");
        }
        else
        {
            WriteLine($"{W * H / 2} 0");
        }
    }
}

Measured memory_bytes: 13396
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc;

  void run() {
    for ( ;; ) {
      int n = ni();
      int m = ni();
      if ( ( n | m ) == 0 ) {
        break;
      }

//      debug(n, m);
      int[] h = new int[n];
      int[] w = new int[m];
      for ( int i = 0; i < n; ++i ) {
        h[ i ] = ni();
      }
      for ( int j = 0; j < m; ++j ) {
        w[ j ] = ni();
      }

      int[] W = new int[1500 * 1000 + 1];
      for ( int i = 0; i < m; ++i ) {
        int sum = 0;
        for ( int j = i; j < m; ++j ) {
          sum += w[ j ];
          ++W[ sum ];
        }
      }

      int ans = 0;
      for ( int i = 0; i < n; ++i ) {
        int sum = 0;
        for ( int j = i; j < n; ++j ) {
          sum += h[ j ];
          ans += W[ sum ];
        }
      }

      System.out.println( ans );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }

}

Measured memory_bytes: 281284
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,f[105][15],p[105][15],cnt,ans=-(1<<30),c;
signed main(){
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++)cin>>f[i][j];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<11;j++)cin>>p[i][j];
	}
	for(int i=1;i<(1<<10);i++){
	    cnt=0;
		for(int j=0;j<n;j++){
		    c=0;
			for(int k=0;k<10;k++){
				if((i>>k&1)&&f[j][k])c++;
			}
			cnt+=p[j][c];
		}
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
}

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

int main(){
  long long a, b, c, d, e;
  cin >> a >> b;
  d = 0;
  for(long long i = 1; i < min(a, b) + 1; i++){
    if(a % i == 0 && b % i == 0)
      d = i;
  }
  e = d * (a / d) * (b / d);
  cout << e << endl;
}

Measured memory_bytes: 256
n,c,k = map(int,input().split())
t = []

for i in range(n):
    t.append(int(input()))

t = sorted(t)
i = 1
machi = k
nori = 1
ans = 1

while i != n:
    if  machi-(t[i]-t[i-1]) >= 0 and nori+1 <= c:
        machi -= (t[i]-t[i-1])
        nori += 1
    else:
        ans += 1
        machi = k
        nori = 1
    i += 1

print(ans)


Measured memory_bytes: 14172
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

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

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

vector<ll> merge(vector<ll> &A, vector<ll> &B){
    vector<ll> cp(A);
    for(auto i:B) cp.push_back(i);
    sort(cp.begin(),cp.end(),greater<ll>());
    return vector<ll>(cp.begin(),cp.begin()+min(2,(int)cp.size()));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    vector<ll> A(1<<N);
    rep(i,1<<N) cin>>A[i];
    vector<vector<ll>> dp(1<<N,vector<ll>(2,0));
    rep(i,1<<N) dp[i]={A[i]};
    
    rep(i,N)rep(b,1<<N)if((b&(1<<i))){
        dp[b] = merge(dp[b],dp[b^(1<<i)]);
    }
    
    ll ans=0;
    rep1(i,(1<<N)-1){
        ans = max(ans,dp[i][0]+dp[i][1]);
        cout1(ans);
    }
}

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

#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 repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-10;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


int x, y, z;
void solve() {
    cin >> x >> y >> z;
    swap(x, y); swap(x, z);
    cout << x << " " << y << " " << z << endl;
}

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


Measured memory_bytes: 256
INF = 1000000


def diikstraMethd(G, s):
    # ?????????
    n = len(G)
    # White:0 Gyay:1 Black:2
    color = [0 for _ in range(n)]
    d = [INF for _ in range(n)]
    p = [None for _ in range(n)]

    d[s] = 0

    while True:
        mincost = INF
        for i in range(n):
            if color[i] != 2 and d[i] < mincost:
                mincost = d[i]
                u = i

        if mincost == INF: break

        color[u] = 2

        for v in range(n):
            if color[v] != 2 and M[u][v] != INF:
                if d[u] + M[u][v] < d[v]:
                    d[v] = d[u] + M[u][v]
                    p[v] = u
                    color[u] = 1

    return d


if __name__ == '__main__':
    n = int(input())
    M = [[INF for _ in range(n)] for i in range(n)]
    for _ in range(n):
        tmp = list(map(int, input().split()))
        u = tmp.pop(0)
        k = tmp.pop(0)
        for _ in range(k):
            v = tmp.pop(0)
            c = tmp.pop(0)
            M[u][v] = c
    d = diikstraMethd(M, 0)

    for i in range(n):
        print('{0} {1}'.format(i, d[i]))

Measured memory_bytes: 7924
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  int a[110000];
  int res=1;
  cin >> N;

  rep(i,N) cin >> a[i];

  int trend = 1;
  FOR(i,1,N-1){
    if(trend < 1  && a[i-1] > a[i]) {
      res++;
      trend = 1;
    }
    else if(trend > 1 && a[i-1] < a[i]) {
      res++;
      trend = 1;
    }
    else if(trend == 1) {
      if(a[i-1] < a[i]) trend = 0;
      else if(a[i-1] > a[i]) trend = 2;
    }
  }

  cout << res << endl;
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


	int w, h, x, y;

	cin >> w >> h >> x >> y;

	if(2 * x == w and 2 * y == h){
		cout << fixed << setprecision(6) << (w * h) / 2.0 << " " << 1 << endl;
	}else{
		cout << fixed << setprecision(6) << (w * h) / 2.0 << " " << 0 << endl;
	}





	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

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

	int N;
	cin >> N;

	vector<int> Ws;
	for (int i=0; i<N; i++) {
		int W;
		cin >> W;
		Ws.push_back(W);
	}

	int m = 99999999;
	for (int t=0; t<N; t++) {
		int a = 0, b = 0;
		for (int i=0; i<=t; i++) a += Ws[i];
		for (int i=t+1; i<N; i++) b += Ws[i];

		m = min(m, abs(a-b));
	}

	cout << m << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

vector<pair<int, int> > ans;
vector<vector<int> > v;
int d = 1;

void dfs(int pos)
{
  ans[pos].first = d++;
  rep(i, v[pos].size())
  {
    int next = v[pos][i];
    if (ans[next].first == -1)
    {
      dfs(next);
    }
  }
  ans[pos].second = d++;
}

int main()
{
  int n;
  cin >> n;
  ans.resize(n);
  v.resize(n);
  rep(i, n)
  {
    ans[i] = make_pair(-1, -1);
    int u, k;
    cin >> u >> k;
    u--;
    v[u].resize(k);
    rep(j, k)
    {
      cin >> v[u][j];
      v[u][j]--;
    }
  }

  rep(i, n)
  {
    if(ans[i].first == -1)
      dfs(i);
  }
  rep(i, n)
  {
    cout << i + 1 << " " << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
 
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define FOR(i, to) for (int i = 0; i < (to); ++i)
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
#define MOD 1000000007
#define INF 1000000000LL * 100000000LL
#define Nmax 202020

ll X,Y,Z;
string S;
int N;
int main() {
  cin >> N;
  cin >> S;
  if(N% 2 == 1) {
    cout << "No" << endl;
    return 0;
  } else {
    string a = S.substr(0,N/2);
    if(a + a == S) {
      cout << "Yes" << endl;
    } else cout << "No" << endl;
  }
  return 0;
}
 


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)


//行列累乗
void matpom(ll*mat,int size,ll n,int m){
	ll*temp=(ll*)malloc(size*size*sizeof(ll));
	ll*ans=(ll*)malloc(size*size*sizeof(ll));

	rep(i,0,size)rep(j,0,size)ans[i*size+j]=i==j;
	while(n){
		if(n%2){
			rep(i,0,size*size)temp[i]=0;
			rep(i,0,size)rep(j,0,size)rep(k,0,size)temp[i*size+j]=(temp[i*size+j]+ans[i*size+k]*mat[k*size+j])%m;
			rep(i,0,size*size)ans[i]=temp[i];
		}
		rep(i,0,size*size)temp[i]=0;
		rep(i,0,size)rep(j,0,size)rep(k,0,size)temp[i*size+j]=(temp[i*size+j]+mat[i*size+k]*mat[k*size+j])%m;
		rep(i,0,size*size)mat[i]=temp[i];
		n/=2;
	}
	rep(i,0,size*size)mat[i]=ans[i];

	free(temp);
	free(ans);
}

ll d[100][100];
int main(){
	int v,e;
	scanf("%d%d",&v,&e);
	while(e--){
		int s,t;
		scanf("%d%d",&s,&t);
		d[s][t]=1;
	}
	
	matpom((ll*)d,100,110,(1<<30)-1);
	rep(i,0,v)rep(j,0,v)if(d[i][j]){
		puts("1");
		return 0;
	}
	puts("0");
}



Measured memory_bytes: 2112
import Control.Monad
import Data.List
import Data.Ord
import Data.Maybe

main = do
  n <- readLn :: IO Int
  red <- replicateM n getLine >>= return . map ((\[x,y] -> (x,y)) . map read . words) :: IO [(Int,Int)]
  blue <- replicateM n getLine >>= return . map ((\[x,y] -> (x,y)) . map read . words) :: IO [(Int,Int)]

  print $ length $ solve red blue

  where
    solve red blue = solve' (reverse $ sortBy (comparing snd) red) (sortBy (comparing fst) blue)
    solve' [] _ = []
    solve' _ [] = []
    solve' rs (b:bs)
      | isJust r = (r,b) : solve' (delete (fromJust r) rs) bs
      | otherwise = solve' rs bs
      where r = find (\(x,y) -> x < fst b && y < snd b) rs


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N; cin >> N;
  vector<long long> z, w;
  for(int i = 0; i < N; i++){  
    int x, y; cin >> x >> y;
    z.push_back(x+y);
    w.push_back(x-y);
  }
  sort(z.begin(), z.end());
  sort(w.begin(), w.end());
  cout << max(z[N-1] - z[0], w[N-1] - w[0]) <<endl;
}


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

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T>
vector<T> make_v(size_t size, const T& init){ return vector<T>(size, init); }

template<class... Ts>
auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }


int main() {
    int a, b;
    cin >> a >> b;
    int k = 64;
    auto v = make_v(k, k, 0);
    for (int i = k/2; i < k; ++i) {
        for (int j = 0; j < k; ++j) {
            v[i][j] = 1;
        }
    }
    int x = 0, y = 0;
    while(a-1){
        a--;
        v[y][x] ^= 1;
        x += 2;
        if(x == k) {
            y+=2;
            x=0;
        }
    }
    x = 0, y = k-1;
    while(b-1){
        b--;
        v[y][x] ^= 1;
        x += 2;
        if(x == k) {
            y-=2;
            x=0;
        }
    }
    printf("%d %d\n", k, k);
    for (int i = 0; i < k; ++i) {
        for (int j = 0; j < k; ++j) {
            printf(v[i][j] ? "." : "#");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<n;i++)
const ll INF = 1<<30;
const ll MOD = 1e9+7;
const ll MAX = 1000000;

ll X,Y;

ll fact[MAX], fact_inv[MAX];

// 繰り返し二乗法
ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll comb(ll n, ll r){
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

int main(){
    cin >> X >> Y;
    if((X+Y)%3){cout << 0 << endl; return 0;}
    //n+2m=X, 2n+m=Y
    ll n = -(X-2*Y)/3; ll m = Y-2*n;
    if(n<0 || m<0){cout << 0 << endl; return 0;}

    ll x = MAX;
    fact[0]=1;
    // 階乗の計算
    rep(i, x) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[x]=power(fact[x], MOD-2);
    // 逆元の計算
    for(int i=x-1;i>=0;--i) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;

    cout << comb(n+m,n) << endl;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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


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

    int N, T;
    cin >> N >> T;
    vector<int> cost_vec;

    int tmp_time;
    int tmp_cost;
    for(int i = 0; i < N; i++){
        cin >> tmp_cost >> tmp_time;
        if(tmp_time <= T){
            cost_vec.push_back(tmp_cost);
        }
    }

    if(cost_vec.size() == 0){
        cout << "TLE" << endl;
    }else{
        int ans = 1001;
        for(int i = 0; i < cost_vec.size(); i++){
            chmin(ans, cost_vec[i]);
        }
        cout << ans << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <cstring>

using namespace std;
const int MOD = 1000000007;

int dp[1010][1010];
char table[1010][1010];

int main(){
    int H, W;
    cin >> H >> W;

    memset(dp, 0, sizeof(dp));

    for(int h=0; h<=H; ++h){
        table[h][0] = '.';
    }
    for(int w=0; w<=W; ++w){
        table[0][w] = '.';
    }

    for(int h=1; h<=H; ++h){
        for(int w=1; w<=W; ++w){
            cin >> table[h][w];
        }
    }
    dp[1][1]=1;

    for(int h=1; h<=H; ++h){
        for(int w=1; w<=W; ++w){
            if( table[h-1][w] != '#' && table[h][w-1] != '#' ){
                dp[h][w] += dp[h-1][w] + dp[h][w-1];
                dp[h][w] %= MOD;
            }else if( table[h-1][w] == '#' && table[h][w-1] != '#' ){
                dp[h][w] += dp[h][w-1];
                dp[h][w] %= MOD;
            }else if( table[h-1][w] != '#' && table[h][w-1] == '#' ){
                dp[h][w] += dp[h-1][w];
                dp[h][w] %= MOD;
            }else{
                dp[h][w] = 0;
                dp[h][w] %= MOD;
            }
        }
    }

    cout << dp[H][W] << endl;

}

Measured memory_bytes: 5248
#include <cstdio>
#include <string.h>
#include <iostream>
#include <math.h>
using namespace std;
int main(){
		int N,K;
		cin >> N >> K;
		int s[N];
		for(int i=0; i<N ;i++){
				cin >> s[i];
		}
		int min;
		for(int i=0;i<N-K+1;i++){
				int d;
				d=fmin(fabs(s[i]),fabs(s[K+i-1]))+fabs(s[K+i-1]-s[i]);
				min = fmin(min,d);
				if(i==0)min=d;
		}
		cout << min << endl;
}


Measured memory_bytes: 640
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

void solve(){
	//code
	string s;
	cin>>s;
	if(s=="RRR") cout<<3;
	else if(s=="RRS" or s=="SRR") cout<<2;
	else if(s=="RSS" or s=="SRS" or s=="RSR" or s=="SSR") cout<<1;
	else cout<<0;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 100000
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
int first[MAXN+5], cur[MAXN+5], fa[2][MAXN+5], in[2][MAXN+5], c[MAXN+5], w[MAXN+5], to[MAXN+5], n, tot;
struct Edge{int to,nex,w; Edge(){} Edge(int _to, int _nex, int _w):to(_to),nex(_nex),w(_w){}}e[(MAXN<<2)+5]; bool book[(MAXN<<2)+5];
inline void Add(int a, int b, int w){e[tot] = Edge(b,first[a],w), first[a] = tot++, e[tot] = Edge(a,first[b],w), first[b] = tot++;}
void DFS(int p){for(rint u = cur[p]; ~u; u = cur[p]) if(cur[p]=e[u].nex, !book[u] && !book[u^1]) !e[u].w ? to[e[u^1].to] = e[u].to, ++c[e[u].to], --c[e[u^1].to] : 0, book[u] = true, DFS(e[u].to);}
int main()
{
	n = read(), memset(first,-1,sizeof first); for(rint k = 0, i; k < 2; k++) for(i = 1; i <= n; ++in[k][fa[k][i++]=max(read(),0)]);
	for(rint i = 1; i <= n; i++) if((in[0][i]+in[1][i])&1){puts("IMPOSSIBLE"); return 0;} puts("POSSIBLE");
	for(rint i = 1; i <= n; Add(i,fa[0][i],0), Add(i,fa[1][i],1), i++); memcpy(cur,first,sizeof cur), DFS(1); for(rint i = 1; i <= n; printf("%d ",c[i]), i++); putchar('\n'); return 0;
}

Measured memory_bytes: 12160
package main

import "fmt"

func main() {
	// Code for B - Go to Jail
	var N int
	fmt.Scan(&N)

	var count int
	var D1, D2 int
	var flag int
	for i := 0; i < N; i++ {
		fmt.Scan(&D1, &D2)
		if D1 == D2 {
			count++
		} else {
			count = 0
		}

		if count == 3 {
			flag++
		}
	}

	if flag == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1768
#include <iostream>
#include <vector>
#include <map>
#include <bitset>

using namespace std;

vector <int> comp, permutacion;
vector <bool> visit;
vector <vector <int> > ady;

void DFS(int n)
{
	visit[n] = true;
	comp.push_back(n);
	
	for(int i=0; i<ady[n].size(); i++)
		if(!visit[ady[n][i]])
			DFS(ady[n][i]);
}

int main() {
	int n, m;
	cin >> n >> m;
	ady.resize(n+1);
	visit = vector <bool> (n+1, false);
	permutacion.resize(n);
	
	for(int i=0; i<n; i++)
		cin >> permutacion[i];
	
	int a, b;
	for(int i=0; i<m; i++)
	{
		cin >> a >> b;
		ady[a].push_back(b);
		ady[b].push_back(a);
	}
	int res = 0;
	for(int i=1; i<=n; i++)
	{
		if(!visit[i])
		{
			comp.clear();
			DFS(i);
			map<int, int> mapa1, mapa2;
			
			for(int j=0; j<comp.size(); j++)
			{
				mapa1[comp[j]]++;
			}
			
			for(int j=0; j<comp.size(); j++)
			{
				if(mapa1[permutacion[comp[j]-1]])
				{
				mapa1[permutacion[comp[j]-1]]--;
				res++;
				}
					
			}
			
			
			
		}
	}
	
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 14200
def main():
    n = int(input())
    a = list(map(int, input().split()))
    dp = [-10**15]*(n+1)
    dp[2] = max(a[0], a[1])
    if n > 2:
        dp[3] = max(a[:3])
        aa = a[0]+a[2]
        for i in range(4, n+1):
            if i%2:
                aa += a[i-1]
                dp[i] = max(dp[i-1], dp[i-2]+a[i-1])
            else:
                dp[i] = max(aa, dp[i-2]+a[i-1])
    print(dp[n])

if __name__ == "__main__":
    main()

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,d; cin >> n >> d;
    cout << (n+2*d)/(2*d+1) << endl;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

// B

void solve() {

}

int main() {
  string s;
  cin >> s;
  int sum = 0;
  rep(i,(int)s.size()){
    sum += ( s[i] - '0' );
    sum %= 9;
  }
  puts(sum?"No":"Yes");
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int pm(int x, int y){
    int res=0;
    for(int i=0; i<y; ++i){
        x/=2;
    }
    res = -2*(x%2)+1;
    return res;
}

int main(){
    int N, M;
    cin >> N >> M;
    
    if (M==0){
        cout<<0<<endl;
        return 0;
    }
    
    vector<vector<long> >v;
    v = vector<vector<long> >(N, vector<long>(3));
    for (auto it1 = v.begin(); it1 != v.end(); ++it1){
        for(auto it2 = it1->begin(); it2 != it1->end(); ++it2){
            cin >> *it2;
        }
    }
    vector<long> scores;
    long mx = 0;
    for (int i=0; i<8; ++i){
        for(auto it1 = v.begin(); it1 != v.end(); ++it1){
            long s=0;
            s = (*it1)[0]*pm(i,0) + (*it1)[1]*pm(i,1) + (*it1)[2]*pm(i,2);
            scores.push_back(s);
        }
        sort(scores.begin(), scores.end());
        long sco = accumulate((scores.end()-M), scores.end(), 0L);
        scores.clear();
        
        mx = max(mx , sco);
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

char tmp[100];
string s, t = "CODEFESTIVAL2016";

int read() {
  if (scanf("%s", tmp) < 1) {
    return false;
  }
  s = tmp;
  return true;
}

void solve() {
  int ans = 0;
  for (int i = 0; i < sz(s); i++) {
    ans += (s[i] != t[i]);
  }
  printf("%d\n", ans);
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
n=int(input())
*a,=map(int,input().split())
o=e=0
for i in a:
    if i%2:
        o+=1
    else:
        e+=1
if not o or not e:
    print(0)
elif o%2:
    print(n-1)
else:
    print(n-2)


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

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

int main(){
    string s, t;
    cin >> s >> t;
    bool a = (s.at(0) == t.at(2) && s.at(1) == t.at(1)) && s.at(2) == t.at(0);
    if(a==true){
        cout << "YES" << endl;
    }
    else if (a==false){
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
N, T = map(int, input().split())

pushed_time = list(map(int, input().split()))
period = [pushed_time[0], pushed_time[0] + T]
# 今流れているお湯の [出始めた時刻, 止まる時刻]
duration = 0

for t_i in pushed_time[1:]:
    if t_i <= period[1]: # お湯が止まる前に次の人がボタンを押すならば
        period[1] = t_i + T # お湯が止まる時刻は {押した時} + T になる
    else:
        duration += period[1] - period[0]
        # お湯が止まる。止まるまでの時間をお湯が出ていた総時間に加算
        period = [t_i, t_i + T] # 次の区間が始まる
duration += period[1] - period[0]

print(duration)


Measured memory_bytes: 25200
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;

main(){
    ll n=in(),h=in(),d=in();
    ll ans=0;
    vector<ll> rui(n+100),dp(h+d+100);
    rui[1]=1;
    ll r=1;
    rep2(i,1,n-1){
        rui[i+1]=r*(i+1)%MOD+rui[i];
        r=(r*(i+1))%MOD;
        rui[i+1]%=MOD;
    }
    dp[0]=r;
    dp[1]=MOD-r;
    rep2(i,0,h-1){
        dp[i+1]=(dp[i]+dp[i+1]+dp[i]*rui[n]%MOD)%MOD;
        dp[i+d+1]=(dp[i+d+1]-dp[i]*rui[n]%MOD+MOD)%MOD;
        if(i+d>=h)ans=(ans+dp[i])%MOD;
    }
    cout<<ans%MOD;
}



Measured memory_bytes: 23680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#include <limits>
#include <iomanip>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    //
    vector<int> abc0(26,0);
    vector<int> abc1(26,0);
    //
    int common=0;
    int most=0;
    //
    for(int i=1;i<N;i++){
        common=0;
        vector<int> abc0(26,0);
        vector<int> abc1(26,0);
        for(int j=0;j<i;j++){
            int num0 = (int)(S[j]-'a');
            abc0[num0]++;
        }
        for(int k=i;k<N;k++){
            int num1 = (int)(S[k]-'a');
            abc1[num1]++;
        }
        for(int l=0;l<26;l++){
            if((abc0[l]>=1)&&(abc1[l]>=1)){
                common++;
            }
        }
        if(common > most){
            most = common;
        }
    }
    cout << most << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define mp(a,b) make_pair(a,b)
#define pi acos(-1)
#define pii pair<int,int>
#define pb push_back
#define lowbit(x) ((x)&(-x))
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int maxn = 1e5 + 10;
const int maxm = 1e6 + 10;
const ll mod =  998244353;



int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    int n;
    scanf("%d",&n);
    int mx = 0, sum = 0;
    for(int i = 0; i < n; i++) {
        int a;
        scanf("%d",&a);
        sum += a, mx = max(mx, a);
    }
    sum -= mx;
    if(sum > mx) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  string s, t;
  cin >> N >> s >> t;

  long num = N;
  
  while (num  > 0) {
    if (s.substr(N-num, num) == t.substr(0, num)) break;
    num--;
  }

  cout << 2 * N - num << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2){
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}
 
// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;
 
int main(){
    ll b,x,c,y=0,n,m,k,l,r,w,sum=0,sum2=0,ans=0;
    string s,t;
    bool f=true;
    cin >> x;
    n = x/100;
    if(x%100 <= 5*n)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;
  for(char i='a';i<='z';i++){
    if(s+i==t){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
z['   '],i;
main(j){
	for(;++i<2e3;)
		for(j=z[i>>5]&1<<i?1e7:-2*i*~i;j<5e6;j+=i-~i)z[j>>5]|=1<<j;
	for(;~scanf("%d",&i);)
		for(j=~i/-2;i;)
			z[--j>>5]&1<<j|
			z[j-1>>5]&1<<j-1|
			z[j-3>>5]&1<<j-3|
			z[j-4>>5]&1<<j-4||printf("%d\n",j*2+1,i=0);
}

Measured memory_bytes: 1020
#include <stdio.h>
#include <stdlib.h>
void Lucas(char a, char b, char c, char d);
void Lucas(char a, char b, char c, char d)
{
    int x1, x2, x3, x4, x5, x6, x7, x8;
    a -= 48;
    b -= 48;
    c -= 48;
    d -= 48;
    x1 = a+b+c+d;
    x2 = a+b+c-d;
    x3 = a+b-c+d;
    x4 = a-b+c+d;
    x5 = a+b-c-d;
    x6 = a-b+c-d;
    x7 = a-b-c+d;
    x8 = a-b-c-d;
    if (x1==7)
    {
        printf("%d+%d+%d+%d=7\n",a,b,c,d);
    }
    else if (x2==7)
    {
        printf("%d+%d+%d-%d=7\n",a,b,c,d);
    }
    else if (x3==7)
    {
        printf("%d+%d-%d+%d=7\n",a,b,c,d);
    }
    else if (x4==7)
    {
        printf("%d-%d+%d+%d=7\n",a,b,c,d);
    }
    else if (x5==7)
    {
        printf("%d+%d-%d-%d=7\n",a,b,c,d);
    }
    else if (x6==7)
    {
        printf("%d-%d+%d-%d=7\n",a,b,c,d);
    }
    else if (x7==7)
    {
        printf("%d-%d-%d+%d=7\n",a,b,c,d);
    }
    else if (x8==7)
    {
        printf("%d-%d-%d-%d=7\n",a,b,c,d);
    }
}

int main()
{
    char a, b, c, d;
    scanf("%c%c%c%c",&a,&b,&c,&d);
    Lucas(a,b,c,d);
    return 0;
}


Measured memory_bytes: 128