akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine(); //読み飛ばし

            string line = Console.ReadLine();

            int[] nums = line.Split(' ').Select(c => int.Parse(c)).OrderBy(x=>x).ToArray();

            if (nums.Length % 2 == 1)
            {
                Console.WriteLine("0");
                return;
            }

            int N = nums.Count();

            Console.WriteLine((nums[N/2]-nums[N/2-1]).ToString());
            
        }

        private static bool Candevide(int[] data , int threshold)
        {
            if (data.Length % 2 == 1)
            {
                return false;
            }

            return data.Where(num => num >= threshold).Count() == data.Count() / 2;
        }
    }
}


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

    void solve() {
	    ll n, h;
	    cin >> h >> n;
	    ll a[n], sum  = 0;
	    for(ll i = 0; i < n; i++) cin >> a[i], sum+=a[i];
	    cout << (sum >= h ? "Yes": "No") << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    }


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
using namespace std;
int main(){

  int a,b,d,r;
  double f;

  cin >>a>>b;

  d=a/b;
  r=a%b;
  f=(double)a/b;

  printf("%d %d %.5lf\n",d,r,f);

  return 0;
}

Measured memory_bytes: 1192
#include <iostream>
using namespace std;
int main(void){
    //Your code here!
    int n,k,i;
    int ans=0;
    std::cin >>n>>k ;
    string s;
    std::cin >>s ;
    int num=0;
    int a[n];
    if(s[0]=='0'){a[0]=0;num++;}
    for (i=1;i<n;i++){
        if(s[i-1]=='0'&&s[i]=='1'){
            a[num]=i;
            num++;
        }
        if(s[i-1]=='1'&&s[i]=='0'){
            a[num]=i;
            num++;
        }
    }
    if (s[n-1]=='1'){a[num]=n;num++;}
    if (s[n-1]=='0'){a[num]=n;num++;a[num]=n;num++;}
    //for (i=0;i<num;i++){std::cout << a[i] << std::endl;}
    if(num-1<=2*k)std::cout << n << std::endl;
    else{
        for (i=0;i<(num-2*k+1)/2;i++){
            if (i==0)ans=a[2*k];
            else {
                if(a[2*(k+i)]-a[2*i-1]>ans)ans=a[2*(k+i)]-a[2*i-1];
            }
        }
        std::cout << ans << std::endl;
    }
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    string S;
    cin >>S;
    sort(all(S));
    rep(i,S.size()-1){
        if(S[i+1]==S[i]){
            cout<<"no"<<endl;
            return 0;
        }
    }
    
    cout << "yes" << endl;


    return 0;
    

}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  ll ans = 1;
  rep(i,N){
    ans *= (i+1);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


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

int dp[100000][3];
int arr[100000][3];
int solve(int a, int v) {
    
    if(a==0) return dp[a][v] = arr[a][v];
    if(dp[a][v] != 0) return dp[a][v];
    for(int i = 0; i < 3; i++) {
        if(i != v) {
            dp[a][v] = max(dp[a][v], solve(a-1, i) + arr[a][v]);
        }
    }
}

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

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> arr[i][j];
        }
    }
    for(int i = 0; i < 3; i++) dp[0][i] = arr[0][i];
    if(n-1 != 0) {
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            if(i != j) {
                dp[n-1][i] = max(dp[n-1][i], solve(n-2, j) + arr[n-1][i]);
            }
        }
        
    }
    }
    int ans = 0;
    /*for(int i = 0; i < n; i++) {
       for(int j = 0; j< 3; j++) {
           cout << dp[i][j] << " ";
       }
       cout << endl;
    }*/
    //cout << endl;
    for(int i = 0; i < 3; i++) {
        ans = max(ans, dp[n-1][i]);
    }
    cout << ans << endl;
    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int H,W,h,w; cin >> H >> W >> h >> w;
    cout << H*W - (h*W+H*w-h*w) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
typedef long long ll;
const int NIL = -1;

struct Node{
  int cost, x, y;
};
 
