akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  if (m & 1) {
    cout << -1 << '\n';
    return 0;
  }
  vector<set<int> > edge(n);
  REP(i, m) {
    int a, b; cin >> a >> b; --a; --b;
    edge[a].emplace(b);
    edge[b].emplace(a);
  }
  vector<int> c, d, deg(n, 0);
  set<pair<int, int> > st;
  REP(i, n) st.emplace(edge[i].size(), i);
  while (!st.empty()) {
    auto p = *st.begin();
    st.erase(st.begin());
    int sz = p.first, ver = p.second;
    if ((deg[ver] + sz) & 1) {
      if (sz == 0) assert(false);
      for (int e : edge[ver]) if (e % 3 == 1 || e == *edge[ver].rbegin()) {
        edge[ver].erase(e);
        c.emplace_back(e + 1);
        d.emplace_back(ver + 1);
        ++deg[e];
        st.erase(make_pair(edge[e].size(), e));
        edge[e].erase(ver);
        st.emplace(edge[e].size(), e);
        break;
      }
    }
    // cout << sz << ' ' << ver << endl;
    for (int e : edge[ver]) {
      c.emplace_back(ver + 1);
      d.emplace_back(e + 1);
      ++deg[ver];
      st.erase(make_pair(edge[e].size(), e));
      edge[e].erase(ver);
      st.emplace(edge[e].size(), e);
    }
  }
  REP(i, n) {
    if (deg[i] & 1) assert(false);
  }
  if (c.size() != m) assert(false);
  REP(i, m) cout << c[i] << ' ' << d[i] << '\n';
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

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

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

string ltrim(string s){return s.substr(s.find_first_not_of(" "));}
string rtrim(string s){return s.substr(0, s.find_last_not_of(" ")+1);}
string trim(string s){return rtrim(ltrim(s));}

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

    list<int> a;

    REP(i,n){
        string com;
        int val;
        cin>>com;
        if(com=="insert"){
            cin>>val;
            a.emplace_front(val);
        }else if(com=="delete"){
            cin>>val;
            auto it = a.begin();
            for(; it !=a.end(); it++){
                if((*it)==val){
                    a.erase(it);
                    break;
                }
            }
        }else if(com=="deleteFirst"){
            a.pop_front();
        }else if(com=="deleteLast"){
            a.pop_back();
        }
    }

    
    
    string ans="";
    for(auto it:a){
        ans +=  to_string(it) + " ";
    }
    ans = rtrim(ans);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 33968
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readB(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		// String[] strArr = str.split("\\s+");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		A = Integer.parseInt(str);
	}

	int A;

	public void readB(String str) {
		int B = Integer.parseInt(str);
		if (A + B == 3)
			System.out.println(3);
		else if (A + B == 4)
			System.out.println(2);
		else
			System.out.println(1);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21076
#include <iostream>

using namespace std;

int main(){
    int v[50],c[50],sum = 0,n;
    cin >> n;
    
    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] > 0){
            sum += (v[i] - c[i]);
        }
    }
    cout<<sum<<endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int n,w[N]; char s[N];
