akhauriyash/Code-Regression huggingface dataset:
// 2012/02/23 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;

	int DP[101][3];
	for(int i=0; i<=N; i++)
		for(int j=0; j<3; j++)
			DP[i][j] = 0;

	for(int i=0; i<K; i++){
		int A, B;
		cin >> A >> B;

		if(B==1)
			DP[A][1] = DP[A][2] = -1;
		else if(B==2)
			DP[A][0] = DP[A][2] = -1;
		else if(B==3)
			DP[A][0] = DP[A][1] = -1;
	}

	DP[0][0] = DP[0][1] = DP[0][2] = 0;
	for(int j=0; j<3; j++)
		if(DP[1][j]!=-1)
			DP[1][j] = 1;

	for(int j=0; j<3; j++){
		int sum = 0;
		for(int k=0; k<3; k++)
			if(DP[1][k]!=-1)
				sum++;

		if(DP[2][j]!=-1)
			DP[2][j] = sum;
	}

	for(int i=3; i<=N; i++){
		int sum = 0;
		for(int j=0; j<3; j++)
			if(DP[i-1][j]!=-1)
				sum += DP[i-1][j];

		for(int j=0; j<3; j++){
			if(DP[i][j]==-1)
				continue;

			int sub = 0;
			if(DP[i-1][j]!=-1){
				sub = DP[i-1][j]+20000;

				for(int k=0; k<3; k++){
					if(j==k)
						continue;

					if(DP[i-2][k]!=-1)
						sub -= DP[i-2][k];
				}

				sub %= 10000;
			}

			DP[i][j] = (sum+10000-sub)%10000;
		}
	}

