akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll na,nb,m;cin>>na>>nb>>m;
  res=INF;
  vector<ll>a(na),b(nb);
  rep(i,0,na)cin>>a[i];
  rep(i,0,nb)cin>>b[i];
  res=*min_element(ALL(a))+*min_element(ALL(b));
  rep(i,0,m){
    ll x,y,c;cin>>x>>y>>c;x--;y--;
    chmin(res,a[x]+b[y]-c);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  rep(i,n)std::cin >> a[i];
  sort(all(a));
  std::cout << a[n-1]-a[0] << std::endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp;
   
fn read<T: FromStr>() -> T {
	let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let n: u32 = read();
	let mut a: Vec<u32> = Vec::new();
	for i in 0..n {
		a.push(read());
	}
	
	println!("{}", 1.0 / a.iter().map(|x| *x as f32).map(|x| 1.0 / x).fold(0.0, |x, y| x + y));
}

Measured memory_bytes: 4352
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int k = sc.nextInt();
        char[] s = sc.next().toCharArray();

        int ans = 0;
        int cnt = 0;
        int changeCnt = 0;
        for (int i = 1; i < n; i++) {
            if (s[i-1] == s[i]) {
                ans++;
            } else {
                if (cnt % 2 == 1 && changeCnt < k) {
                    ans += 2;
                    changeCnt++;
                }
                cnt++;
            }
        }
        if (cnt % 2 == 1 && changeCnt < k)
            ans++;

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 24532
#include <bits/stdc++.h>
using namespace std;
bool T=false;
int main(){
    int N;cin>>N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin>>a[i];
    }
    int cnt=0;
    for (int i = 0; i < N; i++)
    {
        if(a[i]%2!=0&&(i+1)%2!=0)cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  if(n/2+(n%2) >= k) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <stack>
#include <math.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int, int> pii;
int main(){
ll int n,i,a1=0;
cin>>n;
ll int dam[n];
for(i=0;i<n;i++){
  cin>>dam[i];
  if(i%2==0){a1+=dam[i];
  }else{a1-=dam[i];}
}
cout << a1<<" ";

for(i=0;i<n-1;i++){
cout << 2*dam[i]-a1<<" ";
a1=2*dam[i]-a1;
}
 cout << endl;





}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int n, a[200020], b, r;
long long z;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		while (r < n && (b ^ a[r]) == (b + a[r])) {
			b += a[r];
			r++;
		}
		z += r - i;
		b -= a[i];
	}
	printf("%lld\n", z);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll x,y;
cin>>x>>y;
cout<<x+y/2<<endl;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	vector<int> v(128);
	string w;
	cin >> w;
	for (char c : w)
		v[c]++;
	bool ok = true;
	for (int x : v) {
		if (x & 1)
			ok = false;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
from math import factorial

N,M = map(int,input().split())

pdic={}

p=2
while p**2<=M:
    c=0
    while M%p==0:
        c+=1
        M//=p
    if c>0:
        pdic[p]=c
    p+=1
if M>1:
    pdic[M]=1

ans=1
tmp=factorial(N-1)

for p in pdic.keys():
    e=pdic[p]
    ans*=factorial(N+e-1)//(factorial(e)*tmp)

print(ans%(10**9+7))


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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {

    set<ll> m;
    ll a, b, c;
    cin >> a >> b >> c;

    rep(i, b) {
        m.insert((a * i) % b);
    }

    if (m.find(c) == m.end()) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }


}



Measured memory_bytes: 256
h, w = map(int, input().split())

s = [input() for _ in range(h)]

ans = 'Yes'

for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == '#' and s[i-1][j] == '.' and s[i+1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.':
            ans = 'No'
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n; i++)
#define all(v) (v).begin(), (v).end()
#define decimal fixed << setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    rep(i, N) cin >> l[i];
    sort(all(l));
    reverse(all(l));
    int answer = 0;
    rep(i, K) answer += l[i];
    cout << answer << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, x;
  cin >> N >> x;
  if(N == 2){
    cout << (x == 2?"Yes":"No") << endl;
    if(x == 2)for(int i = 0; i < 3; i++)cout << i + 1 << endl;
    return 0;
  } else if(x <= 1|| x >= 2 * N - 1){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  vector<long> ans(2 * N - 1);
  ans.at((2 * N - 1) / 2) = x;
  long co;
  if(x == 2){
    ans.at((2 * N - 1) / 2) = x;
    ans.at((2 * N - 1) / 2 + 1) = x - 1;
    ans.at((2 * N - 1) / 2 + 2) = x + 1;
    ans.at((2 * N - 1) / 2 - 1) = x + 2;
    co = 1;
    for(int i = 0; i < ans.size(); i++){
      while(co == x || co == x - 1|| co == x + 1|| co == x + 2)co++;
      if(ans.at(i) == 0){
        ans.at(i) = co;
        co++;
      }
    }
  } else {
    ans.at((2 * N - 1) / 2) = x;
    ans.at((2 * N - 1) / 2 + 1) = x + 1;
    ans.at((2 * N - 1) / 2 + 2) = 1;
    ans.at((2 * N - 1) / 2 - 1) = 2;
    co = 1;
    for(int i = 0; i < ans.size(); i++){
      while(co == x || co == x + 1|| co == 1|| co == 2)co++;
      if(ans.at(i) == 0){
        ans.at(i) = co;
        co++;
      }
    }
  }
  for(int i = 0; i < ans.size(); i++)cout << ans.at(i) << endl;;
  return 0;
}

Measured memory_bytes: 3072
N = int(input())
List = []

A = []
B = []

for i in range(N):
  a,b = map(int,input().split())
  List.append([a,b])
  A.append(a)
  B.append(b)
  

if N%2 == 1:
  A.sort()
  B.sort()
  ans = B[N//2] - A[N//2] + 1
  print(int(ans))
else:
  A.sort()
  B.sort()
  c = B[N//2] - A[N//2] + 1
  d = B[N//2-1] - A[N//2-1] + 1
  print(c+d-1)

Measured memory_bytes: 42836
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	int cnt = 0;
	map<string, int>m;
	for (int i = 0; i < N; i++)
	{
		string tmp;
		cin >> tmp;
		sort(tmp.begin(), tmp.end());
		m[tmp]++;
		if (m[tmp] >= 2)cnt += m[tmp] - 1;
	}
	cout << cnt;
}

Measured memory_bytes: 11136
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

vector<int> ans{1,2,3,4,5,6,7,8,9,19,29,39,49,59,69,79,89,99,199,299,399,499,599,699,799,899,999};

signed main() {
	FOR (i,2,14) {
		int tmp = pow(10,i) - 1;
		FOR (j,10,100) {
			if (j / 10 < i) {
				ans.push_back(tmp + j * pow(10,i));
			} else if (j % 10 == 9) {
				ans.push_back(tmp + j * pow(10,i));
			}
		}
	}
	FOR (i,100,109) {
		ans.push_back((i+1) * pow(10,12) - 1);
	}
	sort(ALL(ans));
	int k;
	cin >> k;
	REP (i,k) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 256
from collections import Counter

n,m = map(int,input().split())
A = list(map(int,input().split()))

S = [0]
s = 0

for i in range(n):
  s += A[i]
  S += [s]

R = []

for i in range(n+1):
  R += [S[i]%m]
  
R = Counter(R)

ans = 0

for r in R.values():
  ans += r*(r-1)//2

print(ans)

Measured memory_bytes: 64280
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		List<Integer> list = new ArrayList<>();
		long l1 = 0L,l2 = 0L;

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}

		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int ai : A) {
			Integer i = map.get(ai);
			map.put(ai, i == null ? 1 : i + 1);
		}

		for (int key : map.keySet()) {
			if ( map.get(key) >= 2) list.add(key);
		}
		Integer[] answers = (Integer[]) list.toArray(new Integer[0]);
		if (answers.length >= 2) {
			Arrays.sort(answers);
			l2 = (long)answers[answers.length-1]*(long)answers[answers.length-2];
		}
		list.clear();

		for (int key : map.keySet()) {
	    	if ( map.get(key) >= 4) list.add(key);
		}
		Integer[] answers2 = (Integer[]) list.toArray(new Integer[0]);
	    if (answers2.length >= 1) {
		    Arrays.sort(answers2);
		    l1 = (long)answers2[answers2.length-1]*(long)answers2[answers2.length-1];
	    }
	    System.out.println(Math.max(l1, l2));
	}

}


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