inline int read(){
	int num=0; char g=getchar(); while(g<48||57<g) g=getchar();
	while(47<g&&g<58) num=(num*10)+g-48,g=getchar(); return num;
}
inline int getans(int a,int b){
	int ans=1;
	while(a>0&&b>0) {if(a%2<b%2) ans=0; a/=2,b/=2;} return ans;
}
int main(){
	n=read(); bool fl=0; int sum=0; scanf("%s",s+1);
	for(int i=1;i<=n;i++) w[i]=s[i]-'1';
	for(int i=1;i<=n;i++) if(w[i]==1) fl=1;
	for(int i=1;i<=n;i++) if(fl==1&&w[i]==2) w[i]=0;
	for(int i=1;i<=n;i++) if(getans(n-1,i-1)) sum^=w[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 5 * 10000 + 1
#define INF 10000000000


int n, k;
vector<ll> stones;
vector<ll> dp(int(1e5 + 10), LLONG_MAX); // dp[i] is the minimum cost to reach stone i. Answer is at dp[n-1].
int main()
{
    cin >> n >> k;
    stones.assign(n, 0LL);
    dp[0] = 0;
    for (int i = 0; i < n; ++i)
        cin >> stones[i];

    for (int i = 1; i < n; ++i)
        for (int j = 1; j <= k; ++j)
            if (i - j >= 0)
                dp[i] = min(abs(stones[i-j] - stones[i]) + dp[i - j], dp[i]);
    
    cout << dp[n-1] << endl;
    return 0;
}

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

const int nmax=100005;
vector<int> A[nmax],B[nmax];
int color[nmax];

void DFS(int u,int N,int color[nmax]){
    bool check=true;
    for(int i=0;i<N;i++){
        if(color[i]==0){
            check=false;
            break;
        }
    }
    if(check){
        for(int i=0;i<N;i++){
            cout<<color[i]%2<<endl;
        }
        return;
    }
    for(int i=0;i<A[u].size();i++){
        if(color[A[u][i]]==0){
            color[A[u][i]]=color[u];
            DFS(A[u][i],N,color);
        }
    }
    for(int i=0;i<B[u].size();i++){
        if(color[B[u][i]]==0){
            color[B[u][i]]=color[u]%2+1;
            DFS(B[u][i],N,color);
        }
    }
    return;
}

int main(){

        int N;
        cin>>N;
        for(int i=0;i<N-1;i++){
            int x,y,z;
            cin>>x>>y>>z;
            if(z%2==0){
                A[x-1].push_back(y-1);
                A[y-1].push_back(x-1);
            }
            else if(z%2==1) {
                B[x-1].push_back(y-1);
                B[y-1].push_back(x-1);
            }
            
        }
    
        color[0]=2;
        DFS(0,N,color);
    }



Measured memory_bytes: 13696
#include<iostream>
#include<algorithm>
using namespace std;
int n;
main()
{
	while(cin>>n,n)
	{
		int a[1111];
		for(int i=0;i<n;i++)cin>>a[i];
		int ans=1e9;
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				int A=abs(a[i]-a[j]);
				ans=ans<A?ans:A;
			}
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3060
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());

using ll = long long int;

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int num_digit(int a){
    return a == 0 ? 0 : num_digit(a / 10) + 1;
}

int main(){
    int n, sum = 0;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        if(num_digit(i) % 2 == 1){
            sum += 1;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split(" "))
AB = [list(map(int, input().split(" "))) for _ in range(N)]

AB.sort(key=lambda x: x[0])

sum_num = 0
for a, b in AB:
    c = min(b, M)
    sum_num += a*c
    # print(a*c, c, M)
    M -= c
    if M <= 0:
        break

print(sum_num)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string s;cin>>s;


    int l=0,r=s.size()-1;
    int ans=0;
    while(l<r){
        if(s[l]==s[r]){
            l++;r--;
            continue;
        }
        ans++;
        if(s[l]=='x')l++;
        else if(s[r]=='x')r--;
        else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

D={}
MIN=0
MAX=len(S)-1
for i in range(len(S)):
    D[i]=S[i]
F=1
Q=int(input())
for i in range(Q):
    q=list(input().split())
    if F==1:
        if q[0]=="1":
            F*=-1
        else:
            if q[1]=="1":
                D[MIN-1]=q[2]
                MIN-=1
            else:
                D[MAX+1]=q[2]
                MAX+=1
    else:
        if q[0]=="1":
            F*=-1
        else:
            if q[1]=="2":
                D[MIN-1]=q[2]
                MIN-=1
            else:
                D[MAX+1]=q[2]
                MAX+=1
ans=""

for i in range(MIN,MAX+1):
    ans+=D[i]
if F==1:
    print(ans)
else:
    print(ans[::-1])


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    map<int, int> mp;
    
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        
        mp[a]++;
    }
    
    int m;
    cin >> m;
    
    bool flag = true;
    
    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        
        if(mp[a] == 0){
            flag = false;
            break;
        }
        
        mp[a]--;
    }
  
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    
}


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

int main() {
	int n,m;
	cin >> n >> m;
	
	vector<bool> solved(n + 1);
	vector<int> waCount(n + 1);
	int x = 0;
	int y = 0;
	for(int i = 0; i < m; i++){
		int problem;
		string status;
		cin >> problem >> status;
		if (status == "WA" && !solved[problem]){
			waCount[problem]++;
		}else if(status == "AC" && !solved[problem]){
			solved[problem] = true;
			x++;
			y += waCount[problem];
		}
		
	}
	cout << x << " " << y << endl;
	return 0;
}

Measured memory_bytes: 640
from collections import Counter
import heapq

H, W = map(int, input().split())
Power = []
for _ in range(10):
    Power.append(list(map(int, input().split())))

Power_map = [0]*10

for i in range(10):
    Q = []
    if i == 1:
        continue
    if Power[i][1] == min(Power[i]):
        Power_map[i] = Power[i][1]
    else:
        to1 = Power[i][1]
        heapq.heappush(Q, (to1, 1))
        for j in range(10):
            if (i == j) or j == 1:
                continue
            elif to1 > Power[i][j]:
                heapq.heappush(Q, (Power[i][j], j))
        while len(Q) > 0:
            Costsum, now = heapq.heappop(Q)
            if now == 1:
                Power_map[i] = Costsum
                break
            for k in range(10):
                if now == k:
                    continue
                elif Costsum + Power[now][k] < to1:
                    heapq.heappush(Q, (Costsum+Power[now][k], k))

Wall = []
for _ in range(H):
    wall = list(map(int, input().split()))
    for __ in range(W):
        if wall[__] >= 0:
            Wall.append(wall[__])
WallC = Counter(Wall)

ans = 0
for i in range(10):
    ans += WallC[i] * Power_map[i]

print(ans)



Measured memory_bytes: 54364
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Linq;

namespace _20190324_04 {
    class Program {
        static void Main(string[] args) {
            var n = int.Parse(Console.ReadLine());
            var c = new Dictionary<int, char>() {
                [0] = 'A',
                [1] = 'C',
                [2] = 'G',
                [3] = 'T',
            };
            var memo = new List<Dictionary<string, int>>();
            for (int i = 0; i < n + 1; i++) {
                memo.Add(new Dictionary<string, int>());
            }
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    for (int k = 0; k < 4; k++) {
                        var s = c[i].ToString() + c[j] + c[k];
                        switch (s) {
                            case "AGC":
                            case "ACG":
                            case "GAC":
                                memo[3][s] = 0;
                                break;
                            default:
                                memo[3][s] = 1;
                                break;
                        }
                        for (int l = 4; l <= n; l++) {
                            memo[l][s] = 0;
                        }
                    }
                }
            }
            for (int i = 4; i <= n; i++) {
                for (int j = 0; j < 4; j++) {
                    foreach (var item in memo[i - 1]) {
                        var last4 = item.Key + c[j];
                        if (isOK(last4)) {
                            var key = new string(last4.Skip(1).ToArray());
                            memo[i][key] = (memo[i][key] + item.Value) % 1000000007;
                        }
                    }
                }
            }
            var sum = 0;
            foreach (var item in memo[n]) {
                sum = (sum + item.Value) % 1000000007;
            }

            Console.WriteLine(sum);
        }

        static bool isOK(string last4) {
            for (int i = 0; i < 4; i++) {
                var t = last4.ToCharArray();
                if (i >= 1) {
                    t[i - 1] = last4[i];
                    t[i] = last4[i - 1];
                }
                var s = new string(t);
                if (Regex.IsMatch(s, "AGC")) {
                    return false;
                }
            }
            return true;
        }
    }
}


