akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  map<int,int> mn,cnt;
  cnt[0]=0; mn[0]=n;
  rep(i,n) if(cnt[a[i]]++==0) mn[a[i]]=i;
  vector<ll> re(n);
  vector<pii> mnv(all(mn)),cntv(all(cnt));
  //cout<<mnv<<cntv;
  ll sum=0;
  int m=mnv.size(),aa=MOD;
  rrep(i,m-1){
    sum+=cntv[i+1].Y;
    ll d=mnv[i+1].X-mnv[i].X;
    assert(d>0);
    MN(aa,mnv[i+1].Y);
    re[aa]+=sum*d;
  }
  for(ll x:re) cout<<x<<endl;
  return 0;
}


Measured memory_bytes: 14736
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int K;
  cin>>K;
  int A,B;
  cin>>A>>B;
  for(int i=A;i<=B;i++){
    if(i%K==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Maxn=1e5+10;
const ll INF=1e13;
ll dp[(1<<14)],cost[Maxn],item[Maxn];
ll N,M;
bool vis[20];
int main() {
    ios::sync_with_stdio(false);
    cin>>N>>M;
    ll limits=(1<<N)-1;
    for(ll i=1;i<=limits;i++)  dp[i]=INF;
    dp[0]=0;
    for(ll i=1;i<=M;i++){
        ll a,b;
        cin>>a>>b;
        memset(vis,0,sizeof(vis));
        for(ll i=1;i<=b;i++){
            ll c;
            cin>>c;
            vis[c]=1;
        }
        ll temp=0,now=N;
        while(now>0){
            if(vis[now]){
                temp|=1;
            }
            now--;
            temp<<=1;
        }
        temp>>=1;
        cost[i]=a;
        item[i]=temp;
    }
    for(ll i=0;i<=limits;i++){
        for(ll j=1;j<=M;j++){
            ll state=item[j];
            dp[i|state]=min(dp[i|state],cost[j]+dp[i]);
        }
    }
    if(dp[limits]==INF) cout<<"-1";
    else{
        cout<<dp[limits];
    }
    return 0;
}


Measured memory_bytes: 3708
#include <iostream>
 
using namespace std;
 
int main(){
 
  while(1) {
 
  int N;
  cin >> N;
  if(N == 0) break;
 
  int b[100000];
   
  for(int i=0;i<N;i++) {
    cin >> b[i];
  }
 
  int count = 0,flag = 2;
  int t;
 
  while(1) {
    for(int i=1;i<=N;i++) {
      if(b[i-1] != i) break;
 
      if(i == N) flag = 0;
    }
     
    if(flag == 0) break;
 
    count++;
    if(count > 10000) {
      flag = 1;
      break;
    }
    t = N;
    for(int i=0;i<N;i++) b[i]--;
 
    for(int i=0;i<N;i++) {
      if(b[i] == 0) {
    for(int j=i;j<N-1;j++) {
      b[j] = b[j+1];
    }
    N--;
    i--;
      }
    }
    N++;
    b[N-1] = t;
 
    //  for(int i=0;i<N;i++) cout << b[i] <<" ";
    //cout << endl;
 
  }
 
 
  if(flag == 1) cout << "-1"<<endl;
  else cout << count << endl;
 
  }
 
  return 0;
}

Measured memory_bytes: 1176
s = input()

check = 0

for i in range(len(s)) :
  if (i+1)%2 == 0 :
    if s[i] == 'R' :
      check = 1
  else :
    if s[i] == 'L' :
      check = 1

if check == 0 :
  print('Yes')
else :
  print('No')

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
//https://atcoder.jp/contests/abc176/submissions/16116488
const int INF=2.147e9;
int qlen=0;
static inline int Abs(int x){return x<0?-x:x;}
struct nodetag{int y,x,cost;}Q[50000];
static inline void qfix(int idx)
{
  while(1)
  {
    int midx=idx;
    rep(i,2){int cidx=idx*2+i+1;if(cidx<qlen&&Q[midx].cost>Q[cidx].cost){midx=cidx;}}
    if(midx==idx){if(!idx){break;}idx=(idx-1)/2;}
    else{struct nodetag sw=Q[idx];Q[idx]=Q[midx];Q[midx]=sw;idx=midx;}
  }
}
static inline void qpush(int y,int x,int cost)
{
  Q[qlen].y=y;Q[qlen].x=x;Q[qlen].cost=cost;qfix(qlen);qlen++;
}
static inline struct nodetag qpop(void)
{
  if(qlen<=0){exit(EXIT_FAILURE);}
  struct nodetag res=Q[0];qlen--;if(qlen){Q[0]=Q[qlen];qfix(0);}
  return res;
}
const int dx[24]={0,1,0,-1,0,0,1,1,1,1,-1,-1,-1,-1,2,2,2,2,2,-2,-2,-2,-2,-2},
          dy[24]={1,0,-1,0,2,-2,1,2,-1,-2,1,2,-1,-2,0,1,2,-1,-2,0,1,2,-1,-2};
int main(void)
{
  int H=IN(),W=IN(),Ch=IN(),Cw=IN(),Dh=IN(),Dw=IN(),dist[H][W],field[H][W];char str[W+1];
  rep(i,H)
  {
    if(!scanf("%s",str)){return -1;}
    rep(j,W){dist[i][j]=INF;field[i][j]=(str[j]=='#');}
  }
  qpush(Ch-1,Cw-1,0);dist[Ch-1][Cw-1]=0;
  while(qlen)
  {
    struct nodetag pos=qpop();
    rep(i,24)
    {
      if(dist[Ch-1][Cw-1]){break;}
      int ny=pos.y+dy[i],nx=pos.x+dx[i],warp=!(Abs(dx[i])+Abs(dy[i])<=1),need=dist[pos.y][pos.x]+warp;
      if(0<=ny&&ny<H&&0<=nx&&nx<W&&!field[ny][nx]&&need<dist[ny][nx])
      {
        dist[ny][nx]=need;qpush(ny,nx,need);
      }
    }
  }
  return OUT(dist[Dh-1][Dw-1]<INF?dist[Dh-1][Dw-1]:-1),0;
}

Measured memory_bytes: 9516
N = int(input())
A = list(map(int, input().split())) 
B = list(map(int, input().split())) + [0]

curr = min(A[0], B[0])
ans = min(A[0], B[0])

B[0] -= ans
  
for i in range(N):
  #B[i]がA[i+1]を残った力で攻撃
  curr = min(A[i+1], B[i])
  ans += curr
  A[i+1] -= curr
  #B[i+1]がA[i+1]を攻撃
  curr = min(A[i+1], B[i+1])
  ans += curr
  B[i+1] -= curr
print(ans)

Measured memory_bytes: 18476
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
sortsecond = lambda val : val[1]
for i in range(n):
    b[i] = [i,a[i]]
b.sort(key=sortsecond)
for i in range(n):
    print(b[i][0]+1)

Measured memory_bytes: 22272
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]
ans = float("INF")
for a in range(2**n):
    d0 = [(a >> b) & 1 for b in range(n)]
    for c in range(2**n):
        d1 = [(c >> d) & 1 for d in range(n)]
        abc = [0] * 3
        ans_ = 0
        for i in range(n):
            if d0[i] == 1 and d1[i] == 1:
                if abc[0]: ans_ += 10
                abc[0] += l[i]
            elif d0[i] == 0 and d1[i] == 1:
                if abc[1]: ans_ += 10
                abc[1] += l[i]
            elif d0[i] == 1 and d1[i] == 0:
                if abc[2]: ans_ += 10
                abc[2] += l[i]
        if abc[0] == 0 or abc[1] == 0 or abc[2] == 0: continue
        ans_ += abs(abc[0]-A)+abs(abc[1]-B)+abs(abc[2]-C)
        ans = min(ans, ans_)
print(ans)

Measured memory_bytes: 50652
local n, m = io.read("*n", "*n")
local a = {}
local sum = 0
for i = 1, n do
  a[i] = io.read("*n")
  sum = sum + a[i]
end
table.sort(a, function(x, y) return x > y end)
print(a[m] * 4 * m < sum and "No" or "Yes")


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<vector<P>> g;

int main() {


    
    ll h, w;
    cin >> h >> w;
    
    vector<string> s(h);
    
    for (int i = 0; i < h; ++i)
    {
        cin >> s[i];
    }
    priority_queue<pair<P, P>, vector<pair<P, P>>, greater<>> q;
    
    pair<P, P> start = make_pair(P(0, 0), P(0, 0));
    set<P> used;
    
    if (s[0][0] == '#')
    {
        start.first = P(1, 1);
    }
    q.push(start);
    while (q.size() > 0)
    {
        pair<P, P> now = q.top();
        P states = now.first;
        q.pop();
        if (used.count(now.second) != 0)
        {
            continue;
        }
        used.insert(now.second);
        if (now.second.first == h - 1 && now.second.second == w - 1)
        {
            cout << states.first << endl;
            break;
        }
        if (used.count(P(now.second.first + 1, now.second.second)) == 0 && now.second.first + 1 < h)
        {
            P nextstates = states;
            if (s[now.second.first + 1][now.second.second] == '#')
            {
                if (states.second == 0)
                {
                    nextstates.first++;
                }
                nextstates.second = 1;
            }
            else
            {
                nextstates.second = 0;
            }
            q.push(make_pair(nextstates, P(now.second.first + 1, now.second.second)));
        }
        if (used.count(P(now.second.first, now.second.second + 1)) == 0 && now.second.second + 1 < w)
        {
            P nextstates = states;
            if (s[now.second.first][now.second.second + 1] == '#')
            {
                if (states.second == 0)
                {
                    nextstates.first++;
                }
                nextstates.second = 1;
                
            }
            else
            {
                nextstates.second = 0;
            }
            q.push(make_pair(nextstates, P(now.second.first, now.second.second + 1)));
        }
    }
    
    return 0;
}

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

int main() {
  
  int n;
  map<string, int> s;
  map<string, int>::iterator itr;
  string tmp;
  int current_max=-1;
  priority_queue<string, vector<string>, greater<string>> ans;
  cin >> n;

  rep(i, n) {
    cin >> tmp;
    itr = s.find(tmp);
    if(itr != s.end()) {
      s[tmp]++;
    } else {
      s[tmp]=1;
    }
    current_max = max(s[tmp],current_max);
  }

  for(map<string,int>::iterator i = s.begin();i!=s.end();i++) {
    if ( i->second == current_max) ans.push(i->first);
  }

  while(!ans.empty()){
    cout << ans.top() << endl;
    ans.pop();
  }
  
  return 0;
}

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

using namespace std;

int n, h, max_a, b[100000];
long long ans;

int main(){
    int x;
    cin >> n >> h;
    for(int i = 0; i < n; ++i){
        cin >> x >> b[i];
        max_a = max(max_a, x);
    }
    sort(b, b + n);
    reverse(b, b + n);

    for(int i = 0; i < n; ++i){
        if(max_a < b[i]){
            h -= b[i];
            ans++;
            if(h <= 0) break;
        }
    }

    if(h > 0) ans += ceil(1.0 * h / max_a);

    cout << ans << endl;
}

Measured memory_bytes: 640
a = int(input())
building = [[[0 for zero in range(10)] for floor in range(3)] for room in range(4)]


for i in range(a):
    b, f, r, v = map(int,input().split())
    building[b-1][f-1][r-1] += v

for j in range(4):
    for k in range(4):
        if k == 3:
            if j != 3:
                print('####################')
            else:
                break
        else:
            print(' ' + ' '.join([str(building[j][k][n]) for n in range(10)]))


Measured memory_bytes: 5608
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner scan = new Scanner(System.in);
		int a[] = new int[5];

		for(int i=0; i<5; i++)
		{
			a[i]=scan.nextInt();
		}
		Arrays.sort(a);

		for(int i=0; i<5; i++)
		{
			System.out.print(a[5-i-1]);
			if(i!=4)
				System.out.print(" ");
		}
		System.out.println();
	}

}

