akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

int main()
{
  bool flag = false;
  int a, b;
  std::string s;

  std::cin >> a >> b;
  std::cin >> s;
  int i;
  for (i = 0; i < a; ++i) {
    if ( s[i] < '0' || s[i] > '9') {
      flag = true;
    }
  }
  if ( s[i] != '-') { flag = true;}
  ++i;
  int max = i + b;
  for (; i < max; ++i) {
    if ( s[i] < '0' || s[i] > '9') {
      flag = true;
    }
  }

  if (flag == false) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}


ll dp[3001][3001];
vector<ll> A;

ll dfs(int i, int j, int turn) {
    if (i > j) {
        return 0;
    }
    if (dp[i][j] != -1) return dp[i][j];
    if (turn == 0) {
        return dp[i][j] = max(A[i] + dfs(i + 1, j, 1 - turn), A[j] + dfs(i, j - 1, 1 - turn));
    } else {
        return dp[i][j] = min(dfs(i + 1, j, 1 - turn), dfs(i, j - 1, 1 - turn));
    }
}

void solve() {
    int N;
    cin >> N;
    A.resize(N);
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    for (int i = 0; i < 3001; i++) {
        for (int j = 0; j < 3001; j++) {
            dp[i][j] = -1;
        }
    }
    ll X = dfs(0, N - 1, 0);
    ll Y = sum - X;
    cout << X - Y << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
int main(){
	string a;
	cin >> a;
	long ans = 0;
	int l = a.size();
	for(int i = 0;i<l;i++)
	{
		ans +=(long)(a[i] -'0');
		ans=ans%9;
	}
	if(ans==0)
	{
		cout<<"Yes";
	}
	else{
		cout <<"No";
	}
}

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

int main() {
  vector<int> p;
  vector<P> q;
  rep(i,5){
    int c; cin >> c;
    if(c%10 == 0) p.push_back(c);
    else q.push_back({c%10,c});
  }
  sort(q.rbegin(), q.rend());
  
  int ans=0;
  rep(i,p.size()) ans += p[i];
  rep(i,q.size()-1) ans += 10 * ((q[i].second + 9) / 10);
  
  if(q.size() != 0) ans += q[q.size()-1].second;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3608
#include<iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>

unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

#define LOCAL  1
#define UPLOAD 2

using namespace std;

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

  int A, B;
  cin >> A >> B;

  if((A + B) % 2  == 0){
    cout << (A+B)/2 << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
gets; gets
s = gets.chomp.split('')
dominos = []
while s.length > 0
    if s[0] == s[1]
        dominos.push(2)
        s.shift(2)
    else
        dominos.push(1)
        s.shift
    end
end

ans = dominos[0] == 1 ? 3 : 6
prev = dominos[0]
dominos.shift

MOD = 10**9+7

dominos.each do |d|
    if prev == 1 && d == 1
        ans *= 2
    elsif prev == 1 && d == 2
        ans *= 2
    elsif prev == 2 && d == 2
        ans *= 3
    end
    ans %= MOD
    prev = d
end
puts ans

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

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var K = long.Parse(Console.ReadLine());
        long count = 0;

        for (int i = 0; i < S.Length; i++)
        {
            var num = S[i] - '0';
            if (num == 1)
            {
                count++;
                if (count == K)
                {
                    Console.WriteLine(1);
                    return;
                }
            }
            else
            {
                Console.WriteLine(num);
                return;
            }
        }

    }
}



Measured memory_bytes: 11092
N = int(input())
A = list(map(int,input().split()))
 
CurrentMoney = 1000

for i in range(N - 1):
    Stocks = 0
    if A[i] < A[i+1]:
        Stocks = CurrentMoney // A[i]
    CurrentMoney += (A[i + 1] - A[i]) * Stocks

print(CurrentMoney)

Measured memory_bytes: 9180
#include<stdio.h>
#include<math.h>
#define N 10000

int main(){
  int a[N],i,j,k=0,n,b=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
for(i=0;i<n;i++){
  if(a[i]%2==0){
    if(a[i]==2){
      k++;
    }
    continue;
  }else if(a[i]==1){
      k--;
    continue;
  }
  for(j=3;j<=sqrt(a[i]);j+=2){
    if(a[i]%j==0){
      k--;
      break;
    }
  }k++;
	}
  printf("%d\n",k);

	return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll r,d,x;
	cin>>r>>d>>x;
	rep(i,10){
		x=r*x-d;
		puta(x);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ull N;
	cin >> N;

	vector<ull> A(N, 0);
	for (int i = 0; i < N; ++i){
		cin >> A[i];
	}

	sort(A.rbegin(), A.rend());

	bool distinct = true;
	for (int ii = 0; ii < N-1; ++ii){
		if (A[ii] == A[ii+1]){
			distinct = false;
			break;
		}
	}

	if (distinct){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;		
	}

	return 0;
}


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

using namespace std;

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

    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        string op;
        int b, e;
        cin >> op;
        cin >> b >> e;
        if(op == "print"){
            cout << s.substr(b, e-b+1) << endl;
        }else{
            string x, y, z;
            x = s.substr(0, b);
            z = s.substr(e+1, s.size()-(e+1));
            if(op == "replace"){
                string r;
                cin >> y;
            }else{
                y = s.substr(b, e-b+1);
                reverse(y.begin(), y.end());
            }
            s = x + y + z;
        }
    } 
}