Measured memory_bytes: 18732
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready, resolve
    int N,K;
    cin >> N >> K;
    vector<double> pList;
    pList.resize(N);
    map<int,double> eMap;
    for (int i=1; i<=1000; i++) eMap[i] = 0.5 + 0.5 * i;
    for (int i=0; i<N; i++) {
        int p;
        cin >> p;
        pList.at(i) = eMap[p];
    }

    double ans = 0;
    double beforeAns = 0;
    for (int i=0; i<K; i++) ans += pList[i];
    beforeAns = ans;
    for (int i=0; i<N-K; i++) {
        beforeAns -= pList[i];
        beforeAns += pList[i+K];
        ans = max(ans,beforeAns);
    }

    printf("%10.8f", ans);

    return 0;
}

Measured memory_bytes: 1920
#include<iostream>

using namespace std;

#define MAX_X 600

int main(void)
{
	int d;
	int s = 0;

	while(1){
		while(1){
			cin >> d;
			if( MAX_X % d == 0 ) break;
		}
		if( cin.eof() ) break;

		for( int i = 0 ; i < MAX_X / d ; i++ )
		{
			int height = ( i * d ) * ( i * d );
			int width = d;
			s += height * width;
		}
		cout << s << endl;
		s = 0;
	}

	return 0;
}

