akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
}


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

int main(){
    int X,Y;
    cin >> X >> Y;
    int Z=0;
    
    if(Y < 2*X || Y > 4*X){
        Z = 1;
    }

    if(Y % 2 != 0){
        Z = 1;
    }

    int turu,kame;
    turu = Y - 2*X;
    turu /= 2;

    kame = X - turu;
    if(kame < 0 || turu < 0){
        Z = 1;
    } 
    if(Z == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main () {
    int r, g, b;
    cin >> r >> g >> b;

    if ((100 * r + 10 * g + b) % 4 == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lld n,i,s=0;
    cin>>n;
    lld a[n+2];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i%2==1&&a[i]%2==1)
        {
            s++;
        }
    }
    cout<<s<<"\n";
	return 0;
}


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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n, a, cnt = 1, ans;
   cin >> n;
   vector<int> x, y;

   rep(i, n)
   {
      cin >> a;
      x.push_back(a);
   }
   ans = x[0];

   for (int i = 1; i < n; ++i)
   {
      if (ans >= x[i])
      {
         ++cnt;
         ans = x[i];
      }
   }
   cout << cnt << '\n';
}

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

struct p {
  long x, y;
};
struct circle {
  p c;
  long r;
};
int main() {
  p s, t;
  cin>>s.x>>s.y>>t.x>>t.y;
  int n;
  cin>>n;
  circle c[n+2];
  for (int i=1; i<=n; i++) cin>>c[i].c.x>>c[i].c.y>>c[i].r;
  c[0].c = s;
  c[0].r = 0;
  c[n+1].c = t;
  c[n+1].r = 0;

  vector<pair<double, int> > g[n+2];
  for (int i=0; i<n+2; i++) {
    for (int j=i+1; j<n+2; j++) {
      double d = sqrt(pow(c[i].c.x - c[j].c.x, 2) + pow(c[i].c.y - c[j].c.y, 2));
      double w = max(d - c[i].r - c[j].r, 0.0);
      g[i].emplace_back(w, j);
      g[j].emplace_back(w, i);
    }
  }
  priority_queue<pair<double, int>, vector<pair<double, int> >, greater<pair<double, int>>> pq;

  bool used[n+2];
  for (int i=0; i<n+2; i++) used[i] = false;
  double d[n+2];
  double inf = 2 * 1e12;
  for (int i=0; i<n+2; i++) d[i] = inf;
  pq.push(make_pair(0, 0));
  d[0] = 0.0;
  while (!pq.empty()) {
    auto top = pq.top();
    pq.pop();
    double d_cur = top.first;
    int cur = top.second;
    if (used[cur]) {
      continue;
    }
    used[cur] = true;
    for (auto e: g[cur]) {
      double w = e.first;
      int to = e.second;
      if (used[to]) {
        continue;
      }
      if (d[cur] + w < d[to]) {
        d[to] = d[cur] + w;
        pq.push(make_pair(d[to], to));
      }
    }
  }
  printf("%.9lf\n", d[n+1]);
}

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

class D
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var rs = new int[h[0] - 1].Select(_ => read()).ToArray();
		map = rs.Concat(rs.Select(r => new[] { r[1], r[0] })).GroupBy(r => r[0]).ToDictionary(g => g.Key, g => g.Select(r => r[1]).ToArray());
		ops = new int[h[1]].Select(_ => read()).GroupBy(a => a[0]).ToDictionary(g => g.Key, g => g.Sum(a => a[1]));

		c = new int[h[0] + 1];
		FindPoints(1, 0);
		Console.WriteLine(string.Join(" ", c.Skip(1)));
	}

	static Dictionary<int, int[]> map;
	static Dictionary<int, int> ops;
	static int[] c;

	static void FindPoints(int p, int p0)
	{
		c[p] = c[p0] + (ops.ContainsKey(p) ? ops[p] : 0);
		if (map.ContainsKey(p)) foreach (var q in map[p]) if (q != p0) FindPoints(q, p);
	}
}


Measured memory_bytes: 111780
#include<stdio.h>
int fibonacci(int n){
  int F[45];
  int i;

  F[0] = 1;
  F[1] = 1;
  for(i=2;i<=n;i++) F[i] = F[i-2] + F[i-1];
 
  return F[i-1];
}

int main(){
  int n;

  scanf("%d",&n);
  printf("%d\n",fibonacci(n));
  
  return 0;
}



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

