akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int A, B, C;

void solve() {
	cin >> A >> B >> C;
	int S = (A + B + C) / 2;
	cout << int(sqrt(S * (S - A) * (S - B) * (S - C) + eps)) << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
// In the name of ALLAH
#include <bits/stdc++.h>
using namespace std;

#define PB push_back
#define PF push_front
#define MP make_pair
#define FF first
#define SS second
#define _sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

ll n, k, ans = 1;

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k; ans = k;
	for (int i = 0; i < n - 1; i ++) ans *= k - 1;

	cout << ans << '\n';
}


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

const int MAXN = 1000001;
int dp[MAXN];

int rec(int n) {
  int &res = dp[n];
  if(res != -1) return res;
  if(n == 1) return res = 0;
  return res = rec(n%2 == 0 ? n/2 : n*3 + 1) + 1;
}

int main() {
  int n;
  fill(dp, dp+MAXN, -1);
  while(cin >> n && n) {
    cout << rec(n) << endl;
  }
  return 0;
}

Measured memory_bytes: 5064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
      int a[5];
      for(int i=0;i<5;i++)
         cin>>a[i];
      sort(a,a+5);
      int flag=0;
      for(int i=0;i<5;i++)
      {
          if(a[i]!=i)
          {
              flag=1;
              cout<<i<<endl;
           break;
          }
      }
      if(flag==0)
          cout<<5<<endl;
}



Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
constexpr int MOD = 1000000007;
//http://drken1215.hatenablog.com/entry/2018/08/05/224100_1
void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}
string S;
long long dp[210000][5];

/*
dp[i+1][0] i文字目まで考えた時にABCとの称号をスタートすらしてない
dp[i+1][1] i文字目まで考えた時Aまでは照合させたようなもの
dp[i+1][2] i文字目まで考えた時にBまでは照合させたようなもの
dp[i+1][3] i文字目まで考えたときにABCとの照合でCまでは照合させた
*/

void add(ll &a,ll b){
    a += b;
    if (a >= MOD) a-= MOD;
}

int main ()
{
    dp[0][0] = 1;
    cin>>S;
    REP(i,S.size()){
        //i文字目でカウントをすすめない
        REP(j,4){
            if (S[i] != '?') add(dp[i+1][j],dp[i][j]);
            else add(dp[i+1][j],dp[i][j] * 3 %MOD);
        }
        //i文字目でカウントをすすめる
        if (S[i] == 'A' || S[i] == '?') add(dp[i+1][1],dp[i][0]);
        if (S[i] == 'B' || S[i] == '?') add(dp[i+1][2],dp[i][1]);
        if (S[i] == 'C' || S[i] == '?') add(dp[i+1][3],dp[i][2]);
    }
    cout<<dp[S.size()][3]<<endl;
    return 0;
}

Measured memory_bytes: 4608
import java.util.*;
 
public class Main {
  	public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int y = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int[] array_p = new int[a];
      for (int i = 0; i < a; i++) {
        array_p[i] = sc.nextInt();
      }
      int[] array_q = new int[b];
      for (int j = 0; j < b; j++) {
        array_q[j] = sc.nextInt();
      }
      int[] array_r = new int[c];
      for (int k = 0; k < c; k++) {
        array_r[k] = sc.nextInt();
      }
      
      int[] array_x = new int[x];
      int[] array_y = new int[y];
      int[] array_eat = new int[x + y];
      long delicious = 0;
      
      Arrays.sort(array_p);
      Arrays.sort(array_q);
      Arrays.sort(array_r);
      for (int l = 0; l < x; l++) {
        array_x[l] = array_p[a-1-l];
      }
      for (int m = 0; m < y; m++) {
        array_y[m] = array_q[b-1-m];
      }
      System.arraycopy(array_x, 0, array_eat, 0, x);
      System.arraycopy(array_y, 0, array_eat, x, y);
      Arrays.sort(array_eat);
      
