akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int r,g,b; cin >> r >> g >> b;
    cout << ((10*g+b)%4==0 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
y=input()
v = [y[i: i+2] for i in range(0, len(y), 2)]

a=''
b=''

if int(v[0])>=1 and int(v[0])<=12:
	a='YYorMM'
elif int(v[0])>=13 or int(v[0])==0:
	a='YY'
    
if int(v[1])>=1 and int(v[1])<=12:
	b='YYorMM'
elif int(v[1])>=13 or int(v[1])==0:
	b='YY'

result=''
if a=='YY' and b=='YYorMM':
	result="YYMM"
elif  a=='YY' and b=='YY':
	result="NA"
elif  a=='YYorMM' and b=='YY':
	result="MMYY"
elif  a=='YYorMM' and b=='YYorMM':
	result="AMBIGUOUS"
else:
	result="ERROR"
    
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
		
		int a[5];
		fx(5){
			cin>>a[x];
		}
		int k;
		cin>>k;
		fx(5){
			fyg(5,x+1){
				if(abs(a[x]-a[y])>k){
					ce(":(")
					return 0;
				}
			}
		}
		
		ce("Yay!")
	
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

	c := 1
	a := 26
	for i := 0; i < 20; i++ {
		if n < a {
			p(n, c)
			return
		}
		n -= a
		a *= 26
		c++
	}
}

func p(n, c int) {
	bs := []byte("abcdefghijklmnopqrstuvwxyz")
	ans := make([]byte, c)
	for i := range ans {
		a := n % 26
		ans[i] = bs[a]
		n -= a
		n /= 26
	}
	for i := len(ans) - 1; i >= 0; i-- {
		fmt.Print(string([]byte{ans[i]}))
	}
	fmt.Println()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1772
import java.math.*;
import java.util.*;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String a = sc.next();
		String b = sc.next();
		BigDecimal ba = new BigDecimal(a);
		BigDecimal bb = new BigDecimal(b);
		int c = ba.compareTo(bb);
		if (c>0) {
			System.out.println("GREATER");
		} else if (c<0) {
			System.out.println("LESS");
		} else {
			System.out.println("EQUAL");
		}
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n;
	int a,d;
	int m;
	cin>>n>>a>>d>>m;
	vvi in(m,vi(3));
	rep(i,m)rep(j,3)cin>>in[i][j];
	int k;
	cin>>k;
	for(int i = m-1 ; i >= 0 ; i --){
		if(!in[i][0]){ // swap;
			if(in[i][1] <= k && k <= in[i][2]){
					k = in[i][2] + in[i][1] - k;
			}
		}
	}
	int v = a + d * (k-1);
	
	rep(i,m){
		if(in[i][1] <= k && k <= in[i][2]){
			if(in[i][0]==0){
				k = in[i][1] + in[i][2] - k;
			}else if(in[i][0]==1){
				v ++;
			}else if(in[i][0]==2){
				v /= 2;
			}
		}
	}
	cout<<v<<endl;
	
	
}

Measured memory_bytes: 11232
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shuffle
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                String input = Console.ReadLine();
                if (input == "-") Environment.Exit(0);
                int count = int.Parse(Console.ReadLine());

                for (int i = 0; i < count; ++i)
                {
                    int n = int.Parse(Console.ReadLine());
                    input = input.Substring(n) + input.Substring(0, n);
                }
                Console.WriteLine(input);
            }
        }
    }
}


Measured memory_bytes: 8840
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map(String::toInt)
    var sum = 0
    var sum2 = 0
    var ave = a.average().toInt()
    for (i in 0 until n) {
        sum += Math.pow((a[i] - ave).toDouble(), 2.0).toInt()
        sum2 += Math.pow((a[i] - ave - 1).toDouble(), 2.0).toInt()
    }
    println(Math.min(sum,sum2))
}


Measured memory_bytes: 38008
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define REP(i,a,b) for(long long int i=a ; i<b ; i++)
#define mp make_pair
#define INF 1000000000000000000
#define mod 1000000007
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define vi vector<ll>
#define vd vector<ld>
#define vvi vector<vi>
#define vvd vector<vd>
#define vpi vector<pi>
#define vpd vector<pd>
#define us unordered_set<ll>
#define um unordered_map<ll,ll>
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<ll>())
#define all(a) a.begin(),a.end()
#define N 100005


