akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

bool solve(int n) 
{
    string s = to_string(n);
    rep(i,s.size()-1) {
        if(s[i] != s[i+1]) { 
            return true;
        }
    }
    return false;
}


int main() 
{
    int s;
    bool loop = true;
    cin >> s;
    
    while(1){
        loop = solve(s);
        if(loop) {
            s++;
        } else {
            break;
        }
    }

    cout << s << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <deque>
#include <stack>
#include <iomanip>
#include <cmath>


using namespace std;


typedef long long ll;
typedef long double ld;


const int MAXN = 101;


int N, mean;
int a[MAXN];


int getDist(int x, int y) {
  int d = x - y;
  return d*d;
}


void input() {
  cin >> N;
  for (int i = 1 ; i <= N ; i++) {
    cin >> a[i];
  }
}


void preprocess() {
  int sum = 0;
  for (int i = 1 ; i <= N ; i++) {
    sum += a[i];
  }
  mean = round(1.0 * sum / N);
}


void solve() {
  int ans = 0;
  for (int i = 1 ; i <= N ; i++) {
    ans += getDist(a[i], mean);
  }
  cout << ans;
}






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

  int T;
//  cin >> T;
  T = 1;

  for (int i = 0 ; i < T ; i++) {
    input();
    preprocess();
    solve();
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<ll>
#define pb push_back
#define ff first
#define ss second
#define inf 2e18
#define ull unsigned long long
#define pi acos(-1.0)
#define mod 1000000007
#define lop0(n) for(ll i=0;i<n;i++)
#define lopj(n) for(ll j=0;j<n;j++)
#define lop1(n) for(ll i=1;i<=n;i++)
#define all(v) v.begin(),v.end()
ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vi vec[200005];
ll vis[200005],cnt;
ll dfs(ll u)
{
    vis[u]=1;
    cnt+=1;
    for(ll i=0;i<vec[u].size();i++)
    {
        if(vis[vec[u][i]]==0)
        {
            dfs(vec[u][i]);
        }
    }
    return cnt;
}
main()
{
    ll n,m;
    cin>>n>>m;
    while(m--)
    {
        ll a,b;
        cin>>a>>b;
        vec[a].pb(b);
        vec[b].pb(a);
    }
    ll ans=1;
    lop1(n)
    {
        if(vis[i]==0)
        {
            cnt=0;
            ans=max(ans,dfs(i));
        }
    }
    cout<<ans;
}



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



int main() {

	int n, m;
	int a, b, c;

	scanf("%d", &n);

	a = n % 10;
	b = ( (n - a) % 100) / 10;
	c = ( ( n - 10 * b - a ) % 1000 ) / 100;

	m = c + 10 * b + 100 * c;

	if (n == m) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return 0;
}


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

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int gcd(int a,int b)
{
	return (b == 0)?a:gcd(b,a%b);
}
int main() {
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
	off;
	int n,x;
	cin>>n>>x;
	vector<int> arr(n);
	rep(i,0,n)
	{
		cin>>arr[i];
		arr[i]-=x;
		arr[i]=abs(arr[i]);
	}
	int g=arr[0];
	rep(i,1,n)
	{
		if(g < arr[i])
			swap(g,arr[i]);
		g = gcd(g,arr[i]);
		if(g == 1)
			break;
	}
	cout<<g;
  	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

struct edge{int to,cost;};

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vector<vector<edge>> g(n);
    rep(i,n-1){
        int u,v,c; cin >> u >> v >> c; u--; v--;
        g[u].pb(edge{v,c});
        g[v].pb(edge{u,c});
    }

    int q, k; cin >> q >> k; k--;
    vint d(n,-1);
    d[k]=0;
    queue<int> que;
    que.push(k);
    while(!que.empty()){
        int v=que.front(); que.pop();
        for(auto nv:g[v]){
            if(d[nv.to]!=-1) continue;
            d[nv.to]=d[v]+nv.cost;
            que.push(nv.to);
        }
    }

    while(q--){
        int u,v; cin >> u >> v; u--; v--;
        cout<<d[u]+d[v]<<endl;
    }

}

Measured memory_bytes: 11936
num = []
while True:
    l = map(int, raw_input().split())
    if l[0] == l[1] == l[2] == -1:
        break
    if l[0]*l[1] < 0:
        num.append("F")
    else:
        sum = l[0] + l[1]
        if sum >= 80:
            num.append("A")
        elif sum >= 65:
            num.append("B")
        elif sum >= 50:
            num.append("C")
        elif sum >= 30:
            if l[2] >= 50:
                num.append("C")
            else:
                num.append("D")
        else:
            num.append("F")

for i in range(len(num)):
    print num[i]

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N; cin >> N;
  //main
  
  
  // output
  if(N%2){cout << N/2 << endl;}
  else{cout << N/2-1 << endl;}

  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string s;
	int ans;
	cin >> s;

	if ((s[0] == 'R') && (s[1] == 'R') && (s[2] == 'R')) ans = 3;
	else if ((s[0] == 'R') && (s[1] == 'R')) ans = 2;
	else if ((s[2] == 'R') && (s[1] == 'R')) ans = 2;
	else if ((s[0] == 'R') || (s[1] == 'R') || (s[2] == 'R')) ans = 1;
	else ans = 0;

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class abc139_c
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine()); //マスの数を読み込み
        int[] H = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);　//マスの高さを読み込みして配列に挿入
        int ans = 0; //最大で移動できる数
        int count = 0; //i番目をカウント
        for (int i = 1; i < N; i++)
        {
            if (H[i - 1] >= H[i])
                count++;
            else
            {
                ans = Math.Max(ans , count); //ansとcountを比べて大きい方をansに挿入
                count = 0;
            }
        }
        ans = Math.Max(ans , count);
        Console.WriteLine(ans);
        Console.Read();
    }
}