      for (int p = 0; p < array_eat.length; p++) {
        if ( (p + 1 <= c) && (array_eat[p] < array_r[c - (p + 1)]) ) {
          delicious += (long)array_r[c - (p + 1)];
        } else {
          delicious += (long)array_eat[p];
        }
      }
      System.out.println(delicious);
    }
}

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

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

    for (int i = 0; i <= 25; ++i)
    {
        for (int j = 0; j <= 15; ++j)
        {
            if ((i*4 + j*7)==n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

public static void main(String[] args) {
  Scanner scanner = new Scanner(System.in);
  String cases = scanner.next();
  String did = scanner.next();
  
  if (cases.equals(did)) {
    System.out.print("Yes");
  } else {
    System.out.print("No");
  }
}
}

  

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

using namespace std;

#define pb push_back

typedef long long ll;

const int mod = 1e9+7;

int n, i, j;
int m;
char s[1001][1002];
int dp[1001][1001];

int main(){
    memset(dp, 0, sizeof dp);
    scanf("%d %d",&n, &m);
    for(i=0;i<n;++i){
        scanf("%s", s[i]);
    }
    dp[0][0] = 1;
    for(i=1;i<m;++i){
        if(s[0][i]=='#') break;
        dp[0][i] = 1;
    }
    for(i=1;i<n;++i){
        if(s[i][0]=='#') break;
        dp[i][0] = 1;
    }
    for(i=1;i<n;++i){
        for(j=1;j<m;++j){
            if(s[i][j]=='#') continue;
            dp[i][j] = (dp[i][j-1]+dp[i-1][j])%mod;
        }
    }
    int ans = dp[n-1][m-1];
    printf("%d\n", ans);
    return 0;
}







Measured memory_bytes: 5120
N=int(input())
S=input()
sl=list(S)
change=[0]
for i in range(1,N):
  if (sl[i-1]==')')and(sl[i]=='('):
    change.append(i)

change.append(N)
r_add=0
l_add=0
for i in range(len(change)-1):
  A=sl[change[i]:change[i+1]]
  r=0
  l=0
  for a in A:
    if a=='(':
      l+=1
    else:
      r+=1
      
  if r==l:
    continue
  elif r>l:
    if r_add>0:
      if r_add>=r-l:
        r_add-=r-l
      else:
        l_add+=r-l-r_add
        r_add=0
        
    else:
      l_add+=r-l
      
  else:
    r_add+=l-r
      
print('('*l_add+S+')'*r_add)

Measured memory_bytes: 3064
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

	vector<P> M;
	rep(i, N)
	{
		P p;
		cin >> p.first >> p.second;
		M.push_back(p);
	}

	//dp[i] := 敵のHPをi削るために必要な魔力の最小値
	vector<ll> dp(H + 1, 10000000000);
	dp[0] = 0;

	reple(i, 1, H)
	{
		for (auto m : M)
		{
			int idx = max(i - m.first, 0);
			dp[i] = min(dp[i], dp[idx] + m.second);
		}
	}

	cout << dp[H] << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int A,B,K;cin >> A >> B >> K;
    set<int> ans;
    for(int i=A;i<min(A+K,B);++i) ans.insert(i);
    for(int i=max(A,B-K+1);i<=B;++i) ans.insert(i);
    for(auto itr=ans.begin();itr!=ans.end();++itr) cout << *itr << '\n';
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b,c;
  cin>>a>>b>>c;
  
  if(b-a==c-b) {
    cout<<"YES";
  }else {
    cout<<"NO";
  }
  
  return 0;
}

Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
pi ps[5005];
const lint INF=1e18;
lint dp[5005][5005];
int main(){
  cin>>n;
  REP(i,n){
    cin>>ps[i].fr>>ps[i].sc;
  }
  sort(ps,ps+n,[&](pi a,pi b){
    return a.fr+a.sc<b.fr+b.sc;
  });
  REP(i,5005) REP(j,5005) dp[i][j]=INF;
  REP(i,n){
    chmin(dp[1][i+1],(lint)ps[i].sc);
  }

  int res=0;
  REP(i,n+1){
    REP(j,n) if(dp[i][j]<INF){
      chmin(dp[i][j+1],dp[i][j]);
      if(dp[i][j]<=ps[j].fr){
        chmin(dp[i+1][j+1],dp[i][j]+ps[j].sc);
      }
    }
    if(dp[i][n]<INF) res=i;
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 195968
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    int n;
    int[] a;

    void run() {
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        a = new int[n];
        int[] r = new int[n], l = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        LinkedList<Integer> stack = new LinkedList<>();
        LinkedList<Integer> cnts = new LinkedList<>();
        stack.add(0);
        int cnt = 1;

        for (int i = 0; i < n; i++) {
            l[i] = 1;
            while (stack.getLast() > a[i]) {
                stack.removeLast();
                l[i] += cnts.removeLast();
            }
            stack.addLast(a[i]);
            cnts.addLast(l[i]);
        }

        stack.clear();
        stack.addLast(0);

        for (int i = n - 1; i >= 0; i--) {
            r[i] = 1;
            while (stack.getLast() > a[i]) {
                stack.removeLast();
                r[i] += cnts.removeLast();
            }
            stack.addLast(a[i]);
            cnts.addLast(r[i]);
        }

//        debug(l);
//        debug(r);

        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += 1L * a[i] * l[i] * r[i];
        }

        System.out.println(ans);

    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 92868
import java.util.Scanner;

public class Main {
	final boolean DEBUG = false;
	static class Node {
		private static boolean isFirstPrint = false;

		int id;
		Node l, r;
		Node(int id) {
			this.id = id;
		}

		void printPostOrder() {
			isFirstPrint = true;
			this.postorder();
		}
		void postorder() {
			if (this.l != null)
				this.l.postorder();
			if (this.r != null)
				this.r.postorder();
			System.out.print((isFirstPrint ? "" : " ") + this.id);
			isFirstPrint = false;
		}
	}
	Node[] nodes;
	int[] preIds, inIds;
	int preIndex, inIndex;

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		nodes = new Node[n + 1];
		preIds = new int[n];
		inIds = new int[n];
		preIndex = inIndex = 0;

		for (int i = 1; i <= n; i++)
			nodes[i] = new Node(i);
		for (int i = 0; i < n; i++)
			preIds[i] = scan.nextInt();
		for (int i = 0; i < n; i++)
			inIds[i] = scan.nextInt();

		int rootId = preIds[0];
		nodes[rootId] = makeTree(inIds);

		nodes[rootId].printPostOrder();
		System.out.println();
	}

	Node makeTree(int[] ids) {
		if (ids.length == 0)
			return null;
		if (ids.length == 1) {
			preIndex++;
			return nodes[ids[0]];
		}
		int rootId = preIds[preIndex++];
		int[] lIds = null, rIds = null;
		int lidx = 0, ridx = 0;
		for (int i = 0; i < ids.length; i++) {
			if (rootId != ids[i])
				continue;
			lidx = i;
			ridx = ids.length - i - 1;
			if (DEBUG)
				System.out.println("\nlidx, ridx:" + lidx + ", " + ridx);
			lIds = new int[lidx];
			rIds = new int[ridx];
			for (int j = 0; j < lidx; j++)
				lIds[j] = ids[j];
			for (int j = 0; j < ridx; j++)
				rIds[j] = ids[i + j + 1];
		}
		if (DEBUG) {
			System.out.print("ids: ");
			for (int i = 0; i < ids.length; i++)
				System.out.print(ids[i] + " ");
			System.out.println("\nrootId: " + rootId);
			System.out.print("lIds: ");
			for (int i = 0; i < lIds.length; i++)
				System.out.print(lIds[i] + " ");
			System.out.print("\nrIds: ");
			for (int i = 0; i < rIds.length; i++)
				System.out.print(rIds[i] + " ");
			System.out.println();
		}
		nodes[rootId].l = makeTree(lIds);
		nodes[rootId].r = makeTree(rIds);
		return nodes[rootId];
	}

	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 26368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct BinomialCoefficient  {
    BinomialCoefficient() {
        
    }
    
    BinomialCoefficient(int n) : fac(n + 2), finv(n + 2), inv(n + 2) {
        initialize(n, false);
    }
    
    void initialize(int n, bool resize = true) {
        if (resize) {
            fac.resize(n + 2);
            finv.resize(n + 2);
            inv.resize(n + 2);
        }
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= n; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    
    ll factorial(int n) {
        return fac[n];
    }
    
    ll combination(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
    
    ll permutation(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * finv[n - r] % mod;
    }
    
private:
    int mod = 1e9 + 7;
    vector<ll> fac, finv, inv;
};

BinomialCoefficient bc;

ll f(ll r, ll c) {
    ll res = 0;
    rep(i, c) {
        res += bc.combination(r + i + 2, i + 2);
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    bc = BinomialCoefficient(r2 + c2 + 2);
    ll ans = f(r2, c2);
    ans = (ans + mod - f(r1 - 1, c2)) % mod;
    ans = (ans + mod - f(r2, c1 - 1)) % mod;
    ans = (ans + f(r1 - 1, c1 - 1)) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 47104
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll K = 0, X =0;
    cin >> K >> X;

    //本文
    REP(i,2*K-1){
      cout << X-K+1+i<< " ";
    }
    //出力
    //cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3624
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1 < n-b:
        print(min((1+b+(a-2))//2,b-1))
    else:
        print(min((n-a+(n-b+1))//2,n-a))

Measured memory_bytes: 3060
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int cnt;
void insertionSort(VI& A, int n, int g){
  for(int i=g;i<n;++i){
	int v = A[i];
	int j = i - g;
	while(j >= 0 && A[j] > v){
	  A[j+g] = A[j];
	  j -= g;
	  ++cnt;
	}
	A[j+g] = v;
  }
}

void shellSort(VI& A, int n){
  cnt = 0;
  int m = 0;
  while((1<<m) <= n) ++m;

  VI G(m);
  REP(i,m)
 	G[i] = 1<<(m-1-i);

  cout << m << endl;
  cout << G[0];
  REP(i,m-1) cout << " " << G[i+1];
  cout << endl;
  
  for(int i=0;i<m;++i)
	insertionSort(A, n, G[i]);
}

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

  int n; cin >> n;
  VI A(n);
  REP(i,n) cin >> A[i];
  shellSort(A, n);

  cout << cnt << endl;
  REP(i,n) cout << A[i] << endl;
  
  return 0;
}

Measured memory_bytes: 4888
#include <iostream>
#include <algorithm>

using namespace std;


int main(){
  int loop_num;
  long sum;
  long Penalty[12800];
  while(cin >> loop_num){
    for(int i=0;i<loop_num;i++){
      cin >> Penalty[i];
    }
    sort(Penalty,Penalty+loop_num);
    
    sum = 0;
    for(int i=0;i<loop_num;i++){
      sum += Penalty[i]*(loop_num-i);
    }

    cout << sum << endl;
  }
  
}

Measured memory_bytes: 0
s = input()
K = int(input())
l = []
if len(s) == 1:
    print(s)
    exit()
for i in range(len(s)):
    for j in range(i, len(s)):
        d = s[i:j+1]
        l.append(d)
        if len(d) >= K:
            break
l = list(set(l))
l.sort()
print(l[K-1])

Measured memory_bytes: 5068
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = long.Parse(Console.ReadLine());
        //long[] n = Console.ReadLine().Split().Select(long.Parse).ToArray();

        var ans = n;
        for (long i = 0; i <= n; i++)
        {
            long count = 0;
            long tmp = i;
            while (tmp > 0)
            {
                count += tmp % 6;
                tmp /= 6;
            }

            tmp = n - i;
            while (tmp > 0)
            {
                count += tmp % 9;
                tmp /= 9;
            }

            ans = Math.Min(ans, count);
        }
        // 出力
        Console.WriteLine(ans);
    }
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 1;
    for (int i = 0; i < n - 1; ++i) {
        if (s[i] != s[i + 1]) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl read >>= print

solve :: Integer -> Integer
solve n = 2 * q + f r
  where
    (q,r) = n `divMod` 11
    f x | x == 0 = 0
        | x <= 6 = 1
        | otherwise = 2

getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 508
n = int(input())

price = []

for i in range(n):
    price.append(int(input()))

max = price[1] - price[0]
min = price[0]

for i in range(1, n):
    if max < price[i] - min:
        max = price[i] - min

    if min > price[i]:
        min = price[i]


print(max)



Measured memory_bytes: 13588
#include <iostream>

using namespace std;

int main(){
	int n;
	cin>>n;
	int *r;
	r=new int [n];
	if (r==NULL) {
		cout<<"Error!"<<endl;
		return -1;
	}
	int i,j;
	for (i=0;i<n;i++){
		cin>>r[i];
	}
	int max=r[1]-r[0];
	for (j=n-1;j>=0;j--){
		if (r[j]<=max) continue;
		for (i=j-1;i>=0;i--){
			if (r[j]-r[i]>max) max=r[j]-r[i];
		}
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 1964
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define db long double
#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define lb lower_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<a.size();++i)
#define gc() getchar()
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
inline int rd()
{
	int x=0;char c=gc();while(!isdigit(c))c=gc();
	while(isdigit(c))x=x*10+c-48,c=gc();return x;
}
const int N=2000005,P=1e9+7;
int ans,x[10],y[10],fac[N],ifac[N];
inline int pw(int a,int b){int r=1;for(;b;b>>=1,a=1ll*a*a%P)if(b&1)r=1ll*r*a%P;return r;}
inline int C(int a,int b){return a<0||b<0||a<b?0:1ll*fac[a]%P*ifac[b]%P*ifac[a-b]%P;} 
inline int sol(int xx,int yy,int kd)
{
	int xx1,xx2,yy1,yy2;
	if(!kd){xx1=xx-x[1],xx2=xx-x[0],yy1=yy-y[1],yy2=yy-y[0];}else{xx1=x[4]-xx,xx2=x[5]-xx,yy1=y[4]-yy,yy2=y[5]-yy;}
	int res=(((C(xx1+yy1,xx1)-C(xx1+yy2+1,xx1)+P)%P-C(xx2+yy1+1,yy1)+P)%P+C(xx2+yy2+2,xx2+1))%P;
	return res; 
}
int main()
{
	fac[0]=1;rep0(i,1,N)fac[i]=1ll*fac[i-1]*i%P;
	ifac[N-1]=pw(fac[N-1],P-2);
	per(i,N-1,1)ifac[i-1]=1ll*ifac[i]*i%P;
	rep(i,0,5)x[i]=rd();rep(i,0,5)y[i]=rd();
	rep(i,x[2],x[3])
	{
		(ans+=1ll*sol(i,y[2],1)*sol(i,y[2]-1,0)%P*(P-i-y[2])%P)%=P;
		(ans+=1ll*sol(i,y[3]+1,1)*sol(i,y[3],0)%P*(i+y[3]+1)%P)%=P;
	}
	rep(i,y[2],y[3])
	{
		(ans+=1ll*sol(x[2],i,1)*sol(x[2]-1,i,0)%P*(P-i-x[2])%P)%=P;
		(ans+=1ll*sol(x[3]+1,i,1)*sol(x[3],i,0)%P*(i+x[3]+1)%P)%=P;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 15872
n,m,k=map(int,input().split())
l=list(map(int,input().split()))
c1=0
c2=0
for i in range(k+1,n):
  if i in l:
    c1+=1
for i in range(1,k):
  if i in l:
    c2+=1
print(min(c1,c2))

      

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

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

  int count = 0;
  for (int i = 0; i < N-2; i++) {
    if (S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C') {
      count++; 
    }
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    int d = 0;
    int c[26];
    int s[365][26];
    int t[365];
    int last[26] = {0};
    int score = 0;

    cin >> d;

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

    for(int i = 0; i < d; i++)
    {
        for(int j = 0; j < 26; j++)
        {
            cin >> s[i][j];
        }
    }

    for(int i = 0; i < d; i++)
    {
        cout << (rand() % 26 + 1) << endl;
    }

}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define sz 100010
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

int const mod = 1e9;

int main()
{
    BeatMeScanf;
    ll a;
    cin>>a;
    ll ans =  a + (a*a) + (a*a*a);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3644
N = int(input())
a = [int(x) for x in input().split()]

a_cum = []
cumsum = 0

# cumsum array
for i in a :
    cumsum += i
    a_cum.append(cumsum)

min_abs = 2*(10**9)

for i in range(0, len(a_cum) - 1) :
    x = a_cum[i]
    y = a_cum[len(a_cum) - 1] - x
    
    min_abs = min(abs(x - y), min_abs)
    
print(min_abs)

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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define space ' '
#ifdef ONLINE_JUDGE
#define enter '\n'
#else
#define enter std::endl
#endif
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << enter
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << enter
using std::make_pair;

template < typename T >
inline T read( )
{
 T x = 0;
 char ch = gc( );
 bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int N = 1001, mod = 1e9 + 7;
 int n, a [ N ];
 void Fakemain( )
 {
  IOS;
  cin >> n;
  For( i, 1, n )
   cin >> a[ i ];
  int ans = 0;
  std::sort( a + 1, a + 1 + n, std::less < int > ( ) );
  For( i, 1, n ) For( j, i + 1, n ) For( k, j + 1, n )
  {
   if( a[ i ] + a[ j ] > a[ k ] && a[ i ] != a[ j ] && a[ j ] != a[ k ] )
    ans++;
  }
  cout << ans;
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;


//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 2000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
//-------------------------------------------------------------------
ll gcd(ll a, ll b){
  if(b<a) swap(a, b);
  ll r = a % b;
  if(r==0) return b;
  while(r!=0){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  return (a/g)*b;
}
struct Merge{
  set<vll> lr;
  ll INF = 1000000000000000009;
  vll remove(ll a, ll b){
    if(a>b) swap(a, b);
    auto itr = lr.lower_bound(vll{b+1, 0});
    if(itr==lr.begin()) return vll{a, b};
    itr--;
    ll lef = a, ri = b;
    while((*itr)[1]>=a){
      ll now_x = (*itr)[0], now_y = (*itr)[1];
      lef = min(lef, now_x), ri = max(ri, now_y);
      if(itr==lr.begin()){
        lr.erase(itr);
        break;
      }
      itr--;
      lr.erase(vll{now_x, now_y});
    }
    return vll{lef, ri};
  }
  void merge(ll a, ll b){lr.insert(remove(a, b));}
  vll get(ll a){
    auto itr = lr.lower_bound(vll{a+1, 0});
    if(itr==lr.begin()) return vll{INF, INF};
    itr--;
    if((*itr)[1]<a) return vll{INF, INF};
    return *itr;
  }
  bool same(ll a, ll b){
    if(get(a)[0]==-1) return false;
    return get(a)[0]==get(b)[0];
  }
};
int main(int argc, char const *argv[]) {
  ll ans=0, tmp, n, t;std::cin >> n >> t;
  Merge m;
  m.merge(0, t);
  re(i, n){
    std::cin >> tmp;
    m.merge(tmp, tmp+t);
  }
  for(auto itr=m.lr.begin();itr!=m.lr.end();itr++){
    //std::cout << (*itr)[0] << " " << (*itr)[1] << '\n';
    ans += (*itr)[1] - (*itr)[0];
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 632
n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i] = map(int,input().split())
a.sort(reverse=True)
b.sort()
if n%2:
  a_med = a[n//2]
  b_med = b[n//2]
  print(b_med - a_med + 1)
else:
  a_med = (a[n//2-1] + a[n//2])/2
  b_med = (b[n//2-1] + b[n//2])/2
  print(int((b_med - a_med)*2)+1)

Measured memory_bytes: 25592
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); ++i) {
		cout << "x";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner ob=new Scanner(System.in);
    long h=ob.nextLong();
    long k=1;
    long c=0;
    while(h>0)
    {
      c=c+k;
      h=h/2;
      k=k*2;
    }
    System.out.println(c);
  }
}

Measured memory_bytes: 21844
#include <iostream>

int main(void){
    int N;
    double ans;
    int count = 0;
    std::cin >> N;

    for (int i = 0; i <= N; i++){
        if (i % 2 == 1){
            count++;
        }
    }

    ans = double(count) / double(N);
    std::cout << ans << std::endl;
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    string S; cin >> S;
    ll N = S.length() + 1;
    ll l[N] = {0};
    ll g[N] = {0};
    for (ll i = 0; i < N - 1; i++) {
        if (S[i] == '<') {
            l[i + 1] = l[i] + 1;
        }
    }
    for (ll i = N - 2; i >= 0; i--) {
        if (S[i] == '>') {
            g[i] = g[i + 1] + 1;
        }
    }
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ans += max(l[i], g[i]);        
    } 
    cout << ans << "\n";
}

Measured memory_bytes: 11660
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float("inf")
mod = 10 ** 9 + 7

X, Y = MAP()
if abs(X-Y) <= 1:
	print("Brown")
else:
	print("Alice")


Measured memory_bytes: 5148
#include <vector>
#include <set>
#include <map>
#include <string>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <string.h>
#include <stdio.h>

typedef long long ll;
using namespace std;

typedef vector<vector<pair<int, int> > > graph_t;
typedef vector<tuple<int, int, int>> edges_t;
const int INF = 1e9+1;

vector<int> dijkstra(int N, const graph_t &g, int s)
{
	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > q;
	vector<int> cost(N, INF);
	q.push(make_pair(0, s));
	cost[s] = 0;
	while (!q.empty()) {
		pair<int, int> p = q.top();
		q.pop();
		int c = p.first;
		int v = p.second;
		if (cost[v] < c)
			continue;
		for (vector<pair<int, int> >::const_iterator i = g[v].begin(); i != g[v].end(); ++i) {
			if (cost[i->first] > cost[v] + i->second) {
				cost[i->first] = cost[v] + i->second;
				q.push(make_pair(cost[i->first], i->first));
			}
		}
	}
	return cost;
}

int solve(int c, int n, int s, int d, const edges_t &edges)
{
	graph_t g;
	g.resize(n);
	for (auto i = edges.begin(); i != edges.end(); i++) {
		int a, b, f;
		tie(a, b, f) = *i;
		g[a].emplace_back(b, f);
		g[b].emplace_back(a, f);
	}

	vector<vector<int>> cost; // cost[?????????????????°][????????????]
	cost.resize(c+1);
	for (auto i = cost.begin(); i != cost.end(); ++i) {
		i->resize(n, INF);
	}
	cost[c] = dijkstra(n, g, s);
	for (int w = c-1; w >= 0; w--) {
		cost[w][s] = 0;
		priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
		q.emplace(0, s);
		while (!q.empty()) {
			int e, v;
			tie(e, v) = q.top();
			q.pop();
			if (e > cost[w][v])
				continue;
			for (auto j = g[v].begin(); j != g[v].end(); ++j) {
				bool updated = false;
				if (cost[w][j->first] > e + j->second) {
					cost[w][j->first] = e + j->second;
					updated = true;
				}
				if (cost[w][j->first] > cost[w+1][v] + j->second/2) {
					cost[w][j->first] = cost[w+1][v] + j->second/2;
					updated = true;
				}
				if (updated) {
					q.emplace(cost[w][j->first], j->first);
				}
			}
		}
	}
	return cost[0][d];
}

void solve_stdio()
{
	while (true) {
		int c, n, m, s, d;
		if (!(cin >> c >> n >> m >> s >> d))
			break;
		if (c == 0)
			break;
		s--; d--;
		edges_t edges;
		for (int i = 0; i < m; i++) {
			int a, b, f;
			cin >> a >> b >> f;
			a--; b--;
			edges.emplace_back(a, b, f);
		}
		int ans = solve(c, n, s, d, edges);
		cout << ans << endl;
	}
}

int main()
{
	solve_stdio();
}


Measured memory_bytes: 1228
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();

        if (a[0] != 0) {
            System.out.println(-1);
            return;
        }

        long cnt = 0;
        for (int i = 1; i < n; i++) {
            if (a[i - 1] < a[i]) {
                if (a[i] - a[i - 1] != 1) {
                    System.out.println(-1);
                    return;
                }
                cnt++;
            } else {
                cnt += a[i];
            }
        }

        System.out.println(cnt);
    }

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


Measured memory_bytes: 77080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    set<char> sSet;
    string ans="yes";
    for(auto c:s){
        if(sSet.count(c)){
            ans="no";break;
        }
        sSet.insert(c);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m, ans;
int h[100010];
bool flag[100010];
vector<int> vec[100010];
int main(){
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> h[i + 1];
    }
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    for(int i = 1; i <= n; i++){
        if(flag[i])
            continue;
        for(int j = 0; j < vec[i].size(); j++){
            if(h[i] > h[vec[i][j]]){
                flag[vec[i][j]] = true;
            }
            else{
                flag[i] = true;
                break;
            }
        }

    }
    for(int i = 1; i <= n; i++){
        if(!flag[i])
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9260
#include<iostream>

int gcd(int a,int b){
    int c=1;
    if(a<b){
        c=a;a=b;b=c;
    }
    while(c!=0){
            c=a%b;
            a=b;
            b=c;
        }
   return a;
}

int main()
{
    int k,ans=0;
    std::cin >> k;
    for(int i = 1; i <= k; i++)
        for(int j=1; j <= k; j++)
            for(int n=1; n <= k; n++){
                ans+=gcd(gcd(i,j),n);
            }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3632
n,m=map(int,input().split())
al=[input() for _ in range(n)]
bl=[input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if bl[k]!=al[i+k][j:j+m]:
                break
        else:
            print('Yes')
            exit()
else:
    print('No')

Measured memory_bytes: 3064
n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
  connection[l[i][1]-1].append(l[i][0]-1)

distance1=[-1 for i in range(n)]
distance1[0]=0
next=connection[0]
next2=[]
check=[-1 for i in range(n)]
check[0]=1
checkct=1
ct=0
while len(next)!=0 and checkct!=n:
  ct+=1
  for i in range(len(next)):
    distance1[next[i]]=ct
    check[next[i]]=1
    checkct+=1
    for j in range(len(connection[next[i]])):
      if check[connection[next[i]][j]]==-1:
        next2.append(connection[next[i]][j])
  next=next2
  next2=[]

distanceN=[-1 for i in range(n)]
distanceN[n-1]=0
next=connection[n-1]
next2=[]
check=[-1 for i in range(n)]
check[n-1]=1
checkct=1
ct=0
while len(next)!=0 and checkct!=n:
  ct+=1
  for i in range(len(next)):
    distanceN[next[i]]=ct
    check[next[i]]=1
    checkct+=1
    for j in range(len(connection[next[i]])):
      if check[connection[next[i]][j]]==-1:
        next2.append(connection[next[i]][j])
  next=next2
  next2=[]

ctF=0;ctS=0
for i in range(n):
  if distance1[i]<=distanceN[i]:
    ctF+=1
  else:
    ctS+=1
if ctF>ctS:
  print('Fennec')
else:
  print('Snuke')

Measured memory_bytes: 83288
# coding: utf-8
# Your code here!

# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())
from math import gcd 
def resolve():  
    N=int(input())
    N=N
    r=range(1,N+1)
    ans=0
    for a in r:
        for b in r:
            t= gcd(a,b)
            for c in r:
                ans+= gcd(t,c)
    print(ans)
"""         
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じ,るの忘れてるだろ
"""
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """200"""
        output = """10813692"""
        self.assertIO(input, output)


if __name__ == "__main__":
    #unittest.main()

    resolve()




Measured memory_bytes: 72284
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

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

int main(){
    int n,k;
    cin>>n>>k;
    bool ok=false;
    ll g;
    rep(i,0,n){
        int x;
        cin>>x;
        if(x>=k)ok=true;

        if(i==0)g=x;
        else g=gcd(x,g);
    }
    if(ok && k%g==0)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;



    

    return 0;
}




Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
void baseminus2number() {
	int n;
	cin >> n;

	if (n == 0) {
		cout << 0 << endl;
	}
	stack<int> s;
	while (n != 0)
	{
		s.push(abs(n) % 2);
		n -= s.top();
		n /= -2;
	}

	while (!s.empty())
	{
		if (s.top() == 0)
			cout << 0;
		else
			cout << 1;
		s.pop();
	}
	cout << endl;
}
int main() {
	baseminus2number();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, M, K;
  cin >> N >> M >> K;
  vector<long> A(N + 1), B(M + 1);
  long a;
  for(int i = 0; i < N; i++){
    cin >> a;
    A.at(i + 1) = A.at(i) + a;
  }
  for(int i = 0; i < M; i++){
    cin >> a;
    B.at(i + 1) = B.at(i) + a;
  }
  long pl = 0, ans = 0;
  for(int i = M; i >= 0; i--){
    while(pl <= N){
      if(A.at(pl) + B.at(i) <= K){
        ans = max(pl + i, ans);
      } else break;
      pl++;
    }
    if(pl > N)pl--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6424