akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr ll P = 1e9 + 7;
//constexpr ll P = 998244353;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

#include <vector>
#include <functional>

/*	verified : 2020/07/17
		AOJ, Range Minimum Query (RMQ)
		http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A
*/

template<typename T>
struct segment_tree {
	long long N;				// the size of V
	long long M;				// the number of leaves
	std::vector<T> V;			// Segment Tree, 1-indexed
	std::function<T(T, T)> OP;	// binary operation
	T ID;						// identity element op OP

	segment_tree(std::vector<T>& a, std::function<T(T, T)> f, T t) : OP(f), ID(t) {
		M = 1;
		while (M < a.size()) M *= 2;
		N = 2 * M;
		V.resize(N, ID);
		for (long long i = 0; i < a.size(); i++) V[M + i] = a[i];
		for (long long i = a.size(); i < M; i++) V[M + i] = ID;
		for (long long i = M - 1; i > 0; i--) {
			V[i] = OP(V[2 * i], V[2 * i + 1]);
		}
	}

	segment_tree() {}
	void init(std::vector<T>& a, std::function<T(T, T)> f, T t) {
		OP = f; ID = t;
		M = 1;
		while (M < a.size()) M *= 2;
		N = 2 * M;
		V.resize(N, ID);
		for (long long i = 0; i < a.size(); i++) V[M + i] = a[i];
		for (long long i = a.size(); i < M; i++) V[M + i] = ID;
		for (long long i = M - 1; i > 0; i--) {
			V[i] = OP(V[2 * i], V[2 * i + 1]);
		}
	}

	void point_update(long long i, T x) {
		i += M;
		V[i] = x;
		while (i / 2 < i) {
			i /= 2;
			V[i] = OP(V[2 * i], V[2 * i + 1]);
		}
	}

	T range_subfunc(
		long long cur_node, long long cur_left, long long cur_right,
		long long l, long long r
	) {
		if (cur_right <= l || r <= cur_left) return ID;
		if (l <= cur_left && cur_right <= r) return V[cur_node];
		long long mid = (cur_left + cur_right) / 2;
		return OP(
			range_subfunc(cur_node * 2, cur_left, mid, l, r),
			range_subfunc(cur_node * 2 + 1, mid, cur_right, l, r)
		);
	}

	T range_fold(long long l, long long r) {
		return range_subfunc(1, 0, M, l, r);
	}
};

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

	ll n, q;
	cin >> n >> q;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	auto f = [] (ll a, ll b) {return a + b;};
	segment_tree<ll> sg(a, f, 0);
	while (q--) {
		ll x, y, z;
		cin >> x >> y >> z;
		if (x == 0) {
			sg.point_update(y, a[y] + z);
			a[y] += z;
		} else cout << sg.range_fold(y, z) << '\n';
	}
}