Measured memory_bytes: 1160
import java.io.*;
import java.math.BigInteger;
import java.util.*;

 
public class Main{
	/*
	 * use Integer for sorting
	 * avoid object comparison
	 * NEVER APPEND A STRING -> APPEND char by char
	 * Always use TreeSet instead of HashSet
	 * 
	 */
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e8;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static long[] fac;
    public static int N = 400000+200;
    public static int x = 0;
    public static boolean[] visited;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		long lcm = (a*b)/gcd(a,b);
		out.print(lcm);
		
		
		
		out.close();
	}
	private static long gcd(long a, long b) {
		if(b == 0) return a;
		return gcd(b,a%b);
	}
}

Measured memory_bytes: 21076
#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; }

string s,t;
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 >> s >> t;
}

int solve(){
    int n=s.length();
    int m=t.length();
    int dp[n+10][m+10];
    memset(dp,0,sizeof(dp));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if(s[i]==t[j]) dp[i+1][j+1] = dp[i][j]+1;
            else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
        }
    }
    DBG(dp[n][m])
    // for (int i = 0; i <= n; i++)
    // {
    //     for (int j = 0; j <= m; j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
        
    // }
    
    string r;
    int i=n-1,j=m-1;
    int last=0;
    while(i>=0 && j>=0){
        if(dp[i+1][j+1]==dp[i+1][j]) j--;
        else if(dp[i+1][j+1]==dp[i][j+1]) i--;
        else {
            r += s[i];
            last = i;
            i--,j--;
            }
    }
    reverse(r.begin(),r.end());
    cout << r << endl;

    return 0;    
}   

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


Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b,c;cin>>a>>b>>c;
    if(a <= c && a+b >= c) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

int main()
{
    fast();
    umap<ll,ll> w,r;
    ll x,n;
    cin>>n>>n;
  //  ll ans1=0,ans2=0;
    umap<ll,bool> haha;
    ll ans=0;
    while(n--)
    {
        string y;
        cin>>x>>y;
        if(y=="AC"){
            if(haha[x]==false){
                ans+=w[x];
                haha[x]=true;
            }
            r[x]++;
        }
        else
        {
            w[x]++;
        }

    }
    cout<<r.size()<<" "<<ans;
}

Measured memory_bytes: 12652
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
	int a,b;
  cin>>a>>b;
  map<int,int>mp;
  mp[a]++;
  mp[b]++;
  if(mp[1] == 0)
  {
    cout<<"1"<<endl;
  }
  else if(mp[2] == 0)
{
    cout<<"2"<<endl;
  }
  else
  {
    cout<<"3"<<endl;
  }
}

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