Measured memory_bytes: 26844
#include <iostream>

int main(){
    int a,b,c,d;

    std::cin >> a >> b >> c;

    while((a>b) || (b>c) || (a>c)){   
        if(a>b){
            d = a;
            a = b;
            b = d; 
        }
        if(b>c){
            d = b;
            b = c;
            c = d;          
        }
        if(a>c){
            d = a;
            a = c;
            c = d;           
        }
    }

    std::cout << a << " " << b << " " << c << std::endl;
}


Measured memory_bytes: 3088
from math import sqrt,ceil,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())


# for _ in range(ii()):

n,k=mi()
a=li()
for i in range(k,n):
    if a[i]>a[i-k]:
        print('Yes')
    else:
        print('No')
    

Measured memory_bytes: 94300
import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
a, b, c = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(3, n)
a.sort(); c.sort()

def main():
    print(np.sum(np.searchsorted(a, b) * (n - np.searchsorted(c, b, side='right'))))

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 50040
package main

import (
	"fmt"
)

func main() {
	var n, m, x int
	fmt.Scanf("%d %d %d", &n, &m, &x)
	c := make([]int, n)
	sk := make([][]int, n)
	for i := 0; i < n; i++ {
		sk[i] = make([]int, m)
		fmt.Scan(&c[i])
		for j := 0; j < m; j++ {
			fmt.Scan(&sk[i][j])
		}
	}
	var sum int
	mini := 100000000000000000
	for bit := 0; bit < (1 << n); bit++ {
		sum = 0
		aa := make([]int, m)
		for i := 0; i < n; i++ {
			if (bit>>i)&1 == 1 {
				sum += c[i]
				for j := 0; j < m; j++ {
					aa[j] += sk[i][j]
				}
			}
		}
		if min(aa) >= x {
			if mini >= sum {
				mini = sum
			}
		}
	}
	if mini == 100000000000000000 {
		fmt.Println("-1")
	} else {
		fmt.Println(mini)
	}
}

func min(a []int) int {
	m := 999999
	for i := 0; i < len(a); i++ {
		if m >= a[i] {
			m = a[i]
		}
	}
	return m
}