Measured memory_bytes: 16456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector <ll> arr(n+1);
	for (int z=1;z<=n;z++){
		cin >> arr[z];
	}
	vector <map<ll,vector<ll>>> dp(n+1);
	dp[0][0].resize(2);
	dp[0][0][0] = 0;
	dp[0][0][1] = -(ll(1) << 50);
	for (int z=1;z<=n;z++){
		for (int x=max(ll(z)/2-5,ll(0));x<z/2+5;x++){
			dp[z][x].resize(2);
			dp[z][x][0] = -(ll(1) << 60);
			dp[z][x][1] = -(ll(1) << 60);
			for (int i=1;i<=4;i++){
				if (z-i < 0) break;
				if (dp[z-i].find(x) != dp[z-i].end()) dp[z][x][0] = max(dp[z][x][0],dp[z-i][x][1]);
				if (dp[z-i].find(x-1)!= dp[z-i].end()) dp[z][x][1] = max(dp[z][x][1],dp[z-i][x-1][0]+arr[z]);
			}
		}
	}
	ll ans = -LLONG_MAX;
	for (int z=1;z<=n;z++){
		if (dp[z].find(n/2) != dp[z].end()){
			ans = max(ans,max(dp[z][n/2][0],dp[z][n/2][1]));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 232856
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
using ll =long long;

int main (void) {
  int N,ans,l,r;
  scanf("%d", &N);
  for (int i=0;i<N;i++) scanf("%d%d",&l,&r) ,ans+=r-l+1;
  printf("%d", ans);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pll pair<ll,ll>
#define ld long double
#define pld pair<ld,ld>
#define pii pair<int,int>
#define sqr(a) ((a)*(a))
#define all(v) v.begin(),v.end()

using namespace std;
//using namespace __gnu_pbds;

const ll MOD = 1e9+7;
const ll INF=1e18;
const ld E=1e-8;
mt19937_64 rnd(time(0));
ll p1 = 31, p2 = 29, p3 = 7, p4=rnd()%100+1, md1 = MOD, md2 = 998244353, md3=998244357, md4=rnd()%1000000000;

//using ord_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

ll n, m, k, h, T;
ll a[300001], b[300001];

ll binpow(ll h, ll r, ll md = MOD)
{
    ll l = 1;
    while (r)
    {
        if (r & 1) l *= h, l %= md;
        h *= h;
        h %= md;
        r /= 2;
    }
    return l;
}

ll gcd(ll x, ll y)
{
    if (x < y) swap(x, y);
    while (x && y)
    {
        x %= y;
        swap(x, y);
    }
    return x + y;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen("capitals.in","r",stdin);
    //freopen("capitals.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i];
    }
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    if (n%2)
    {
        cout << b[n/2+1]-a[n/2+1]+1 << "\n";
    }else
    {
        ld x=(ld)(a[n/2]+a[n/2+1])/2., y=(ld)(b[n/2]+b[n/2+1])/2.;
        cout << (ll)((y-x)/0.5)+1 << "\n";
    }
    return 0;
}

/*
4
1 4 3 6
3
1 2 3
4
6 3 4 1
*/


Measured memory_bytes: 6704
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

while True:
    h, w = map(int, input().split())
    if h + w == 0:
        exit(0)

    for i in range(h):
        for j in range(w):
            if (i+j) % 2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 8296
#include<stdio.h>
#include<stdlib.h>
#define N 10000
#define NIL -1
#define O 0


struct Node{
  int p,l,r;
};

struct Node T[N];
int n;

void preOrder(int u){
  if(u==NIL){
    return;
  }
  printf(" %d",u);
  preOrder(T[u].l);
  preOrder(T[u].r);
}

void inOrder(int u){
  if(u==NIL){
    return;
  }
  inOrder(T[u].l);
  printf(" %d",u);
  inOrder(T[u].r);
}

void postOrder(int u){
  if(u==NIL){
    return;
  }
  postOrder(T[u].l);
  postOrder(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,d,v,l,r;
  scanf("%d",&n);
  for(i=O;i<n;i++){
    T[i].p=NIL;
  }
  for(i=O;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&l);
    scanf("%d",&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL){
      T[l].p=v;
    }
    if(r!=NIL){
      T[r].p=v;
    }
  }
  for(i=O;i<n;i++){
    if(T[i].p==NIL){
      d=i;
    }
  }

  printf("Preorder\n");
  preOrder(d);
  printf("\n");
  printf("Inorder\n");
  inOrder(d);
  printf("\n");
  printf("Postorder\n");
  postOrder(d);
  printf("\n");
  return O;
}



Measured memory_bytes: 2096
m,d=[int(i) for i in input().split()]
ans=0
for i in range(1,m+1):
    for j in range(1,d+1):
        s=str(j)
        if len(s)==1:
            s="0"+s
        if int(s[0])>=2 and int(s[1])>=2 and int(s[0])*int(s[1])==i:
            ans+=1
print(ans)

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

using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

#define MP make_pair<int,int>

int main(){
  int n;
  scanf("%d\n",&n);
  while(n--){
    char __s[2521];
    gets(__s);
    string s(__s);
    int t;
    while((t=s.find("Hoshino"))!=-1){
      s[t+6] = 'a';
    }
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
        #define ll long long
        #define rep(i,a,b) for(i=a;i<b;i++)
        #define pb push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define CLR(a) memset((a),0,sizeof(a))
        #define mp make_pair
        #define hell 1000000007

        using namespace std;
         //int g[105][105];
        //vector < int > wt(100004);
       // vector < int > a;
        //vector < int > v(30500);
        //int cst[102][100005];
        //int ansr[100005];
     //ll int sum,x=0,c=0,n,m,flag=0,a1,a2,flag1=0,flag2=0;


         /* rep(i,0,50)
          {
              if(ck[i]) cout<<i<< " o"<<endl;
              else cout<<i<<" e"<<endl;
          }*/

        void solve()
        {
          ll int  i,j=0,r=200,p,q,k=0,ans=0,d,y=0,h,flag=0,n,m=0,a,b,id,c,h1,h2,a1,b1;
          cin>>n;
          vector < ll int > dm(n+1),mn(n+1),v(n+1);
          rep(i,1,n+1) cin>>dm[i];
          h1=h2=0;
          rep(i,1,n+1)
            {
                if(i%2==0) h1+=2*dm[i];
                h2+=dm[i];
            }
            v[1]=h2-h1; //cout<<h2<<" "<<h1<<endl;
            rep(i,2,n+1)
              {
                  v[i]=2*dm[i-1]-v[i-1];
              }
              rep(i,1,n+1) cout<<v[i]<<" ";

        }

        int main()
        {
            ios::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            int t=1;
          //  cin>>t;
            while(t--)
            solve();
        }

           /*

      void bfs( int i , int j)
           {
               vis[i][j]= true;
             queue < int > que;
             que.push(k);
             while(!que.empty())
             {
                int x= que.front();
                que.pop();
                 for ( int i=1;i<=n;i++)
                 {
                     if((!g[1][n] and g[x][i] ) or (g[1][n] and ! g[x][i]))
                     {
                       if(!vis[i])
                       {
                           que.push(i);
                           level[i]=level[x]+1;
                           vis[i]= true;
                       }
                     }
                 }
             }
           }

          ll int por(ll int a,ll int b)
             {
                ll int k=1;
                while(b>0)
                {
                    if(b%2) k=k*a,k%=hell;
                    b/=2;
                    a*=a; a%=hell;
                }
                return k;
             } */


Measured memory_bytes: 3712
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define rep(i , a , n) for (int i=a; i<(int)(n); i++)
#define re(i , n)     for (int i=0; i<(int)(n); i++)
#define p push_back
#define em emplace_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define trace(a) cerr << #a << " = " << a << endl

using namespace std;

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

const int mod=7+1e9;
const int inf=1e9;
const int N=1e5+5;
int dp[N],h[N];
int n,k;
int f(int i)
{
    if(i>=n)return 0;
    int &ret=dp[i];
    if(ret!=-1)return ret;
    int c1=inf;
    for(int j=1;j<=k&&i+j<=n-1;++j)
    {
        if(i+j<=n-1)
        c1=min(c1 , abs(h[i]-h[i+j]) + f(i+j) );
    }
    return ret=(c1==inf?0:c1);
}
int main()
{
#ifdef LOCAL
    freopen("input.in", "r", stdin);
#endif
      IOS;
      cin>>n>>k;
      re(i,n)
          cin>>h[i];
      memset(dp,-1,sizeof dp);
      cout<<f(0);
}




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

const int INF = 1001001001;

vector<int> to[100005];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;              // dfs の実装には queue を使う
  vector<int> dist(n, INF);  // 距離
  vector<int> pre(n, -1);    // 直前の頂点
  dist[0] = 0;
  q.push(0);
  while (!q.empty()) {
    // 最初の要素を取り出す
    int v = q.front();
    q.pop();
    for (int u : to[v]) {
      if (dist[u] != INF) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }

  cout << "Yes" << endl;
  rep(i, n) {
    if (i == 0) continue;
    int ans = pre[i];
    ++ans;
    cout << ans << endl;
  }

  return 0;
}


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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var number = str[0] * 100 + str[1] * 10 + str[2];

            if(number % 4 == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    cin>>n;
    vll facs;
    for(i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            if(i*i!=n)facs.pb(n/i);
            facs.pb(i);
        }
    }
    flag=0;
    sort(facs.begin(),facs.end());
    for(i=1;;i++)
    {
        for(j=0;j<facs.size();j++)
        {
            x=i;
            y=x-facs[j];
            if(pow(x,5)-pow(y,5)==n){flag=1;break;}
        }
        if(flag)break;
    }
    cout<<x<<" "<<y;
}

Measured memory_bytes: 4232
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
  ll n,k;
  cin >> n >> k;
  set<ll> s;

  while(k--){
    ll temp;
    cin >> temp;
    while(temp--){
      ll temp1;
      cin >> temp1;
      s.insert(temp1);
    }
  }
  cout << n-s.size();
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
typedef long long int ll;
typedef vector<int> vint;
typedef vector<bool> vbool;
const ll LINF = 9000000000000000000ll;
const int INF = 2000000000;
const ll MOD = 1e9+7;

vbool prime_bool(int n) {
    vbool ans(n, true);
    ans[0] = false;
    ans[1] = false;
    srep(i, n+1, 2) {
        if (ans[i]) {
            int j = i*2;
            while (j <= n) {
                ans[j] = false;
                j += i;
            }
        }
    }
    return ans;
}

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

    int n = 100005;
    auto p = prime_bool(n);
    vint a(n, 0);
    int total = 0; 
    rep(i, n) {
        if (i%2==1 && p[i] && p[(i+1)/2]) {
            total += 1;
            a[i] = total;
        } else {
            a[i] = total;
        }
    }
    int l, r;
    vint ans(q);
    rep(i, q) {
        cin >> l >> r;
        ans[i] = a[r] - a[l-1];
    }
    rep(i, q) cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 1408
N = int(input())
primetable = []

i = 2
while i* i <= N:
  if(N % i == 0):
    j = 0
    while N % i == 0:
      N/= i
      j+= 1
    primetable.append((i, j))
  i+= 1
if(N != 1):
  primetable.append((int(N), 1))
  
Ans = 0  
for i in primetable:
  ans = 0
  n = 1
  while 1/ 2* n* (n+ 1)<= i[1]:
    ans = n
    n+= 1
  Ans+= ans  
  
print(Ans)

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

int main() {
    long a, b, k;
    cin >> a >> b >> k;
    //aから食べる
    if(k < a){
        a -= k;
        k = 0;
    }
    if(k >= a){
        k -= a;
        a = 0;
    }
    //bから食べる
    if(k != 0){
        if(k < b){
            b -= k;
            k = 0;
        }
        if(k >= b){
            k -= b;
            b = 0;
        }
    }
    cout << a << " "<< b << endl;
}

Measured memory_bytes: 256
#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 cnt=1;
   vector<int>r;
   for(int i=0;i<n-1;i++){
    if(a[i+1]<=a[i]){
    cnt++;
    r.push_back(cnt);
    }
    else {
      cnt=1;
    }
   }
   if(r.size()==0){
    cout<<0;
    return 0;
   }
   sort(r.begin(),r.end());
   reverse(r.begin(),r.end());
   cout<<r[0]-1;

return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

char str[12];

int main() {
    cin >> str;
    int e = 0, ans = 0;
    rep(b, strlen(str)) {
        if (e < b) e = b;
        while (str[e] == 'A' || str[e] == 'T' || str[e] == 'G' || str[e] == 'C') e++;
        ans = max(ans, e - b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		boolean flg = false;

		for (int i = 1; i <= 9; i++) {
			if (A % i == 0) {
				if (1 <= A / i && A / i <= 9) {
					System.out.print("Yes");
					flg = true;
					break;
				}
			}
		}
		if (!flg) {
			System.out.print("No");
		}

	}
}


Measured memory_bytes: 23508
#include <cstdio>
using namespace std;

int a,b,n;

int main(void)
{
    scanf("%d%d%d",&n,&a,&b);
    for(int i=n;i<=b;i+=n)
    {
        if(a<=i&&i<=b)
        {
            printf("OK");
            return 0;
        }
    }
    
    printf("NG");
    return 0;
}

Measured memory_bytes: 1732
import copy

n = int(input())
l = [input().split() for i in range(n)]
index = copy.deepcopy(l)

for i in range(n):
    l[i][1] = int(l[i][1])
    index[i][1] = int(index[i][1])

l.sort(key=lambda x: x[1], reverse=True)
l.sort(key=lambda x: x[0], reverse=False)

for i in range(n):
    for j in range(n):
        if l[i] == index[j]:
            print(j+1)
            break


Measured memory_bytes: 3444
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

template<typename T>
T meguru_search(T ok, T ng, function<bool(T)> check){
    while(max(ok, ng) - min(ok, ng) > T(1)){
        T mid = (ok + ng) / T(2);
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    lint n, m;
    cin >> n >> m;

    vector<lint> a(n);
    rep(i, n){
        cin >> a[i];
    }
    SORT_INV(a);

    vector<lint> sum(n + 1);
    reps(i, n){
        sum[i] = sum[i - 1] + a[i - 1];
    }

    lint cnt;
    int r;

    auto check = [&](lint mid){
        cnt = 0;
        r = n - 1;
        rep(i, n){
            while(r >= 0 && a[i] + a[r] < mid){
                --r;
            }
            cnt += r + 1LL;
        }
        return cnt >= m;
    };

    lint mini = meguru_search<lint>(-1LL, LLINF, check);

    lint ans = 0;
    cnt = 0;
    r = n - 1;
    rep(i, n){
        while(r >= 0 && a[i] + a[r] < mini){
            --r;
        }
        ans += a[i] * (r + 1LL) + sum[r + 1];
        cnt += r + 1LL;
    }
    ans -= max(cnt - m, 0LL) * mini;

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;

bool isOK(ll x,ll k,vector<ll> a)
{
	ll sum = 0;
	rep(i, a.size())
	{
		sum += (a[i] + x - 1) / x - 1;
	}
	if (sum <= k)
		return true;
	return false;
}


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

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n)
	{
		cin >> a[i];
	}
	
	ll ok = 1000000001;
	ll ng = 0;

	while (abs(ok - ng) > 1)
	{
		ll mid = (ok + ng) / 2;
		if (isOK(mid,k,a))
		{
			ok = mid;
		}
		else
		{
			ng = mid;
		}
	}

	cout << ok << endl;
	
	//ll n;
	//ll bits = (1 << n) - 1;
	////全部0の場合も調べたいのなら条件を変更するか、別途その分だけプログラムを書く
	//while (bits)
	//{
	//	ll tmp = bits;
	//	for (int i = 0; i < n; i++)
	//	{
	//		if ((tmp >> i) & 1)
	//		{
	//			func();
	//		}
	//		else
	//		{

	//		}
	//	}

	//	bits--;
	//}

	return 0;
}

Measured memory_bytes: 6364
#include <stdio.h>
 
int main()
{
/* 問題文
　左右一列にN個のマスが並んでおり、左からi番目のマスの高さは Hiです。
　あなたは各マスについて1度ずつ次のいずれかの操作を行います。
　マスの高さを 1低くする。何もしない。
　操作をうまく行うことでマスの高さを左から右に向かって単調非減少にできるか求めてください。
*/
    int i,N,Ans=0;
    int N_max = 100000; 
    int H[N_max];
    

    scanf("%d", &N);
    if(N> 100000) N=100000; 
    if(N<1) N=1;
    
    // Hiの読み込み
    for(i=0;i<N;i++){
        scanf("%d", &H[i]);  
    }

    // 値の操作
    for(i=0;i<(N-1);i++){
        if(H[i] > H[i+1]){
            H[i] = H[i]-1;
            if(H[i] < 1) H[i]=1;            
        }
        // 右隣と同値の場合は最右端とも比較
        else if((H[i]>H[N-1]) && (H[i] == H[i+1])){
            H[i] = H[i]-1;
            if(H[i] < 1) H[i]=1;         
        }
        
    }
    
    /*
     for(i=N-2;i=0;i--){
        if(H[i] > H[i+1]){
            H[i] = H[i]-1;
            if(H[i] < 1) H[i]=1;            
        }  
    }
    */
 
    
    
    // 短調非減少のチェック
    for(i=0;i<N-1;i++){
        if(H[i]>H[i+1]){
            Ans = -1;
        }  
    }
    
    // 結果出力
    if(Ans == -1)
        printf("No");
    else
        printf("Yes");
    
  return 0;  
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

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

signed main() {
	int K;
	cin >> K;
	
	int ans = 0;
	for (int a = 1; a <= K; a++) {
		for (int b = 1; b <= K; b++) {
			for (int c = 1; c <= K; c++) {
				int g = gcd(a, b);
				g = gcd(g, c);
				ans += g;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
void print(vector<int> &dp){
	for(auto d: dp) cout<<d<<" ";
	cout<<endl;
}
void mincost(vector<int> h,int k){
	vector<int> dp(h.size());
	//print(h);
	dp[0] = 0;
	for(int i=1;i<h.size();++i){
		dp[i] = INT_MAX;
		for(int x=1;x<=k;++x){
			// standing at i, see all the ways I could have reached it (I can only take steps from 1 to k)
			if(i-x>=0) {
				dp[i] = min(dp[i],dp[i-x] + abs(h[i]-h[i-x]));
				//cout<<i<<" "<<i-x<<endl;
				//print(dp);
			}
		}
	}
	cout<<dp[h.size()-1];
}
int main(){
	int n,k;
	cin>>n>>k;
	vector<int> h(n,0);
	for(auto& x:h) cin>>x;
	mincost(h,k);
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1), B(N);
  for (int i = 0; i < N + 1; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> B[i];
  }

  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    int C = min(A[i], B[i]);
    ans += C, A[i] -= C, B[i] -= C;
    ans += min(A[i + 1], B[i]), A[i + 1] -= min(A[i + 1], B[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3988
N, M = map(int, input().split())

A = {}
for i in range(N):
  KA = list(map(int, input().split()))
  for a in KA[1:]:
    if a in A:
      A[a] += 1
    else:
      A[a] = 1


ans = 0
for a in A:
  if A[a] == N:
    ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#ifdef _GLIBCXX_DEBUG
int c_;
#define dbg(...) {if(!c_)cerr<<"\033[96;1m";++c_; \
__VA_ARGS__;--c_;if(!c_)cerr<<"\033[0m";}
#else
#define dbg(...)
#endif
#define st first
#define nd second
#define flg() __LINE__, __PRETTY_FUNCTION__
#define mkp(...) make_pair(__VA_ARGS__)
#define prt(...) print(cout, __VA_ARGS__)
#define dprt(...) dbg(print(cerr, __VA_ARGS__))
#define dmp(...) dprt(#__VA_ARGS__, __VA_ARGS__)
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std; using ll = long long;
template< typename t > using V = vector< t >;
template< typename t > void print(ostream& os, const t& a){os<<a<<'\n';}
template< typename t, typename... v > void print(ostream& os, const t& a, 
v&&... b){os << a << ' '; print(os, b...);}

constexpr int maxn = 1e5;

int n, m;
int tb[maxn + 1][2];


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

    cin >> n >> m;

    tb[1][1] = 1;

    for (int i = 2; i <= n; ++i)
        tb[i][0] = 1;

    for (int i = 0; i < m; ++i)
    {
        int x, y; cin >> x >> y;

        if (tb[x][0] and tb[x][1])
            --tb[x][0], ++tb[y][1];
        else if (tb[x][1])
            --tb[x][1], ++tb[y][1];
        else if (tb[x][0])
            --tb[x][0], ++tb[y][0];
    }

    int rs = 0;

    for (int i = 1; i <= n; ++i)
        if (tb[i][1])
            ++rs;

    prt(rs);
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
constexpr int MOD = 1000000007;
constexpr ll INF = 50000000000000000;
typedef std::pair<int,int> P;
constexpr ll SIZE= 100010;

ll Fact[100010];
ll Com[100010];
ll LP(ll x,ll y);
void FC(ll x);
ll MC(ll x,ll y);
ll LP(ll x,ll y){
    if(y==0)return 1;
    if(y%2==0)return LP((x*x)%MOD,y/2)%MOD;
    else return LP(x,y-1)*x%MOD;
}
void FC(ll x){
    Fact[0]=Com[0]=1;
    ll temp=1;
    EREP(i,x){
        temp=temp*i%MOD;
        Fact[i]=temp;
        Com[i]=LP(temp,MOD-2);
    }
}
ll MC(ll x,ll y){
    if(y==0)return 1;
    if(x<y)return 0;
    return (Fact[x]*(Com[y]*Com[x-y]%MOD))%MOD;
}

ll N,M;
ll S[100010];
ll ans=0;
bool F=true;
int main() {
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    FC(N);
    REP(i,N){
        S[i]+=LP(i+1,MOD-2);
    }
    REP(i,N){
        S[i+1]+=S[i];
        S[i+1]%=MOD;
    }
    REP(i,N){
        ll a;
        cin>>a;
            ll s=(S[N-1-i]+S[i]-S[0])%MOD;
        ans+=s*a;
        ans%=MOD;
    }
    cout<<(ans*Fact[N])%MOD<<endl;
    return 0;
}

Measured memory_bytes: 2560
// https://atcoder.jp/contests/abc149/tasks/abc149_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, K;
  ll R, S, P;
  string T;
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;

  map<char, ll> pts;
  pts['r'] = R;
  pts['s'] = S;
  pts['p'] = P;

  ll res = 0;
  V<char> hands(N);

  rep(i, N) {
    char next = T[i];

    char want = next == 'r' ? 'p' : next == 's' ? 'r' : 's';

    if (i >= K && hands[i - K] == want) {
      hands[i] = '#';
      continue;
    }

    hands[i] = want;
    res += pts[want];
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main(void){
    int a,b;
    cin >> a >> b;
    int count = 0;
    while(a>0){
        a = a/b;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<string> title(n);
  vector<int> time(n);
  for(int i=0; i<n; i++){
    cin>>title.at(i)>>time.at(i);
  }
  string x;
  cin>>x;
  int ans=0;
  int j;
  for(j=0; j<n; j++){
    if(x==title.at(j))break;
  }
  for(int k=j+1; k<n; k++){
    ans+=time.at(k);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
S = input()

alpha2num = lambda c: ord(c) - ord('A') + 1
num2alpha = lambda c: chr(c+64)

S_list = np.array([alpha2num(s) for s in S])

#print(S_list)
S_list_added = (S_list-1+N)%26+1
#print(S_list_added)

S_list_converted = [num2alpha(s) for s in S_list_added]
print("".join(S_list_converted))



Measured memory_bytes: 21500
#include <iostream>

using namespace std;
int main(){
  int x,y;
  cin >>x >>y;

  if(x==1) x=100;
  if(y==1) y=100;
  if(x>y) cout << "Alice";
  else if(x<y) cout << "Bob";
  else cout << "Draw";

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

map<string, int> m={{"Vacant",0}, {"Male",1}, {"Female",-1}};

bool bin_search(int l, int r, int state){
    int mid=(l+r)/2;

    cout << mid << endl;
    string s;
    cin >> s;

    if(m[s]==0){
        return true;
    }else if((mid%2==0 && m[s]==state) || (mid%2==1 && m[s]==-state)){
        return bin_search(mid, r, state);
    }else{
        return bin_search(l, mid, state);
    }

}

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

    cout << 0 << endl;
    string s;
    cin >> s;
    if(m[s]==0)return 0;
    bin_search(1, N, m[s]);
}


Measured memory_bytes: 852
N = 10 ** 9

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    S = Z()
    x = (S + N - 1)//N
    y = N * x - S
    print(0, 0, 1, N, x, y)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
from itertools import accumulate
def main():
    mod=10**9+7
    n=int(input())
    a=list(map(int,input().split()))
    aa=[0]+list(accumulate(a))
    ans=0
    for i in range(n-1):
        ans += a[i]*(aa[-1]-aa[i+1])%mod
    print(ans%mod)

if __name__ == '__main__':
    main()

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

int main(){
  string s,t;
  cin>>s;
  cin>>t;
  int count = 0;
  for (int i=0; i<s.size(); i++){
    if(s[i] != t[i]){
      count +=1;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3916
N = int(raw_input())
P= [int(x) - 1 for x in  raw_input().split()]
ans=0
for i in range(N-1):
    if P[i]==i:
        [P[i], P[i+1]]= [P[i+1], P[i]]
        ans+=1
if P[N-1]==N-1:
    ans+=1
print ans


Measured memory_bytes: 11560
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, ll> pill;

#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 405;
const ll mod = 1000000007;
const double PI = acos(-1.0);

int n;
int val[maxn];

void solve()
{
	int res = 0;
	int i, j, k;
	repp(i, 1, 2 * n)
	{
		sa(val[i]);
	}
	sort(val + 1, val + 2*n + 1);
	for (i = 1; i <= 2 * n - 1; i = i + 2)
	{
		res += val[i];
	}
	printf("%d\n", res);
}
int main()
{
	while (scanf("%d", &n) != EOF)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

#define ABS(a) ((a)>0?(a):-(a))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))

void run(void){
  int n;
  scanf("%d",&n);
  int *x=(int *)malloc(sizeof(int)*n);
  int *y=(int *)malloc(sizeof(int)*n);
  char *ans=(char *)calloc(n*41,sizeof(char));
  int *dir=(int *)calloc(n,sizeof(int));
  char v[4]={'R','L','U','D'};
  int i;
  for(i=0;i<n;i++) scanf("%d%d",x+i,y+i);
  int cond=(ABS(x[0])+ABS(y[0]))%2;
  for(i=1;i<n;i++){
    if(cond!=(ABS(x[i])+ABS(y[i]))%2){
      printf("-1\n");
      return;
    }
  }
  int d[40];
  int m=0;
  while(m<=40){
    for(i=0;i<n;i++){
      if(ABS(y[i])>ABS(x[i])){
	dir[i]=y[i]>=0?2:3;
      } else {
	dir[i]=x[i]>=0?0:1;
      }
    }
    int max=ABS(x[0])+ABS(y[0]);
    for(i=1;i<n;i++) max=MAX(max,ABS(x[i])+ABS(y[i]));
    if(max==0) break;
    int dd=max==1?1:max/2;
    for(i=0;i<n;i++){
      if(dir[i]==0){
	x[i]-=dd;
      } else if(dir[i]==1){
	x[i]+=dd;
      } else if(dir[i]==2){
	y[i]-=dd;
      } else {
	y[i]+=dd;
      }
      ans[41*i+m]=v[dir[i]];
    }
    d[m++]=dd;
  }
  printf("%d\n",m);
  for(i=0;i<m;i++) printf("%d ",d[i]);
  printf("\n");
  for(i=0;i<n;i++) printf("%s\n",ans+i*41);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 256
// Author by Md. Jashim Uddin_RMSTU

#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     ll              long  long int
#define     fast            ios_base :: sync_with_stdio(false);cin.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)

#define     forn(i,n)       for(int i=1;i<=n;i++)
#define     min3(a,b,c)     min(a,min(b,c)
#define     M             32000

int main()
{
    vector<ll>v;
    ll n,c=0,ss=0;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;++i)
        cin>>a[i];
    for(int i=0;i<n;i++)
    {
        if(a[i]%2==0)
        {
          v.pb(a[i]);
        c++;
        }

    }
    for(int i=0;i<c;i++)
    {
        if(v[i]%3==0 || v[i]%5==0)
        ss++;
    }

   if(ss==c) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;

    return 0;

}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n;cin>>n;

    ld a[n];

    f(i,0,n-1)
    cin>>a[i];

    vector<vector<ld>> dp(n+1,vector<ld>(n+1,0.0));

    dp[0][0]=1.0;

    f(i,1,n)
    {
        dp[i][0]=dp[i-1][0]*(1-a[i-1]);
    }

    f(i,1,n)
    {
        f(j,1,i)
        {
            dp[i][j]=dp[i-1][j-1]*a[i-1]+dp[i-1][j]*(1.0-a[i-1]);
            // cout<<dp[i][j]<<" ";
        }
        // cout<<endl;
    }

    ld ans=0.0;

    f(i,1,n)
    {
        if(i>n/2)
        {
            ans+=dp[n][i];
        }
    }

    cout<<fixed<<setprecision(12)<<ans;

    return 0;
}

Measured memory_bytes: 141056
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
a=get_i
puts yn_judge(a.inject{|x,y| x^y}.zero?)

Measured memory_bytes: 9220
n,z,w=[int(i) for i in input().split(' ')]
a=[int(i) for i in input().split(' ')]

if len(a)>1:
  l0=abs(a[-1]-a[-2])
else:
  l0=-1000000000000000000
l1=abs(a[-1]-w)

if l1>l0:
  print(l1)
else:
  print(l0)

Measured memory_bytes: 3316
#include<iostream>
using namespace std;
int main(){
	int a,min,max,p,mmax=0,mm,i,b;
	while(1){
		mmax=0;
		cin>>a>>min>>max;
		if(a==min && min==max && a==0) break;
		for(i=0;i<a;i++){
			cin>>p;
			if(i>=min && i<max+1){
				if(mm-p>=mmax) {
					mmax=mm-p;
					b=i;
				//	cout<<mm<<" "<<p<<" "<<mmax<<endl;
				}
			}
			mm=p;
		}
		cout<<b<<endl;
	}
	return 0;
}

Measured memory_bytes: 3024
use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::cmp::{max, min};
use std::*;

fn main() {
    input! {
        (n, m): (u32, u32)
    }
    let ans = (m*1900 + (n-m)*100)*2u32.pow(m);
    println!("{}", ans);
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;
  std::vector<int> v(n);
  vvi even = vv(100001, 2, 0, int);
  vvi odd = vv(100001, 2, 0, int);
  range(i, 100001) even[i][1] = odd[i][1] = i;
  range(i, n) {
    std::cin >> v[i];
    if(i%2==0) even[v[i]][0]++;
    else odd[v[i]][0]++;
  }
  if(n==2){
    if(v[0]!=v[1]) std::cout << 0 << '\n';
    else std::cout << 1 << '\n';
    return 0;
  }
  sort(even.begin(), even.end());
  sort(odd.begin(), odd.end());
  reverse(even.begin(), even.end());
  reverse(odd.begin(), odd.end());
  if(even[0][1] == odd[0][1]){
    std::cout << n - max(even[1][0]+odd[0][0], even[0][0]+odd[1][0]) << '\n';
  }else std::cout << n - even[0][0] - odd[0][0] << '\n';
  return 0;
}


Measured memory_bytes: 11648
#include<cstdio>
#include<stdlib.h>
#include<iostream>
using namespace std;

const int maxn = 1005;

int T[maxn][maxn];

int calculateCommon(string s1,string s2){
	for(int i = 0;i <= s1.length();i++){
		for(int j = 0;j <= s2.length();j++){
			if(i == 0 || j == 0){
				T[i][j] = 0;
			}else{
				if(s1[i - 1] == s2[j - 1]){
					T[i][j] = T[i - 1][j - 1] + 1;
				}else{
					T[i][j] = (T[i][j - 1] < T[i - 1][j]) ? T[i - 1][j]:T[i][j - 1];
				}
			}
	//		cout << "T[" << i << "][" << j << "] = " << T[i][j] << endl;
		}
	}
	return T[s1.length()][s2.length()];
}

int main(){
	int q;
	string s1;
	string s2;
	cin >> q;
	getchar();
	for(int i = 0;i < q;i++){
		getline(cin,s1);
		getline(cin,s2);
		cout << calculateCommon(s1,s2) << endl;
	}
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll A, B, C;
    cin >> A >> B >> C;

    if (A%2 == 0 || B%2 == 0 || C%2 == 0) {
        cout << 0 << endl;
    } else {
        if (A < B) {
            if (B < C) {
                cout << A*B << endl;
            } else {
                cout << A*C << endl;
            }
        } else {
            if (A < C) {
                cout << A*B << endl;
            } else {
                cout << B*C << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256