akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

bool contain(ll x, ll v) {
  while (x > 0) {
    ll a = x % 10;
    if (a == v) return true;
    x /= 10;
  }
  return false;
}

void solve(ll N, ll K, std::vector<ll> D) {
  ll cur = N;

  while (true) {
    bool ok = true;
    rep(i, K) {
      if (contain(cur, D.at(i))) {
        ok = false;
        break;
      }
    }
    if (ok) break;
    cur++;
  }

  cout << cur << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  ll K;
  scanf("%lld", &K);
  std::vector<ll> D(K);
  for (int i = 0; i < K; i++) {
    scanf("%lld", &D[i]);
  }
  solve(N, K, std::move(D));
  return 0;
}


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

int main() {
  int n;
  int count = 0;
  int countIJ[10][10];

  cin >> n;
  memset(countIJ, 0, sizeof(countIJ));

  for (int k = 1; k <= n; ++k) {
    int nn = k;
    while (nn >= 10) {
      nn /= 10;
    }
    int top = nn;
    int bottom = k % 10;
    ++countIJ[top][bottom];
  }

  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      count += countIJ[i][j] * countIJ[j][i];
    }
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;  
#define pb push_back
#define F first
#define S second
#define ppp pair<ll,pair<ll,ll>>
#define pp pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define pi 3.14159265358
#define MOD 998244353



int main()
{

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout); 
    // freopen("error.txt", "w", stderr); 
    // #endif
    
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);

     ll n,i,j,l;

     string ans="";
    cin>>n;

    //cout<<(n-1)%26<<endl;
    while(n)
    {
      ll x=(n-1)%26;
     
     // cout<<n<<" "<<x<<endl;
      n-=x;
      ans=char('a'+x)+ans;
      n=n/26LL;
    }

    cout<<ans;

      

}



Measured memory_bytes: 3612
// https://beta.atcoder.jp/contests/abc088
// status:

#define SUBMIT

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <queue>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_SIDE = 50;
const int NOT_VISITED = -1;

int H, W;
int sy, sx;
int gy, gx;
int dist[MAX_SIDE + 1][MAX_SIDE + 1];
char field[MAX_SIDE + 1][MAX_SIDE + 1];
int black_count;
queue<pair<int, int>> pos_queue;

bool is_goal(int y, int x) {
    return y == gy && x == gx;
}

void bfs(int y, int x) {
    pos_queue.push(make_pair(y, x));

    while (!pos_queue.empty()) {
        auto p = pos_queue.front();
        pos_queue.pop();

        y = p.first, x = p.second;
        auto up = y - 1, down = y + 1;
        auto left = x - 1, right = x + 1;

        // up
        if (1 <= up && field[up][x] != '#' && dist[up][x] == NOT_VISITED) {
            dist[up][x] = dist[y][x] + 1;
            if (is_goal(up, x)) break;
            pos_queue.push(make_pair(up, x));
        }

        // down
        if (down <= H && field[down][x] != '#' && dist[down][x] == NOT_VISITED) {
            dist[down][x] = dist[y][x] + 1;
            if (is_goal(down, x)) break;
            pos_queue.push(make_pair(down, x));
        }

        // left
        if (1 <= left && field[y][left] != '#' && dist[y][left] == NOT_VISITED) {
            dist[y][left] = dist[y][x] + 1;
            if (is_goal(y, left)) break;
            pos_queue.push(make_pair(y, left));
        }

        // right
        if (right <= W && field[y][right] != '#' && dist[y][right] == NOT_VISITED) {
            dist[y][right] = dist[y][x] + 1;
            if (is_goal(y, right)) break;
            pos_queue.push(make_pair(y, right));
        }
    }
}

void start_bfs() {
    memset(dist, NOT_VISITED, sizeof(dist));
    dist[sy][sx] = 0;
    bfs(sy, sx);
}


int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto s = std::string(R"(10 37
.....................................
...#...####...####..###...###...###..
..#.#..#...#.##....#...#.#...#.#...#.
..#.#..#...#.#.....#...#.#...#.#...#.
.#...#.#..##.#.....#...#.#.###.#.###.
.#####.####..#.....#...#..##....##...
.#...#.#...#.#.....#...#.#...#.#...#.
.#...#.#...#.##....#...#.#...#.#...#.
.#...#.####...####..###...###...###..
.....................................
)");

    stringstream stream(s);