//	for(int i=0; i<=N; i++)
//		cout << DP[i][0] << ' ' << DP[i][1] << ' ' << DP[i][2] << endl;

	int sum2 = 0;
	for(int j=0; j<3; j++)
		if(DP[N][j]!=-1)
			sum2 += DP[N][j];

	cout << sum2%10000 << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  
  for(int i = 0; i < w + 2; i++){
    cout << "#";
  }
  cout << endl;
  
  for(int i = 0; i < h; i++){
    string s;
    cin >> s;
    cout << "#" << s << "#" << endl;
  }
  
  for(int i = 0; i < w + 2; i++){
    cout << "#";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
// Code for E - Count Median
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;

  cin >> N;

  vector<int> A(N);
  vector<int> B(N);

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    cin >> B.at(i);
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  int n = N - 1;

  if (N % 2 != 0) {
    cout << B.at((n + 1) / 2) - A.at((n + 1) / 2) + 1 << endl;
  } else {
    map<float, bool> m;
    int min1 = A.at(n / 2);
    int max1 = B.at(n / 2);

    int min2 = A.at(n / 2 + 1);
    int max2 = B.at(n / 2 + 1);

    cout << (max1 - min1 + 1) + (max2 - min2 + 1) - 1 << endl;
  }

	return 0;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N = 1e5 + 5;
#define int long long int
 
int32_t main() {
    IOS ;
    string a, b ; cin >> a >> b ; 
    int n = a.length(), m = b.length() ; 
    int dp[n+1][m+1] ; 

    for(int i=0; i<=n; i++) 
    for(int j=0; j<=m; j++)
    if(i == 0 or j == 0) dp[i][j] = 0 ;  
    else if(a[i-1] == b[j-1]) dp[i][j] = 1 + dp[i-1][j-1] ; 
    else dp[i][j] = max(dp[i-1][j], dp[i][j-1]) ;

    vector<char> v ; int i = n, j = m ;
    while(i and j) {
        if(dp[i][j] != dp[i][j-1]) {
            if(a[i-1]==b[j-1]) v.push_back(b[j-1]), j-- ;   
            i-- ; 
        } 
        else j-- ;
    }
    for(i=v.size()-1; i>=0; i--) cout << v[i] ;

    return 0 ;
}


Measured memory_bytes: 74004
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void _run(){
    int x;
    cin>>x;
    int ans = 800*x-x/15*200;
    cout<<ans<<endl;
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int t=1;
    // scanf("%d",&t);
    while(t--)_run();
    
    return 0;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp(a, b) make_pair(a, b)
#define pb push_back

const long long MOD = 1000000007;

ll v[200100];

vector<ll> g[200100];
ll begin_[200100*2];
ll end_[200100*2];
ll k=0;
vector<ll> euler_tour;

void dfs(ll x, ll p){
    begin_[x] = k;
    euler_tour.pb(x);
    k++;
    for(ll i = 0; i < g[x].size(); i++){
        if(g[x][i] != p){
            dfs(g[x][i], x);
            euler_tour.pb(x);
            k++;
        }
    }
    end_[x]=k;
}

struct SegTree{
    ll sum[(1<<19)*2];
    ll lazy[(1<<19)*2];
    void lazy_evaluate(int i, int l, int r){
        sum[i] += lazy[i] * (r - l);
        if(i < (1 << 19) - 1)
        {
            lazy[2 * i + 1]+=lazy[i];
            lazy[2 * i + 2]+=lazy[i];
        }
        lazy[i]=0;
    }
    void update(int a, int b, int i, int l, int r, int x)
    {
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b)
        {
            lazy[i]+=x;
            lazy_evaluate(i, l, r);
        }
        else
        {
            lazy_evaluate(i, l, r);
            update(a, b, i * 2 + 1, l, (l + r) / 2, x);
            update(a, b, i * 2 + 2, (l + r) / 2, r, x);
            sum[i] = sum[i * 2 + 1] + sum[i * 2 + 2];
            return;
        }
    }
    int query(int a, int b, int i, int l, int r)
    {
        lazy_evaluate(i, l, r);
        if(r<=a||b<=l)return 0;
        if(a<=l&&r<=b)return sum[i];
        else
        {
            int lch = query(a, b, i * 2 + 1, l, (l + r) / 2);
            int rch = query(a, b, i * 2 + 2, (l + r) / 2, r);
            return lch+rch;
        }
    }
    void update(ll a,ll b,int x){update(a,b,0,0,1<<19,x);}
    int query(ll a,ll b){return query(a,b,0,0,1<<19);}
};

SegTree tree;

int main(){
    ll n, q;
    cin >> n >> q;
    ll a, b;
    rep(i, n-1){
        cin >> a >> b;
        a--;
        b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(0, -1);

//    debug("dfs");

    rep(i, n){
        tree.update(begin_[i], begin_[i]+1, 0);
    }

    ll p, x;
    rep(i, q){
        cin >> p >> x;
//        debug(p);
        p--;
        tree.update(begin_[p], end_[p], x);
    }

//    debug("update");

    rep(i, n){
        cout << tree.query(begin_[i], begin_[i]+1) << " ";
    }
    
    return 0;
}


Measured memory_bytes: 49776
#include <iostream>

using namespace std;

int table[5001][5001];
int main() {
    int N;
    cin >> N;
    char S[5001];
    cin >> S;


    for (int diff=1; diff<N; diff++) {
        for (int i2=N-1; i2>=0; i2--) {
            int i1 = i2 - diff;
            if (i1 < 0) break;
            if (S[i1] == S[i2]) {
                if (i2 == N-1) {
                    table[i1][i2] = 1;
                } else {
                    table[i1][i2] = min(i2-i1, 1+table[i1+1][i2+1]);
                }
            }
        }
    }

    int ans = 0;
    int a1 = -1;
    int a2 = -1;
    for (int i=0; i<N; i++) {
        for (int j=i+1; j<N; j++) {
            if (ans < table[i][j]) {
                ans = table[i][j];
                a1 = i;
                a2 = j;
            }
        }
    }
    cout << ans << endl;
    //cerr << a1 << " " << a2 << endl;
    return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> v;
    vector<int> memo;
    rep(i,H) {
        vector<char> vSub(W);
        bool frag = false;
        rep(j, W) {
            cin >> vSub.at(j);
            if (vSub.at(j) == '#'){
                frag = true;
                memo.push_back(j);
            }
        }
        if (frag) {
            v.push_back(vSub);
        }
    }
    sort(memo.begin(), memo.end());
    vector<int> tmp;
    tmp.push_back(memo.at(0));
    rep(i, memo.size()) {
        if (memo.at(i) != tmp.at(tmp.size() - 1)) {
            tmp.push_back(memo.at(i));
        }
    }
    rep(i, v.size()) {
        rep(j, tmp.size()) {
            cout << v.at(i).at(tmp.at(j));
        }
        cout << endl;
    }
    
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <tuple>
#include <map>
using namespace std;

int N, dp[109][1024], mod = 1000000007;

bool hantei2(string S) {
	for (int i = 0; i < (int)S.size() - 2; i++) {
		if (S.substr(i, 3) == "AGC") return true;
	}
	return false;
}

bool hantei(string S) {
	if (hantei2(S) == true) return false;
	for (int i = 0; i < S.size(); i++) {
		string T = S;
		swap(T[i], T[i + 1]);
		if (hantei2(T) == true) return false;
	}
	return true;
}

bool check(int pos, int t) {
	int cp[6] = { 1, 4, 16, 64, 256 };

	string S1 = "", S2 = "AGCT";
	for (int i = 0; i < 5; i++) {
		int p = (t / cp[i]) % 4;
		if (i >= 5 - pos) S1 += S2[p];
	}
	if (hantei(S1) == false) return false;
	return true;
}

int main() {
	cin >> N;
	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 1024; j++) {
			if (dp[i][j] == 0) continue;
			for (int k = 0; k < 4; k++) {
				int t = (j / 4) + k * 256;
				if (check(i + 1, t) == false) continue;
				dp[i + 1][t] += dp[i][j];
				dp[i + 1][t] %= mod;
			}
		}
	}

	int sum = 0;
	for (int i = 0; i < 1024; i++) { sum += dp[N][i]; sum %= mod; }
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	
	cin>>n;
	int v[21];
	int c[21];
	int ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>c[i];
	}
	for(int i=0;i<n;i++)
	{
		if(v[i]>c[i])
		{
			ans=ans+v[i]-c[i];
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3596
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int a,b;
    cin >> a >> b;

    if(a <= 5)P(0);
    else if(a <= 12)P(b/2);
    else P(b);
    return  0;
}


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

int main() {
  int n;
  cin >> n;
  vector<string> ss(n);
  for (auto &&s : ss) {
    cin >> s;
  }
  
  for (auto &&s : ss) {
    sort(s.begin(), s.end());
  }
  
  map<string, int64_t> mp;
  
  int64_t ans = 0;
  
  for (auto &&s : ss) {
    ans += mp[s]++;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main() {
	int A,B,sum;
  cin >> A >> B;
  for(int i=A;i<=B;i++){
    int a,b,d,e;
    a=i/10000;
    b=(i-10000*a)/1000;
    d=(i%100)/10;
    e=i%10;
    if(a==e&&b==d){
    	sum++;
    }
  }
  cout << sum;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

int n,k,m,c[310][310],dp[310][310],s[310][310];

inline void add(int &x,int y)
{
	x+=y;
	if(x>=m) x-=m;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k>>m;
	for(int i=0;i<=n+1;i++) c[i][0]=1;
	for(int i=1;i<=n+1;i++){
		for(int j=1;j<=n+1;j++){
			c[i][j]=c[i-1][j-1];
			add(c[i][j],c[i-1][j]);
		}
	}
	for(int i=0;i<=k;i++) dp[1][i]=1;
	for(int i=k;i>=0;i--) s[1][i]=s[1][i+1]+dp[1][i];
	for(int i=2;i<=n+1;i++){
		for(int j=1;j<i;j++){
			for(int l=k;l>=0;l--){
				add(dp[i][l],(((dp[i-j][l]*s[j][l+1])%m)*c[i-2][j-1])%m);
			}
		}
		for(int l=k;l>=0;l--){
			s[i][l]=s[i][l+1];
			add(s[i][l],dp[i][l]);
		}
	}
	cout<<dp[n+1][0]<<endl;
	return 0;
}

Measured memory_bytes: 5828
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] a = nextIntArray(sc, N);

		sc.close();

		long ans = Long.MAX_VALUE;

		for (int bit = 0; bit < (1 << N); bit++) {
			if (Integer.bitCount(bit) != K || (bit&1)!=1) {
				continue;
			}

			long t = a[0];
			long c = 0;
			for (int j = 1; j < N; j++) {
				if (((bit >> j) & 1) == 1) {
					c += Math.max( (t + 1) - a[j], 0);
					t = Math.max(t + 1, a[j]);
				} else {
					t = Math.max(t, a[j]);
				}
			}

			ans = Math.min(ans, c);
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 21844
/*Obada*/
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int N , M ;
    cin >> N >> M ;

    if (N >=1 && N <= 100 && M >= 0 && M <= N)

        cout << (N == M ? "Yes" : "No") ;

    return 0;


}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var sqrtN = (int)Math.Sqrt(N);

        var result = new int[N + 1];
        for (int i = 1; i <= sqrtN; i++)
        {
            for (int j = 1; j <= sqrtN; j++)
            {
                for (int k = 1; k <= sqrtN; k++)
                {
                    var v = i * i + j * j + k * k + i * j + j * k + k * i;
                    if (v <= N)
                    {
                        result[v]++;
                    }
                }
            }
        }
        for (int i = 1; i < result.Length; i++)
        {
            Console.WriteLine(result[i]);
        }
    }
}

Measured memory_bytes: 27496
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string S;
    cin >> S;
    cout << (S == "ABC" ? "ARC" : "ABC" ) << endl;
    return 0;
};


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >>a[i];
	int even = 0 ;
	int odd = 0 ;
	rep(i,n){
		if(a[i] % 2) odd ++ ;
		else even ++ ;
	}
	int minus = pow(2,even);
	ll ans = pow(3,n) - minus ;
	cout << ans << endl;
}


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

