akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	for(int i=0;i<tx-sx;i++)cout<<"R";
	// cout<<endl;
	for(int i=0;i<ty-sy;i++)cout<<"U";
	// cout<<endl;
	for(int i=0;i<tx-sx;i++)cout<<"L";
	// cout<<endl;
	for(int i=0;i<ty-sy;i++)cout<<"D";
	// cout<<endl;
	cout<<"D";
	// cout<<endl;
	for(int i=0;i<tx-sx+1;i++)cout<<"R";
	// cout<<endl;
	for(int i=0;i<ty-sy+1;i++)cout<<"U";
	// cout<<endl;
	cout<<"L";
	cout<<"U";
	for(int i=0;i<tx-sx+1;i++)cout<<"L";
	// cout<<endl;
	for(int i=0;i<ty-sy+1;i++)cout<<"D";
	// cout<<endl;
	cout<<"R";
}

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

int main() {
	int e,i,j,k,l,n,count,p,q,z;
	cin >>  n ;
	z=sqrt(n);
	z=z+2;
  vector<int> vec(100000);
  for (p = 0; p < 100000; p++) {
   vec.at(p)=0;
  }

	for (i = 1; i < z; i++) {
    	for (j = 1; j <z; j++) {
    	for (k = 1; k < z; k++) {
    		e=i*i+j*j+k*k+i*j+j*k+k*i;
		 vec.at(e)=vec.at(e)+1;
 	 }
 	 }
	 }
for (i = 1; i < n+1; i++) {
cout << vec.at(i) << endl;
}
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    
    int cnt = scan.nextInt();
    while (cnt != 0) {
      int[] dp = new int[cnt];
      int[] res = new int[cnt];
      Arrays.fill(dp, Integer.MIN_VALUE);
      Arrays.fill(res, Integer.MIN_VALUE);
      
      dp[0] = scan.nextInt();
      res[0] = dp[0];
      for (int i = 1; i < cnt; i++) {
        int v = scan.nextInt();
        dp[i] = Math.max(v, dp[i-1] + v);
        res[i] = Math.max(res[i-1], dp[i]);
      }
      
      System.out.println(res[cnt-1]);
      cnt = scan.nextInt();
    }
  }
}



Measured memory_bytes: 34336
#include <iostream>
#include <limits>
 
using namespace std;
 
class Die {
  public:
  int f1, f2, f3, f4, f5, f6;
    Die(int f1, int f2, int f3, int f4, int f5, int f6)
      :f1{f1}, f2{f2}, f3{f3}, f4{f4}, f5{f5}, f6{f6} {}
  void manipulate(char move) {
    if (move == 'N') {
      auto tmp = f5;
      f5 = f1;
      f1 = f2;
      f2 = f6;
      f6 = tmp;
    } else if (move == 'S') {
      auto tmp = f6;
      f6 = f2;
      f2 = f1;
      f1 = f5;
      f5 = tmp;
    } else if (move == 'E') {
      auto tmp = f3;
      f3 = f1;
      f1 = f4;
      f4 = f6;
      f6 = tmp;
    } else { // move == 'W'
      auto tmp = f4;
      f4 = f1;
      f1 = f3;
      f3 = f6;
      f6 = tmp;
    }
  }
  int get_right() { return f3; }
};

int main()
{
  int f1, f2, f3, f4, f5, f6;
  cin >> f1 >> f2 >> f3 >> f4 >> f5 >> f6;
  cin.get();
  cin.ignore(numeric_limits<streamsize>::max(), '\n');

  int top, front;
  while (cin >> top >> front) {
    Die d(f1, f2, f3, f4, f5, f6);
    if (top == d.f3 or top == d.f4) // right or left side to top
      while(top != d.f1)
        d.manipulate('W');  // side rotation
    else
      while(top != d.f1)
        d.manipulate('N');  // backward rotation
    // post: top is correct
    if (front == d.f2)
      cout << d.f3;
    else if (front == d.f3)
      cout << d.f5;
    else if (front == d.f5)
      cout << d.f4;
    else // front == d.f4
      cout << d.f2;
    cout << endl;
  }
}


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