#endif
    stream >> H >> W;
    black_count = 0;
    for (int y = 1; y <= H; ++y) {
        for (int x = 1; x <= W; ++x) {
            stream >> field[y][x];
            if (field[y][x] == '#') black_count++;
        }
    }

    sy = 1, sx = 1;
    gy = H, gx = W;

    start_bfs();
    if (dist[gy][gx] == NOT_VISITED) cout << "-1" << endl;
    else {
        auto ans = H * W - black_count - dist[gy][gx] - 1;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FOREACH(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define SIZE(v) ((int)(v).size())
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define llint long long
#define pii pair<int, int>
#define UNVISITED -1


template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}
 
template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
 
class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif


int main() {
    int x; scanf("%d", &x);
    printf("%d\n", 1 - x);
}

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

long long ans(long long N,int n){
  if(N % n == 0) return n+N/n-2;
  else return ans(N,n-1);
}

int main(){
  long long N;
  cin >>N;
  int min = int(sqrt(double(N)))+1;
  cout << ans(N,min) << endl;
}

Measured memory_bytes: 256
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    [_, k] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    ls <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    print $ sum $ take k $ sortBy (flip compare) ls


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	ll N; cin >> N;
	vector<ll> vec;
	for (ll i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			vec.pb(i);
			if (N / i != i) {
				vec.pb(N / i);
			}
		}
	}
	ll ans = 0;
	for (ll d : vec) {
		ll m = d-1, k = N / d;
		if (k < m) {
			ans += m;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
a = list(input())
 
while len(a) >= 5:
    if a[-5:] == list('dream'):
        del a[-5:]
        continue
    if a[-7:] == list('dreamer'):
        del a[-7:]
        continue
    if a[-5:] == list('erase'):
        del a[-5:]
        continue
    if a[-6:] == list('eraser'):
        del a[-6:]
        continue
    break
 
if a == []:
    print('YES')
else:
    print('NO')

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

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

  if(a > b) swap(a, b);
  if(b > c) swap(b, c);
  if(a > b) swap(a, b);

  cout<<a<<" "<<b<<" "<<c<<endl;
  return 0;
}


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

class strongly_connected_component {
    using graph = std::vector<std::vector<int>>;
public:
    strongly_connected_component(int n) : g(n), rg(n), cmp(n), K(0) {}

    void add_edge(int s, int t) {
        g[s].push_back(t);
        rg[t].push_back(s);
    }

    void build() {
        const int n = g.size();
        std::vector<bool> used(n);
        for(int v = 0; v < n; ++v) {
            if(!used[v]) dfs(v, used);
        }
        std::fill(std::begin(used), std::end(used), false);
        int k = 0;
        for(int i = (int)vs.size() - 1; i >= 0; --i) {
            if(!used[vs[i]]) rdfs(vs[i], k++, used);
        }
        K = k;
    }

    int belongs(int v) const {
        return cmp[v];
    }

    graph build_graph() { // also call build()
        build();
        int const V = g.size();
        std::vector<std::set<int>> s(K);
        graph res(K);
        for(int v = 0; v < V; ++v) {
            for(const auto to : g[v]) {
                s[cmp[v]].insert(cmp[to]);
            }
        }
        for(int i = 0; i < K; ++i) { // remove self-loop edge
            for(auto j : s[i]) {
                if(i != j) res[i].push_back(j);
            }
        }
        return res;
    }

private:
    void dfs(int v, std::vector<bool>& used) {
        used[v] = true;
        for(const auto to : g[v]) {
            if(!used[to]) dfs(to, used);
        }
        vs.push_back(v);
    }
    void rdfs(int v, int k, std::vector<bool>& used) {
        used[v] = true;
        cmp[v] = k;
        for(auto to : rg[v]) {
            if(!used[to]) rdfs(to, k, used);
        }
    }

private:
    graph g, rg;
    std::vector<int> cmp, vs;
    int K;
};

int main() {
    int n, m; cin >> n >> m;
    strongly_connected_component scc(n);
    for(int i = 0; i < m; ++i) {
        int s, t; cin >> s >> t;
        scc.add_edge(s, t);
    }
    auto g = scc.build_graph();
    n = g.size();
    if(n == 1) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> in(n), out(n);
    for(int i = 0; i < n; ++i) {
        out[i] = g[i].size();
        for(auto to : g[i]) {
            in[to] += 1;
        }
    }
    int scnt = 0, tcnt = 0;
    for(int i = 0; i < n; ++i) {
        scnt += in[i] == 0;
        tcnt += out[i] == 0;
    }
    cout << max(scnt, tcnt) << endl;
}



Measured memory_bytes: 11000
#include<iostream>
#include<vector>
using namespace std;
int main()
{

int n;
cin>>n;
vector<int> p(n);
for(int i=0;i<n;i++)
    {
     int x;
     cin>>x;
     x--;
     p[x]=i;
    }

int t=1,ans=1;
for(int i=1;i<n;i++)
    {
     if(p[i]>p[i-1]) t++;
                else t=1;
     ans=max(ans,t);
    }
cout<<n-ans;

return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

  int ans = INF;
  // iは最初に使う色(0 or 1)
  rep(i,2) {
    // iを最初に使ったときに変えなければならないタイルの数
    int cnt = 0;
    rep(j,s.size()) {
      // (j%2,i) = (0,0), (1,1)のときtrue
      if ((j%2 == 0) ^ (s[j] == (char)(i+'0'))) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a<b&&b<c&&a<c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        sc.close();
    }
}


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

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

int main(){
	string a,b;
	cin>>a>>b;
	int c=0;
	for(int i=0;i<3;i++){
		if(a[i]==b[i])
			c++;
	}
	cout<<c<<endl;
	return 0;
}



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

using namespace std;

int ans;


int a,b;

int main() {

  int N; cin >> N;
  // for(int i;i<N;i++){}
  if(N%2==0){
    a = N/2;
    b = N/2;
  }
  else{
    a = N/2;
    b = N/2 +1;
  }
  cout << a*b << endl;

  return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int n,w,a[111],v[111],memo[111111][111];
long long int dp(int x,int c){
  if(memo[x][c]!=-1) return memo[x][c];
  if(c==n) return 0;
  if(x+a[c]>w) return memo[x][c]=dp(x,c+1);
  else return memo[x][c]=max(dp(x+a[c],c+1)+v[c],dp(x,c+1));
}
int main(){
  memset(memo,-1,sizeof(memo));
  cin>>n>>w;
  for(int i=0;i<n;i++) cin>>a[i]>>v[i];
  cout<<dp(0,0)<<endl;
  return(0);
}


Measured memory_bytes: 96640
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;

int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> b(M);
	int sol = 0;
	for(int i = 0; i < M; i++) cin>>b[i];
	for(int i = 0; i < N; i++) {
		ll res = 0;
		for(int j = 0; j < M; j++) {
			int a;
			cin>>a;
			res += (a * b[j]);
		}
		res += C;
		if(res > 0) sol++;
	}
	cout<<sol<<endl;

    return 0;
}


Measured memory_bytes: 256
A, B, M = [int(_) for _ in input().split()]

La = [int(_) for _  in input().split()]
Lb = [int(_) for _ in input().split()]
Lm = [[int(_) for _ in input().split()] for _ in range(M)]

ans = min(La) + min(Lb)
for x, y, c in Lm:
    ans = min(ans, La[x-1] + Lb[y-1] - c)
print(ans)


Measured memory_bytes: 32496
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

int visited[8];
int G[8][8];
int ans;
int n,m;
void dfs(int s,int cnt){
	if(cnt==n){
		ans++;
		return;
	}
	visited[s]=1;
	for(int i=0;i<n;i++){
		if(G[s][i]&&!visited[i]){
			dfs(i,cnt+1);
		}
	}
	visited[s]=0;
}

int main(){
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int x,y; cin >> x >> y;
		x--; y--;
		G[x][y]=G[y][x]=1;
	}
	ans=0;
	dfs(0,1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,l;
        cin>>n>>l;
        ll k=l-1;
        ll sum=((n*(n+1))/2)+n*k;
        //cout<<sum<<" ";
        for(ll i=1;i<=n;i++)
        {
            if(i==-k)
            {
                cout<<sum;
                exit(0);
            }
            
        }
        if(k>=0)
        {
            cout<<sum-k-1;
        }
        else
        {
            cout<<sum-n-k;
        }
	
    } 
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N, M; cin >> N >> M;
  ll A[N+1]={}; rep(i, N) cin >> A[i+1];
  map<ll, ll> mod; mod[0]++;
  rep(i, N) { A[i+1] = (A[i]+A[i+1])%M; mod[A[i+1]]++; }
  // rep(i, N+1) cout << A[i] << endl;  

  ll result = 0;
  for (auto x: mod) if (x.second>=2) result += x.second*(x.second-1)/2;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define All(v) v.begin(), v.end()
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, A, B;
    cin>>N>>A>>B;
    cout<<min(N*A, B)<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()]
acc1, acc2 = [0], [0]
for i in range(N):
    acc1.append(acc1[-1] + A1[i])
    acc2.append(acc2[-1] + A2[i])
ans = 0
for i in range(N):
    ans = max(ans, acc1[i+1] + acc2[-1] - acc2[i])
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
  cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int count = 0;
  for(int i = 0; i < N; i++){
    if(i != 0 && vec.at(i) == vec.at(i-1)){
    count += 0;
    }
    else{
    count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import math
a,b,x = [ int(r) for r in input().split(' ') if len(r) > 0]

if 2*x >= a*a*b:
    print(90-math.degrees((math.atan2(a,2*(b-x/a**2)))))
else:
    print(90-math.degrees(math.atan2((2*x)/(a*b),b)))


Measured memory_bytes: 9316
#include <stdio.h>

int main(void){
  int n,k,ans=0;
  int p[1001];

  scanf("%d %d",&n,&k);

  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
  }

  int tmp;

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(p[j]<p[i]){
        tmp=p[j];
        p[j]=p[i];
        p[i]=tmp;
      }
    }
  }

  for(int i=0;i<k;i++){
    ans+=p[i];
  }

  printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 1716
import sys
sys.setrecursionlimit(2 * 10 ** 5 + 10)

N, Q, *ABPX = map(int, open(0).read().split())
AB, PX = ABPX[:2 * (N - 1)], ABPX[2 * (N - 1):]

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)
    E[b].append(a)