int main(){
  int n,m = 0;cin >> n >> m;
  vector<int> a(n);
  priority_queue<int> que;
  rep(i,n){
    cin >> a[i];
    que.push(a[i]);
  }
  ll ans = 0;
  for(int i=0;i<m;i++){//O(10ˆ5)
    int b;b = que.top() / 2;
    que.pop();
    que.push(b);
  }
  for(int i=0;i<n;i++){//O(10ˆ5)
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
  return 0;
}

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

int max(int a, int b, int c)
{
	if(a>=b && a>=c)
	return a;
	if(b>=a && b>=c)
	return b;
	else 
	return c;
}
int main()
{
	int a,b,c,k;
	while(cin>>a>>b>>c)
	{
		cin>>k;
		while(k--)
		{
			int mx=max(a,b,c);
			if(mx==a)
			a=a*2;
			else if(mx==b)
			b*=2;
			else
			c*=2;
		}
		cout<<a+b+c<<endl;
	}
	return 0;
}

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

int main()
{
    int n, m, i, j, x;
    cin >> n >> m;

    vector<int> v[n+1];
    string s;

    while(m--)
    {
        cin >> x >> s;
        if(v[x].empty() || v[x].back() == 0)
            v[x].push_back(s == "AC");
    }

    int point = 0, penalty = 0;
    for(auto u : v)
    {
        if(u.empty() || u.back() == 0)
            continue;
        else
        {
            point++;
            penalty += u.size() -1;
        }
    }

    cout << point << " " << penalty;
}


Measured memory_bytes: 5760
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int N, C;
	cin >> N >> C;
	vvl D(C, vl(C));
	REP(i, C) {
		REP(j, C) {
			cin >> D[i][j];
		}
	}

	vvl col(3, vl(C));
	int p;
	FOR(i, 1, N) {
		FOR(j, 1, N) {
			cin >> p;
			p--;
			col[(i + j) % 3][p]++;
		}
	}

	ll ans = LLONG_MAX / 2;
	REP(i, C) {
		REP(j, C) {
			if (i == j) {
				continue;
			}
			REP(k, C) {
				if (i == k || j == k) {
					continue;
				}
				ll tmp = 0;
				REP(ii, C) {
					tmp += D[ii][i] * col[0][ii];
				}
				REP(jj, C) {
					tmp += D[jj][j] * col[1][jj];
				}
				REP(kk, C) {
					tmp += D[kk][k] * col[2][kk];
				}
				ans = min(ans, tmp);
			}
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(x).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

constexpr ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    bool operator==(const mint a)const{
        return x==a.x;
    }
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vec<int> L(K),R(K);
    for(int i=0;i<K;i++) cin >> L[i] >> R[i];
    vec<mint> dp(N);
    dp[0] = 1;
    for(int i=0;i<N;i++){
        for(int j=0;j<K;j++){
            int l = i+L[j],r = i+R[j];
            if(l<N) dp[l] += dp[i];
            if(r+1<N) dp[r+1] -= dp[i];
        }
        dp[i+1] += dp[i];
    }
    cout << dp[N-1]-dp[N-2] << "\n";
}

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

long dp[110][100010];
int w[110], v[110];

int main()
{
    int N, W; cin>>N>>W;
    for(int i=0; i<N; ++i) cin>>w[i]>>v[i];

    for(int i=0; i<N; ++i) {
        for(int j=0; j<=W; ++j) {
            dp[i+1][j]=max(dp[i+1][j], dp[i][j]);
            if (j>=w[i])
                dp[i+1][j]=max(dp[i+1][j], dp[i][j-w[i]]+v[i]);
        }
    }

    long res=0;
    for(int i=0; i<=W; ++i) res=max(res, dp[N][i]);
    cout<<res<<endl;
}


Measured memory_bytes: 79360
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std; 
using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
 
template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;
 
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'
 
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 
 
const int MXN = 2e5 + 5;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;


const int MX = 1e5 + 5;
int N, M, A, B, d[MX], p[MX], used[MX];
vi adj[MX];

int main(){ FAST
    //ifstream cin("/Users/konwoo/input.txt");
    //ofstream cout("/Users/konwoo/output.txt");

    cin >> N >> M;
    F0R(i,M){
        cin >> A >> B;
        adj[A].pb(B);
        adj[B].pb(A);
    }
    F0R(i,N){
        d[i+1] = 1e9;
        p[i+1] = -1;
    }
    used[1] = 1;
    d[1] = 0;
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int v = q.front(); 
        q.pop();
        for (int u : adj[v]){
            if (!used[u]){
                used[u] = 1;
                q.push(u);
                d[u] = d[v] + 1;
                p[u] = v;
            }
        }
    }
    cout << "Yes\n";
    FOR(i,2,N+1){
        cout << p[i] << newl;
    }
    


    

 
 
 
    return 0;
}


Measured memory_bytes: 11360
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const L = parseInt(arg[0].split(" ")[0]);
    
    const splitted3 = L / 3;
    
    console.log(Math.pow(splitted3, 3));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
//#define double ld
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ifstream in("input.txt");ofstream out("output.txt");
const int inf=1e18;
const int mod=1e9+7;
int n,k;
vector<int> vec;
vector<vector<int> > dp;

void init()
{
    cin>>n;
    vec.resize(n);
    for(int i=0;i<n;i++)
        cin>>vec[i];
    dp.resize(n,vector<int>(n,inf));
    for(int i=0;i<n;i++)
    {
        dp[i][i]=0;
        if((i+i)%2==(n-1)%2)
            dp[i][i]+=vec[i];
        else
            dp[i][i]-=vec[i];
    }
}

int go(int l,int r)
{
    if(l<0||r<0||l>=n||r>=n)
        return inf;
    if(dp[l][r]!=inf)
        return dp[l][r];
    int ans;
    if((l+r)%2==(n-1)%2)
    {
        ans=-inf;
        if(go(l+1,r)!=inf)
            ans=max(ans,go(l+1,r)+vec[l]);
        if(go(l,r-1)!=inf)
            ans=max(ans,go(l,r-1)+vec[r]);
    }
    else
    {
        ans=min(-vec[l]+go(l+1,r),-vec[r]+go(l,r-1));
    }
    return dp[l][r]=ans;
}

signed main()
{
    init();
    cout<<go(0,n-1)<<"\n";
    return 0;
}




Measured memory_bytes: 70912
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++) cin >>a[i];
	for(int i=0;i<n;i++){
		int key = a[i];
		int j = i-1;
		while(j>=0&&a[j]>key){
			a[j+1]=a[j];
			j--;
		}
		a[j+1] = key;
	
		for(int i=0;i<n;i++) {
			cout<<a[i];
			if(i==n-1) cout<<endl;
			else cout<<" ";
		}
	
	}
	return 0;
}