int main() 
{
   int A, B, K;
   cin >> A >> B >> K;

   for (int i = 0; i < K; i++)
   {
      if (i % 2 == 0)
      {
         if (A % 2 == 0)
            A /= 2;
         else
            A = (A - 1) / 2;
         B += A;
      }
      else
      {
         if (B % 2 == 0)
            B /= 2;
         else
            B = (B - 1) / 2;
         A += B;
      }
   }
   cout << A << ' ' << B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<vector<ll>> dp(n, vector<ll>(1<<n,-1));
    // vector<vector<set<ll> > > candidates(2,vector<set<ll>(n,set<ll>()));
    vector<int> candidates(n,0);
    rep(i,n){
        rep(j,n){
            int tmp;cin>>tmp;
            candidates[i] |= ((tmp<<j));
        }
    }
    function<ll(int,int)> solve = [&](int num, int women){
        if(dp[num][women]!=-1){return dp[num][women];}
        ll res = 0;
        int match = candidates[num] & women;
        DEBUG{
            printf("num: %d, match: %d\n",num,match);
        }
        if(match==0){return dp[num][women] = 0;}
        if(num==n-1&&match!=0){
            return dp[num][women] = 1;
        }
        rep(i,n){
            if(match>>i&1){
                res += solve(num+1,women^(1<<i)); 
                res %= MOD;
            }
        }
        return dp[num][women] = res;
    };
    cout << solve(0,(1<<n)-1) << endl;
    return 0;
}


Measured memory_bytes: 360832
h,w = (int(i) for i in input().split())

arr = [[(-1 if i=='#' else 0) for i in input()] for j in range(h)]

metWall = False
for j in range(w):
    if metWall:
        arr[0][j] = 0
    else:
        if (arr[0][j]==-1):
            arr[0][j] = 0
            metWall = True
        else:
            arr[0][j] = 1

for i in range(1,h):
    for j in range(w):
        this = arr[i][j]
        if this==-1:
            arr[i][j] = 0
        else:
            arr[i][j] = (arr[i][j-1] if j>0 else 0)+arr[i-1][j]

print(arr[-1][-1]%1000000007)


Measured memory_bytes: 157308
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num_values = in.nextInt();
		int[] values = new int[num_values];
		for(int i = 0; i < num_values; i++) {
			values[i] = in.nextInt();
		}
		in.close();
		int maxp = values[1] - values[0];
		int minv = min(values[1], values[0]);
		for(int i = 2; i < num_values; i++) {
			// maxp = values[i] - minv;
			maxp = max(maxp, values[i] - minv);
			minv = min(minv, values[i]);
		}
		System.out.println(maxp);
	}
	
	public static int max(int x, int y) {
		if(x > y)
			return x;
		else return y;
	}
	
	public static int min(int x, int y) {
		if(x > y)
			return y;
		else return x;
	}
	
}


Measured memory_bytes: 101336
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, char> Pc;
typedef pair<int, string> Ps;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int N;
  cin >> N;
  while (N > 0) {
    if (N % 10 == 7) {
      cout << "Yes" << endl;
      return 0;
    }
    N /= 10;
  }
  cout << "No" << endl;

  return 0;
}


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

#define ll long long

int main() {
	ll n, ans=0, c=0;
	cin >> n;
	ll a[n];
	for(int i=0; i<n; ++i)
		cin >> a[i];
	for(int i=0; i<n; ++i) {
		if(a[i]<c) {
			ans+=c-a[i];
		} else {
			c=a[i];
		}
	}
	cout << ans << "\n";
}


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

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


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e2, ksz = 1e5;
int n, k, a[nsz + 5], dp[ksz + 5][2];

bool inline dfs(int me, int k) {
    if (dp[k][me] != -1)  return dp[k][me];
    if (k < a[1])  return dp[k][me] = 0;
    bool win = 0;
    cont (i, n) {
        if (k - a[i] >= 0) {
            win |= !dfs(!me, k - a[i]);
        }
    }
    return dp[k][me] = win;
}