C = [0] * (N + 1)
for p, x in zip(*[iter(PX)] * 2):
    C[p] += x


ans = [0] * (N + 1)
def dfs(v, p, acc):
    ans[v] = acc + C[v]
    for c in E[v]:
        if p != c:
            dfs(c, v, acc + C[v])

dfs(1, 0, 0)

print(*ans[1:])

Measured memory_bytes: 269708
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
const int MOD = (int)1e9 + 7;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
const int limit = 50;
int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visted[limit];

void dfs(int v) {
  visted[v] = true;
  for (int v2 = 0; v2 < n; ++v2) {
    if (graph[v][v2] == false) continue;
    if (visted[v2] == true) continue;
    dfs(v2);
  }
}

int main(int argc, char const *argv[]) {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    graph[b[i]][a[i]] = true;
    graph[a[i]][b[i]] = graph[b[i]][a[i]];
  }
  int ans = 0;
  for (int i = 0; i < m; ++i) {
    graph[a[i]][b[i]] = false;
    graph[b[i]][a[i]] = false;
    for (int j = 0; j < n; ++j) visted[j] = false;

    dfs(0);

    bool bridge = false;
    for (int j = 0; j < n; ++j)
      if (visted[j] == false) bridge = true;
    if (bridge) ans++;
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int a, b;
	cin >> a >> b;
	
	if (a == b){ cout << "a == b" << endl; } else { if (a < b){ cout << "a < b" << endl; } else { cout << "a > b" << endl; } }

	return 0;
}