Measured memory_bytes: 3104
// Problem : B - Palindrome-philia
// Contest : AtCoder - AtCoder Beginner Contest 147
// URL : https://atcoder.jp/contests/abc147/tasks/abc147_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    string s;
    cin>>s;
    int n = sz(s);
    int i = 0, j = n-1;
    int ans = 0;
    while(i < j){
        if(s[i] != s[j]) ans++;
        i++; j--;
    }
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  cout << max(A*B,C*D) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int read()
{
	char c;
	int w=1;
	while((c=getchar())>'9'||c<'0')if(c=='-')w=-1;
	int ans=c-'0';
	while((c=getchar())>='0'&&c<='9')ans=(ans<<1)+(ans<<3)+c-'0';
	return ans*w;
}
int x,y,a,b,c;
int A[1000005];
int B[1000005];
int C[1000005];
bool cmp(int ax,int bx)
{
	return ax>bx;
}
int D[1000005];
int cnt;
signed main(){
	x=read();
	y=read();
	a=read();
	b=read();
	c=read();
	for(int i=1;i<=a;i++)
	{
		A[i]=read();
	}
	for(int i=1;i<=b;i++)
	{
		B[i]=read();
	}
	for(int i=1;i<=c;i++)
	{
		C[i]=read();
	}
	sort(A+1,A+a+1,cmp);
	sort(B+1,B+b+1,cmp);
	sort(C+1,C+c+1,cmp);
	for(int i=1;i<=x;i++)
	{
		cnt++;
		D[cnt]=A[i];
	}
	for(int i=1;i<=y;i++)
	{
		cnt++;
		D[cnt]=B[i];
	}
	for(int i=1;i<=min(c,x+y);i++)
	{
		cnt++;
		D[cnt]=C[i];
	}
	sort(D+1,D+cnt+1,cmp);
	int ans=0;
	for(int i=1;i<=x+y;i++)
	{
		ans+=D[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14592
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    int n;
    double sum=0;
    cin>>n;
    vector<pair<int,int>> v(n);
    for(auto & e:v) cin>> e.first >> e.second;
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++){
            if(i!=j){
                sum+=sqrt(pow(v[i].first-v[j].first,2)+pow(v[i].second-v[j].second,2));
            }
        }
    }
    cout <<setprecision(10)<<sum/n<<endl;
}

