akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<sstream>
#include<bitset>
#define scand(a) scanf("%d",&a)
#define scandd(a,b) scanf("%d%d",&a,&b)
#define scanddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define mst(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x&-x)
#define lson rt<<1
#define rson rt<<1|1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fLL;
const int maxn=1e5+5;
const ll mod=1e9+7;
ll inv[maxn],sum[maxn];
ll a[maxn];
void init()
{
	inv[0]=0;inv[1]=1;
	for(int i=2;i<maxn;i++)
	{
		inv[i]=(mod-mod/i)%mod*inv[mod%i]%mod;
	}
	for(int i=1;i<maxn;i++)
	{
		sum[i]=(inv[i]+sum[i-1])%mod;
	}
}
int main()
{
	#ifdef local
	freopen("1.txt","r",stdin);
	#endif
	init();
	int n;
	scand(n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=(ans+a[i]*(sum[n-i+1]+sum[i]-1)%mod)%mod;
	}
	for(int i=1;i<=n;i++)
	{
		ans=(ans*i)%mod;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 6172
using System;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {


            //テンプレート
            //// 整数の入力
            //int a = int.Parse(Console.ReadLine());
            //// スペース区切りの整数の入力
            //string[] input = Console.ReadLine().Split(' ');
            //int b = int.Parse(input[0]);
            //int c = int.Parse(input[1]);
            //// 文字列の入力
            //string s = Console.ReadLine();
            ////出力
            //Console.WriteLine(a + b + c + " " + s);


            int n = int.Parse(Console.ReadLine());
            int[] ryokan_h = new int[n];
            int mieru = 0;

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

            for (int i = 0; i < n; i++)
            {
                ryokan_h[i] = int.Parse(input[i]);
            }

            int max_height = 0;

            foreach (var height in  ryokan_h)
            {
                if (max_height <= height)
                {
                    max_height = height;
                    mieru += 1;
                }

            }

            Console.WriteLine(mieru);
            Console.ReadLine();



        }

    }
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
typedef long long ll;
#include <cmath>

int main(int argc, char *argv[])
{
	int a[9];
	for (int i=0;i<9;i++) cin>>a[i];
	
	set<int> b;

	int n;
	cin >>n;
	for (int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		b.insert(t);
	}
	string s="No";
	if (b.count(a[0])&&b.count(a[1])&&b.count(a[2])) s="Yes"; 
	if (b.count(a[3])&&b.count(a[4])&&b.count(a[5])) s="Yes"; 
	if (b.count(a[6])&&b.count(a[7])&&b.count(a[8])) s="Yes";

	if (b.count(a[0])&&b.count(a[3])&&b.count(a[6])) s="Yes"; 
	if (b.count(a[1])&&b.count(a[4])&&b.count(a[7])) s="Yes"; 
	if (b.count(a[2])&&b.count(a[5])&&b.count(a[8])) s="Yes";

	if (b.count(a[0])&&b.count(a[4])&&b.count(a[8])) s="Yes"; 
	if (b.count(a[2])&&b.count(a[4])&&b.count(a[6])) s="Yes";
	
	cout<< s<< endl;
	return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
a = set(a)
mod = 10**9+7
dp = [0]*(n+5)
dp[0] = 1
for i in range(1,n+1):
        if i in a:
                continue
        if i == 1:
                dp[i] = 1
                continue
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[n]%mod)

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

int main() {
	long long int  a[10];
	for (int i = 0; i < 10; i++)cin >> a[i];
	sort(a, a + 10);
	cout << a[9] << endl;
	cout << a[8] << endl;
	cout << a[7] << endl;
	return 0;
}

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

vii v;
void dfs(vi &nums, int m, int n, int min_num, int i) {
    if (i == n) {
        v.push_back(nums);
        return;
    }

    repeat(j, min_num, m + 1) {
        vi x = nums;
        x.push_back(j);
        dfs(x, m, n, j, i + 1);
    }
}

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

    int n, m, q;
    cin >> n >> m >> q;
    vii p(q, vi(4));
    rep(i, q) {
        vi t(4);
        rep(j, 4) cin >> t[j];
        t[0]--, t[1]--;
        p[i] = t;
    }

    vi e = {1};
    rep(i, m) {
        vi z = e;
        z[0] += i;
        dfs(z, m, n, 1 + i, 1);
    }

    int ans = 0;
    foreach (e, v) {
        int cnt = 0;
        rep(i, q) {
            if ((e[p[i][1]] - e[p[i][0]]) == p[i][2]) cnt += p[i][3];
        }
        ans = max(ans, cnt);
    }

    out(ans);

    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int r;
    cin >> r;
    const double pi = acos(-1.0);
    double ans = 2 * pi * r;
    printf("%.20f\n", ans);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  A.begin(), A.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))


