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

using namespace std;

typedef long long ll;

void solve(ll a, ll b, ll v[], int m) {
    for (int i = 0; i < m; i++) {
        if ( a + b >= 0 && a - b >= 0 ) {
            cout << "R";
            a -= v[i];
        } else if ( a + b >= 0 && a - b < 0 ) {
            cout << "U";
            b -= v[i];
        } else if ( a + b < 0 && a - b >= 0 ) {
            cout << "D";
            b += v[i];
        } else {
            cout << "L";
            a += v[i];
        }
    }
    cout << endl;
    return;
}

int main() {
    int N, m = 34;
    ll X[1003], Y[1003];
    ll d[34];
    ll  t = 1;
    for (int i = 0; i < 33; i++) {
        d[32-i] = t;
        t *= 2;
    }
    d[33] = 1;

    cin >> N;

    int even = 0, odd = 0;

    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
        if ( ( abs(X[i]) + abs(Y[i])) % 2 == 0) {
            even++;
        } else {
            odd++;
        }
    }
    if (even && odd) {
        cout << -1 << endl;
        return 0;
    }

    if (odd) { m -= 1; }
    cout << m << endl;

    for (int i = 0; i < m; i++) {
        cout << d[i];
        if (i == m-1) { cout << endl; }
        else { cout << " "; }
    }
    for (int i = 0; i < N; i++) {
        solve(X[i], Y[i], d, m);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
const double EPS = 1e-10;
int main(void){
    double a;
    cin>>a;
    double x=0,y=0,z=0;
    int ans=0;
    for(int i=1;i<1000000;i++){
        x+=cos(z),y+=sin(z);
        z+=a*M_PI/180;
        if((x-EPS<=0&&x+EPS>=0)&&(y-EPS<=0&&y+EPS>=0)){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}

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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pd pair<double, int>
#define pii pair<int, pi>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 200001
#define mod 1000000007

int main()
{
  lli n, m;
  cin >> n >> m;
  lli ans = 0;
  for (int i = m; i <= n + 1; i++)
    ans = (ans + (i * (n + 1 - i) + 1)) % mod;
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  iostreamBooster();
  char s[105];
  int h, w; cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    cin >> s;
    cout << s << '\n' << s << '\n';
  }


  return 0;
}



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

int main(){
  vector<int> b;
  for(int i=0; i<9; i++){
	int val;
    cin >> val;
    b.push_back(val);
  }
    
  int N; cin >> N;
  for(int i = 0; i<N; i++) {
    int val;  
    cin >> val;
    
    for(int j = 0; j<9; j++){
        if(b[j] == val) b[j]=0;
    }
  }
  
  int ans[8][3] = {{0,1,2}, {3,4,5}, {6,7,8}, {0,3,6}, {1,4,7}, {2,5,8}, {0,4,8}, {2,4,6}};
  for(int i = 0; i<8; i++){
      if(b[ans[i][0]]+b[ans[i][1]]+b[ans[i][2]] == 0) {
          cout << "Yes";
          return 0;
      }
  }
  
  cout << "No";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.mutable

object Main {
  def solve(sc: => Scanner): Unit = {
    val N, M = sc.nextInt
    if (N != 0 || M != 0) {
      val list = Array.fill[List[(Int, Int)]](N)(List[(Int, Int)]())
      for (i <- 0 until M) {
        val a, b, cost = sc.nextInt
        list(a) :+= (b, cost)
        list(b) :+= (a, cost)
      }
      val que = mutable.PriorityQueue.empty[(Int, Int)](implicitly[Ordering[(Int, Int)]].reverse)
      que.enqueue((0, 0))
      val flag = Array.fill[Boolean](N)(false)
      var ans = 0
      while (que.length != 0) {
        val now = que.dequeue()
        if (!flag(now._2)) {
          flag(now._2) = true
          ans += now._1
          for (next <- list(now._2)) {
            if (!flag(next._1)) {
              que.enqueue((next._2, next._1))
            }
          }
        }
      }
      println(ans)
      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 48120
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 200003
int cnt[64];
int main()
{
    int i,n,j;
    ll x,y;
    in(n);
    rep(i,n)
    {
        llin(x);
        j=0;
        while(x>0)
        {
            cnt[j]+=(x&1);
            x/=2,j++;
        }
    }
    ll ans=0;
    ll p=1;
    rep(i,60)
    {
        x=cnt[i],y=n-x;
        x*=y,x%=M;
        x*=p,x%=M;
        p*=2,p%=M;
        ans+=x;
    }
    llout(ans%M);
}









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;

int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	sort(v.begin(), v.end());
	double ans = v[0];
	for(int i=1; i<n;i++){
		ans = (ans+v[i])/2.0;
	}
	printf("%10f\n", ans);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll sol(ll n) {
    if (n == 1) return 1;
    return sol(n / 2) * 2 + 1;
}

int main() {
    ios::sync_with_stdio(false);
    int h, a;
    cin >> h >> a;
    cout << (h - 1) / a + 1;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <queue>
using namespace std;

#define LET(name, value) __typeof(value) name = value
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define FOREQ(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for (LET(i, (c).begin()); i != (c).end(); ++i)

struct Edge {
  int dst, dist;
  Edge(int dst, int dist): dst(dst), dist(dist) {}
};

struct State {
  int city, rest, cost;
  State(int city, int rest, int cost): city(city), rest(rest), cost(cost) {}
  bool operator<(const State& rhs) const { return cost > rhs.cost; }
};

inline int add_name(map<string, int>& name2id, const string& name) {
  if (name2id.count(name)) {
    return name2id[name];
  } else {
    int id = name2id.size();
    return name2id[name] = id;
  }
}

vector<Edge> edges[6010];
bool has_lpg[6010];
bool visit[6010][2010];
int cost[6010][2010];

int main() {
  int N, M, cap;
  while (scanf("%d%d%d", &N, &M, &cap), N|M|cap) {
    map<string, int> name2id;
    string src_name, dst_name;

    memset(has_lpg, false, sizeof(has_lpg));
    memset(visit, false, sizeof(visit));
    memset(cost, 0x0f, sizeof(cost));

    cin >> src_name >> dst_name;
    int src = add_name(name2id, src_name);
    int dst = add_name(name2id, dst_name);
    REP(i, N) {
      int dist;
      cin >> src_name >> dst_name >> dist;
      int s = add_name(name2id, src_name);
      int t = add_name(name2id, dst_name);
      edges[s].push_back(Edge(t, dist));
      edges[t].push_back(Edge(s, dist));
    }
    REP(i, M) {
      cin >> src_name;
      has_lpg[name2id[src_name]] = true;
    }

    priority_queue<State> Q;
    Q.push(State(src, 10 * cap, 0));
    cost[src][10 * cap] = 0;
    int ans = -1;

    while (!Q.empty()) {
      int city = Q.top().city;
      int rest = Q.top().rest;
      Q.pop();

      if (visit[city][rest]) { continue; }
      visit[city][rest] = true;
      if (city == dst) {
        ans = cost[city][rest];
        break;
      }

      FOREACH(it, edges[city]) {
        int new_city = it->dst;
        if (rest < it->dist) { continue; }
        int new_rest = has_lpg[new_city] ? 10 * cap : rest - it->dist;
        int new_cost = cost[city][rest] + it->dist;
        if (new_cost >= cost[new_city][new_rest]) { continue; }
        cost[new_city][new_rest] = new_cost;
        Q.push(State(new_city, new_rest, new_cost));
      }
    }

    cout << ans << endl;

    REP(i, name2id.size()) { edges[i].clear(); }
  }
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean key = true;
		int count = 0;
		int[] list = new int[N];
		for (int i = 0; i < N; i++) {
			int add = sc.nextInt();
			list[i] = add;
		}
		out : while (key) {
			for (int i = 0; i < list.length; i++) {
				if (list[i]%2 == 0) {
					list[i] /= 2;
				} else {
					key = false;
					break out;
				}
			}
			count++;
		}
		System.out.println(count);
	}	
}

Measured memory_bytes: 21844
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	string s;
	cin >> s;
	int cnt = 0;
	rep(i, s.length()) {
		if (s[i] == '1') cnt++;
	}
	cout << cnt << endl;

	return 0;
}





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

using namespace std;

const int MAX_BITS = 63;
int no_of_numbers;
vector <int> no_of_1s(MAX_BITS, 0);

int is_bit_set(long long n, int position)
{
    return ( (n & (1LL << position)) != 0);
}

long long get_mask_with_prefix_till(long long n, int replaced_one)
{
    long long mask = 0;

    for(int bit = MAX_BITS; bit >= 0; bit--)
    {
        if(bit > replaced_one)
        {
            if(is_bit_set(n, bit))
            {
                mask |= (1LL << bit); //cout << "Setting 1 at position " << bit << " Mask = " << mask << endl;
            }
        }
        else if(bit == replaced_one)
        {
            continue;
        }
        else
        {
            if(2*no_of_1s[bit] < no_of_numbers)
            {
                mask |= (1LL << bit);// cout << "Setting 1 at position " << bit << " Mask = " << mask << endl;
            }
        }
    }

    return mask;
}

long long get_value(vector <long long> &A, long long mask)
{
    long long sum = 0;

    for(int i = 1; i <= no_of_numbers; i++)
        sum += (A[i]^mask);

    return sum;
}

int main()
{
    long long K;
    cin >> no_of_numbers >> K;

    vector <long long> A(no_of_numbers + 1);
    for(int i = 1; i <= no_of_numbers; i++)
        cin >> A[i];

    for(int i = 1; i <= no_of_numbers; i++)
    {
        for(int bit = 0; bit <= MAX_BITS; bit++)
        {
            if(is_bit_set(A[i], bit))
            {
                no_of_1s[bit]++;
            }
        }
    }

    vector <long long> masks;
    masks.push_back(K);
    masks.push_back(0);

    for(int bit = MAX_BITS; bit >= 0; bit--)
    {
        if(is_bit_set(K, bit))
        {
            long long mask = get_mask_with_prefix_till(K, bit); //cout << "Bit = " << bit << " m = " << mask << endl;

            masks.push_back(mask);
        }
    }

    long long maximum_value = 0;
    for(int m = 0; m < masks.size(); m++)
    {
        maximum_value = max(maximum_value, get_value(A, masks[m]));
    }

    cout << maximum_value;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>

using namespace std;

int main() {
    int L;
    cin >> L;
    double dim = L/3.0;
    cout << fixed;
    cout << setprecision(7);
    cout << dim*dim*dim;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;


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

    int n,k;
    cin >> n >> k;
    ll ans;
    ans = k;
    ll aa = pow(k-1,n-1);
    ans *= aa;
    cout << ans << endl;

    cout << endl;
    return 0;
}


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

int main(){
  int n, l;
  cin >> n >> l;
  vector< string > v(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  sort(v.begin(),v.end());
  for(auto x: v) cout << x;
}


Measured memory_bytes: 3576
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
if sum(b)>sum(a):
    print(-1)
    exit()

j,k=[],[]
for i in range(n):
    if a[i]>b[i]:
        j.append(a[i]-b[i])
    elif a[i]<b[i]:
        k.append(b[i]-a[i])
ans=len(k)

j.sort()
t=sum(k)
while t>1:
    t-=j.pop()
    ans+=1
print(ans)


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

int main(){
  int n;
  while(cin >> n , n){
    int name;
    int ans;
    double near = -1;
    for(int i=0;i<n;i++){
      double w,h;
      cin >> name >> h >> w;
      double tmp = w / ((h/100)*(h/100));
      if(near == -1 || fabs(22.0-tmp) < fabs(22.0-near)){
	near = tmp;
	ans = name;
      }
      else if(fabs(22.0-tmp) == fabs(22.0-near)){
	if(name < ans){
	  name = ans;
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1228
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a0 = int.Parse(line[0]);
            var L = int.Parse(line[1]);
            if (a0 == 0 && L == 0) break;
            var j = 0;
            var d = new Dictionary<int, int>();
            d[a0] = j;
            var pre = a0;
            while (true)
            {
                j++;
                var w = getNew(pre, L);
                if (d.ContainsKey(w)) { Console.WriteLine("{0} {1} {2}", d[w], w, j - d[w]); break; }
                else d[w] = j;
                pre = w;
            }
        }
    }
    public static int getNew (int a , int L)
    {
        var ab = a.ToString();
        var p = L - ab.Length;
        var t = ab + new string('0', p);
        var t1 = t.ToCharArray();
        Array.Sort(t1);
        var n1 = int.Parse(new string(t1));
        Array.Reverse(t1);
        var n2 = int.Parse(new string(t1));
        return n2 - n1;
    }
}



Measured memory_bytes: 9980
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  
  rep(i,n){
    cout << g[i].size() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())

visit = set()
now = 1
for i in range(1, n + 10):
    if now not in visit:
        visit.add(now)
        now = a[now - 1]
    else:
        print(-1)
        break
    if now == 2:
        print(i)
        break


Measured memory_bytes: 18972
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

set<ll> yaku(ll n) {
    set<ll> st;
    for (ll x = 1; x * x <= n; x++) {
        if (n % x == 0) {
            st.insert(x);
            st.insert(n / x);
        }
    }
    st.erase(1);
    return st;
}

signed main() {
    fio();
    ll n;
    cin >> n;

    auto st = yaku(n);

    ll ans = 0;
    for (auto itr = st.begin(); itr != st.end(); itr++) {
        ll k = *itr;
        ll x = n;
        while (x >= k) {
            if (x % k == 0) x /= k;
            else x %= k;
        }
        if (x == 1) ans++;
    }

    auto st2 = yaku(n - 1);
    ans += st2.size();
    cout << ans << endl;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

#ifdef LOCAL
#define i64 "%lld"
#else
#define i64 "%I64d"
#endif

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

const int N = 1e5 + 10;

int n, L, x[N];
int jump[N][20];

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

    cin >> n; forn(i,n) cin >> x[i];
    cin >> L;
    x[n] = x[n-1] + L; n++; 

    int j = 0;
    forn(i,n) {
        while (j < n-1 && x[j+1] - x[i] <= L) j++;
        jump[i][0] = j;
    }
//    forn(i,n) cerr << jump[i][0] << ' ';
//    D(n);

    for (int k = 0; k < 19; k++)
        forn(i,n) jump[i][k+1] = jump[jump[i][k]][k];


    int q; cin >> q;
    while (q--) {
        int x,y; cin >> x >> y;
        --x; --y;
        if (x > y) swap(x,y);

        int ans = 0;
        dforsn(i,0,20) if (jump[x][i] < y) {
            ans += 1<<i;
            x = jump[x][i];
        }
        cout << ans+1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 9088
import sys
for line in sys.stdin:
    if line == "\n":
        break
    w = float(line)
    if w <= 48:
        print("light fly")
    elif w <= 51:
        print("fly")
    elif w <= 54:
        print("bantam")
    elif w <= 57:
        print("feather")
    elif w <= 60:
        print("light")
    elif w <= 64:
        print("light welter")
    elif w <= 69:
        print("welter")
    elif w <= 75:
        print("light middle")
    elif w <= 81:
        print("middle")
    elif w <= 91:
        print("light heavy")
    else:
        print("heavy")
        

Measured memory_bytes: 7424
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
H0=(T-A)/0.006

mind=10**9

for i in range(N):
    if abs(H[i]-H0)<mind:
        ans=i+1
        mind=abs(H[i]-H0)

print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

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

    vector<int> d;

    for(int i=0; i<N; i++){
      int di;
      cin >> di;
      d.push_back(di);
    }

    sort(d.begin(), d.end());

    int ret = d[N/2] - d[(N/2)-1];

    cout << ret << endl;
}


Measured memory_bytes: 892
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 11;

int n;
int s[N];
vector<string> sol;

void solve(int cur, int last) {
  if(cur >= n) {
    string t = "";
    for(int i = 0 ; i < n ; i++) 
      t += char(s[i] + 'a');
    sol.push_back(t);
    return;
  }
  for(int i = 0 ; i <= last + 1 ; i++) {
    s[cur] = i;
    solve(cur + 1, max(last, i));
  }
}

int main()
{
  cin >> n;
  solve(0, -1);
  for(int i = 0 ; i < sz(sol) ; i++)
    cout << sol[i] <<  endl;
  return 0;
}


Measured memory_bytes: 9588
s = input()
a = []

def f(n):
    if n%2 == 0:
        return n/2
    else:
        return 3*n + 1

a.append(int(s))

for i in range(10**10):
    if f(a[i]) in a:
        ans = i+2
        break
    a.append(int(f(a[i])))

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

llint h, w, k;
llint sx, sy;
char c[805][805];
llint dist[805][805];
llint dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};

void bfs()
{
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			dist[x][y] = inf;
		}
	}
	queue<P> Q;
	Q.push(P(sx, sy));
	dist[sx][sy] = 0;
	
	llint x, y;
	while(Q.size()){
		x = Q.front().first, y = Q.front().second;
		Q.pop();
		for(int i = 0; i < 4; i++){
			llint nx = x + dx[i], ny = y + dy[i];
			if(nx < 1 || nx > w || ny < 1 || ny > h) continue;
			if(c[nx][ny] == '#') continue;
			if(dist[nx][ny] < inf/2) continue;
			dist[nx][ny] = dist[x][y] + 1;
			Q.push(P(nx, ny));
		}
	}
}

int main(void)
{
	cin >> h >> w >> k;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			cin >> c[x][y];
			if(c[x][y] == 'S') sx = x, sy = y;
		}
	}
	bfs();
	
	llint ans = inf;
	for(llint y = 1; y <= h; y++){
		for(llint x = 1; x <= w; x++){
			llint d = min(min(x-1, y-1), min(w-x, h-y));
			if(dist[x][y] <= k) ans = min(ans, (d+k-1)/k+1);
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 9328
N = int(input())
A = list(map(int, input().split()))

rng = [[A[N], A[N]]]

for i in range(N - 1, -1, -1):
    merged = (rng[-1][0] + 1) // 2 + A[i]
    nonmerged = rng[-1][1] + A[i]
    rng.append([merged, nonmerged])
if rng[-1][0] > 1:
    print(-1)
    exit()
rng.reverse()
prev_non_leaf = 1
ans = 1
for i in range(1, N + 1):
    l, u = rng[i]
    ans += min(prev_non_leaf * 2, u)
    prev_non_leaf = prev_non_leaf * 2 - A[i]
print(ans)


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


int main() {

    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0 ;i < n; ++i) {
        int l, r;
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string.h>
#define ll long long
using namespace std;

struct robot
{
	int start;
	int left;
	int right;
}bots[100005];

bool compare(robot a,robot b)
{
	return a.right< b.right;
}

int main()
{
	int n,l;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>bots[i].start>>l;
		bots[i].left=bots[i].start-l;
		bots[i].right=bots[i].start+l;
	}
	
	sort(bots+1,bots+n+1,compare);
	
	int countn=1,rightn=bots[1].right,cnt=1;
	for(int j=2;j<=n;j++)
	{
		if(bots[j].left>=bots[cnt].right)
		{
			countn++;
			rightn=bots[j].right;
			cnt=j;
		}
	}
	cout<<countn;

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 3005;

string S[2];
int dp[MAX_N][MAX_N];
struct LOG {
  LOG(int next1 = -1, int next2 = -1, char c = ' ') : next1(next1), next2(next2), c(c) {}
  int next1, next2;
  char c;
};
LOG mlog[MAX_N][MAX_N];

signed main()
{
  cin >> S[0] >> S[1];
  int N[2];
  N[0] = S[0].size(); N[1] = S[1].size();

  REP(n1,N[0]+1) {
    REP(n2,N[1]+1) {
      if(n1 < N[0]) {
        if(dp[n1+1][n2] < dp[n1][n2]) {
          dp[n1+1][n2] = dp[n1][n2];
          mlog[n1+1][n2] = LOG(n1,n2);
        }
      }
      if(n2 < N[1]) {
        if(dp[n1][n2+1] < dp[n1][n2]) {
          dp[n1][n2+1] = dp[n1][n2];
          mlog[n1][n2+1] = LOG(n1,n2);
        }
      }
      if(n1 < N[0] && n2 < N[1]) {
        if(S[0][n1] == S[1][n2] && dp[n1+1][n2+1] < dp[n1][n2]+1) {
          dp[n1+1][n2+1] = dp[n1][n2]+1;
          mlog[n1+1][n2+1] = LOG(n1,n2,S[0][n1]);
        }
      }
    }
  }

  // cerr << "size: " << dp[N[0]][N[1]] << endl;

  string ans;
  int n1 = N[0], n2 = N[1];
  while(0 <= n1 && 0 <= n2) {
    if(mlog[n1][n2].c != ' ') {
      ans += mlog[n1][n2].c;
    }

    int nn1 = mlog[n1][n2].next1;
    int nn2 = mlog[n1][n2].next2;
    n1=nn1;n2=nn2;
    // cerr << n1 << " " << n2 << endl;
  }

  reverse(begin(ans), end(ans));

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int n;
string s;
char l;
set<string> h;

signed main() {
	cin >> n;
	while(n--) {
		cin >> s;
		if(h.count(s)) {
			cout << "No";
			return 0;
		}
		h.insert(s);
		if(l && s[0] != l) {
			cout << "No";
			return 0;
		}
		l = s[s.length()-1];
	}
	cout << "Yes";
	return 0;
}

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

void dfs(int x, vector<int> &l) {
  vis[x] = 1;
  for (auto v : g[x]) {
    if (vis[v]) continue;
    l.push_back(v);
    dfs(v, l);
    break;
  }
}

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n, m, root = 0;
  cin >> n >> m;

  vis.resize(n + 1, 0);
  g.resize(n + 1);

  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;

    g[u].push_back(v);
    g[v].push_back(u);

    root = u;
  }

  vector<int> l, r;
  dfs(root, l);
  dfs(root, r);

  cout << l.size() + r.size() + 1 << '\n';
  for (int i = (int)l.size() - 1; i >= 0; --i) {
    cout << l[i] << " "; 
  }
  cout << root << " ";
  for (int i = 0; i < (int)r.size(); ++i) {
    cout << r[i] << " ";
  }
  cout << '\n';
}


Measured memory_bytes: 9720
#include<bits/stdc++.h>
#define ll long long
#define all(s0) s0.begin(),s0.end()
#define ins(s0) inserter(s0,s0.begin())
using namespace std;
ll read()
{
    char ch=getchar();
    ll x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
vector<int> t[200005];

int main()
{
    int n,x;
    cin>>n;
    for(int i=2;i<=n;i++)
    {
        cin>>x;
        t[x].push_back(i);
    }
    for(int i=1;i<=n;i++)
        cout<<t[i].size()<<endl;
    return 0;
}


Measured memory_bytes: 14496
from collections import deque, defaultdict
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
edge = [[] for _ in range(N + 1)]
Redge = [[] for _ in range(N + 1)]
for _ in range(M):
    s, t = map(int, input().split())
    edge[s].append(t)
    Redge[t].append(s)

dp = [0.0] * (N + 1)
for s in reversed(range(1, N)):
    dp[s] = sum(dp[t] + 1.0 for t in edge[s]) / len(edge[s])
ans = dp[1]


cut = set()
for s in range(1, N):
    if len(edge[s]) > 1:
        i = edge[s][0]
        for j in edge[s]:
            if dp[i] < dp[j]:
                i = j
        cut.add((s, i))

for ng in cut:
    dp = [0.0] * (N + 1)
    for s in reversed(range(1, N)):
        E = 0.
        prob = 0.
        for t in edge[s]:
            if (s, t) == ng:
                continue
            prob += 1.0
            E += dp[t] + 1.0
        dp[s] = E / prob
    ans = min(ans, dp[1])

print(ans)

Measured memory_bytes: 60636
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    int ans=2147483647;
    for(long unsigned int i=0;i<=a.size()-b.size();i++)
    {
        int num=0;
        for(long unsigned int j=0;j<b.size();j++)
            if(a[i+j]!=b[j])
                num++;
        ans=min(ans,num);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  int num = 0;
  int count = 0;
  for(int j = 0; j < n-1; j++) {
    num = a[num]-1;
    count++;
    if(num == 1) {
      cout << count << endl;
      break;
    }
    else if(j == n-2) cout << -1 << endl;
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
	    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    ld l;
    cin>>l;
    ld x,y,val,val1;
    val=pow(l/3,3);
    cout<<fixed<<setprecision(7)<<val<<endl;
}  

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)

int main() {
    // your code goes here
    ll n,m,a[10005];
    cin >> n >> m;
    rep(i,1,m){
        cin >> a[i];
        n-=a[i];
    }
    if(n>=0) cout << n << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	
	int ans = 1, c = 0;
	for(int i = 2; i <= n; i++)
	{
		int x = i;
		int d = 0;
		
		while((x & 1) == 0)
		{
			x >>= 1;
			d++;
		}
		
		if(d > c)
		{
			ans = i;
			c = d;
		}
	}
	
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200010;
int n;
ll ans;
int a[N];
queue<int> q;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + 1 + n);
	q.push(a[n]);
	for (int i = n - 1; i; i--) {
		q.push(a[i]);
		q.push(a[i]);
	}
	for (int i = 1; i < n; i++) {
		ans += q.front();
		q.pop();
	}
	cout << ans;
	return 0;
}

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

int main()
{
	int s;
	cin >> s;
	long long  fib[s];
	const int mod =1e9+7;
	fib[0]=0;
	fib[1]=0;
	fib[2]=1;
	for (int i = 3; i < s; i++)
	{
	 	fib[i]=(fib[i-1]+fib[i-3])%mod;
	}
	cout << fib[s-1];
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

template<typename T,T MOD,T B>
struct RollingHash{
  using ll = long long;
  vector<T> hash,po;
  RollingHash(){}
  RollingHash(vector<T> vs){init(vs);}
  RollingHash(string &s){
    vector<T> vs;
    for(char c:s) vs.emplace_back(c);
    init(vs);
  }
  void init(vector<T> vs){
    int n=vs.size();
    hash.assign(n+1,0);
    po.assign(n+1,1);
    for(int i=0;i<n;i++){
      hash[i+1]=((ll)hash[i]*B+vs[i])%MOD;
      po[i+1]=(ll)po[i]*B%MOD;
    }
  }
  //S[l, r)
  T find(int l,int r){
    T res=(ll)hash[r]+MOD-(ll)hash[l]*po[r-l]%MOD;
    return res>=MOD?res-MOD:res;
  }
};

int main(void) {
  int64 A, B;
  cin >> A >> B;
  cout << A/__gcd(A, B)*B << endl;
}



Measured memory_bytes: 256
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll f(ll h)
{
    if (h == 1) return 1;
    return 2*f(h/2) + 1;
}

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int a, b, c;
    cin >> a >> b >> c;

    if (a==7 && b ==5 && c==5) {cout<<"YES"; return 0;}
    if (a==5 && b ==7 && c==5) {cout<<"YES"; return 0;}
    if (a==5 && b ==5 && c==7) {cout<<"YES"; return 0;}

    cout << "NO";
    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

void fail(){
  cout << -1 << endl;
  exit(0);
}

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  if(a[0] != 0) fail();

  int ans = 0;
  for(int i = 1; i < n; i++){
    if(a[i-1] + 1 < a[i]) fail();
    if(a[i-1] + 1 == a[i]){
      ans++;
    }else{
      ans += a[i];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/19/20 20:59:58
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int a,b; cin>>a>>b;
    if (a == b) {
      cnt++;
    } else {
      cnt = 0;
    }
    ans = max(ans, cnt);
  }
  cout << (ans>=3 ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3636
n, a, b = map( int, input().split() )
if a > b:
  exit( print( 0 ) )
if n == 1:
  exit( print( 1 if a == b else 0 ) )
else:
  x = ( n - 1 ) * a + b
  y = ( n - 1 ) * b + a
  print( y - x + 1 )


Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
int main()
{
    //ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;


          if(s=="MON")cout<<7-1<<endl;
          else if(s=="TUE")cout<<7-2<<endl;
          else if(s=="WED")cout<<7-3<<endl;
          else if(s=="THU")cout<<7-4<<endl;
         else if(s=="FRI")cout<<7-5<<endl;
         else if(s=="SAT")cout<<7-6<<endl;
         else if(s=="SUN")cout<<7<<endl;










    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

void solve(int k, int n, vector<int>& v)
{
    v.resize(n);
    if(k % 2 == 0){
        v[0] = k / 2;
        for(int i=1; i<n; ++i)
            v[i] = k;
        return;
    }

    for(int i=0; i<n; ++i)
        v[i] = (k + 1) / 2;
    for(int i=0; i<n/2; ++i){
        if(v.back() == 1){
            v.pop_back();
        }
        else{
            -- v.back();
            while(v.size() < n)
                v.push_back(k);
        }
    }
}

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

    vector<int> ans;
    solve(k, n, ans);

    cout << ans[0];
    for(unsigned i=1; i<ans.size(); ++i)
        cout << ' ' << ans[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 3456
char s[10001];
f(char*k){
	char*p=s;
	int c=0;
	for(;p=strstr(p,k);){
		c++;
		p++;
	}
	printf("%d\n",c);
}
main(){
	for(;~scanf("%s",s);){
		f("JOI");
		f("IOI");
	}
}

Measured memory_bytes: 0
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 2019;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin>>N;
  vector<ll>A(N);
  vector<ll>M(N);
  rep(i,N){
    cin>>A[i];
  }
  M[0]=0;
  for(int i=0;i<N-2;i+=2){
    M[i+2]=M[i]+(A[i+1]-A[i])*2;
  }
  M[1]=M[N-1]+(A[0]-A[N-1])*2;
  for(int i=1;i<N-2;i+=2){
    M[i+2]=M[i]+(A[i+1]-A[i])*2;
  }
  ll Msum=0,Asum=0;
  for(int i=0;i<N;i++){
    Msum+=M[i];
    Asum+=A[i];
  }
  ll ans =(Asum-Msum)/N;
  for(int i=0;i<N;i++){
    cout<<M[i]+ans<<" ";
  }
  cout<<endl;
  
  
  
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;


int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> x(M), y(M);
    rep(i, M){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }
    vector<bool> flag(N, 0);
    flag[0] = 1;
    vector<int> have(N, 1);
    for(int i = 0; i < M; i++){
        if(flag[x[i]]){
            flag[y[i]] = true;
        }
        if(have[x[i]] == 1){
            flag[x[i]] = false;
        }
        have[x[i]]--;
        have[y[i]]++;
    }
    ll cnt = 0;
    for(int i = 0; i < N; i++){
        if(flag[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 2176
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
using namespace std;


int main() {
	int K, X;
	cin >> K >> X;
	if (K * 500 >= X) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

}

Measured memory_bytes: 256