akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <atcoder/all>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace atcoder;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 300000;
const int K = 100000;
const int mod = 1e9 + 7;
int a[3];
string s[N];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, m;
    cin >> n >> m;
    mf_graph<int> g(n * m + 2);
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if (s[i][j] == '#') continue;
            if ((i + j) % 2 == 0) g.add_edge(n * m, i * m + j, 1);
            if ((i + j) % 2 == 1) g.add_edge(i * m + j, n * m + 1, 1);
            if ((i + j) % 2 == 1) continue;
            for (int l = 0; l < 4; l++){
                int ni = i + dx[l];
                int nj = j + dy[l];
                if (ni >= 0 && ni < n && nj >= 0 && nj < m && s[ni][nj] == '.'){
                    g.add_edge(i * m  + j, ni * m + nj, 1);
                }
            }
        }
    }
    cout << g.flow(n * m, n * m + 1) << endl;
    auto e = g.edges();
    for (auto x: e){
        if (x.flow == 1){
            if (x.from == n * m || x.to == n * m + 1) continue;
            int i = x.from / m;
            int j = x.from % m;
            int ni = x.to / m;
            int nj = x.to % m;
            if (i == ni){
                s[i][min(j, nj)] = '>';
                s[i][max(j, nj)] = '<';
            } else{
                s[min(i, ni)][j] = 'v';
                s[max(i, ni)][j] = '^';
            }
        }
    }
    for (int i = 0; i < n; i++) cout << s[i] << endl;
}


Measured memory_bytes: 15724
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();

		int n = s.length;
		if (s[0] == '0' || s[n - 1] == '1') {
			System.out.println(-1);
			return;
		}
		for (int i = 0; i < n / 2; i++) {
			if (s[i] != s[n - 2 - i]) {
				System.out.println(-1);
				return;
			}
		}

		PrintWriter pw = new PrintWriter(System.out);
		
		int idx = 0;
		for (int i = 0; i < n - 1; i++) {
			pw.println((idx + 1) + " " + (i + 2));
			if (s[i] == '1') {
				idx = i + 1;
			}
		}
		pw.flush();
	}
}


Measured memory_bytes: 42368
/* Accepted. */
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
using namespace std;
typedef long long ll;
#define MAXN 200000
int n , s , maxn , cur;
int main() {
	//freopen( "input","r",stdin );
	cin >> n;
	for( int i = 0 ; i < n ; ++ i ) {
		cin >> cur, s += cur, maxn = max( maxn , cur );
	}
	puts(maxn < s-maxn ? "Yes" : "No");
}//qwq



Measured memory_bytes: 256
#include<stdio.h>

int a,b,k,str;
int n,s,w,e,u,d,ans;