int main() {
  int n;
  cin >> n;
  set<string> x;
  int ans = 0;
  for (int i=0; i<n; i++) {
    string s;
    cin >> s;
    if (x.count(s)) continue;
    ans++;
    x.insert(s);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 19176
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c;
    cin >> a >> b >> c;
    ll t = a + b + 1;
    if(t > c)
    {
        cout << b + c << endl;
    }
    else
    {
        cout << b + min(t, c) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
function main(input) {
    var a = input[0];
    var b = input[1];
  	a = a.split("").sort().join("");
  	b = b.split("").sort().reverse().join("");
  console.log(a<b?"Yes":"No");
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))

Measured memory_bytes: 22208
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int> v(n), u(n);
    rep(i, n){
        int a;
        cin >> a;
        if(i+1 < n) v[i+1] = a;
        if(n-i < n) u[n-i] = a;
    }
    rep(i, n-1){
        chmax(v[i+1], v[i]);
        chmax(u[i+1], u[i]);
    }
    reverse(all(u));

    /*
    rep(i, v.size()){
        cout << v[i] << ", ";
    }cout << endl;
    rep(i, u.size()){
        cout << u[i] << ", ";
    }cout << endl;
    */

    rep(i, n) cout << max(v[i], u[i]) << endl;
}

Measured memory_bytes: 3200
let () = Scanf.scanf "%d\n" @@ fun n ->
  let array = Array.init n @@ fun i -> if i<n-1 then Scanf.scanf "%d " @@ fun a -> a else Scanf.scanf "%d" @@ fun a -> a in 
  Printf.printf "%d\n" @@
  Array.fold_left (fun acc a ->
    if a = 0 || acc = 0
    then 0
    else if acc = -1
    then -1
    else if acc <= 1000000000000000000 / a
    then acc * a
    else -1) 1 array

Measured memory_bytes: 6668
package main
import (
	"fmt"
)
func main() {
	var x, y int
	fmt.Scan(&x, &y)
	if x < y{
	    fmt.Println("a < b")
	}else if x > y{
	    fmt.Println("a > b")
	}else{
	    fmt.Println("a == b")
	}
}


Measured memory_bytes: 1144
import sys
sys.setrecursionlimit(10**6)
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)