#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define in insert
#define fbo find_by_order
#define ook order_of_key


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...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll powmod(ll x,ll y)
{
	if(x==0)
		return 0;
	if(y==0 || x==1)
		return 1;
	if(y%2==0)
		return powmod((x*x)%mod,y/2)%mod;
	return (x*powmod(x,y-1)%mod)%mod;
}
void print1D(vi a)
{
	for(ll i=0;i<a.size();++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
void print2D(vector<vi> a)
{
	for(ll i=0;i<a.size();++i)
	{
		for(ll j=0;j<a[i].size();++j)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}
void solve()
{
	ll h,w;
	cin>>h>>w;
	vector<string> a(h);
	for(ll i=0;i<h;++i)
	{
		cin>>a[i];
	}
	vvi dp(h,vi(w));
	for(ll i=0;i<h;++i)
	{
		if(a[i][0]=='#')
			break;
		dp[i][0]=1;
	}
	for(ll j=0;j<w;++j)
	{
		if(a[0][j]=='#')
			break;
		dp[0][j]=1;
	}
	for(ll i=1;i<h;++i)
	{
		for(ll j=1;j<w;++j)
		{
			if(a[i][j]=='#')
				dp[i][j]=0;
			else
			{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
			}
		}
	}
	cout<<dp[h-1][w-1]<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

bool from1[2505];
bool fromN[2505];
bool ok[2505];
vector<vl> G(2505);
vector<vl> rG(2505);



int main(){
    ll n; cin >> n;
    ll mx = 0;
    vl a(n);
    rep(i,n){
        cin >> a[i];
        mx = max(mx, a[i]);
    }
    ll ans2 = 0;
    rep(i,n){
        if(min(a[i],mx-a[i]) >= min(ans2,mx-ans2)){
            if(mx != a[i]) ans2 = a[i];
        }
    }
    cout << mx << " " << ans2 << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <map>
using namespace std;
typedef pair<int, int> P;
int main(void){
    long long h, w, n;
    cin >> h >> w >> n;
    map<P, int> m;
    int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
    int dy[9] = {0, 1, 0, -1, 1, -1, 1, -1, 0};
    for(int i=0; i<n; i++){
        int x, y;
        cin >> y >> x;
        y--;
        x--;
        for(int j=0; j<9; j++){
            int nx = x + dx[j];
            int ny = y + dy[j];
            if(nx >= 1 && nx <= w-2 && ny >= 1 && ny <= h-2){
                m[P(ny, nx)]++;
            }
        } 
    }
    long long ans[10];
    fill(ans, ans+10, 0);
    map<P, int>::iterator ite;
    for(ite = m.begin(); ite != m.end(); ite++){
        ans[ite->second]++;
    }
    long long sum=0;
    for(int i=1; i<10; i++){
        sum += ans[i];
    }
   
    ans[0] = (h-2)*(w-2) - sum;
    for(int i=0; i<10; i++){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 56448
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

//#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define sz(a) (int)(a.size())

const int MOD = (int)1e9 + 7;
const ll INF = 1e17;
const int MAXN = 1e4 + 100;
const int MLOG = 22; // ios_base :: sync_with_stdio(false);

vector <int> adj[MAXN];
int A[MAXN];

bool state_felakat(int v, int p = -1) {
	for(int u : adj[v]) 
		if(u != p) {
			if(A[u] >= A[v])
				continue;
			else
				if(state_felakat(u, v))
					return false;
		}
	return true;
}

signed main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> A[i];
	for(int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	for(int i = 0; i < n; i++)
		if(!state_felakat(i))
			cout << i + 1 << ' ';
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(){
  char s[11] = {'\0'};
  std::cin >> s;
  int vals[3];
  int count = 0;
  char* pt = strtok(s, "/");
  do{
    vals[count] = atoi(pt);
    count++;
    pt = strtok(NULL, "/");
  }while( pt != NULL );

  if( vals[1] <= 4 ){
    std::cout << "Heisei" << '\n';
  }else{
    std::cout << "TBD" << '\n';
  }
  return 0;
}


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

vector<string> myhash(10000000);

void set(string& a){
  int x = 0;
  for(int i=0; i<a.size(); i++){
    x *= 11;
    x += a[i];
    x %= 10000000;
  }

  while(true){
    if(myhash[x].empty()){
      myhash[x] = a;
      break;
    }
    else if(myhash[x].compare(a)==0){
      break;
    }
    else{
      x++;
      if(x > 10000000)
	x -= 10000000;
    }
  }
}

void find(string& a){
  int x = 0;
  for(int i=0; i<a.size(); i++){
    x *= 11;
    x += a[i];
    x %= 10000000;
  }

  while(true){
    if(myhash[x].compare(a) == 0){
      cout << "yes\n";
      break;
    }
    else if(myhash[x].empty()){
      cout << "no\n";
      break;
    }
    else{
      x++;
      if(x > 10000000)
	x -= 10000000;
    }
  }
}

int main(){
  string a, b;
  int n;
  cin >> n;
  while(n--){
    cin >> a >> b;
    if(a.compare("insert")==0)
      set(b);
    else
      find(b);
  }

  return 0;
}

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

int main(){
    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 1;i <= n;i++){
        if(i%3 == 0 || i%5 == 0) continue;
        sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333
#define Mo 998244353

using namespace std;
int i,j,m,n,p,k,bit[N],ath[N],A[N],P[N],sum[N],x[N],y[N],z[N],Now[N],Str[N];
int lowbit(int x)
{
	return x&-x;
}
//Find the xorsum of the position
void ins(int x,int y)
{
		for (;x<=n;x+=lowbit(x)) bit[x]^=1;
}
int Find(int x)
{
		int s=0;
		for (;x;x-=lowbit(x)) s^=bit[x];
		return s; 
} 
//Find the position
void Ins(int x,int y)
{
		for (;x<=n;x+=lowbit(x)) sum[x]+=y;
}
int ask(int x)
{
		int s=0;
		for (;x;x-=lowbit(x)) s+=sum[x];
		return s;
}
void Re()
{
		puts("No");
		exit(0);
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i) scanf("%d",&x[i]);
	for(i=1;i<=n;++i) scanf("%d",&y[i]);
	for(i=1;i<=n;++i) scanf("%d",&z[i]);
	for (i=1;i<=n;++i)
	{ 
			if (x[i]+1==y[i]&&y[i]+1==z[i]) A[i]=(x[i]+2)/3,P[i]=0;
			else if (x[i]==y[i]+1&&y[i]==z[i]+1) A[i]=(z[i]+2)/3,P[i]=1;
			else 
			{
					puts("No");
					return 0;
			}
	}
	for (i=1;i<=n;++i) if ((A[i]&1)!=(i&1)) { puts("No"); return 0; }
	for (i=1;i<=n;i+=2)
	{
			int nowpos=A[i]+(ask(n)-ask(A[i]))*2;
			Now[i]=Find(A[i])^(((nowpos-i)/2)&1); 
			ath[i]^=1; ath[nowpos]^=1;
			ins(1,1);
			ins(A[i]+1,1);
			Ins(A[i],1);
	}
	for (i=1;i<=n;++i)
	{
			ath[i]^=ath[i-1];
			if (i%2==0) Str[i]=ath[i]; 
	}
	memset(ath,0,sizeof(ath));
	memset(bit,0,sizeof(bit));
	memset(sum,0,sizeof(sum));
	for (i=2;i<=n;i+=2)
	{
			int nowpos=A[i]+(ask(n)-ask(A[i]))*2;
			Now[i]=Find(A[i])^(((nowpos-i)/2)&1)^Str[A[i]];
			ath[i]^=1; ath[nowpos]^=1;
			ins(1,1);
			ins(A[i]+1,1);
			Ins(A[i],1);
	}
	for (i=1;i<=n;++i)
	{
			ath[i]^=ath[i-1];
			if (i&1) Now[i]^=ath[i];
	}
	int s=0;
	for (i=1;i<=n;i+=2) s^=(Now[i]^P[i]);
	if (s&1) Re();
	s=0;
	for (i=2;i<=n;i+=2) s^=(Now[i]^P[i]);
	if (s&1) Re();
	puts("Yes"); 
}


Measured memory_bytes: 4096
use std::collections::HashSet;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($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: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 exe(s: &str) -> String {
    let s: HashSet<char> = s.chars().collect();
    if s.len() > 1 {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}

fn main() {
    input! {
        s: String,
    }
    let ans = exe(&s);
    println!("{}", ans);
}


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

int N, M;
vector<vector<int>> G;
using P = pair<int, int>;
vector<P> ans;
vector<int> deg;
vector<int> depth;

void dfs(int cur, int pre) {
    for(auto to : G[cur]) {
        if(depth[to] == -1) {
            depth[to] = depth[cur] + 1;
            dfs(to, cur);
        } else {
            if(depth[to] > depth[cur]) {
                ans.emplace_back(cur, to);
                deg[cur]++;
            }
        }
    }
    if(pre != -1) {
        if(deg[cur] % 2) {
            ans.emplace_back(cur, pre);
            deg[cur]++;
        } else {
            ans.emplace_back(pre, cur);
            deg[pre]++;
        }
    }
}

bool solve() {
    cin >> N >> M;
    G.resize(N);
    deg.resize(N);
    depth.assign(N, -1);
    rep(i, 0, M) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].push_back(b); G[b].push_back(a);
    }
    if(M % 2) return 0;
    depth[0] = 0;
    dfs(0, -1);
    return 1;
}

int main() {
    if(solve()) {
        for(auto p : ans) cout << p.first + 1 << " " << p.second + 1 << "\n";
    } else {
        cout << -1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 14836
n,k=map(int,input().split())
d=list(map(int,input().split()))
for i in range(1,100001):
    if i<n:
        continue
    num=str(i)
    ok=True
    for nn in num:
        if int(nn) in d:
            ok=False
            break
    if ok:
        print(i)
        exit(0)




Measured memory_bytes: 40924
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>

using namespace std;

typedef long long ll;

int main(void){
    string s,ans;
    cin >> s;
    string s1,s2;
    s1 = s.substr(0,2);
    s2 = s.substr(2,4);
    ll s1_n = atoi(s1.c_str());
    ll s2_n = atoi(s2.c_str());
    bool yymm = false;
    bool mmyy = false;
    if(s1_n >= 0 && s1_n <= 99 && s2_n > 0 && s2_n < 13){
        yymm = true;
    }
    if(s2_n >= 0 && s2_n <= 99 && s1_n > 0 && s1_n < 13){
        mmyy = true;
    }
    if(mmyy && yymm){
        ans = "AMBIGUOUS";
    }
    if(mmyy && !yymm){
        ans = "MMYY";
    }
    if(!mmyy && yymm){
        ans = "YYMM";
    }
    if(!mmyy && !yymm){
        ans = "NA";
    }
    cout << ans << endl;
    return 0;
}


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

int n,m;
pair<int,int>p[100003];

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		p[i]=pair<int,int>(b-2,a-1);
	}
	sort(p+1,p+1+m);
	int l=0;
	int ans=0;
	for (int i=1;i<=m;i++){
		if (l<=p[i].second){
			l=p[i].first+1;
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    int n;
    cin >> n;
    n %= 10;
    if(n == 2 || n == 4 || n == 5|| n == 7|| n == 9) {
        cout << "hon" << endl;
    } else if(n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

typedef long long ll;

int main(){
    string s;
    int a,b,c;
    while(cin >> s && s!="#"){
        cin >> a >> b >> c;
        int x = 400*a+40*b+c;
        if(x>=400*31+40*5+1){
            s = "?";
            a-=30;
        }
        cout << s << " " << a << " " << b << " " << c << endl;
    }
    return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define ll long long
#define eps 1e-8
#define INF 0x3f3f3f3f
#define pb push_back
#define endl '\n'
#define IO ios::sync_with_stdio(false)
using namespace std;
const ll maxn = 1e6 + 5;
ll book[maxn],n,w[maxn];
int main(){
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++)
        cin >> w[i],book[w[i]]++;
    for(int i = 1; i <= n; i++)
        ans += book[i] * (book[i] - 1) / 2;
    for(int i = 1; i <= n; i++){
        ll res = ans;
        if(book[w[i]])
            res -= book[w[i]] - 1;
        cout << res << endl;
    }
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    vector<string> S(N + 1);
    cout << 0 << endl;
    string str;
    cin >> str;
    if (str == "Vacant") return 0;
    S[0] = str;
    S[N] = str;
    int left = 0;
    int right = N;
    while (true) {
        int mid = (right + left) / 2;
        cout << mid << endl;
        cin >> str;
        if (str == "Vacant") return 0;
        S[mid] = str;
        if ((mid - left) % 2 == 0) {
            if (S[left] == S[mid]) left = mid;
            else right = mid;
        } else {
            if (S[left] != S[mid]) left = mid;
            else right = mid;
        }
    }
    return 0;
}


Measured memory_bytes: 1620
#define _USE_MATH_DEFINES
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    ll s = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 == 0 || i % 5 == 0)
            continue;
        s += i;
    }

    OP(s);
    return 0;
}

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

int main(void) {
    int n;
    cin >> n;
    vector<int> v(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] - c[i] > 0) {
            ans += v[i] - c[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
for(var i=0;i<Arr.length;i++){
   if(Arr[i]==="-")break;
   var str=Arr[i];
   var next=Arr[i+1]-0;
   for(var j=0;j<next;j++){
      var num=Arr[i+2+j]-0;
      str=str.slice(num)+str.slice(0,num);
   }
   i=i+next+1;
   console.log(str);
}

Measured memory_bytes: 7648
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}
int main(){
    char x,y;
    cin>>x>>y;

    string ans;

    if(x-y>0){
        ans='>';
    }else if(y-x>0){
        ans='<';
    }else{
        ans='=';
    }
    
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_f
price1 = (n * 100 / 108).ceil
price2 = (n * 100 / 108).floor
if (price1.to_f * 1.08).to_i == n.to_i
  puts price1
elsif (price2.to_f * 1.08).to_i == n.to_i
  puts price2
else
  puts ':('
end

Measured memory_bytes: 1788
#include<stdio.h>

int main(){
    int N;
    int M;
    int A[100000];
    int a;
    scanf("%d %d",&N ,&M);
    int i;
    for(i=0; i<M;i++){
        scanf("%d", &A[i]);
    }
    a=0;
    for(i=0; i<M;i++){
    a=a+A[i];
    }
    if(a<=N){
        printf("%d",N-a);
    }else{
        printf("-1");
    }
}

Measured memory_bytes: 1752
#include <stdio.h>

int main()
{
    int inputN, inputA;
    scanf("%d", &inputN);
    int intArray[100];

    for (int i = 0; i < inputN; i++)
    {
        scanf("%d", &inputA);
        intArray[i] = inputA;
    }

    for (int i = 0; i < inputN; i++)
    {
        if (intArray[i] % 2 == 0)
        {
            if (intArray[i] % 5 == 0)
            {
                continue;
            }
            else if (intArray[i] % 3 == 0)
            {
                continue;
            }
            else
            {
                printf("DENIED \n");
                return 0;
            }
        }
    }
    printf("APPROVED \n");

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

		// Nの値をK新法で割ったあまりが各桁の値となる
		int cnt = 0;
		do{
			n /= k;
			cnt++;
		}while(n!=0);
		System.out.println(cnt);
	}
}


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

int T[2];
long long A[2],B[2];

int main(){
	cin >> T[0] >> T[1] >> A[0] >> A[1] >> B[0] >> B[1];

	if(A[0] < B[0]){
		long long tmp = A[0];
		A[0] = B[0];
		B[0] = tmp;
		tmp = A[1];
		A[1] = B[1];
		B[1] = tmp;
	}
	// A[0] > B[0];

	long long da = T[0] * A[0] + T[1] * A[1];
	long long db = T[0] * B[0] + T[1] * B[1];

	if(da == db){
		cout << "infinity" << endl;
		return 0;
	}
	else if(da > db){
		cout << "0" << endl;
		return 0;
	}
	else if(A[1] > B[1]){
		cout << "0" << endl;
		return 0;
	}

	long long da2 = T[0] * A[0];
	long long db2 = T[0] * B[0];
	
	long long int n = (da2 - db2) / (db - da) + 1;
	long long int ans = n * 2;
	if((n-1)*da + da2 == (n-1)*db + db2){
		ans--;
	}
	ans--; // first set

	cout << ans << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

vector<string> split(string base, char spl){
  vector<string> result;
  string::size_type pos = 0;
  string::size_type bef = 0;
  base += spl;
  while( (pos = base.find_first_of(spl,bef)) != string::npos ){
    result.push_back(base.substr(bef,pos-bef));
    bef = pos+1;
  }
  return result;
}

int toint(string s){
  return atoi(s.c_str());
}

// year : 2013 ~ 2413 ( 1e7 )
// month : 12
// day : 31
int maya_to_ad[150000];
map<int,int> ad_to_maya;
int span;

bool is_uruu(int y){
  return (y%4==0 && (y%100!=0 || y%400==0));
}

int daylist[12] = {31,28,31,30,31,30,31,31,30,31,30,31};

void calc(){
  int y = 2012;
  int m = 12;
  int d = 21;
  REP(i,150000){
    int id = ((y*12)+(m-1))*31+(d-1);
    maya_to_ad[i] = id;
    ad_to_maya[id] = i;
    if(y==2412 && m==12 && d==21) span = i;
    ++d;
    if(d > daylist[m-1]){
      if(m==2 && is_uruu(y) && d==29){
        // do nothing
      }else if(m==12){
        // next year
        ++y;
        m=1;
        d=1;
      }else{
        // next month
        ++m;
        d=1;
      }
    }
  }
}

int main(){
  // mae shori
  // 400 years
  calc();
  // input
  while(true){
    string s;
    cin>>s;
    if(s=="#")break;
    vector<string> input = split(s,'.');
    if(input.size()==3){
      // year.month.day
      int year = toint(input[0]);
      int month = toint(input[1]);
      int day = toint(input[2]);
      int yeardown = (year-2013)/400;
      year -= yeardown * 400;
      int id = ((year*12)+(month-1))*31+(day-1);
      // over flow
      ll maya = ad_to_maya[id];
      maya += (ll)yeardown * (ll)span;
      maya %= 1872000;
      int ki = maya%20; maya/=20;
      int w = maya%18;  maya/=18;
      int t = maya%20;  maya/=20;
      int ka = maya%20; maya/=20;
      int b = maya;
      printf("%d.%d.%d.%d.%d\n",b,ka,t,w,ki);
    }else{
      // b.ka.t.w.ki
      int b = toint(input[0]);
      int ka = toint(input[1]);
      int t = toint(input[2]);
      int w = toint(input[3]);
      int ki = toint(input[4]);
      int id = ((((b*20)+ka)*20+t)*18+w)*20+ki;
      int yearadd = id/span;
      id %= span;
      int ad = maya_to_ad[id];
      int day = 1+ad%31;    ad/=31;
      int month = 1+ad%12;  ad/=12;
      int year = ad + yearadd*400;
      printf("%d.%d.%d\n",year,month,day);
    }
  }
  return 0;
}

Measured memory_bytes: 8824
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int memo[100];
int dp(int now,int sum,int ans);
int n,x,a[100];

int main(){
  fill(memo,memo+100,-1);
  scanf("%d %d",&n,&x);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  sort(a,a+n);
  printf("%d\n",dp(0,0,0));
		  
    
  return 0;
}

int dp(int now,int sum,int ans){
  if(now==n){
    if(sum<x) return ans-1;
    else return ans;
  }
  if(memo[now]!=-1) return ans;
  if(sum+a[now]>x) return ans;
  return memo[now]=max(dp(now+1,sum,ans),dp(now+1,sum+a[now],ans+1));
}


Measured memory_bytes: 256
import math

n = int(input())

p1 = [0.0, 0.0]
p2 = [100.0, 0.0]

def rad(r) :
    return math.radians(r)

def sin(s) :
    return math.sin(s)
    
def cos(s) :
    return math.cos(s)

def Koch(n, p1, p2) :
    if n == 0 :
        return 0
    else :
        s = [0, 0]
        t = [0, 0]
        u = [0, 0]
        
        s[0] = (p2[0] - p1[0]) / 3 + p1[0]
        s[1] = (p2[1] - p1[1]) / 3 + p1[1]
        t[0] = (p2[0] - p1[0]) / 3 * 2 + p1[0]
        t[1] = (p2[1] - p1[1]) / 3 * 2 + p1[1]
        
        u[0] = (t[0] - s[0]) * cos(rad(60)) - (t[1] - s[1]) * sin(rad(60)) + s[0]
        u[1] = (t[0] - s[0]) * sin(rad(60)) + (t[1] - s[1]) * cos(rad(60)) + s[1]
        
        Koch(n - 1, p1, s)
        pri(s[0], s[1])
        
        Koch(n - 1, s, u)
        pri(u[0], u[1])
        
        Koch(n - 1, u, t)
        pri(t[0], t[1])
        
        Koch(n - 1, t, p2)
        
def pri(x, y) :
    print(f"{x:.8f} {y:.8f}")
    
print(p1[0], p1[1])
Koch(n, p1, p2)
print(p2[0], p2[1])
        


Measured memory_bytes: 5780
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;
typedef long long ll;

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

	int l;
	int i = 0,j=0;
	string S, T;
	string ANS;

	cin >> l >> S >> T;
	ANS = S + T;
	for (i = 0; i < l;i++)
	{
		
		ANS[j] = S[i];
		ANS[j + 1] = T[i];
		j = j + 2;
	}

	cout << ANS << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    l = sorted(list(map(int, input().split())), reverse=True)

    ans = 0
    for i in range(0, N*2, 2):
        ans += min(l[i], l[i+1])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int k = scanner.nextInt();
        Collection<Integer>[] friendships = new ArrayList[n];
        Collection<Integer>[] blockships = new HashSet[n];
        for (int i = 0; i < n; i++) {
            friendships[i] = new ArrayList<>();
            blockships[i] = new HashSet<>();
        }
        for (int i = 0; i < m; i++) {
            int a = scanner.nextInt()-1;
            int b = scanner.nextInt()-1;
            friendships[a].add(b);
            friendships[b].add(a);
        }
        for (int i = 0; i < k; i++) {
            int a = scanner.nextInt()-1;
            int b = scanner.nextInt()-1;
            blockships[a].add(b);
            blockships[b].add(a);
        }
        int[] result = getNumberOfProposedFriends(friendships, blockships);
        StringBuilder sb = new StringBuilder();
        sb.append(result[0]);
        for (int i = 1; i < n; i++) {
            sb.append(" ").append(result[i]);
        }
        System.out.println(sb.toString());
    }

    public static int[] getNumberOfProposedFriends(Collection<Integer>[] friendships, Collection<Integer>[] blockships){
        int n = friendships.length;
        int[] result = new int[n];
        boolean[] marked = new boolean[n];
        for (int i = 0; i < n; i++) {
            if(marked[i]) continue;
            if(friendships[i].isEmpty()){
                 result[i]=0;
                 continue;
            }
            List<Integer> processingQueue = new ArrayList<>();
            processingQueue.add(i);
            HashSet<Integer> nodesOfConnectedComponent = new HashSet<>();
            nodesOfConnectedComponent.add(i);
            for (int j = 0; j < processingQueue.size(); j++) {
                Integer node = processingQueue.get(j);
                if(marked[node]) continue;
                marked[node]=true;
                if(nodesOfConnectedComponent.addAll(friendships[node])){
                    processingQueue.addAll(friendships[node]);
                }
            }
            int size = nodesOfConnectedComponent.size()-1;
            nodesOfConnectedComponent.forEach(node->{
                Collection<Integer> blockship = blockships[node];
                result[node] = (int)(size - friendships[node].size()- blockship.stream().filter(nodesOfConnectedComponent::contains).count());
            });
        }
        return result;
    }
}

Measured memory_bytes: 198648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }

int main() {
    int n;
	cin >> n;
    
    float ans = 2 * 3.14159265 * n;
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3788
#include <stdio.h>

int main(void)
{
    int i, pts = 0;
    char x[3];
    scanf("%s", x);
    for (i = 0; i < 3; i++) if (x[i] == 'o') pts++;
    printf ("%d\n", 700 + (100 * pts));
    return (0);
}


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

template <typename T> bool chmax(T &a, const T b){if(a < b){a = b;return true;}return false;}
template <typename T> bool chmin(T &a, const T b){if(a > b){a = b;return true;}return false;}
#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j,l,p;
    ll r,c,k;
    cin >> r >> c >> k;
    vector<vector<ll>> item(r,vector<ll>(c,0));
    vector<vector<vector<ll>>> dp(r,vector<vector<ll>>(c,vector<ll>(4,0)));
    for(i = 0;i < k;++i){
        ll rr,cc,vv;
        cin >> rr >> cc >> vv;
        --rr;   --cc;
        item.at(rr).at(cc) = vv;
    }
    dp.at(0).at(0).at(0) = 0;
    dp.at(0).at(0).at(1) = item.at(0).at(0);
    ll dx[2] = {-1, 0};
    ll dy[2] = {0, -1};
    for(i = 0;i < r;++i){
        rep(j,c){
            rep(l,2){
                ll ii = i + dx[l];
                ll jj = j + dy[l];
                if(ii < 0 || jj < 0) continue;
                if(l == 1){
                    for(p = 0;p < 4;++p){
                        chmax(dp.at(i).at(j).at(p), dp.at(ii).at(jj).at(p));
                        if(p) chmax(dp.at(i).at(j).at(p), dp.at(ii).at(jj).at(p-1) + item.at(i).at(j));
                    }
                }else{
                    for(p = 0;p < 4;++p){
                        chmax(dp.at(i).at(j).at(0), dp.at(ii).at(jj).at(p)); 
                        chmax(dp.at(i).at(j).at(1), dp.at(ii).at(jj).at(p) + item.at(i).at(j));
                    }
                }
            }
        }
    }
    ll ans = 0;
    rep(i,4){
        chmax(ans, dp.at(r-1).at(c-1).at(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 706528
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#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)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

typedef db T;
const db eps = 1e-8;
int sgn(T x){return (x>eps)-(x<-eps);}
struct P{
    T x,y;
    P(){} P(T x,T y):x(x),y(y){}
    void read(){scanf("%lf%lf",&x,&y);}
    P operator - (const P&b) const {return P(x-b.x,y-b.y);}
    P operator + (const P&b) const {return P(x+b.x,y+b.y);}
    T operator * (const P&b) const {return x*b.x+y*b.y;}
    P operator * (const T&k) const {return P(x*k,y*k);}
    P operator / (const T&k) const {return P(x/k,y/k);}
    T operator ^ (const P&b) const {return x*b.y-y*b.x;}
    bool operator < (const P&b) const {return sgn(x-b.x)?x<b.x:y<b.y;}
    bool operator == (const P&b) const{return !sgn(x-b.x)&&!sgn(y-b.y);}
    P rot90() {return P(-y,x);}
};
T norm(P x){return x*x;}
T abs(P x){return sqrt(x*x);}
db rad(P p1,P p2){
    return atan2l(p1^p2,p1*p2);
}
struct L{
    P s,t;
    L(){} L(P s,P t):s(s),t(t){}
};
struct C{
    P o;T r;
    C(){} C(P o,T r):o(o),r(r){}
    void read(){o.read();scanf("%lf",&r);}
};
vector<P> insCL(C c,L a){
    db x = (a.s-c.o)*(a.t-a.s) , y = norm(a.t-a.s);
    db d = x * x - y * (norm(a.s-c.o) - c.r*c.r);
    vector<P> res;
    if(sgn(d) < 0) return res;
    d = max(d,0.);
    P mid = a.s - (a.t - a.s) * (x / y);
    P del = (a.t - a.s) * (sqrt(d) / y);
    return {mid - del,mid + del}; // dir : a.s -> a.t
}
db areaCT(db r,P s,P t) { // need divide 2
    vector<P> p = insCL(C(P(0,0),r),L(s,t));
    if(!sz(p)) return r*r*rad(s,t);
    bool b1 = sgn(norm(s)-r*r) == 1 , b2 = sgn(norm(t)-r*r) == 1;
    if(b1 && b2) {
        if(sgn((s-p[0])*(t-p[0])) <= 0 && sgn((s-p[1])*(t-p[1])) <= 0)
            return r*r*(rad(s,p[0]) + rad(p[1],t)) + (p[0]^p[1]);
        else return r*r*rad(s,t);
    } else if(b1) return r*r*rad(s,p[0])+(p[0]^t);
    else if(b2) return r*r*rad(p[1],t)+(s^p[1]);
    return (s^t);
}

int main(){
    int n;db r;
    scanf("%d%lf",&n,&r);
    vector<P> ps(n);
    rep(i,0,n) ps[i].read();
    db ans=0;
    rep(i,0,n) ans += areaCT(r , ps[i] , ps[(i + 1) % n]);
    ans /= 2;
    printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 3268
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
const int N=1e5+10;
int n,m,a,b,ans;
int main()
{
	int i,j,k;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d%d",&a,&b);
		ans+=b-a+1;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define N 100009
using namespace std;

int n,a[N],b[N]; ll m;
int main(){
	scanf("%lld%d",&m,&n);
	int i;
	for (i=1; i<=n; i++){
		scanf("%d",&a[i]); b[i]=a[i]-a[i-1];
		if (i&1) b[i]=-b[i];
	}
	int cas; scanf("%d",&cas);
	ll l=0,r=m,x=0,y=m,tg=0,u,v; i=1;
	while (cas--){
		scanf("%lld%lld",&u,&v);
		for (; i<=n && u>=a[i]; i++){
			tg+=b[i]; x+=b[i]; y+=b[i];
			x=min(m,max(0ll,x));
			y=min(m,max(0ll,y));
			r=min(r,m-tg); l=max(l,-tg);
		}
		if (l<=v && v<=r) v+=tg;
		else v=v<l?x:y;
		if (i&1) v-=u-a[i-1]; else v+=u-a[i-1];
		printf("%lld\n",min(m,max(0ll,v)));
	}
	return 0;
}


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

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

    long long ans = 0;
    for (int i=1; i<N; i++)
    {
        if (A[i]<A[i-1])
        {
            //cout << "hey" << endl;
            ans += A[i-1] - A[i];
            A[i] = A[i-1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4776
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
struct node
{
	int x,y,next;
}a[400010];int len,last[200010];
inline void ins(int x,int y)
{
	len++;
	a[len].x=x;a[len].y=y;
	a[len].next=last[x];last[x]=len;
}
int dep[200010],ans[200010];
int top[2],sta[2][200010];
inline void dfs(int x,int fa)
{
	int ul=dep[x]&1;
	sta[ul][++top[ul]]=x;
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		if(y==fa)continue;
		dep[y]=dep[x]+1;
		dfs(y,x);
	}
}
int u[3];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read();
    for(int i=1;i<n;i++)
    {
    	int x=read(),y=read();
    	ins(x,y),ins(y,x);
    }dfs(1,0);
    u[1]=1,u[2]=2,u[0]=3;
    if(top[0]>top[1])swap(sta[0],sta[1]),swap(top[0],top[1]);
    if(top[0]<=n/3)
    {
    	for(int i=1;i<=top[0];i++)ans[sta[0][i]]=u[0],u[0]+=3;
    	for(int i=1;i<=top[1];i++)
    	{
    		if(u[0]<=n)ans[sta[1][i]]=u[0],u[0]+=3;
    		else if(u[1]<=n)ans[sta[1][i]]=u[1],u[1]+=3;
    		else if(u[2]<=n)ans[sta[1][i]]=u[2],u[2]+=3;
    	}
    }
    else 
    {
    	for(int i=1;i<=top[0];i++)
		{
    		if(u[1]<=n)ans[sta[0][i]]=u[1],u[1]+=3;
    		else if(u[0]<=n)ans[sta[0][i]]=u[0],u[0]+=3;
    	}
    	for(int i=1;i<=top[1];i++)
    	{
    		if(u[2]<=n)ans[sta[1][i]]=u[2],u[2]+=3;
    		else if(u[0]<=n)ans[sta[1][i]]=u[0],u[0]+=3;
    	}
    }
    for(int i=1;i<=n;i++)pr1(ans[i]);
    puts("");
    return 0;
}


Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

bool isPrime(int n) {
	for(int i = 2; i * i <= n; i++) {
		if(n % i == 0) return false;
	}
	return true;
}

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

	vector<int> ps;
	for(int i = 2; i <= 1500000; i++) {
		if(isPrime(i)) ps.push_back(i);
	}

	int n;
	while(cin >> n, n) {
		for(int i = 0; i < ps.size(); i++) {
			if(ps[i] <= n && n < ps[i + 1]) {
				if(ps[i] == n) {
					cout << 0 << endl;
				}
				else {
					cout << ps[i + 1] - ps[i] << endl;
				}
				break;
			}
		}
	}
}

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

int main()
{
  ll N,K;cin>>N>>K;
  vector<ll> A(N+1);
  map<ll,ll> m;
  for (ll i=1;i<=N;i++)
  {
    cin>>A[i];
    m[A[i]]++;
  }
  //cout<<K-(m.size())<<endl;
  ll msize=m.size();

  if( K - msize > 0)
  {
    //cout<<K - msize<<endl;
    cout<<0<<endl;
    return (0);
  }
  
  vector<ll> g;
  for (auto i=m.begin();i!=m.end();i++)
  {
    //cout<<"m["<<i->first<<"]="<<i->second<<endl;
    g.push_back(i->second);
  }
  
  sort(g.begin(),g.end());
  
  //for (ll i=0;i<g.size();i++)
    //cout<<"g["<<i<<"]="<<g[i]<<endl;
  
  ll count=0;
  for (ll i=0;i<m.size()-K;i++)
  {
    count += g[i]; 
  }
  
  cout<<count<<endl;
}

Measured memory_bytes: 16500