Measured memory_bytes: 3188
#include<stdio.h>

int main(void)
{
    char s[4];
    scanf("%s",s);
    if(s[0] == 'R')
    {
        if(s[1] == 'R')
        {
            if(s[2] == 'R')
            {
                printf("3\n");
                
            }
            else
            {
                printf("2\n");
            }
            
        }
        else
        {
            printf("1\n");
        }
        
    }
    else
    {
        if(s[1] == 'R')
        {
            if(s[2] == 'R')
            {
                printf("2\n");
                
            }
            else
            {
                printf("1\n");
            }
            
        }
        else
        {
            if(s[2] == 'R')
            {
                printf("1\n");
            }
            else
            {
                printf("0\n");
            }
            
        }
    }
    
    return 0;

}

Measured memory_bytes: 1648
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int[] a =new int [n];
		for (int i = 0;i < n; ++i){
			a[i] = Integer.parseInt(scan.next());
		}

		long[] sum_araiguma = new long[n-1];sum_araiguma[n-2]=a[n-1];
		long[] sum_sunuke = new long[n-1];sum_sunuke[0]=a[0];

		for(int i = 1;i < n-1; ++i){
			sum_sunuke[i]=sum_sunuke[i-1]+a[i];
			sum_araiguma[n-2-i]=sum_araiguma[n-1-i]+a[n-i-1];
		}

		long min=Long.MAX_VALUE;
		for (int i = 0;i < n-1; ++i){
			min=Math.min(Math.abs(sum_araiguma[i]-sum_sunuke[i]), min);
		}
		System.out.print(min);
	}
}
//end


Measured memory_bytes: 49004
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
typedef long long ll;
using namespace std;
int main() {
  bool flag1=false,flag2=false;
  ll n,ans1,ans2,p=0;
  cin >> n;
  vector<int> a(n),b(n),c2(n);            
  int c1[n];
  r(i,n)cin >> a[i];
  r(i,n)cin >> b[i];
  r(i,n)c1[i]=i+1;
  while(flag1==false||flag2==false){
    r(i,n)c2[i]=c1[i];
    if(equal(a.begin(),a.end(),c2.begin())){
      ans1=p; flag1=true;
    }
    if(equal(b.begin(),b.end(),c2.begin())){
      ans2=p; flag2=true;
    }
    next_permutation(c1,c1+n);
    p++;
  }
  cout<<abs(ans1-ans2)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i;i<n;i++)
using namespace std;
int main(){
  int a[5];
  r(i,5)cin>>a[i];
  sort(a,a+5);
  for(int i=4;i>=0;i--){
    cout<<a[i];
    if(!i)break;
    cout<<' ';
  }
  cout<<endl;
}

Measured memory_bytes: 3128
travel = input()
n = travel.count('N')
s = travel.count('S')
e = travel.count('E')
w = travel.count('W')

# print(f'N : {n}, S : {s}')
# print(f'E : {e}, W : {w}')

if n >= 1 and s == 0 or s >= 1 and n == 0 or e >= 1 and w == 0 or w >= 1 and e == 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<(a-c)*(b-d)<<endl;
	return 0;
}

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

using ll = long long;
const ll INF = 1e9;