Measured memory_bytes: 12000
#include <stdio.h>
#include <ctype.h>
int main() {
    char v1[16],v2[16],v3[16];
    scanf("%s %s %s",v1,v2,v3);
    printf("%c%c%c\n",toupper(v1[0]),toupper(v2[0]),toupper(v3[0]));
	return 0;
}

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

void addEdge(vector<int> graph[], int src,int dest)
{
	graph[src].push_back(dest);
}

void DFS(int node, vector<int> graph[], bool visited[], int dp[])
{
	visited[node] = true;
	
	for(int i=0;i<graph[node].size();i++)
	{
		if(!visited[graph[node][i]])
			DFS(graph[node][i], graph,visited,dp);
		
		dp[node] = max(dp[node], 1+dp[graph[node][i]] );
	}
  	return ;
}

void solve(vector<int> graph[], int n)
{
	int dp[n+1];
	memset(dp,0,sizeof(dp));
	
	bool visited[n+1];
	memset(visited, false, sizeof(visited));
	
	for(int i=1;i<=n;i++)
	{
		if(!visited[i])
		{
			DFS(i,graph,visited,dp);
		}
	}
	
	int max = INT_MIN;
	for(int i=1;i<=n;i++)
	{
		if(dp[i]>max)
			max = dp[i];
	}
	
	cout<<max;
}