Measured memory_bytes: 256
#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <tuple>
#include <set>
#include <map>

#define FOR0(var, max) for (ul (var) = 0; (var) < (max); ++(var))
#define FORi(var, min, max) for (ul (var) = (min); (var) < (max); ++(var))
#define FORi_INV(var, min, max) for (ul (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

const static ul NMAX = 2 * 1000;
const static ul LiMAX = 1000;

static ul N;
static sl Li[NMAX];

void solve(void) {
  ul res = 0;
  sort(begin(Li), begin(Li) + N);
  FOR0(i, N) {
    auto A = Li[i];
    FORi(j, i + 1, N) {
      auto B = Li[j];
      FORi(k, j + 1, N) {
        if (k == i || k == j) {
          continue;
        }
        if (LTLT(B - A, Li[k], B + A)) {
          res++;
        }
      }
    }
  }
  cout << res << endl;
}

int main(void) {
  cin >> N;
  FOR0(i, N) {
    cin >> Li[i];    
  }
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int sum = 0;

    for (int i = 1; i < b-a; i++) {
      sum += i;
    }
    System.out.println(sum-a);
  }

}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int q,n;
string s;

class Analysis{
	public:
	int Num(int &I){
		int res=0;
		while(I<n&&isdigit(s[I])) res=10*res+(s[I]-'0'),I++;
		return res;
	}
	int Fact(int &I){
		int res;
		if(s[I]=='(') res=Exp(++I),I++;
		else res=Num(I);
		return res;
	}
	int Term(int &I){
		int res=Fact(I);
		while(I<n){
			if(s[I]=='*') res*=Fact(++I);
			else if(s[I]=='/') res/=Fact(++I);
			else break;
		}
		return res;
	}
	int Exp(int &I){
		int res=Term(I);
		while(I<n){
			if(s[I]=='+') res+=Term(++I);
			else if(s[I]=='-') res-=Term(++I);
			else break;
		}
		return res;
	}
};

Analysis A;

int main(){
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>s;
		s.pop_back();
		n=s.size();
		int I=0;
		cout<<A.Exp(I)<<endl;
	}
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
#define int ll
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif
 
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
 
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
 
using pi=pair<int,int>;
using vi=vc<int>;
 
template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}
 
template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}
 
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n,k;cin>>n>>k;
	vi p(n);
	rep(i,n)cin>>p[i];
	
	vi t(n-k+1);
	{
		int cnt=0,j=1;
		rep(i,n-k+1){
			while(j<i+k){
				if(p[j-1]>p[j])
					cnt++;
				j++;
			}
			t[i]=cnt;
			if(p[i]>p[i+1])
				cnt--;
		}
	}
	vi sm(n-k+1);
	{
		set<int> s;
		int j=0;
		rep(i,n-k){
			while(j<i+k+1)
				s.insert(p[j++]);
			if(*s.bg==p[i]&&*prev(s.ed)==p[j-1])
				sm[i+1]=1;
			s.erase(p[i]);
		}
	}
	int ans=0,z=0;
	rep(i,n-k+1)if(!sm[i]){
		if(t[i])ans++;
		else z++;
	}
	ans+=bool(z);
	cout<<ans<<endl;
}

Measured memory_bytes: 11136
#include<iostream>
using namespace std;
int main(){
    int H,W;
    cin >> H >> W;
    while(H != 0){
        for(int i = 0; i < H ; i++){
            for( int j = 0; j < W; j++){
        cout << "#";
            }cout <<endl;
        }cout <<endl;
     cin >> H >> W;
    }   
    return 0;
}


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