int main() {
    ios::sync_with_stdio(0);
    cin >> n >> k;
    cont (i, n) {
        cin >> a[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << (dfs(0, k) ? "First" : "Second") << ln;
}

Measured memory_bytes: 4736
import math
N,M = map(int,input().split())
S = input()
T = input()
G = math.gcd(N,M)
a,b = N//G,M//G
S = S[0::a]
T = T[0::b]
if S == T:
    print(a*b*G)
else:
    print(-1)

Measured memory_bytes: 9232
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

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


int main(){
  ll n; cin >> n; map<string,ll> table; ll sum = 0;
  
  for(ll i=0; i < n; i++){
    string s; cin >> s; sort(all(s));
    if(table.count(s)){
      table[s]++; sum += table[s];
    }
    else table[s] = 0;
    
  }
  
  cout << sum << endl;
}
      
  
  

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

int countOk(int r, int c, vector<vector<int> > v){
    int sum = 0;
    for(int j=0; j<c; j++){
        int count = 0;
        for(int i=0; i<r; i++){
            if(v[i][j] == 1) count++;
        }
        sum += max(count, r-count);
    }
    return sum;
}

int solve(int r, int c, int idx, vector<vector<int> > v){
    if(idx >= r) return countOk(r, c, v);
    vector<vector<int> > vv = v;
    for(int i=0; i<c; i++){
        vv[idx][i] *= -1;
    }
    return max(solve(r, c, idx+1, v), solve(r, c, idx+1, vv));
}


int main(void){
    // Your code here!
    while(1){
        int r, c; cin >> r >> c;
        if(!r && !c) break;
        vector<vector<int> > a;
        a.resize(r);
        for(int i=0; i<r; i++){
            a[i].resize(c);
            for(int j=0; j<c; j++){
                cin >> a[i][j];
                if(a[i][j] == 0) a[i][j] = -1;
            }
        }
        
        cout << solve(r, c, 0, a) << endl;
    }    
}



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

int main(void) {
  int r;
  cin >> r;
  if (r < 1200)
    cout << "ABC" << endl;
  else if (1200 <= r && r < 2800)
    cout << "ARC" << endl;
  else
    cout << "AGC" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	bool graph[n][n];
	for( int i = 0; i < n; ++i ){
		for(  int j = 0; j < n; ++j ){
			graph[i][j] = false;
		}
	}
	for( int i = 0; i < m; ++i ){
		int x, y;
		cin >> x >> y;
		--x; --y;
		graph[x][y] = true;
		graph[y][x] = true;
	}
	vector<int> v(n-1);
	iota(v.begin(), v.end(), 1);
    int ans = 0;
	do {
		bool flag = true;
		if( !graph[0][v.at(0)] ){
			continue;
		}
		for( int i = 0; i < n-2; ++i ){
			if( !graph[v.at(i)][v.at(i+1)] ){
				flag = false;
				break;	
			}
		}
		if( flag ) ++ans;
    } while( next_permutation(v.begin(), v.end()) );
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long a_min;
  long a_max;
  long b_min;
  long b_max;
  long multiplied_num;
  long max_ans;
  long i,j;
  // 変数aで入力を受け取る
  cin >> a_min >>  a_max >> b_min >>b_max;
  max_ans = a_min * b_min;
  long a[] = {a_min,a_max};
  long b[] = {b_min,b_max};
  for (i=0;i<2;i++){
    for(j=0;j<2;j++){
		multiplied_num = a[i]*b[j];
      	
      	if (max_ans < multiplied_num){
          max_ans = multiplied_num;
        }
      
    }
  }
	 
  
  
  cout << max_ans << endl;
}


Measured memory_bytes: 3588
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                Map hs = new HashMap();
                int n = sc.nextInt();
                int k = sc.nextInt();
                sc.close();
                System.out.println((n + k + 1) / 2);
        }
}

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

using namespace std;

int main() {
#ifdef _DEBUG
	freopen("_in" , "r", stdin );
	freopen("_out", "w", stdout);
#endif
	int n; cin >> n;
	cout << fixed << setprecision(10);
	if (n % 2 == 0) cout << "0.5000000000\n";
	else cout << (n / 2 + 1) / double(n) << '\n';
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    int S, l; 

    do {
        cin >> a >> b;
    } while ((a < 1 || a > 100) || (b < 1 || b > 100));

    S = a * b;
    l = a * 2 + b * 2;

    cout << S << " " << l << endl;
        
    return (0);
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(6);
  int n;
  cin >> n;
  double num = 1.0 * n / 3;
  cout << num * num * num << '\n';
  return 0;
}