#define forr(i,n) for(i=0; i<n; i++)
#define whilee(i,t) while(i!=t)
//#define pb(x) push_back(x);

//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//accumulate(A.begin(), A.end(), 0);
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());


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

    //vector <int> A;
    //deque <int> A;
    //queue <int> A;
    //stack <int> A;
    //set <int> A;
    //map <int,int> A;
    //pair <int,int> A ;
    //vector <pair <int,int>> A ;
    //string S, T;
    int i, j, k, a, b, c, l, m, n, p, q, r, s, t, x, y, z, cnt=0;
    cin>>a>>b;
    if((a+b)<24)
    {
        cout<<a+b<<endl;
    }
    else
    {
         cout<<(a+b)-24<<endl;
    }
    return 0;
}



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

int main() 
{
	long long n,i,tmp,sn=1,t;
	cin>>n;
	for(i=0;i<n;i++)
	{
		long long l1,l2;
		cin>>tmp;
		if(tmp>sn)
		{
			t=sn;
			sn=tmp;
			tmp=t;
		}
		l1=tmp;
		l2=sn;
		while(tmp!=0)
		{
		//	cout<<tmp<<endl;
			t=sn%tmp;
			sn=tmp;
			tmp=t;	
		}
		sn=l1/sn*l2;
	}
	cout<<sn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }



void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    int ans = -inf;
    rep3(l, -1, n) rep3(r, l + 1, n + 1) {
        priority_queue<int, vector<int>, greater<int> > q;
        rep(i, l + 1) q.push(a[i]);
        if (r != n) for (int i = n - 1; i >= r; i--) q.push(a[i]);
        
        if (sz(q) > k) continue;
        
        int sum = 0;
        int rest = k - (l + 1) - (n - 1 - r + 1);
        // cout << k << " " << l + 1 << " " << n - 1 - r + 1 << " " << rest << endl;
        
        int cnt = 0;
        while (!q.empty()) {
            int now = q.top();
            // cout << now << endl;
            q.pop();
            if (cnt < rest) {
                cnt++;
                if (now < 0) {
                    continue;
                }
            }
            sum += now;
        }
        // if (sum == 19) cout << l << " " << r << " " << sum << endl;
        chmax(ans, sum);
    }
    cout << ans << endl;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}




Measured memory_bytes: 256
N, M, L = map(int, input().split());
A = [list(map(int,input().split())) for i in range(N)] #N*M配列の取得
B = [list(map(int,input().split())) for i in range(M)] #M*L配列の取得
C = [[] for c in range(N)];
for n in range(N):
    for l in range(L):
        value = 0;
        for m in range(M):
            value = value + A[n][m] * B[m][l];
        C[n].append(value);
        if l == L-1:
            print(C[n][l], end="");
        else:
            print(C[n][l], end=" ");
    print();
'''
N,M,L = map(int,input().split())

A = [list(map(int,input().split())) for i in range(N)] #N*M配列の取得
B = [list(map(int,input().split())) for i in range(M)] #M*L配列の取得
ANS = [[0]*L for i in range(N)] #N*L


for x in range(N):
    for y in range(L):
        for z in range(M):
            ANS[x][y] += B[z][y]*A[x][z]

for row in range(N):
    print("%d"%ANS[row][0],end = "")
    for col in range(1,L):
        print(" %d"%(ANS[row][col]),end = "")
    print()
'''