#define int long long

const int mod = 1e9+7;

int n, k;

void mult(int ans[59][59], int base[59][59]){
    int rep[59][59] = {0};
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                rep[i][j] += ans[i][k] * base[k][j];
                rep[i][j] %= mod;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            ans[i][j] = rep[i][j];
        }
    }
}

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

    cin >> n >> k;
    int base[59][59];

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin >> base[i][j];
        }
    }

    int answer[59][59];
    for(int i = 0; i <= n; i++){
        answer[i][i] = 1;
    }

    while(k){
        if(k%2 == 1){
            mult(answer, base);
        }
        mult(base, base);
        k/=2;
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            ans+=answer[i][j];
            ans%=mod;
        }
    }
    cout << ans << endl;
}


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

#define ull unsigned long long
#define ll long long

using namespace std;

ll m = 1e9 + 7;

ll mod(ll a, ll b)
{
    return ((a % b) + b) % b;
}

ll modmulti(ll a, ll b)
{
    return mod(mod(a, m) * mod(b, m), m);
}

ll modsum(ll a, ll b)
{
    return mod(mod(a, m) + mod(b, m), m);
}

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

    ull ans = 0, n;
    cin >> n;
    vector<ull> v(n + 1);
    vector<ull> s(n + 1);
    for (ull i = 1; i <= n; i++)
    {
        cin >> v[i];
        s[i] = modsum(s[i - 1], v[i]);
        if (s[i] >= m)
            s[i] %= m;
    }
    for (ull i = 1; i <= n - 1; i++)
    {
        ans = modsum( ans, modmulti(v[i], s[n] - s[i]) );
        if (ans >= m)
            ans %= m;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
int n,k,x,vis[11];
int check(int n){
	bool flag=true;
	while(n){
		if (vis[n%10]==1){
			flag=false;
			break;
		}
		n/=10;
	}
	if (flag) return 1;
	return 0;
}
int main(){
	scanf("%d%d",&n,&k);
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=k;i++){
		scanf("%d",&x);
		vis[x]=1;
	}
	while(!check(n)){
		n++;
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int[] c = new int[a];
    int d = 0;
    int counter = 1;
    for(int i = 0;i < c.length;i++){
      c[i] = sc.nextInt();
    }
    for(int j = 0;j < c.length;j++){
      d += c[j];
      if(b >= d){
        counter++;
      }
    }
    System.out.println(counter);
  }
}

Measured memory_bytes: 21844
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    List<int>[] es;

    void calc()
    {
        cin = new Scanner();
        string S = cin.next();
        int ans = 0;
        for (int i = 0; i < S.Length - 1; i++)
        {
            if (S[i] != S[i + 1]) ans++;
        }
        Console.WriteLine(ans);
    }
    
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1E9 + 7;
const int INF = 1 << 29;

ll N;

void rec(ll cur, ll isUsed, ll &count) {
  if (cur > N) return;
  if (isUsed == 0b111) ++count;
  rec(cur * 10 + 7, isUsed | 0b001, count);
  rec(cur * 10 + 5, isUsed | 0b010, count);
  rec(cur * 10 + 3, isUsed | 0b100, count);
}

int main() {
  cin >> N;
  ll count = 0;
  rec(0, 0, count);
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int m, f, r;
    while(1){
        scanf("%d%d%d", &m, &f, &r);
        
        if(m == -1 && f == -1 && r == -1){break;}
        if(m == -1 || f == -1){printf("F\n");
        }else if(m + f >= 80){printf("A\n");
        }else if(m + f >= 65){printf("B\n");
        }else if(m + f >= 50){printf("C\n");
        }else if(m + f >= 30){
            if(r >= 50){
                printf("C\n");
            }else{printf("D\n");
            }
        }else{printf("F\n");
        }
    }
     return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}

const ll MAX = 1e18;