Measured memory_bytes: 256
// Xが10^9だから Xでループ系ではない
// 計算式でばっちりでるか、AやらBやらでループするかの選択肢しかない
//
// A^5とかで簡単に 10^9に到達しそうなのでがんばれるだけループ回すかという感じ

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

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

  ll x;
  cin >> x;
  // 3.6 x 10^5 くらいだしいけるやろ
  for(int i = -300; i <= 300; i++) {
    for (int j = -300; j <= 300; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j<< endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4084
#-------------
N = int(input())
T,A = map(int, input().split())
H =list(map(int, input().split()))
#-------------
Temp = []

for i in range(N) :
  Temp.append(T-0.006*H[i]-A)

Temp_abs=[]
for i in range(N) :
  Temp_abs.append(abs(Temp[i]))

cnt =1
for i in range(N):
  if min(Temp_abs) != Temp_abs[i]:
    cnt+=1
  else:
    print(cnt)

Measured memory_bytes: 9284
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	string s;
	cin>>s;
	int n = s.size()+1;
	int dp[n+1]={0};
	for(int i=0;i<n-1;i++){
		if(s[i]=='<'){
			dp[i+1]=max(dp[i+1],dp[i]+1);
		}
	}
	for(int i=n-2;i>=0;i--){
		if(s[i]=='>'){
			dp[i] = max(dp[i],dp[i+1]+1);
		}
	}
	ll sum=0;
	for(int i=0;i<n;i++){
		sum+=dp[i];
	}
	cout<<sum<<endl;
	//cout<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int dfs(int,string);
int n;string s;
string good="AGCT";
int main(){
    cin>>s;
    n=(int)s.size();
    cout<<dfs(0,s);
}
int dfs(int depth,string tmp){
    if(depth==n)return 0;
    int now=(int)tmp.size();
    bool flag2=true;
    rep(i,now){
        bool flag=false;
        rep(j,4){
            if(tmp[i]==good[j])flag=true;
        }
        if(!flag){
            flag2=false;
            break;
        }
    }
    int res;
    if(flag2)return now;
    else{
        string next1=tmp;
        string next2=tmp;
        next1.erase(next1.begin()+0);
        next2.pop_back();
        res=max(dfs(depth+1,next1),dfs(depth+1,next2));
    }
    return res;
}


Measured memory_bytes: 256
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}
namespace IO{
    char nc(){ static char bf[100000],*p1=bf,*p2=bf; return p1==p2&&(p2=(p1=bf)+ fread(bf,1,100000,stdin),p1==p2)?EOF:*p1++; }
    int rd(){ int res=0; char c=getchar(); while(!isdigit(c))c=getchar(); while(isdigit(c))res=res*10+c-'0',c=getchar(); return res; }
}/*}}}*/
/******************heading******************/
#define int lld
const int N=1e5+50,P=1e9+7;

int n;
char s[N*2];
int ans=1,tot;

signed main(){
    scanf("%lld",&n);
    scanf("%s",s+1);
    int cur=0;
    FOR(i,1,n*2)s[i]=s[i]=='B';
    tot=1;
    FOR(i,1,n)tot=tot*i%P;
    FOR(i,1,n*2){
        if((cur&1)==s[i])ans*=cur,ans%=P,cur--;
        else cur++;
        //if(cur<0)return puts("0"),0;
        //printf("cur=%lld\n",cur);
    }
    if(cur)return puts("0"),0;
    printf("%lld",ans*tot%P);
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.util.LinkedList;
import java.lang.Math;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Long x = sc.nextLong();

        long c500 = x/500;
        long c5 = (x-c500*500)/5;
        long iei = 1000*c500 + 5*c5;

        System.out.print(iei);

    }
}

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

using namespace std;

const int mod = 1e9 + 7;

int add() { return 0; }
template<typename... M> int add(int a, M... b) {
  int x = add(b...);
  return a + x - mod * (a + x >= mod);
}

int mul() { return 1; }
template<typename... M> int mul(int a, M... b) {
  return int(1ll * a * mul(b...) % mod);
}

int pwr(int a, int x) {
  return (x ? mul(pwr(mul(a, a), x >> 1), (x & 1 ? a : 1)) : 1);
}

int dvd(int a, int b) {
  return mul(a, pwr(b, mod - 2));
}

int sub(int a, int b) {
  return a - b + mod * (a < b);
}

void inc(int& a, int b) {
  a = add(a, b);
}

void dec(int& a, int b) {
  a = sub(a, b);
}

int C(int n, int k) {
  int res = 1;
  for (int i = n - k + 1; i <= n; ++i) {
    res = mul(res, i);
  }
  for (int i = 1; i <= k; ++i) {
    res = dvd(res, i);
  }
  return res;
}

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

  int n, a, b;
  cin >> n >> a >> b;
  int ans = pwr(2, n) - 1;
  dec(ans, add(C(n, a), C(n, b)));
  cout << ans;

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a int
	var s string

	fmt.Scan(&a)
	fmt.Scan(&s)

	if a >= 3200 {
		fmt.Println(s)
	} else {
		fmt.Println("red")
	}
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}


Measured memory_bytes: 512
/*
	Created by Rahul Goel.
*/

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1000000000;

