akhauriyash/Code-Regression huggingface dataset:
using System;
class ProgramD
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] a = Console.ReadLine().Split(' ');
            long n = long.Parse(a[0]);
            long x = long.Parse(a[1]);
            long y = long.Parse(a[2]);
            long[] ans = new long[n];

            for(long i = 1;i <= n;i++)
                for(long j = i+1;j <= n;j++)
                {
                    if(j <= x)
                    {
                        ans[j - i]++;
                        continue;
                    }

                    if(y <= i)
                    {
                        ans[j - i]++;
                        continue;
                    }

                    
                    ans[Math.Min(j - i, Math.Abs(y - j)+ Math.Abs(x - i) + 1)]++;

                }

            for(long i = 1;i <= n - 1;i++)
                Console.WriteLine(ans[i]);

            
        }
 
 
    }

Measured memory_bytes: 11196
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
int a,b;
int main()
{
    cin>>a>>b;
	cout<<((a-2*b>0)?(a-2*b):0)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define ll long long
    #define pb push_back
    #define mod 1000000007
    using namespace std;
    ll power(ll x,ll y)
    {
        ll res=1;
        while(y>0)
        {
            if(y%2==1)
                res=(res*x);
            x=(x*x);
            y=y/2;
        }
        return res;
    }
    int main()
    {
        ll n,W;
        cin>>n>>W;
        ll val[n+1],wt[n+1],knap[n+1][W+1];
        for(ll i=0;i<n;i++)
            cin>>wt[i]>>val[i];
    //         W=8
    //         val{2,3,1,4}//see video abdul bari
    //         wt{3,4,6,5}
    //         0 1 2 3 4 5 6 7 8 i--->
    // vi wi 0 0 0 0 0 0 0 0 0 0 j---v (downwards)
    //  2  3 1 0 
    //  3  4 2 0
    //  1  6 3 0
    //  4  5 4 0
        for(ll i=0;i<=n;i++)
        {
            for(ll j=0;j<=W;j++)
            {
                if(i==0||j==0)
                    knap[i][j]=0;
                else if(j-wt[i-1]>=0)
                    knap[i][j]=max(knap[i-1][j],knap[i-1][j-wt[i-1]]+val[i-1]);
                else
                    knap[i][j]=knap[i-1][j];
            }
        }
        cout<<knap[n][W];
    }

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

using ll = long long;

ll f(ll b, ll n)
{
    if (n < b) return n;
    else return f(b, n/b) + n % b;
}

ll solve(ll n, ll s)
{
    if (s > n) return -1;
    if (s == n) return n+1;

    auto result = numeric_limits<ll>::max();

    auto consider = [&](ll base)
    {
        if (f(base, n) == s) result = min(result, base);
    };

    for (auto base = 2LL; base*base <= n; base++)
        consider(base);

    for (auto d = 1LL; d*d <= n-s; d++) if ((n-s) % d == 0)
    {
        consider(d+1);
        consider((n-s)/d + 1);
    }

    return result == numeric_limits<ll>::max() ? -1 : result;
}

int main()
{
    ll n; cin >> n;
    ll s; cin >> s;
    cout << solve(n, s) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B && B == C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

int main() {
    int n; cin >> n;
    int a, b; cin >> a >> b;
    int cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for (int i=0; i<n; ++i) {
        int p; cin >> p;
        if (p <= a) cnt1++;
        else if (p >= b+1) cnt3++;
        else cnt2++;
    }
    cout << min({cnt1, cnt2, cnt3}) << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		Orique oq = new Orique();
		for (int i = 0; i < n; i++) {
			oq.inque(sc.next(), sc.nextInt());
		}
		oq.RoundRobinScheduling(q);
	}
}

class Orique {
	private class kakunou {
		String kstr;
		int kint;
		int kprenum;

		void setkakunou(String s, int i, int pre) {
			kstr = s;
			kint = i;
			kprenum = pre;
		}
	}

	private int length = 0;
	ArrayList<String> str = new ArrayList<String>();
	ArrayList<Integer> in = new ArrayList<Integer>();
	kakunou k;
	private ArrayList<Integer> prenumber = new ArrayList<Integer>();

	Orique() {
		k = new kakunou();
	}

	public void inque(String t, int i) {
		str.add(t);
		in.add(i);
		prenumber.add(i);
		length++;
	}

	private void inque(kakunou k) {
		str.add(k.kstr);
		in.add(k.kint);
		prenumber.add(k.kprenum);
		length++;
	}

	private void deque() {
		k.setkakunou(str.get(0), in.get(0), prenumber.get(0));
		str.remove(0);
		in.remove(0);
		prenumber.remove(0);
		length--;

	}
    public void RoundRobinScheduling(int q) {
		
		int total=0;
		deque();
		while(true){
			int t1=k.kint-q;
			if(t1>0){
				total=total+q;
				k.kint=t1;
				inque(k);
				
			}else{
				total=total+k.kint;
				System.out.println(k.kstr+" "+total);
				}
			if(length>0)deque();
			else break;
		}
		}
}

Measured memory_bytes: 64740
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  reverse(all(a));
  ll ans = 0;
  for(int i = 2; i < n; i += 2) ans += a[i / 2 - 1];
  for(int i = 1; i < n - 1; i += 2) ans += a[i / 2 + 1];
  if(!(n & 1)) ans += a[n / 2 - 1];
  cout << ans << endl;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  int n, x;
  cin >> n >> x;
  int ans = 1;
  int coo = 0;
  rep(i, n) {
    int l;
    cin >> l;
    coo += l;
    if (coo > x) break;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

n, m = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
a = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( n ) ]
b = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( m ) ]