Measured memory_bytes: 1156
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n, k = Is()
r, s, p = Is()
t = S()
flag = [False]*n
ans = 0
for i in range(n):
    if i >= k and t[i-k] == t[i] and not flag[i-k]:
        flag[i] = True
        continue
    if t[i] == 'r':
        ans += p
    elif t[i] == 's':
        ans += r
    else:
        ans += s

print(ans)

Measured memory_bytes: 42788
N = gets.to_i
a = gets.split.map(&:to_i)

color = Hash.new { |h, k| h[k] = 0 }
N.times do |i|
  color[:gray]   += 1 if a[i].between?(   1,  399)
  color[:brown]  += 1 if a[i].between?( 400,  799)
  color[:green]  += 1 if a[i].between?( 800, 1199)
  color[:aqua]   += 1 if a[i].between?(1200, 1599)
  color[:blue]   += 1 if a[i].between?(1600, 1999)
  color[:yellow] += 1 if a[i].between?(2000, 2399)
  color[:orange] += 1 if a[i].between?(2400, 2799)
  color[:red]    += 1 if a[i].between?(2800, 3199)
  color[:any] += 1 if a[i].between?(3200, 4800)
end

num = 0
color.each do |k, v|
  next if k == :any
  num += 1 if v > 0
end
puts [num == 0 ? 1 : num, num + color[:any]] * " "

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;
// Welcome to my source code!

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int key) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = new Node;
    z->key = key;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;

    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