#define pii pair < int, int >
#define vi vector < int >
#define vvi vector < vector < int > >
#define vpii vector < pair < int, int > >
#define vvpii vector < vector < pair < int, int > > >
#define pb push_back
#define f first
#define s second
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	if(n&1)
		cout << n/2 + 1 << endl;
	else
		cout << n/2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	int car[10];
	int kazu = 0;
	int n;

	while(scanf("%d",&n)!=EOF){

		if(n == 0){
			printf("%d\n",car[kazu]);
			kazu--;
		}
		else{
			kazu++;
			car[kazu] = n;
		}
	}

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
bool flag[10];
int N,M;
int rec(vector<vector<int>> G,int now){
  flag[now]=true;
  int cnt=0;
  for(int i=1;i<=N;i++){
    if(!flag[i])break;
    cnt++;
  }
  if(cnt==N)return 1;
  int ans=0;
  for(auto e:G[now]){
    if(!flag[e]){
      ans+=rec(G,e);
      flag[e]=false;
    }
  }
  return ans;
}
int main(){
  cin>>N>>M;
  vector<vector<int>>G(N+1);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  cout<<rec(G,1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int n, m;
  cin >> n >> m;
  int s[5];
  rep(i, 6) { s[i] = -1; }

  rep(i, m) {
    int si, ci;
    cin >> si >> ci;

    if (s[si - 1] != -1 && s[si - 1] != ci) {
      cout << "-1" << endl;
      return 0;
    }

    if (si == 1 && ci == 0 && n != 1) {
      cout << "-1" << endl;
      return 0;
    }

    s[si - 1] = ci;
  }

  int ans[5];
  rep(i, n) {
    if (s[i] != -1) {
      ans[i] = s[i];
    } else {
      if (n != 1 && i == 0) {
        ans[i] = 1;
      } else {
        ans[i] = 0;
      }
    }
  }

  int res = 0;

  rep(i, n) { res += ans[i] * pow(10, n - i - 1); }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
es = (0..N).map{ [] }
rs = (0..N).map{ [] }
(N+M-1).times{
  a,b = gets.split.map(&:to_i)
  es[a] << b
  rs[b] << a
}

Root = (1..N).find{ |n| rs[n].size == 0 }

def topological_sort(node_num, edges, roots)
  ns = Array.new(node_num+1,0)
  edges.each{ |h| h.each{ |m| ns[m] += 1 } }
  nodes = roots.map{ |d| d }
  sorted = []
  while n = nodes.pop
    sorted << n
    edges[n].each{ |m|
      ns[m] -= 1
      if ns[m] == 0
        nodes << m
      end
    }
  end
  sorted
end

sorted = topological_sort(N, es, [Root])
dp = Array.new(N+1,0)
dp[sorted[0]] = 1
rs[Root] << 0
sorted.each{ |n|
  es[n].each{ |m|
    dp[m] = dp[n] + 1 if dp[n] >= dp[m]
  }
}
puts (1..N).map{ |m|
  rs[m].find{ |n| dp[m] == dp[n] + 1 }
}

Measured memory_bytes: 30808
import sys

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = sum(B)

if N == 2 and A[0] == 1: ## only 2 items, and order 1 to 2
  ans = ans +C[0]
  print(ans)
  sys.exit()

for i in range(1,N):
  if A[i]-A[i-1] == 1:
    ans= ans +C[-1+A[i-1]]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    int N; cin>>N;
    vector<pair<ll,ll>> S(N);
    for(int i=0;i<N;i++){
        ll a,b; cin>>a>>b;
        S[i].first=b;   //締め切り
        S[i].second=a;  //所要時間
    }
    sort(S.begin(),S.end());
    ll count=0;
    bool can=true;
    for(int i=0;i<N;i++){
        count+=S[i].second;
        if(count>S[i].first){
            can=false;
        }
    }
    if(can){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;
import java.util.Arrays;
 
public class Main{
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] l = new int[m];
        int[] r = new int[m];
        for(int i = 0; i < m; i++){
            l[i] = Integer.parseInt(sc.next());
            r[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        
        int count = 0;
        if(m != 1 && max(l) > min(r)){
            count = 0;
        }
        else{
            count = min(r) -max(l) +1;
        }
        System.out.println(count);
    }
    public static int max(int[] a){
        int max = a[0];
        for (int i = 1; i < a.length; i++) {
            int v = a[i];
            if (v > max) {
              max = v;
            }
        }
        return max;
    }
    public static int min(int[] a){
        int min = a[0];
        for (int i = 1; i < a.length; i++) {
            int v = a[i];
            if (v < min) {
              min = v;
            }
        }
        return min;
    }
}


Measured memory_bytes: 50744
hoa=list(input())
hob=list(input())
hoc=list(input())
f="A"

while 1:
  if(f=="A" and len(hoa)==0):
    print(f)
    break
  elif(f=="B" and len(hob)==0):
    print(f)
    break
  elif(f=="C" and len(hoc)==0):
    print(f)
    break
  elif(f=="A"):
    if(hoa[0]=="a"):
      f="A"
      hoa=hoa[1:]
    elif(hoa[0]=="b"):
      f="B"
      hoa=hoa[1:]
    elif(hoa[0]=="c"):
      f="C"
      hoa=hoa[1:]
  elif(f=="B"):
    if(hob[0]=="a"):
      f="A"
      hob=hob[1:]
    elif(hob[0]=="b"):
      f="B"
      hob=hob[1:]
    elif(hob[0]=="c"):
      f="C"
      hob=hob[1:]
  elif(f=="C"):
    if(hoc[0]=="a"):
      f="A"
      hoc=hoc[1:]
    elif(hoc[0]=="b"):
      f="B"
      hoc=hoc[1:]
    elif(hoc[0]=="c"):
      f="C"
      hoc=hoc[1:]




Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, k) = (v[0], v[1]);
    let ans = max(max(n * k, n - k), n + k);
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<tuple>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (!ts[i][j])return false;
	return true;
}


vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}