int main()
{
	int n, m;
	cin>>n>>m;
	vector<vector<int> > v;
	vector<int> graph[n+1];
	
	for(int i=0;i<m;i++)
	{
		vector<int> temp;
		int src, dest;
		cin>>src>>dest;
		temp.push_back(src);
		temp.push_back(dest);
		addEdge(graph,src,dest);
		v.push_back(temp);
		
    }
	
	solve(graph,n);
	return 0;
}

Measured memory_bytes: 18104
n = gets.to_i
nums = gets.split.map(&:to_i)

cumulative_sums = []
previous = 0
nums.each do |num|
  cumulative_sums << num + previous
  previous += num
end

cumulative_sums_r = []
previous = 0
nums.reverse.each do |num|
  cumulative_sums_r.unshift(num + previous)
  previous += num
end

gaps = []
(1...n).each do |index|
  gaps << (cumulative_sums[index - 1] - cumulative_sums_r[index]).abs
end

puts gaps.min


Measured memory_bytes: 22224
// Problem : B - ROT N
// Contest : AtCoder Beginner Contest 146
// URL : https://atcoder.jp/contests/abc146/tasks/abc146_b
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

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

  cout.precision(16);
  cout << fixed;
  
  int n;
  string s;
  cin >> n >> s;
  
  n %= 26;
  
  for (auto&& i : s) {
    int shifted = i + n;
    
    if (shifted > 'Z') {
      shifted = 'A' + (shifted - ('Z' + 1));
    }
      
    i = shifted;
  }
  
  cout << s;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,l;

