akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

std::vector<int64_t> divisor(int64_t n) {
    // nの約数をソートして列挙。1とnも含む。計算量はO(sqrt(n))なので、int64_tも入り得る。
    std::vector<int64_t> res;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) {
                res.push_back(n / i);
            }
        }
    }
    std::sort(res.begin(), res.end());
    return res;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

const int MAX_N = 1e3 + 10;
int N;
int64_t K;
int64_t A[MAX_N], B[MAX_N];

bool solve(int64_t x) {
    std::vector<int> vec;
    rep (i, 1, N) {
        B[i] = A[i];
        vec.push_back(i);
    }
    std::sort(vec.begin(), vec.end(), [&](int i, int j){
        return B[i] % x < B[j] % x;
    });

    int sum = 0;
    for (int i : vec) {
        if (sum + B[i] % x <= K) {
            sum += B[i] % x;
            B[i] -= B[i] % x;
        } else {
            break;
        }
    }

    rep (i, 1, N) {
        if (0 < B[i] % x) {
            if (x - (B[i] % x) <= sum) {
                sum -= x - (B[i] % x);
            } else {
                return false;
            }
        }
    }

    return true;

}

int main(int argc, char **argv) {
    std::cin >> N >> K;
    int64_t sum = 0;
    rep (i, 1, N) {
        std::cin >> A[i];
        sum += A[i];
    }

    auto divi = divisor(sum);

    std::reverse(divi.begin(), divi.end());

    for (int d : divi) {
        if (solve(d)) {
            std::cout << d << std::endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
D, G = map(int, input().split())
Q = list()
s = 0
for d in range(D):
    Q.append([d+1]+[int(x) for x in input().split()])
    s += Q[-1][1]
dp = [-float("inf")]*(s+1)
dp[0] = 0
for i, p, c in Q:
    for j in range(s, -1, -1):
        for k in range(1, p+1):
            if k == p:
                cc = 100*i*k+c
            else:
                cc = 100*i*k
            if k <= j:
                dp[j] = max(dp[j], dp[j-k]+cc)
for i in range(s+1):
    if dp[i] >= G:
        print(i)
        exit()


Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int len_y = y2 - y1;
    int len_x = x2 - x1;
    //cout << len_x << " " << len_y << endl;
    cout << x2-len_y << " "<<  y2 + len_x << " " << x1-len_y <<" " <<y1 + len_x <<endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
k,a,b = map(int, input().split())

if b - a < 2:
    print(1+k)
else:
    c = a - 1 + 2
    d = k - c
    if d % 2 == 0:
        print((d//2)*(b-a)+b)
    else:
        print((d//2)*(b-a)+b+1)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner text = new Scanner(System.in);
		
		int a = text.nextInt();
		int b = text.nextInt();
		int c = text.nextInt();
		
		int s;
		int count = 0;
		
		for(s = a; s <= b; s++){
			
				if(c % s == 0){
					count++;
				}
		}
		
		System.out.println(count);

	}

}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int UF_MAX = 1e5 + 3;

class UF{
	int x[UF_MAX];
	int co;
	
public:
	
	UF(){
		fill(x,x+UF_MAX,-1);
		co = 0;
	}
	
	int boss(int a){
		int s = a;
		while(x[s] > -1) s = x[s];
		if(s != a) x[a] = s;
		return s;
	}
	
	void uni(int a , int b){
		int s = boss(a);
		int t = boss(b);
		if(s != t){
			++co;
			if(x[s] < x[t]){
				x[s] += x[t];
				x[t] = s;
			} else {
				x[t] += x[s];
				x[s] = t;
			}
		}
	}
	
	bool find(int a , int b){
		return boss(a) == boss(b);
	}
	
	int count(){
		return co;
	}
	
	int member(int a){
		return -x[boss(a)];
	}
};

UF uf;
int N,M;
int p[100003];

int main(){
	cin >> N >> M;
	repp(i,1,N+1) cin >> p[i];
	repp(i,0,M){
		int x,y; cin >> x >> y;
		uf.uni(x,y);
	}
	int ans = 0;
	repp(i,1,N+1) if(uf.find(i,p[i])) ++ans;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
/*input
3 3
5
1 1 1
1 2 2
2 2 5
2 3 8
3 3 3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
vector<pll> r[maxn];
vector<pll> c[maxn];
vector<pll> edge[maxn];
bool vis[maxn];
ll v[maxn];
vector<ll> cpn;
void dfs(int u){
	cpn.pb(u);
	vis[u]=1;
	for(pll e:edge[u]){
		if(vis[e.F]){
			if(v[e.F]-v[u]!=e.S){
				cout<<"No\n";
				exit(0);
			}
		}
		else{
			v[e.F]=v[u]+e.S;
			dfs(e.F);
		}
	}
}

int main(){
	IOS;
	int n,m;
	cin>>n>>m;
	int q;
	cin>>q;
	while(q--){
		ll x,y,d;
		cin>>x>>y>>d;
		--x;--y;
		r[x].pb(MP(y,d));
		c[y].pb(MP(y,d));
	}
	REP(i,n){
		sort(ALL(r[i]));
		REP(j,SZ(r[i])-1){
			edge[r[i][j].F].pb(MP(r[i][j+1].F,r[i][j+1].S-r[i][j].S));
			edge[r[i][j+1].F].pb(MP(r[i][j].F,r[i][j].S-r[i][j+1].S));
			// cout<<r[i][j].F<<' '<<r[i][j+1].F<<' '<<r[i][j+1].S-r[i][j].S<<'\n';
		}
	}
	REP(i,m) if(!vis[i]){
		cpn.clear();
		v[i]=0;
		dfs(i);
		ll mn=cpn[0];
		for(int j:cpn) if(v[j]<v[mn]) mn=j;

		for(int j:cpn) for(pll k:c[j]){
			// cout<<k<<'\n';
			ll tmp=k.S-v[k.F]+v[mn];
			if(tmp<0){
				cout<<"No\n";
				return 0;
			}
		}
	}
	cout<<"Yes\n";
	return 0;
}


Measured memory_bytes: 34044
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int a[100001];
int b[100001];

int N;

using P = pair<int, int>;
priority_queue<P> aa;
priority_queue<P> bb;

signed main()
{
	cin >> N;

	REP(i, N)
	{
		int v;
		cin >> v;

		if (i % 2 == 0)
		{
			a[v]++;
		}
		else
		{
			b[v]++;
		}
	}

	if (N == 2)
	{
	}

	for (int i = 1; i <= 100000; i++)
	{
		aa.push(P(a[i], i));
		bb.push(P(b[i], i));
	}

	P max_a_1 = aa.top();
	aa.pop();
	P max_a_2 = aa.top();
	aa.pop();
	P max_b_1 = bb.top();
	bb.pop();
	P max_b_2 = bb.top();
	bb.pop();

	int ans = INT_MAX;

	if (max_a_1.second != max_b_1.second)
	{
		ans = MIN(ans, N - (max_a_1.first + max_b_1.first));
	}
	if (max_a_1.second != max_b_2.second)
	{
		ans = MIN(ans, N - (max_a_1.first + max_b_2.first));
	}
	if (max_a_2.second != max_b_1.second)
	{
		ans = MIN(ans, N - (max_a_2.first + max_b_1.first));
	}
	if (max_a_2.second != max_b_2.second)
	{
		ans = MIN(ans, N - (max_a_2.first + max_b_2.first));
	}

	cout << ans << endl;
}








Measured memory_bytes: 5100
#include <stdio.h>
#define YEAR 1000
#define MONTH 10
#define DAY_1 20
#define DAY_2 19

int main(void){
    int num,i;
    int num_day;
    int y,m,d;
    scanf("%d",&num);
    for(i=0; i<num; i++){
        num_day = 0;
        scanf("%d %d %d",&y,&m,&d);

        while(y < YEAR){
            while(m <= MONTH){
                if(((y%3)!=0) && ((m%2) == 0)){
                    d++;
                }
                while(d <= DAY_1){
                    num_day ++;
                    d++;
                }
                d = 1;
                m++;

            }
            m = 1;
            y++;
        }
            /*num_day += DAY_1 - d + (m % 2);
            printf("%d\n",num_day);
            if( m == MONTH){//m+1 の処理
                m = 1;
                y++;
            }
            else
            {
                m++;
            }

            if( (m % 2) == 0){
                num_day += DAY_2 ;   
            }
            if( y != YEAR){
                num_day += (MONTH - m)/2 * (DAY_1 + DAY_2);
                y++;
            }
            
            printf("%d\n",num_day);

            num_day += (YEAR - y) % 3 * (5*(DAY_1+DAY_2));
            printf("%d\n",num_day);
            y += (YEAR - y) % 3;

            int year_3 = 2 * (5*(DAY_1+DAY_2)) + (10*(DAY_1));
            num_day += (YEAR - y)/3 * year_3;
*/
            printf("%d\n",num_day);
    }
}


Measured memory_bytes: 2044
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; string C; cin >> n >> C;
    string r, w;
    rep(i, n){
        if(C[i]=='R')w += "R";
        else r += "W";
    }
    string t = w + r;
    int cnt = 0;
    rep(i, n)if(C[i] != t[i])cnt++;
    cout << cnt / 2 << ln;
}
    


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

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

Measured memory_bytes: 256
/*  I'm a mess, I'm a loser                  */
/*  I'm a hater, I'm a user                  */
/*  I'm a mess for your love, it ain't new   */
/*  I'm obsessed, I'm embarrassed            */
/*  I don't trust no one around us           */
/*  I'm a mess for your love, it ain't new   */

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
ll mod=1000000007;


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


ll t=1;
//cin>>t;
while(t--)
{

ll x,y,a,b,c;
cin>>x>>y>>a>>b>>c;
ll ar[a],br[b],cr[c],i,j;

for(i=0;i<a;i++)
cin>>ar[i];

for(i=0;i<b;i++)
cin>>br[i];

for(i=0;i<c;i++)
cin>>cr[i];

sort(ar,ar+a,greater<ll>());
sort(br,br+b,greater<ll>());
sort(cr,cr+c,greater<ll>());
vector<ll>v;

for(i=0;i<x;i++)
v.push_back(ar[i]);

for(i=0;i<y;i++)
v.push_back(br[i]);

ll ans=0;
for(i=0;i<v.size();i++)
ans+=v[i];

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

ll add=0,sub=0;

for(i=0;i<min((ll)v.size(),c);i++)
{
  if(cr[i]>v[i])
   {
     add+=cr[i];
     sub+=v[i];
   }
   else
    break;
}

cout<<ans+add-sub<<endl;

}
return 0;
}

















Measured memory_bytes: 7624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9

ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    ll a[n+1],b[n];f(i,0,n+1)cin>>a[i];
    f(i,0,n)cin>>b[i];ll ans=0;
    f(i,0,n){
        if(b[i]>=a[i] && a[i]>0){
            ans+=a[i];b[i]-=a[i];
        }
        else if(b[i]<a[i]){ans+=b[i];b[i]=0;}
        if(b[i]>=a[i+1]){
            ans+=a[i+1];a[i+1]=0;
        }
        else if(b[i]<a[i+1]){ans+=b[i];a[i+1]-=b[i];}
    }
    cout<<ans;
    return 0;  
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
int n;
vector<int>d(n);

int main() {
	int n, sum = 0;
	cin >> n;
	vector<int>d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			sum += d[i] * d[j];
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()

if S[0] == "S":
    if S[1] == "S":
        if S[2] == "S":
            print("0")
        else:
            print("1")
    else:
        if S[2] == "S":
            print("1")
        else:
            print("2")
else:
    if S[1] == "S":
        if S[2] == "S":
            print("1")
        else:
            print("1")
    else:
        if S[2] == "S":
            print("2")
        else:
            print("3")
  

Measured memory_bytes: 9132
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

void disp_table (map <char, char > t )
{
	int size = t.size();
	int i;

	map <char, char >::iterator it = t.begin();
	for (; it != t.end(); ++it){
		cout << (*it).first << ':' << (*it).second << endl;
	} // end for
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.dc", "r", stdin );
	string str = "";
	int n;

	while (getline (cin, str ) ){
		stringstream ssn(str);
		ssn >> n;
		if (n == 0 ){
			break;
		} // end if
		map <char, char > table;
		int i;

		for (i = 0; i < n; ++i){
			char src = 0, des = 0;
			getline (cin, str );
			stringstream ss(str);
			ss >> src >> des;
			table[src] = des;
		} // end for

//		disp_table (table );

		int m;
		getline (cin, str );
		stringstream ssm (str );
		ssm >> m;

		for (i = 0; i < m; ++i){
			char c;
			getline (cin, str );
			stringstream ssc (str );
			ssc >> c;
//			cout << " c: " << c; 
			map <char, char>::iterator it = table.find (c);
			if (it != table.end() ){
				cout << table[c];
			}else{
				cout << c;
			} // end if
		} // end for
		cout << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 932
# abc156_a.py
# https://atcoder.jp/contests/abc156/tasks/abc156_a

# A - Beginner /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 高橋君はプログラミングコンテストサイト「ButCoder」の会員です。
# ButCoder の会員には 2つのレーティング 内部レーティング と 表示レーティング が割り当てられています。
# 表示レーティングは、その会員のコンテスト参加回数が 10以上のときは内部レーティングに等しく、そうでないときは、
# 会員のコンテスト参加回数を K として、内部レーティングから 100×(10−K)を引いたものになります。
# 高橋君のコンテスト参加回数が Nで表示レーティングが Rであるとき、高橋君の内部レーティングを求めてください。

# 制約
#     入力は全て整数である
#     1≤N≤100
#     0≤R≤4111

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N R

# 出力

# 高橋君の内部レーティングを出力せよ。

# 入力例 1
# 2 2919

# 出力例 1
# 3719

# コンテスト参加回数が 10より少ない 2 であるため、内部レーティングから 100×(10−2)=800を
# 引いたものが高橋君の表示レーティングになっています。
# よって高橋君の内部レーティングは 2919+800=3719となります。

# 入力例 2
# 22 3051

# 出力例 2
# 3051


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    N, R = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    if N >= 10:
        result = R
    else:
        result = R + 100*(10-N)

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2 2919']
        lines_export = [3719]
    if pattern == 2:
        lines_input = ['22 3051']
        lines_export = [3051]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin >> N;
  vector<int> ans(N);
  for(int i=0; i<N-1; i++){
    int tmp;
    cin >> tmp;
    ans.at(tmp-1)++;
  }
  
  for(int i=0; i<N; i++){
    cout << ans.at(i) << endl;
    
  }
}

//cout << fixed << setprecision(10) << (long double)2*sum/(long double)N << endl;


Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int nth_bit(ll x, ll n){
    return (x>>n) & 1;
}

void add(ll & a, ll b) { a = (a+b) % mod; }

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

    ll N; cin >> N;
    ll dp[61][3] = {};

    dp[60][0] = 1;

    reprev(d, 60) rep(s, 3) rep(k, 3){
        int s2 = min(2, 2*s + nth_bit(N, d) - k);
        if(s2 >= 0) add(dp[d][s2], dp[d+1][s]);
    }

    cout << (dp[0][0] + dp[0][1] + dp[0][2]) % mod << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    int a[32] = {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};
    int k; cin >> k;
    cout << a[k-1] << endl;
    return 0;
}


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

int main() {
    int a[5], k;
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
    int f = 1;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            if (abs(a[i] - a[j]) > k) f = 0;
        }
    }
    cout << (f ? "Yay!" : ":(") << endl;
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import Data.Char


main :: IO ()
main = getLine >>= print . solve
solve :: String -> Int
solve = go 0
  where
    go !acc (s1:s2:s3:ss) = if s1 == s2
        then go (acc + 2) ss
        else go (acc + 1) (s2:s3:ss)
    go !acc (s1:s2:[]) = acc + if s1 == s2 then 1 else 2
    go !acc (s:[]) = acc + 1
    go !acc [] = acc


Measured memory_bytes: 9596
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int h, w;
const int maxN = 2005;
int tp[maxN][maxN];
int a[maxN][maxN];
int up[maxN][maxN];
int le[maxN], ri[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c;
            cin >> c;
            if (c == '.') tp[i][j] = 1;
            else tp[i][j] = 0;
        }
    }
    int best = max(h, w);
    for (int i = 0; i + 1 < h; i++) {
        for (int j = 0; j + 1 < w; j++) {
            a[i][j] = (tp[i][j] ^ tp[i + 1][j]) ^ (tp[i][j + 1] ^ tp[i + 1][j + 1]);
        }
    }
    h--;
    w--;
    const int INF = (int)1e9;
    for (int i = 0; i < h; i++) {
        vector < int > ups;
        for (int j = 0; j < w; j++) {
            if (a[i][j] == 1) {
                up[i][j] = 0;
            }
            else {
                if (i) up[i][j] = 1 + up[i - 1][j];
                else up[i][j] = 1;
            }
        }
        vector < pair < int, int > > st;
        st.emplace_back(-INF, -1);
        for (int j = 0; j < w; j++) {
            while (st.back().first > up[i][j]) st.pop_back();
            le[j] = st.back().second + 1;
            st.emplace_back(up[i][j], j);
        }
        st.clear();
        st.emplace_back(-INF, w);
        for (int j = w - 1; j >= 0; j--) {
            while (st.back().first >= up[i][j]) st.pop_back();
            ri[j] = st.back().second - 1;
            st.emplace_back(up[i][j], j);
        }
        for (int j = 0; j < w; j++) {
            int from = le[j];
            int to = ri[j];
            int sz = up[i][j];
            best = max(best, (to - from + 1 + 1) * (sz + 1));
        }
    }
    cout << best;
    return 0;
}