using namespace std;
int main (){

   string s;
   int c=0;
   cin >>s ;
   cout << s.at(0);
   for (int i=1 ; i<(s.size())-1;i++)
    {
        c++;
    }
    cout <<c<< s[s.size()-1];

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

ll BASE_NUM = 1000000007;

void warshall_floyd(int n, vector<vector<ll>> &d)
{
    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main()
{
    // 整数の入力
    ll H, W;
    cin >> H >> W;
    vector<string> map;
    for (int i = 0; i < H; i++)
    {
        string s;
        cin >> s;
        map.push_back(s);
    }

    vector<vector<ll>> D(H * W, vector<ll>(H * W, BASE_NUM));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (map[i][j] == '.')
            {
                D[W * i + j][W * i + j] = 0;
            }
        }
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (map[i][j] == '.')
            {
                if (i > 0)
                {
                    if (map[i - 1][j] == '.')
                    {
                        D[W * (i - 1) + j][W * i + j] = 1;
                    }
                }

                if (i < H - 1)
                {
                    if (map[i + 1][j] == '.')
                    {
                        D[W * (i + 1) + j][W * i + j] = 1;
                    }
                }

                if (j > 0)
                {
                    if (map[i][j - 1] == '.')
                    {
                        D[W * i + j - 1][W * i + j] = 1;
                    }
                }

                if (j < W - 1)
                {
                    if (map[i][j + 1] == '.')
                    {
                        D[W * i + j + 1][W * i + j] = 1;
                    }
                }
            }
        }
    }

    warshall_floyd(H * W, D);
    ll max_d = 0;
    for (int i = 0; i < H * W; i++)
    {
        for (int j = 0; j < H * W; j++)
        {
            if (D[i][j] < BASE_NUM)
            {
                max_d = max(max_d, D[i][j]);
            }
        }
    }
    cout << max_d << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
