akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int modpow(int a, int n){
    int ret = 1;
    while(n > 0){
        if(n & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }

    return ret;
}

signed main(){
    
    int n, m; cin >> n >> m;
    if(n == m){
        cout << 1 << endl;
        return 0;
    }
    int ans = modpow(2, n);
    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        int l = max(0LL, i - m);
        int r = i - 1;
        int add;
        if(l == 0) add = dp[r];
        else add = (dp[r] - dp[l - 1] + MOD) % MOD;
        dp[i] += add;
        dp[i] %= MOD;
        dp[i] += dp[i - 1];
        dp[i] %= MOD;
    }
    
    //for(int i = 0; i <= n; i++) cout << dp[i] << " ";
    //cout << endl;

    int sub = 0;
    for(int i = n - m + 1; i <= n; i++){
        //cout << i << endl;
        sub = (MOD + sub + (dp[i] - dp[i - 1])) % MOD;
        sub %= MOD;
    }
    //cout << sub << endl;
    cout << (ans - sub + MOD) % MOD << endl;

    return 0;
}



Measured memory_bytes: 3612
n = int(input())
a = list(map(int, input().split()))
ac = 0
ans1 = 0
for i in range(n):
    ac += a[i]
    if ac * (-1) ** i > 0:
        continue
    else:
        ans1 += abs(ac) + 1
        ac = (-1) ** i

ac = 0
ans2 = 0
for i in range(n):
    ac += a[i]
    if ac * (-1) ** i < 0:
        continue
    else:
        ans2 += abs(ac) + 1
        ac = (-1) ** (i + 1)

print(min(ans1, ans2))


Measured memory_bytes: 14212
using System;
using System.Collections.Generic;
using System.Linq;


class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var b = Console.ReadLine().Split(' ');

        var ret = 0L;
        for (var i = 0; i < n; i++)
        {
            if (i == 0)
            {
                ret += int.Parse(b[i]);
            }
            else if (i < n - 1)
            {
                ret += (int.Parse(b[i]) < int.Parse(b[i - 1])) ? int.Parse(b[i]) : int.Parse(b[i - 1]);
            }
            else
            {
                ret += int.Parse(b[i - 1]);
            }
        }

        Console.Write(ret);
    }
}


Measured memory_bytes: 11092
#include<iostream>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
const int maxn = 108576;
const int mod = 998244353;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    int ans = 1;
    cin >> s;
    f1(s.size() - 1) {
        if (s[i] != s[i - 1]) {
            ans++;
        }
    }
    cout << ans << '\n';

}

Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
        boolean[] isVisited = new boolean[n+1];
        isVisited[0] = true;
        for(int i = 0; i < m; i++) {
            int num1 = sc.nextInt();
            int num2 = sc.nextInt();

            if(map.containsKey(num1)) {
                map.get(num1).add(num2);
            } else {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(num2);
                map.put(num1, list);
            }

            if(map.containsKey(num2)) {
                map.get(num2).add(num1);
            } else {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(num1);
                map.put(num2, list);
            }

        }
        System.out.println(helper(map, isVisited, 1));
    }

    private static int helper(HashMap<Integer, ArrayList<Integer>> map, boolean[] isVisited, int current) {
        if(isVisited[current] || !map.containsKey(current)) return 0;
        isVisited[current] = true;
        if(check(isVisited)) {
            isVisited[current] = false;
            return 1;
        }
        ArrayList<Integer> list = map.get(current);
        int count = 0;
        for(int num: list) {
            count += helper(map, isVisited, num);
        }
        isVisited[current] = false;
        return count;
    }

    private static boolean check(boolean[] isVisited) {
        for(int i = 0; i < isVisited.length; i++) {
            if(!isVisited[i]) return false;
        }
        return true;
    }
}


Measured memory_bytes: 23764
import java.util.*;

public class Main {
    static char[][] board;
    static int r;
    static int c;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        r = sc.nextInt();
        c = sc.nextInt();
        board = new char[r + 2][c + 2];
        for (char[] b : board) {
            Arrays.fill(b, '#');
        }
        for (int i = 1; i <= r; i++) {
            String str = sc.next();
            for (int j = 1; j <= c; j++) {
                board[i][j] = str.charAt(j - 1);
            }
        }
        
        int count = 0;
        int[][] yokoline = new int[r + 2][c + 2];
        for (int i = 1; i <= r; i++) {
            for (int j = 0; j <= c + 1; j++) {
                if (board[i][j] == '#') {
                    if (count == 0) {
                        continue;
                    } else {
                        for (int k = j - 1; k >= j - count; k--) {
                            yokoline[i][k] = count;
                        }
                        count = 0;
                    }
                } else {
                    count++;
                }
            }
            // System.out.println(Arrays.toString(yokoline[i]));
        }