init = -1
for i in range(N):
    if len(G[i]) >= 3:
        init = i
        break
if init == -1:
    print(1)
    exit(0)

def dfs(v, p):
    res = []
    for w in G[v]:
        if w == p:
            continue
        res.append(dfs(w, v))
    c = len(res)
    if c == 0:
        return 0
    if c == 1:
        return res[0]
    zero = res.count(0)
    if zero >= 2:
        return sum(res) + (zero - 1)
    return sum(res)
print(dfs(init, -1))


Measured memory_bytes: 76464
time = [int(input()) for _ in range(5)]

amari = [10]
for i in range(5):
    if time[i]%10 != 0:
        amari += [time[i]%10]
mia = min(amari)


import math
ti = 0
for i in range(5):
    ti += math.ceil(time[i]/10)*10


print(ti-10+mia)

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int reverseI(int n) {
    int left = n / 10;
    int right = n % 10;
    return right * 10 + left;
}

bool isKaibun(int n) {
    int left = n / 1000;
    int right = reverseI(n % 100);
    return left == right;
}

int main() {

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

    int ans = 0;
    for (int i = a; i <= b; i++) {
        if (isKaibun(i)) {
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int a[20];
int ans = 0;


void dfs(int flag, int dep) {
    if(dep == n + 1) {
        if(flag)ans ++;
        return;
    }
    for(int i=a[dep]-1;i<=a[dep]+1;i++) {
        int t = (i % 2) ? 0 : 1;
        dfs(flag|t, dep + 1);
    }
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    dfs(0, 1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>

#define N 300005
#define M 8000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

int i,j,m,n,p,k,a[N],ans,aa,bb,f[N],g[N];

int main()
{
		scanf("%d%d%d",&n,&aa,&bb);
		for (i=1;i<=n;++i) scanf("%d",&a[i]);
		ans=abs(bb-a[n]); 
		for (i=n;i;--i)
		{
				if (i==n) f[i]=g[i]=abs(a[i-1]-a[i]);
				else 
				{
					f[i]=abs(a[i-1]-n);
					g[i]=abs(a[i-1]-n);
					for (j=i+1;j<=n;++j)
					 	f[i]=max(f[i],g[j]),
					 	g[i]=min(g[i],f[j]);
				}
		}
		for (i=1;i<n;++i) ans=max(ans,g[i+1]);
		printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    

    ll n,k;
    string s;
    cin >> n >> k >> s;
    s[k-1] = s[k-1] + 0x20;
    cout << s << endl;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	fn := f(n)

	if n%fn == 0 {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}

}

func f(n int) int {
	fn := n % 10
	tmp := n

	for tmp >= 10 {
		tmp /= 10
		fn += tmp % 10
	}

	return fn
}


Measured memory_bytes: 512
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

char a[1010][1010];
int dp[1010][1010];

int main(void){
	          int i,j;

	          cin.tie(0);  ios_base::sync_with_stdio(false);

	          int H,W;
	          cin >> H >> W;

	          for(i=1;i<=H;i++){
	        	  for(j=1;j<=W;j++){
	        		  cin >> a[i][j];
	        	  }
	          }


	          dp[1][1]=1;
	          for(i=1;i<=H;i++){
	        	  for(j=1;j<=W;j++){
	        		  if(a[i][j]=='#') continue;
	        		  if(a[i][j-1]!='#'){
	        			  dp[i][j]+=dp[i][j-1];
	        			  dp[i][j]=dp[i][j]%(1000000007);
	        		  }
	        		  if(a[i-1][j]!='#'){
	        			  dp[i][j]+=dp[i-1][j];
	        			  dp[i][j]=dp[i][j]%(1000000007);
	        		  }
	        	  }
	          }

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

	          return 0;
}


Measured memory_bytes: 5248
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define repit(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define sortt(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define mkp make_pair
#define mkt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
// inline void fastio() { ios::sync_with_stdio(false), cin.tie(0); }
/******* Variable ************************************/
const int maxn = 1e6 * 50;
const int inf = 1e9 + 7;
const double pi = 3.141592653589;
/******* Function ************************************/
/******* Main ****************************************/
void Main() {
  string s, p;
  cin >> s >> p;
  s += s;
  rep(i, 0, s.size() - p.size() + 1) {
    if (s.substr(i, p.size()) == p) {
      puts("Yes");
      return;
    }
  }
  puts("No");
}

/******************************************************
  Smaile!
▕▔╲┊┊┊┊┊┊┊┊┊╱▔▏
┊╲┈╲╱▔▔▔▔▔╲╱┈╱┊
┊┊╲┈╭╮┈┈┈╭╮┈╱┊┊
┊┊╱┈╰╯┈▂┈╰╯┈╲┊┊
┊┊▏╭╮▕━┻━▏╭╮▕┊┊
┊┊╲╰╯┈╲▂╱┈╰╯╱
                      How`s it going?
                              |＼
                      　／￣＼　ヽ
                      ／　　　ヽ |_
                      ￣＼　　　　 ＼
                      ／￣　/|/| /ﾚ､ ヽ＿
                      ￣＼ Yヘ |/ヘ幺　∠
                      　＜_|(･> <･) 6) ／
                      　　 (ﾞ　_　ﾞ／＜
                      　　　＞､ーイ￣￣
                      　　／厂ヽ／￣/＼
                      　 ( ｜　(亀)(>　)▏

                            Take a rest before getting tired!
                                        　　 ●
                                        　　/⌒ヽ
                                        　 ｜ 　|/⌒ヽ(ヽ
                                        　 (｀　∥ー⌒) |
                                        　|￣||￣￣￣￣￣|
                                        　|―||―――――|
                                        　|　Ｕ　　　　　|
                                        　|￣￣￣￣￣￣￣|
                                        　|＿＿＿＿＿＿＿|
                                        　　|―――――|
                                        　　|―――――|
                                        ｗｗＷｗｗＷｗＷＷｗ

******************************************************/
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

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 A, B;
  cin >> A >> B;
  ll ans = lcm(A, B);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#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 reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll N; string S;
    cin>>N>>S;
    ll r=0, w=0;
    rep(i, N){
        if(S[i]=='R') r++;
        else w++;
    }
    ll rt=0, wt=0, Minim=r;
    rep(i, N){
        if(S[i]=='R') rt++;
        else wt++;
        ll hanten=max(wt,(r-rt));
        Minim=min(Minim, hanten);
    }
    cout<<Minim<<endl;
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(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)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    LL N;
    cin >> N;
    LL M;
    cin >> M;

    LL r = (N == 1 ? 1 : N - 2);
    LL c = (M == 1 ? 1 : M - 2);

    cout << r * c << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

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

int main() {
  string n;
  cin >> n;
  
  if((n.at(0)==n.at(1) and n.at(1)==n.at(2)) or (n.at(1)==n.at(2) and n.at(2)==n.at(3))){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
cnt = 0
for i in range(1, n+1):
    sum = i%10 + i//10%10 + i//100 % 10 + i//1000 % 10 + i//10000 % 10
    if((a <= sum)and(b >= sum)):
        cnt += i

print(cnt)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;
int main(){
  int n;cin >> n;
  vector<Int> a(n+1,0);
  a[0] = 2;
  a[1] = 1;
  for(int i=2;i<n+1;i++){
    a[i] = a[i-2]+a[i-1];
  }
  cout << a[n] << endl;
}


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

#define vvi vector<vector<int>>
#define ll long long int

int main() {

    string s, t;
    cin >> s >> t;

    vvi dic(30);
    int num;
    for (int i = 0; i < s.length(); i++) {
        num = int(s[i]) - int('a');
        dic[num].push_back(i);
    }

    ll j = -1;
    ll count = 0;
    int num_i;

    for (int i = 0; i < t.length(); i++) {
        num_i = int(t[i]) - int('a');
        if (dic[num_i].size() > 0) {
            auto itr = lower_bound(dic[num_i].begin(), dic[num_i].end(), j+1);
            if (itr == dic[num_i].end()) {
                count++;
                j = dic[num_i][0];
            }
            else j = *itr;
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << count * s.length() + j + 1 << endl;

    return 0;
}


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

int main(){
  int h,w,a,b;
  cin >> h >> w >> a >> b;
  r(i,b){
    r(j,w-a)cout << 1;
    r(j,a)cout << 0;
    cout << endl;
  }
  r(i,h-b){
    r(j,w-a)cout << 0;
    r(j,a)cout << 1;
    cout << endl;
  }
}

Measured memory_bytes: 1280
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int x=scanner.nextInt();
		int y=scanner.nextInt();
		int tmp1=x+Math.abs(Math.abs(x)-Math.abs(y));
		int tmp2=-x+Math.abs(Math.abs(x)-Math.abs(y));
		int tmp3=-(x+Math.abs(Math.abs(x)-Math.abs(y)));
		int tmp4=-(-x+Math.abs(Math.abs(x)-Math.abs(y)));
		int ans=0;
		if(tmp1==y)ans=Math.abs(Math.abs(x)-Math.abs(y));
		else if(tmp2==y||tmp3==y)ans=Math.abs(Math.abs(x)-Math.abs(y))+1;
		else ans=Math.abs(Math.abs(x)-Math.abs(y))+2;
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

const ll mod=998244353;

int n;

ll fac[maxn],ans;

struct node{
	int x,y;
}a[maxn];

ll qpow(ll base,ll K){
	ll res=1;
	while(K){
		if(K&1) res=(res*base)%mod;
		base=(base*base)%mod;
		K>>=1;
	}
	return res;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].y);
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=(fac[i-1]*2)%mod;
	ans=(fac[n]-n-1+mod)%mod;
	for(int i=1;i<=n;i++){
		for(int j=1;j<i;j++){
			int sum=0;
			for(int k=1;k<j;k++) if(1ll*(a[i].x-a[j].x)*(a[j].y-a[k].y)==1ll*(a[i].y-a[j].y)*(a[j].x-a[k].x)) sum++;
			ans=(ans-fac[sum]+mod)%mod;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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; }
ll mod = 1e9+7;


int main(){
    ll n,m; cin >> n >> m;
    vector<ll> stair(n+1,true);
    for(ll i=0;i<m;i++){
        ll x; cin >> x;
        stair[x] = false;
    }
    ll dp[n+1];
  	for(int i=0;i<n+1;i++){ dp[i] = 0;}
    dp[0]=1; 
    for(ll i=1;i<n+1;i++){
        if(i>1){
            if(stair[i])
                dp[i] = (dp[i-1]+dp[i-2])%mod;
           	else
                dp[i] = 0;
            
        }else{
            if(stair[i]) 
            	dp[i]=dp[i-1]; 
            else 
            	dp[i]=0;
        }
    }
    cout << dp[n]%mod << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
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 ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

int A[MAX];
int D[MAX];

int AA[MAX];
int DD[MAX];

int RES[MAX];
int R[MAX];

VI solve(int n, int m, int t)
{
	FOR (i, 0, n)
	{
		int d = t;
		if (D[i] == 1) d = -d;
		RES[i] = A[i] + d;
		RES[i] %= m;
		if (RES[i] < 0) RES[i] += m;
	}

	LL tot = 0;

	int x = A[0];
	FOR (i, 1, n)
	{
		if (D[i] == D[0]) continue;
		int y = A[i];

		int dst = 0;

		if (D[i] == 1) dst = y - x;
		else dst = m - (y - x);

		LL cur = 0;

		int v = 2 * t;

		v -= dst;

		if (v <= 0) continue;
		cur = 1;
		cur += v / m;
		if (v % m == 0) cur--;

		tot += cur;
	}

	tot %= n;

	if (D[0] == 1) tot = n - tot;
	tot %= n;

	int ind = tot;
	int val = RES[0];
	int dir = D[0];

//	cout<<ind<<' '<<val<<' '<<dir<<endl;

	sort(RES, RES + n);

	int wh = -1;

	FOR (i, 0, n)
	{
		if (RES[i] == val)
		{
			if (dir == 1 && i < n && RES[i+1] == val) i++;
			wh = i;
			break;
		}
	}

	FOR (i, ind, n)
	{
		R[i] = RES[wh];
		wh++;
		if (wh >= n) wh -= n;
	}

	FOR (i, 0, ind)
	{
		R[i] = RES[wh];
		wh++;
		if (wh >= n) wh -= n;
	}

	VI res;
	FOR (i, 0, n)
	{
		res.PB(R[i]);
	}
	return res;
}

VI brute(int n, int m, int t)
{
	FOR (i, 0, n)
	{
		A[i] *= 2;
	}
	m *= 2;
	t *= 2;

	FOR (it, 0, t)
	{
		FOR (i, 0, n)
		{
			if (D[i] == 0) A[i]++;
			else A[i]--;
			A[i] %= m;
			if (A[i] < 0) A[i] += m;
		}

		FOR (i, 0, n)
		{
			int i1 = i;
			int i2 = (i+1) % n;
			if (A[i1] == A[i2])
			{
				D[i1] ^= 1;
				D[i2] ^= 1;
			}
		}
	}

	VI res;
	FOR (i, 0, n)
	{
		res.PB(A[i] / 2);
	}

	return res;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	while(true)
	{
		int n, m, t;
		scanf("%d%d%d", &n, &m, &t);
		//n = 3;
		//m = 10;
		//t = 7;
		set<int> s;
		FOR (i, 0, n)
		{
			int x, d;
			scanf("%d%d", &x, &d);
			//x = rand() % m;
			//while(s.count(x)) x = rand() % m;
			//s.insert(x);
			//d = rand() % 2 + 1;
			d--;

			A[i] = x;
			D[i] = d;

			AA[i] = x;
			DD[i] = d;
		}

		//sort(A, A+n);
		//sort(AA, AA+n);

		VI a = solve(n, m, t);
	/*	VI b = brute(n, m, t);

		if (a != b)
		{
			cout<<n<<' '<<m<<' '<<t<<endl;
			FOR (i, 0, n)
			{
				cout<<AA[i]<<' '<<DD[i]<<endl;
			}

			FOR (i, 0, SZ(a))
			{
				cout<<a[i]<<' ';
			}
			cout<<endl;
			FOR (j, 0, SZ(b))
			{
				cout<<b[j]<<' ';
			}
			cout<<endl;
			throw -1;
		}
		else cout<<"ok"<<endl<<endl;*/


		FOR (i, 0, n)
		{
			printf("%d\n", R[i]);
		}
		break;
	}

}


Measured memory_bytes: 4088
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

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

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



void solve(void){

  int N, M;
  
  cin >> N >> M;
  
  if(M<N){
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }


  return;
}

int main(int argc, const char * argv[]) {


    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}


Measured memory_bytes: 256
a=input().split()
b=input().split()
N=int(a[0])
K=int(a[1])
c=[]
s=0

for i in range(N):
 l=int(b[i])
 c.append(l)
c.sort(reverse=True)
for i in range(K):
 s +=c[i]
print(s)

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

using i64 = int64_t;

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for(int i=0;i<s.size();++i){
        cnt += (i%2) == (s[i]-'0');
    }
    int ans = cnt;
    cnt = 0;
    for(int i=0;i<s.size();++i){
        cnt += (!(i%2)) == (s[i]-'0');
    }
    ans = min(ans, cnt);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
import sys

def solve():
    n, a, b = map(int, input().split())

    if n == 1:
        if a == b:
            print(1)
        else:
            print(0)
    else:
        if a > b:
            print(0)
        else:
            ans = (n - 2)*(b - a) + 1
            print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
a,b,h,w = gets.split.map &:to_i

if (a%h).zero? && (b%w).zero?
  puts "No"
  exit
end

swap = (b%w).zero?
a,b,h,w = b,a,w,h if swap

s = Array.new
s[b] = 1
b.step(1+w, -w) do |i|
  s[i-w] = s[i] + 1
end
w.times do |i|
  next if s[i]
  s[i] = 0
  i.step(b-w, w) do |j|
    s[j+w] = s[j] - 1
  end
end

t = [b.times.map{|i| s[i+1]-s[i]}] * a
t = t.transpose if swap

puts "Yes", t.map{|i| i*" "}


Measured memory_bytes: 7932
#include <stdio.h>

int main()
{
	int A,B,C,D,E,F,t=0;
	
	scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);

	if(A<B)//AとBを交換
	{
		t = B;
		B = A;
		A = t;
	}

	if(B<C)//BとCを交換
	{
		t = C;
		C = B;
		B = t;
	}

	if(C<D)//CとDを交換
	{
		t = D;
		D = C;
		C = t;
	}

	if(A<B)//AとBを交換
	{
		t = B;
		B = A;
		A = t;
	}
	
		if(B<C)//BとCを交換
	{
		t = C;
		C = B;
		B = t;
	}

	if(A<B)//AとBを交換
	{
		t = B;
		B = A;
		A = t;
	}



if(E>=F) printf("%d\n",A+B+C+E);

if(E<F) printf("%d\n",A+B+C+F);

	

	return 0;
}



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

int main() {
	int n; cin >> n;
	vector<int>a(n); for (auto&& x : a)cin >> x;
	
	int cnt4 = 0, cnt2 = 0;
	for (auto&& x : a) {
		if (x >= 4 && x % 4 == 0)cnt4++;
		else if (x >= 2 && x % 2 == 0)cnt2++;
	}
	cnt4 += (cnt2 / 2);
	cout << (cnt4 >= n / 2 ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std; 
  
int main(){
  int n;
  scanf("%d",&n);
  unsigned long sum = 0;
  
  for(int i=1;i<=n;i++){
  	
  	
  	if(i%3==0 && i%5==0){
  		//printf(",FIZZBUZZ,");
	  }
	else if(i%3==0){
	//	printf(",FIZZ,");
	} 
	else if(i%5==0){
	//	printf(",BUZZ,");
	}
	else{
	
	//printf(",%d,",i);
	sum= sum+i;
    }
  }
  printf("%ld",sum);
  
  return 0;
}

Measured memory_bytes: 3816
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

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

    int A[3];
    cin >> A[0] >> A[1] >> A[2];

    int ans = 3000;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (j == i) {
                continue;
            }
            for (int k = 0; k < 3; ++k) {
                if (i == k || j == k) {
                    continue;
                }
                int tmp = abs(A[j] - A[i]) + abs(A[k] - A[j]);
                ans = min(ans, tmp);
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String strn = input.readLine( );
		int n = Integer.parseInt(strn);
		String strk = input.readLine( );
		int k = Integer.parseInt(strk);
		String strx = input.readLine( );
		int x = Integer.parseInt(strx);
		String stry = input.readLine( );
		int y = Integer.parseInt(stry);

		int answer = 0;


		if(n>k){
			for(int i=0; i<k; i++){
				answer = answer + x;
			}
			for(int i=k; i<n; i++){
				answer = answer + y;
			}
		}else{
			for(int i=0; i<n; i++){
				answer = answer + x;
			}
		}

		System.out.println(answer);
	}

}


Measured memory_bytes: 21460
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())

x = [0] * n
y = [0] * n

for i in range(n):
    x[i], y[i] = map(int, input().split())


sum = 0
c = 0

for i in range(n):
    for j in range(i):
        sum += math.sqrt((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2)
        c += 1

if n == 2:
    print(sum)
else:
    print(sum * 2 / n )

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll mod=1000000007;
ll MOD=998244353;

int main() {
    ll n,x,m;
    cin >> n >> x >> m;
    ll c=1,su=x,cc,se;
    map<ll,pair<ll,ll>> s;
    s[x]=mk(0,0);
    while(true){
        if (c==n){
            cout << su << endl;
            return 0;
        }
        ll u=x*x%m;
        if (s.find(u)!=s.end()){
            cc=c-s[u].first;
            se=su-s[u].second;
            x=u;
            break;
        }
        s[u]=mk(c,su);
        c++;
        su+=u;
        x=u;
    }
    ll ans=s[x].second+(n-s[x].first)/cc*se;
    if ((n-s[x].first)%cc!=0){
        ll w=x;
        rep(i,(n-s[x].first)%cc){
            ans+=w;
            w=w*w%m;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6680
#include <iostream>
#include <cmath>
#include <algorithm>
int main()
{
    using namespace std;
    string s, t;
    int a, b;
    string u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (s == u)
    {
        a = a - 1;
    }
    else if (t == u)
    {
        b = b - 1;
    }
    cout << a << ' ' << b;
    return 0;
}

Measured memory_bytes: 256