int main(){
    int a, b;
    cin >> a >> b;
    for(int i = 0; i < 1004; i++){
        if(int(i*0.08) == a && int(i*0.1) == b)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static Scanner sc;

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		// a+b:c
		// a:b+c
		// a+c:b

		if (a + b == c || a == b + c || a + c == b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 9168
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,m;
    cin>>n>>m;
    vec s(m);
    vec c(m);
    rep(i,m){
        cin>>s[i]>>c[i];
        s[i]--;
    }
    vec a(10,-1);
    int ng=0;
    rep(i,m){
        if(a[s[i]]==-1 || a[s[i]]==c[i]){
            a[s[i]]=c[i];
        }
        else{
            ng++;
        }
    }

    if(n==2){
        if(a[0]==0) ng++;
    }
    else if(n==3){
        if(a[0]==0) ng++;
    }

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

    if(ng!=0) cout<<-1<<endl;
    else{
    rep(i,n){
        cout<<a[i];
    }
    cout<<endl;
    }
}

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

#define REP(i,n) for(i=0;i<n;i++)
#define ll long long

int main(void){
    char s[3];
    int i, ans=700;

    REP(i,3){
        scanf("%c",&s[i]);
    }
    
    if(s[0]=='o') ans=ans+100;
    if(s[1]=='o') ans=ans+100;
    if(s[2]=='o') ans=ans+100;

    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll K;
int main()
{
    cin >> K;
    int N = 50;
    vector<ll> result(50);
    for (int i = 0; i < result.size(); i++)
    {
        result[i] = i;
        result[i] += K / N;
    }
    K %= N;
    for (int i = 0; i < K; i++)
    {
        result[i] += N;
        for (int j = 0; j < result.size(); j++)
        {
            if (i == j)
            {
                continue;
            }
            result[j]--;
        }
    }
    cout << N << endl;
    for (auto &val : result)
    {
        cout << val << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 2e5 + 5;

int n,a[N];
ll ans;

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

Measured memory_bytes: 4388
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N=II()
A=LI()
L=[_ for _ in range(N)]
i = 1
for a in A:
    L[a-1] = i
    i += 1
p2S(L)

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

using namespace std;

const int mod = 1e9 + 7;

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

int main()
{
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector <vector <int> > can (n,vector <int> (n));
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
        cin >> can[i][j];

    vector <int> dp(1 << n);
    dp[0]=1;
    for (int mask=0;mask<(1 << n)-1;mask++)
    {
        int a=__builtin_popcount(mask);
        for (int b=0;b<n;b++)
            if (can[a][b] && !(mask & (1<<b)))
        {
            int tmp=mask ^ (1 << b);
            add_self(dp[tmp],dp[mask]);
        }
    }

    cout << dp[(1<<n)-1];
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 10000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n, a;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> a;
    n = n * n;
    cout << n - a << endl;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define v vector
#define ALL(x) x.begin(),x.end()
#define rALL(x) x.rbegin(),x.rend()
#define endl '\n'
#define DEBUG

template<typename T> void DBG(const char* name, T&& H) {
	cerr << name << " = " << H << ')' << endl;
}

template<typename T, typename... Args> void DBG(const char* names, T&& H, Args&&... args) {
	const char* NEXT = strchr(names+1, ',');
	cerr.write(names, NEXT-names) << " = " << H << " |";
	DBG(NEXT+1, args...);
}

#ifdef DEBUG
	#define dbg(...) cerr << __FUNCTION__ << ' ' <<__LINE__ << " : (", DBG(#__VA_ARGS__, __VA_ARGS__)
#else
	#define dbg(...)
#endif

using ll = long long;
using ld = long double;

const ll mod = 1e9 + 7;
const ld PI = acos(-1.0);

void Solve() {
	string s;
	cin >> s;
	s = " " + s;
	vector<string> dict = {"dream", "erase", "eraser", "dreamer"};
	vector<bool> dp(s.size(), 0);
	dp[0] = 1;
	for(int i = 1; i < s.size(); i ++) {
		for(int j = 0; j < 4; j ++) {
			if(dict[j].size() > i) continue;
			bool match = true;
			for(int k = i+1-dict[j].size(), a = 0; k <= i; k ++, a ++) {
				if(dict[j][a] != s[k]) match = false;
			}
			if(dp[i-dict[j].size()]) dp[i] = match;
			else dp[i] = false;
			if(dp[i]) break;
		}
	}
	if(dp[s.size()-1]) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

	int tt = 1;
	while(tt --) {
		Solve();
	}
	
	return 0;
}

Measured memory_bytes: 512
a=input()
n=int(input())
for i in range(n):
	b=input().split()
	if b[0]=='print':
		print(a[int(b[1]):int(b[2])+1])
	elif b[0]=='replace':
		a=a[:int(b[1])]+b[3]+a[int(b[2])+1:]
	elif b[0]=='reverse':
		c=(a[int(b[1]):int(b[2])+1])
		c=c[::-1]
		a=a[:int(b[1])]+c+a[int(b[2])+1:]
		
		
		
		


Measured memory_bytes: 5612
open Batteries
let reverse s = let len = String.length s in
  String.init len (fun i -> s.[len - 1 - i])
let cut st str = String.init (String.length str - st) (fun a -> String.get str (a+st))
let get num str = String.init num (fun a -> String.get str a)
let s = read_line ()
let n = String.length s
let before = get (n/2) s
let after = cut (n/2+1) s
let before_n = String.length before
let after_n = String.length after

let b_b = get (before_n/2) before
let b_a = reverse @@ if before_n mod 2 = 0 then cut (before_n/2) before else cut (before_n/2+1) before
let a_b = get (after_n/2) after
let a_a = reverse @@ if after_n mod 2 = 0 then cut (after_n/2) after else cut (after_n/2+1) after

let _ = (if before = after && b_b = b_a && a_b = a_a then "Yes" else "No") |> print_endline


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

using namespace std;

int main() {
    int a, b, c, w;
    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: 3088
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
const Int maxi = 10000000 + 1;
int cal[10000000 + 10] = {};
int main(){
    vector<bool>prime(maxi,true);
    for(int i = 0; i < maxi; ++i) cal[i] = 1;
    for(int i = 2; i < prime.size(); ++i){
        if(not prime[i]) continue;
        prime[i] = false;
        cal[i] = 1;
        for(int j = 1; i * j < maxi; ++j){
            Int cnt = 1;
            Int num = j;
            while(num % i == 0){++cnt; num /= i;}
            cal[i * j] *= (cnt + 1 ) ;
            prime[i * j] = false;
        }
    }
    int N; cin >> N;
    cal[1] = 1;
    Int ans = 0;
    for(Int i = 1; i <= N; ++i)
        ans += i * cal[i];
    cout << ans << endl;
    
}



Measured memory_bytes: 43448
//Don't give up too easy bhai
#pragma GCC optimize("-O3")
 
#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define double long double
#define inf 1e18

typedef pair<int,int> pii;
 
#define forall(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define vi vector<int>
#define vd vector<double>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define br cout<<"\n"
#define whatis(x) cerr << "var "<<#x << " ==> " << x<<"\n"
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define T int __t;cin>>__t;while(__t--)

void solve()
{
	
}

signed main()
{
	fast;

	int n;cin>>n;
	map<int,int>x;
	forall(i,1,sqrt(n)+1){
		forall(j,1,sqrt(n)+1) {
			forall(k,1,sqrt(n)+1) {
				int t = i*i + j*j + k*k + i*j +j*k+i*k;
				if(t<=n) x[t]++;
			}
		}
	}

	forall(i,1,n+1) cout<<x[i],br;


	return 0;
}

Measured memory_bytes: 4220
#include <cstdio>
#define Maxn 200000
int a[Maxn+5];
int fa[Maxn+5];
int head[Maxn+5],arrive[Maxn<<1|5],nxt[Maxn<<1|5],tot;
void add_edge(int from,int to){
	arrive[++tot]=to;
	nxt[tot]=head[from];
	head[from]=tot;
}
int n,m;
void dfs(int root,int x){
	a[root]+=x;
	x=a[root];
	for(int i=head[root];i;i=nxt[i]){
		if(arrive[i]==fa[root]){
			continue;
		}
		fa[arrive[i]]=root;
		dfs(arrive[i],x);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	int u,v;
	for(int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		a[u]+=v;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++){
		printf("%d ",a[i]);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 17152
n=int(input())
ac, wa, tle, re=0, 0, 0, 0
for i in range(n):
  s=input(str())
  if s=='AC':
    ac=ac+1
  elif s=='WA':
    wa=wa+1
  elif s=='TLE':
    tle=tle+1
  elif s=='RE':
    re=re+1

print('AC x ', ac)
print('WA x ', wa)
print('TLE x ', tle)
print('RE x ', re)

Measured memory_bytes: 9188
#include<iostream>
#include<cctype>
#include<vector>
#include <ctype.h>
#include<algorithm>
#include<queue>
#include<string>
#include <math.h>
#include <iomanip>
using namespace std;
int n,p;
int main() {
	cin >> n >> p;
	if (n % 3 != 0 && p % 3 != 0 && (n + p) % 3 != 0)cout << "Impossible" << endl; else cout << "Possible" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n, k, h[100000], ans=1e9;
	cin >> n >> k;
	for(int i=0; i<n; i++){
		cin >> h[i];
	}
	sort(h, h+n);
	for(int i=0; i<n-k+1; i++){
		ans=min(ans, h[i+k-1]-h[i]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3

N, K = map(int, input().split())

h = list(map(int, input().split()))
# print(N, K, h)

inf = float("inf")
dp = [inf for _ in range(N)]

dp[0] = 0

# 配るDP
# for i in range(N):
#     for k in range(1, K + 1):
#         if i + k < N:
#             k_step = dp[i] + abs(h[i] - h[i + k])
#             dp[i + k] = min(dp[i + k], k_step)

# 貰うDP
for i in range(1, N):
    for k in range(1, K + 1):
        if i - k >= 0:
            k_step = dp[i - k] + abs(h[i - k] - h[i])
            dp[i] = min(dp[i], k_step)

print(dp[N - 1])


Measured memory_bytes: 58848
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
///-------------------------

int main()
{
    Phuong_; /// <3333
    char t;
    cin >> t;
    if (t>='a' && t<='z') cout << 'a'; else cout << 'A';
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<int> sum1(n);
    vector<int> sum2(n);
    vector<int> a1(n);
    vector<int> a2(n);
    rep(i, n) cin >> a1[i];
    rep(i, n) cin >> a2[i];
    rep(i, n) {
        if (i==0) sum1[i] = a1[i];
        else sum1[i] = sum1[i-1] + a1[i];
    }
    for (int i=n-1; i>=0; i--) {
        if (i==n-1) sum2[i] = a2[i];
        else sum2[i] = sum2[i+1] + a2[i];
    }
    int ans = 0;
    rep(i, n) {
        int now = sum1[i] + sum2[i];
        chmax(ans, now);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
from math import gcd
MOD = 10**9 + 7
n = int(input())
zero = 0
cnt = dict()
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zero += 1
        continue
    g = gcd(x, y)
    x //= g
    y //= g
    if y < 0 or (y == 0 and x < 0):
        x *= -1
        y *= -1
    rot_90 = 1 if x <= 0 else 0
    if rot_90:
        x, y = y, -x
    try:
        cnt[(x, y)][rot_90] += 1
    except KeyError:
        cnt[(x, y)] = [int(not rot_90), rot_90]

ans = 1
for s, t in cnt.values():
    now = 1
    now += (pow(2, s, MOD) - 1) % MOD
    now += (pow(2, t, MOD) - 1) % MOD
    ans *= now
ans -= 1
ans += zero
print(ans % MOD)

Measured memory_bytes: 62788
from statistics import mean, median,variance,stdev
import sys
import math

x = input().split()
#y = input().split()
a= []
#for i in range(len(x)):
 #   a.append(int(x[i]))

if x[0][len(x[0])-1] == x[1][0] and x[1][len(x[1])-1] == x[2][0]:print("YES")
else:print("NO")

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

int main(){
	char* str;
	int i = 0;
	int j = 1;
	int n;

	str = (char*)calloc(200001,sizeof(char));

	scanf("%s",str);

	while( str[i] != 'A' ){
		i++;
	}

	n = strlen(str);
	j = n - 1;

	while( str[j] != 'Z' ){
		j--;
	}

	printf("%d\n",j-i+1);

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
	char t;
	map<char, int> val;
	FOR(i,2,9) val[i+'0'] = i;
	val['T'] = 10;
	val['J'] = 11;
	val['Q'] = 12;
	val['K'] = 13;
	val['A'] = 14;

	while (cin >> t && t != '#'){
		string s[4][13];
		REP(i,4) REP(j,13) cin >> s[i][j];
		int l = 0;
		int win[4] = {};
		REP(j,13){
			int a[4];
			REP(i,4){
				a[i] = val[s[i][j][0]];
				if (s[i][j][1] == t) a[i] += 15;
				else if (s[i][j][1] != s[l][j][1]) a[i] = 0;
			}
			REP(i,4){
				if (a[i] > a[l]) l = i;
			}
			win[l]++;
		}

		int ew = win[1]+win[3], ns = win[0]+win[2];
		if (ew > ns) printf("EW %d\n", ew - 6);
		else printf("NS %d\n", ns - 6);

	}
    return 0;
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define endl '\n'
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long 
using namespace std;
const int N = 1e5+10;
const int M = 1e9+7;
int main(){
	FIO;
	int h, w;
	cin >> h >> w;
	int a[h+1][w+1];
	memset(a,0,sizeof(a));
	string s[h+1];
	for (int i = 1; i <= h; ++i)
	{
		cin >> s[i];
		// cout << s[i] << "\n";
	}
	a[1][1] = 1;
	for (int i = 1; i <= h; ++i)
	{
		for (int j = 1; j <= w; ++j)
		{
			if(i == 1 && j == 1)
				continue;
			if(s[i][j-1]=='.')
				a[i][j] = (a[i][j] + a[i-1][j] + a[i][j-1])%M; 
		}
	}
	cout << a[h][w] << " ";
	return 0;
}

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

struct CLOTHES{
    int a;
    int b;
    int c;
};

int dp[256][256] = { 0 };

int main(){
    int d,n;
    cin >> d >> n;
    int t[256];
    for(int i = 1; i <= d; i++){
        cin >> t[i];
    }
    CLOTHES clo[256];
    for(int i = 1; i <= n; i++){
        cin >> clo[i].a >> clo[i].b >> clo[i].c;
    }
    
    for(int i = 1; i <= d; i++){
        for(int i2 = 1; i2 <= n; i2++){
            if(t[i] >= clo[i2].a && t[i] <= clo[i2].b){
                if(i == 1){ dp[i][i2] = abs(0 - clo[i2].c); }
                else{
                    for(int j = 1; j <= n; j++){
                        if(dp[i - 1][j] != -1){
                            if(i != 2){
                                dp[i][i2] = max(dp[i][i2], dp[i - 1][j]+abs(clo[j].c - clo[i2].c));
                            }
                            else { dp[i][i2] = max(dp[i][i2], abs(clo[j].c - clo[i2].c)); }
                        }
                    }
                }
            }
            else{ dp[i][i2] = -1; }
        }
    }

    int ans = -1;
    for(int i = 1; i <= n; i++){ ans = max(ans, dp[d][i]); }
    cout << ans << endl;
}

Measured memory_bytes: 3300
import java.util.Scanner;

// https://atcoder.jp/contests/abc139/tasks/abc139_c
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int[] arrayH = new int[N];
		for(int i=0;i<N;i++) {
			arrayH[i] = sc.nextInt();
		}
		sc.close();

		int ans = 0;
		int count = 0;

		for(int i = 0;i<N-1;i++) {
			if(arrayH[i]>=arrayH[i+1]) {
				count++;
			}else {
				ans = Math.max(count,ans);
				count = 0;
			}
		}
		ans = Math.max(count,ans);

		System.out.println(ans);
	}

}


Measured memory_bytes: 49004
from decimal import Decimal, getcontext
a, b = map(int, input().split())
getcontext().prec = 50
c = Decimal(a) * Decimal(b)
if a == 1 or b == 1:
    print(1)
else:  
    if c % 2 == 1:
        print(int(c/2)+1)
    else:
        print(int(c/2))


Measured memory_bytes: 5076
n, m = map(int, input().split())
graph = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

visit = [0] * (n + 1)
ans = 0


def dfs(now, depth):
    global ans
    if visit[now]:
        pass
    if depth == n:
        ans += 1

    visit[now] = 1
    if graph[now]:
        for i in graph[now]:
            if visit[i] == 0:
                dfs(i, depth + 1)
    visit[now] = 0


dfs(1, 1)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <queue>
#include <map>

#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
#define INF 1e12
typedef long long ll;
using namespace std;


int main()
{
	int a, b, h;
	cin >> a >> b >> h;
	int ans = (a + b) * h / 2;
	co(ans);
	return 0;
}

Measured memory_bytes: 256
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    N=int(input())
    A=[]
    for i in range(N):
        S,P=pin(str)
        P=int(P)
        A.append((S,P,i+1))
    A.sort(key=lambda x:x[1],reverse=True)
    A.sort(key=lambda x:x[0])
    for a in A:
        print(a[2])

#%%submit!
resolve()

Measured memory_bytes: 38512
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll INF=1e18;
int n;
ll a[3001];
ll memo[2][3001][3001];
ll solve(int p, int l, int r){
	if(l==r){
		if(p==0) return a[l];
		else return -a[l];
	}
	if(memo[p][l][r]!=INF) return memo[p][l][r];
	if(p==0){
		ll ans=max(solve(1-p, l+1, r)+a[l], solve(1-p, l, r-1)+a[r]);
		return memo[p][l][r]=ans;
	}else{
		ll ans=min(solve(1-p, l+1, r)-a[l], solve(1-p, l, r-1)-a[r]);
		return memo[p][l][r]=ans;
	}
}
int main()
{
	cin>>n;
	for(int i=0; i<n; i++) cin>>a[i];
	for(int i=0; i<n; i++){
		for(int j=i; j<n; j++){
			memo[0][i][j]=memo[1][i][j]=INF;
		}
	}
	cout<<solve(0, 0, n-1)<<endl;
	return 0;
}

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

int main( int argc, char *argv[] )
{
long long a;
long long b;
long long x;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> a;
	cin >> b;
	cin >> x;
	cout << ( ( x + b ) / x ) - ( ( x + a - 1 ) / x ) << endl;

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ifor(n) for(int i=0;i<n;i++) 
#define jfor(n) for(int j=0;j<n;j++)
#define Ifor(n) for(int i=1;i<n;i++) 
#define Jfor(n) for(int j=1;j<n;j++)
const int inf=0x3f3f3f3f;
char s[600004];
int main(){
    scanf("%s",&s[300000]);
    int l=300000,r=strlen(s+300000)+l-1;
    int q;
    scanf("%d",&q);
    int flag=0;
    while(q--){
    	int t;
    	scanf("%d",&t);
    	if(t==1)flag=1-flag;
    	if(t==2){
    		int f;
    		char c;
    		scanf("%d %c",&f,&c);
    		if(f==1){
    			if(flag==0){
    				l--;
    				s[l]=c;
				}
				if(flag==1){
					r++;
					s[r]=c;
				}
			}
			if(f==2){
				if(flag==0){
					r++;
					s[r]=c;
				}
				if(flag==1){
					l--;
					s[l]=c;
				}
			}
		}
	}
	if(flag==0) for(int i=l;i<=r;i++)printf("%c",s[i]);
	else for(int i=r;i>=l;i--)printf("%c",s[i]);
	printf("\n");
} 

Measured memory_bytes: 768
struct Restaurant {
  let index: Int
  let city: String
  let point: Int
}

var table: [String: [Restaurant]] = [:]

let N = Int(readLine()!)!

for i in 1...N {
  let inp = readLine()!.split(separator: " ").map { String($0) }
  table[inp[0], default: []].append(Restaurant(index: i, city: inp[0], point: Int(inp[1])!))
}
for key in table.keys.sorted() {
  for r in table[key]!.sorted { $0.point > $1.point } {
    print(r.index)
  }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 111;

int H, W;
string S[MAX];

bool visit[MAX][MAX];

int isWhite(int x, int y) {
    return S[y][x] == '.';
}

int solve() {
    queue<ii> w, b;
    if (isWhite(0, 0)) {
        w.push(ii(0, 0));
        visit[0][0] = true;
    }
    else w.push(ii(-1, 0));

    int ans = 0;
    while (1) {
        while (!w.empty()) {
            int x = w.front().first, y = w.front().second; w.pop();
            if (x == W-1 && y == H-1) return ans;
            if (x < W-1 && !visit[y][x+1]) {
                visit[y][x+1] = 1;
                if (isWhite(x+1, y)) w.push(ii(x+1, y));
                else b.push(ii(x+1, y));
            }
            if (x == -1) continue;
            if (y < H-1 && !visit[y+1][x]) {
                visit[y+1][x] = 1;
                if (isWhite(x, y+1)) w.push(ii(x, y+1));
                else b.push(ii(x, y+1));
            }
        }
        ans++;
        while (!b.empty()) {
            int x = b.front().first, y = b.front().second; b.pop();
            if (x == W-1 && y == H-1) return ans;
            if (y < H-1 && !visit[y+1][x]) {
                visit[y+1][x] = 1;
                if (isWhite(x, y+1)) w.push(ii(x, y+1));
                else b.push(ii(x, y+1));
            }
            if (x < W-1 && !visit[y][x+1]) {
                visit[y][x+1] = 1;
                if (isWhite(x+1, y)) w.push(ii(x+1, y));
                else b.push(ii(x+1, y));
            }            
        }
    }
}

int main() {
    cin >> H >> W;
    REP (i, H) cin >> S[i];
    cout << solve() << endl;
}

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

int main(void){
 	char a,b;
  	cin >> a >> b;
  
  	if((a=='H'&&b=='H')||(a=='D'&&b=='D')) cout << 'H' << endl;
  	else cout << 'D' << endl;
  
  	return 0;
}

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


ll mul(ll x, ll y, ll z) {
    ll xx = x / z;
    ll yy = y / z;

    if (x % z == 0) return yy - xx + 1;
    else return yy - xx;
}


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

    ll s = mul(a, b, c);
    ll t = mul(a, b, d); 
    ll cd = __gcd(c, d);
    ll lcm = c / cd * d;
    ll u = mul(a, b, lcm); 
    

    cout << b - a + 1 - (s + t - u);
}


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

int main() {
  int n;
  string s;
  cin>>n>>s;
  rep(i,s.size()) {
    cout<<(char)('A'+((s[i]-'A')+n)%26);
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int x = sc.nextInt();
    int tmp_p = x;
    int res = 0;

    for (int i = 0; i < x; i ++) {
      if (x==1) {
        res = 1;
        break;
      }
      
      for (int j = 2; j < tmp_p; j++) {
        if ((int)Math.pow(i, j) <= x) {
          res = Math.max(res, (int)Math.pow(i, j));
        } else {
          tmp_p = j;
          break;
        }
      }
    }

    System.out.println(res);
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
pair<ll,ll> p[n];
for(int i=0;i<n;i++) {cin>>p[i].first; p[i].second=i;}
sort(p,p+n);
for(int i=0;i<n;i++) cout<<p[i].second+1<<" ";
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
const int mod = 1e9 + 7;
int main() {
    int n;cin >> n;
    vector< pair<int,int> > a(n);
    for (int i = 0; i < n; ++i) {
        int x,l;cin>> x >> l;
        int left = x - l;
        int right = x + l;
        pair<int ,int> tmp = make_pair(right,left);
        a[i] =  tmp;
    }
    sort(a.begin(), a.end());
    int ans = 0;
    int now = a[0].second;
    for (int i = 0; i < n; ++i) {
        if(now > a[i].second){continue;}
        now = a[i].first;
        ans++;
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    int a1 = 1, a2 = 1, temp;
    for(int i = 1; i < n; i++){
        temp = a2;
        a2 += a1;
        a1 = temp;
    }
    printf("%d\n", a2);
    return 0;
}


Measured memory_bytes: 3196
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#define ll long long
#define MAX_VALUE 1000000000
#define MAX 100000

int main(void){
 int n;
 scanf("%d",&n);
 int a[200001];
 int i,j;
 for(i=0;i<n;i++){
  scanf("%d",&a[i]);
 }
 
 for(i=n-1;i>=0;i-=2)
  printf("%d ",a[i]);
 if(n%2==0){
 for(i=0;i<n;i+=2)
  printf("%d ",a[i]);
 }else{
 for(i=1;i<n;i+=2)
  printf("%d ",a[i]);
 }
 return 0;
}

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

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

Int a[222][222];
Int dp[2][222][222][222];
signed main(){
  memset(a,0,sizeof(a));
  Int h,w;
  cin>>h>>w;
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      cin>>a[i][j];
  
  memset(dp,-1,sizeof(dp));
  dp[0][0][0][0]=a[0][0];
  for(Int i=0;i<h;i++){
    for(Int l=0;l<w;l++){
      for(Int r=l;r<w;r++){
	for(Int k=0;k<2;k++){
	  if(dp[k][i][l][r]<0) continue;
	  if(l+1<=r)
	    chmax(dp[k][i][l+1][r],dp[k][i][l][r]+(!k)*(l+1<r)*a[i][l+1]);
	  if(r+1<w)
	    chmax(dp[1][i][l][r+1],dp[k][i][l][r]+a[i][r+1]);
	  
	  chmax(dp[0][i+1][l][r],dp[k][i][l][r]+a[i+1][l]+(l!=r)*a[i+1][r]);
	}
      }
    }
  }
  cout<<max(dp[0][h][w-1][w-1],dp[1][h][w-1][w-1])<<endl;
  return 0;
}


Measured memory_bytes: 171520