int main() {
	long l, r;
	
	scanf("%ld%ld", &l ,&r);
	
	if (r-l >= 2019) {
		puts("0");
		return 0;
	}
	int MIN = 2019;
	for (long i=l; i<r; i++) {
		for (long j=i+1; j<=r; j++) {
			if ((i*j)%2019 == 0) {
				puts("0");
				return 0;
			}
			if (MIN > (i*j)%2019)
				MIN = (i*j)%2019;
		}
	}

	cout << MIN << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n],b[n];
  REP(i,n){
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b+n);
  int x,y;
  x = b[n/2-1];
  y = b[n/2];
  REP(i,n){
    if(a[i] <= x){
      cout << y << endl;
    }
    else{
      cout << x << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3712
require 'pp'

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

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

top_and_bottoms = Array.new(10).map {Array.new(10, 0)}

inp = gets.chomp
n = inp.to_i
digits = inp.size

res = 0
1.upto(n) do |i|
  i_s = i.to_s
  top_digit = i_s[0].to_i
  end_digit = i_s[-1].to_i
  top_and_bottoms[top_digit][end_digit] += 1
  # top_and_bottoms[end_digit][top_digit] += 1
end

res = 0

0.upto(9) do |i|
  i_eq_j = false
  0.upto(9) do |j|
    next if i_eq_j && i == j
    # puts "Ok" if i == j && i == 1
    i_eq_j = true if i == j
    # p [i, j, top_and_bottoms[i], top_and_bottoms[i][j], top_  and_bottoms[j][i]]
    # p [i, j] if top_and_bottoms[i][j] * top_and_bottoms[j][i] != 0

    res += top_and_bottoms[i][j] * top_and_bottoms[j][i]
  end
end

# pp top_and_bottoms

puts res

Measured memory_bytes: 4348
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define DIVIDE 10000.0
const int INF = 1e9;
const double EPS = 0.00001;
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	ld x[n + 1], y[n + 1], z[n + 1], r[n + 1], l[n + 1];
	for(int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i] >> z[i] >> r[i]>> l[i];
	}
	ld sx, sy, sz, dx, dy, dz;
	for(int i = 0; i < m; i++)
	{
		cin >> sx >> sy >> sz >> dx >> dy >> dz;
		ld ax = (ld)(sx - dx) / DIVIDE;
		ld ay = (ld)(sy - dy) / DIVIDE;
		ld az = (ld)(sz - dz) / DIVIDE;

		ld bx = sx;
		ld by = sy;
		ld bz = sz;
		bool flag[n + 1] = {};
		ll ans = 0;
		for(int j = 0; j <= DIVIDE; j++)
		{
			for(int k = 0; k < n; k++)
			{
				ld cx = bx - x[k];
				ld cy = by - y[k];
				ld cz = bz - z[k];
				ld dist = cx * cx + cy * cy + cz * cz;
				if(dist - r[k] * r[k] <= EPS)
					flag[k] = true;
			}
			bx -= ax;
			by -= ay;
			bz -= az;
		}
		for(int j = 0; j < n; j++)
			if(flag[j])
				ans += l[j];
		cout << ans << endl;
	}
	return 0;
}


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

char grid[801][801];
bitset<801> vis[801];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    // what if we flip the phases around...
    // unlock rooms first, then move to those unlocked rooms

    // find empty rooms first, then get min

    int h, w, k; cin >> h >> w >> k;

    queue<vector<int>> q;

    int best = 1e9;

    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            cin >> grid[i][j];
            if(grid[i][j] == 'S')
                q.push({i, j, 0});
        }
    }

    while(!q.empty()){
        vector<int> state = q.front(); q.pop();
        int x = state[0], y = state[1], moves = state[2];
        // unlock K, move K, min dist / K
        int mini = min(x, min(y, min(h - x - 1, w - y - 1)));
        best = min(best, 1 + mini / k + (mini % k != 0));
        if(moves == k) continue;
        for(int dx = -1; dx <= 1; ++dx){
            for(int dy = -1; dy <= 1; ++dy){
                if(dx == 0 && dy == 0) continue;
                if(dx != 0 && dy != 0) continue;
                if(x + dx < 0 || x + dx == h) continue;
                if(y + dy < 0 || y + dy == w) continue;
                if(grid[x + dx][y + dy] == '#') continue;
                if(vis[x + dx][y + dy]) continue;
                vis[x + dx][y + dy] = 1;
                q.push({x + dx, y + dy, moves + 1});
            }
        }
    }

    cout << best << "\n";

    return 0;
}


Measured memory_bytes: 1024