signed main() {
    cin >> n >> l;l--;
    int sum=0,memo=INF;
    rep1(i,n) {
        sum += i+l;
        if (abs(memo) > abs(i+l)) memo = i+l;
    }
    cout << sum - memo << endl;
}






Measured memory_bytes: 256
import heapq as hq
from collections import deque
N = int(input())
edges = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    edges[a].append((b,1))
    edges[b].append((a,1))
INF = float("inf")
d = [INF]*N
d[0] = 0
prev = [None]*N
q = [(0,0)]
while q:
    dist, i = hq.heappop(q)
    if d[i] < dist:
        continue
    for j, w in edges[i]:
        if d[j] > d[i]+w:
            d[j] = d[i]+w
            prev[j] = i
            hq.heappush(q, (d[j], j))
path = deque()
i = N-1
while prev[i] != 0:
    path.append(prev[i])
    i = prev[i]
fncq = deque([0])
snkq = deque([N-1])
fnc = 1
snk = 1
visited = [False]*N
visited[0] = True
visited[N-1] = True
while path:
    v = path.pop()
    fncq.append(v)
    visited[v] = True
    fnc += 1
    if path:
        v = path.popleft()
        snkq.append(v)
        visited[v] = True
        snk += 1
po = [fncq, snkq]
while fncq or snkq:
    for i in range(2):
        q = po[i]
        if q:
            v = q.popleft()
            for w,_ in edges[v]:
                if not visited[w]:
                    visited[w] = True
                    q.append(w)
                    if i == 0:
                        fnc += 1
                    else:
                        snk += 1
print("Fennec" if fnc > snk else "Snuke")

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