using namespace std;
string str;
int ans,len;
int main()
{
	cin>>str;
	len = str.length();
	for(int i=0;i<len;i++)
	{
		if(i == 0) cout<<str[i];
		else
		{
			if(i != len-1) ans++;
			else cout<<ans<<str[i];	
		}
    }
    cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
long long  n ;
int main(){
	cin>>n;
	bool a = false;
	for(int i = n ; i > 0; i--){
		rep(j,i+1){
			long long k = j*j;
			if(i == k){
				cout<<i<<endl;
				a = true;
				break;
			}
			if(k>i){
				break;
			}
		}
		if(a){
			break;
		}
	}
	
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//#define D(fmt,...) fprintf(stderr, fmt, ##__VA_ARGS__)
#define D(fmt,...) 
#define P(fmt,...) fprintf(stdout, fmt, ##__VA_ARGS__)
#define MAX 100
#define BFSZ 5
void print(int array[], size_t size) {
    int z;
    for (z = 0; z < size-1; z++) {
      P("%d ", array[z]);
    }
    P("%d\n", array[z]);
}
void insertionSort (int array[], size_t size)
{
  int i = 0;
  for (i = 1; i < size; i++) {
    int v = array[i];
    int j = i - 1;
    while (j >= 0 && array[j] > v) {
      array[j+1] = array[j];
      j--;
    }
    array[j+1] = v;
    print(array, size);
  }
}


int main (int ac, char **av)
{
  while (1) {
    int size = 0;
    fscanf(stdin, "%d\n", &size);
    int array[MAX] = {0};
    char buf[MAX * 5] = {0};
    char *eof = fgets(buf, MAX*5, stdin);
    if (eof == NULL) {
      break;
    }
    int i = 0;
    
    char numBuf[BFSZ] = {0};
    int array_idx = 0;
    int buf_idx = 0;
    for (i = 0; i < size*BFSZ; i++) {
      if (buf[i] == '\0') {
	continue;
      } else if (buf[i] == ' ') {
	array[array_idx++] = atoi(numBuf);
	buf_idx=0;
	memset(numBuf, 0, BFSZ);
      } else if (buf[i] == '\n') {
	array[array_idx++] = atoi(numBuf);
	memset(numBuf, 0, BFSZ);
	break;
      } else {
	memcpy(numBuf+buf_idx++, buf+i, 1);
      }
    }
    int j = 0;
    print(array, size);
    insertionSort(array, size);
  }
  return 0;
}

Measured memory_bytes: 608
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, c = M()
l = [0]*101
l[a] = 1
l[b] = 1
l[c] = 1
print(sum(l))

Measured memory_bytes: 68388
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int n;
int dom[205];
char fin[205];
inline int mod(int i){return (i>2*n)?i-2*n:i;}
int main(){
    cin>>n;
    string rep;
    if (n==1){
        cout<<"? 1"<<endl;
        cin>>rep;
        if (rep=="Red") cout<<"! RB"<<endl;
        else cout<<"! BR"<<endl;
        return 0;
    }

    int l,r;
    string initial;

    cout<<"? ";
    for (int x=1;x<=n;x++){
        cout<<x<<" ";
    }
    cout<<endl;

    cin>>initial;

    int hi=n+1,lo=1,mid;
    while (hi-lo>1){
        mid=(hi+lo)>>1;
        cout<<"? ";
        for (int x=mid;x<mid+n;x++){
            cout<<x<<" ";
        }
        cout<<endl;

        cin>>rep;
        if (rep==initial) lo=mid;
        else hi=mid;
    }

    if (initial=="Red") fin[lo]='R',fin[lo+n]='B';
    else fin[lo]='B',fin[lo+n]='R';

    l=lo+1,r=lo+n;

    //printf("Bsta done %d %d\n",l,r);

    for (int x=mod(r+1);x!=l-1;x=mod(x+1)){
        cout<<"? "<<x<<" ";
        for (int y=l;y!=r;y=mod(y+1)){
            cout<<y<<" ";
        }
        cout<<endl;
        cin>>rep;
        if (rep=="Red") fin[x]='R';
        else fin[x]='B';
    }

    vector<int> red;
    vector<int> blue;

    for (int x=1;x<2*n;x++){
        if (fin[x]=='R') red.push_back(x);
        else if (fin[x]=='B') blue.push_back(x);
    }

    for (int x=l;x!=r;x=mod(x+1)){
        cout<<"? "<<x<<" ";
        for (int y=0;y<(n>>1);y++){
            cout<<red[y]<<" ";
            cout<<blue[y]<<" ";
        }
        cout<<endl;
        cin>>rep;
        if (rep=="Red") fin[x]='R';
        else fin[x]='B';
    }

    cout<<"! ";
    for (int x=1;x<=2*n;x++){
        cout<<fin[x];
    }
    cout<<endl;
}


Measured memory_bytes: 724
S = list(input())


def dfs(count, string):
    if count == 4:
        if eval(string) == 7:
            return string + '=7'
        else:
            return ''
    plus = dfs(count + 1, string + '+' + S[count])
    minus = dfs(count + 1, string + '-' + S[count])
    return plus + minus


print(dfs(1, S[0])[:9])


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

int main()
{
	int N,K;
	cin>>K>>N;
	int arr[N+5];
	int dis[N+5]={0};
	for(int i=0;i<N;i++)
	{
		cin>>arr[i];
	}
		for(int i=0;i<N;i++)
	{
		if(i<N-1)
		{
			dis[i]=arr[i+1]-arr[i];		
		}
		else
			dis[i]=K-arr[i]+arr[0];
		
	}
	int max=0;
	for(int i=0;i<N;i++)
	{
		if(max<dis[i])
			max=dis[i];
	}	
	//	cout<<max<<endl;
	cout<<K-max<<endl;

return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007

ll dp[100000][3];
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i;
    cin>>n;
    ll a[n][3];
    for(i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(i=1;i<n;i++){
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 8336
#include <algorithm>
#include <iostream>
#include <string>
#define ll long long
using namespace std;

int main(){
 string S;
 int K;
 cin>>K>>S;
 if(S.size()<=K) cout<<S<<endl;
 else{
   for(int i=0;i<K;i++) cout<<S[i];
   cout<<"..."<<endl;
 }
}

Measured memory_bytes: 3572
#include <stdio.h>

int x , y , r , w , h;

int main ()  {

	scanf ("%d %d %d %d %d" , &w , &h ,&x , &y , &r);
	
	if ((x+r)>w || (y+r)>h || (x-r)<0 || (y-r)<0) {
		printf ("No\n");
	} else {
		printf ("Yes\n");
	}
	return 0;
}




Measured memory_bytes: 2088
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type point struct {
	x int
	y int
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()

	points := make([]point, n)
	for i := 0; i < n; i++ {
		points[i].x = readInt()
		points[i].y = readInt()
	}

	total := 0.0
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i != j {
				dx := points[i].x - points[j].x
				dy := points[i].y - points[j].y
				total += math.Hypot(float64(dx), float64(dy))
			}
		}
	}
	fmt.Printf("%.10f\n", total/float64(n))
}


Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int N;
	int count = 0;
	int a[100000];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		if (i != 0) {
			if (a[i] == a[i - 1]) {
				count++;
				a[i] = 10000 + i;
			}
		}
	}
	printf("%d", count);
	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;



 class Main{
     
    static  ArrayList<String> al=new ArrayList<String>();
    static int A=1,B=0;
    static char chars[]= new char[]{
         'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',
         'q','r','s','t','u','v','w','x','y','z'
     };
    static char getChar(int n){return chars[n];}
    static int getCode(char c){return (int)c-(int)'a';}
    static int F(int m){return (A*m+B)%26;}
    static String replace(String str){
        StringBuilder sb=new StringBuilder();
        for(int i=0; i<str.length(); i++){
           // System.out.println(str.charAt(i)+" "+F(getCode(str.charAt(i))));
            char replaced = getChar(F(getCode(str.charAt(i))));
            //System.out.println(replaced);
            sb.append(replaced);
        }        return new String(sb);
    }
    static void detectAB(){
        A=1;B=0;
        for(int a=1; a<30000;a+=2){
            for(int b=0; b<26;b++){
                A=a;B=b;
                for(String str:al){
                    String rep = replace(str);
                    //System.out.println(rep);
                    if(rep.equals("this")||rep.equals("that"))return;
                }
            }
        }
    }
    
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // System.out.println(getCode('a')+""+getCode('b')+""+getCode('z'));
         //System.out.println(replace("abz"));
         //String line;
         try{
         int n=Integer.parseInt(br.readLine());
         //int n=1;
         //for(int i=0; i<n;i++){
         String line;
         while((line=br.readLine())!=null){
             //System.out.println("aa"+n);
             al.clear();
             
             //System.out.println(line);
             String split[]=line.split(" ");
             for(String str:split)if(str.length()==4)al.add(str);
            detectAB();
             System.out.print(replace(split[0]));
            for(int j=1; j<split.length;j++){
                System.out.print(" "+replace(split[j]));
            }
             System.out.println();
         }
         }catch(Exception e){}
         
     }
     
 }

Measured memory_bytes: 23096
#include<bits/stdc++.h>
#define ull unsigned long long int 
#define pb push_back
#define F first
#define S second
#define ll long long 
#define ld long double 

#define int long long int

const int mod = 1000000007;
const ll inf = 1e18; 
 
int power(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int ncr(int n, int r){ int C[r+1]; memset(C, 0, sizeof(C)); C[0] = 1; for(int i = 1; i <= n; i++) {int t=i;if(r<t)t=r; for (int j = t; j > 0; j--) C[j] = C[j] + C[j-1]; }return C[r];} 
int gcd(int a,int b){if (a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (a/gcd(a,b)*b);}

int min(int a , int b){return a < b ? a : b;}
int max(int a , int b){return a > b ? a : b;}

using namespace std;

signed main(){

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

	int n;
	cin >> n;
	int a[n];
	for(int i = 0 ; i < n ; i++)
		cin >> a[i];
	
	int dp[n][n] = {};
	for(int l = n-1 ; l >= 0 ; l--){
		for(int r = l ; r < n ; r++){
			if(l == r)
				dp[l][r] = a[l];
			else
				dp[l][r] = max(a[l] - dp[l+1][r] , a[r] - dp[l][r-1]);
		}
	}
	cout << dp[0][n-1];
}










Measured memory_bytes: 73936
import java.util.Scanner;
class Main{
    public static void main(String[] args){
	int array[] = new int[101];
	int i,j,count=0,flag=1,temp;

	Scanner scan = new Scanner(System.in);
	array[0] = scan.nextInt();

	for(i=1;i<=array[0];i++){
	    array[i] = scan.nextInt();
	}
	
	while(flag!=0){
	    flag=0;
	    for(j=array[0];j>1;j--){
		if(array[j] < array[j-1]){
		    temp = array[j];
		    array[j] = array[j-1];
		    array[j-1] = temp;
		    flag = 1;
		    count++;
		}
	    }
	}
	for(i=1;i<=array[0];i++){
	    if(i==array[0]){System.out.println(array[i]+"\n"+count);}
	    else System.out.print(array[i]+" ");
	}
    }
}



Measured memory_bytes: 26292
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}


signed main(){
	
	ll a = 0 ,b = 0;
	string s;
	cin >> s;
	
	rep(i,0,s.size()){
		if(s[i] == '0') a++;
		else b++;
	}
	
	cout << (ll)s.size()-abs(a-b) << endl;
	return 0;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20)
#define int long long
#define double long double
#define gcd __gcd
#define lcm(a, b) (a / gcd(a, b) * b)
#define factorial(a) (a < 2 ? 1 : factorial(a - 1) * a)
#define summation(a) (a < 1 ? 0 : (a * a + a) / 2)
const int INF = 1e18, MOD = 1e9 + 7;

vector<int> fact;

void modinit(int n) {
    fact.push_back(1);
    int now = 1;
    for (int i = 1; i <= n; i++) {
        now *= i;
        now %= MOD;
        fact.push_back(now);
    }
}

int modpow(int x, int n) {
    return n < 1 ? 1 : modpow(x * x % MOD, n / 2) * (n % 2 ? x : 1) % MOD;
}

int modcomb(int n, int r) {
    if (n < r) return 0;
    return fact[n] * modpow(fact[n - r], MOD - 2) % MOD * modpow(fact[r], MOD - 2) % MOD;
}

char c;

signed main() {
    INCANT;
    cin>>c;
    if (c <= 'Z') cout<<'A'<<endl;
    else cout<<'a'<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());

    int n=a[N-1];
    auto low=std::lower_bound(a.begin(),a.end()-2,n/2);
    int r=*low;
    if(low!=a.begin() && std::abs(n/2-*low)>std::abs(n/2-*(low-1))){
        r=*(low-1);
    }

    cout << n << " " << r << endl;
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e7 + 555;
const double PI = acos(-1.0);


void solve()
{
	
	int n;
	string s;
	cin >> n >> s;
	int cnt =  1;
	rep(i, sz(s)) if(i && s[i] != s[i - 1]) cnt++;
	cout << cnt; 
}
 
int main()
{
    Red;
    solve();
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

struct sta
{
    int c, s, f;

    void wait(ll &t)
    {
        if (t <= s)
        {
            t = s;
        }
        else
        {
            t += (t - s + f - 1) / f * f - t + s;
        }
        return;
    };

    void go(ll &t)
    {
        t += c;
        return;
    };
};

int main()
{
    int n;
    cin >> n;
    sta station[n];
    repi(i, n - 1, 0)
    {
        int c, s, f;
        cin >> c >> s >> f;
        station[i].c = c;
        station[i].s = s;
        station[i].f = f;
    }
    repi(i, n, 0)
    {
        ll time = 0;
        repi(j, n - 1, i)
        {
            station[j].wait(time);
            station[j].go(time);
        }
        cout << time << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//Atcoder Regular Contest 093 C
#include <cstdio>
#define maxn 100010
using namespace std;
typedef long long ll;
ll n,pos[maxn],len[maxn],total=0;
ll abs(ll k)
{
	if(k>0) return k;
	return -k;
}
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&pos[i]);
	}pos[n+1]=0;
	for(int i=0;i<=n;i++)
	{
		total+=(len[i]=abs(pos[i+1]-pos[i]));
	}
	for(int i=1;i<=n;i++){
		printf("%lld\n",total+abs(pos[i+1]-pos[i-1])-(len[i-1]+len[i]));
	}
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b==c+d)
    {
        cout<<"Balanced\n";
    }
    else if(a+b>c+d)
    {
        cout<<"Left\n";
    }
    else
    {
        cout<<"Right\n";
    }
    return 0;

}


Measured memory_bytes: 3564
#include<iostream>

using namespace std;

int main(){

        int N;

        cin >> N;

        int i,j,c=0;
        int C=0;


        for(i=1;i<=N;i=i+2){
                for(j=1;j<=N;j++){
                        if(i%j==0){
                        c++;
                        }
                }
                if(c==8){
                C++;
                }
                c=0;
        }


        cout << C;

        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll sx,sy; cin >> sx >> sy;
    ll tx,ty; cin >> tx >> ty;
    string ans;
    ll x = tx - sx;
    ll y = ty - sy;
    rep(i, x)ans += 'R';
    rep(i, y)ans += 'U';
    rep(i,x)ans += 'L';
    rep(i,y)ans += 'D';
    
    ans += 'D';
    rep(i,x+1)ans += 'R';
    rep(i,y+1)ans += 'U';
    ans += 'L';
    ans += 'U';
    rep(i,x+1)ans += 'L';
    rep(i,y+1)ans += 'D';
    ans += 'R';

    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"

vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

int main() {
	vector<string>sts;
	string st;
	vector<vector<int>>nums;
	while (cin >> st) {
		vector<string>sts = split(st, ',');
		vector<int>anums;
		for (auto s : sts) {
			anums.push_back(stoi(s));
		}
		nums.emplace_back(anums);
	}
	for (int i = 0; i < nums.size(); ++i) {
		if (i > nums.size()/2) {
			int plus = i - nums.size()/2;
			for (int j = 0; j < plus; ++j) {
				nums[i].insert(nums[i].begin(), 0);
			}
		}
		nums[i].resize(i + 1);
	}
	vector<vector<int>>dps(nums);
	for (int i = 0; i < dps.size(); ++i) {
		for (int j = 0; j < dps[i].size(); ++j) {
			dps[i][j] = 0;
		}
	}
	dps[0][0] = nums[0][0];
	for (int h = 0; h < dps.size()-1; ++h) {
		for (int w = 0; w <= h; ++w) {
			dps[h + 1][w] = max(nums[h + 1][w] + dps[h][w], dps[h + 1][w]);
			dps[h + 1][w + 1] = max(nums[h + 1][w + 1] + dps[h][w], dps[h + 1][w + 1]);
		}
	}
	cout << dps[dps.size() - 1][dps.size()/2] << endl;
	return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int x,y;
    cin>>x>>y;
    int count=0;
    for(int i=x;i<=y;i++){
        if(i%n==0){
            count++;
        }
    }
    if(count==0){
        cout<<"NG";
    }
    else{
        cout<<"OK";
    }
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    if (s[0]== 'R') ++cnt;
    if (s[1] == 'R') ++cnt;
    if (s[2] == 'R') ++cnt;
    if (s == "RSR")cnt=1;
    
    cout << cnt << endl;
}

Measured memory_bytes: 3596
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    AB=[]
    for i in range(n):
        a,b=map(int,input().split())
        AB.append((a+b,a,b))    
    AB.sort(reverse=True)
    x=sum([-b[2] for b in AB])
    sum_ab=sum([ab[0] for ab in AB[::2]])
    print(x+sum_ab)


if __name__=='__main__':
    main()

Measured memory_bytes: 29892
import java.util.Scanner;

class Main {

  public static String solve(String[] data) {
    for(int i=0; i<8; i++) {
      for(int j=0; j<8; j++) {
        if(data[i].charAt(j)=='0') {
          continue;
        }
        if(i<7&&j<7) {
          if(data[i+1].charAt(j)=='1' && data[i].charAt(j+1)=='1' && data[i+1].charAt(j+1)=='1') {
            return "A";
          }
        }
        if(i<5) {
          if(data[i+1].charAt(j)=='1' && data[i+2].charAt(j)=='1' && data[i+3].charAt(j)=='1') {
            return "B";
          }
        }
        if(j<5) {
          if(data[i].charAt(j+1)=='1' && data[i].charAt(j+2)=='1' && data[i].charAt(j+3)=='1') {
            return "C";
          }
        }
        if(i<6&&0<j) {
          if(data[i+1].charAt(j)=='1' && data[i+1].charAt(j-1)=='1' && data[i+2].charAt(j-1)=='1') {
            return "D";
          }
        }
        if(i<7&&j<6) {
          if(data[i].charAt(j+1)=='1' && data[i+1].charAt(j+1)=='1' && data[i+1].charAt(j+2)=='1') {
            return "E";
          }
        }
        if(i<6&&j<7) {
          if(data[i+1].charAt(j)=='1' && data[i+1].charAt(j+1)=='1' && data[i+2].charAt(j+1)=='1') {
            return "F";
          }
        }
        return "G";
      }
    }
    return "a";
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] data = new String[8];
    for(int i=0; i<8; i++) {
      data[i] = sc.nextLine();
    }
    System.out.println(solve(data));
    while(sc.hasNext()) {
      String nl = sc.nextLine();
      for(int i=0; i<8; i++) {
        data[i] = sc.nextLine();
      }
      System.out.println(solve(data));
    }
  }
}

Measured memory_bytes: 27184
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException{
		Main mainObj = new Main();
		mainObj.solve();
	}
	
	public void solve() throws IOException{
		FastScanner fs = new FastScanner();
		int x = fs.nextInt();
		
		int ans = 0;
		ans += (x / 500)*1000;
		ans += ((x % 500)/5) * 5;
		System.out.println(ans);
	}

	public class FastScanner {
		
		BufferedReader reader;
		private StringTokenizer st;
		
		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		
		public String next() throws IOException {
			if(st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}
		
		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}
		
		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
		
		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		
		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for(int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}
		
		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for(int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}
		
		public void close() throws IOException {
			reader.close();
		}
	}
}