int main() {
    int H, W, D;
    cin >> H >> W >> D;
    int A[H][W];
    Node T[H*W+1];
    T[0] = {0, NIL, NIL};
    rep(i,H){
      rep(j,W){
        cin >> A[i][j];
        T[A[i][j]].x = i; T[A[i][j]].y = j; T[A[i][j]].cost = NIL;
      }
    }

    rep(i,D){
      T[i].cost = 0;
    }

    for(int i = 1; i <= H*W; i++){
      if (T[i].cost == NIL){
        T[i].cost = abs(T[i].x - T[i-D].x) + abs(T[i].y - T[i-D].y) + T[i-D].cost;
      }
    }


    int Q;
    cin >> Q;
    int L[Q],R[Q];
    rep(i,Q){
      cin >> L[i] >> R[i];
    }

    rep(i,Q){
      cout << T[R[i]].cost-T[L[i]].cost << endl;
    }
    


    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define SZ(s) ((int)(s.size()))
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ALL(a) (a).begin(), (a).end()
typedef pair<int,int> PI;




int main() {
  int N, H;
  string S[110];
  int T[110];
  cin >> N >> H;
  rep(i, N) {
    cin >> S[i] >> T[i];
  }

  int total = 0, success = 0;
  rep(i, N) {
    int j = 0;
    int t = 0;
    while(true) {
      string out;
      if (j) out = string(j, '_') + S[i].substr(j);
      else out = S[i];
      printf("? %s\n", out.data()); fflush(stdout);
      char c[2];
      scanf("%s", c);
      total++;
      if (c[0] == tolower(S[i][j])) {
        j++;
        success++;
        if (j == int(S[i].size())) break;
      } else {
        t++;
        if (t > T[i]) {
          H--;
          break;
        }
      }
    }
    if (H == 0) {
      printf("! Game Over\n"); fflush(stdout);
      return 0;
    }
  }
  long long a = (long long)1000 * success / total;
  printf("! Game Clear %lld.%lld\n", a/10, a%10);
  fflush(stdout);
}

Measured memory_bytes: 1300
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	int n, d;
	cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	rep(p, n)rep(q, d) cin >> x[p][q];
	int ans = 0;
	int a;
	for(int i=0;i<n;i++)
	{
		for (int t = i + 1; t < n; t++)
		{
			a = 0;
			for(int p = 0; p < d ; p++ )
			{
				a += (x[i][p] - x[t][p])*(x[i][p] - x[t][p]);
			}
 
			for (int q = 1; q <= a; q++)
			{
				if (q * q == a)
				{
					ans++;
				}
			}

		}
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
void topsort(int v, vector<int> &visited, multimap<int, int> &mp, stack<int> &stk)
{
	visited[v] =1;
	multimap<int, int>::iterator lb,ub;
	lb = mp.lower_bound(v);
	ub = mp.upper_bound(v);
	while(lb!=ub)
	{
		if(visited[lb->second]!=1)
			topsort(lb->second, visited, mp, stk);
		lb++;
	}
	stk.push(v);

}
int main()
{
	int n,m;
	multimap<int,int> mp;
	cin >> n >> m;
	for(int i=0; i<m; i++)
	{
		int v1,v2;
		cin >> v1 >> v2;
		mp.insert(make_pair(v1,v2));
	}
	
	int ans = INT_MIN;
	
	vector<int> v(n+1, 0);
	stack<int> stk;
	vector<int> visited(n+1,0);

	for(int i=1; i<=n; i++)
	{
		if(visited[i]!=1)
			topsort(i, visited, mp, stk);
		
	}
	v[stk.top()] =0;
	while(!stk.empty())
	{
		int val = stk.top();
		stk.pop();
		multimap<int, int>::iterator lb,ub;
		lb = mp.lower_bound(val);
		ub = mp.upper_bound(val);
		while(lb!=ub)
		{
			v[lb->second] = max(v[lb->second], v[lb->first]+1);
			ans = max(ans, v[lb->second]); 
			lb++;

		}

	}
	// for(int i=1;i<=n;i++)
	// {
	// 	cout << v[i] << " ";
	// }
	// cout << endl;
	cout << ans << endl;
	return 0;
}

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

int main() {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int ans = a*x+b*y;
  
  for (int i = 0; i <= max(x,y);i++) { //i枚分購入
    int sum = 0;
    sum += i*c*2; //i枚分なので、値段は2倍
    if (x > i) sum += (x-i) * a;
    if (y > i) sum += (y-i) * b;
    ans = min(ans,sum);
  }
  cout << ans << endl;
}


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

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

	vector <int> A(N, 0);

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

	for (int i = 0; i < N ; i++){
		int v,j;
		v = A[i];
		j = i - 1;

		while (j >= 0 && A[j]>v){
		
			A[j + 1] = A[j];//A[N-2]=A[N-3]
			j -- ;
			A[j + 1] = v;
		}

		for (int k = 0; k < N; k++){
			cout << A[k];
			if (k != N - 1)cout << " ";
		}cout << endl;
	
	}

	return 0;
}

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

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

template <typename T, typename U>
bool chmin(T &a, const U &b){
  return (a > b ? a = b, true : false);
}

template <typename T, typename U>
bool chmax(T &a, const U &b){
  return (a < b ? a = b, true : false);
}

template <typename T, size_t N, typename U>
void fill_array(T (&a)[N], const U &v){
  std::fill((U*)a, (U*)(a + N), v);
}

template <typename T, size_t N, size_t I = N>
auto make_vector(const std::array<int, N> &a, T value = T()){
  static_assert(I >= 1);
  static_assert(N >= 1);
  if constexpr (I == 1){
    return std::vector<T>(a[N - I], value);
  }else{
    return std::vector(a[N - I], make_vector<T, N, I - 1>(a, value));
  }
}

template <typename T>
std::ostream& operator<<(std::ostream &s, const std::vector<T> &a){
  for(auto it = a.begin(); it != a.end(); ++it){
    if(it != a.begin()) s << " ";
    s << *it;
  }
  return s;
}

template <typename T>
std::istream& operator>>(std::istream &s, std::vector<T> &a){
  for(auto &x : a) s >> x;
  return s;
}

template <typename F>
std::pair<int, int> rho(int N, int first, F f){
  std::vector<int> check(N);

  int tail = 0, cycle = 0;
  int a = first, i = 1;
  while(true){
    check[a] = i;

    a = f(a);
    ++i;
    if(check[a] > 0){
      tail = check[a] - 1;
      cycle = i - check[a];
      break;
    }
  }

  return {tail, cycle};
}


namespace haar_lib {}

namespace solver {
  using namespace haar_lib;

  constexpr int m1000000007 = 1000000007;
  constexpr int m998244353 = 998244353;

  void init(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(12);
    std::cerr << std::fixed << std::setprecision(12);
    std::cin.exceptions(std::ios_base::failbit);
  }

  void solve(){
    int64_t N, X, M; std::cin >> N >> X >> M;

    auto [tail, cycle] = rho(M, X, [M](int64_t a){return a * a % M;});

    int64_t ans = 0;

    if(N <= tail){
      int64_t a = X;
      for(int i = 0; i < N; ++i){
        ans += a;
        a = a * a % M;
      }
    }else{
      int64_t a = X;
      for(int i = 0; i < tail; ++i){
        ans += a;
        a = a * a % M;
      }

      N -= tail;

      {
        int64_t b = a, s = 0;
        for(int i = 0; i < cycle; ++i){
          s += b;
          b = b * b % M;
        }

        ans += s * (N / cycle);
      }

      {
        int64_t b = a;
        for(int i = 0; i < N % cycle; ++i){
          ans += b;
          b = b * b % M;
        }
      }
    }

    std::cout << ans << "\n";
  }
}

int main(){
  solver::init();
  while(true){
    try{
      solver::solve();
    }catch(const std::istream::failure &e){
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3916
<?php

$N = trim(fgets(STDIN));
$S = array();
$P = array();
$I = array();

for ( $i = 0; $i < $N; $i++ ) {
    list($s, $p) = explode(" ",trim(fgets(STDIN)));
    $S[] = $s;
    $P[] = $p;
    $I[] = $i;
}
$SPI = array($S, $P, $I);
array_multisort($SPI[0], SORT_ASC, SORT_STRING,
                $SPI[1], SORT_NUMERIC, SORT_DESC
            );

for ($i=0; $i < $N; $i++) { 
    for ($j=0; $j < $N; $j++) {
        if ($SPI[0][$i] == $S[$j] && $SPI[1][$i] == $P[$j]) {
            echo ($j+1) . "\n";
            break;
        }
    }
}

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,a,b;
	cin >> n >> a >> b;
	if((b - a) % 2) cout << min(a,n - b + 1) + (b - a) / 2 << endl;
	else cout << (b - a) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
constexpr int INF = 1e9, MOD = 1e9 + 7;
constexpr int64_t LINF = 5e18, LMOD = 998244353;
// #include <atcoder/all>
// using namespace atcoder;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string s; cin >> s;
	if(s.back() == 's') s += "es";
	else s += "s";
	cout << s << '\n';
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll n; cin >> n;
	VI a(n); REP(i,n) cin >> a[i];
	VI p(60,0);
	REP(i,n){
		REP(j,60){
			if(a[i]>>j&1)
				p[j]++;
		}
	}
	ll ans=0;
	REP(i,60){
		ll a=(p[i]*(n-p[i]))%MOD;
		ll b=(1ll<<i)%MOD;
		ans+=(a*b)%MOD;
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
N = int(input())
P = list(map(int,input().split()))
for i in range(N):
  if P[i] == i+1:
    P[i] = True
  else:
    P[i] = False
ans = 0
for i in range(N):
  if P[i]:
    ans+=1
    if i+1 < N and P[i+1]:
      P[i+1] = False
print(ans)

Measured memory_bytes: 20488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const string yes = "Yes";
const string no = "No";

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  if (n%2) {
    cout << no << endl;
    return 0;
  }
  for (int i=0; i<n; i+=2) {
    if (s[i]=='h' && s[i+1]=='i') {
      cout << yes << endl;
      return 0;
    }
  }
  cout << no << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce
from operator import mul
from pprint import pprint



sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

h, w, k = LI()
sy, sx, gy, gx = LI()
cost = [[INF] * w for _ in range(h)]
cost[sy - 1][sx - 1] = 0
grid = SR(h)
q = deque([(sy - 1, sx - 1)])
while q:
    cy, cx = q.popleft()
    for i, j in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        for l in range(1, k + 1):
            ny, nx = cy + i * l, cx + j * l
            if 0 <= nx < w and 0 <= ny < h and grid[ny][nx] == "." and cost[ny][nx] >= cost[cy][cx] + 1:
                if cost[ny][nx] == INF:
                    q.append((ny, nx))
                    cost[ny][nx] = cost[cy][cx] + 1
            else:
                break


print(cost[gy - 1][gx - 1] if cost[gy - 1][gx - 1] != INF else -1)










Measured memory_bytes: 120452
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define clt(x) 63-__builtin_clzll(x)
#define bct(x) __builtin_popcountll(x)
#define all(v) (v).begin(),(v).end()
#define pi pair<ll,ll>
#define vi vector<ll>
#define vpi vector<pair<ll,ll>>
#define maxq priority_queue<ll>
#define minq priority_queue<ll,vector<ll>, greater<ll>>
#define cont continue;
#define reto return 0;
#define sz size()
#define spmod 1116295198451
#define p 1000000007
#define md 998244353 
#define N 2e5+10
//typedef tree<int,null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> //pbds;

ll power(ll x, ll y ) 
{ 
    ll res = 1;
    x = x % p; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n;
  cin>>n;
  ll ans=power(10,n);
  ll x=2*power(9,n);
  x%=p;
  x-=power(8,n);
  x+=p;
  x%=p;
  ans+=p;
  ans-=x;
  ans%=p;
  deb(ans)
  //deb(ans)
}

Measured memory_bytes: 3612
#pragma GCC optimize("Ofast", "unroll-loops")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int N, M;
int G[8][8];

void input() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int a, b; cin >> a >> b;
		--a, --b;
		G[a][b] = 1;
		G[b][a] = 1;
	}
}

bool judge(vector<int>& lis) {
	int now = 0;
	for (int i = 0; i < N - 1; ++i) {
		if (!G[now][lis[i]])
			return false;
		now = lis[i];
	}
	return true;
}

int main() {
	input();
	ll res = 0;
	vector<int> lis(N - 1);
	for (int i = 0; i < N - 1; ++i)
		lis[i] = i + 1;
	do {
		if (judge(lis)) ++res;
	} while (next_permutation(lis.begin(), lis.end()));
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
    #include<string.h>
    main()
    {
    	int w=0,x=0,p=0,len,i,y=0,z=0,cnt=0,c,cex=0;
    	char s[10000];
    	scanf("%s",s);
    	len=strlen(s);
    	if(s[0]=='A')
    	{
    		w=1;
    	}
    	for(i=2;i<len-1;i++)
    	{
    		if(s[i]>='A' && s[i]<='Z')
    		{
    			cnt++;
    			c=i;
    		}
    	}
    	
    	if(cnt==1 && s[c]=='C')
    	{
    		x=1;
    	}
    	if(s[len-1]=='C' || (s[len-1]>='a' && s[len-1] <='z'))
    	{
    		y=1;
    	}
    	
    	for(i=1;i<len-1;i++)
    	{
    		if(i!=c){
    		if(s[i]>='a' && s[i]<='z')
    		{
    			z=1;
    		}
    		else if(s[i]<'a' || s[i]>'z'){
    		break;}}
    	}
    	
    	if(w==1 && x==1 && y==1 && z==1)
    	{
    		printf("AC\n");
    	}
    	else printf("WA\n");
    	//printf("%d%d%d%d",w,x,y,z);
    }
    	
     

Measured memory_bytes: 128
#include <stdio.h>

 int main(void)
 {
 int a[2][4] = {0}, i;
 double r, l;

 while(scanf("%lf %lf", &l, &r) == 2){
 ++ a[0][(l < 1.1) + (l < 0.6) + (l < 0.2)];
 ++ a[1][(r < 1.1) + (r < 0.6) + (r < 0.2)];
 }
 for(i = 0; i < 4; ++ i) printf("%d %d\n", a[0][i], a[1][i]);
 return 0;
}

Measured memory_bytes: 2564
K,X=map(int,input().split())

base=[]

if X<=-1000000+K:
    for i in range(K):
        base.append(-1000000+K)
        if X+i>-1000000+K:
            base.append(X+i)
    answer=sorted(base)
else:
    for j in range(K):
        base.append(X-j)
        if j>=1:
            base.append(X+j)
    answer=sorted(base)

print(' '.join(map(str,answer)))

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

int main(){
	LL n,k,sum = 0;
	cin >> n >> k;
	for(LL i = k + 1LL;i <= n;i++){
		for(LL j = 1LL;j <= n;j++){
			if(j * i > n){
				if((j - 1LL) * i == n) break;
				LL p = 0;
				if(k == 0) p = 1LL;
				LL ans = max(n - (j * i - (i - k - p)) + 1LL,0LL);
				sum += ans;
				break;
			}
			else sum += i - k;
		}
	}
	cout << sum << endl;
}

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

int main(){
  int d;cin>>d;
  if(d==22)cout<<"Christmas Eve Eve Eve"<<endl;
  if(d==23)cout<<"Christmas Eve Eve"<<endl;
  if(d==24)cout<<"Christmas Eve"<<endl;
  if(d==25)cout<<"Christmas"<<endl;
  return 0;
}


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

int main()
{
	int a, b;
	cin >> a >> b;
	int ans1 = a + a - 1;
	int ans2 = b + b - 1;
	int ans3 = a + b;
	cout << fmax(fmax(ans1, ans2), ans3) << endl;
}


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

int n, m, ans = 0;
int a[1005] = {0};

int main() {
  while(1) {
    cin >> n >> m;
    if(n + m == 0) break;
    ans = 0;
    for(int i = 0; i < n; ++i) cin >> a[i];
    for(int i = 0; i < n; ++i)
      for(int j = i + 1; j < n; ++j)
        if(a[i] + a[j] <= m) ans = max(ans, a[i] + a[j]);
    if(ans != 0)
      cout << ans << endl;
    else
      cout << "NONE" << endl;
  }
  return 0;
}


Measured memory_bytes: 3084
n,w=map(int,input().split())

weight=[]
value=[]
for i in range(n):
  a,b=map(int,input().split())
  weight.append(a)
  value.append(b)

xxx=sum(value)
dp=[[float('inf')]*(sum(value)+1) for i in range(n+1)]
dp[0][0]=0

for i in range(n):
  for j in range(xxx+1):
    dp[i+1][j]=min(dp[i+1][j],dp[i][j])                             #+1、個数制限なし
    dp[i+1][min(j+value[i],xxx)]=min(dp[i+1][min(j+value[i],xxx)],dp[i][j]+weight[i])

ans=0
for i in range(xxx+1):
  if dp[-1][i]<=w:
    ans=max(ans,i)

print(ans)


Measured memory_bytes: 328664
// 再提出

#include <iostream>
#include <map>
 
using namespace std;
 
int main() {
	int n;
	map<int, int> ma;
	int m;
 
	cin >> n;
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		ma[d]++;
	}
 
	cin >> m;
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		if (--ma[t] < 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
 
	cout << "YES" << endl;
 
	return 0;
}

Measured memory_bytes: 9600
input = raw_input

h, w = map(int, input().split(" "))
t =  h *w 

if 1 in [h, w]:
    out = 1
else:
    if w % 2 == 1: 
        n1 = 1 + ((w-1) // 2) 
        n2 = ((w-1) // 2)
    else:
        n1 = w // 2
        n2 = n1

    if h % 2 == 1: 
        h1 = 1 + ((h-1) // 2) 
        h2 = ((h-1) // 2)
    else:
        h1 = h // 2
        h2 = h1

    out = h1 * n1 + h2 * n2
print(out)

Measured memory_bytes: 27884
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define double long double
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = a; i < (int)(b); ++i)

using namespace std;

int32_t main() {
    int n;
    cin >> n;
    int h[n + 1];
    FOR(i, 1, n + 1) {
        cin >> h[i];
    }
    int d[n + 1];
    d[1] = 0;
    d[2] = abs(h[1] - h[2]);
    FOR(i, 3, n + 1) {
        d[i] = min(abs(h[i] - h[i-2]) + d[i-2], abs(h[i] - h[i-1]) + d[i - 1]);
    }
    cout << d[n] << endl;
    return 0;
}

Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define PB push_back
#define INF 1000000001
#define INFL 1000000000000000001
#define M 1000000007
string s;
ll n,k;
vector<ll>q;
int main(void){
	cin>>s>>k;
	n=s.size();
	ll l=1;
	for(int i=1;i<=n;i++){
		if(i==n||s[i-1]!=s[i]){
			q.PB(l);
			l=0;
		}
		l++;
	}
	ll ans=0;
	if(s[0]!=s[n-1]){
		for(int i=0;i<q.size();i++)ans+=q[i]/2LL;
		ans*=k;
	}else{
		if(q.size()==1){
			ans=n*k/2LL;
		}else{
			for(int i=1;i+1<q.size();i++)ans+=q[i]/2LL;
			ans+=(q[0]+q.back())/2LL;
			ans*=(k-1LL);
			for(int i=0;i<q.size();i++)ans+=q[i]/2LL;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int area = a * b;
    int length = (a + b) * 2;
    System.out.println(area + " " + length);
  }
}


Measured memory_bytes: 26116
#include <iostream>
using namespace std;
int main()
{int n,r;
 cin>>n;
 r=n%10;
 if(r==2||r==4||r==5||r==7||r==9)
   cout<<"hon";
 else if(r==3)
   cout<<"bon";
   else
     cout<<"pon";
}
 

Measured memory_bytes: 3616
//In The Name Of Godd
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef pair<ll, ll> ii;
typedef pair<int, ii> iii;
typedef pair<double, double> dd;
typedef pair<dd, double> ddd;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<dd> vdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;

#define forn(i, n) for (ll i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define inf 100000000000
#define eps 1e-9
const int maxn = 1e5 + 100;
vi graph[maxn];
bool vis[maxn];
ll dp[maxn];

void dfs(int v, vi &cur) {
  vis[v] = true;
  for(auto &e: graph[v]) if(!vis[e])
    dfs(e, cur);
  cur.push_back(v);
}

int main() {
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  forn(i, m) {
    int x, y; cin >> x >> y;
    x--, y--;
    graph[x].push_back(y);
  }
  deque<int> ord;
  forn(i, n) if(!vis[i]) {
    vi cur;
    dfs(i, cur);
    for(auto &e: cur) ord.push_front(e);
  }
  for(auto &e: ord) {
    for(auto &ee: graph[e]) dp[ee] = max(dp[ee], dp[e] + 1);
  }
  // for(auto &e: ord) cerr << e + 1 << ' ';
  cout << endl;
  ll ans = 0;
  forn(i, maxn) ans = max(ans, dp[i]);
  cout << ans << endl;
}


Measured memory_bytes: 9800
import java.util.Scanner;
 
public class Main {
 
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt();
		int w = scanner.nextInt();
		String[] s = new String[h];
 
		for (int i = 0; i < h; i++) {
			s[i] = scanner.next();
		}
		for (int i = 0; i < w + 2; i++) {
			System.out.print("#");
		}
		System.out.println("");
		for (int i = 0; i < h; i++) {
			System.out.print("#");
			System.out.print(s[i]);
			System.out.println("#");
		}
		for (int i = 0; i < w + 2; i++) {
			System.out.print("#");
		}
	}
}

Measured memory_bytes: 23764
l, r = map(int, input().split())

if r - l >= 673:
    print(0)
    exit()
else:
    ans = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, i * j % 2019)
    print(ans)

Measured memory_bytes: 9176
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	string s;
	cin>>s;
	int n=s.size();
	vector<int> v;
	for(int i=0;i<n;i++){
		if(s[i]=='W'){
			v.push_back(i);
		}
	}
	ll sum=0;
	for(int i=0;i<v.size();i++){
		sum += v[i]-i;
	}
	cout<<sum<<endl;
	//cout<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 4380
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <tuple>
int n, m, clk, cnt;
std::vector<std::vector<std::pair<int, int>>> e;
std::vector<int> a, b, ans, dfn, low, belong, stk;
std::vector<std::vector<int>> f;
void dfs(int u) {
    stk.push_back(u);
    dfn[u] = low[u] = clk++;
    for (auto &&edge : e[u]) {
        int v, i;
        std::tie(v, i) = edge;
        if (dfn[v] == -1) {
            dfs(v);
            low[u] = std::min(low[u], low[v]);
        } else if (belong[v] == -1) {
            low[u] = std::min(low[u], dfn[v]);
        }
    }
    if (dfn[u] == low[u]) {
        int v;
        do {
            v = stk.back();
            stk.pop_back();
            belong[v] = cnt;
        } while (v != u);
        ++cnt;
    }
}
void solve() {
    for (int s = 0; s < n; ++s) {
        f.assign(n, std::vector<int>(2, -1));
        std::queue<std::pair<int, int>> que;
        f[s][0] = f[s][1] = s;
        for (auto &&edge : e[s]) {
            int v, i;
            std::tie(v, i) = edge;
            f[v][0] = v;
            que.emplace(v, 0);
        }
        while (!que.empty()) {
            int u, j;
            std::tie(u, j) = que.front();
            que.pop();
            for (auto &&edge : e[u]) {
                int v, i;
                std::tie(v, i) = edge;
                if (f[v][0] == -1) {
                    f[v][0] = f[u][j];
                    que.emplace(v, 0);
                } else if (f[v][1] == -1 && f[v][0] != f[u][j]) {
                    f[v][1] = f[u][j];
                    que.emplace(v, 1);
                }
            }
        }
        for (auto &&edge : e[s]) {
            int v, i;
            std::tie(v, i) = edge;
            if (f[v][1] != -1)
                ans[i] ^= 1;
        }
    }
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> n >> m;
    a.resize(m);
    b.resize(m);
    ans.resize(m);
    e.resize(n);
    dfn.assign(n, -1);
    low.resize(n);
    belong.assign(n, -1);
    for (int i = 0; i < m; ++i) {
        std::cin >> a[i] >> b[i];
        --a[i];
        --b[i];
        e[a[i]].emplace_back(b[i], i);
    }
    for (int i = 0; i < n; ++i)
        if (dfn[i] == -1)
            dfs(i);
    for (int i = 0; i < m; ++i)
        if (belong[a[i]] == belong[b[i]])
            ans[i] = 1;
    solve();
    for (int i = 0; i < m; ++i)
        std::cout << (ans[i] == 1 ? "diff" : "same") << "\n";
    return 0;
}

Measured memory_bytes: 6656
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll D,T,S;
  cin>>D>>T>>S;
  if(D<=T*S) COYe;
  else CONo;
  return 0;
}

Measured memory_bytes: 3592
/*
 * じょえチャンネル
 * 高評価・チャンネル登録よろしくお願いします！
 * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
 */

#include<bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long N, R;
    cin >> N >> R;
    if(N > 9)cout << R << endl;
    else cout << R + 100 * (10 - N) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>//sort
#include <vector>
#include <string>
#include <map>//pair
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
  string S;
  bool ans = true;
  cin >> S;
  int size = S.size();
  //rep(i, size){
  //if(i % 2 == 0){
  for(int i = 1; i < size; i += 2){
    if(S.at(i) != 'L' && S.at(i) != 'U' && S.at(i) != 'D')ans = false;
    //cout << ans << endl;
  }
  //else if(i % 2 == 1){
  for(int i = 0; i < size; i += 2){
    if(S.at(i) != 'R' && S.at(i) != 'U' && S.at(i) != 'D')ans = false;
    //cout << ans << endl;
  }
  //}
  //rep(i, size)cout << S.at(i) << endl;
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main() {
    int d,t,s;
    cin >> d >> t >> s;
    
    int dist = t*s;
    if(d<=dist) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3608
n=input()
l=len(n)
h="Yes"
for i in range(0,len(n)):
    if (i+1)%2!=0:
        if n[i]=="R"or n[i]=="U"or n[i]=="D" :
            pass
        else:
            h="No"
            break
    else:
        if n[i]=="L"or n[i]=="U"or n[i]=="D" :
            pass
        else:
            h="No"
            break
print(h)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, M, N, D, K, Q, W, H, T, X, Y;

int main()
{
    string sA, sB, sC;
    cin >> sA >> sB >> sC;
    int turn = 0;
    int ia = 0, ib = 0, ic = 0;
    while (true) {
        char next;
        switch (turn) {
            case 0:
                next = sA[ia]; ia++;
            break;
            case 1:
                next = sB[ib]; ib++;
            break;
            case 2:
                next = sC[ic]; ic++;
        }
        switch (next) {
            case 'a': turn = 0; break;
            case 'b': turn = 1; break;
            case 'c': turn = 2; break;
        }
        
        if (ia == sA.size() && turn == 0) {
            cout << "A" << endl; return 0;
        }
        if (ib == sB.size() && turn == 1) {
            cout << "B" << endl; return 0;
        }
        if (ic == sC.size() && turn == 2) {
            cout << "C" << endl; return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <stack>
using namespace std;


int main() {
	int n,a,b;
	cin >> n >> a >> b;
 
	int s = n * a;
	if(s > b) s = b; 



    cout << s << endl;
}

    



Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        checked {
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
        }
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = int.Parse(spl[0]);
        var b = int.Parse(spl[1]);

        return a* b;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 27296
n = int(input())
a = tuple(list(map(int, input().split())))

def puramai(a):
    b = list(a)
    hikaku = 0
    ans = 0
    for i in range(n):
        if i % 2 == 0 and hikaku + b[i] <= 0:
            b[i] = -hikaku+1
            ans += abs(b[i]-a[i])
        
        elif i % 2 != 0 and hikaku + b[i] >= 0:
            b[i] = -hikaku-1
            ans += abs(b[i]-a[i])
        
        hikaku += b[i]
    return ans

def maipura(a):
    b = list(a)
    hikaku = 0
    ans = 0
    for i in range(n):
        if i % 2 == 0 and hikaku + b[i] >= 0:
            b[i] = -hikaku-1
            ans += abs(b[i]-a[i])
        
        elif i % 2 != 0 and hikaku + b[i] <= 0:
            b[i] = -hikaku+1
            ans += abs(b[i]-a[i])
        
        hikaku += b[i]
    return ans
print(min(maipura(a), puramai(a)))

Measured memory_bytes: 14648
def resolve():
    N = int(input())
    S = input()

    ans = 0
    for i in range(10):
        idx = S.find(str(i))
        if idx != -1:
            for j in range(10):
                idx2 = S.find(str(j), idx+1)
                if idx2 != -1:
                    for k in range(10):
                        idx3 = S.find(str(k), idx2+1)
                        if idx3 != -1:
                            ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
0-1 Knapsack Problem

You have N items that you want to put them into a knapsack. Item i has value vi and weight wi.

You want to find a subset of items to put such that:

The total value of the items is as large as possible.
The items have combined weight at most W, that is capacity of the knapsack.
Find the maximum total value of items in the knapsack.

Input
N W
v1 w1
v2 w2
:
vN wN
The first line consists of the integers N and W. In the following lines, the value and weight of the i-th item are given.

Output
Print the maximum total values of the items in a line.

Constraints
1 ??? N ??? 100
1 ??? vi ??? 1000
1 ??? wi ??? 1000
1 ??? W ??? 10000
Sample Input 1
4 5
4 2
5 2
2 1
8 3
Sample Output 1
13

Sample Input 2
2 20
5 9
4 10
Sample Output 2
9
*/

public class Main {
    public static class Solver {
        int solve(int W, List<Integer> values, List<Integer> weights) {
            int[] dp = new int[W + 1];
            for (int i = 1; i <= values.size(); ++i) {
                for (int j = W; j >= 0; --j) {
                    int v = values.get(i - 1);
                    int w = weights.get(i - 1);
                    if (j - w >= 0) {
                        dp[j] = Math.max(dp[j], dp[j - w] + v);
                    }
                }
            }
            return dp[W];
        }
    }

    private static final Pattern SPLIT = Pattern.compile("\\s");
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Integer> weights = new ArrayList<>();
        List<Integer> values = new ArrayList<>();
        List<Integer> NW = Stream.of(SPLIT.split(scanner.nextLine())).map(Integer::valueOf)
                .collect(Collectors.toList());
        final int N = NW.get(0);
        final int W = NW.get(1);
        for (int i = 0; i < N; ++i) {
            List<Integer> collect = Stream.of(SPLIT.split(scanner.nextLine())).map(Integer::valueOf)
                    .collect(Collectors.toList());
            values.add(collect.get(0));
            weights.add(collect.get(1));
        }
        System.out.println(new Solver().solve(W, values, weights));
    }
}

Measured memory_bytes: 33048
import Control.Monad

main = do
  [str1, str2, str3] <- sequence [getLine, getLine, getLine]
  let a1 = map read (words str1) ::[Int]
  let a2 = map read (words str2) ::[Int]
  let a3 = map read (words str3) ::[Int]
  str <- getLine
  let n = read str ::Int
  bs <- forM [1..n] $ \i -> do
    str <- getLine
    let b = read str ::Int
    return b
  let ans1 = map (`elem` bs) a1
  let ans2 = map (`elem` bs) a2
  let ans3 = map (`elem` bs) a3
  if ck ans1 ans2 ans3 == True
    then putStrLn "Yes"
    else putStrLn "No"


ck :: [Bool] -> [Bool] -> [Bool] -> Bool
ck lt1 lt2 lt3
  | and lt1 == True = True
  | and lt2 == True = True
  | and lt3 == True = True
  | and [lt1 !! 0, lt2 !! 0, lt3 !! 0] == True = True
  | and [lt1 !! 1, lt2 !! 1, lt3 !! 1] == True = True
  | and [lt1 !! 2, lt2 !! 2, lt3 !! 2] == True = True
  | and [lt1 !! 0, lt2 !! 1, lt3 !! 2] == True = True
  | and [lt1 !! 2, lt2 !! 1, lt3 !! 0] == True = True
  | otherwise = False
  

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,K; cin >> N >> K;
    VI D(10,0);
    REP(i,K){
        int d; cin >> d;
        D[d] = 1;
    }
    auto check = [&](int n){
        while(n){
            int d = n%10;
            if(D[d]) return false;
            n /= 10;
        }
        return true;
    };
    FOR(i,N,1000000){
        if(check(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  char x, y;
  cin >> x >> y;
  if (x < y == 1) cout << "<" << endl;
  else if ((x == y) == 1) cout << "=" << endl;
  else cout << ">" << endl;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long *)b)return 1;
    return -1;
}
int main(int argc, const char * argv[]) {
    unsigned long long a;
    scanf("%llu",&a);
    char b[5];
    scanf("%s",b);
    unsigned long long bd=0;
    if(b[3]=='0'&&b[4]=='0'){
        printf("%llu",a*(b[0]-'0'));
    }
    bd+=b[0]-'0';
    bd*=10;
    bd+=b[2]-'0';
    bd*=10;
    if(b[3]=='0'){
        bd/=10;
    }else{
        bd+=b[3]-'0';
        bd*=10;
    }
    unsigned long long ans=a*bd;
    if(b[3]=='0'){
        ans/=10;
    }else{
        ans/=1000;
    }
    printf("%llu",ans);
    return 0;
}


Measured memory_bytes: 1732