Measured memory_bytes: 47360
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int func(int a, int x){
	if(a == 0)return x;
	return -x;
}

char printer(int a){
	if(a == 0)return '+';
	return '-';
}

int main(){
	int x;
	cin>>x;
	int A,B,C,D;
	A = x / 1000;
	B = (x - A * 1000) / 100;
	C = (x - (A * 1000 + B * 100)) / 10;
	D = (x - (A * 1000 + B * 100 + C * 10));
	//cout<<A<<B<<C<<D;
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < 2; j++){
			for(int k = 0; k < 2; k++){
				if(A + func(i,B) + func(j, C) + func(k, D) == 7){
					cout<<A<<printer(i)<<B<<printer(j)<<C<<printer(k)<<D<<"=7"<<endl;
					return 0;
				}
			}
		}
	}
	return 0;
	
}

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

using namespace std;


int main()
{
  int N;
  string S;
  int dp[500001] = {};
  
  cin >> N;
  cin >> S;
  for(int i = 0; i < N; i++) {
    if(S[i] == '1') {
      if(i > 0 && S[i - 1] == '0') {
        for(int j = i - 2; j >= 0; j--) {
          if(S[j] == '0') break;
          dp[i + 1] = max(dp[i + 1], dp[j] + (i - 1) - j);
        }
      }
      if(i + 1 < N && S[i + 1] == '0') {
        for(int j = i + 2; j < N; j++) {
          if(S[j] == '0') break;
          dp[j + 1] = max(dp[j + 1], dp[i] + j - (i + 1));
        }
      }
    }
    dp[i + 1] = max(dp[i], dp[i + 1]);
  }

  cout << dp[S.size()] << endl;
}