void dice(char *di){
	if(di[0]=='N'){	
		k=u;
		u=s;
		s=d;
		d=n;
		n=k;
	}else if(di[0]=='S'){
		k=u;
		u=n;
		n=d;
		d=s;
		s=k;
		
	}else if(di[0]=='W'){
		k=u;
		u=e;
		e=d;
		d=w;
		w=k;
		
	}else if(di[0]=='E'){
		k=u;
		u=w;
		w=d;
		d=e;
		e=k;
	}else if(di[0]=='L'){
		k=s;
		s=w;
		w=n;
		n=e;
		e=k;
		
	}else if(di[0]=='R'){
		k=s;
		s=e;
		e=n;
		n=w;
		w=k;
	}
        ans+=u;                  
}
int main(){
	while(1){
		n=5,s=2,w=4,e=3,u=1,d=6,ans=1;
		char di[6];
		scanf("%d",&a);
		if(a==0)break;
		for(b=0;b<a;b++){
			scanf("%s",di);
			dice(di);
			for(str=0;str<6;str++){
				di[str]='\0';
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
long long  A[1000005];
int main()
{
    int i;
    for(i=1;i<1000001;i++)
    {
        A[i]=i;
        if(i%3==0 || i%5==0)
        {
            A[i]=0;
        }
    }
    long long sum=1;
    for(i=2;i<1000001;i++)
    {
        sum+=A[i];
        A[i]=sum;
    }
    int N;
    scanf("%d",&N);
    printf("%lld",A[N]);

    return 0;
}


Measured memory_bytes: 9540
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse4,sse4.2,popcnt,abm,mmx,avx")
#endif
#include <bits/stdc++.h>

using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
typedef long long Long;
typedef double Double;

template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

vector<int> a, b, res;

int n;
const int N = 2e5 + 5;
int cnt_a[N], cnt_b[N];

const int RANDOM =
    chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);

bool validate() {
  bool valid = true;
  for (int i = 0; i < n; ++i) {
    valid &= (a[i] != res[i]);
  }
  return valid;
}

bool solve() {
  res = b;
  for (int t = 0; t < 50; ++t) {
    rotate(begin(res), begin(res) + rng() % n, end(res));
    if (validate()) return true;
  }
  res = b;
  reverse(all(res));
  for (int t = 0; t < 50; ++t) {
    if (validate()) return true;
    shuffle(all(res), rng);
  }
  return false;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif
  cin >> n;
  a.resize(n), b.resize(n), res.resize(n);
  cin >> a >> b;
  for (int x : b) ++cnt_b[x];
  for (int x : a) {
    ++cnt_a[x];
    if (cnt_b[x] + cnt_a[x] > n) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (solve()) {
    cout << "Yes" << endl;
    cout << res << endl;
    return 0;
  }

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


Measured memory_bytes: 7188
def submit():
    k = int(input())

    if k % 2 == 0:
        print(-1)
        return
    if k % 5 == 0:
        print(-1)
        return

    d = {}
    for t in [1, 3, 7, 9]:
        d[t] = {}
        for i in range(10):
            d[t][t * i % 10] = i
    
    td = k % 10
    curr = 0
    count = 0
    while count == 0 or curr != 0:
        diff = 7 - (curr % 10)
        if diff != 0:
            if diff < 0:
                diff += 10
            coef = d[td][diff]
            curr += coef * k
        curr //= 10
        count += 1

    print(count)
    
submit()

Measured memory_bytes: 9220
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
    };
    if n % k <= k / 2 {
        println!("{}", n % k);
    } else {
        println!("{}", k - n % k);
    }
}


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

using namespace std;

#define fo(i,CApiTaL_N) for(int i=0; i<CApiTaL_N; i++)
#define Fo(i,k,CApiTaL_N) for(int i=k; i<CApiTaL_N; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int t=1;
const int mxN=3e3;
string s1,s2;
vector<vector<pair<int,pii>>>dp(mxN+1,vector<pair<int,pii>>(mxN+1));

void test_case(){
    cin>>s1>>s2;
    int n=s1.size(), m=s2.size();
    Fo(i,1,n+1){
        Fo(j,1,m+1){
            if(s1[i-1]==s2[j-1]){
                dp[i][j]=max({mp(dp[i-1][j-1].first+1,mp(i-1,j-1)), mp(dp[i][j-1].first,mp(i,j-1)), mp(dp[i-1][j].first,mp(i-1,j))});
            }else{
                dp[i][j]=max(mp(dp[i][j-1].first,mp(i,j-1)), mp(dp[i-1][j].first,mp(i-1,j)));
            }
        }
    }
    auto fnl=mp(0,mp(0,0));
    string ans="";
    Fo(i,1,n+1){
        Fo(j,1,m+1){
            if(dp[i][j].first>fnl.first){
                fnl=dp[i][j];
            }
        }
    }
    pii prv=fnl.second,curr=fnl.second;
    if(fnl.first)ans.pb(s1[curr.first]);
    while(prv!=mp(0,0)){
        int l1=curr.first, r1=curr.second, l2=prv.first, r2=prv.second;
        // cout<<l1<<" "<<r1<<" "<<l2<<" "<<r2<<" "<<dp[l1][r1].first<<endl;
        if(l1+1==l2&&r1+1==r2){
            ans.pb(s1[l1]);
        }
        prv=curr;
        curr=dp[l1][r1].second;
    }

    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

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

    // cin>>t;
    while(t--){
        test_case();
    }
    
    return 0;
}

Measured memory_bytes: 109340
use proconio::{ input, fastout };

#[fastout]
fn main() {
    input! {
        n:usize,
    };
    let mut c0 = 0;
    let mut c1 = 0;
    let mut c2 = 0;
    let mut c3 = 0;
    for _ in 0..n {
        input! {
            res:String,
        }; 
        match &res[..] {
            "AC" => c0 += 1,
            "WA" => c1 += 1,
            "TLE" => c2 += 1,
            _ => c3 += 1,
        };
    }
    println!("AC x {}", c0);
    println!("WA x {}", c1);
    println!("TLE x {}", c2);
    println!("RE x {}", c3);

}


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

int main() {
  int n,c=0;cin>>n;
  vector<int> v(n);
  rep(i,n){
    cin>>v.at(i);
    if(v.at(i)!=i+1){c++;}
  }
  if(c==0||c==2)cout<<"YES";
  else{cout<<"NO";}
}



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

int parent(int i){
    return i / 2;
}
int left(int i){
    return 2 * i;
}
int right(int i){
    return 2 * i + 1;
}
int main(){
    int H, A[MAX + 1];
    cin >> H;
    for(int i = 1; i <= H; i++){
        cin >> A[i];
    }
    for(int i = 1; i <= H; i++){
        cout << "node " << i << ": key = " << A[i] << ", ";
        if(parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
        if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
        if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>

int main(void)
{
   int i,x;
   char s[4];

   scanf("%s",s);

   x = 0;
   for (i = 0;i < 4;i++) { 
     if (s[i] == '+')
      x = x + 1;
     else if (s[i] == '-')
      x = x - 1; 
   } 
   printf("%d\n",x);
   return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

typedef vector<char> VC;
typedef vector< VC > VVC;

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

	VVI res( n, VI( n, INT_MAX / 10 ) );

	REP( i, 0, n )
	{
		int from, num;
		cin >> from >> num;

		from--;

		REP( j, 0, num )
		{
			int to;
			cin >> to;

			to--;

			res[ from ][ to ] = 1;
		}
	}

	const int N = res.size();

	REP( k, 0, N )
	{
		REP( i, 0, N )
		{
			REP( j, 0, N )
			{
				res[i][j] = min( res[i][j], res[i][k] + res[k][j] );
			}
		}
	}

	int p;
	cin >> p;

	REP( i, 0, p )
	{
		int s, d, v;
		cin >> s >> d >> v;

		s--;
		d--;

		int dist = res[s][d] + 1;

		if ( dist <= v )
		{
			cout << dist << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3

from collections import defaultdict

N = int(input())

s = []
for i in range(N):
    s.append(input())

c = defaultdict(int)
for ss in s:
    c["".join(sorted(list(ss)))] += 1

result = 0
for v in c.values():
    result += v * (v - 1) // 2

print(result)


Measured memory_bytes: 25328
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	const int a[] = {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};
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

const int mod=1000000007;
struct mint{
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const{return mint(-x);}
  mint& operator+=(const mint a){
    if((x+=a.x)>=mod) x-=mod;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x+=mod-a.x)>=mod) x-=mod;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=mod;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a=pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }

  // for prime mod
  mint inv() const{
    return pow(mod-2);
  }
  mint& operator/=(const mint a){
    return (*this)*=a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};

ll c[60];

int main(){
  int N; cin >>N;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  rep(i,N){
    for(int j=0;j<60;j++){
      if(a[i]&(1ll<<j)) c[j]++;
    }
  }
  ll ans=0;
  rep(j,60){
    ans+=(1ll<<j)%MOD*c[j]%MOD*(N-c[j])%MOD;
    ans%=MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
N, M = map(int, input().split())
S = input()[::-1]

if S.find('1'*M) >= 0:
    print(-1)
    exit()

ans = []
i = 0
while i < N:
    a = S[i:i+M+1].rfind('0')
    ans.append(a)
    i += a

print(*ans[::-1])


Measured memory_bytes: 6408
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<utility>
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define ll long long
using namespace std;
int main() {
	std::ios::sync_with_stdio(false);
	ll n, a, b;
	cin >> n >> a >> b;
	ll time = n / (a + b);
	ll mod = n % (a + b);
	ll ans = a * time;
	if (mod>=a) {
		ans += a;
	}
	else {
		ans += mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int n;

int f(int v, int par, const vector<vector<int>> &G) {
    vector<int> vec;
    for (int u : G[v]) {
        if (u == par) continue;
        vec.push_back(f(u, v, G));
    }
    if (vec.size() == 0) return 0;
    sort(vec.rbegin(), vec.rend());
    int res = 0;
    int m = vec[0] + 1;
    REP(i, vec.size()) {
        m = max(m,vec[i] + i + 1);
    }
    res = m;
    return res;
}

int main() {
    cin >> n;
    vector<vector<int>> G(n);
    REP(i,n-1) {
        int a; cin >> a;
        G[i+1].push_back(a - 1);
        G[a-1].push_back(i+1);
    }
    cout << f(0,-1, G) << endl;
    return 0;
}

Measured memory_bytes: 16640
#include <iostream>
using namespace std;
void ABC80(void);
void ABC81(void);
void ABC83(void);
void ABC85(void);
void ABC86(void);
void ABC87(void);
void ABC88(void);
void ABC89(void);

int main(void){
    ABC86();
}

void ABC86(void){
    int a,b;
    cin>>a>>b;
    if((a*b)%2==1)cout<<"Odd"<<endl;
    else cout<<"Even"<<endl;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int m = 0;
	int t = b;
	while (t != 0) {
		m++;
		t = t / 10;
	}
	int c = a*pow(10, m)+b;
	int d = (int)(sqrt(c));
	d = d*d;
	if (d == c)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    string S;
    READ(S);
    ll N=S.length();
    bool flag=true;
    FORI(i,0,N)
    {
        if(i%2==0 && S[i]=='L')
        {
            flag=false;
        }
        else if(i%2==1 && S[i]=='R')
        {
            flag=false;
        }
    }
    if(flag)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
package main
import(
  "fmt"
  "sort"
)
func main() {
  var(
    x [4]int
    a [3][]int
    d,totalab,totalcd []int
    min int
  )
  for i:=0;i<=3;i++{
    fmt.Scan(&x[i])
  }
  for i:=0;i<3;i++{
    a[i]=make([]int,x[i],1000)
    for j:=0;j<x[i];j++{
      fmt.Scan(&a[i][j])
    }
  }
  for _,i:=range a[0] {
    for _,j:=range a[1] {
      totalab=append(totalab,i+j)
    }
  }
  sort.Sort(sort.Reverse(sort.IntSlice(totalab)))
  min=x[3]
  if x[0]*x[1]<x[3]{
    min=x[0]*x[1]
  }
  for i:=0;i<min;i++{
    d=append(d,totalab[i])
  }
  for _,i:=range a[2]{
    for _,j:=range d{
      totalcd=append(totalcd,i+j)
    }
  }
  sort.Sort(sort.Reverse(sort.IntSlice(totalcd)))
  for i:=0;i<x[3];i++{
    fmt.Println(totalcd[i])
  }
}

Measured memory_bytes: 105856
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

def main():
    N, K = geta(int)
    h = geta(int)

    INF = 10 << 60
    dp = [INF]*N
    dp[0], dp[1] = 0, abs(h[0] - h[1])

    for i in range(2, N):
        lb = max(0, i-K)
        tmp, hi = INF, h[i]
        for dpj, hj in zip(dp[lb:i], h[lb:i]):
            tmp = min(tmp, dpj + abs(hi-hj))
        dp[i] = tmp

    print(dp[-1])

if __name__ == "__main__":
    main()

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

int main()
{
    int a[4], b[2];

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

    cin >> b[0] >> b[1];

    sort(a, a + 4);

    cout << a[1] + a[2] + a[3] + max(b[0], b[1]) << endl;
}



Measured memory_bytes: 3148
#include <math.h>

#include <iostream>

using namespace std;

int main(void) {
  double a, b, x;
  cin >> a >> b >> x;
  const double kPi = M_PI;

  double l = 0, r = kPi / 2.0;

  while (abs(r - l) > 1e-10) {
    double m = (r + l) / 2.0;
    double y = 0.0;
    if (b / tan(m) > a) {
      y = a * a * b - (a * tan(m) * a * a) / 2.0;
    } else {
      y = b / tan(m) * a * b / 2.0;
    }

    if (x < y) {
      l = m;
    } else {
      r = m;
    }
  }
  printf("%.10f\n", l * 180.0 / kPi);
  return 0;
}


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

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

using namespace std;

namespace utils{
  template <typename T> void print(vector<vector<T>> mat) {
    rep (i, mat.size()) {
      rep (j, mat[0].size()) cout << mat[i][j] << ' ';
      cout << endl;
    }
  }

  template <typename T> void print(vector<T> v) {
    rep (i, v.size()) cout << v[i] << ' ';
    cout << endl;
  }

  template <typename T> pair<T, T> shape(vector<vector<T>> mat) {
    int d1, d2;

    d1 = mat.size();
    if (d1 > 0) d2 = mat[0].size();
    else int d2 = 0;
    cout << "(" << d1 << ", " << d2 << ")" << endl;
    return make_pair(0, 0);
  }

  template <typename T> vector<vector<T>> empty(int n, int m) {
    vector<vector<T>> mat(n, vector<T>(m));
    return mat;
  }
}


const long long d = 1000000000 + 7;

long long factorial(long long n) {
  if (n>1) return (n%d) * factorial(n-1);
  return 1;
}

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

  long long ans = 1;

  long long fn = 1;
  long long fm = 1;

  for (long long i=1; i<=n; i++) {
    fn = (fn * (i%d)) % d;
  }
  fn %= d;

  for (long long i=1; i<=m; i++) {
    fm = (fm * (i%d)) % d;
  }
  fm %= d;

  // cout << fn << endl;
  // cout << fm << endl;


  if (abs(n-m) > 1) {
    ans = 0;
  }
  else {
    if (n == m) ans *= 2;
    ans *= (fm * fn);
    ans %= d;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())

def number(a,b,c):
    num=a%b
    sumn=0
    for i in range(2,10000000):
        if sumn==c:
            print("YES")
            return
        sumn+=num
        if sumn>b:
            sumn=sumn%b
    print("NO")
number(a,b,c)

Measured memory_bytes: 9012
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
#define int long long
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ

signed main(){
    int n; cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    int ans=1001001;
    rep(bit,1<<n){
        vector<P> v,w;
        rep(i,n){
            if(bit&(1<<i)){ //omote
                if(i%2==0) v.pb({a[i],i});
                else w.pb({a[i],i});
            }else{ //ura
                if(i%2==0) w.pb({b[i],i});
                else v.pb({b[i],i});
            }
        }
        sort(ALL(v));
        sort(ALL(w));
        if(v.size()==w.size()||v.size()==w.size()+1){
            bool ok=1;
            vector<P> lst;
            rep(i,v.size()){
                if(i!=0&&lst.back().fi>v[i].fi) ok=0;
                lst.pb(v[i]);
                if(i!=w.size()&&lst.back().fi>w[i].fi) ok=0;
                if(i!=w.size()) lst.pb(w[i]);
            }
            if(ok){
                int res=0;
                rep(i,n){
                    rep(j,n){
                        if(i<j&&lst[i].se>lst[j].se) res++;
                    }
                }
                chmin(ans,res);
            }
        }
    }
    cout << (ans==1001001 ? -1 : ans) << endl;
}


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

signed main(void)
{
	rep(i, 5)
	{
		int a;
		cin  >> a; 
		if (a == 0)
			cout << i + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int N = s.length();
        int M = t.length();
        int[][] dp = new int[N + 1][M + 1];

        for (int i = 1; i < N + 1; i++) {
            for (int j = 1; j < M + 1; j++) {
                dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                if (s.charAt(i - 1) == t.charAt(j - 1)) {
                    dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - 1] + 1);
                } else {
                    dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - 1]);
                }
            }
        }
        List<Character> ansList = new ArrayList<>();
        int n = N - 1;
        int m = M - 1;
        while (n >= 0 && m >= 0) {
            if (s.charAt(n) == t.charAt(m)) {
                ansList.add(s.charAt(n));
                n--;
                m--;
            } else {
                if (dp[n + 1][m + 1] == dp[n][m + 1]) {
                    // case s.charAt(n) is not needed
                    n--;
                } else {
                    m--;
                }
            }
        }
        Collections.reverse(ansList);
        StringBuilder sb = new StringBuilder();
        for (Character c : ansList) {
            sb.append(c);
        }
        String ans = sb.toString();
        System.out.println(ans);
    }
}

Measured memory_bytes: 80972
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x);
#define bb(x)      cerr<< x <<endl;
#define ii         pair<int,int>
#define vi         vector<int>
#define fr         first
#define se         second
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M   = 1e7+9 ;
const ll inf = 1e19  ;
const int si = 1e5+9 ;
//////////////////////    Hi    ^_^  hack me if you can :P

set<pair<int,int>>st;
vector<ii> v;
int a[si];
int ans;
int main()
{
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
            cin>>a[i];
    }
        for(int i=1;i<=n;i++)
    {
            ii q = {a[i],i};
            if(st.find(q)!=st.end()){
                ++ans;
            }
            ii p = {i,a[i]};
            st.insert(p);
    }

    cout<<ans<<endl;
    r0;
}



Measured memory_bytes: 5376
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define debug(x) cout<<#x<<": "<<x<<endl
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int main(void)
{
    ll N, X;
    cin >> N >> X;
    ll ret = 0;
    ll Y, Z, m;

    ret += X + (N - X);
    Y = X;
    Z = N - X;
    while (true) {
        //debug(Y);
        //debug(Z);
        m = Z / Y;
        //debug(m);
        if (Z % Y == 0) {
            ret += (2*m - 1) * Y;
            break;
        }
        ret += 2 * m * Y;
        ll tempz = Z;
        Z = Y;
        Y = tempz - m * Y;
    }
    printf("%lld\n", ret);
    return 0;
}


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

int main() {
	int N;
	string s;
	cin >> N >> s;
	int red = 0;
	for (int i = 0;i < N;++ i) if (s[i] == 'R') ++ red;
	cout << (red > N - red ? "Yes" : "No");
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

*/

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int i;
  char s[9999];
  fgets(s,9999,stdin);
  for(i=0;s[i+4]!=0;i++)
    {
      if(s[i]=='a' && s[i+1]=='p' &&  s[i+2]=='p'&& s[i+3]=='l'&& s[i+4]=='e')
	s[i]='p',s[i+1]='e',s[i+2]='a',s[i+3]='c',s[i+4]='h';
      else if(s[i]=='p'&&s[i+1]=='e'&&s[i+2]=='a'&&s[i+3]=='c'&&s[i+4]=='h')
	s[i]='a',s[i+1]='p',s[i+2]='p',s[i+3]='l',s[i+4]='e';     
    }
  printf("%s",s);
  exit(0);
}

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

void compute(){
    int x, y, w, h, n, px, py;
    int sum = 0;
    cin >> x >> y >> w >> h >> n;
    for ( int i = 0; i < n; i++ ){
	cin >> px >> py;
	if ( x <= px && px <= x + w &&
	     y <= py && py <= y + h ) sum++;
    }
    cout << sum << endl;
}
main(){
    int tcase; cin >> tcase;
    for ( int i = 0; i < tcase; i++ ) compute();
}

Measured memory_bytes: 0
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    sc.nextLine()
    val numberSequence = sc.nextLine.split(" ").map(_.toInt)

    @annotation.tailrec
    def go(num: Int, acc: Int): Int = {
      if (num % 2 != 0) acc
      else go(num / 2, acc + 1)
    }

    println(numberSequence.map(go(_, 0)).sum)
  }
}

Measured memory_bytes: 32000
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(NULL); cin.tie(NULL);
 
using namespace std;
const int N = 1E5+7;
 
long long f[107][N];
int n,W;
long long w[N], c[N];
 
int main()
{
    fastIO
    cin>>n>>W;
    
    for (int i = 1;i <= n; ++i) cin>>w[i]>>c[i];
    
    for (int i = 1;i <= n; ++i)
        for (int j = W;j >= 1;--j)
            if (j-w[i] >= 0) f[i][j] = max(f[i-1][j],f[i-1][j-w[i]]+c[i]);
            else f[i][j] = f[i-1][j];
    
    cout<<f[n][W];
}

Measured memory_bytes: 81724
#include <iostream>
#include <vector>

long body(std::vector<long>& a, long base){
    long ans  = 0;
    
    std::vector<long> s(a.size());
    s.at(0) = a.at(0);
    for(unsigned long i = 1; i < a.size(); i++){
        s.at(i) = s.at(i-1) + a.at(i);
    }

    long diff = 0;
    long prev = base;
    for(unsigned long i = 0; i < s.size(); i++){
        s.at(i) += diff; // update
        long n = 0;
        if(prev > 0 && s.at(i) >= 0){
            n = s.at(i) + 1;
            ans += n;
            diff -= n;
        }else if(prev < 0 && s.at(i) <= 0){
            n = - s.at(i) + 1;
            ans += n;
            diff += n;
        }
        prev = - prev;
    }
    return ans;
}

int main(int argc, char **argv)
{
    long n;
    std::cin >> n;

    std::vector<long> a(n);
    for(long i = 0; i < n; i++){
        std::cin >> a.at(i);
    }

    long ans_a, ans_b;
    
    ans_a = body(a, -1);
    ans_b = body(a, 1);
    
    long ans = std::min(ans_a, ans_b);

    std::cout << ans << std::endl;
    
}


Measured memory_bytes: 1804
#include <iostream>
#include <list>
using namespace std;
int main(){
	int N,M,Q;
	cin>>N>>M>>Q;
	list<int> L;
	for(int i=0;i<N;i++)
		L.push_back(i);
	list<int>::iterator btn=L.begin();
	for(int i=0;i<M;i++){
		int a;
		cin>>a;
		if(a%2==0){
			for(int j=0;j<a;j++){
				btn++;
				if(btn==L.end())
					btn=L.begin();/*endの後はデータが入っているから動かしてからチェックしてもおっけ-
*/
			}
		}
		else{
			for(int j=0;j<a;j++){
				if(btn==L.begin())
					btn=L.end();/*beginの前のデータがいないからチェックしてから動かさなければならない*/
				btn--;
			}
		}
		list<int>::iterator it=btn;
		btn++;
		if(btn==L.end())
			btn=L.begin();
		L.erase(it);
	}
	for(int i=0;i<Q;i++){
		int q;
		cin>>q;
		list<int>::iterator it;
		for(it=L.begin();it!=L.end();it++){
			if(*it==q)
				break;
		}
		if(it!=L.end())
			cout<<1<<endl;
		else
			cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 7440
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

ostream& operator <<(ostream& out, const pair<int, int>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const set<T>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n, m, x;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d", &x);
    n -= x;
  }
  puts(n <= 0 ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();

    // どれかが残り二つの合計値になっていたらYes
    if(a == b + c || b == c + a || c == a + b) {
      System.out.println("Yes");
    // さもなくばNo
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35772
#include <stdio.h>

int max(int a, int b);

int main(void)
{
	int N;
	scanf("%i", &N);
	int t[N][3];
	for(int i = 0; i < N; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			scanf("%i", &t[i][j]);
		}
	}
	int table[N][3];
	for(int k = 0; k < 3; k++)
	{
		table[0][k] = t[0][k];
	}
	
	for(int i = 1; i < N; i++)
	{	
		{
			table[i][0] = (t[i][0] + max(table[i - 1][1], table[i - 1][2]));
		}

		{
			table[i][1] = (t[i][1] + max(table[i - 1][2], table[i - 1][0]));
		}

		{
			table[i][2] = (t[i][2] + max(table[i - 1][0], table[i - 1][1]));
		}
	}

	int maxima = max(max(table[N - 1][0], table[N - 1][1]), table[N - 1][2]);
	printf("%i", maxima);
}

int max(int a, int b)
{
	if(a > b)
	{
		return a;
	}
	else
	{
		return b;
	}
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
const long long mod = 1000000007; 
using namespace std;
int main(){
	int n, m, t; 
	int a[2005];
	long long c = 0; 
	cin >> n >> m;
	for(int i=1; i<=n; ++i) cin >> a[i]; 
	t = 0; 
	for(int i=1; i<=n; ++i)
		for(int j=i+1; j<=n; ++j)
			if(a[i] > a[j]) ++t; 
	c += 1ll*m*t%mod; 
	t = 0; 
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=n; ++j)
			if(a[i] > a[j]) ++t; 
	c = (c+(1ll*m*(m-1)/2)%mod*t%mod)%mod;
	cout << c << endl; 
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    A, B, C, D = input()

    for a in ["+", "-"]:
        for b in ["+", "-"]:
            for c in ["+", "-"]:
                if eval(A + a + B + b + C + c + D) == 7:
                    print(A + a + B + b + C + c + D + "=7")
                    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 4336
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

h,k = map(int, input().split())
h = np.array(sorted(list(int(i) for i in input().split()), \
      reverse = True))

print(h[k:].sum())


Measured memory_bytes: 35740
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String n = s.next();
        n = n.replace('1','2');
        n = n.replace('9','1');
        n = n.replace('2','9');
        System.out.println(n);
    }
}


Measured memory_bytes: 23124
import Control.Applicative
import Control.Monad.State

main = do
    n <- getLine
    xs <- map read.words<$>getLine
    let (list, s) = bubbleSort xs
    putStrLn $ unwords.map show $ list
    print s

bubbleSort xs = runState (bSort xs) 0

bSort :: [Int] -> State Int [Int]
bSort [] = return []
bSort xs = do
    (y:ys) <- bubble xs
    ys' <- bSort ys
    return (y:ys')

bubble :: [Int] -> State Int [Int]
bubble [x] = return [x]
bubble (x:xs) = do
    (y:ys) <- bubble xs
    if x > y
       then modify (+1) >> return (y:x:ys)
       else return (x:y:ys)



Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//
signed main()
{
  ios();
  string S;
  cin >> S;
  int cnt = 0;
  int l = S.length();
  rep(i,l)
  {
    if(S[i] == '0')
    {
      cnt ++;
    }
  }
  cout << min(cnt,l-cnt) * 2 << endl;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std; 
int main (){
int s,k;
scanf("%d%d",&k,&s);
int c=0,z;
for(int y=0;y<=k;y++){

for(int x=0;x<=k;x++)
{

z=s-(y+x);
if (z>=0&&z<=k)
c++;
}
}
printf("%d",c);
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    string s; cin >> s;

    for (int i = 0; i < 3; ++i) {
        cout << s[i];
    }

    cout << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MD=int(1e9)+7;

int madd(int x,int y) {
	if (x+y<MD) return x+y; else return x+y-MD;
}
int mmul(int x,int y) {
	return int(ll(x)*y % MD);
}

int const MAXN=4400;
int C[MAXN][MAXN];

int f(int n,int k) {
	if (n<k) return 0;
	return C[n-1][k-1];
}

int g(int n,int k) {
	if (n<k-1) return 0;
	return C[n+1][k];
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	C[0][0]=1;
	rep(i,1,MAXN) rep(j,0,i+1) {
		C[i][j]=C[i-1][j];
		if (j>0) C[i][j]=madd(C[i][j],C[i-1][j-1]);
	}
	
	int N,K;
	cin>>N>>K;

	rep(i,1,K+1) cout<<mmul(f(K,i),g(N-K,i))<<"\n";
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin >> d[i];
  }
  
  sort(d.begin(),d.end());
  cout << d[N/2] - d[(N/2)-1] << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

int main() {
  size_t A, B;
  std::cin >> A >> B;

  std::string S;
  std::cin >> S;

  for (size_t i = 0; i < S.length(); ++i)
    if ((S[i] == '-') ^ (i == A))
      return (std::cout << "No" << std::endl), 0;

  std::cout << "Yes" << std::endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    def f(n):
        return n // x + 1

    a, b, x = map(int, input().split())
    print(f(b) - f(a - 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61864
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 555
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int H,W,h,w;
int a[MAX][MAX];
long long sum=0;
int main()
{
	H=read();W=read();h=read();w=read();
	for(int i=1;i<=H;++i)
		for(int j=1;j<=W;++j)
			a[i][j]=1000;
	for(int i=h;i<=H;i+=h)
		for(int j=w;j<=W;j+=w)
			a[i][j]=-h*w*1000+999;
	for(int i=1;i<=H;++i)
		for(int j=1;j<=W;++j)sum+=a[i][j];
	if(sum<0)puts("No");
	else
	{
		puts("Yes");
		for(int i=1;i<=H;++i,puts(""))
			for(int j=1;j<=W;++j)
				printf("%d ",a[i][j]);
	}
	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int M1 = sc.nextInt();
		int D1 = sc.nextInt();
		int M2 = sc.nextInt();
		int D2 = sc.nextInt();
		if (D2 == 1) {
			System.out.println("1");
		} else {
			System.out.println("0");
		}
	}

}

class FScanner {
	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 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: 21716