Node* find(Node *u, int key) {
    while (u != NIL && u->key != key) {
        if (key < u->key) {
            u = u->left;
        } else {
            u = u->right;
        }
    }
    return u;
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int m, k;
    string com;
    cin >> m;

    REP(i,m) {
        cin >> com;
        if (com == "insert") {
            cin >> k;
            insert(k);
        } else if (com == "find") {
            cin >> k;
            if (find(root, k) != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        } else {
            inorder(root);
            cout << '\n';
            preorder(root);
            cout << endl;
        }
    }
}


Measured memory_bytes: 21988
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
    int n,m; cin >> n >> m;
    vs s(n);
    rep(i,n) cin >> s[i];
    mcf_graph<int,ll> g(n*m+2);
    int S = n*m, T = n*m+1;
    ll F = n+m;
    ll cnt = 0;
    for(int i=n-1; i>=0; i--){
        for(int j=m-1; j>=0; j--){
            if(s[i][j] == 'o'){
                g.add_edge(S, i*m+j, 1, (ll)(i+j)*inf);
                cnt++;
            }
            if(i < n-1 && s[i][j] != '#' && s[i+1][j] != '#'){
                g.add_edge(i*m+j, (i+1)*m+j, 100, inf-1);
                //print2(k*m+l, (k+1)*m+l);
            }
            if(j < m-1 && s[i][j] != '#' && s[i][j+1] != '#'){
                g.add_edge(i*m+j, i*m+j+1, 100, inf-1);
                //print2(k*m+l, k*m+l+1);
            }
            g.add_edge(i*m+j, T, 1, (F-i-j)*inf);
        }
    }
    //g.add_edge(S,T,cnt,F*inf);
    auto res = g.flow(S,T,cnt);
    cout << cnt * F * inf - res.second << "\n";
}

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

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, W;
long long dp[110][100100];
int main() {
    cin >> n >> W;
    vector<int> w(n, 0);
    vector<long long> v(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> w.at(i) >> v.at(i);
    }

    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= W; ++j) {
            dp[i][j] = 0;
        }
    }

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= W; ++j) {
            if(j+w.at(i) <= W) {
                dp[i+1][j+w.at(i)] = dp[i][j] + v.at(i);
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }

    cout << dp[n][W] << endl;
}

Measured memory_bytes: 80128
import sys

input = sys.stdin.readline


def bubble_sort(a):
    b = a[:]
    cnt = 0
    n = len(b)
    for i in range(n):
        for j in range(n - 1, i, -1):
            if b[j] < b[j - 1]:
                b[j], b[j - 1] = b[j - 1], b[j]
                cnt += 1
                cnt %= mod
    return cnt, b


mod = 10 ** 9 + 7

n, k = map(int, input().split())
a = list(map(int, input().split()))

cnt, b = bubble_sort(a)
ans = cnt * k
ans %= mod
# print(ans)

b.sort(reverse=True)
# print(b)
dd = dict()

sm = 0
for i, bb in enumerate(b):
    if dd.get(bb, None) is None:
        dd[bb] = i
        sm += i
    else:
        sm += dd[bb]

ans += (k - 1) * k // 2 * sm
ans %= mod

print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define gt(n) scanf("%d", &n)
#define gtll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
fast;
int n,k;
cin>>n>>k;
string s;
cin>>s;
s[k-1]=tolower(s[k-1]);
cout<<s<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cassert>
#include <cctype>
#include <cstdio>

using namespace std;

static int stack[100];
static int count = 0;