Measured memory_bytes: 2820
n,m=map(int,input().split())
K=[list(map(int,input().split())) for _ in range(m)]
P=list(map(int,input().split()))

ans = 0

for bits in range(2 ** n):
    ok = True
    for i, k in enumerate(K):
        ok = ok and sum((bits >> (s - 1)) & 1 for s in k[1:]) % 2 == P[i]
    if ok:
        ans += 1
        

print(ans)


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

int main() {
    int N;
    cin >> N;
    int sum = 0;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        sum = sum ^ a[i];
    }
    
    for (int i = 0; i < N; i++)
    {
        int ans = sum ^ a[i];
        cout << ans << endl;
    }
    
  return 0;
}


Measured memory_bytes: 3968
word_list=[]
for i in range(97,123):
    word_list.append(chr(i))
for i in range(65,91):
    word_list.append(chr(i))
l_w_l=len(word_list)
while 1:
    n=int(input())
    if n==0:break
    li=list(map(int,input().split()))
    s=input()
    ans=""
    for i in range(len(s)):
        w_k=word_list.index(s[i])-li[i%n]
        while w_k<0:w_k+=l_w_l
        ans+=word_list[w_k]
    print(ans)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll a, b, c;

void solve(){
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << space << b << space << c << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const s: string[] = input[0].split('');
let ans: string = 'Yes';
const len: number = s.length;
for(let i = 0; i < len; i++){
    if (i % 2 === 0){
        if(s[i] === 'L'){
            ans = 'No';
        }
    }else{
        if(s[i] === 'R'){
            ans = 'No';
        }
    }
}
console.log(ans);

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

int main() {
	long long int n,m,a,b;
	cin>>n;
	string str;
	cin>>str;
	int cnt=0;
	int i=0;
	int j=str.size()-1;
	while(1){
		while (str[i]=='R'){
			i++;
			if (i==str.size()) break;
		}
		while(str[j]=='W'){
			j--;
			if (j==-1) break;
		}
		if (i<j){
			cnt++;
			i++;
			j--;
		}
		else{
			break;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
int n,a,sum;
std::bitset<4000010>f;
int main(){
	scanf("%d",&n);f[0]=1;
    for(;n;--n){scanf("%d",&a);sum+=a;f|=f<<a;}
	for(sum=(sum+1)>>1;!f[sum];++sum);
	printf("%d",sum);
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
  int N, Y;
  int x=-1,y=-1,z=-1;
  
  scanf("%d%d", &N, &Y);

  // 計算量(O^2)
  for (int i =0; i <= N;i++) {
    for (int j=0; j <= N; j++) {
      if (N - i - j >= 0 && (10000 * i) + (5000 * j) + (N - i - j) * 1000 == Y) {
        x = i;
        y = j;
        z = N - i - j;
        printf("%d %d %d",x,y,z);
        return 0;
      }
    }
  }

   
  printf("%d %d %d",x,y,z);
  return 0;
} 

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    CoutYn(a == b);
}

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

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

  string ab = string(b - '0', a);
  string ba = string(a - '0', b);

  if (ab < ba)
    cout << ab << endl;
  else
    cout << ba << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
    int i, N, M, list[51] = {0};
    scanf("%d %d", &N, &M);
    for ( i = 0; i < M; i++ ){
        int a, b;
        scanf("%d %d", &a, &b);
        list[a]++;
        list[b]++;
    }
    for ( i = 1; i <= N; i++ ){
        printf("%d\n", list[i]);
    }
    return 0;
}

Measured memory_bytes: 128
// *********************************************************************************
// *                        MURTAZA MUSTAFA KHUMUSI                                *
// *                        NIT-DGP,CSE - 2019-2023                                *
// *********************************************************************************

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007;
#define loop(i, a, n) for (int i = a; i < n; i++)
#define loop1(i, b, n) for (int i = b; i <= n; i++)
#define loopit(a) for (auto it = a.begin(); it != a.end(); it++)
#define ms(a, b) memset(a, b, sizeof(a))
#define pb(a) push_back(a)
#define MP make_pair
#define pi pair<int, int>
#define ff first
#define ss second
#define bloop(i, a, b) for (int i = a; i > b; i--)
#define bloop1(i, a, b) for (int i = a; i >= b; i--)
#define PQ priority_queue<int> pq;
#define vi vector<int>
#define MPQ priority_queue<pi, vector<int>, greater<pi>> mpq;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);
const int MAX = 1e6+1;
int factor[MAX];

void generatePrimeFactors()
{
    factor[1] = 1;

    // Initializes all the positions with their value.
    for (int i = 2; i < MAX; i++)
        factor[i] = i;

    // Initializes all multiples of 2 with 2
    for (int i = 4; i < MAX; i += 2)
        factor[i] = 2;

    for (int i = 3; i * i < MAX; i++)
    {
        // check if it has no prime factor.
        if (factor[i] == i)
        {
            // Initializes of j starting from i*i
            for (int j = i * i; j < MAX; j += i)
            {
                // if it has no prime factor before, then
                // stores the smallest prime divisor
                if (factor[j] == j)
                    factor[j] = i;
            }
        }
    }
}

// function to calculate number of factors
int calculateNoOFactors(int n)
{
    if (n == 1)
        return 1;

    int ans = 1;
    int dup = factor[n];
    int c = 1;
    int j = n / factor[n];
    while (j != 1)
    {

        if (factor[j] == dup)
            c += 1;
        else
        {
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;
        }

        // prime factorizes a number
        j = j / factor[j];
    }

    // for the last prime factor
    ans = ans * (c + 1);

    return ans;
}


void solve()
{
    int n;
    cin >> n;
    int ans = 0;
    generatePrimeFactors();
    loop(i,1,n){

       ans += calculateNoOFactors(n-i);

    } 
    cout << ans << "\n";
}
int main()
{

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    io;
    solve();

    return 0;
}


Measured memory_bytes: 7548
import java.util.*;
 
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in); 

        String S = sc.next();
        long K = sc.nextLong();
        sc.close();
        int pos = 0;
        while(pos < S.length()){
            if(S.charAt(pos) != '1'){
                if(K > pos)
                    System.out.println(S.charAt(pos));
                else
                    System.out.println(1);
                break;
            } else
                pos++;
            if(pos == S.length()){
                System.out.println(1);
            }
        }
    }
}