int main(){
  int N;
  cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int ans=0;
  for(int i=0;i<N;i++)ans+=v[i]-1;
  cout<<ans<<endl;
  return 0;
}


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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

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

    string ans = "No";
    if (N % 2 == 1) {
        cout << ans << endl;
        return 0;
    }

    int k = N / 2;

    string first;
    string second;

    for (int i = 0; i < N; ++i) {
        if (i < k) {
            first += str[i];
        } else {
            second += str[i];
        }
    }

    if (first == second) {
        ans = "Yes";
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int n; cin >> n;
  vector<int> A(n);
  loop(i,1,n+1) {
    int a;
    cin >> a;
    a--;
    A[a] = i;
  }
  loop(i,0,n) {
    if (i!=0) cout << " ";
    cout << A[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3772
import java.util.*;

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

        if ( x > y ){
            int temp = x;
            x = y;
            y = temp;
        }
        if (x > z){
            int temp = x;
            x = z;
            z = temp;
        }
        if ( y > z){
            int temp = y;
            y = z;
            z = temp;
        }
        System.out.println(x + " " + y + " " + z);
    }


}


Measured memory_bytes: 26320
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            int a = cin.ReadInt;
            int b = cin.ReadInt;

            int ans1 = Math.Min(a, b);
            int ans2 = Math.Max(0, (a + b) - n);

            Console.WriteLine(ans1 + " " + ans2);
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

string c = "ACGT";

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    int ans = 0;
    int i = 0;
    for(int i=0;i<s.size();i++){
        int cnt = 0;
        while(i < s.size() && (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') ){
            i++;
            cnt ++ ;
        }
        chmax(ans,cnt);
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
  int64_t N;
  cin >> N;
  
  vector<int64_t> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  vector<int> r(N);
  int64_t result = 0;
  for (int64_t i = 0; i < N; ++i) {
    if (0 <= i - A[i]) {
      result += r[i - A[i]];
    }
    if (i + A[i] < N) {
      ++(r[i + A[i]]);
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 5628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;


int main(){
    int n,m,p;
    cin>>p>>n>>m;
    if((m-n)%2==1)cout<<"Borys"<<endl;
    else cout<<"Alice"<<endl;

    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long int;
using namespace std;

int main() {
    fastio;
    int a, b;
    cin >> a >> b;
    if (a <= b)
        cout << a << endl;
    else
        cout << a - 1 << endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<=b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define ll long long
#define name "frog1"
#define maxn 100005

using namespace std;

int n,h[maxn],a[maxn];

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

    cin>>n;
    f(i,1,n)
    {
        cin>>h[i];
        a[i]=1000000009;
        fd(j,i-1,max(i-2,1))
        {
            a[i]=min(a[i],a[j]+abs(h[i]-h[j]));
        }
        if(i==1)
        {
            a[i]=0;
        }
    }
    cout<<a[n];


}


Measured memory_bytes: 4320
n = input()
m = input()
l = [i for i in range(1,2*n+1)]
for i in xrange(m):
    k = input()
    nl = [None]*2*n
    if k==0:
        for j in xrange(n): nl[2*j] = l[j]
        for j in xrange(n,2*n): nl[2*(j-n)+1] = l[j]
    else:
        for j in xrange(k): nl[j+2*n-k] = l[j]
        for j in xrange(k,2*n): nl[j-k] = l[j]
    l = nl
for i in xrange(2*n):
    print l[i]

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

using namespace std;

typedef long long ll;
const ll INF = 4*1e18+1;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N, K;
  cin >> N >> K;

  vector<pair<ll, ll>> xy(N);
  ll x, y;
  for(int i = 0; i < N; i++){
    cin >> x >> y;
    xy[i] = make_pair(x, y);
  }

  sort(xy.begin(), xy.end());
  ll ans = INF;

  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){
      ll width = abs(xy[i].first - xy[j].first);
      vector<ll> y_vec;
      for(int k = i; k <= j; k++){
        y_vec.push_back(xy[k].second);
      }

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

      ll tmp_height = 2*1e9+1;

      if(y_vec.size() < K){

      }else{
        for(int k = 0; k + K - 1< y_vec.size(); k++){
          chmin(tmp_height, y_vec[k+K-1] - y_vec[k]);
        }

        chmin(ans, max(1LL, tmp_height) * max(1LL, width));
      }
    }
  }
  
  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.Math.*;

class Main{

    static long[][] dp = new long[101][100001];

    public static void main(String[] args){
    
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();

        int w = sc.nextInt();
        int v = sc.nextInt();
    
        for(int j = 0; j <= W; j++){
            if(w <= j) dp[1][j] = v;
            else dp[1][j] = 0;
        }        

        for(int i = 2; i <= N; i++){
            w = sc.nextInt();
            v = sc.nextInt();
            for(int j = 0; j <= W; j++){
                //slucaj da ne uzememo i-ti po redu
                dp[i][j] = dp[i-1][j];
                //ako zelimo uzeti i-ti po redu                
                if(w <= j && dp[i][j] < (dp[i-1][j-w] + v) )
                    dp[i][j] = v+ dp[i-1][j-w]; 
            }    
        }            

        System.out.println( dp[N][W] );    
    }
}


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

N = INT()
p = LIST()

ans = 0
flg = False

for i in range(N):
	if flg:
		flg = False
	elif p[i] == i+1:
		ans += 1
		flg = True

print(ans)




Measured memory_bytes: 15956
#include <iostream>
#include <algorithm>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll minFunc(vector<ll> vec){
    ll min = vec[0];
    for(ll i = 0;i < vec.size(); i++){
        if(min > vec[i]){
            min = vec[i];
        }
    }
    return min;
}

ll maxFunc(vector<ll> vec){
    ll max = vec[0];
    for(ll i = 0;i < vec.size(); i++){
        if(max < vec[i]){
            max = vec[i];
        }
    }
    return max;
}

ll sumFunc(vector<ll> vec){
    ll sum = 0;
    for(ll i = 0;i < vec.size(); i++){
        sum += vec[i];
    }
    return sum;
}


int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    for (ll i = 0; i < N; ++i) cin >> a[i];

    // IOJ環境だとコンパイルエラーになる
    // ll max = *max_element(begin(a), end(a));
    // ll min = *min_element(begin(a), end(a));
    // ll sum = accumulate(begin(a), end(a), 0);

    ll max = maxFunc(a);
    ll min = minFunc(a);
    ll sum = sumFunc(a);

    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3268
n, m = list(map(int, input().split()))
r, l = 10 ** 5 + 1, 0
for i in range(m):
    li, ri = list(map(int, input().split()))
    if li > l:
        l = li
    if ri < r:
        r = ri

print(r - l + 1 if r >= l else 0)


Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a;
    cin >> a;
    if(a < 1200){
        cout << "ABC";
    }
    else if(a < 2800){
        cout << "ARC";
    }
    else
    {
        cout << "AGC";
    }
    
    cout << endl;
}


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

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

int main() {
  int N;
  std::cin >> N;
  std::vector<int> h(N);
  for (int i = 0; i < N; ++i)
    std::cin >> h[i];

  const int iinf = 1000000007;
  std::vector<int> dp(N + 7, iinf);
  // dp[i] = 足場 i に辿り着くまでの最小コスト

  dp[0] = 0;
  for (int i = 0; i < N; ++i) {
    chmin(dp[i + 1], dp[i] + std::abs(h[i + 1] - h[i]));
    chmin(dp[i + 2], dp[i] + std::abs(h[i + 2] - h[i]));
  }

  std::cout << dp[N - 1] << std::endl;
}


Measured memory_bytes: 1024
//	??´?§?????§???¢ 
#include<iostream>
using namespace std;

int main() {
	int a,b,c,n;
	cin >> n;
	for ( int i=0; i < n; i++ ){
		bool flag = false;
		cin >> a >> b >> c;
		if (a + b > c && a + c > b && b + c > a){
			if ( ((a*a + b*b) == c*c) ||  ((a*a + c*c) == b*b) || ((b*b + c*c) == a*a) ){
				flag = true;
			}
		}
		if (flag) {
			cout << "YES" << endl;
		}else {
			cout << "NO" << endl;
		}
	}
}

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

typedef long long ll;

using namespace std;

ll MAX = 1e9+1;
int MOD = 1e9+7;

void solve() {
    int h, w;
    cin >> h >> w;

    vector<int> dp(w+1);
    dp[0] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char x;
            cin >> x;
            if (x == '.') {
                dp[j] = (dp[j] + (j == 0 ? 0 : dp[j-1])) % MOD;  
            } else {
                dp[j] = 0;
            }
        }
    }

    cout << dp[w-1] % MOD << endl;
}