Measured memory_bytes: 2236
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> a(Q);
  vector<int> b(Q);
  vector<int> c(Q);
  vector<int> d(Q);
  
  for(int i=0;i<Q;i++){
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  
  vector<int> A(10);
  long long maximum = 0;
  
  for(A.at(9)=1;A.at(9)<=M;A.at(9)++){
    for(A.at(8)=1;A.at(8)<=A.at(9);A.at(8)++){
      for(A.at(7)=1;A.at(7)<=A.at(8);A.at(7)++){
        for(A.at(6)=1;A.at(6)<=A.at(7);A.at(6)++){
          for(A.at(5)=1;A.at(5)<=A.at(6);A.at(5)++){
            for(A.at(4)=1;A.at(4)<=A.at(5);A.at(4)++){
              for(A.at(3)=1;A.at(3)<=A.at(4);A.at(3)++){
                for(A.at(2)=1;A.at(2)<=A.at(3);A.at(2)++){
                  for(A.at(1)=1;A.at(1)<=A.at(2);A.at(1)++){
                    for(A.at(0)=1;A.at(0)<=A.at(1);A.at(0)++){
                      long long sum = 0;
                      for(int i=0;i<Q;i++) if(A.at(b.at(i)) - A.at(a.at(i)) == c.at(i)) sum += d.at(i);
                      if(sum > maximum) maximum = sum;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << maximum << endl;
  return 0;
}

Measured memory_bytes: 3644
function Main(input) {
    var A = parseInt(input[0], 10);
    var B = parseInt(input[1], 10);
 
    var sum = A + B;
 
    console.log(sum % 2 === 0 ? sum/2 : sum/2 + 0.5);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372
def ketu(x, y):
    gx = get_g(x)
    gy = get_g(y)
    if dep[gy] > dep[gx]:
        gx, gy = gy, gx
    if dep[gy] == dep[gx]:
        dep[gx] += 1
    oya[gy] = gx

def get_g(x):
    oyax = oya[x]
    if oyax == x:
        return x
    re = oya[x] = get_g(oyax)
    return re

n, m = map(int, input().split())
oya = [i for i in range(n + 1)]
dep = [1] * (n + 1)
for _ in range(m):
    x, y, z = map(int, input().split())
    ketu(x,y)
for i in range(1,n+1):
    get_g(i)
print(len(set(oya[1:])))


Measured memory_bytes: 14752
N,M = map(int,input().split())
X = list(map(int,input().split()))

if N >= M:
    print(0)
else:
    X.sort()
    D = []
    for i in range(M-1):
        D.append(X[i+1]-X[i])
    D.sort()
    print(sum(D[0:M-N]))

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

int main(){
  int N;
  cin>>N;
  bool ans=false;
  for(int i=2;i<10;++i){
    if(N%i==0){
      if(N/i<10){
      ans=true;
      }
  }
  }
  if(N==1){ans=true;}
  if(ans){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main() {
	int n,sum=0,a,b;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a>>b;
		sum+=b-a+1;
	}
	cout<<sum<<endl;
	return 0;
}

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

int main(){
    
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    vector<int> interval(n);

    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    for(int i=0;i<n-1;i++){
        interval.at(i)=a.at(i+1)-a.at(i);
    }
    interval.at(n-1)=a.at(0)+(k-a.at(n-1));

    sort(interval.rbegin(),interval.rend());

    cout << k-interval.at(0) << endl;


}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=663224321;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
int main(){
  IOS();
  ll ans = 0;
  ll n;
  cin >> n;
  REP (i,n) {
    ll x;
    cin >> x;
    if (x&1) ans = 1;
  }
  if (ans) cout << "first" << endl;
  else cout << "second" << endl;
}


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

int main(){
    int N,M; cin >> N >> M;
    int sum=0;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
        sum=sum+A.at(i);
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    if(A.at(M-1)*4*M<sum) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3632
import copy

n=int(input())
a=list(map(int,input().split( )))
q=int(input())
for _ in range(q):
    b,m,e = map(int,input().split( ))
    tmp=a[b:e]
    tmp2=copy.deepcopy(tmp)
    #####
    for k in range(e-b):
        a[b+k]=tmp2[k-(e-m)]
        #print(*tmp)
print(*a)



Measured memory_bytes: 6484
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  i64 N;
  cin >> N;
  vector<i64> A(N);
  vector<i64> cnt(N);
  rep(i,1,N) {
    cin >> A[i];
    A[i]--;
    cnt[A[i]]++;
  }
  rep(i,0,N) {
    cout << cnt[i] << endl;
  }
}


Measured memory_bytes: 6428
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 103 D "Islands War"
 *   https://abc103.contest.atcoder.jp/tasks/abc103_d/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = in.nextInt();
		int M = in.nextInt();
		int[][] ab = in.nextIntArray(M, 2);

		Arrays.sort(ab, Comparator.comparingInt(a -> a[1]));

		int ans = 0;
		int r = 0;
		for (int[] target : ab) {
			if (r <= target[0]) {
				r = target[1];
				ans++;
			}
		}

		out.println(ans);

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, String split) {
			String[][] ret = new String[h][];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 92964
N = int(input())
A = tuple(map(int, input().split()))
AI = tuple(i + a for i, a in enumerate(A))
AJ = tuple(i - a for i, a in enumerate(A))

cai = {}
caj = {}
vali = set()
valj = set()
for ai, aj in zip(AI, AJ):
    if not ai in cai:
        cai[ai] = 0
    if not aj in caj:
        caj[aj] = 0

    cai[ai] += 1
    vali.add(ai)

    caj[aj] += 1
    valj.add(aj)

count = 0
for val in vali & valj:
    count += cai[val] * caj[val]

print(count)

Measured memory_bytes: 76232
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;
#define MAX 100
#define Infty (1LL<<32)

int n;
long long A[MAX][MAX];

void floyd(){
    for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
        if(A[i][k]==Infty)continue;
        for(int j=0;j<n;j++){
        if(A[k][j]==Infty)continue;  
        A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
    }
    }
    }
}



int main(){
    int q;
    int s,t,d;
    
    cin>>n>>q;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            A[i][j]=((i==j)?0:Infty);
        }
    }
    
    for(int i=0;i<q;i++){
     cin>>s>>t>>d;
     A[s][t]=d;
    }
    
     floyd();

    bool negative = false;
    for(int i=0;i<n;i++){
        if(A[i][i]<0)negative = true;
    }
    
    if(negative){
        cout<<"NEGATIVE CYCLE"<<endl;
    }
    else {
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(j)cout<<" ";
                if(A[i][j]==Infty)cout<<"INF";
                else cout<<A[i][j];
            }
            cout<<endl;
        }
    }
    return 0;
}
    



Measured memory_bytes: 3200
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var c = new int[n - 1];
        var s = new int[n - 1];
        var f = new int[n - 1];
        for (int i = 0; i < n - 1; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            c[i] = int.Parse(line[0]);
            s[i] = int.Parse(line[1]);
            f[i] = int.Parse(line[2]);
        }
        for (int i = 0; i < n - 1; i++)
        {
            var count = s[i] + c[i];
            for (int j = i + 1; j < n - 1; j++)
            {
                var ns = s[j];
                while (true)
                {
                    if (ns < count) ns += f[j];
                    else { count = ns + c[j]; break; }
                }
            }
            Console.WriteLine(count);
        }
        Console.WriteLine(0);
    }
}


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

public class MainClass
{
	public const long Giri = 1000000007;
	public class Job
	{
		public int Day {get;set;}
		public int Reward {get;set;}
	}
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var m = p[1];
		
		var jobs = new Job[n];
		var dayHeap = new HeapQueue<Job>(n, (u,v)=>v.Day - u.Day);
		var rewHeap = new HeapQueue<Job>(n, (u,v)=>u.Reward - v.Reward);
		for(int i = 0; i < n; i++)
		{
			p = Input().ToInt();
			jobs[i] = new Job(){Day = p[0], Reward=p[1] };
			dayHeap.Push(jobs[i]);
		}
		long wa = 0;
		for(int i = 0; i <= m; i++)
		{
			for(;;)
			{
				if(dayHeap.Count == 0 || dayHeap.Peep().Day > i) break;
				var t = dayHeap.Pop();
				rewHeap.Push(t);
			}
			if(rewHeap.Count > 0)
			{
				var t = rewHeap.Pop();
				wa += t.Reward;
				
			}
		}
		Console.WriteLine(wa);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}

class HeapQueue<T>
{
	private List<T> _buffer;
	private Comparison<T> _comparer;
	
	public HeapQueue()
	{
		_buffer = new List<T>();
	}
	
	public HeapQueue(int capacity, Comparison<T> comparer = null)
	{
		_buffer = new List<T>(capacity);

		_comparer = comparer;
	}
	
	public void Push(T el)
	{
		List<T> array = _buffer;
		int n = array.Count;
		array.Add(el);
		
		while (n != 0)
		{
			int i = (n - 1) / 2;
			if (Compare(array[n], array[i]) > 0)
			{
				T tmp = array[n]; array[n] = array[i]; array[i] = tmp;
			}
			n = i;
		}
	}
	
	public T Pop()
	{
		T el = _buffer[0];
		
		List<T> array = _buffer;
		
		int n = array.Count - 1;
		array[0] = array[n];
		array.RemoveAt(n);

		for (int i = 0, j; (j = 2 * i + 1) < n; )
		{
			if ((j != n - 1) && (Compare(array[j], array[j + 1]) < 0))
				j++;
			if (Compare(array[i], array[j]) < 0)
			{
				T tmp = array[j]; array[j] = array[i]; array[i] = tmp;
			}
			i = j;
		}
		return el;
	}
	
	public T Peep()
	{
		if(_buffer.Count <= 0)
			return default(T);

		return _buffer[0];
	}
	private int Compare(T left, T right)
	{
	/*
		if(_comparer == null)
			return left.CompareTo(right);
			*/
		return _comparer(left, right);
	}
	
	public int Count
	{
		get{ return _buffer.Count; }
	}
	
}


Measured memory_bytes: 23752
#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 int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 3e5 + 10;

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

	int n;
	cin >> n;
	int a[n], sum[60] = {0};
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for(int i = n - 1; i >= 0; i--) {
		for(int j = 0; j < 60; j++) {
			if(a[i] & (1LL << j)) {
				ans = (ans + ((n - 1 - i - sum[j]) % mod) * ((1LL << j) % mod) % mod) % mod;
				sum[j]++;
			}
			else {
				ans = (ans + (sum[j] % mod) * ((1LL << j) % mod) % mod) % mod;
			}
		}
	}
	cout << ans;
	
	return 0;
}

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

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

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

    vector<int> dp(n, 1e9);
    dp[0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j <= i + k; ++j) {
            if (j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
            }
        }
    }

    cout << dp[n - 1] << "\n";
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int query(int x)
{
	if(mp.find(x)!=mp.end())	return mp[x];
	cout<<x<<endl;
	fflush(stdout);
	string s;
	cin>>s;
	if(s=="Vacant")	exit(0);
	return mp[x]=(s=="Male");
}
int main()
{
	int n;
	cin>>n;
	int s=0,e=n-1;
	while(e-s>=2){
		int mid=(s+e)/2;
		if((query(mid)^(mid%2))!=(query(s)^(s%2))){
			e=mid;
		}
		else s=mid;
	}
	for(int i=s;i<=e;i++)query(i);
}

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

typedef long long ll;
typedef pair<int,int> P;

int main(){
	int n,k;	
	cin>>n>>k;	
	vector<ll>x(n);
	ll tmp=0;	
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	ll ans=1145141919;
	for(int i=0,j=i+k-1;j<n;i++,j++){
		ans=min(ans,x[j]-x[i]+min(abs(x[i]),abs(x[j])));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{

    int N, M;
    input(N, M);

    cout << N*(N-1) / 2.0 + M*(M-1)/2.0 << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())
    print((B - 1 + A - 1 - 1) // (A - 1))

    return


if __name__ == '__main__':
    main()


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



int main()
{
    int a,b,c,d,k,i;

    string s;

    cin >> s;

    for(i=0;i<s.size();i++)
    {
        if(s[i] == '?')cout << "D";
        else cout << s[i];
    }

    cout << endl;

}



Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.141592653589793//23846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m,n) for (int i = m;  i < n; i++)

#define local
#ifdef local
#endif

#define MAX 10233
#define LCH(i) ((i) << 1)
#define RCH(i) ((i) << 1 | 1)
inline ll read(){
   ll s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
const int N = 2e5+5;
ll c[N];
struct mon
{
        ll x,h;
};
mon monster[N];
bool cmp(mon a, mon b)
{
    return a.x < b.x;
}
int main()
{
    ll n, d, a;
    n = read();
    d = read();
    a = read();
    for (int i = 0; i < n; i++)
    {
        monster[i].x = read();
        monster[i].h= read();
    }
    sort(monster, monster + n,cmp);
    ll ans = 0;
    for (int i = 0,j = 0; i < n; i++)
    {
        while(j < n && monster[j].x <=monster[i].x + 2*d) // 找到这次炮击能打到的最远的怪兽
            ++j;
        ll need = max((monster[i].h - c[i]*a + a - 1)/a, 0ll); //这个怪兽需要炮击的次数就是怪兽的生命值h减去之前炮击的次数c[i]*a,0ll的意思是longlong 的0；
        ans += need;
        c[i] += need;
        c[j] -= need; //把炮击范围外的第一个怪兽先剪掉need
        c[i+1] += c[i];
    }
    cout << ans << endl;

}

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

using namespace std;
typedef long long ll;
typedef map<ll,int>::iterator miter;
const int N = 100010;
const int MR[20] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71};
int _w;

int isp[N];
void prelude() {
	memset(isp, 1, sizeof isp);
	isp[0] = isp[1] = 0;
	for( int i = 2; i < N; ++i )
		if( isp[i] )
			for( int j = i+i; j < N; j += i )
				isp[j] = 0;
}

int n;
map<ll,int> cnt, prm;

ll gcd( ll a, ll b ) {
	return b ? gcd(b, a%b) : a;
}

ll fpow( __int128 a, ll b, ll mod ) {
	__int128 c = 1;
	while(b) {
		if( b & 1 ) c = c * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return ll(c);
}

bool miller_rabin( ll x ) {
	if( x < N ) return isp[x];
	for( int i = 0; i < 20; ++i ) {
		ll y = MR[i];
		if( fpow(y, x-1, x) != 1 )
			return false;
	}
	return true;
}

int rhocnt = 0;
void pollard_rho( ll x ) {
	if( x <= 100 ) {
		for( int i = 2; i*i <= x; ++i )
			while( x % i == 0 )
				x /= i, ++prm[i];
		if( x != 1 ) ++prm[x];
		return;
	}
	if( miller_rabin(x) ) {
		++prm[x];
		return;
	}
	__int128 a = 0, b = 0;
	while(1) {
		while( a == b ) {
			a = rand() % x;
			b = (a * a + 1) % x;
		}
		ll g = gcd(x, abs(a-b));
		++rhocnt;
		if( g != 1 ) {
			pollard_rho(x/g);
			pollard_rho(g);
			break;
		}
		a = (a * a + 1) % x;
		b = (b * b + 1) % x;
		b = (b * b + 1) % x;
	}
}

int main() {
	ios::sync_with_stdio(false);
	prelude();
	cin >> n;
	for( int i = 1; i <= n; ++i ) {
		ll a;
		cin >> a;
		for( ll i = 2; i*i*i <= a; ++i )
			while( a % (i*i*i) == 0 )
				a /= i*i*i;
		++cnt[a];
	}
	int ans = 0;
	for( miter it = cnt.begin(); it != cnt.end(); ++it ) {
		if( it->first == 1 ) continue;
		prm.clear();
		rhocnt = 0;
		pollard_rho(it->first);
		ll a = 1;
		for( miter mit = prm.begin(); mit != prm.end(); ++mit ) {
			a *= mit->first;
			a *= mit->second == 1 ? mit->first : 1;
		}
		if( cnt.count(a) ) {
			if( a > it->first )
				ans += max( cnt[a], it->second );
		} else {
			ans += it->second;
		}
	}
	if( cnt[1] ) ++ans;
	printf( "%d\n", ans );
	return 0;
}


Measured memory_bytes: 6912
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

dict_count = {}

# 数を数える
for a in A:
  if a in dict_count.keys():
    dict_count[a] += 1
  else:
    dict_count[a] = 1

# 最大値
count_max = 0
for key, value in dict_count.items():
  count_max += value*(value-1)//2

# 答えを出力
for a in A:
  print(count_max-dict_count[a]+1)

Measured memory_bytes: 24996
// Last Change: 04/07/2019 13:19:32.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll A, B, area, road;
  cin >> A >> B;

  area = A * B;
  road = A + B - 1;

  cout << area - road << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

uint64_t n, A[100000], R[100000];
int main(void) {
    int i;
    uint64_t sum = 0, x = 0;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >>A[i];
        sum += A[i];
        if (i%2) x += A[i];
    }
    R[0] = sum - 2*x;
    for (i = 1; i < n; i++) {
        R[i] = 2*A[i-1]-R[i-1];
    }
    for (i = 0; i < n; i++) {
        cout << R[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    map<string, int> mp;
    int N, M;
    cin >> N;
    string S;
    for (int i = 0; i < N; i++) {
        cin >> S;
        mp[S]++;
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        cin >> S;
        mp[S]--;
    }
    int ans = 0;
    for (auto m : mp) { ans = max(m.second, ans); }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 100000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back


int n,a,b;
vector<ll> v;
ll c[110][110];

void comb_table(void){
  for(int i=0;i<=100;i++){
    for(int j=0;j<=i;j++){
      if(j==0||j==i){
        c[i][j] = 1LL;
      }
      else{
        c[i][j]=(c[i-1][j-1]+c[i-1][j]);
      }
    }
  }
}


int main(){
  cin>>n>>a>>b;
  rep(i,n){
    ll w;
    cin>>w;
    v.PB(w);
  }
  sort(all(v));
  reverse(all(v));
  int s=0,t=0;
  rep(i,n){
    if(v[i]==v[a-1]){
      s++;
      if(i<a)
        t++;
    }
  }

  double ave=0;
  rep(i,a){
    ave+=v[i];
  }
  ave/=a;
  comb_table();
  
  printf("%.10lf\n",ave);
  ll sum=0;
  if(t==a){
    FOR(i,a,b+1)
      sum+=c[s][i];
  }
  else
    sum=c[s][t];


  cout<<sum<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++) 
#define per(i , n , x)  for(int i = n ; i >= x ; i --) 
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  printf("%d\n" , x)
#define ddebug(x , y)  printf("%d %d\n" , x , y)
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
const int inf = 0x3f3f3f3f ;
const int maxn = 2e5 + 5 ;
const int maxm = 2e6 + 5 ;
const ll mod = 998244353 ;
int n , a[maxn] ;
map<int , ll> dp[maxn] ;
void solve()
{
	rep(i , 1 , n)  dp[i][1] = a[i] ;
	rep(i , 3 , n)
	{
		rep(j , max(2 , i / 2 - 3) , min(n , i / 2 + 3))
		{
		   ll max1 = -1e18 ; 
		   rep(k , max(1 , i - 5) , i - 2)
		   {
		  	 if(dp[k].count(j - 1) == 0)  continue ;
		  	 max1 = max(max1 , dp[k][j - 1] + a[i]) ;
		   }
		   if(max1 < -1e17)  continue ;
		   dp[i][j] = max1 ; 	
		}  
	}
	ll ans = -1e18 ;
	rep(i , max(1 , n - 10) , n)  
	  if(dp[i].count(n / 2))
        ans = max(ans , dp[i][n / 2]) ;
	wl(ans) , en() ;
}
int main()
{
	r(n) ;
	rep(i , 1 , n)  r(a[i]) ;
	solve() ;
	return 0 ;
}

Measured memory_bytes: 82732
MOD = 2019

L, R = gets.chomp.split.map(&:to_i)

ans = 987654321

if R - L >= MOD || R % MOD <= L % MOD
  puts 0
  exit 0
end

min = L % MOD
max = R % MOD 

min.upto(max) do |i|
  (i + 1).upto(max) do |j|
    ans = [ans, (i * j) % MOD].min
  end
end

puts ans


Measured memory_bytes: 1788
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;

char c[8][10];
const int x[24][6] = {
  {0, 1, 2, 4, 3, 5},
  {0, 2, 4, 3, 1, 5},
  {0, 4, 3, 1, 2, 5},
  {0, 3, 1, 2, 4, 5},
  {1, 0, 3, 5, 2, 4},
  {1, 3, 5, 2, 0, 4},
  {1, 5, 2, 0, 3, 4},
  {1, 2, 0, 3, 5, 4},
  {2, 0, 1, 5, 4, 3},
  {2, 1, 5, 4, 0, 3},
  {2, 5, 4, 0, 1, 3},
  {2, 4, 0, 1, 5, 3},
  {3, 0, 4, 5, 1, 2},
  {3, 4, 5, 1, 0, 2},
  {3, 5, 1, 0, 4, 2},
  {3, 1, 0, 4, 5, 2},
  {4, 0, 2, 5, 3, 1},
  {4, 2, 5, 3, 0, 1},
  {4, 5, 3, 0, 2, 1},
  {4, 3, 0, 2, 5, 1},
  {5, 1, 3, 4, 2, 0},
  {5, 3, 4, 2, 1, 0},
  {5, 4, 2, 1, 3, 0},
  {5, 2, 1, 3, 4, 0}
};
pair<int, int> a[8];
bool used[8];

bool fit(char p, char q) {
  return (isupper(p) && islower(q) && tolower(p) == q) 
    || (islower(p) && isupper(q) && toupper(p) == q);
}

bool dfs(int n) {
  char p, q;
  if (n == 8) return true;
  for (int i=0; i<8; i++) {
    if (used[i]) continue;
    for (int j=0; j<24; j++) {
      if (n & 1) {
        p = c[a[n-1].first][x[a[n-1].second][1]];
        q = c[i][x[j][3]];
        if (!fit(p,q)) continue;
      }
      if (n & 2) {
        p = c[a[n-2].first][x[a[n-2].second][2]];
        q = c[i][x[j][4]];
        if (!fit(p,q)) continue;
      }
      if (n & 4) {
        p = c[a[n-4].first][x[a[n-4].second][0]];
        q = c[i][x[j][5]];
        if (!fit(p,q)) continue;
      }
      used[i] = true;
      a[n].first = i;
      a[n].second = j;
      if (dfs(n+1)) return true;
      used[i] = false;
    }
  }
  return false;
}

int main() {
  while (1) {
    fgets(c[0], sizeof(c[0]), stdin);
    if (c[0][0] == '0') break;
    for (int i=1; i<8; i++) {
      fgets(c[i], sizeof(c[i]), stdin);
    }
    for (int i=0; i<8; i++) {
      used[i] = false;
    }
    if (dfs(0)) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
  return 0;
}

Measured memory_bytes: 928
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0),cin.tie(0);
#define endl '\n'
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ll long long
#define F first
#define S second
#define pb push_back
const int N = 1e6 + 5;
typedef pair<int,int>ii;
int main(){
  fast;
  int a,b;
  while(cin >> a >> b){
    cout << max(a-(2*b),0) << endl;
  }

}

Measured memory_bytes: 256
#include  <iostream>

using namespace std;

int main()
{
	int n, x;
	int L[100], D[101];

	D[0] = 0;
	cin >> n >> x;
	for (int i = 0; i < n; i++)  cin >> L[i];

	int i;
	for (i = 0; i < n; i++) {
		D[i + 1] = D[i] + L[i];
		if (D[i + 1] > x)  break;
	}
	cout << i + 1 << endl;
}

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

ans = []

def base_mi2(x):
    if x == 1:
        ans.insert(0,'1')
        return ans
    else:
        if x % 2 != 0:
            ans.insert(0,'1')
            return base_mi2(x//(-2)+1)
        else:
            ans.insert(0,'0')
            return base_mi2(x//(-2))

if n == 0:
    print('0')
else:
    print(''.join(base_mi2(n)))

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

int main()
{
  string n;
  bool a=false,b=false,c=false,d=false;
  cin>>n;
  for(int i=0;i<n.length();i++){
    if(n[i]=='N')a=true;
    if(n[i]=='E')b=true;
    if(n[i]=='S')c=true;
    if(n[i]=='W')d=true;
  }
  if( (a && c && !b && !d) ||
      (!a && !c && b && d) ||
      (a && b && c && d))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

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

using namespace std;
typedef long long LL;

int main() {
    int n;


    cin>>n;
    LL tot = 0;
    int m = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        tot += max(0, m - x);
        m = max(m, x);
    }

    cout<<tot;
    return 0;
}

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


int main(){
  ll N,ans=0;
  cin >> N;
  vector<ll> money;
  money.push_back(1);
  ll i=1;
  while(pow(6,i)<=N){
    money.push_back(pow(6,i));
    ++i;
  }
  i=1;
  while(pow(9,i)<=N){
    money.push_back(pow(9,i));
    ++i;
  }
  sort(money.begin(),money.end(),greater<ll>());
  ll dp[200000];
  for(ll i=0;i<200000;++i) dp[i] = 1e9;
  dp[0] = 0;
  for(ll i=0;i<money.size();++i){
    for(ll j=0;j<=100000;++j){
      dp[j+money[i]] = min(dp[j]+1,dp[j+money[i]]);
    }
  } 
  cout << dp[N] << endl;
}

Measured memory_bytes: 1792