Measured memory_bytes: 22612
N = int(input())
x = list(map(int, input().split()))
xmin, xmax = min(x), max(x)
temp = []
res = xmax-xmin
for i in range(xmin, xmax+1):
	for n in range(N):
		temp.append(abs(x[n]-i))
	if max(temp)<res:
		res = max(temp)
	temp=[]

print(res)


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y=0;
	cin>>x;
	int b[x],j=0;
	for(int i=0;i<x;i++){
		int a;cin>>a;
		if(a!=i+1){
			y++;
			b[j]=a+i+1;
			j=j+1;
		}
	}
	if(y==2 || y==0){
		if(y==0){
			cout<<"YES";
		}
		else{
			if(b[0]==b[1]) cout<<"YES";
			else cout<<"NO";
		}
	}
	else cout<<"NO";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i,j;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ta=(c+b-1)/b;
	int tb=(a+d-1)/d;
	if(ta<=tb) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}

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

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

int main() {
  char in[120];
  pair<pair<string, int>, int> p[110];
  int a;
  
  scanf("%d", &a);
  
  for (int i = 0; i < a; i++) {
    int t;
    scanf("%s%d", in, &t);
    string tmp = in;
    p[i] = make_pair(make_pair(in, -t), i);
  }

  sort(p, p + a);
  for (int i = 0; i < a; ++i) printf("%d\n", p[i].second + 1);
  return 0;
}


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