int main() {
    solve();
	return 0;
}



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

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

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

Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////



int main() {

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

	cout << A + B + C + 9 * max({ A,B,C });
	
	

	system("PAUSE");
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
using namespace std;

int main()
{
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1];
    return 0;
}

Measured memory_bytes: 256
def main():
    N, X, M = [int(s) for s in input().split()]

    sums = [0]
    s = 0
    seen = {}
    for i in range(N):
        if X in seen:
            previ = seen[X]
            # repeats from previ, ... i-1
            seq_length = i - previ
            remaining_full = (N - i) // seq_length
            remaining_part = (N - i) - remaining_full * seq_length
            s += (sums[-1] - sums[-seq_length-1]) * remaining_full
            s += sums[remaining_part-seq_length-1] - sums[-seq_length-1]
            print(s)
            return
        s += X
        sums.append(s)
        seen[X] = i

        X = X * X % M

    print(s)

main()



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

using namespace std;

int main(){
    int x;
    cin >> x;
    if(x<600){
        cout << 8 << endl;
    }else if(x<800){
        cout << 7 << endl;
    }else if(x<1000){
        cout << 6 << endl;
    }else if(x < 1200){
        cout << 5 << endl;
    }else if(x<1400){
        cout << 4 << endl;
    }else if(x<1600){
        cout << 3 << endl;
    }else if(x<1800){
        cout << 2 << endl;
    }else{
        cout << 1 << endl;
    }
}

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