Measured memory_bytes: 7068
//A
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int K;
    cin >> K;
    int x[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << x[K - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  println {
    Seq.fill(sc.nextInt())(sc.next())
      .map(_.sorted)
      .groupBy(identity)
      .map(_._2.size.toLong)
      .foldLeft(0L)((acc, i) => acc + i * (i - 1L) / 2L)
  }
}

Measured memory_bytes: 117048
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <iomanip>
using ll = long long;
using namespace std;
//#define int long long

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = 0; i <= (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int i = n; i >= 0; i--)
int factorical(int n) {
	int sum = 1;
	for (int i = 1; i <= n; ++i)
	{
		sum *= i;
	}
	return sum;
}


void printVector(const vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}



int main() {
	int n;
	cin >> n;
	vector<double> x, y;
	x.resize(n);
	y.resize(n);

	rep(i, n) {
		cin >> x[i] >> y[i];
	};

	double fac = factorical(n);
	vector<int> sum;
	sum.resize(fac);
	
	vector<int> nums(n);
	iota(nums.begin(), nums.end(), 0);
	
	double root = 0.0;
	

	double num = 0.0;
	do {
		double root_add = 0.0;
		rep(i, n-1) {
			root += sqrt(pow(x[nums[i + 1]] - x[nums[i]], 2) + pow(y[nums[i + 1]] - y[nums[i]], 2));
		}
	
		num += 1;
	} while (next_permutation(nums.begin(), nums.end()));
	cout << fixed << setprecision(10) << root/fac << endl;

	return 0;
}

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

int main() {
	/*
	ifstream ifs("test.txt");
	char str[256];

	if (ifs.fail()) {
		cerr << "失敗" << endl;
		return -1;
	}
	while (ifs.getline(str, 256 - 1)) {
		cout << "[" << str << "]" << endl;
	}
	*/

	ifstream ifs("test.txt");
	string str;

	int a;

	//while (getline(ifs, str)) {
	//	sscanf(str.data(), "%d", &a);
	//}

	cin >> a;

	cout << a*a*a << endl;

	return 0;
}


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

int T, card[16];

bool is_same_number(int a, int b, int c) {
    return ((a == b) && (b == c));
}

bool is_sequence(int a, int b, int c) {
    return ((a+2 == b+1) && (b+1 == c));
}

bool is_good_set(int a, int b, int c) {
    return (is_same_number(a, b, c) || is_sequence(a, b, c));
}

bool is_all_good_set() {
    return (is_good_set(card[0], card[1], card[2]) && is_good_set(card[3], card[4], card[5]) && is_good_set(card[6], card[7], card[8]));
}

int win() {
    sort(card, card+9);
    do {
        if (is_all_good_set()) return 1;
    } while (next_permutation(card, card+9));

    return 0;
}

int main() {
    cin >> T;
    for (int t = 0; t < T; ++t) {
        for (int i = 0; i < 9; ++i) {
            cin >> card[i];
        }
        string color;
        for (int i = 0; i < 9; ++i) {
            cin >> color;
            if (color == "G") card[i] += 10;
            else if (color == "B") card[i] += 20;
        }

        if (win()) cout << 1 << endl;
        else cout << 0 << endl;
    }

}

Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
int x[1000010];
int dis[1000010];

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

for (int i = 0 ; i < n ; i ++ ){
        cin >> x[i];
}
int ans = 0 , mx = 0 ;
for (int i=1 ; i < n ; i++){
    dis[i]=x[i]-x[i-1];
    mx=max(mx,dis[i]);
    ans+=dis[i];
}
dis[n]=m+x[0]-x[n-1];
mx=max(mx,dis[n]);
ans+=dis[n];
cout << ans-mx;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int solve(int s){
    if(((s/10000)==(s%10))&&(((s/1000)%10)==((s/10)%10)))return 1;
    return 0;
}
int main(){
    int a,b,ans=0;
    cin >> a >> b;
    rep(i,b-a+1){
        ans+=solve(a+i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
rr = lambda: sys.stdin.readline().strip()
rri = lambda: int(rr())
rrs = lambda: [int(_) for _ in rr().split()]

A, B = rrs()
if A >= 13:
    print(B)
elif 6 <= A <= 12:
    print(B//2)
else:
    print(0)

Measured memory_bytes: 3316
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>
#include <cmath>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  int64_t a,b;
  cin>>a>>b;
  std::unordered_set<int> fact_a,fact_b;
  fact_a.insert(1);
  fact_b.insert(1);
  for(int i=2;i<sqrt(a)+1;i++){
    while(a%i==0){
      a/=i;
      if(fact_a.find(i)==fact_a.end()) fact_a.insert(i);
    }
  }
  if(a>1){
    if(fact_a.find(a)==fact_a.end()) fact_a.insert(a);
  }
  for(int i=2;i<sqrt(b)+1;i++){
    while(b%i==0){
      b/=i;
      if(fact_b.find(i)==fact_b.end()) fact_b.insert(i);
    }
  }
  if(b>1){
    if(fact_b.find(b)==fact_b.end()) fact_b.insert(b);
  }

  int result=0;
  for(int i=1;i<=1000000;i++){
    if(fact_a.find(i)!=fact_a.end()&&fact_b.find(i)!=fact_b.end()){
      result++;
    }
  }
  if(a>1000000&&a==b) result++;
  cout<<result<<endl;



  return 0;
}


Measured memory_bytes: 256
(defun input (n)
  (let ((a (make-array n)))
    (loop for i below n do (setf (aref a i) (read)))
    a))

(defparameter *fact-array* (make-array 60))
(setf (aref *fact-array* 0) 1)
(setf (aref *fact-array* 1) 1)
(defun fact (n)
  (let ((x (aref *fact-array* n)))
    (if (> x 0)
      x
      (progn (setf (aref *fact-array* n) (* n (fact (1- n))))
             (aref *fact-array* n)))))
(defun ncr (n r) (/ (fact n) (fact r) (fact (- n r))))

(defun solve (a b v)
  (let ((ave (/ (loop for i below a sum (aref v i)) a))
        (num (count (aref v (1- a)) v))
        (tmp (loop for i from (1- a) downto 0 unless (= (aref v i) (aref v (1- a))) return (- a i 1))))
    (cons (float ave)
          (if (= (aref v 0) (aref v (1- a)))
            (loop for i from a to b when (<= i num) sum (ncr num i))
            (ncr num tmp)))))

(let* ((n (read))
       (a (read))
       (b (read))
       (v (sort (input n) #'>))
       (e (solve a b v)))
  (format t "~,6F~%~A~%" (car e) (cdr e)))

Measured memory_bytes: 18788
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;


typedef long long ll;

int main() {
  int n; cin >> n;
  map<int, int> count;
  ll ans = 0;
  for (int i = 0; i < n; ++i) { 
    int a; cin >> a;
    int si = i+1-a;
    if (count.find(si) != count.end()) {
      ans += count[si];
    }
    count[i+1+a] += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 12968
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto X = RD!char;
	auto Y = RD!char;

	writeln(X-'A' == Y-'A' ? "=" : X-'A' < Y-'A' ? "<" : ">");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#define MAX_N 100000
#define MAX_CARD_NUM 1000000000

using namespace std;

struct Card {
  char type;
  int number;
  void print() {
    printf("%c %d", type, number);
  }
};

void print_cards(Card cards[], int n) {
  for(int i=0; i<n; i++) {
    printf("%c %d\n", cards[i].type, cards[i].number);
  }
}

int partition(Card cards[], int p, int r) {
  int i = p-1;
  int x = cards[r].number;
  for(int j=p; j<r; j++) {
    if(cards[j].number <= x) {
      i++;
      Card tmp = cards[j];
      cards[j] = cards[i];
      cards[i] = tmp;
    }
  }
  Card tmp = cards[r];
  cards[r] = cards[i+1];
  cards[i+1] = tmp;
  return i+1;
}

void quicksort(Card cards[], int p, int r) {
  if(p < r) {
    int q = partition(cards, p, r);
    quicksort(cards, p, q-1);
    quicksort(cards, q+1, r);
  }
}

bool is_stable(Card original[], Card sorted[], int n) {
  int max = sorted[n-1].number;
  char order[MAX_N];
  for(int i=0; i<max+1; i++) {
    int order_i = 0;
    for(int j=0; j<n; j++) {
      if(original[j].number == i) {
        order[order_i] = original[j].type;
        order_i++;
      }
    }

    int p = 0;
    for(int j=0; j<n; j++) {
      if(sorted[j].number == i) {
        if(sorted[j].type != order[p]) {
          return false;
        }
        p++;
      }
    }
  }
  return true;
}

int main() {
  int n, number;
  char type;
  Card cards[MAX_N];
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> type >> number;
    cards[i].type = type;
    cards[i].number = number;
  }

  Card cards_to_sort[MAX_N];
  for(int i=0; i<n; i++) {
    cards_to_sort[i] = cards[i];
  }

  quicksort(cards_to_sort, 0, n-1);

  if(is_stable(cards, cards_to_sort, n))
    printf("Stable\n");
  else
    printf("Not stable\n");
  print_cards(cards_to_sort, n);
  return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;

using namespace std;

signed main() {
  ll n;
  string s;
  cin >> n >> s;
  if (n%2==1) { cout << "No" << endl; return 0; }
  rep(i,n/2){
    if (s[i] != s[i+n/2]) {
      cout << "No" << endl;
      return 0;
    }
  }
    cout << "Yes" << endl;
}


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

string s,t;
int ls,lt,st,cnt;
vector<int> pos[26];

int main()
{
	cin>>s>>t;
	ls=s.size(),lt=t.size();
	for(int i=0;i<ls;++i) pos[s[i]-'a'].push_back(i+1);
	for(int i=0;i<ls;++i) pos[s[i]-'a'].push_back(i+ls+1);
	for(int i=0;i<lt;++i) {
		if(pos[t[i]-'a'].size()==0) {
			cout<<-1;
			return 0;
		}
		st=*upper_bound(pos[t[i]-'a'].begin(),pos[t[i]-'a'].end(),st);
		if(st>ls) cnt++,st-=ls;
	}
	printf("%lld",1ll*cnt*ls+st);
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int c[3][3];
  rep(i, 3) rep(j, 3) {
    cin >> c[i][j];
  }

  int a[3];
  for (a[0] = -100; a[0] < 101; a[0]++)
  for (a[1] = -100; a[1] < 101; a[1]++)
  for (a[2] = -100; a[2] < 101; a[2]++) {
    bool next = 0;
    int b[3];
    b[0] = c[0][0] - a[0];
    b[1] = c[1][1] - a[1];
    b[2] = c[2][2] - a[2];
    if(
      c[0][1] == a[0] + b[1] &&
      c[0][2] == a[0] + b[2] &&
      c[1][0] == a[1] + b[0] &&
      c[1][2] == a[1] + b[2] &&
      c[2][0] == a[2] + b[0] &&
      c[2][1] == a[2] + b[1]
    ) {
      cout << "Yes\n";
      exit(0);
    }
  }
  cout << "No\n";
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) max(a,min(b,c))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define print1(a,n) for(int i=1;i<=n;i++) cout<<a[i]<<" "
#define print21(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<" ";}cout<<endl;}
#define scan1(a,n) for(int i=1;i<=n;i++) cin>>a[i]
#define scan(a,n) for(int i=0;i<n;i++) cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "
#define int long long
#define double long double
#define float long double
#define vi vector<int>
#define si set<int>
#define vb vector<bool>
#define vc vector<char>
#define pii pair<int,int>
#define piii pair<int,pair<int,int>>
#define mkp make_pair
#define mod 1000000007
#define ff first
#define ss second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mset(m,v) memset(m,v,sizeof(m))
#define bs binary_search
#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 endl '\n'
using namespace std;
bool comp(int x,int y){
	if(x>=y)
	return true;
	return false;
} 
bool compare(const pii &i,const pii &j){
	return i.ss<j.ss;
}
bool compare1(const pii &i,const pii &j){
	return i.ff>j.ff;
}
string decitobinary(int n){
	string s="";
	while(n>0){
		s=to_string(n%2)+s;
		n=n/2;
	}
	return s;
}
int binarytodeci(string s){
	int n=0;
	reverse(s.begin(),s.end());
	for(int i=0;i<s.length();i++){
		string t="";
		t+=s[i];
		n+=(int)pow(2,i)*stoi(t);
	}
	return n;
}
double intlog(double base,double x){
    return (log(x)/log(base));
}
int fact(int n){
    int res=1; 
    for(int i=2;i<=n;i++) 
    res=res*i; 
    return res; 
}
int ncr(int n,int r){ 
return fact(n)/(fact(r)*fact(n-r));}

  const int N=1e6+3;
  vector<int> adj[N];
  bool vis[N];
  
	void dfs(int u){
	vis[u]=true;
		for(int v:adj[u]){
			if(vis[v]){
				cout<<u<<" ";
				break;
			}
			dfs(v);
		}
	}
int compute_hash(string s){
	int p=31,hash=0,po=1;
	for(char c:s){
		hash+=(c-'a'+1)*po%mod;
		po=(po*p)%mod;
	}
	return hash;
}
vector<vector<int>> group_identical_strings(vector<string> const& s) {
    int n = s.size();
    vector<pair<long long, int>> hashes(n);
    for (int i = 0; i < n; i++)
        hashes[i] = {compute_hash(s[i]), i};
    sort(hashes.begin(), hashes.end());
    vector<vector<int>> groups;
    for (int i = 0; i < n; i++) {
        if (i == 0 || hashes[i].first != hashes[i-1].first)
        groups.emplace_back();
        groups.back().push_back(hashes[i].second);
    }
    return groups;
}
void solve(){
    int n,k;
    cin>>n>>k;
    int a[n+1];
    scan1(a,n);
    int dp[n+1];
    dp[1]=0;
    for(int i=2;i<=n;i++){
        dp[i]=INT_MAX;
        for(int j=1;j<=k && i-j>=1;j++){
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<dp[n];
}
int32_t main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		solve();
   }
}





Measured memory_bytes: 25216
/*
	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
	int n;
	ll count=0;
	cin>>n;
	ll arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
		
	for (int i = 0; i < n; i++) { 
        for (int j = i + 1; j < n; j++) { 
  
            // The innermost loop checks for 
            // the triangle property 
            for (int k = j + 1; k < n; k++) 
  
                // Sum of two sides is greater 
                // than the third 
                if ( arr[i]!=arr[j] and arr[i]!=arr[k] and arr[k]!=arr[j] and
                    arr[i] + arr[j] > arr[k] 
                    && arr[i] + arr[k] > arr[j] 
                    && arr[k] + arr[j] > arr[i]) 
                    count++; 
        } 
    } 
    cout<<count;
}

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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    int k = 0, ans = 0;
    rep1(i, n) {
        int p;
        cin >> p;
        if (p != i) { ans += (k + 1) / 2;k = 0; }
        else k++;
    }
    ans += (k + 1) / 2;

    cout << ans << endl;

}

Measured memory_bytes: 256
n, @a, @b=gets.split.map(&:to_i)
@hp=[]
n.times{@hp << gets.to_i}

def check(t)
  _t=0
  @hp.each do |e|
    res=e-@b*t
    next if res<=0
    _t+=[0, (res+@a-@b-1)/(@a-@b)].max
  end
  _t<=t
end

l, u=0, 10**18 #(@hp.inject(:+)+@a-1)/@a
while u-l>1
  m=(u+l)/2
  if check(m)
    u=m
  else
    l=m
  end
end

puts u


Measured memory_bytes: 2996
#include "bits/stdc++.h"

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int h,w,ni,nj;
string s[10];
bool b[10][10];

bool check(int i,int j){
	if(i>=0&&i<h&&j>=0&&j<w)return true;
	return false;
}

void input(){
	cin>>h>>w;
	for(int i=0;i<h;i++)cin>>s[i];
	return;
}

void solve(){
	int i=0,j=0;
	b[0][0]=true;
	while(i<h&&j<w){
		if(i+1<h&&s[i+1][j]=='#'){
			b[i+1][j]=true;
			i++;
		}
		else if(j+1<w&&s[i][j+1]=='#'){
			b[i][j+1]=true;
			j++;
		}
		else break;
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'&&!b[i][j]){
				cout<<"Impossible"<<endl;
				return;
			}
		}
	}
	cout<<"Possible"<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main()
{
	ios_base::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	map<char, char> a,b;
	rep(i, s.size()) {
		//cout << s[i] << " " << t[i] << endl;
		if (!a[t[i]]) {
			a[t[i]] = s[i];
		}
		else if (a[t[i]] != s[i] && s[i] != t[i]) {
			cout << "No\n";
			//cout << s[i] << t[i];
			return 0;
		}
	}
	rep(i, t.size()) {
		if (!b[s[i]])
			b[s[i]] = t[i];
		else if (b[s[i]] != t[i]) {
			cout << "No\n";
			//cout << t[i] << s[i];
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 916
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;


vll bk(62, 1);
bitset<61> A, B;

vvl dp = VV(64, 3, -1, ll);

ll f(ll keta, int g){
  if(keta==-1) return 1;
  if(dp[keta][g]!=-1) return dp[keta][g];
  ll ret = 0;

  if(g==0){
    //確定していない
  }else if(g==1){
    //大きいことが確定
    return dp[keta][g] = 2*bk[keta];
  }else{
    ret += f(keta-1, g);
    if(!A[keta]) ret += f(keta-1, 1);
  }
  return dp[keta][g] = ret;
}

void solve(ll a, ll b){
  if(a==0){
    ll x = 1;
    while(b>=x) x*=2;
    std::cout << x << '\n';
    exit(0);
  }
  ll x = 1, c = 0;
  while(b>=2*x) x*=2, c++;
  if(x<=a) solve(a-x, b-x);

  ll tmp = x;
  for(ll i=c-1;i>=0;i--, tmp/=2){
    if((b>>i)&1){
      for(int j=i;j>=0;j--) b |= (1LL<<j);
      break;
    }
  }
  if(b-x>=a){
    std::cout << x + (x - a) << '\n';
    exit(0);
  }
  A = bitset<61>(a);
  B = bitset<61>(b);
  ll bottom = x - a, top = b - x + 1;
  ll ad = f(c-1, 2);
  std::cout << bottom + top + ad << '\n';
  exit(0);
}

int main(int argc, char const *argv[]) {
  ll a, b;std::cin >> a >> b;
  for(int i=1;i<62;i++) bk[i] = bk[i-1]*2;
  solve(a, b);
  return 0;
}


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

signed main()
{
    string s; cin >> s;
    int ans;
    if (s == "RRR") ans = 3;
    else if ((s == "RRS") || (s == "SRR")) ans = 2;
    else if (s == "SSS") ans = 0;
    else ans = 1;

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


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi v(n), c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    int ans = 0;
    rep(i, n) {
        int xy = v[i] - c[i];
        if (xy > 0) ans += xy;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = int(input())

def even(n):
    return n // 2

def odd(n):
    return 3 * n + 1

l = [0 for _ in range(100000+10)]
a = s
ans = 1
l[a] += 1
while True:
    if a % 2 == 0:
        a = even(a)
    else:
        a = odd(a)
    l[a] += 1
    ans += 1
    if l[a] >= 2:
        break
print(ans)

Measured memory_bytes: 3956
#include <stdio.h>          // printf(), fgets()
#include <string.h>         // strstr()
#include <ctype.h>          // islower()
#include <stdbool.h>

static const int NUL = '\0';

int
main(int argc, char** argv)
{
	char line[81];
	const char* key[3] = {"the", "this", "that"};

	while (fgets(line, sizeof(line), stdin) != NULL)
	{
		int i;

		while (true)
		{
			for (i = 0; i < 3; ++i)
			{
				if (strstr(line, key[i]) != NULL)
					break;
			}

			if (i < 3)
				break;

			for (i = 0; line[i] != NUL; ++i)
			{
				if (islower(line[i]))
					line[i] = (line[i] + 1 - 'a') % 26 + 'a';
			}
		}

		printf("%s", line);
	}

	return 0;
}

Measured memory_bytes: 528
/**
 *    author: gxfireball       
**/
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;

void solve(){
   string str;
   cin >> str;
	if(str[3] == str[2] && str[4] == str[5]){
		cout << "Yes";
	}
	else cout << "No";
}

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        List<string> ans = new List<string> { };
        string no = "UNRESTORABLE";
        string a = Console.ReadLine();
        string b = Console.ReadLine();
        
        if (a.Length < b.Length) { Console.WriteLine(no); return; }
        int s = 0;
        for (int i = 0; i < a.Length - b.Length + 1; i++)
        {
            int first = 0;
            for (int j = 0; j < b.Length; j++)
            {
                if (a[i + j] != b[j] && a[i + j] != '?') { goto H; }
                if (j == b.Length - 1)
                {
                    s++;
                }
                if (j == 0)
                {
                    first = i;
                }
            }
            string K = "";
            for (int k = 0; k < a.Length; k++)
            {
                if (k == first) { K += b; k += b.Length - 1; continue; }
                if (a[k] == '?') { K += 'a'; }
                else { K += a[k]; }
            }
            ans.Add(K);
            H: { } 
            if (i == a.Length - b.Length && ans.Count==0) { Console.WriteLine(no); return; }
        }
        ans.Sort();
        Console.WriteLine(ans[0]);
        Console.ReadLine();
        
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        for (long i = 2; i < n; i++) { if (n % i == 0) return false; }
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

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

int main() {
  //入力
  int n;
  cin >>n;
  vector<int>flower(n);
  int smallest;
  for(int i=0;i<n;i++)
  {
    cin >>flower[i];
    if(i==0)
    {
      smallest=flower[i];
    }
    else if(smallest>flower[i])
    {
      smallest=flower[i];
    }
  }

  //処理
  int ans=flower[0];
  for(int i=0;i<n-1;i++)
  {
    if(flower[i+1]-flower[i]>0)
    {
      ans+=flower[i+1]-flower[i];
    }
  }

  //出力
  cout << ans << endl;
}


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

int main(void){
    int x1,x2,y1,y2; cin >> x1 >> y1 >> x2 >> y2;

    int x3=x2+y1-y2;
    int y3=y2-x1+x2;
    int x4=x1+y1-y2;
    int y4=y1+x2-x1;

    printf("%d %d %d %d\n", x3, y3, x4, y4);
}

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

int main()
{
    int N, A, B; cin >> N >> A >> B;
    vector<int> H(N); for (auto& e : H) cin >> e;
    sort(H.begin(), H.end());

    int dAB = A - B;
    int l = 0, r = (H.back() + B - 1) / B;
    while (r - l > 1) {
        int c = l + (r - l)/2;
        int base = B * c;
        auto it = upper_bound(H.begin(), H.end(), base);
        bool ok = true;
        int x = 0;
        while (it != H.end()) {
            x += (*it  - base + dAB - 1) / dAB;
            if (x > c) {
                ok = false;
                break;
            }
            it++;
        }
        if (ok) {
            r = c;
        } else {
            l = c;
        }
    }
    cout << r << endl;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d,e,f;
    cin>> a >> b >> c >> d >> e >> f;
    
    if ( a + b*5 + c*10 + d*50 + e*100 + f*500 >= 1000) {
        cout<< "1" <<endl;
       }else{
           cout<< "0" <<endl;
       }
       
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,cnt = 0;
  cin>>n>>x;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    x -= a[i];
    if(x >= 0) cnt++;
    else break;
  }
  if(x>0) cnt--;
  cout << cnt << endl;
}

Measured memory_bytes: 256
l, r = map(int, input().split())
ans = 2019
for i in range(l, min(r+1, l+2019)):
    for j in range(i+1, min(r+1, i+2019)):
        ans = min(ans, ((i % 2019) * (j % 2019)) % 2019)
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
const HASH B = 1e9 + 7;

int h, w;
char field[105][105];
int ans[105][105];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    rep(i, h)rep(j, w) cin >> field[i][j];
    rep(i, h){
        bool ok = false;
        int cnt = 0;
            rep(j, w) {
                if (field[i][j] == '.') {
                    if (ok) {
                        cnt++;
                        ans[i][j] = cnt;
                    }
                    else ans[i][j] = -1;
                }
                else {
                    ok = true;
                    cnt = 0;
                    ans[i][j] = 0;
                }
                if (j != w - 1) cout << ans[i][j] << " ";
                else cout << ans[i][j];
            }
            cout << endl;
        }
}

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

int w, h;
ll cnt = 0;
Graph G;
struct Direct {
    int x;
    int y;
};

Direct direction[8] = {{-1, -1}, {0, -1}, {1, -1}, {-1, 0},
                       {1, 0},   {-1, 1}, {0, 1},  {1, 1}};

void dfs(int x, int y) {
    if(G[y][x] == 1) {
        G[y][x] = 0;
    }
    rep(i, 8) {
        if(0 <= x + direction[i].x && x + direction[i].x < w) {
            if(0 <= y + direction[i].y && y + direction[i].y < h) {
                if(G[y + direction[i].y][x + direction[i].x] == 1) {
                    dfs(x + direction[i].x, y + direction[i].y);
                }
            }
        }
    }
}

int main() {
    while(1) {
        cnt=0;
        cin >> w >> h;

        G = Graph(h);
        if(!w && !h) break;
        rep(i, h) {
            G[i] = vector<int>(w);
        }
        rep(i, h) {
            rep(j, w) {
                cin >> G[i][j];
            }
        }
        rep(i, h) {
            rep(j, w) {
                if(G[i][j]) {
                    cnt++;
                    dfs(j, i);
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
/*
I just got lost in thought. It was unfamiliar territory.
- Steven Wright
*/

#include <algorithm>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <vector>
//#include <boost/math/common_factor.hpp>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 1000000000;
const int MAX = 100005;
const int MAX1 = 2007;
const int MAX2 = 4007;
const int LEN = 21;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1234567891;
//g++ -std=c++11 your_file.cpp -o your_program

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ifstream in("");
    ofstream out("");
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dy = y2 - y1, dx = x2 - x1;
    cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;
    return 0;
}

Measured memory_bytes: 384