        count = 0;
        int[][] tateline = new int[r + 2][c + 2];
        for (int j = 1; j <= c; j++) {
            for (int i = 0; i <= r + 1; i++) {
                if (board[i][j] == '#') {
                    if (count == 0) {
                        continue;
                    } else {
                        for (int k = i - 1; k >= i - count; k--) {
                            tateline[k][j] = count;
                        }
                        count = 0;
                    }
                } else {
                    count++;
                }
            }
        }
        
        int max = 0;
        for (int i = 1; i <= r; i++) {
            for (int j = 1; j <= c; j++) {
                max = Math.max(yokoline[i][j] + tateline[i][j] - 1, max);
            }
        }
        
        System.out.println(max);
        
    }
    
    public static int check(int i, int j) {
        if (board[i][j] == '#') return 0;
        
        int count = 1;
        
        for (int x = i - 1; x >= 1; x--) {
            if (board[x][j] == '#') break;
            count++;
        }
        for (int x = i + 1; x <= r; x++) {
            if (board[x][j] == '#') break;
            count++;
        }
        for (int y = j - 1; y >= 1; y--) {
            if (board[i][y] == '#') break;
            count++;
        }
        for (int y = j + 1; y <= c; y++) {
            if (board[i][y] == '#') break;
            count++;
        }
        
        return count;
    }
}


Measured memory_bytes: 68844
#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
#define ff first
#define ss second

char s[1000010];

bool comp(ii a, ii b){
	return a.ss > b.ss;
}
int32_t main(){
	int n;
	scanf("%d", &n);
	vector<ii> v1, v2;
	for(int z=0; z<n; ++z){
		scanf("%s", s);
		int q = 0;
		int tam = int(strlen(s));
		int a=0, b=0;
		for(int i = 0; i<tam; ++i){
			if(s[i]==')'){
				if(q>0) --q;
				else ++b;
			}
			else ++q;
		}
		a = q;
		if(a>b) v1.emplace_back(a, b); 
		else v2.emplace_back(a, b); 
	}
	sort(v1.begin(), v1.end(), comp);
	sort(v2.begin(), v2.end());
	int q = 0;
	for(auto x:v2){
		int a = x.ff;
		int b = x.ss;
		if(a>q){
			printf("No\n");
			return 0;
		}
		q-=a;
		q+=b;
	}
	for(auto x:v1){
		int a = x.ff;
		int b = x.ss;
		if(a>q){
			printf("No\n");
			return 0;
		}
		q-=a;
		q+=b;
	}
	if(q==0)
		printf("Yes\n");
	else
		printf("No\n");
}


Measured memory_bytes: 11328
import Foundation
 
let array = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }

var answer = "No"
if array[0] == array[1] || array[0] == array[2] {
    if array[1] != array[2] {
    	answer = "Yes"
    }
}

if array[1] == array[2] {
    if array[0] != array[1] {
    	answer = "Yes"  
    }
}
print(answer)