int main() {
  
  int N;
  int sum=0;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);//値の入力
  }
 for(int i=0;i<N-1;i++){
   for(int j=i+1;j<N;j++){
     sum += vec.at(i)*vec.at(j);
   }
 }
 cout << sum << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split( ))
mod = 10**9+7

def chs(s,t,mod):
    nume =  1
    for i in range(s-t+1,s+1):
        nume *= i
        nume %= mod
    deno = 1
    for i in range(1,t+1):
        deno *= i
        deno %= mod
    deno = pow(deno,mod-2,mod)
    
    return (nume*deno%mod)
ans = 0

for i in range(k):
    x1 = chs(k, k-i, mod)
    #print("chs",x1)
    x2 = pow(k-i,n, mod)
    #print("pow",x2)
    ans += x1*x2*(-1)**i
print(ans%mod)


Measured memory_bytes: 5600
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int i, j, n, w;
    int[] v, vv;
    int[][] dp;
    n = sc.nextInt(); w = sc.nextInt();
    v = new int[n]; vv = new int[n]; dp = new int[n + 1][w + 1];
    for(i = 0;i < n;i++){
      v[i] = sc.nextInt(); vv[i] = sc.nextInt();
    }
    for(i = 0;i < n;i++)for(j = 0;j <= w;j++){
      if(dp[i + 1][j] < dp[i][j])dp[i + 1][j] = dp[i][j];
      if(j + vv[i] <= w && dp[i][j] + v[i] > dp[i + 1][j + vv[i]])
        dp[i + 1][j + vv[i]] = dp[i][j] + v[i];
    }
    out.println(dp[n][w]);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 31200
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N, M = map(int, input().split())
    logging.info("Hello!")

    if N == M:
        print("Yes")
    else:
        print("No")
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 4584
#include <bits/stdc++.h>
#define int long long int
#define MOD 1000000007
using namespace std;
void solve() {
        int n;
        cin >> n;
        cout << n*n*n << endl;
        return ;
}