int main() {
	using restaurant = tuple<string, int, int>;
	int N; cin >> N;
	auto book = vector<restaurant>(N);
	string city; int score;
	for (size_t i = 0; i < N; i++) {
		cin >> city >> score;
		book[i] = std::make_tuple(city, -score, i + 1);
	}
	sort(book.begin(), book.end());
	for (size_t i = 0; i < book.size(); i++) {
		cout << get<2>(book[i]) << endl;
	}
}


Measured memory_bytes: 256
from collections import deque
n,m=map(int,input().split())
road=[[] for i in range(n)]
flag=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)
count=0
for i in range(n):
    if flag[i]!=0:
        continue
    count+=1
    q=deque([i])
    while q:
        p=q.popleft()
        flag[p]=1
        for z in road[p]:
            if flag[z]==0:
                q.append(z)
print(count-1)

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

int main()
{
    int n;
    cin >> n;
    int h[n];
    int m = 0;
    int res = 0;
    rep(i, n) {
        cin >> h[i];
        if (h[i] >= m) ++res;
        m = max(m, h[i]);
    }

    cout << res << endl;

    return 0;
}

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int x = A * 100 + 10 * B + C;
	if (0 == x % 4) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3520
from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(N+1)]

for i in range(M):
    x, y = map(int, input().split())
    G[x].append(y)
    G[y].append(x)

USED = [-1] * (N+1)
USED[0] = 0
USED[1] = 0

Q = deque()
Q.append(1)

while Q:
    x = Q.pop()
    for t in G[x]:
        if USED[t] == -1:
            Q.appendleft(t)
            USED[t] = x

if -1 in USED:
    print("No")
else:
    print("Yes")
    for _ in USED[2::]:
        print(_)


Measured memory_bytes: 34744
N, M = [int(x) for x in input().split()]
A = set()

MOD = 10 ** 9 + 7

for _ in range(M):
    A.add(int(input()))

result = {0: 1}

for i in range(1, N+1):

    # 階段が壊れている場合にはそこに行くパターンは無い
    if i in A:
        result[i] = 0

    # それ以外の場合、前の段と前の前の段まで行くパターンを加算した数になる
    else:
        if i - 1 in result:
            min_1 = result[i-1]
        else:
            min_1 = 0
        if i - 2 in result:
            min_2 = result[i-2]
        else:
            min_2 = 0
        result[i] = (min_2 + min_1) % MOD

print(result[N])


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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 main()
{
    string s;
    cin >> s;
    set<char> ans;
    rep(i,s.size()) ans.insert(s[i]);

    set<char> key;
    rep(i,26) key.insert('a'+i);

    for(set<char>::iterator itr = key.begin(); itr != key.end(); itr++)
    {
        if( ans.find(*itr) == ans.end() )
        {
            cout << *itr << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}


Measured memory_bytes: 512
#互いに素なa,bについて、a*x+b*y=1の一つの解
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

def mod_inv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m

import fractions
mod = (10**9)+ 7
n = int(input())
a = list(map(int, input().split()))
lcm = 1
for i in range(n):
    gcd = fractions.gcd(lcm, a[i])
    lcm *= a[i]
    lcm = lcm // gcd
lcm %= mod
ans = 0
for i in range(n):
    k = mod_inv(a[i], mod)
    ans += lcm * k
    ans %= mod
print(ans)

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

using namespace std;

typedef long long ll;

const int MAX_N = 400;
const ll INF = 1e18;
ll s[1 + MAX_N];
ll dp[1 + MAX_N][1 + MAX_N];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i<=n; ++i) {
        int x;
        cin >> x;
        s[i] = s[i - 1] + x;
    }
    for (int l = 2; l <= n; l++) {
        for (int i = 1; i + l - 1 <= n; i++) {
            ll ans = INF;
            int j = i + l - 1;
            for (int k = i; k < j; k++)
                ans = min (ans, dp[i][k] + dp[k + 1][j]);
            dp[i][j] = ans + s[j] - s[i - 1];
        }
    }
    cout << dp[1][n] << "\n";
    return 0;
}