## コンビネーション計算用 ========
## https://qiita.com/derodero24/items/91b6468e66923a87f39f
mod = int(1e9+7)
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル

for i in range( 2, N*M ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def combination(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
## コンビネーション計算用 --------
  

## 二つの駒の距離の総和 = cost_allpairs
var_1 = M**2 * (N-1) * N * (N+1) // 3
var_2 = N**2 * (M-1) * M * (M+1) // 3
cost_allpairs = int((var_1 + var_2) // 2)
cost_allpairs = cost_allpairs % mod ## ここでmod取っておく

## コンビネーションの計算
cmb = combination(N*M-2, K-2, mod)

## 答え
ans = (cost_allpairs * cmb) % mod
print(int(ans))

Measured memory_bytes: 26864
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

from collections import Counter
c = Counter(A)

if N % 2 == 0:
    for i in range(1, N, 2):
        if c[i] != 2:
            break
    else:
        print(2**(N // 2) % mod)
        exit()
    print(0)
else:
    for i in range(0, N, 2):
        if i == 0:
            if c[i] != 1:
                break
        else:
            if c[i] != 2:
                break
    else:
        print(2**(N // 2) % mod)
        exit()
    print(0)


Measured memory_bytes: 55404
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<array>

using namespace std;
int main(){
    int t;
    cin >>t;
    set<string>arr;
    for(int i=0;i<t;i++){
        string x;
        cin>>x;
        arr.insert(x);
    }
    cout<<arr.size()<<endl;

}

Measured memory_bytes: 19228
N = int(input())
dic = {}
for i in range(N):
    sp = input().split()
    s = sp[0]
    p = int(sp[1])
    if s in dic:
        dic[s].append([p,i])
    else:
        dic[s] = [[p,i]]
for key in sorted(dic):
  for j in sorted(dic[key], reverse = True):
    print(j[1]+1)

Measured memory_bytes: 3064
A,B,C,X,Y=map(int,input().split())

if(A+B<=C*2):
    ans=A*X+B*Y
    print(ans)
    exit()

else:
    if(X==Y):
        ans=2*X*C
        print(ans)
        exit()
    elif(X<Y):
        sa=Y-X
        ans=min(sa*B,sa*C*2)
        ans=ans+C*X*2
        print(ans)
        exit()
    elif(Y<X):
        sa=X-Y
        ans=min(sa*A,sa*C*2)
        ans=ans+C*Y*2
        print(ans)
        exit()


Measured memory_bytes: 61804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    vei cnt(13,0);
    cnt[0]++;
    rep(i,N) {
        int d; cin >> d;
        cnt[d]++;
    }
    rep(i,13) if(cnt[i] > 2) { cout << 0 << endl; return 0; }

    int ans = 0;


    for (int bit = 0; bit < (1<<13); ++bit) {
        vector<int> S;
        for (int i = 0; i < 13; ++i) {
            if(!cnt[i]) continue;
            else if(cnt[i] == 1) {
                if (bit & (1<<i)) S.pub(i);
                else S.pub(24 - i);
            }
            else {
                S.pub(i);
                S.pub(24 - i);
            }
        }

        int temp = 24;
        for (int i = 0; i < S.size(); i++) {
            for(int j = i+1; j < S.size(); j++) {
                int x = abs(S[i] - S[j]);
                temp = min(temp, min(24 - x, x));
            }
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
    return 0;
    
}

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

int main()
{
  int n;
  int node,k,vi;
  int graph[100][100];

  cin >> n;
  memset(graph,0,sizeof(graph));
  
  for(int i=0;i < n;i++){
    cin >> node >> k;
    for(int j=0;j < k;j++){
      cin >> vi;
      graph[node-1][--vi] = 1;
    }
  }
  for(int i=0;i < n;i++){
    for(int j=0;j < n;j++){
      if(j) cout << " ";
      if(graph[i][j]) cout << 1;
      else cout << 0;
    }
    cout << endl;
  }
  return 0;
}



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

using namespace std;

int main(void) {
	int N,L;
	cin >> N >> L;
	int ind = 0;
	int sum = 0;
	int ma = (1 << 28);
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		sum += L+i;
		if (abs(L+i) < ma) {
			ma = abs(L+i);
			ind = i;
		}
	}
	cout << sum-(L+ind) << endl;
	return 0;
}



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

long fac(long x) {
  long y = 1, mod = 1e9+7;
  while (x > 0) y = y * x % mod, x--;
  return y;
}

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> V(N);
  for (int i = 0, x, y; cin >> x >> y; i++) V.at(i) = {x, y};

  vector<int> P(N);
  for (int i = 0; i < N; i++) P.at(i) = i;

  long double sum = 0;
  do {
    for (int i = 0; i + 1 < N; i++) sum += hypot(V.at(P.at(i)).first - V.at(P.at(i + 1)).first, V.at(P.at(i)).second - V.at(P.at(i + 1)).second);
  } while (next_permutation(P.begin(), P.end()));

  cout << fixed << setprecision(6) << sum / fac(N) << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int K;
    cin >> K;
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[K-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion


LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 



/*****************************************************************************/

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

	int n, k;
	cin >> n >> k;
	vi x(n);
	f_vI(x, n);
	int ans = ll_INF;
	f(i, 0, n - k + 1) {
		int x_l = x[i], x_r = x[i+k - 1];
		ans = min(ans, min(abs(x_l) + abs(x_r - x_l), abs(x_r) + abs(x_l - x_r)));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
A, B = map(int, input().split())
cou = 0
while A != (B + 1):
    Astr = str(A)
    if int(Astr[0]) == int(Astr[4]) and int(Astr[1]) == int(Astr[3]):
        cou = cou + 1
    A = A + 1
print(cou)

Measured memory_bytes: 3060
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS = 1e-12;
const double INF = 1e12;


int main(){
	int N,M;
	while(cin>>N>>M){
		int d[501][501];
		REP(i,501)REP(j,501)d[i][j]=1000000;
		if(N==0&&M==0)break;
		REP(i,M){
			int a,b;
			cin>>a>>b;
			a--;b--;
			d[a][b]=1;d[b][a]=1;
		}
		REP(k,N){
			REP(i,N){
				REP(j,N)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
		int res=0;
		FOR(i,1,N)if(d[0][i]<=2)res++;
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 2140
import java.util.Scanner;

public class Main {

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

		String priv = sc.next();

		if ( priv.equals("ABC")){
			System.out.println("ARC");
		} else {
			System.out.println("ABC");
		}

	}

}


Measured memory_bytes: 35432