int32_t main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        solve();
        return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 300000 + 5;
int a[N];

int main(){
	string s;
	cin >> s;
	int ans1 = 0,ans2 = 0;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == 'A')
			ans1++;
		else if(s[i] == 'B')
			ans2++;
	}
	if(!ans1 || !ans2)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[]) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int res = 0;
        for (int i=0; i<=N; i++) {
            String[] a = String.valueOf(i).split("");
            int tmp = 0;
            for (String b : a) {
                tmp += Integer.parseInt(b);
            }
            if (tmp >= A && tmp <= B) {
                res += i;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 32724
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
	int n;cin >> n;
	vector <int> v(n);
	for(int i=0; i<n; i++){
	 cin >> v[i];
	 v[i]--;
	}
	int cnt=0;
	int index=distance(v.begin(), find(v.begin(), v.end(), 0));
	while(cnt<=n){
		if(v[index]==1){
			cout << cnt << endl;
			return 0;
		}
	   // cout << cnt << " index is " << index << endl;
		cnt++;
		index = v[index];
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
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 ALL(v) v.begin(), v.end()
typedef long long ll;
using  pill = pair<int,ll>;
using  Graph = vector<vector<pill>>;

int main(){
    int N; cin >> N;
    Graph G(N);
    rep(i,N-1){
        int from,to,cost;
        cin >> from >> to >> cost;
        from--; to--;
        G[from].emplace_back(pill(to,cost));
        G[to].emplace_back(pill(from,cost));
    }

    vector<ll> dist(N,-1);
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        rep(i,G[v].size()){
            int u = G[v][i].first;
            int w = G[v][i].second;
            if(dist[u] != -1) continue;
            dist[u] = (dist[v] + w) % 2;
            que.push(u);
        }
    }   
    rep(i,N){
        if(dist[i] % 2 == 0) cout << "0" << endl;
        else cout << "1" << endl;
    }
}


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

int main(void){
    
    while(1) {
        int n;
        cin >> n;
        if (n==0) break;
        int stone[21][21];
        for(int y=0; y<21; y++){
            for(int x=0; x<21; x++){
                stone[y][x] = 0;
            }
        }
        for(int i=0; i<n; i++){
            int x, y;
            cin >> x >> y;
            stone[y][x] = 1;
        }
        int m;
        int x=10, y=10;
        cin >> m;
        for(int i=0; i<m; i++){
            char d;
            int l;
            cin >> d;
            cin >> l;
            for(int j=0; j<l; j++) {
                if(d=='N'){ y++; }
                if(d=='E'){ x++; }
                if(d=='S'){ y--; }
                if(d=='W'){ x--; }
                if(stone[y][x] == 1) {
                    stone[y][x] = 0;
                    n--;
                }
           }
        }
        cout << (n==0 ? "Yes" : "No") << endl;
        
    }
    
}

Measured memory_bytes: 1152
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
a.sort(reverse=True)
print(sum(a[::2]) - sum(a[1::2]))


Measured memory_bytes: 38384