const int MAXN = 2.1e5;
int N;
int X[MAXN];
int Y[MAXN];
pair<int, int> P[MAXN];
int minx[MAXN];
int maxx[MAXN];
int miny[MAXN];
int maxy[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i];
		if (X[i] > Y[i]) swap(X[i], Y[i]);
		P[i] = {X[i], Y[i]};
	}
	sort(P, P + N);
	for (int i = 0; i < N; i++) {
		tie(X[i],Y[i]) = P[i];
	}

	ll ans = ll(*max_element(X,X+N) - *min_element(X,X+N)) * ll(*max_element(Y,Y+N) - *min_element(Y,Y+N));
	int V = *max_element(Y,Y+N) - *min_element(X,X+N);
	miny[0] = INF;
	maxy[0] = -INF;
	for (int i = 0; i < N; i++) {
		miny[i+1] = min(miny[i], Y[i]);
		maxy[i+1] = max(maxy[i], Y[i]);
	}
	minx[N] = INF;
	maxx[N] = -INF;
	for (int i = N-1; i >= 0; i--) {
		minx[i] = min(minx[i+1], X[i]);
		maxx[i] = max(maxx[i+1], X[i]);
	}
	for (int i = 0; i <= N; i++) {
		ans = min(ans, ll(V)*ll(max(maxx[i],maxy[i]) - min(minx[i],miny[i])));
	}

	cout << ans << '\n';

	return 0;
}


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


int main(){
   int n,ans=1,k;
   cin>>n;
   for(int i=0;i<n;i++){
       scanf("%d",&k);
       if(k%2==0){
           if(k%5>0&&k%3>0){ans=0;break;}
       }
   }
   if(ans)printf("APPROVED\n");
   else printf("DENIED\n");
}

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




using namespace std;