Measured memory_bytes: 22996
#include<stdio.h>
int main(){
	int a;
	int b;
	int c;
	int x;
	int y=1;
	int z;
	scanf("%d",&x);
		while(y<=x){
		scanf("%d",&a);
		scanf("%d",&b);
		scanf("%d",&c);
		if(c>=b){
			z=c;
			c=b;
			b=z;
		}
		if(a<=c){
			z=a;
			a=b;
			b=c;
			c=z;
		}
		else if(b>=a){
			z=b;
			b=a;
			a=z;
		}
	z=a*a-b*b-c*c;
	if(z==0)
		puts("YES");
	else
		puts("NO");
	y++;
	}
return(0);
}

Measured memory_bytes: 1008
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>

using namespace std;

typedef long long ll;

int main() {
    ll x, y, a, b, c;   cin >> x >> y >> a >> b >> c;
    ll *p = new ll[a], *q = new ll[b], *r = new ll[c];
    for (ll i = 0; i < a; i++)
        cin >> p[i];
    for (ll i = 0; i < b; i++)
        cin >> q[i];
    for (ll i = 0; i < c; i++)
        cin >> r[i];

    sort(p, p+a, greater<ll>());
    sort(q, q+b, greater<ll>());
    sort(r, r+c, greater<ll>());

    priority_queue<ll> p_que;
    for (int i = 0; i < x; i++)
        p_que.push(p[i]);
    for (int i = 0; i < y; i++)
        p_que.push(q[i]);
    for (int i = 0; i < c; i++)
        p_que.push(r[i]);

    ll ans = 0;
    for (ll i = 0; i < x+y; i++) {
        ans += p_que.top();
        p_que.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8304
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <cmath>

using namespace std;

int main(){
  int N,T;
  cin>>N>>T;
  vector<int> v;
  for(int i=0;i<N;i++){
    int c,t;
    cin>>c>>t;
    if(t<=T){
      v.push_back(c);
    }
  }
  if(v.size()==0){
    cout<<"TLE"<<endl;
    return 0;
  }

  int min=2000;
  for(auto it=v.begin();it!=v.end();it++){
    if(min>(*it)){
      min=(*it);
    }
  }

  cout<<min<<endl;

  return 0;
}


Measured memory_bytes: 256