for i in range( n ):
	c = 0
	for j in range( m ):
		c += ( a[i][j] * b[j][0] )
	print( c )

Measured memory_bytes: 7024
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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 () {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  string ans;
  auto f = [&](int n, char c) {
    rep(_,n) ans += c;
  };

  f(ty-sy, 'U');
  f(tx-sx, 'R');
  f(ty-sy, 'D');
  f(tx-sx, 'L');

  f(1, 'L');
  f(ty-sy+1, 'U');
  f(tx-sx+1, 'R');
  f(1, 'D');
  f(1, 'R');
  f(ty-sy+1, 'D');
  f(tx-sx+1, 'L');
  f(1, 'U');
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int score = sc.nextInt();
    
    if(score<1200){
      System.out.println("ABC");
    }else if(score<2800){
      System.out.println("ARC");
    }else
      System.out.println("AGC");
  }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <string>

std::string s;
int a[30];
bool f;

int main(){
	std::cin >> s;
	for(int i=0; i<s.size(); ++i)
		++a[s[i]-'a'];
	for(int i=0; i<26; ++i)
		if(a[i] > 1)
			f = true;
	if(f) std::cout << "no" << std::endl;
	else std::cout << "yes" << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstring>
#include<cstdio>
#define MAX 1000000
using namespace std;
class Queue {
	int Time1[MAX], Time2[MAX], ansTime[MAX], namenum[MAX], ansname[MAX];
	int head, tail,a;
	int x1, num;
	
public:
	
	void initialize() {

		head = tail =  0;
		a = 0;

	}

	bool isEmpty() {

		return head == tail;

	}

	void enqueue(int x, int i) {
		Time1[tail] = x;
		namenum[tail] = i;
		tail = (tail+1)%MAX;

	}
	void dequeue() {
	
		if (head + 1 == MAX) head = 0;
		else head++;

	}
	void process(int x) {
		int q = 0;
		while(!isEmpty()) {
			
			x1 = Time1[head];
			q += min(x,x1);
			x1 -= x; 
			num = namenum[head];
			
			if (x1 <= 0) {
			    dequeue();
			    ansTime[a] = q;
				ansname[a] = num;
				a++;
			}
			else {
			    dequeue();
				enqueue(x1, num);
			}
		}
	}

	void returnans(int n){
		for(int i = 0; i < n; i++){
			cout << ansTime[i] << " " << ansname[i] << endl;
		}
	}


	int ansT(int i){
	    return ansTime[i];
	}
	int ansN(int i){
	    return ansname[i];
	}
	int min(int x, int y){
		if(x>y) return y;
		else return x;
	}

};

int main() {
    int n,q,x;
	Queue Q;
	char ch[MAX][10];
	char c;
	Q.initialize();
	cin >> n >> q;
	for(int i = 0; i < n; i++){
	    scanf("%s %d",ch[i],&x);
	    Q.enqueue(x,i);
	}
	Q.process(q);
	for(int i = 0; i < n; i ++){
		printf("%s %d\n",ch[Q.ansN(i)],Q.ansT(i));
	}
	return 0;
}



Measured memory_bytes: 5480
n,m=map(int,input().split(" "))
g=[]
t=[]
sac=0
op=0
for i in range(n):
  g.append("0")
  t.append("")
for j in range(m):
  s,c=map(int,input().split(" "))
  if(g[s-1]!=str(c) and t[s-1]==""):
    g[s-1]=str(c)
    t[s-1]="T"
  if(g[s-1]!=str(c) and t[s-1]!=""):
    sac=1
  if(s==1 and c==0):
    sac=1
    op=1
if(t[0]=="" and len(g)!=1 and sac==0):
  g[0]="1"
if(op==1):
  sac=0
str_g = "".join(g)

if(sac==0 and g[0]!="0"):
  print(str_g)

elif(sac==0 and len(g)==1):
  print("0")
else:
  print("-1")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define mod 1000000007
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> pi;

int n,sum;
string s;

int main() {
	cin >> s;
	n = s.length();
	for( int i = 0 ; i < n ; i++ )
		sum += s[i]-'0';
	if(sum%9)
		puts("No");
	else
		puts("Yes");
	return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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 main(){
  int n,m;
  cin>>n>>m;
  int total=0;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
    total+=vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  if(vec.at(m-1)>=(double)total/(4*m)){
    cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,mod;
  cin>>n>>mod;

  vector<Int> a(n*2);
  for(Int i=0;i<n*2;i++) cin>>a[i];
  sort(a.begin(),a.end());

  Int ans=mod;
  {
    Int res=0;
    for(Int i=0;i<n;i++)
      chmax(res,(a[i]+a[n*2+~i])%mod);
    chmin(ans,res);
  }
  
  vector<Int> b(n*2);
  for(Int i=n;i<n*2;i++){
    if(a[i-1]+a[i]<mod){
      b[i]=n*2;
      continue;
    }
    Int l=0,r=i;
    while(l+1<r){
      Int m=(l+r)>>1;
      if(m*2+~i<0||a[m*2+~i]+a[i]<mod) l=m;
      else r=m;
    }
    b[i]=r;
  }

  vector<Int> c(n*2);
  for(Int i=0;i<n;i++){
    if(a[i]+a[i+1]>=mod){
      c[i]=0;
      continue;
    }
    Int l=i+1,r=n*2;
    while(l+1<r){
      Int m=(l+r)>>1;
      if(m*2+~i>=n*2||a[m*2+~i]+a[i]>=mod) r=m;
      else l=m;
    }
    c[i]=l;
  }


  vector<Int> ng(n*2,0);
  {
    Int tmp=0;
    for(Int i=n*2-1;i>n;i--){
      chmax(tmp,b[i]);
      ng[i*2-n*2]|=i<tmp;
    }
  }
  {
    Int tmp=n*2;
    for(Int i=0;i<n;i++){
      chmin(tmp,c[i]);
      ng[i*2]|=tmp<=i;
    }
  }  
  
  Int pos=2;
  while(ng[pos]) pos+=2;
  
  {
    Int res=0;
    for(Int i=0;i*2<pos;i++)
      chmax(res,(a[i]+a[pos+~i])%mod);
    
    for(Int i=0;pos+i*2<n*2;i++)
      chmax(res,(a[pos+i]+a[n*2+~i])%mod);
    
    chmin(ans,res);
  }
  
  cout<<ans<<endl;
  return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1000000007
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'

struct custom_hash {    // anti-hack for unordered_map. To declare: unordered_map<long long, int, custom_hash> safe_map;
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//
int MAXN = 1000001;
vector<int>spf(MAXN,1);

void sieve()
{
	spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
		spf[i] = i; 
  
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<MAXN; j+=i) 
  
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

vector<int>getFactorization(int x)
{
	vector<int>ret;
	while(x!=1)
	{
		if(ret.empty() || ret.back()!=spf[x])
		ret.pb(spf[x]);
		x = x/spf[x];
	}
	return ret;
}

void solve()
{
	int n;
	cin>>n;
	vi a(n);
	fi(n)cin>>a[i];
	int gcd = __gcd(a[0],a[1]);
	for(int i=2;i<n;i++)gcd=__gcd(gcd,a[i]);
	bool set_wise = (gcd==1);
	unordered_set<int>us;
	sieve();
	bool pair_wise = true;
	for(int i=0; i<n && pair_wise; i++)
	{
		vector<int>temp = getFactorization(a[i]);
		for(int j:temp)
		{
			if(j!=1)
			{
				if(us.find(j)==us.end())
					us.insert(j);
				else
				{
					pair_wise = false;
					break;
				}
			}
		}
	}
	if(pair_wise)
		cout << "pairwise coprime";
	else if(set_wise)
		cout << "setwise coprime";
	else
		cout << "not coprime";

}


int main()
{
    int t;
    // cin>>t;
    // while(t--)
     solve();

	return 0;
}

Measured memory_bytes: 11104
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X, Y):
    return X + Y // 2


def main():
    # N = read_int()
    N, M = read_int_n()
    # A = [read_int_n() for _ in range(N)]
    print(slv(N, M))


if __name__ == '__main__':
    main()


Measured memory_bytes: 8124
///Made By Imangali

#include <bits/stdc++.h>

#define pb push_back
#define int long long
#define eb emplace_back
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>
#define forit(it, s) for(auto it: s)
#define AddSpeed cin.tie(0); ios_base :: sync_with_stdio(0);
#define fixset(x) cout << fixed << setprecision(x)
#define sz(s) (int)s.size()
#define all(s) (s).begin(),(s).end()
#define sqr(x) ((x) * 1ll * (x))
#define fname "A"
#define vi vector<int>
#define rep(i,t,n) for(int i = t; i < n; i ++)
#define vpii vector<pair<int,int>                         

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef long double lld;

const int INF = 1e9 + 7;
const ld EPS = 1e-9;
const ld pi = acos(-1);
const int mod = 998244353;
const int N = 500 + 7;
const int maxn = 3e5 + 7;
using namespace std;

inline void time() {
	cerr << (clock() * 1.0 / CLOCKS_PER_SEC * 1.0);
}
int n, a[maxn];
main() { AddSpeed
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	int k = 0, s = 0;
 	for(int i = 1; i <= n; i ++) {
  	s += i;
  	k += a[i];
	}
	if(k % s != 0) {
		cout<<"NO";
		return 0;
	}
	k /= s;
	vector <int> st;  
	for(int i = 1; i < n; i ++)
		st.pb(a[i + 1] - a[i]);
	st.pb(a[1] - a[n]);

	for(auto x : st) {      	
		if(x > k) {
			cout<<"NO";
			return 0;
		}
		if((k - x) % n != 0) {
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";

	return 0;                                                                                                           
}                               

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

int N;

int main() {
    cin >> N;
    vector<int> A(N);
    cin >> A[0];
    if (A[0] != 0) {
        cout << -1 << endl;
        return 0;
    }
    
    long long ans = 0;
    for (int i = 1; i < N; i++) {
        cin >> A[i];
        if (A[i] > A[i - 1] + 1) {
            cout << -1 << endl;
            return 0;
        } else if (A[i] <= A[i - 1]) {
            ans += A[i - 1];
        }
        if (i == N - 1) {
            ans += A[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
//#include <algorithm>
#include <vector>

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

using namespace std;

int main(int argc, char* argv[])
{
    long n, ww;
    scanf("%ld %ld", &n, &ww);

    vector<long> w(n);
    vector<long> v(n);

    long i, j;
    for(i=0; i<n; i++) {
        scanf("%ld %ld", &(w[i]), &(v[i]));
    }

    vector<vector<long long> > aa(n+1, vector<long long>(ww+1, 0));

    for(i=n-1; i>=0; i--) {
        for(j=1; j<=ww; j++) {
            if(j>=w[i]) {
                aa[i][j] = MAX(aa[i+1][j], aa[i+1][j-w[i]]+v[i]);
            }
            else {
                aa[i][j] = aa[i+1][j];
            }
        }
    }
    printf("%lld\n", aa[0][ww]);

    return 0;
}


Measured memory_bytes: 80256
import sys
readline = sys.stdin.readline
N, K = map(int, input().split())
W = tuple(map(int, sys.stdin.read().splitlines()))
ma = max(W)
def check(x):
    if x < ma:
        return False
    use = 1
    rest = x
    for w in W:
        if rest >= w:
            rest -= w
        else:
            rest = x - w
            use += 1
    return use <= K
l = 0
r = sum(W)
while r - l > 1:
    m = (r + l) // 2
    if check(m):
        r = m
    else:
        l = m
print(r)


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for (int i = 1; i < N; i++) {
    int a;
    cin >> a;
    a--;
    G[a].emplace_back(i);
  }
  function<int(int, int)> rec = [&](int u, int p) {
    int res = 0;
    vector<int> cands;
    for (int v : G[u]) {
      if (v == p) continue;
      cands.emplace_back(rec(v, u));
    }
    sort(cands.begin(), cands.end(), greater<int>());
    for (int i = 0; i < (int)cands.size(); i++) {
      res = max(res, cands[i] + i + 1);
    }
    return res;
  };
  cout << rec(0, -1) << '\n';
  return 0;
}


Measured memory_bytes: 21068
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if i < n-1:
        if a[i]+1 == a[i+1]:
            ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

const llong INF = 4e18;

llong solve_short(int N, int K, VI& A) {
   DEBUG(K);
   if (K == 0)
      return 0;

   llong best_short_sum = -INF;

   for (int start = 0; start < N; ++start) {
      llong cur_sum = 0;
      llong cur_best_sum = -INF;
      FOR(steps, 1, min(K, N)) {
         cur_sum += A[ start + steps - 1 ];
         cur_best_sum = max(cur_best_sum, cur_sum);
      }
      best_short_sum = max(best_short_sum, cur_best_sum);
   }
   DEBUG(best_short_sum);
   
   return best_short_sum;
}

llong solve_cycle(int K, VI& A) {
   const int N = SZ(A);
   REP(i, N)
      A.push_back(A[i]);

   llong res1 = solve_short(N, K, A);
   if (K < N)
      return res1;

   llong sum = 0;
   REP(i, N)
      sum += A[i];

   if (sum < 0)
      return res1;

   llong res2 = -INF;
   if (K % N == 0) {
      int nrounds = max(K / N - 1, 0);
      DEBUG(nrounds);
      res2 = nrounds * sum;
      K = N;
   }
   else {
      int nrounds = K / N;
      DEBUG(nrounds);
      res2 = nrounds * sum;
      K %= N;
   }
   DEBUG(res2);

   llong best_short_sum = solve_short(N, K, A);
   res2 += best_short_sum;

   return max(res1, res2);
}

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

   int N, K;
   cin >> N >> K;
   VI P(N);
   REP(i, N) {
      cin >> P[i];
      --P[i];
   }
   VI C(N);
   REP(i, N)
      cin >> C[i];

   VVI cycles;
   VI vis(N);
   REP(i, N) {
      if (vis[i]) continue;
      VI cycle;
      for (int j = i; !vis[j]; ) {
         vis[j] = true;
         cycle.push_back(j);
         j = P[j];
      }
      cycles.emplace_back(cycle);
   }

   llong res = -INF;
   for (VI& cycle : cycles) {
      DEBUG(cycle);
      VI A;
   // A.reserve(2 * cycle.size());
      for (int j : cycle)
         A.push_back(C[j]);
      DEBUG(A);
      llong cur = solve_cycle(K, A);
      res = max(res, cur);
   }
   
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 3836
#include <iostream>
 using namespace std; int main(void){ 
    int a;
    cin>>a;
    char b[100];
    char c[100];
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    for(int i=0;i<a;i++){
        cin>>c[i];
    }
    for(int i=0;i<a;i++){
        cout<<b[i]<<c[i];
    }
    return 0;
    }


Measured memory_bytes: 256
import math
def jud(s):
    for i in range(2,int(math.sqrt(s))+1):
            if s%i == 0:
                return 0
    return 1

n = int(input())
a = [0]*n
cnt = 0

for i in range(n):
    a[i] = int(input())
    han = jud(a[i])
    if han == 1:
        cnt += 1

print(cnt)


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

int main() {
	int s,m,h;
	cin >> s;
	h = s / 3600;
	s = s % 3600;
	m = s / 60;
	s = s % 60;
	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

Measured memory_bytes: 3072
import sys
n, k = map(int, input().split())
p = [int(i) for i in input().split()]
total = [0] * n
total[0] = sum(range(1, p[0] + 1)) / p[0]
max_value = 0
if k == 1:
    print(sum(range(1, max(p) + 1)) / max(p))
    sys.exit()
elif k == n:
    print(sum([sum(range(1, i + 1)) / i for i in p]))
    sys.exit()
for i in range(1, n):
    total[i] = total[i - 1] + sum(range(1, p[i] + 1)) / p[i]
    
    if i == k - 1:
        max_value = total[i]
    elif i >= k:
        max_value = max(max_value, total[i] - total[i - k])
print(max_value)

Measured memory_bytes: 78856
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

int dp[1025][100100];
int k=10;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    int v[n+1],w[n+1];
    for(int i=1;i<=n;i++) cin>>v[i]>>w[i];

    rep(i,600)rep(j,100100) dp[i][j]=0;
    for(int cur=1;cur<=min((1<<k),n);cur++){
        int par=cur/2;
        for(int i=100000;i>=0;i--){
            chmax(dp[cur][i],dp[par][i]);
            if(i+w[cur]<100100) chmax(dp[cur][i+w[cur]],dp[par][i]+v[cur]);
        }
    }

    int q;cin>>q;
    while(q--){
        int node,l;cin>>node>>l;

        if(node<(1<<k)){
            cout<<dp[node][l]<<endl;
            continue;
        }
        vector<int> vv,ww;
        for(;node>=(1<<k);node>>=1) vv.push_back(v[node]),ww.push_back(w[node]);

        int t=(int)vv.size();
        ll ans=0;
        for(int bit=0;bit<(1<<t);bit++){
            ll wsum=0,vsum=0;
            rep(i,t)if((bit>>i)&1)wsum+=ww[i],vsum+=vv[i];
            if(wsum<=l) chmax(ans,vsum+dp[node][l-wsum]);
        }
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 406276
import networkx as nx

R, C = [int(x) for x in input().split()]
grid = [list(input()) for r in range(R)]


def pack(r, c):
    return r * C + c


graph = nx.Graph()
top_nodes = set()  # top half of the bipartite graph
for r in range(R):
    for c in range(C):
        if r + 1 < R and grid[r][c] == grid[r + 1][c] == ".":
            u, v = pack(r, c), pack(r + 1, c)
            graph.add_edge(u, v)
            if (r + c) % 2 == 0:
                top_nodes.add(v)
            else:
                top_nodes.add(u)
        if c + 1 < C and grid[r][c] == grid[r][c + 1] == ".":
            u, v = pack(r, c), pack(r, c + 1)
            graph.add_edge(u, v)
            if (r + c) % 2 == 0:
                top_nodes.add(v)
            else:
                top_nodes.add(u)


matching = nx.bipartite.maximum_matching(graph, top_nodes=top_nodes)

count = 0
for u, v in matching.items():
    if u > v:
        assert matching[v] == u
        r1, c1 = divmod(u, C)
        r2, c2 = divmod(v, C)
        if r1 == r2:
            if c1 > c2:
                c1, c2 = c2, c1
            grid[r1][c1], grid[r2][c2] = ">", "<"
        elif c1 == c2:
            if r1 > r2:
                r1, r2 = r2, r1
            grid[r1][c1] = "v"
            grid[r2][c2] = "^"
        count += 1

print(count)
for row in grid:
    print("".join(row))



Measured memory_bytes: 66496
#include <bits/stdc++.h>
using namespace std;
const int md=998244353;
int a,b,c,d,i,j,k,cur;
long long f[3003][3003][2];
int main() {
  scanf("%d%d%d%d",&a,&b,&c,&d);
  f[a][b][1]=1;
  for (i=a; i<=c; i++) for (j=b; j<=d; j++) for (k=0; k<2; k++) if (f[i][j][k]) {
    f[i+1][j][0]=(f[i+1][j][0]+f[i][j][k]*j)%md;
    cur=(k==1)?i:1;
    f[i][j+1][1]=(f[i][j+1][1]+f[i][j][k]*cur)%md;
  }
  printf("%d\n",int((f[c][d][0]+f[c][d][1])%md));
  return 0;
}


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

int N, C;
vector<vector<int>> field;

int dh[] = {-1, -1, 0, 1, 1, 0};
int dw[] = {0, -1, -1, 0, 1, 1};

bool alive;
int dfs(int h, int w){
    int c = field[h][w];
    field[h][w] = -1;
    
    int res = 1;
    for(int i=0; i<6; i++){
        int nh = h + dh[i];
        int nw = w + dw[i];
        if(0<=nh && nh<N && 0<=nw && nw<=nh){
            if(field[nh][nw] == c){
                res += dfs(nh, nw);
            }
            if(field[nh][nw] == 0){
                alive = true;
            }
        }
    }
    return res;
}

int remove(){
    int res = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<=i; j++) if(field[i][j] != 0 && field[i][j] != -1){
            alive = false;
            bool rev = field[i][j] == C;
            int painted = dfs(i, j);
            if(!alive){
                if(rev)
                    res -= painted;
                else
                    res += painted;
            }
        }
    }
    return res;
}

void solve(){
    auto origin = field;
    int ans = -10000000;
    
    for(int i=0; i<N; i++){
        for(int j=0; j<=i; j++) if(field[i][j] == 0){
            field[i][j] = C;
            ans = max(ans, remove());
            field = origin;
        }
    }
    cout << ans << endl;
}

int main(){
    while(cin >> N >> C, N|C){
        field.resize(N);
        for(int i=0; i<N; i++){
            field[i].resize(i+1);
            for(auto &v: field[i])
                cin >> v;
        }
        solve();
    }
    
}

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

int main() {
  int N;
  cin >> N;
  vector<int> card(N);
  for(int i=0;i<N;i++){
    cin >> card[i];
  }
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());
  int A,B;
  A=0;
  B=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      A+=card[i];
    }
    else{
      B+=card[i];
    }
  }
  cout << A-B <<endl;
}


Measured memory_bytes: 256
INF = float('inf')
N = int(input())
M = []
D = []
P = []
visited = []
for i in range(N):
    M.append([a if a != -1 else INF for a in map(int, input().split())])
    D.append(INF)
    P.append(-1)
    visited.append(False)

D[0] = 0
P[0] = None

while True:
    min_cost = INF
    u = -1
    for i in range(N):
        if not visited[i] and D[i] < min_cost:
            u = i
            min_cost = D[i]

    if u == -1:
        break

    visited[u] = True

    for i, m in enumerate(M[u]):
        if not visited[i] and m != INF and m < D[i]:
            D[i] = m
            P[i] = u

print(sum(D))


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

using namespace std;

int main() {
	int x, ans = 0;
	cin >> x;
	for(int b = 1; b <= 40; b++) {
		for(int p = 2; p <= 10; p++) {
			if((int)pow(b, p) <= x) ans = max(ans, (int)pow(b, p));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
n,k = map(int, input().split())
hs = [False]*n
for _ in range(k):
  d = int(input())
  s = [int(i) for i in input().split()]
  for p in s:
    if not hs[p-1]:
      hs[p-1]=True
res=0
for i in range(n):
  if not hs[i]:
    res+=1
print(res)

Measured memory_bytes: 67668
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#include<tuple>
#include<algorithm>
#define INF 1111111111
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> tup;
typedef long long ll;
vector<int> vec(100100);
vector<int> passed(100100);
vector<int> dx = {-1,1};

int main() {
  int tmp;
  cin >> tmp;
  const int n = tmp;
  int b[n-1];
  for(int i=0;i<n;i++)
    cin >> b[i];

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N>>A;
    vec p(N), c(N);
    rep(i,N) cin>>p[i]>>c[i];
    A /= 100;
    rep(i,N) c[i] /= 100;
    ll ans = 1e+3;
    rep(s,(1LL << N)){
        ll score = 0, temp = 0;
        rep(i,N){
            if((s>>i)&1) {
                score += c[i] + (i+1)*p[i];
                temp += p[i];
            }
        }
        if(score >= A){
            ans = min(ans,temp);
            continue;
        }
        for(ll i = N-1; i >= 0; --i){
            if((s>>i)&1) continue;
            rep(j,p[i] - 1){
                score += i+1;
                ++temp;
                if(score >= A){
                    ans = min(ans,temp);
                    break;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <stack>
#include <climits>

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

using namespace std;

int data[5000];
stack<int> wn[5000];

int main(){
	int n;
	int m;
	scanf("%d%d", &n, &m);
	fill(data, data + 5000, 0);
	int a, b;
	REP(i, m){
		scanf("%d%d", &a, &b);
		++(data[--b]);
		wn[--a].push(b);
	}
	int t = -1;
	bool ex = false;
	REP(i, n){
		REP(j, n){
			if (data[j] == 0){
				if (t != -1)
					ex = true;
				t = j;
			}
		}
		printf("%d\n", t+1);
		while (!wn[t].empty()){
			--(data[wn[t].top()]);
			wn[t].pop();
		}
		data[t] = INT_MAX;
		t = -1;
	}
	if (ex)
		printf("1\n");
	else
		printf("0\n");
}

Measured memory_bytes: 4420
#include<iostream>
int main()
{
    int n;
    std::cin >> n;
    
    if ((n%10==7)||(n%100-n%10==70)||(n-n%100==700))
    {
        std:: cout << "Yes" << std::endl;
    }
    
    else
    {
        std:: cout << "No" << std::endl;
    }
    
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int sz) : data(sz, -1), sz(sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x;
        sz--;
        return true;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() {return sz;}
};

int main(void) {
    int n, m;
    cin >> n >> m;
    int p[n];
    rep (i, n) {cin >> p[i]; p[i]--;}
    int x[m], y[m];
    rep (i, m) {cin >> x[i] >> y[i]; x[i]--; y[i]--;}

    vector<int> a(n);
    rep (i, n) {
        a[p[i]] = i;
    }

    UnionFind uf(n);

    rep (i, m) uf.unionSet(x[i], y[i]);

    int ans = 0;
    rep (i, n) ans += (uf.findSet(i, a[i]));

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int n;
    cin >> n;
    cout << 800*n-(n/15*200);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,x,y,cnt=0;
    cin>>n>>k>>x>>y;
    while(n>0&&k>0)
    {
        cnt+=x;
        n--;
        k--;
    }
    while(n>0)
    {
        cnt+=y;
        n--;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int f(int k) { return k * k; }
signed main() {
	int n, q, x0[110], y0[110], r[110], x1, x2, y1, y2;
	while (cin >> n, n) {
		for1(i, n)cin >> x0[i] >> y0[i] >> r[i];
		cin >> q;
		while (q--) {
			cin >> x1 >> y1 >> x2 >> y2;
			bool b = 0;
			for1(i, n) {
				if ((f(x1 - x0[i]) + f(y1 - y0[i]) - f(r[i])) < 0 && (f(x2 - x0[i]) + f(y2 - y0[i]) - f(r[i])) < 0)continue;
				if ((f(x1 - x0[i]) + f(y1 - y0[i]) - f(r[i])) * (f(x2 - x0[i]) + f(y2 - y0[i]) - f(r[i])) < 0)b = 1;
				else if (f((y1 - y2) * x0[i] - (x1 - x2) * y0[i] + x1 * y2 - x2 * y1) <= f(r[i]) * (f(x1 - x2) + f(y1 - y2)) && ((x1 - x2) * (x0[i] - x1) + (y1 - y2) * (y0[i] - y1)) * ((x1 - x2) * (x0[i] - x2) + (y1 - y2) * (y0[i] - y2)) <= 0)b = 1;
				if (b)break;
			}
			cout << (b ? "Safe\n" : "Danger\n");
		}
	}
}


Measured memory_bytes: 2960
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template<class T, class U> bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }

void solve(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll& i : a) cin >> i;
    string s;
    cin >> s;
    vector<ll> base;
    for(ll i = n; i--; ){
        if(s[i] == '0'){
            for(ll b : base) chmin(a[i], a[i] ^ b);
            if(a[i]) base.push_back(a[i]);
        }
        else{
            for(ll b : base) chmin(a[i], a[i] ^ b);
            if(a[i]){
                cout << 1 << endl;
                return;
            }
        }
    }
    cout << 0 << endl;
}
int main(){
    ll t;
    cin >> t;
    while(t--) solve();
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int n,r;
  cin >> n >> r;
  if(n>=10)cout << r << endl;
  else cout << r+(100*(10-n)) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};
vector<int> compress(vector<int> x){
    vector<int> res=x,tmp=x;
    sort(tmp.begin(),tmp.end());
    for(int i=0;i<(int)res.size();++i){
        res[i]=lower_bound(tmp.begin(),tmp.end(),res[i])-tmp.begin()+1;
    }
    return res;
}
int main(){
    ll K;cin>>K;
    vector<ll> a(50);
    for(int i=0;i<50;++i) a[i]=i;
    ll m=K/50;
    for(int i=0;i<50;++i) a[i]+=m;
    ll n=K%50;
    while(n--){
        for(int i=0;i<50;++i){
            if(a[i]==m) a[i]+=50;
            else a[i]--;
        }
    }
    cout<<50<<endl;
    for(int i=0;i<50;++i){
        cout<<a[i];
        if(i<49) cout<<' ';
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
string c1,c2,cc1,cc2;
int main(){
    cin>>c1>>c2;
    cc1=c1,cc2=c2;
    reverse(c1.begin(),c1.end());
    reverse(c2.begin(),c2.end());
    cout<<(c2==cc1&&c1==cc2?"YES":"NO")<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <unordered_map>

int NN = 3;
const int MOD = 1000000007;
std::vector<std::unordered_map<std::string, int>*> memo;

bool isOK (std::string last4) {
  for(int i=0; i<4; i++) {
    std::string t = last4;
    if ( i>= 1 ) {
      char tmp = t[i-1];
      t[i-1] = t[i];
      t[i] = tmp;
    }
    if ( t.find("AGC") != std::string::npos ){
      return false;
    }
  }
  return true;
}

long long dfs(int cur, std::string last3) {

  if (memo[cur]->count(last3)) return memo[cur]->at(last3);
  if (cur == NN) return 1;

  long long  ret = 0;
  std::string S = "ATGC";
  for(int i=0; i<S.size(); i++){
    if ( isOK(last3+S[i]) ){
      ret += (dfs(cur+1, last3.substr(1,2)+S[i]) % MOD);
    }
  }
  memo[cur]->insert( {last3, ret%MOD} );
  return ret % MOD;
}


int main (void) {
  std::cin >> NN;
  memo.resize(NN+1); for(int i=0; i<NN+1; i++) { memo[i] = new std::unordered_map<std::string, int> (); }
  std::cout << dfs(0, "TTT") % MOD << std::endl;
  return 0;
}

Measured memory_bytes: 896
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    IN(k);
    ll i = 0;
    rep(j, k) {
        i = (i*10+7) % k;
        if (i == 0) {
            cout << j+1 << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
main(){
	int n;cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	cout<<a[n-1];
	for(int i=n-2;i>=0;i--)cout<<" "<<a[i];
	cout <<endl;
	return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    if(A[0]>0){
        cout<<-1<<endl;
        return 0;
    }
    ll ans=0;
    for(int i=N-1;i>=0;--i){
        if(A[i-1]+1<A[i]){
            cout<<-1<<endl;
            return 0;
        }
        if(A[i-1]>=A[i]){
            ans+=A[i];
        }
        else{
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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;
  cin >> N;

  vector<int> p(N);
  rep(i, N){
    cin >> p[i];
    p[i]--;
  }
  
  vector<ll> a(N);
  vector<ll> b(N);

  rep(i, N){
    a[i] = (i+1) * 30000;
  }

  rep(i, N){
    b[i] = (N-i) * 30000;
  }

  rep(i, N){
    a[p[i]] += (i+1);
  }

  rep(i, N){
    cout << a[i] << " ";
  }
  cout << endl;

  rep(i, N){
    cout << b[i] << " ";
  }
  cout << endl;

  return 0;
}


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

int main(){
    
    int a,b; cin>>a>>b;

    bool flag = false;
 
    for(int c=1; c<=3; c++){
        if( (a*b*c) % 2 != 0) flag = true;
    }

    if(flag) cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    return 0;
}

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

int N;
multiset<int> ms;
int ans = 0;

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    int inp;
    cin >> inp;
    ms.emplace(inp);
  }

  while (!ms.empty()) {
    auto it = ms.end();
    it--;
    int a = *it;
    ms.erase(it);

    int b = 1;
    while (b <= a) {
      b <<= 1;
    }
    b -= a;

    auto jt = ms.find(b);
    if (jt != ms.end()) {
      ans++;
      ms.erase(jt);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 11648
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}
int main()
{
    int i, n, d[100000],k;
    scanf("%d",&n);
    for(i=0; i<n; i++) {
        scanf("%d",d+i);
    }
    qsort(d, n, sizeof(int), cmp);
    int ans = d[n/2]-d[n/2-1];
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdint>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
string S; cin >> S;
bool flag = false;
if(S[0] != 'A'){
  flag = true;
}
int count = 0;
for(int i = 2; i <= S.size()-2;i++){
  if(S[i] == 'C'){
    count++;
  }
}
if(count!=1){
  flag = true;
}

int ans = 0;
rep(i,S.size()){
if((S[i]>= 'A') && (S[i]<='Z')){
  ans++;
}
}
if(ans > 2){
  flag = true;
}
  if(flag){
    cout << "WA" << endl;
  }
  else{
    cout << "AC" << endl;
  }
}

Measured memory_bytes: 256