int main(void) {

    string expr;
    getline(cin, expr);

    for (int i = 0; i < expr.size(); ++i) {
        if (isspace(expr[i])) {
            continue;
        }
        else if (isdigit(expr[i])) {
            int num = 0;
            for (; isdigit(expr[i]); ++i) {
                num = num * 10 + (expr[i] - '0');
            }
            stack[count++] = num;
        }
        else {
            int rhs = stack[--count];
            int lhs = stack[--count];
            int tmp;
            switch (expr[i]) {
                case '+':
                    tmp = lhs + rhs;
                    break;
                case '-':
                    tmp = lhs - rhs;
                    break;
                case '*':
                    tmp = lhs * rhs;
                    break;
                default:
                    fprintf(stderr, "unknown operator: %c\n", expr[i]);
                    return 1;
            }
            stack[count++] = tmp;
        }
    }

    assert(count == 1);
    printf("%d\n", stack[--count]);

    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
using namespace std;
int N, X;
int main() {
    cin >> N >> X;
    int L[N];
    for(int i = 0; i < N; ++i) cin >> L[i];

    int ans = 1;
    int distance = 0;
    for(int i = 0; i < N; ++i){
        distance += L[i];
        if (distance > X) break;
        ans += 1;
    }
    cout << ans << endl;
    return 0;
}


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

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

    vector<int> A(N);
    rep(i, N) {
        int index;
        cin >> index;
        A[index - 1] = i + 1;
    }

    rep(i, N) {
        printf("%d%c", A[i], i == N - 1 ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 1152
#!/usr/bin/env python3
import sys


def solve(K: int, N: int, A: "List[int]"):
    max_len = 0
    for i in range(len(A)):
        if i == 0:
            max_len = A[0] + (K - A[N-1])
        else:
            if A[i] - A[i-1] > max_len:
                max_len = A[i] - A[i-1]
    print(K - max_len)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(K, N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26228
from collections import deque
from copy import deepcopy
n, k = map(int, input().split())
v = deque(map(int, input().split()))
# 取り出せる最大回数
t = min(n, k)
ans = 0
# A,Bの操作の回数で全探索
for a in range(t + 1):
    for b in range(t + 1 - a):
        # 初期化
        vv = deepcopy(v)
        # 今持っている宝石たち
        belongings = []
        # 取り出していく
        for _ in range(a):
            if vv:
                jewelry = vv.popleft()
                belongings.append(jewelry)
        for _ in range(b):
            if vv:
                jewelry = vv.pop()
                belongings.append(jewelry)
        # ソートして、負の宝石は可能な限り筒に戻す
        belongings.sort()
        for i in range(a + b):
            if belongings[i] < 0 and i < (k - a - b):
                belongings[i] = 0
        ans = max(sum(belongings), ans)
print(ans)


Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class M>
struct LazySegmentTree{
    using T = typename M::T;
    using L = typename M::L;
    int sz, height{};
    vector<T> seg; vector<L> lazy;
    explicit LazySegmentTree(int n) {
        sz = 1;
        while(sz < n) sz <<= 1, height++;
        seg.assign(2*sz, M::e());
        lazy.assign(2*sz, M::l());
    }

    void set(int k, const T &x){
        seg[k + sz] = x;
    }

    void build(){
        for (int i = sz-1; i > 0; --i) seg[i] = M::f(seg[2*i], seg[2*i+1]);
    }

    T reflect(int k){ return lazy[k] == M::l() ? seg[k] : M::g(seg[k], lazy[k]); }

    void eval(int k){
        if(lazy[k] == M::l()) return;
        lazy[(k<<1)|0] = M::h(lazy[(k<<1)|0], lazy[k]);
        lazy[(k<<1)|1] = M::h(lazy[(k<<1)|1], lazy[k]);
        seg[k] = reflect(k);
        lazy[k] = M::l();
    }
    void thrust(int k){ for (int i = height; i; --i) eval(k>>i); }
    void recalc(int k) { while(k >>= 1) seg[k] = M::f(reflect((k<<1)|0), reflect((k<<1)|1));}
    void update(int a, int b, const L &x){
        thrust(a += sz); thrust(b += sz-1);
        for (int l = a, r = b+1;l < r; l >>=1, r >>= 1) {
            if(l&1) lazy[l] = M::h(lazy[l], x), l++;
            if(r&1) --r, lazy[r] = M::h(lazy[r], x);
        }
        recalc(a);
        recalc(b);
    }

    T query(int a, int b){ // [l, r)
        thrust(a += sz);
        thrust(b += sz-1);
        T ll = M::e(), rr = M::e();
        for(int l = a, r = b+1; l < r; l >>=1, r>>=1) {
            if (l & 1) ll = M::f(ll, reflect(l++));
            if (r & 1) rr = M::f(reflect(--r), rr);
        }
        return M::f(ll, rr);
    }

    T operator[](const int &k) const { // 0-indexed
        return seg[k + sz];
    }
};

struct Monoid{
    using T = ll;
    using L = ll;
    static T f(T a, T b) { return min(a, b); }
    static T g(T a, L b) { return a+b; }
    static L h(L a, L b) { return a+b; }
    static T e() { return INF<int>; }
    static L l() { return 0; }
};

int main() {
    int n, q;
    cin >> n >> q;
    LazySegmentTree<Monoid> seg(n);
    for (int i = 0; i < n; ++i) {
        seg.set(i, 0);
    }
    seg.build();
    for (int i = 0; i < q; ++i) {
        int v;
        scanf("%d", &v);
        if(v == 0){
            int s, t; ll x;
            scanf("%d%d%lld", &s, &t, &x);
            seg.update(s, t+1, x);
        }else {
            int a, b;
            scanf("%d%d", &a, &b);
            printf("%lld\n", seg.query(a, b+1));
        }
    }
    return 0;
}





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

int main() {
  string s; cin >> s;
  int n = s.size();

  for(int i = 0; i < (1<<(n-1)); i++) {
    string str = ""; str.push_back(s[0]);
    int sum = s[0] - '0';
    for(int j = 0; j < n-1; j++) {
      if((i>>j) & 1) {
        sum += s[j+1] - '0';
        str.push_back('+');
        str.push_back(s[j+1]);
      } else {
        sum -= s[j+1] - '0';
        str.push_back('-');
        str.push_back(s[j+1]);
      }
    }
    if(sum == 7) {
      cout << str << "=7" << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<string.h>

const int max=7;
int con[max][max];
int n;
bool allMoveOK;

void saiki(int now,int deep){
if(deep==n){
	allMoveOK=true;
	return;
}
for(int i=0;i<max;i++){
	if(con[now][i]>0){
		con[now][i]--;
		con[i][now]--;
		saiki(i,deep+1);
		if(allMoveOK==true) return;
		con[now][i]++;
		con[i][now]++;
	}
}
}
void setData(){
char in[3];
memset(con,0,sizeof(con));
allMoveOK=false;	
for(int i=0;i<n;i++){
	scanf("%s",in);
	in[0]-='0';
	in[1]-='0';
	con[in[0]][in[1]]++;
	con[in[1]][in[0]]++;
}
for(int i=0;i<max;i++){
	saiki(i,0);
	if(allMoveOK==true)break;
}
printf("%s\n",allMoveOK?"Yes":"No");
}
int main(){
while(scanf("%d",&n)!=EOF){
	setData();
}
}

Measured memory_bytes: 732
#include <stdio.h>
 
int main(void)
{
    int n,a[100],x,max,min,i;
    
      
    scanf("%d",&n);
  
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    
    max=a[0]; min=a[0];
  
    for(i=0;i<n;i++){
        if(max<a[i])       max=a[i];
        else if(min>a[i])  min=a[i];
    }
  
    x=max-min;
  
    printf("%d",x);
  
    return 0;
}

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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...)
#endif

bool is_palindrome(const string& s) {
    if (s.size() <= 1u)
        return true;
    int l = 0, r = (int)s.size() - 1;
    while (l < r) {
        if (s[l] != s[r])
            return false;
        l++, r--;
    }
    return true;
}

ll ans = 2e18;
map<pair<string, string>, ll> dis;
priority_queue<pair<ll, pair<string, string>>> que;

void push(const string& s1, const string& s2, ll cost) {
    auto pr = make_pair(s1, s2);
    auto it = dis.find(pr);
    if (it == dis.end() || it->second > cost) {
        dis[pr] = cost;
        que.emplace(-cost, pr);
    }
}

void consider(const string& s1, const string& s2, ll cost) {
    if (cost >= ans)
        return;
    int l1 = s1.size(), l2 = s2.size(), mn = min(l1, l2);
    for (int i = 0; i < mn; i++) {
        if (s1[i] != s2[l2 - i - 1])
            return;
    }
    if (l1 == l2) {
        ans = min(ans, cost);
        return;
    }
    if (l1 > l2) {
        string new_str = s1.substr(mn);
        if (is_palindrome(new_str))
            ans = min(ans, cost);
        else
            push(new_str, "", cost);
    } else {
        string new_str = s2.substr(0, l2 - l1);
        if (is_palindrome(new_str))
            ans = min(ans, cost);
        else
            push("", new_str, cost);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> strs(n);
    vector<ll> cost(n);
    for (int i = 0; i < n; i++) {
        cin >> strs[i] >> cost[i];
        consider(strs[i], "", cost[i]);
    }
    while (que.size()) {
        ll d; pair<string, string> pr;
        tie(d, pr) = que.top();
        que.pop();
        d *= -1;
        if (d != dis[pr]) {
            continue;
        } else {
            for (int i = 0; i < n; i++) {
                if (pr.first.empty())
                    consider(strs[i], pr.second, d + cost[i]);
                else
                    consider(pr.first, strs[i], d + cost[i]);
            }
        }
    }
    if (ans >= 2e18)
        cout << "-1\n";
    else
        cout << ans << '\n';
    return 0;
}


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

int main(){
    int A,B,cnt=0;
    cin >> A >> B;
    for (int i=A;i<=B;i++) {
        string S = to_string(i);
        if ((S[0]==S[4])&&(S[1]==S[3])) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;


int main(){
    int t=1;
    //cin>>t;
    while(t--){
        int k;
        cin>>k;
        lli res=0;
        for(int a=1;a<=k;a++){
            for(int b=1;b<=k;b++){
                for(int c=1;c<=k;c++){
                    res+=__gcd(c,__gcd(b,a));
                }
            }
        }
        cout<<res;
    }
    return 0;
}
    

Measured memory_bytes: 3620
#include <vector>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n, q;
    string s;
    cin  >> n >> q;
    cin >> s;
    vector<int> l(1000001);
    vector<int> r(1000001);

    for(int i=0; i<q; i++)
    {
        cin >> r[i] >> l[i];
    }

    vector<int> ruiseki(n+1, 0);
    ruiseki[0] = 0;
    ruiseki[1] = 0;
    for(int i=1; i<n; i++)
    {
        ruiseki[i+1] = ruiseki[i];
        if (s[i-1]=='A' && s[i]=='C')
        {
            ruiseki[i+1] += 1;
        }
    }
    for (int i=0; i<q; i++)
    {
        cout << ruiseki[l[i]] - ruiseki[r[i]] << endl;
    }

    return 0;
}

Measured memory_bytes: 9216
main = do
    [a, b] <- map read . words <$> getLine
    putStrLn $ solve a b

solve a' b' | a > b = "Alice"
            | a < b = "Bob"
            | otherwise = "Draw"
    where a = (a' + 11) `mod` 13
          b = (b' + 11) `mod` 13

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, n) for(int i = n-1; i >= 0; i--)
#define rep4(i, x, n) for(int i = x; i > n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int N;
    string S;
    cin >> N >> S;
    vector<int> R, G, B;
    rep(i, 3*N){
        if(S[i] == 'R') R.push_back(i);
        elif(S[i] == 'G') G.push_back(i);
        else B.push_back(i);
    }
    int a[N], b[N], c[N];
    rep(i, N){
        int num[3];
        num[0] = R[i];
        num[1] = G[i];
        num[2] = B[i];
        sort(num, num+3);
        a[i] = num[0];
        b[i] = num[1];
        c[i] = num[2];
    }
    ll cb[N], ba[N];
    int j = 0, k = 0;
    rep(i, N){
        while(j < N-1){
            if(b[j+1] < c[i]) j++;
            else break;
        }
        cb[i] = j;
        while(k < N-1){
            if(a[k+1] < b[i]) k++;
            else break;
        }
        ba[i] = k;
    }
    ll ans = 1;
    rep(i, N){
        ans *= (cb[i]+1-i);
        ans %= MOD2;
        ans *= (ba[i]+1-i);
        ans %= MOD2;
    }
    rep2(i, 1, N+1){
        ans *= i;
        ans %= MOD2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4860
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;


int main() {
    int w,h,n;
    cin>>w>>h>>n;
    vector<int>x(n);
    vector<int>y(n);
    vector<int>a(n);
    vector<int>v1;
    vector<int>v2;
    vector<int>v3;
    vector<int>v4;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>a[i];
        if(a[i]==1){
            v1.push_back(i);
        }
        if(a[i]==2){
            v2.push_back(i);
        }
        if(a[i]==3){
            v3.push_back(i);
        }
        if(a[i]==4){
            v4.push_back(i);
        }
    }

    int x1=0;
    int x2=w;
    int y3=0;
    int y4=h;

    for(int i=0;i<v1.size();i++){
        x1=max(x1,x[v1[i]]);
    }
    for(int i=0;i<v2.size();i++){
        x2=min(x2,x[v2[i]]);
    }
    for(int i=0;i<v3.size();i++){
        y3=max(y3,y[v3[i]]);
    }
    for(int i=0;i<v4.size();i++){
        y4=min(y4,y[v4[i]]);
    }
    if(x2-x1<=0){
        cout<<0<<endl;
        return 0;
    }
    if(y4-y3<=0){
        cout<<0<<endl;
        return 0;
    }
    cout<<(x2-x1)*(y4-y3)<<endl;




    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

class Main{

    public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	while(sc.hasNext()){
	    String s1=sc.next();
	    String s2=sc.next();
	    int[][] dp=new int[s1.length()+1][s2.length()+1];
	    int res=0;
	    for(int i=1;i<=s1.length();i++){
		for(int j=1;j<=s2.length();j++){
		    dp[i][j]=(s1.charAt(i-1)==s2.charAt(j-1) ? 1+dp[i-1][j-1] : 0);
		    res=Math.max(res,dp[i][j]);
		}
	    }
	    System.out.println(res);

	}

    }


}

Measured memory_bytes: 290716
function isprime(n)
    if n <= 1 return false end
    if n == 2 return true end

    for i = 3:2:(n÷2)
        if n % i == 0 return false end
    end

    return true
end

function solve()
    X = parse(Int, readline())

    i = X
    while true
        if isprime(i)
            println(i)
            break
        end
        i+=1
    end
end

solve()


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

int main()
{
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n - 1);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++)
  {
    cin >> b[i];
    ans += b[i];
  }
  for (int i = 0; i < n - 1; i++)
  {
    cin >> c[i];
  }
  for (int i = 0; i < n - 1; i++)
  {
    if (a[i + 1] == a[i] + 1)
    {
      ans += c[a[i] - 1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256