Measured memory_bytes: 7780
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

   int H,W;
   int[][] c,A;

    private void solve() {
        H = nextInt();
        W = nextInt();
        c = new int[10][10];
        A = new int[H][W];

        for(int i = 0;i < 10;i++) {
            for(int j = 0;j < 10;j++) {
                c[i][j] = nextInt();
            }
        }

        for(int i = 0;i < 10;i++) {
            for(int j = 0;j < 10;j++) {
                for(int k = 0;k < 10;k++) {
                    c[j][k] = Math.min(c[j][k],c[j][i] + c[i][k]);
                }
            }
        }

        for(int i = 0;i < H;i++) {
            for(int j = 0;j < W;j++) {
                A[i][j] = nextInt();
            }
        }

        int ans = 0;

        for(int i = 0;i < H;i++) {
            for(int j = 0;j < W;j++) {
                if (A[i][j] == -1)continue;
                ans += c[A[i][j]][1];
            }
        }

        out.println(ans);

    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 27688
#include<bits/stdc++.h>
using namespace std;
const int N=2005,mo=1e9+7;
int n,m,i,j,k,g[N],z=1,zz=1,x,y,q[N],he,ta,ew[N],pre[N];
int gfa(int x){return g[x]==x?x:g[x]=gfa(g[x]);}
vector<pair<int,int>>te[N];
struct edge{
	int u,v,w;
	inline void in(){scanf("%d%d%d",&u,&v,&w);}
	inline bool operator<(const edge&rhs)const{return w<rhs.w;}
	inline bool tryuni(){
		x=gfa(u),y=gfa(v);if(x==y)return 0;g[x]=y;
		te[u].push_back(make_pair(v,w)),te[v].push_back(make_pair(u,w));return 1;
	}
}e[N];
long long X,su;
bool vi[N];
inline int bfs(int a,int b){
	memset(vi+1,0,n);q[he=0,ta=1]=a;vi[a]=1;
	for(;he<ta;)for(auto v:te[q[++he]])if(!vi[v.first])q[++ta]=v.first,
		vi[v.first]=1,ew[v.first]=v.second,pre[v.first]=q[he];
	int mx=0;for(;b!=a;b=pre[b])mx=max(mx,ew[b]);return mx;
}
int main(){
	scanf("%d%d%lld",&n,&m,&X);
	for(i=1;i<=n;++i)g[i]=i;for(i=1;i<=m;++i)e[i].in();sort(e+1,e+m+1);
	for(i=1;i<=m;){
		for(j=i;e[j].w==e[i].w;++j);
		for(k=i;k<j;++k)if(gfa(e[k].u)!=gfa(e[k].v))zz=zz*2%mo;else z=z*2%mo;
		for(;i<j;++i)if(e[i].tryuni())su+=e[i].w;
	}
	z=1ll*z*(zz-2)%mo;
	if(su>X)z=0;if(su>=X){printf("%d\n",z);return 0;}
	for(i=1;i<=m;++i)e[i].w-=bfs(e[i].u,e[i].v);
	sort(e+1,e+m+1);
	for(i=1;i<=m;++i)if(e[i].w+su==X){
		z=1;
		for(j=i;e[j].w==e[i].w;++j)z=2*z%mo;--z;
		for(;z=2*z%mo,j<=m;++j);printf("%d\n",z);return 0;
	}
	puts("0");
	return 0;
}

Measured memory_bytes: 512
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
using namespace std; 

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = c-a;
	int y = d - b;
	cout << c - y << " " << d + x << " " << a - y << " " << b + x << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

// index が条件を満たすかどうか
bool isOK(vector<int> & a, int index, int key) {
    if (a[index] < key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(vector<int> & a, int key) {
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(a, mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
  int n;
  cin >> n;
  vector<int> la(n);
  for (int i = 0; i < n; ++i) {
    cin >> la[i];
  }
  vector<int> lc;
  lc.push_back(la[0]);
  for (int i = 1; i < la.size(); ++i) {
    int key = la[i];
    int ret = binary_search(lc, key);
    if (ret == lc.size()) {
      lc.push_back(key);
    }
    else {
      lc[ret] = key;
    }
  }
  cout << lc.size() << endl;
}


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

int main(){
  string s,t;cin >> s >> t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  s<t?cout <<"Yes":cout <<"No";
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
U_MAP mp;
ll rui[ohara];
ll tatenow[ohara];
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;

    cnt=2;
    rui[0]=1;
    rrep(i,1,46){
        rui[i]=cnt;
        cnt*=2;
    }

    ll now=0;
    rep(i,n)cin>>a[i],now=(now xor a[i]);

    tmp=now;
    while(1){
        rrrep(i,45,0){
            if(rui[i]<=tmp){
                tmp-=rui[i];
                tatenow[i+1]++;
                break;
            }
        }
        if(tmp==0)break;
    }

    rep(i,n){
        tmp=(a[i] xor (a[i]-1));
        int ok=0;
        while(1){
            rrrep(i,45,0){
                if(rui[i]<=tmp){
                    tmp=i+1;
                    ok=1;
                    break;
                }
            }
            if(ok)break;
        }
        mp[tmp]=a[i];
    }
    ll guuki=0;
    rrrep(i,46,1){
        if((tatenow[i]==1&&guuki%2==0)||(tatenow[i]==0&&guuki%2==1)){
            if(mp[i]==0){
                Cout(-1);
                return 0;
            }
            guuki++;
            ans++;
        }
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 6400
def f(a, b):
    if a * b == 0:
        return 0
    res = f(min(a, b), max(a, b) % min(a, b)) + 2 * min(a, b) * (max(a,b)//min(a, b))
    if(max(a, b) % min(a, b) == 0):
        res -= min(a, b)
    return res

n, x = map(int, input().split())
res = n + f(n - x, x)
print(res)


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

int main(){
    int N;cin>>N;
    int count,res=0;
    cin>>count;
    res+=1;
    for(int i=0;i<N-1;i++){
        int p;
        cin>>p;
        if(p<=count){
            res+=1;
            count=p;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <iostream>
#define maxn 3009
using namespace std;
const int MOD = 1e9 + 7;
int n, m;
int f[maxn][maxn], g[maxn][maxn];
int sum[maxn];

void add(int &x, int y){
	x += y;
	if(x >= MOD)
		x -= MOD;
}
void init(){
	f[0][0] = g[0][0] = 1;
	for(int i = 0;i <= m; i++){
		for(int j = 0; j <= n; j++){
			if(j > 0)
				add(f[i + 1][j - 1], f[i][j]);
			if(j < n)
				add(f[i + 1][j + 1], f[i][j]);
			add(f[i + 1][j], f[i][j]);
			add(f[i + 1][j], f[i][j]);
		}
	}
	
	for(int i = 0; i <= m; i++){
		for(int j = 0; j <= n; j++){
			if(j > 1)
				add(g[i + 1][j - 1], g[i][j]);
			if(j < n)
				add(g[i + 1][j + 1], g[i][j]);
			if(j > 0) add(g[i + 1][j], g[i][j]);
			if(j > 0) add(g[i + 1][j], g[i][j]);
		}
	}
	
	for(int i = 0; i <= m; i++){
		for(int j = 0; j <= n; j++)
			add(sum[i], g[i][j]);
	}
	
}

int main(){
	scanf("%d%d", &n, &m);
	n--;
	m--;
	
	init();
	int ans = 0;
	for(int i = 0; i <= m; i++){
		for(int j = 0; j <= n; j++){
			int cur = 1LL * f[i][j] * sum[m - i] % MOD;
			//cout << i << " " << j << " " << " " << cur << " " << endl;
			add(ans ,cur);
		}
	}
	
	add(ans, ans);
	add(ans, ans);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 70912
/*=======================
Author    : Shounak Dey
Filename  : d.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}
#define PI 3.141592653589793238463

int main()
{
	fast_io;
	double a,b,x;
	cin >> a >> b >> x;
	double l;
	l = 2 * (a * a * b - x);
	l /= (a*a);
	double theta = atan(l/a) * 180 / PI;
	cout << setprecision(10) << fixed;
	if(l<=b){
		cout << theta << endl;
		return 0;
	}
	l = 2 * x / ( a * b );
	cout << atan(b/l) * 180 / PI << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

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

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

match_dict = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

dp = ["0"] * 10010

dp[0] = ""

def greater(x, y):
    if len(x) == len(y):
        return max(x, y)
    else:
        return x if len(x) > len(y) else y

for i in range(N):
    if dp[i] != "0":
        for num in A:
            dp[i+match_dict[num]] = greater(dp[i+match_dict[num]], dp[i]+str(num))

print(dp[N])

Measured memory_bytes: 135516
# import dice
class dice:
    def __init__(self):
        self.top = 1
        # self.srf = [[2,4,3,5],[6,4,3,1],[6,2,5,1],[6,5,2,1],[6,4,3,1],[5,4,3,2]]
        self.bottom = 2
        self.up = 5
        self.left = 4
        self.right = 3
        self.reverse = 6
    def move(self, dim):
        if dim == "N":
            temp = self.top
            self.top = self.bottom
            self.bottom = self.reverse
            self.reverse = self.up
            self.up = temp
        elif dim == "E":
            temp = self.top
            self.top = self.left
            self.left = self.reverse
            self.reverse = self.right
            self.right = temp
        elif dim == "W":
            temp = self.top
            self.top = self.right
            self.right = self.reverse
            self.reverse = self.left
            self.left = temp
        elif dim == "S":
            temp = self.top
            self.top = self.up
            self.up = self.reverse
            self.reverse = self.bottom
            self.bottom = temp

x = []
x = list(map(int, input().split()))
mv = []
mv = list(input())
dc = dice()

for i in range(len(mv)):
    dc.move(mv[i])
    
print(x[dc.top - 1])
    


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define INF 0x3fffffff
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
#define N 1005
int c[N][N];
int f[1<<12];
int a[N];
int b[N];
int d[N];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		a[i]=read(),b[i]=read();
		for(int j=1;j<=b[i];j++)
		{
			c[i][j]=read();
			d[i]|=(1<<(c[i][j]-1));
		}
	}
	int lim=1<<n;
	for(int i=1;i<lim;i++) f[i]=INF;
	for(int i=0;i<lim;i++)
	{
		if(f[i]!=INF)
		{
			for(int j=1;j<=m;j++)
			{
				if(f[i|d[j]]>f[i]+a[j])
				{
					f[i|d[j]]=f[i]+a[j];
				}
			}
		}
	}
	if(f[lim-1]==INF) cout<<"-1\n";
	else cout<<f[lim-1]<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



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

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

using namespace std;
using lint=long long;

struct interval{ int a,b; };

bool cmp_l(const interval &I,const interval &J){ return tie(I.a,I.b)<tie(J.a,J.b); }
bool cmp_r(const interval &I,const interval &J){ return tie(I.b,I.a)<tie(J.b,J.a); }

int main(){
	int n; scanf("%d",&n);
	vector<interval> I(n);
	rep(i,n) scanf("%d%d",&I[i].a,&I[i].b);

	lint ans=0;
	rep(_,2){
		multiset<interval,decltype(&cmp_l)> L(&cmp_l);
		multiset<interval,decltype(&cmp_r)> R(&cmp_r);
		for(auto J:I){
			L.emplace(J);
			R.emplace(J);
		}

		lint res=0;
		int x=0;
		while(1){
			bool ok=false;
			if(!L.empty()){
				auto J=*L.rbegin();
				if(x<J.a){
					res+=J.a-x;
					x=J.a;
					L.erase(L.find(J));
					R.erase(R.find(J));
					ok=true;
				}
			}
			if(!R.empty()){
				auto J=*R.begin();
				if(J.b<x){
					res+=x-J.b;
					x=J.b;
					L.erase(L.find(J));
					R.erase(R.find(J));
					ok=true;
				}
			}
			if(!ok) break;
		}
		res+=abs(x);

		ans=max(ans,res);
		rep(i,n){
			I[i].a*=-1;
			I[i].b*=-1;
			swap(I[i].a,I[i].b);
		}
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void) {
  int n;
  cin >> n;
  ll sum1 = 0, sum2 = 0, ans1 = 0, ans2 = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum1 += a;
    sum2 += a;
    if (i % 2 == 0) {
      if (sum1 <= 0) {
        ans1 += (1 - sum1);
        sum1 = 1;
      }
      if (sum2 >= 0) {
        ans2 += (sum2 + 1);
        sum2 = -1;
      }
    } else {
      if (sum2 <= 0) {
        ans2 += (1 - sum2);
        sum2 = 1;
      }
      if (sum1 >= 0) {
        ans1 += (sum1 + 1);
        sum1 = -1;
      }
    }
  }
  cout << min(ans1, ans2) << endl;
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 3e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}


vector<int>row(MAXN), col(MAXN);
vector<int>a(MAXN), b(MAXN);
set<int>row_pos[MAXN];

int main() 
{
    fastio();

    int h,w,m;
    cin>>h>>w>>m;

    set<pair<int,int>>st;
    for(int i=0;i<m;i++)
    {
        int r,c;
        cin>>r>>c;
        r--,c--;
        a[i] = r;
        b[i] = c;
        row[r]++;
        col[c]++;
        row_pos[r].insert(c);
        st.insert({r,c});
    }

    multiset<int>col_values;
    for(int i=0;i<w;i++)
    {
        col_values.insert(col[i]);
    }

    int ans = 0;
    for(int i=0;i<m;i++)
    {
        ans = max( ans, row[a[i]] + col[b[i]] - 1 );
    }

    for(int r=0;r<h;r++)
    {
        for( auto c : row_pos[r] )
            col_values.erase(col_values.find(col[c]));

        if( !col_values.empty() )
        {
            auto it = col_values.rbegin();
            int val = *it;
            ans = max( ans, row[r] + val );
        }

        for( auto c : row_pos[r] )
            col_values.insert(col[c]);
    }
    cout<<ans,nl;



    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 64164
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
#include<sstream>
using namespace std;
typedef long long ll;

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

ll LCM(ll a, ll b)
{
	return a / GCD(a, b) * b;
}

int main(){
	ll N;
	while(cin >> N, N)
	{
		ll d[10], v[10], gcdV = 0, lcmD = 1;
		for(int i = 0; i < N; i++)
		{
			cin >> d[i] >> v[i];
			ll gcd = GCD(d[i], v[i]);
			d[i] /= gcd;
			v[i] /= gcd;
			lcmD = LCM(lcmD, d[i]);
			gcdV = GCD(gcdV, v[i]);
		}
		for(int i = 0; i < N; i++)
		{
			printf("%lld\n", v[i] / gcdV * (lcmD / d[i]));
	}
	}
}

Measured memory_bytes: 1148
/* ***********************************************
Author        :axp
Created Time  :2017/1/22 20:49:32
TASK		  :C.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef long long ll;
const int inf = 1<<30;
const int md = 1e9+7;
const int N = 1e5+10;
int n;
ll mx[2];
ll ar[N];
int dp[2][N];
int sum[2][N];
int to[2][N];
int nxt[2][N];

int work(ll x)
{
	int l=1,r=n+1;
	while(l<r)
	{
		int mid=(l+r)/2;
		if(ar[mid]>=x)r=mid;
		else l=mid+1;
	}
	return l;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d",&n);
	scanf("%lld%lld",&mx[0],&mx[1]);
	for(int i=1;i<=n;i++)
		scanf("%lld",&ar[i]);
	ar[0]=-1e18-10;
	for(int i=n;i>=0;i--)
	{
		for(int j=0;j<2;j++)
		{
			nxt[j][i]=work(ar[i]+mx[j]);
			to[j][i]=i;
			if(ar[i+1]-ar[i]>=mx[j])to[j][i]=to[j][i+1];
		}
	}

	for(int i=n;i>=1;i--)
	{
		for(int j=0;j<2;j++)
		{
			int l=max(nxt[j^1][i-1],i+1);
			int r=to[j][i]+1;
			if(r>=l)dp[j][i]=(sum[1^j][l]-sum[1^j][r+1]+md)%md;
			if(r>n)dp[j][i]=(dp[j][i]+1)%md;
			sum[j][i]=(sum[j][i+1]+dp[j][i])%md;
			//cout<<j<<' '<<i<<' '<<l<<' '<<r<<' '<<dp[j][i]<<endl;
		}
	}
	int ans=(dp[0][1]+dp[1][1])%md;
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,L;
vector<ll> A;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N >> L;
    for (int i = 0; i < N; i++)
    {
        ll a; cin >> a; A.push_back(a);
    }
    
}
#define NO() do{cout << "Impossible" << endl; return 0;}while(false);
#define YES() do{cout << "Possible" << endl; }while(false);

int solve(){
    // vector<ll> B;
    bool ok = false;
    int idx=0;
    for (int i = 0; i < N-1; i++)
    {
        // B.push_back(A[i+1]+A[i]);
        if(A[i+1]+A[i]>=L) {
            ok=true;
            idx = i+1;
            }
    }
    if(!ok) NO()
    YES()
    int l=1,r=N-1;
    while(l<idx) {cout << l << endl; l++;}
    while(idx<r) {cout << r << endl; r--;}
    cout << idx << endl;

    
    return 0;
}   

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


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, k;
	cin>>n>>k;
	vector<int> a(n);
	for(auto &x : a){
		cin>>x;
	}
	int ans = 1e9;
	for(int i = 0; i + k <= n; i++){
		ans = min(ans, abs(a[i]) + a[i + k - 1] - a[i]);
		ans = min(ans, abs(a[i + k - 1]) + a[i + k - 1] - a[i]);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int d,t,s;
  	cin >> d>> t >> s;
  	int an = t*s;
  	if(an>=d)
    {
    	cout << "Yes" << endl;
    }
    else
    {
    	cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
//#include<bits/stdc++.h>
//using namespace std;
//#define ll long long
//const ll mod = 1e9 + 7;
//const int maxn = 1e5 + 10;
//ll dp[maxn][20];
//char s[maxn];
//ll qpow(ll a,ll b)
//{
//    ll ans = 1;
//    while (b)
//    {
//        if (b & 1) ans *= a;
//        b >>= 1;
//        a = a * a % mod;
//    }
//    return ans;
//}
//int main()
//{
//    ios::sync_with_stdio(false);
////    if (isdigit('3')) cout<<"dnwuisnds"<<endl;
//    scanf("%s",s + 1);
//    int len = strlen(s+1),num=0;
//    if(isdigit(s[len]))
//    {
//        dp[1][s[len]-'0'] = 1;
//        len--;
//    }
//    for (int i = len;i > 0;i --)
//    {
//        if (isdigit(s[i]))
//        {
//            int x = (s[i]-'0')* qpow(10,num);
//            for (int j = 0;j <= 12;j ++)
//                dp[len+1-i][(x+j)%13]=dp[len-i][j];
//        }
//        else
//        {
//            for (int j = 0;j < 10;j ++)
//            {
//                for (int k = 0;k <= 12;k ++)
//                    dp[len+1-i][(j*qpow(10,num)+k)%13] = (dp[len-i][k]+1)%mod;
//            ..}
//        }
//        num++;
////        cout<<s[i]<<endl;
//    }
//    cout<<dp[len][5]<<endl;
//    return 0;
//}
////??2??5
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 10;
ll dp[maxn][20];
char s[maxn];
ll qpow(ll a,ll b)
{
    ll ans = 1;
    while (b)
    {
        if (b & 1) ans *= a;
        b >>= 1;
        a = a * a % 13;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    memset(dp,0,sizeof(dp));
    scanf("%s",s+1);
    int len = strlen(s+1);
    for (int i = 1;i <= len/2;i ++)
        swap(s[i],s[len+1-i]);
    long long num = 0;
    dp[0][0] = 1;
    for (int i = 1;i <= len;i ++)
    {
        if (isdigit(s[i]))
        {
            for (int j = 0;j < 13;j ++)
                dp[i][((s[i]-'0')*qpow(10,num)+j)%13] = dp[i-1][j];
        }
        else
        {
            for (int j = 0;j < 10;j ++)
                for (int k = 0;k < 13;k ++)
                {
                    int x = (j*qpow(10,num)+k)%13;
                    dp[i][x] = (dp[i][x] + dp[i-1][k])%mod;
                }
        }
        num ++;
    }
    cout<<dp[len][5]<<endl;
    return 0;
}
//0   0
//100 9+
//200 5
//300 1
//400 10
//500 6
//600 2
//700 11
//800 7
//900 3


Measured memory_bytes: 16000
inp = input()
split_inp = inp.split()
n = int(split_inp[0])
l = int(split_inp[1])

total_number = 0
abs_min = -1
abs_l = 0
for i in range(l, l+n):
    # print(i)
    if abs_min == -1:
        abs_min = abs(i)
        abs_l = i
    elif abs(i) < abs_min:
        abs_min = abs(i)
        abs_l = i
    total_number += i
print(total_number - abs_l)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int sum;
    long long i,x,y;
    cin>>x>>y;
    i=x;
    while (i<=y)
    {
        sum++;
        i*=2;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

ll solve(multiset<pair<int, int>> sl, multiset<pair<int, int>> sr, int x) {
  int n = sl.size();
  ll ans = 0;
  int cur = 0;
  for (int i = 0; i < n; i++) {
    int l, r;
    if (i % 2 == x) {
      tie(l, r) = *sl.rbegin();
    } else {
      tie(r, l) = *sr.begin();
    }
    {
      auto itl = sl.find({l, r});
      assert(itl != sl.end());
      sl.erase(itl);
    }
    {
      auto itr = sr.find({r, l});
      assert(itr != sr.end());
      sr.erase(itr);
    }

    if (cur < l) {
      ans += l - cur;
      cur = l;
    }
    if (cur > r) {
      ans += cur - r;
      cur = r;
    }
  }
  return ans + abs(cur);
}

int main() {
#ifdef LOCAL
  freopen("c.in", "r", stdin);
  freopen("c.out", "w", stdout);
#endif

  int n;
  while (scanf("%d", &n) == 1) {
    multiset<pair<int, int>> sl;
    multiset<pair<int, int>> sr;

    for (int i = 0; i < n; i++) {
      int l, r;
      scanf("%d%d", &l, &r);
      sl.insert({l, r});
      sr.insert({r, l});

    }

    ll ans = max(solve(sl, sr, 1), solve(sl, sr, 0));
    printf("%lld\n", ans);
  }

  return 0;
}


Measured memory_bytes: 19072
#include<stdio.h>

int main()

{

  int a,b,r;
  char c;

  scanf ("%d %c %d",&a, &c, &b);
  switch(c)
  {
    case '+': r=a+b;
    printf("%d",r);
    break;

    case '-': r=a-b;
    printf("%d",r);
    break;

  }

  return 0;
}

Measured memory_bytes: 1712
n, m = map(int, input().split())
aas = set(list(map(int, input().split())))
a = [i//2 for i in aas]
import math
N = len(a)
def n_of_twos(x):
    res = 0
    while x%(2**(res+1))==0:
        res += 1
    return res
if N>=2:
    n_of_twos_0 = n_of_twos(a[0])
    for i in range(1,N):
        if n_of_twos(a[i]) != n_of_twos_0:
            print(0)
            exit()
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // math.gcd(ans, a[i])
if ans > m:
    print(0)
    exit()
print(1 + (m//ans-1)//2)

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

#define ll long long
#define mx  500005
#define mod 1000000009
#define lim 1000005
#define inf 2000000000
#define N 18
#define eps 100000
#define PI acos(-1)

using namespace std;

int gcd(int a,int b)
{
	while(a && b)
	{
		if(a>b)a%=b;
		else b%=a;
	}
	return (a+b);
}

int main(){
	int n,x;cin>>n>>x;
	vector<int>v;

	v.push_back(x);

	while(n--)
	{
		cin>>x;
		v.push_back(x);
	}

	sort(v.begin(),v.end());
	int ans=0;
	for(int i=1;i<v.size();i++)
			ans=gcd(ans,v[i]-v[i-1]);

	cout<<ans<<"\n";
  	return 0;
}



Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int N;
    cin >> N;
    int a,w,t,r;
    a = w = t = r = 0;
    rep(i,N){
        string S;
        cin >> S;
        if(S == "AC") a++;
        else if(S == "WA") w++;
        else if(S == "TLE") t++;
        else r++;
    }
    cout << "AC x " << a << "\n";
    cout << "WA x " << w << "\n";;
    cout << "TLE x " << t << "\n";;
    cout << "RE x " << r << "\n";;

}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    long long n,m,s=0;
    scanf("%lld%lld",&n,&m);
    if(m>=2*n)
    {
        s=s+n;
        m=m-2*n;
        s=s+m/4;

    }
    else
    {
        s=s+m/2;
    }
    printf("%lld",s);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    int og_n = n, sum = 0;
    while (n)
    {
        int temp = n % 10;
        sum += temp;
        n /= 10;
    }
    if (og_n % sum == 0)
        cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <vector>
using namespace std;

int main() {
	string s;cin >>s;
	vector<string> w{ "SUN","MON","TUE","WED","THU","FRI","SAT"};
	auto pos = find(w.begin(),w.end(),s);
	cout << distance(pos,w.end()) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
int main()
{
	int n,k,a=1;cin>>n>>k;
	REP(i,n)
	{
		if(a+k>a*2)
		{
			a=a*2;
		}
		else
		{
			a=a+k;
		}
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	ll a, b; cin >> a >> b;
	ll s = 100;
	char m[100][100];
	rep(i, 0, s) {
		rep(j, 0, s) {
			if (i < s / 2)	m[i][j] = '#';
			else m[i][j] = '.';
		}
	}

	a--; b--;
	rep(i, 0, s / 2) {
		rep(j, 0, s) {
			if (i & 1 && j & 1) {
				m[i][j] = '.';
				a--;
			}
			if (a == 0)break;
		}
		if (a == 0)break;
	}

	rep(i, s / 2 + 1, s) {
		rep(j, 0, s) {
			if (i & 1 && j & 1) {
				m[i][j] = '#';
				b--;
			}
			if (b == 0)break;
		}
		if (b == 0)break;
	}

	cout << s << " " << s << endl;
	rep(i, 0, s) {
		rep(j, 0, s) {
			cout << m[i][j];
		}
		cout << endl;
	}

	return 0;
}

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

using namespace std;

int main() {
  int a, b, c;
  scanf("%d %d %d", & a, & b, & c);
  if (c >= a && c <= b) printf("Yes\n");
  else if (c <= a && c >= b) printf("Yes\n");
  else printf("No\n");
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.*;

public class Main{
	static Scanner s=new Scanner(System.in);

	public static void main(String[]$){
		HashMap<Integer,Integer> o=new HashMap<>(),e=new HashMap<>();
		o.put(0,0);
		e.put(0,0);
		int n=s.nextInt();

		for(int i=0;i<n;++i)
			(i%2==0?e:o).merge(s.nextInt(),1,Integer::sum);

		Comparator<Entry<Integer,Integer>> c=Entry.comparingByValue();
		Entry<Integer,Integer> O=o.entrySet().stream().max(c).get();
		Entry<Integer,Integer> E=e.entrySet().stream().max(c).get();

		int r=O.getValue()+E.getValue();
		if(O.getKey().equals(E.getKey())){
			o.remove(O.getKey());
			e.remove(E.getKey());
			Entry<Integer,Integer> O2=o.entrySet().stream().max(c).get();
			Entry<Integer,Integer> E2=e.entrySet().stream().max(c).get();
			r=Math.max(
					O.getValue()+E2.getValue(),
					E.getValue()+O2.getValue());
		}
		System.out.println(n-r);
	}
}


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

int main(){
    int N, K, x, y;
    vector<int> h, gap, sum; 
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> x;
        h.push_back(x);
    }
    sort(h.begin(), h.end());
    for(int i = 0; i < N - 1; i++){
        gap.push_back(h[i + 1] - h[i]);
    }

    for(int i = 0; i < N - K + 1; i++){
        y = 0;
        for(int j = i; j < i + K - 1; j++){
            y += gap[j];
        }
        sum.push_back(y);
    }
    sort(sum.begin(), sum.end());
    cout << sum[0] << endl;

    return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

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

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

    long a;
    long b;
    long k;
    long resultOfA = 0;
    long resultOfB = 0;

    cin >> a >> b >> k;

    if (k == 0) {
        resultOfA = a;
        resultOfB = b;
    }
    else if (a >= k) {
        resultOfA = a - k;
        resultOfB = b;
    } else {
        resultOfA = 0;
        if (b >= (k - a)) {
            resultOfB = b - (k - a);
        } else {
            resultOfB = 0;
        }
    }

    cout << resultOfA << " " << resultOfB;

    return 0;
}


Measured memory_bytes: 888
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;

int main()
{

	ll i, j, k, l, m, flag, N, M, K, H, W, X, P, A, B, C;
	char S[100001];
	cin >> S;
	int num[3] = {};
	REP(i, 0, strlen(S)) {
		if (S[i] == 'a') {
			num[0]++;
		}
		if (S[i] == 'b') {
			num[1]++;
		}
		if (S[i] == 'c') {
			num[2]++;
		}
	}
	k = strlen(S);
	if (k % 3 == 0) {
		REP(i, 0, 3) {
			if (num[i] != k / 3) {
				output("NO");
				return 0;
			}
		}
	}
	else{
		REP(i, 0, 3) {
			if (num[i] < k / 3||num[i]>k/3+1) {
				output("NO");
				return 0;
			}
		}
	}

	output("YES");
	return 0;
}





Measured memory_bytes: 384