Measured memory_bytes: 1536
def main():
    M=10**9+7
    n,k=map(int,input().split())
    r1=k*(k+1)//2%M
    r2=k*(k-1)//2%M
    *a,=map(int,input().split())
    ans=0
    for i,t in enumerate(a):
        tem=0
        for j,u in enumerate(a):
            if u<t:
                if j<i:tem+=r2
                else:tem+=r1
        ans+=tem
        ans%=M
    print(ans)
main()

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

#define ll long long int
#define tinput int t; cin>>t; while(t--)
#define rep(i,n,s) for((i)=(s); (i)<(n); (i)++)

template <typename T>
T mini(T x, T y) { return (x<y)?x:y; }
template <typename T>
T maxi(T x, T y) { return (x>y)?x:y; }

int main(){
  //  freopen("input2.txt", "r", stdin);
 //   freopen("output2.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s, t;
    cin>>s>>t;
    int ans = 1000;
    for(int i=0;i<=(s.length()-t.length());i++) {
        int aux=0;
        for(int j=0;j<t.length();j++) {
            if(s[i+j]!=t[j]) aux++;
        }
        if(aux<ans) ans=aux;
    }
    cout<<ans;
   
    return 0;
}

Measured memory_bytes: 3668
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int main() {
    int a[3], b[3];
    int c[4];
    rep(i, 4) c[i] = 0;
    rep(i, 3) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        c[a[i]]++, c[b[i]]++;
    }
    int count1 = 0, count2 = 0;
    rep(i, 4) {
        if (c[i] == 1) count1++;
        if (c[i] == 2) count2++;
    }
    if (count1 == 2 && count2 == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int w,h,x,y;
  cin >> w >> h >> x >> y;
  printf("%lf ", (double)w * h / 2);
  cout << (2 * x == w && 2 * y == h) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>

int main () {
    ll N ;
    cin >> N ;
    ll ans = 0;
    for(ll i = 1 ; i <= N ; i++){
        if( i % 3 != 0 && i % 5 != 0){
            ans += i ;
         }
    }

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

 


Measured memory_bytes: 3624
fn main() {
    let (mut a, mut o, mut b): (isize, char, isize) = (
        read::<isize>(),
        read::<String>().chars().next().expect("wrong"),
        read::<isize>(),
    );
    while o != '?' {
        match o {
            '+' => println!("{}", a + b),
            '-' => println!("{}", a - b),
            '*' => println!("{}", a * b),
            '/' => println!("{}", a / b),
            _ => unreachable!(),
        }
        a = read::<isize>();
        o = read::<String>().chars().next().expect("wrong");
        b = read::<isize>();
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: isize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



Measured memory_bytes: 5032
// 6/25 Sunday
#include <iostream>

using namespace std;

int main() {
	int n,k=0,i;
	bool m1 = true;

	cin >> n;
	int *a = new int[n];
	for (i = 1; i <= n; i++) {
		cin >> a[i];
	}
	i = 1;
	while (m1) {
		k++;
		if (a[i] == 2) { m1 = false;}
		else { i = a[i];
			if (k > n+1) { m1 = false; k = -1; }
		}
	}
	cout << k;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> d(k);
	rep(i, k) cin >> d[i];
	for (int i = 1; i <= 99999; ++i) {
		if (i < n) continue;
		vector<int> res;
		int tmp = i;
		while (tmp) {
			res.emplace_back(tmp % 10);
			tmp /= 10;
		}
		bool elf = true;
		for (auto& c : res) {
			rep(i, k) {
				if (c == d[i]) elf = false;
			}
		}
		if (elf) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
s = input().split()
st = []

for i in range(len(s)):
    c = s.pop(0)
    if c == '+':
        b = st.pop(0)
        a = st.pop(0)
        ans = a + b
        st.insert(0,ans)
    elif c == '-':
        b = st.pop(0)
        a = st.pop(0)
        ans = a - b
        st.insert(0,ans)
    elif c == '*':
        b = st.pop(0)
        a = st.pop(0)
        ans = a * b
        st.insert(0,ans)
    else:
        st.insert(0, int(c))

print(st.pop(0))


Measured memory_bytes: 5596
#include<stdio.h>
int main (){
int n=0;
scanf("%d",&n);
int num=1;
int ans=0;
if(n>=64)ans=64;
else if(n>=32)ans=32;
else if(n>=16)ans=16;
else if(n>=8)ans=8;
else if(n>=4)ans=4;
else if(n>=2)ans=2;
else ans=1;
printf("%d\n",ans);

return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 2013
using namespace std;
short dp[MAX][MAX];
char path[MAX][MAX];

void lcs(string a,string b)
{
  int n = a.size();
  int m = b.size();
  
  REP(i,1,n+1)
    {
      REP(j,1,m+1)
	{
	  if(a[i-1] == b[j-1])
	    {
	      dp[i][j] = dp[i-1][j-1]+1;
	      path[i][j] = 'Z';
	    }
	  else if(dp[i][j-1] < dp[i-1][j])
	    {
	      dp[i][j] = dp[i-1][j];
	      path[i][j] = 'X';
	    }
	  else
	    {
	      dp[i][j] = dp[i][j-1];
	      path[i][j] = 'Y';
	    }
	}
    }

  // cout << dp[n][m] << endl;
  
  string res = "";
  while(n > 0 && m > 0)
    {
      if(path[n][m] == 'Z')
	{
	  assert(a[n-1] == b[m-1]);	 
	  res += a[n-1];
	  n--,m--;
	}
      else if(path[n][m] == 'X')n--;
      else                      m--;
    }

  cout << res << endl; 

}

int main()
{
  string line;
  while(cin >> line)
    {
      rep(i,MAX)rep(j,MAX)dp[i][j] = 0;
      string rline(line.rbegin(),line.rend());
      lcs(line,rline);


    }
  return 0;
}

Measured memory_bytes: 13080
#include <bits/stdc++.h>
using namespace std;
int P[4];
int T[4];

int main() {
	int N;
	cin >> N;
	for(int i = 0; i < 4; i++) cin >> P[i];
	for(int i = 0; i < 4; i++) cin >> T[i];
	
	int ans = 500;
	for (int i = 0; i < 1300000; i++) {
		int cnt = 0;
		int cos = 0;
		int A[4];
		int i2 = i;
		for(int k = 0; k < 3; k++){
			A[k] = i2 % 101;
			cnt += A[k] * T[k];
			i2 /= 101;
		}
		A[3] = max(N - cnt + T[3] - 1, 0) / T[3];
		for(int k = 0; k < 4; k++) cos += A[k] * P[k];
		ans = min(ans, cos);
	}
	cout << ans << endl;
}


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

int main(int argc, char *argv[]){
	int a[5];
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	for (int j = 0; j < 5; ++j){
		for (int i = 0; i < 4; ++i){			
			if(a[i]<a[i+1]){
				int tmp;
				tmp=a[i];
				a[i]=a[i+1];
				a[i+1]=tmp;
			}
		}
	}
	for (int i = 0; i < 4; ++i){
		cout<<a[i]<<" ";	
	}
	cout<<a[4]<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int s1 = A*B;
  int s2 = C*D;
  int ans = max(s1,s2);
  cout << ans << endl;
}
  

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

void out(char num, int times){
    switch(num){
        case '1':
            switch(times%5){
                case 1: cout << '.'; break;
                case 2: cout << ','; break;
                case 3: cout << '!'; break;
                case 4: cout << '?'; break;
                case 0: cout << ' '; break;
            }
            break;
        case '2':
            switch(times%3){
                case 1: cout << 'a'; break;
                case 2: cout << 'b'; break;
                case 0: cout << 'c'; break;
            }
            break;
        case '3':
            switch(times%3){
                case 1: cout << 'd'; break;
                case 2: cout << 'e'; break;
                case 0: cout << 'f'; break;
            }
            break;
        case '4':
            switch(times%3){
                case 1: cout << 'g'; break;
                case 2: cout << 'h'; break;
                case 0: cout << 'i'; break;
            }
            break;
        case '5':
            switch(times%3){
                case 1: cout << 'j'; break;
                case 2: cout << 'k'; break;
                case 0: cout << 'l'; break;
            }
            break;
        case '6':
            switch(times%3){
                case 1: cout << 'm'; break;
                case 2: cout << 'n'; break;
                case 0: cout << 'o'; break;
            }
            break;
        case '7':
            switch(times%4){
                case 1: cout << 'p'; break;
                case 2: cout << 'q'; break;
                case 3: cout << 'r'; break;
                case 0: cout << 's'; break;
            }
            break;
        case '8':
            switch(times%3){
                case 1: cout << 't'; break;
                case 2: cout << 'u'; break;
                case 0: cout << 'v'; break;
            }
            break;
        case '9':
            switch(times%4){
                case 1: cout << 'w'; break;
                case 2: cout << 'x'; break;
                case 3: cout << 'y'; break;
                case 0: cout << 'z'; break;
            }
            break;
        case '0': break;
    }
}

int main(void){
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        char str[1050];
        cin >> str;
        for(int j=0;j<strlen(str);++j){
            int cnt = 0;
            char num = str[j];
            while(true){
                if(str[j+cnt]=='0') break;
                ++cnt;
            }
            out(num, cnt);
            j += cnt;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3100