int main() {
	string S;
	cin >> S;
	string T="CODEFESTIVAL2016";
	int ans = 0;
	for( size_t i = 0; i < 16; i++ ) {
		if( S[i] != T[i] ) {
			ans++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <functional>
#include <set>
#include <unordered_set>
#include <bitset>
#include <string>

using namespace std;


//x の最も下の立っているビットは，x & -x で取り 出せる
template <class T> class BIT{
    public:
    vector<T> array;
    const int n;
    
    public:
    //constractor
    BIT(int _n) : array(_n + 1, 0), n(_n){}
    
    //sum [0,i]
    T sum(int i){
        T s = 0;
        while(i > 0){
            s += array[i];
            i -= i & -i;
        }
        return s;
    }

    //sum [i,j]
    T sum(int i, int j){
        T ret_i = sum(i -1);
        T ret_j = sum(j);
        return ret_j - ret_i;
    }

    // 1-index
    void add(int i, T x){
        while(i <= n){
            array[i] += x;
            i += i & -i;
        }
    }
};

int N = 500100;

int main(){
    int n, Q; cin >> n >> Q;
    BIT<int> bit(N);

    vector<int> a(N+1,0);
    vector<vector<int>> ql(N+1);
    vector<vector<int>> qid(N+1);
    vector<int> ans(N+1, 0);

    vector<int> C(N+1);
    for(int i=1; i<=n; ++i){
        cin >> C[i];
    }

    for(int i=1; i<=Q; ++i){
        int l, r;
        cin >> l >> r;
        ql[r].push_back(l);
        qid[r].push_back(i);
    }

    for(int i=1; i<=n; ++i){
        if(a[C[i]] > 0) bit.add(a[C[i]], -1);
        bit.add(i, +1);
        a[C[i]] = i;
        for(int j=0; j<ql[i].size(); ++j){
            ans[qid[i][j]] = bit.sum(ql[i][j], i);
        }
    }

    for(int i=1; i<=Q; ++i){
        cout << ans[i] << endl;
    }
    return 0;
}



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

int main () {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    int ans = 0;
    for (int j = 0; j <= i; j++) {
      ans += A.at(j);
    }
    for (int j = i; j < N; j++) {
      ans += B.at(j);
    }
    count = max(count, ans);
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import heapq
n,k = map(int,input().split())
a = []
for i in range(n):
  heapq.heappush(a,tuple(map(int,input().split())))
while k:
  cur = heapq.heappop(a)
  if k <= cur[1]:
    print(cur[0])
    k = 0
  else:
    k -= cur[1]

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

#define ll long long

int main(){

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll x,k,d;
    cin>>x>>k>>d;
    x = abs(x);
    if(x/d>=k) {cout<<x-k*d; return 0;}
    ll a = x%d;
    ll b = abs(x%d-d);
    if((k-x/d)%2==0) cout<<a;
    else cout<<b;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[n-1-i];
    bool f = true;
    rep(i,n-1)if(a[i]<a[i+1])a[i+1]--;
    rep(i,n-1)if(a[i]<a[i+1])f = false;
    if(f)puts("Yes");
    else puts("No");
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll a,b;
  cin >> a>>b;
  
  cout << lcm(a,b) << endl;
  
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let mut a = i::iv(n);
    a.sort();
    a.reverse();
    let mut p = vec![0; n];
    p[0] = 1;
    for i in 1..n {
        p[i] = if i % 2 == 1 { -2 } else { 2 };
    }
    p[n - 1] /= 2;
    p.sort();
    p.reverse();
    let mut ans = 0;
    for i in 0..n {
        ans += a[i] * p[i];
    }
    let mut ans2 = 0;
    p.reverse();
    for i in 0..n {
        ans2 -= a[i] * p[i];
    }
    println!("{}", max(ans, ans2));
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int Bitnum(ll n) {
	int ans = 0;
	while (ans * (ans + 1) / 2 <= n)
		ans++;
	return ans - 1;
}

int main(void) {
	ll num, i, n = 0, ans, lim;
	cin >> num;
	lim = sqrt(num);
	while (!(num & 1)) {
		n++;
		num >>= 1;
	}
	ans = Bitnum(n);
	for (i = 3; i <= min(num, lim); i += 2) {
		n = 0;
		while (num % i == 0) {
			n++;
			num /= i;
		}
		ans += Bitnum(n);
	}
	if (num > 1)
		ans++;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
using namespace std;
int main(void){
    double r;
    
    cin >> r;
    
    double m = r*r*3.14159265358979;
    double e = 2*r*3.14159265358979;
    
    cout << fixed;
    cout << m <<" "<< e << endl;
    
    return 0;
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i;
  int sum;
  cin >> N ;
  for(i=1;i<=N;i++){
  int l,r;
    cin >> l >> r;
    sum += r-l+1;  
  }
      cout << sum <<endl;
}


Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template
#pragma region uft 1.0
struct uft
{
    vi p;
    vi s;

    uft() {}

    uft(ll n)
    {
        p.assign(n + 1, 0);
        REP1(i, n)
        {
            p[i] = i;
        }
        s.assign(n + 1, 1);
    }

    ll find(ll i)
    {
        if (p[i] == i)
        {
            return i;
        }
        p[i] = find(p[i]);
        return p[i];
    }

    void unite(ll i, ll j)
    {
        i = find(i);
        j = find(j);
        if (i == j)
        {
            return;
        }
        if (s[i] < s[j])
        {
            p[i] = j;
        }
        else
        {
            p[j] = i;
        }
        s[j] += s[i];
        s[i] = s[j];
    }

    bool same(ll i, ll j)
    {
        return find(i) == find(j);
    }

    ll size(ll i)
    {
        return s[find(i)];
    }
};
#pragma endregion uft

int main()
{
    IN(ll, N);
    IN(ll, M);
    A2IN(ll, A, ll, B, M);
    uft uft(N);
    REP(i, M)
    {
        uft.unite(A[i], B[i]);
    }
    ll ans = 0;
    REP1(i, N)
    {
        CH(max, ans, uft.size(i));
    }
    OUT(ans);
}

Measured memory_bytes: 9528
#include <stdio.h> /*C++Åà¯éæ¤ÉAûKµÄ¨±¤B*/

int main()
{
	int list[31], /*list[0]ÍgíÈ¢*/
		n=0,			/*üÍ³ê½Ô,numberÌÛ*/
		i;
	for(i=1; i<=30; i++) list[i] = 0; /*¢ño,falthðZbg*/
	
	while(scanf("%d",&n)!=EOF) list[n] = 1;	/*üÍ³ê½,true*/
	
	for(i=1; i<=30; i++)
		if(list[i] == 0)
			printf("%d\n",i);
	
	return 0;
}

Measured memory_bytes: 0
import collections

n = int(input())
li = list()

for i in range(n):
    li.append(input())

key = list(collections.Counter(li).keys())
value = list(collections.Counter(li).values())
ans = list()
maxValue = max(value)

for i in range(len(value)):
    if maxValue == value[i]:
        ans.append(key[i])

for i in sorted(ans):
    print(i)

Measured memory_bytes: 119376
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int H,W;
int func(vector<string> HW ,int i, int j) {
	for (int k = 0; k < W; k++) {
		if (j & (1 << k)) {
			for (int l = 0; l < H; l++) {
				HW[l][k] = 'a';
			}
		}
	}

	for (int k = 0; k < H; k++) {
		if (i & (1 << k)) {
			for (int l = 0; l < W; l++) {
				HW[k][l] = 'a';
			}
		}
	}
	
	int cnt = 0;
	for (int k = 0; k < H; k++) {
		for (int l = 0; l < W; l++) {
			if (HW[k][l] == '#') {
				cnt++;	
			}
		}
	}
	return cnt;
}

int main(int argc, char *argv[]) {
	
	cin >> H >> W;
	int K; cin >> K;

	vector<string> HW(H);
	for (int i = 0; i < H; i++) {
		cin >> HW[i];
	}

	int ans = 0;

	for (int i = 0; i < (1 << H); i++) {
		for (int j = 0; j < (1 << W); j++) {
			int cnt = func(HW,i,j);
			if (cnt == K) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	
	



	return 0;
}


Measured memory_bytes: 3632
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

char a[1010][1010];
ll dp[1010][1010];

int
main(void){  
  int h, w;
  cin >> h >> w;
  REP(i, h) REP(j, w) cin >> a[i][j];

  dp[0][0] = 1;
  REP(i, h) REP(j, w){
    if(i+1 <= h && a[i][j] == '.') dp[i+1][j] = ADD(dp[i+1][j], dp[i][j]);
    if(j+1 <= w && a[i][j] == '.') dp[i][j+1] = ADD(dp[i][j+1], dp[i][j]);
  }

  cout << dp[h-1][w-1] << endl;
  
  return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,j=0;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i];
    }
    for(int i = n-1;i >= 0;i -= 2){
        cout << a[i] << " ";
    }
    if(n%2) j=1;
    for(int i = j;i < n;i +=2){
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3712
import sys
input = sys.stdin.readline
from itertools import accumulate
from functools import reduce
from operator import xor, add


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    S = reduce(xor, A)
    for a in A:
        print(S ^ a, end=" ")


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 31856
#include <iostream>

using namespace std;

int nums[1000000];

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

	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}

	int minimum = nums[0];
	int total_ints = 1;
	for(int i = 1; i < n; i++) {
		if(minimum < nums[i]) {
		} else {
			total_ints++;
			minimum = min(nums[i], minimum);
		}
	}

	cout << total_ints;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define maxlen 100001
#define inf INT_MAX
using namespace std;

int h,n,ans=inf;
int a[maxlen],cost[maxlen],dp[maxlen];

signed main()
{
	cin>>h>>n;
	for (int i=0;i<n;i++)  cin>>a[i]>>cost[i];
	
	for (int i=0;i<maxlen;i++)  dp[i]=inf;
	dp[0]=0;
	for (int i=0;i<n;i++)
	{
		for (int j=a[i];j<maxlen;j++)  dp[j]=min(dp[j],dp[j-a[i]]+cost[i]);
	}
	for (int i=h;i<maxlen;i++)  ans=min(ans,dp[i]);
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 1024
N=int(input())
A=list(map(int,input().split()))
D=[0]*3
ans=1
for i in A:
  c=0
  E=[]
  if i==D[0]:
    c+=1
    E.append(0)
  if i==D[1]:
    c+=1
    E.append(1)
  if i==D[2]:
    c+=1
    E.append(2)
  if c==0:
    print(0)
    exit()
  D[E[0]]+=1
  ans*=c
  ans%=10**9+7
print(ans)
    

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

using namespace std;

#define int long long

const int   N   = 5e5 + 1;
const int   B   = 1e8 + 1;

typedef pair<int,int>   ii;
typedef pair<ii,ii>     pii;

int qpow(int a,int exp,int mod) {
    if(exp < 0) exp = mod - 1 + exp;
    int ans = 1;
    while (exp) {
        if(exp & 1) ans = ans * a % mod;
        a = a * a % mod;  exp >>= 1;
    }
    return ans;
}

void add(int &a,int b,int mod) {
    a += b;
    if(a >= mod)a -= mod;
    if(a < 0)   a += mod;
}

int mod[4];
int n, f[N];
int H[N][4];
string S;

void process(int t)   {
    for(int i = 1 ; i <= n ; ++i)   {
        H[i][t] = H[i - 1][t];
        if(S[i - 1] == '+') add(H[i][t], qpow(B,f[i],mod[t]),mod[t]);
        if(S[i - 1] == '-') add(H[i][t],-qpow(B,f[i],mod[t]),mod[t]);
    }
}

map<pii,int> mp;

signed main()   {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n >> S;

    for(int i = 0 ; i < n ; ++i)    {
        f[i + 1] = f[i];
        if(S[i] == '>') f[i + 1]++;
        if(S[i] == '<') f[i + 1]--;
    }

    mod[0] = 1e9 + 7;
    mod[1] = 1e9 + 9;
    mod[2] = 1e9 + 21;
    mod[3] = 1e9 + 33;

    process(0);
    process(1);
    process(2);
    process(3);

    mp[pii({H[n][0],H[n][1]},{H[n][2],H[n][3]})] = 1;

    int ans = 0;

    for(int i = 1 ; i <= n ; ++i)   {
        ans += mp[pii({H[i][0],H[i][1]},{H[i][2],H[i][3]})];
        int res0 = H[n][0] * qpow(B,f[i],mod[0]) + H[i][0];
        int res1 = H[n][1] * qpow(B,f[i],mod[1]) + H[i][1];
        int res2 = H[n][2] * qpow(B,f[i],mod[2]) + H[i][2];
        int res3 = H[n][3] * qpow(B,f[i],mod[3]) + H[i][3];
        res0 %= mod[0]; res1 %= mod[1];
        res2 %= mod[2]; res3 %= mod[3];
        mp[pii({res0,res1},{res2,res3})]++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 51860
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

import java.io.BufferedReader;
import java.io.FileReader;

public class Main{
	
	public static void main(String[] args) throws IOException, InterruptedException {
		
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		String string = sc.next();
		
		int n = string.length();
		
		int[] a = new int[n];
		
		for (int i = 0; i < n; i++) {
			if (string.charAt(i) == 'R') {
				a[i] = 1; 
			}
		}
		
		int[] rightForLeft = new int[n];
		int c = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == 0) {
				rightForLeft[i] = c;
				c = 0;
			}
			else {
				c++;
			}
		}
		
		
		int[] leftForRight = new int[n];
		
		c = 0;
		for (int i = n-1; i >= 0; i--) {
			if (a[i] == 1) {
				leftForRight[i] = c;
				c = 0;
			}
			else {
				c++;
			}
		}
		int[] ans = new int[n];
		for (int i = 0; i < n; i++) {
			if (i > 0 ) {
				if (rightForLeft[i]%2 == 0) {
					ans[i] += rightForLeft[i]/2;
					ans[i-1] += rightForLeft[i]/2;
				}
				else {
					ans[i] += rightForLeft[i]/2;
					ans[i-1] += (rightForLeft[i]/2)+1;
				}
			}
				
			
			if (i < n-1) {
				if (leftForRight[i]%2 == 0) {
					ans[i] += leftForRight[i]/2;
					ans[i+1] += leftForRight[i]/2;
				}
				else {
					ans[i] += leftForRight[i]/2;
					ans[i+1] += (leftForRight[i]/2)+1;
				}
			}
				
			
			
		}
		
		
		for (int i = 0; i < n; i++) {
			out.print(ans[i]+" ");
		}
		
		
		
		out.flush();
	}
		
}	
	
class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}
	
	public Scanner (String file) throws IOException{
        br=new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

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

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

	public char nextChar() throws IOException {
		return next().charAt(0);
	}

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

	public boolean ready() throws IOException {
		return br.ready();
	}

	public void waitForInput() throws InterruptedException {
		Thread.sleep(3000);
	}


}



Measured memory_bytes: 38160
a, b = map(int, input().split())

N = b - a + 1

if a%2 == 0:
    if N%4 == 0:
        print(0)
    elif N%4 == 1:
        print(b)
    elif N%4 == 2:
        print(1)
    else:
        print(b + 1)
else:
    if N%4 == 0:
        print(a ^ b ^ 1)
    elif N%4 == 1:
        print(a)
    elif N%4 == 2:
        print(a ^ b)
    else:
        print(a ^ 1)

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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 N, i;
  cin >> N;
  string X;
  cin >> X;

  i64 C = 0;
  REP(0, N, i) {
    if(X[i] == '1')
      C++;
  }

  if(C == 0) {
    REP(0, N, i) {
      cout << 1 << endl;
    }
  }
  else {
    reverse(all(X));
    vi Rp(N), Rn(N);
    Rp[0] = 1 % (C+1);
    if(C != 1) {
      Rn[0] = 1 % (C-1);
    }
    REP(1, N, i) {
      Rp[i] = (Rp[i-1] * 2) % (C+1);
      if(C != 1) {
	Rn[i] = (Rn[i-1] * 2) % (C-1);
      }
    }

    i64 Ip = 0, In = 0;
    REP(0, N, i) {
      if(X[i] == '1') {
	Ip += Rp[i]; Ip %= (C+1);
	if(C != 1) {
	  In += Rn[i]; In %= (C-1);
	}
      }
    }

    vi ans(N, 1);
    REP(0, N, i) {
      i64 res, CC;
      if(X[i] == '1') {
	if(C == 1) {
	  ans[i] = 0;
	  continue;
	}
	// popcnt -= 1	
	CC = C-1;
	res = (In - Rn[i] + CC) % CC;
      }
      else {
	// popcnt += 1
	CC = C+1;
	res = (Ip + Rp[i] + CC) % CC;
      }
      while(res != 0) {
	res = res % bitset<64>((unsigned long long)res).count();
	ans[i]++;
      }
    }

    REP(0, N, i) {
      cout << ans[N-1-i] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 8408
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;
vector<vector<int>> vec;
vector<vector<int>> dp;
int h, w;
void rec(int y, int x)
{
    if (vec[y][x] == '#')
        return; //壁だったら考えるまでもないです
    if (y >= 1)
    {
        if (vec[y][x] == '.')
        {
            dp[y][x] += dp[y - 1][x];
            dp[y][x] %= MOD;
        }
    }
    if (x >= 1)
    {
        if (vec[y][x] == '.')
        {
            dp[y][x] += dp[y][x - 1];
            dp[y][x] %= MOD;
        }
    }
}
int main()
{
    cin >> h >> w;
    vec.resize(h, vector<int>(w));
    dp.resize(h, vector<int>(w));
    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++){
            vec[i][j] = s[j];
        }
    }
    dp[0][0] = 1;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            rec(i, j);
        }
    }
    cout << dp[h - 1][w - 1] % MOD << endl;
}


Measured memory_bytes: 8192
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String ans = "";
		for (int i = 0; i < 3; i++)
			ans += sc.next().charAt(0);
		
		System.out.println(ans);
		
		sc.close();
	}
}



Measured memory_bytes: 26996
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, q;
  cin>>n>>q;
  vector<vector<int> > A(n);
  while(q--){
    int cmd;
    cin>>cmd;
    
    if(cmd == 0){
      int t, x;
      cin>>t>>x;
      A[t].push_back(x);
    }
    if(cmd == 1){
      int t;
      cin>>t;
      cout<<A[t]<<endl;
    }
    
    if(cmd == 2){
      int t;
      cin>>t;
      A[t].clear();
    }
  }

  return 0;
}



Measured memory_bytes: 8928
import java.util.Scanner

import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer

object Main {


  def read() = {
    val sc = new Scanner(System.in)
    val n, k = sc.nextInt()
    (n, k)
  }


  def solve(n: Int, k: Int): Double = {
    val nCoins = for (initPoint <- (1 to n)) yield {
      // initPoint: サイコロの目
      // nCoin: min [x | p * 2^x>= k]
      //

      @tailrec
      def calcNumCoin(point: Int, nCoin: Int): Int = {
        assert(point >= 1)
        assert(nCoin >= 0)
        if (point >= k) nCoin
        else calcNumCoin(point * 2, nCoin + 1)
      }

      calcNumCoin(initPoint, 0)
    }
    nCoins.map(k => math.pow(0.5, k)).sum/n
  }

  def main(args: Array[String]): Unit = {
    val (n, k) = read()
    val result = solve(n, k)
    println(result)
  }
}

Measured memory_bytes: 39092
s = input()

q = int(input())
a = [input().split() for l in range(q)]
flag =0
c=0
start=""
finish=""
for i in range(0,q):
    if a[i][0]=='1':
        flag +=1
        c=flag%2
    else:
        if a[i][1]=='1':
            if c==0:
                start = a[i][2] + start
            else:
                finish = finish + a[i][2]
        else:
            if c==0:
                finish = finish +a[i][2]
            else:
                start = a[i][2] + start
ans = start + s + finish
if c==0:
    print(ans)
else:
    ans=ans[::-1]
    print(ans)

Measured memory_bytes: 41464
#include <stdio.h>

int main(void){

    int a,b,c,i,x;
    scanf("%d %d %d",&a,&b,&c);
    x = 0;

    for( i=a ; i<=b; i++){
      if( c % i == 0 ){
        x++;
       }
    }
     printf("%d\n",x);
    

    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
using namespace std;
int main()
{
        long long int n,sum = 0;
        cin >> n;
        vector<int> a(n + 1);
        vector<int> b(n);
        for (int i = 0; i < n + 1; i++)
                cin >> a[i];
        for (int i = 0; i < n; i++)
                cin >> b[i];
        for (int i = 0; i < n; i++)
        {
                //ith town
                if (a[i] >= b[i])
                {
                        sum += b[i];
                        a[i] -= b[i];
                        b[i] = 0;
                }
                else
                {
                        sum += a[i];
                        b[i] -= a[i];
                        a[i] = 0;
                }
                //ith + 1 town
                if (a[i + 1] >= b[i])
                {
                        sum += b[i];
                        a[i + 1] -= b[i];
                        b[i] = 0;
                }
                else
                {
                        sum += a[i + 1];
                        b[i] -= a[i + 1];
                        a[i + 1] = 0;
                }

        }
        cout << sum << endl;
        return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


vector<int> num;
int a[3] = {3,5,7};
void f(int x) {
  vector<int> aa = {0}, bb;
  bool ok = true;
  while(ok) {
    for(auto p : aa) {
      rep(i,3) {
        int mm = p*10+a[i];
        if(mm>x) {
          ok = false;
          break;
        }
        num.push_back(mm);
        bb.push_back(mm);
      }
    }
    aa = bb;
    bb.erase(rng(bb));
  }
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  f(n);
  for(auto i : num) {
    int m = i;
    int b[10];
    memset(b,0,sizeof(b));
    while(m>0) {
      b[m%10]++;
      m /= 10;
    }
    if(b[3]>0&&b[5]>0&&b[7]>0) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;

const double EPS = 1e-10;

const int M = 2;
int a[M][M], b[M][M], w[M][M];
int n;

//???????£?
//recursive function(with/without memo)

void multiple_mat_ab_b() {
  int i, j, k;
  memset(w, 0, sizeof(w));
  for (i=0; i<M; i++)
    for (j=0; j<M; j++)
      for (k=0; k<M; k++)
        w[i][j] += a[i][k]*b[k][j];

  for (i=0; i<M; i++)
    for (j=0; j<M; j++)
        b[i][j] = w[i][j];
}

void multiple_mat_aa_a() {
  int i, j, k;
  memset(w, 0, sizeof(w));
  for (i=0; i<M; i++)
    for (j=0; j<M; j++)
      for (k=0; k<M; k++)
        w[i][j] += a[i][k]*a[k][j];

  for (i=0; i<M; i++)
    for (j=0; j<M; j++)
        a[i][j] = w[i][j];
}

void pow_mat_a(int k) {
  a[0][0] = a[0][1] = a[1][0] = 1;
  a[1][1] = 0;

  b[0][0] = b[1][1] = 1;
  b[0][1] = b[1][0] = 0;

  while (k) {
    if (k & 1) multiple_mat_ab_b();
    multiple_mat_aa_a();
    k >>= 1;
  }
}

int main() {
  scanf("%d ", &n);
  pow_mat_a(n);
  printf("%d\n", b[1][0]+b[1][1]);

	return 0;
}

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

int main () {
	int n, x = 0, mx = 0;
	string s;
	cin >> n >> s;

	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') x++;
		else x--;
		mx = max(mx, x);
	}
	cout << mx << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    int n, m, w, t;
    cin >> n >> m >> w >> t;
    unordered_map<string, int> dic;
    vector<int> v(m);
    vector<int> p(m);
    for (int i = 0; i < m; ++i) {
        string s;
        cin >> s >> v[i] >> p[i];
        dic.insert({s, i});
    }
    vector<P> places(n);
    vector<vector<int>> prices(n, vector<int>(m, 10010));
    for (int i = 0; i < n; ++i) {
        int l, x, y;
        cin >> l >> x >> y;
        places[i] = P(x, y);
        for (int j = 0; j < l; ++j) {
            string s;
            int q;
            cin >> s >> q;
            prices[i][dic[s]] = q;
        }
    }
    vector<long long> dp(t + 1);
    for (int i = 1; i < (1 << n); ++i) {
        vector<int> towns;
        int sz = 0;
        for (int j = 0; j < n; ++j) {
            if ((i >> j) & 1) {
                towns.push_back(j);
                ++sz;
            }
        }
        int d = M;
        do {
            int dis = abs(places[towns[0]].first) + abs(places[towns[0]].second) + abs(places[towns[sz - 1]].first) + abs(places[towns[sz - 1]].second);
            for (int i = 0; i < sz - 1; ++i)
                dis += abs(places[towns[i + 1]].first - places[towns[i]].first) + abs(places[towns[i + 1]].second - places[towns[i]].second);

            d = min(d, dis);
        } while (next_permutation(towns.begin(), towns.end()));

        if (d > t) continue;

        vector<int> benef(m);
        for (auto& j : towns)
            for (int k = 0; k < m; ++k)
                benef[k] = max(benef[k], p[k] - prices[j][k]);

        vector<int> dp2(w + 1);
        for (int j = 0; j < m; ++j)
            for (int k = v[j]; k <= w; ++k)
                dp2[k] = max(dp2[k], dp2[k - v[j]] + benef[j]);

        dp[d] = max(dp[d], (long long)dp2[w]);
    }
    vector<int> inis;
    for (int i = 0; i <= t; ++i)
        if (dp[i] > 0)
            inis.push_back(i);

    for (int i = 1; i <= t; ++i) {
        dp[i] = max(dp[i], dp[i - 1]);
        for (auto& j : inis) {
            if (j >= i) continue;
            dp[i] = max(dp[i], dp[i - j] + dp[j]);
        }
    }
    cout << dp[t] << "\n";
    return 0;
}



Measured memory_bytes: 3332