akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] candy = new int[2][n];

        for(int i=0;i<n;i++)candy[0][i]=sc.nextInt();
        for(int i=0;i<n;i++)candy[1][i]=sc.nextInt();

        int[] leftsum = new int[n];
        int[] rightsum = new int[n];

        leftsum[0]=candy[0][0];
        for(int i=1;i<n;i++){
            leftsum[i]=leftsum[i-1]+candy[0][i];
        }
        rightsum[n-1]=candy[1][n-1];
        for(int i=n-2;i>-1;i--){
            rightsum[i]=rightsum[i+1]+candy[1][i];
        }

        int ans=0;
        for(int i=0;i<n;i++){
            ans=Math.max(ans,leftsum[i]+rightsum[i]);
        }
        System.out.println(ans);

    }

}




Measured memory_bytes: 23124
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n;
	while(cin >> n){
		vector<LL> a(n);
		REP(i,n) cin >> a[i];
		// LL ans = 0;
		map<LL,int> cnt;
		REP(i,n) cnt[a[i]]++;
		LL x = 0, y = 0;
		LL se = 0;
		vector<LL> hoge;
		for(auto&& e : cnt) {
			// if(x > y) swap(x,y);
			if(e.S >= 2){
				hoge.push_back(e.F);
				if(e.S >= 4) chmax(se,e.F*e.F);
			}
		
		}
		sort(ALL(hoge));
		// cout << x*y << endl;
		if(SZ(hoge) < 2) {
			cout << 0 << endl;
		}else{
			cout << max(se,hoge[SZ(hoge)-1]*hoge[SZ(hoge)-2]) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define int long long
// iteration and input/output stream
#define rep(i,a,b) for(int i = a;i<=b;i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
 
typedef long long ll; // 64 bit integer
typedef unsigned long long ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
 
vi h;
vi dp;
int n;
int f(int i)
{
    if(i>n)return 0 ;
    if(dp[i]!=-1) return dp[i];
    if(i==n)
    {
        return 0;        
    }
    else
    {
        int val1 = abs(h[i+1]-h[i])+f(i+1);
        if(i+2<=n) val1 = min(val1,abs(h[i+2]-h[i])+f(i+2));
        dp[i] = val1;
        return dp[i];
    }
}

signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    cin>>n;
    dp.resize(n+1,-1);
    h.resize(n+1,0);
    for (int i = 1; i <= n; i++)
    {
        cin>>h[i];
    }
    cout<<f(1)<<"\n";
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if(s=="RRR") {
   cout << "3" << endl;
  }else if(s=="RRS" || s=="SRR") {
   cout << "2" << endl; 
  } else if(s=="RSS" || s=="SRS" || s=="SSR" || s=="RSR") {
   cout << "1" << endl; 
  } else if(s=="SSS") {
   cout <<"0" <<endl; 
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n, t, a;
    cin >> n >> t >> a;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    
    int best = -1;
    long double score = 1e8; 
    rep(i, n) {
        long double z = t - h[i] * 0.006;
        if (score > abs(z - a)) {
            score = abs(z - a);
            best = i;
        }
    }
    put(best + 1);    
    return 0;
}

Measured memory_bytes: 3592
import sys
from collections import deque

n = int(input())
ary = deque([])

for line in sys.stdin:
    op = line.strip().split()
    cmd = op[0]

    if cmd == 'insert':
        x = op[1]
        ary.appendleft(x)

    elif cmd == 'delete':
        x = op[1]
        if x in ary:
            ary.remove(x)

    elif cmd == 'deleteLast':
        ary.pop()

    else:
        ary.popleft()

print(*ary)



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

int main(){
	int H,W,i,j,a,b;
	char x[H][W];
	
	while(1){
		cin>>H>>W;
		
		if(H==0 && W==0)
			break;

		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				/*if(i==0 && j==0){
					cout<<'#';
					x[i][j]='#';
				}
				if(x[i][j-1]=='#'){
					cout<<".";
					x[i][j]='.';
				}
				else if(x[i][j-1]=='.'){
					cout<<"#";
					x[i][j]='#';
				}
				else if(i>0 && x[i-1][0]=='#'){
					cout<<".";
					x[i][j]='.';
				}
				else if(i>0 && x[i-1][0]=='.'){
					cout<<"#";
					x[i][j]='#';
				}*/
				 if( (i+j) % 2 == 0)
				 	cout << "#";
                		 else
                		 	cout << ".";
			}
			cout<<endl;
		}
		cout<<endl;
	}
}
				
					
	

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;
  vector<string> s(n);
  REP(i, n)
    cin >> s[i];

  ll a,b,anb,ab;
  a = b = anb = ab = 0;
  REP(i, n){
    string t = s[i];
    ll k = t.size();
    REP(j, k-1){
      if(t[j] == 'A' && t[j+1]=='B')
        ab++;
    }
    if(t.front()=='B' && t.back()=='A')
      anb++;
    else if(t.back()=='A')
      a++;
    else if(t.front()=='B')
      b++;
  }

  ll ans = ab;
  if(anb==0)
    ans += min(a,b);
  else if(a==0 && b==0)
    ans += anb-1;
  else
    ans += anb+min(a,b);

  cout << ans << endl;
}


Measured memory_bytes: 768
#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: 3012
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
typedef long long ll;
using namespace std;

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

  int a[n+5];

  int b[n+5];
  for(int i=1;i<=n;i++){
      b[i] =0;
  }

  for(int i=1;i<n;i++){
      cin >> a[i];
      b[a[i]]++;
  }

  for(int i=1;i<=n;i++){
      cout << b[i] << endl;
  }

 

  




}

Measured memory_bytes: 5160
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>      // std::setprecision
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;
namespace bst = boost;
template<class T> void fill(T& v) { for (auto& i : v) cin >> i; }

int main() {
  long long A, B;

  cin >> A >> B;
  
  long long gc = gcd(A, B);
  long long r = 0, n = gc;
  
  for (long long i = 2; i * i <= gc; i++) {
    bool used = false;
    while (n % i == 0) {
      n /= i;
      used = true;
    }
    if (used) r++;
  }

  cout << r + (n > 1 ? 2 : 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

const int MAXN = 2e2 + 5;
const int MAXM = 1e7 + 5;

int N;
int a[MAXM];
vector <int> v[2];
vector <int> E[MAXN];
bool bio[MAXN];
int conn[MAXN];

void load() {
	scanf("%d", &N);
	while (N--) {
		int x;
		scanf("%d", &x);
		a[x] = 1;
	}
}

bool dfs(int x) {
	if (bio[x])
		return false;
	bio[x] = true;
	for (auto it : E[x])
		if (conn[it] == -1 || dfs(conn[it])) {
			conn[it] = x;
			return true;
		}
	return false;
}

bool prime(int x) {
	if (x == 1)
		return false;
	for (int i = 2; i * i <= x; i++)
		if (!(x % i))
			return false;
	return true;
}

int solve() {
	memset(conn, -1, sizeof conn);
	for (int i = MAXM - 1; i; i--) {
		a[i] ^= a[i - 1];
		if (a[i])
			v[i % 2].push_back(i);
	}
	
	for (int i = 0; i < v[0].size(); i++)
		for (int j = 0; j < v[1].size(); j++)
			if (prime(abs(v[0][i] - v[1][j]))) 
				E[i].push_back(j);
	
	int match = 0;
	for (int i = 0; i < v[0].size(); i++) {
		memset(bio, false, sizeof bio);
		match += dfs(i);
	}
	
	return v[0].size() + v[1].size() - match + (v[0].size() - match) % 2;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 39296
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<stdio.h>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
#define please return
constexpr auto AC = 0;
using namespace std;
 
int main() {
	int a, b;
	cin >> a >> b;
	cout << a - b + 1 << endl;
	please AC;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int n;
  cin>>n;
  long int a[n],b[n],c,x=10000000000;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    c=min(b[i],x);
    if(b[i]<=x)
      x=b[i];
  }
  for(int l=0;l<n;l++){
    if(b[l]==c)
      c+=a[l];
  }
  cout<<c<<endl;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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

int main() {
  int n;cin>>n;
  int ans=0;
  rep(i,n){
    ll a;cin>>a;
    while(a%2==0){
      a/=2;ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
import math
n = int(input())
a = list(map(int,input().split()))
r ,l = [0] * (n),[0] * (n)
l[0] = 0
r[n-1] = 0
for i in range(1,n):
    l[i] = math.gcd(l[i-1],a[i-1])
    r[n-i-1] = math.gcd(r[n-i],a[n-i])
m = [0] * n
for i in range(n):
    m[i] = math.gcd(l[i],r[i])
print(max(m))


Measured memory_bytes: 24476
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	int r = 0;
	for (int i = 0; i < N; ) {
		int j = i;
		while (j < N && A[j] == A[i]) ++ j;
		r += (j-i)/2;
		i = j;
	}
	cout << r << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int x,y,n;
	while(cin>>x>>y){
		if(x==0&&y==0){
			break;
			}
	if(x>y){
		n=x;
		x=y;
		y=n;
		}
	cout<<x<<" "<<y<<endl;
	}
	}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

int main()
{
	int x,y; cin >> x>>y;
	int a = ((4*x)-y)/2, b=(y-(2*x))/2;
	if(a >= 0 && b >= 0){
	if(a+b==x && 2*a+4*b==y) cout << "Yes\n";
	else cout<<"No\n";}
	else cout<<"No\n";
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

ll const mod=1e9+7;

ll modfact(ll na,ll nz){
    if(na==nz) return 1;
    else return na*modfact(na-1,nz)%mod;
}

ll modpow(ll a,ll n){
    if(n==0) return 1;
    else if(n==1) return a;
    else if(n%2) return a*modpow(a*a%mod,(n-1)/2)%mod;
    else return modpow(a*a%mod,n/2);
}

ll modcomb(ll n,ll k){
    return modfact(n,k)*modpow(modfact(n-k,0),mod-2)%mod;
}

int main(){
    ll s;
    cin>>s;
    ll quo=s/3,rem=s%3,ans=0;
    while(quo>0){
        ans+=modcomb(rem+quo-1,rem);
        ans%=mod;
        quo--;
        rem+=3;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Linq;
class c
{
  public static void Main()
  {
    int[] ab=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    int a=ab[0];
    int b=ab[1];
    if(a==b)Console.WriteLine("Draw");
    else if((a>b&&b!=1)||(a==1))Console.WriteLine("Alice");
    else Console.WriteLine("Bob");
  }
}


Measured memory_bytes: 11220
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

cnt=0
for i in range(n):
    if a[i]<b[i]:
        cnt+=(b[i]-a[i])//2
    else:
        cnt-=a[i]-b[i]

if cnt<0:
    print("No")
else:
    print("Yes")
    


Measured memory_bytes: 4600
//---------- Begin IO utilities ----------
// Thanks to https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let 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:tt : $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")
    };
}

#[allow(unused_macros)]
macro_rules! p {
    ($v:ident) => {
        println!("{}", $v);
    };
    ($v:ident, $($t:ident),*) => {
        print!("{}", $v);
        ($(print!(" {}", $t)),*);
        println!();
    }
}
#[allow(unused_macros)]
macro_rules! ps {
    ($v:ident) => {
        println!("{}", $v.iter().collect::<String>());
    };
    ($v:ident, $($t:ident),*) => {
        print!("{}", $v.iter().collect::<String>());
        ($(print!(" {}", $t.iter().collect::<String>())),*);
        println!();
    }
}
#[allow(dead_code)]
fn pv<T: std::string::ToString>(v: &[T], sep: &str) {
    let s = v.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep);
    println!("{}", s);
}
#[allow(dead_code)]
fn pvs(v: &[Vec<char>], sep:&str) {
    let s = v.iter().map(|e| e.iter().collect::<String>()).collect::<Vec<String>>().join(sep);
    println!("{}", s);
}
//---------- End IO utilities ----------

fn main() {
    input!{
        a: u8,
        b: u8,
        c: u8,
        d: u8,
    }
    let tk = (a + d - 1) / d;
    let dk = (c + b - 1) / b;
    if tk >= dk {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, m;
vector <int> a[MAXN];
bool vis[MAXN], ins[MAXN];
bool work(int pos, int fa) {
	vis[pos] = true;
	ins[pos] = true;
	bool ans = false;
	for (auto x : a[pos]) {
		if (x == fa) continue;
		if (!vis[x]) ans ^= work(x, pos);
		else if (ins[x]) {
			ans ^= true;
			printf("%d %d\n", pos, x);
		}
	}
	ins[pos] = false;
	if (fa == 0) return false;
	if (ans) {
		printf("%d %d\n", pos, fa);
		return false;
	} else {
		printf("%d %d\n", fa, pos);
		return true;
	}
}
int main() {
	read(n), read(m);
	for (int i = 1; i <= m; i++) {
		int x, y; read(x), read(y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	if (m & 1) {
		puts("-1");
		return 0;
	}
	work(1, 0);
	return 0;
}

Measured memory_bytes: 15616
def get_nums
  gets.split.map(&:to_i)
end

def init_matrix(row_num, row_length, default = nil)
  Array.new(row_num).map { Array.new(row_length, default) }
end


a, b  = get_nums

as = a.to_s * b
bs = b.to_s * a
if as < bs
  puts as
else
  puts bs
end

Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <set>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

int main() {
  int test;
  cin >> test;
  while (test--) {
    set<string> open;
    string str;
    cin >> str;
    FOREQ(i, 1, str.size() - 1) {
      string left, right;
      FOR(j, 0, i) { left += str[j]; }
      FOR(j, i, str.size()) { right += str[j]; }
      open.insert(left + right);
      open.insert(right + left);
      reverse(left.begin(), left.end());
      open.insert(left + right);
      open.insert(right + left);
      reverse(right.begin(), right.end());
      open.insert(left + right);
      open.insert(right + left);
      reverse(left.begin(), left.end());
      open.insert(left + right);
      open.insert(right + left);
    }
    cout << open.size() << endl;
  }
}

Measured memory_bytes: 996
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL K, A, B;
	cin >> K >> A >> B;

	if (A <= B) {
		if (K <= A) { O(1); }
		else { O(-1); }
	}
	else {
		LL nowR = A;
		LL plus2 = A - B;
		if (nowR >= K) {
			O(1);
		}
		else {
			// bit数が多いとceilがうまくいかないっぽい。入力例3で間違う。
			//LL nextPlus = ceil((K - nowR) / (double)plus2);
			LL nextPlus = ((K - nowR) + plus2-1) / plus2;
			O(nextPlus * 2 + 1);
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(void){
    ll n,k;cin>>n>>k;
    vector<ll> a(n);
    vector<ll> s,t;
    rep(i,n){
        cin>>a[i];
        if(a[i]>=0)s.push_back(a[i]);
        else t.push_back(a[i]);
    }
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    
    ll szs=s.size(),szt=t.size();
    bool jud=false;
    if(szs>0){
        if(n==k)jud=(szt%2==0);
        else jud=true;
    }else{
        jud=(k%2==0);
    }
    mint res=1;
    if(!jud){
        sort(a.begin(),a.end(),[](int x,int y){
            return abs(x) < abs(y);
        });
        rep(i,k) res*=a[i];
    }else{
        sort(s.begin(),s.end());
        sort(t.rbegin(),t.rend());
        if(k%2==1){
            res*=s.back();
            s.pop_back();
        }
        vector<ll> p;
        while(s.size()>=2){
            ll x=s.back();s.pop_back();
            x*=s.back();s.pop_back();
            p.push_back(x);
        }
        while(t.size()>=2){
            ll x=t.back();t.pop_back();
            x*=t.back();t.pop_back();
            p.push_back(x);
        }
        sort(p.rbegin(),p.rend());
        rep(i,k/2) res*=p[i];
    }
    cout<<res.x<<endl;
}

Measured memory_bytes: 8148
N = int(input())
x = input()
m = 0
sumy = 0
for i in range(N):
    sumx = 0
    a = []
    b = []
    c = []
    for j in range(N):
                
        if j<i:
            a.append(x[j])
        else:
            b.append(x[j])
    for k in range(len(b)):
        if any([l==b[k] for l in a]) and not any(b[k]==n for n in c):
            sumx+=1
            c.append(b[k])
    if sumy<sumx:
        sumy = sumx

print(sumy)

Measured memory_bytes: 44764
import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]

# エントリーポイント
def main():
    N = input(int)
    for a in range(1, 10):
        for b in range(1, 10):
            if a * b == N:
                print("Yes")
                exit()
    else:
        print("No")

    return

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3532
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


const ll mod = 1e9+7;
const double eps = 1e-9;


const int maxN=2e5+10,N=1e6+10;
int a[maxN];
int vis[N],cnt[N];
int n;

void solve(){
    cin>>n;
    for(int i=0;i<n;i++) {
        cin>>a[i];
        cnt[a[i]]++;
    }
    sort(a,a+n);
    for(int i=0;i<n;i++) {
        if(!vis[a[i]]) {
            for(int j=2*a[i];j<=a[n-1];j+=a[i])
                vis[j]=true;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++) {
        if(!vis[a[i]]&&cnt[a[i]]==1)ans++;
    }
    cout<<ans<<"\n";
}






int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 12072
#include <iostream>
#include<iomanip>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <queue>
#include <stack>
using namespace std;

const int NN=5e6+10;

int n,m,k;
int a,b,c;


int main()
{
    scanf("%d%d%d",&a,&b,&c);
    int flag=0;
    for(int i=1;i<1e2;i++){
        //printf("%d\n",(a*i)%b);
        if((a*i)%b==c){
            flag=1;
            break;
        }
    }
    if(flag==1){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}





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

indices = list()
for i in range(Q):
    l, r = map(int, input().split())
    indices.append((l - 1, r - 1))

# count[i]: count of "AC" from index 0 to index i
count = [0 for i in range(N)]
# index of C
for i in range(N - 1):
    if S[i:i+2] == 'AC':
        count[i+1] = count[i] + 1
    
    else:
        count[i+1] = count[i]

for beg, end in indices:
    if beg == 0:
        print(count[end])
    
    else:
        is_boundary = S[beg-1:beg+1] == 'AC'
        print(count[end] - count[beg - 1] - int(is_boundary))
    

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

int main()
{
  int s;
  cin >> s;
  if(s == 1 || s == 2){
    cout << 4 << endl;
    return 0;
  }
  int count = 2;
  while(s != 1){
    if(s % 2 == 1){
      s = s * 3 + 1;
    }
    else{
      s = s / 2;
    }
    count += 1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


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

  ll n, m;
  vector<ll> a(5, 0);
  cin >> n;
  cin >> a;


  ll ans = 0;

  vector<ll> b(5, 0);

  b[0] = ceil((double)n / (double)a[0]);


  if (a[1] >= a[0]) {//つまらない場合
    b[1] = b[0] + 1;
  } else { //つまる場合
    b[1] = 1 + ceil((double)n / (double)a[1]);
  }


  long mi = a[0];
  for (int i = 1; i < 5; i++) {
    // if (a[i] > a[i - 1]) {
    if (a[i] > mi) {
      b[i] = b[i - 1] + 1;
    } else {
      b[i] = i + ceil((double)n / (double)a[i]);
    }
    if (mi>a[i])mi = a[i];
  }





  cout << b[4];


  for (int i = 0; i < 5; ++i){
    cerr << b[i]<<endl;
  }


}




















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

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

	int N, X, T;
	cin >> N >> X >> T;

	if (N%X == 0) {
		cout << (N/X)*T << endl;
	} else {
		cout << (N/X + 1)*T << endl;
	}
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include<functional>
#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#include<vector>
#include<cmath>
#include<string>
#include<map>
using namespace std;
int main() {
	map<string, int>mp;
	int N;
	string s;
	long long int ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s;
		sort(s.begin(),s.end());
		mp[s]++;
	}
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		long int sum = itr->second;
		ans = ans + sum*(sum -1) / 2;
	}
	cout << ans;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> a(M,0);
    vector<ll> b(M,0);
    for(ll i=0;i<M;i++){
        cin>>a[i]>>b[i];
    ;}
    vector<ll> con(N+1,0);
    for(ll i=0;i<M;i++){
        if(a[i]==1){con[b[i]]=1;}
        if(b[i]==1){con[a[i]]=1;}
    ;}
    for(ll i=0;i<M;i++){
        if(a[i]==N&&con[b[i]]==1){cout<<"POSSIBLE"<<endl;return 0;}
        if(b[i]==N&&con[a[i]]==1){cout<<"POSSIBLE"<<endl;return 0;}
    ;}

    cout<<"IMPOSSIBLE"<<endl;

    return 0;
}


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

int main(){
    string S;
    cin >> S;
    rep(i,S.size()){
        S[i] = 'x';
    }
    cout<< S <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<ll, pl> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  //input
  ll D=365;
  //cin >> D;
  vl c(26);
  rep(i, 26) c[i]=1;//cin >> c[i];
  vvl s(D, vl(26));
  rep(i, D) rep(j, 26) s[i][j]=i+j;//cin >> s[i][j];
  
  rep(d, D/26) {
    vector<bool> column(26, 0), row(26, 0);
    vector<ppl> S;
    rep(i, 26) rep(j, 26) S.push_back(ppl (s[i][d*26+j], pl(i, j)));
    sort(all(S), greater<ppl>());
    ll num=0;
    rep(_, 1000) {
      ppl p=S[num];
      if(column[p.second.first] or row[p.second.second]) num++;
      else {
        cout << p.second.first+1 << newl;
        column[p.second.first]=1;
        row[p.second.second]=1;
      }
    }
  }
  rep(d, D%26) {
    cout << d+1 << newl;
  }
  
  return 0;
}


Measured memory_bytes: 3744
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m, i, sum = 0, ans = 0;		
		n = sc.nextInt();
		int t[] = new int[n];
		for(i = 0; i < n; i++){
			t[i] = sc.nextInt();
			sum += t[i];
		}
		m = sc.nextInt();
		for(i = 0; i < m; i++){
			ans = (sum - t[sc.nextInt() - 1]) + sc.nextInt();
			System.out.println(ans);
		}
	}
}


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

#define M 1046527
#define NIL -1
#define L 14

typedef long long ll;

char H[M][L];

int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  else return 0;
}

ll getKey(char str[]) {
  ll sum = 0,p = 1;
  for ( int i = 0; i < strlen(str); i++ ) {
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key) {
  return key % M;
}
int h2(int key) {
  return 1 + (key%(M-1));
}

int find(char str[]) {
  ll key,h;
  key = getKey(str);
  for ( int i = 0;; i++ ){
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h],str) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]) {
  ll key,h;
  key = getKey(str);
  for ( int i = 0;; i++ ) {
    h = (h1(key) + i * h2(key)) % M;
    if ( strcmp(H[h],str) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main() {
  int n;
  char str[L],com[9];
  for ( int i = 0; i < M; i++ ) H[i][0] = '\0';
  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> com >> str;

    if ( com[0] == 'i' ) {
      insert(str);
    } else {
      if ( find(str) ) {
	cout << "yes" << endl;
      } else {
	cout << "no" << endl;
      }
    }
  }
  return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;cin>>n;
  ll ans=0;
  int mae=0;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    ans+=(mae+a)/2;
    if(a==0)mae=0;
    else mae=(mae+a)%2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
/* #pragma GCC optimize("O3") */
/* #pragma GCC target ("avx2") */
/* #pragma GCC optimize("Ofast") */
/* #pragma GCC optimize("unroll-loops") */
/* #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T, typename cmp=less<T>>
using ordered_set=tree<T,null_type,cmp,rb_tree_tag,tree_order_statistics_node_update>;
template<typename K, typename V, typename cmp=less<K>>
using ordered_map=tree<K, V, cmp, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
using ll = long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax = 1000*1007;
#define ar array
#define len(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define tT template<typename T
#define tV typename V
#define ins inline string
#ifdef LOCAL
tT>ins to_string(T& t);
ins to_string(string s) {return '"' + s + '"';}
ins to_string(char c){string res="'";res.push_back(c);return res+"'";}
ins to_string(const char* s) {return to_string((string)s);}
ins to_string(char* s) {return to_string((string)s);}
template <size_t N>ins to_string(bitset<N> v) {string res="";for(size_t i = 0; i < N; i++){
res += static_cast<char>('0' + v[i]);}return res;}
ins to_string(bool b) {return (b ? "true" : "false");}
tT,tV>ins to_string(pair<T, V>& p){return "("+ to_string(p.first)+", "+to_string(p.second)+")";}
tT>ins to_string(T& v){string res="{";for(auto& i:v){res+=to_string(i)+',';} return res+'}';}
#define log(...) cerr<< "[" << #__VA_ARGS__ << " : "<< to_string(__VA_ARGS__) << "]"<<endl
#else
#define log(...) 0x30
#endif

inline void test_case(){
    int x,n;
    cin>>x>>n;
    vector<int> arr(n);
    for(int& i : arr) cin>>i;
    int min_up = 0;
    int min_down = 0;
    for(int i=x; ; i++){
        bool flag = false;
        auto it = find(all(arr), i);
        if(it==arr.end()){
            min_up = i;
            flag = true;
            break;

        }
        if(flag) break;
    }

    for(int i=x;i>=0 ; i--){
        bool flag = false;
        auto it = find(all(arr), i);
        if(it==arr.end()){
            min_down = i;
            flag = true;
            break;
        }
        if(flag) break;
    }
    if(abs(min_up - x) < abs(min_down - x)){
        cout<<min_up<<"\n";
    }
    else cout<<min_down<<'\n';
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    tt = 1;
    for(int qq=1; qq<=tt; qq++){
        /* cout<<"Case #"<<qq<<": "; */
        test_case();
    }
}   



Measured memory_bytes: 3620
s=gets.strip.split('')

groups = []
tmp = []
s.each do |c|
  if tmp.last==?L && c==?R
    groups << tmp
    tmp=[]
  end
  tmp << c
end
groups << tmp

result=[]
groups.each do |group|
  r, l = group.partition {|c| c==?R }
  border_count_r = r.length.odd? ? [r.length/2+1, r.length/2] : [r.length/2, r.length/2]
  border_count_l = l.length.odd? ? [l.length/2, l.length/2+1] : [l.length/2, l.length/2]
  border_count = border_count_r.zip(border_count_l).map {|arr| arr.inject(:+) }
  result.push([0]*(r.length-1))
  result.push(border_count)
  result.push([0]*(l.length-1))
end

puts result.flatten.join (' ')




Measured memory_bytes: 27388
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
int n,m;
signed main(){
	cin>>n>>m;
	if(min(n,m)==1){
		cout<<1<<endl;
		return 0;
	}
	cout<<(n*m+1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    map<ll,ll> m;
    rep(i,n-1){
        ll l;
        cin >> l;
        m[l-1]++;
    }
    rep(i,n){
        cout << m[i] << endl;
    }
    return 0;
}

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  set <int> alp[26];
  int n;
  cin >> n;
  char c, s[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    alp[s[i] - 'a'].insert(i);
  }
  int q, t, x, y;
  cin >> q;
  while (q--) {
    cin >> t >> x;
    if (t == 1) {
      cin >> c;
      alp[s[x - 1] - 'a'].erase(x - 1);
      alp[c - 'a'].insert(x - 1);
      s[x - 1] = c;
    } else {
      cin >> y;
      int ans = 0;
      for (int i = 0; i < 26; i++) {
        auto it = alp[i].lower_bound(x - 1);
        if (it != alp[i].end() && *it < y) ans++;
      }
      cout << ans << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 24320
d, g = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(d)]

ans = 1000
for i in range(1 << d):
  score = 0
  num = 0
  remain_max = -1
  for j in range(d):
    if i >> j & 1:
      score += p[j][0] * 100 * (j + 1) + p[j][1]
      num += p[j][0]
    else:
      remain_max = j
  if score < g:
    remain = 100 * (remain_max + 1)
    need = -(-(g - score) // remain)
    if need >= p[remain_max][0]:
      continue
    num += need
  ans = min(ans, num)
print(ans)


Measured memory_bytes: 3064
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

nh=zip([1,0,-1,0],[0,1,0,-1])

###########

n,a = ii()
x = ii()
ans=0

@memoize
def dp(i,b,c):
    if i<0:
        return 0
    elif b>i+1:
        return 0
    elif b==1:
        return x[0:i+1].count(c)
    else:
        return dp(i-1,b,c)+dp(i-1,b-1,c-x[i])
        
for j in range(n):
    ans+=dp(n-1,j+1,a*(j+1))

print ans


Measured memory_bytes: 43440
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iterator>

using namespace std;

int main()
{
    int N;
    scanf("%d", &N);
    vector<int> A;
    for(int i=0; i<N; i++){
        int a;
        scanf("%d", &a);
        A.push_back(a);
    }

    vector<int> B = A;
    sort(B.begin(), B.end());
    int m1 = B[B.size()/2 - 1];
    int m2 = B[B.size()/2];

    for(int i=0; i<N; i++){
        int m;
        if(A[i] <= m1) m = m2;
        else m = m1;
        printf("%d\n", m);
    }
    return 0;
}

Measured memory_bytes: 3828