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

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

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll re=0;
  while(*max_element(all(a))>=n){
    ll mn=*min_element(all(a));
    if(mn>=n){
      re+=(mn-(n-1ll))*n;
      rep(i,n) a[i]-=mn-(n-1);
    }
    rep(i,n)if(a[i]>=n){
      rep(j,n)if(i!=j) a[j]+=a[i]/n;
      re+=a[i]/n;
      a[i]%=n;
    }
 }
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
cards_number = input()
numbers = list(map(int, cards_number.split()))
ordered_numbers = sorted(numbers, reverse=True)

even_indexes = list(num for num in range(0, N) if num % 2 == 0)
odd_indexes = list(num for num in range(0, N) if num % 2 == 1)
alice_cards = list(ordered_numbers[even_index] for even_index in even_indexes)
bob_cards = list(ordered_numbers[odd_index] for odd_index in odd_indexes)

alice_point = sum(alice_cards)
bob_point = sum(bob_cards)

print(alice_point-bob_point)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}


bool solve(){
  ll n;cin>>n;
  vector<ll>f(n+1);
  for(ll i=1;i<=n;i++){
    ll num=i;
    while(num<=n){
      f[num]++;
      num+=i;
    }
  }
  ll ans=0;
  rep(i,n+1)ans+=f[i]*i;
  cout<<ans<<endl;

  return false;
}

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


Measured memory_bytes: 81340
#n = int(input())
#s = input()
n,x = map(int,input().split())
da = list(map(int,input().split()))
m = 100010
mod = 1000000007

dp = [0 for i in range(m)]
da.sort()
da.reverse()
dp[x] = 1
for i in range(n):
    for j in range(m):
        if j >= da[i]:
            dp[j%da[i]] += dp[j]
            dp[j] *= n-i-1
            if dp[j] >= mod: dp[j] %= mod
            if dp[j%da[i]] >= mod: dp[j] %= mod
        else:
            dp[j] *= n-i
            if dp[j] >= mod: dp[j]%=mod
ans = 0
for i in range(m):
    ans += dp[i] * i
    if ans >= mod: ans %= mod
print(ans)


Measured memory_bytes: 45040
#include <iostream>
#include <vector>
#include <climits>
using namespace std;

class Town
{
public:
	Town() : totalCost( 0 ), isGoal( false ), isThrough( false ){}
	~Town(){}

	void clear(){
		totalCost = 0;
		isGoal = false;
		isThrough = false;
	}

	vector< pair< int, int > > routes;
	int totalCost;
	bool isGoal;
	bool isThrough;
};

int startToGoal( Town* towns, int start, int goal )
{
	int move = start;
	towns[ goal ].isGoal = true;
	vector< pair< int, pair< int, int > > > gotoList;

	while( !towns[ move ].isGoal ){
		towns[ move ].isThrough = true;
		int count = towns[ move ].routes.size();
		for( int i = 0; i < count; ++i ){
			gotoList.push_back( make_pair( move, towns[ move ].routes[ i ] ) );
		}
		int minCost = INT_MAX;
		int here, go, c;
		vector< pair< int, pair< int, int > > >::iterator itr = gotoList.begin();
		while( itr != gotoList.end() ){
			here = itr->first;
			go = itr->second.first;

			if( towns[ go ].isThrough ){
				itr = gotoList.erase( itr );
				continue;
			}

			c = towns[ here ].totalCost + itr->second.second;
			if( c < minCost ){
				minCost = c;
				move = go;
			}
			++itr;
		}
		towns[ move ].totalCost = minCost;
	}
	return towns[ move ].totalCost;
}

int main()
{
	int n, m;
	int a, b, c, d;
	int bugget, cost;
	int home, turn;

	cin >> n;
	cin >> m;

	Town* towns = new Town[ n + 1 ];

	char dummy;
	for( int i = 0; i < m; ++i ){
		cin >> a >> dummy >> b >> dummy >> c >> dummy >> d;
		towns[ a ].routes.push_back( make_pair( b, c ) );
		towns[ b ].routes.push_back( make_pair( a, d ) );
	}

	cin >> home >> dummy >> turn >> dummy >> bugget >> dummy >> cost;

	cost += startToGoal( towns, home, turn );

	for( int i = 0; i < n + 1; ++i ){
		towns[ i ].clear();
	}

	cost += startToGoal( towns, turn, home );

	cout << bugget - cost << endl;

	delete[] towns;

	return 0;
}

Measured memory_bytes: 1196
import java.io.*;
import java.util.*;
//import java.util.stream.*;
//import java.math.*;

public class Main {

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long num = 1;
        for (int i = 1; i <= n; i++) {
            num = (long) (num * i % (Math.pow(10, 9) + 7));
        }
        System.out.println(num);
        bw.flush();
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int max1=0;
    int max2=0;
    map<int,int> P1;
    map<int,int> P2;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(i%2==0){
            P1[a]++;
        }
        else{
            P2[a]++;
            max2=max(max2,a);
        }
    }
    vector<int> s1;
    vector<int> s2;
    int ans1=0;
    int ans2=0;
    for(auto x:P1){
        if(x.second>ans1){max1=x.first;ans1=x.second;}
        s1.push_back(x.second);
    }
    for(auto x:P2){
        if(x.second>ans2){max2=x.first;ans2=x.second;}
        s2.push_back(x.second);
    }
    s1.push_back(0);
    s2.push_back(0);
    sort(s1.begin(),s1.end(),greater<>());
    sort(s2.begin(),s2.end(),greater<>());
    if(max1!=max2){
        cout<<n-s1[0]-s2[0]<<endl;
    }
    else{
        cout<<n-max(s1[0]+s2[1],s2[0]+s1[1])<<endl;
    }
}


Measured memory_bytes: 5504
#include	<iostream>
#include	<unordered_set>

using namespace std;

int		n;
int		A[20] = { 0 };
unordered_set<int>		us;

void calc(int m, int sum)
{
	if (m == n)
	{
		us.insert(sum);
	}
	else
	{
		calc(m + 1, sum);
		calc(m + 1, sum + A[m]);
	}
}

int main()
{
	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		cin >> A[i];
	}

	calc(0, 0);

	int		m;
	int		ans;
	cin >> m;

	for (int i = 0; i < m; i++)
	{
		cin >> ans;
		if (us.find(ans) == end(us))
		{
			cout << "no\n";
		}
		else
		{
			cout << "yes\n";
		}
	}

	return 0;
}

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

#define endl '\n'

using namespace std;

const int N = (int)(2e5) + 3;

string s;
int n;

int dp[N][3];

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

    cin >> s;
    n = (int)s.size();

    if(n == 1) {
        cout << 1 << endl;
        return 0;
    }

    dp[0][1] = 1;
    dp[0][2] = INT_MIN;
    dp[1][1] = (s[0] != s[1] ? 2 : INT_MIN);
    dp[1][2] = 1;

    for(int i = 2; i < n; ++i) {
        for(int clen = 1; clen <= 2; ++clen) {
            string curr = s.substr(i - clen + 1, clen);
            string old1 = (i - clen - 1 >= 0 ? s.substr(i - clen - 1, 2) : curr);
            string old2 = s.substr(i - clen, 1);

            if(curr != old1) dp[i][clen] = max(dp[i][clen], 1 + dp[i - clen][2]);
            if(curr != old2) dp[i][clen] = max(dp[i][clen], 1 + dp[i - clen][1]);
        }
    }

    cout << max(dp[n - 1][1], dp[n - 1][2]) << endl;

    return 0;
}


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

int main() {
  double W,H,x,y;
  cin>>W>>H>>x>>y;
  cout<<setprecision(10)<<W*H/2<<' ';
  if(x==W/2&&y==H/2)cout<<1<<endl;
  else cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 256
alpha = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
strings = [input() for _ in range(n)]
available = {a: 100 for a in alpha}
for s in strings:
    for a in alpha:
        available[a] = min(available[a], s.count(a))
cands = []
for a, i in available.items():
    cands += [a]*i
ans = ''.join(sorted(cands))
print(ans)

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

int main()
{
	long long int N, ans = 0,ab=0,ac=0;

	cin >> N;

	vector<int>A(N), B(N), C(N);

	for (int n = 0; n < N; n++)
		scanf("%d", &A[n]);

	for (int n = 0; n < N; n++)
		scanf("%d", &B[n]);

	for (int n = 0; n < N; n++)
		scanf("%d", &C[n]);

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	for (int n = 0; n < N; n++,ab = 0,ac = 0) {

		ab = lower_bound(A.begin(), A.end(), B[n]) - A.begin();
		ac = C.end() - upper_bound(C.begin(), C.end(), B[n]);

		ans += ab*ac;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<iomanip>;

const int INF = 1001001001;
vector<int>to[100005];

int main() {
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	queue<int>q;
	vector<int>dist(n, INF);
	vector<int>pre(n, -1);
	dist[0] = 0;
	q.push(0);
	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (int u : to[v]) {
			if (dist[u] != INF)continue;
			dist[u] = dist[v] + 1;
			pre[u] = v;
			q.push(u);
		}
	}
	cout << "Yes" << endl;
	rep(i, n) {
		if (i == 0) {
			continue;
		}
		int ans = pre[i];
		++ans;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 10612
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int N, K;
	string S;
	
	cin >> N >> S >> K;
	
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != S[K - 1]) {
			S[i] = '*';
		}
	}
	
	cout << S << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] c = new int[3,3];

            for(int i = 0; i < 3; i++)
            {
                var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                c[i, 0] = input[0];
                c[i, 1] = input[1];
                c[i, 2] = input[2];
            }

            var x = c[0, 0] + c[1, 1] + c[2, 2];
            var y = c[1, 0] + c[2, 1] + c[0, 2];
            var z = c[2, 0] + c[0, 1] + c[1, 2];

            if (x == y && y == z)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 28256
t,*s=input().split('T')
x,y=map(int,input().split())
dx,dy={len(t)},{0}
for a in map(len,s[1::2]):dx=set(t+a for t in dx)|set(t-a for t in dx)
for b in map(len,s[::2]):dy=set(t+b for t in dy)|set(t-b for t in dy)
if x in dx and y in dy:print('Yes')
else:print('No')

Measured memory_bytes: 4956
#include <bits/stdc++.h>
using namespace std;
#define el "\n"
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define M 1000000007
#define all(v) v.begin(), v.end()
ll FindLCM(ll a, ll b) 
{ 
    return (a * b) / __gcd(a, b); 
} 
ll ppm(ll m, ll n, ll a, ll b) 
{ 
    // Find LCM of a and b 
    ll lcm = FindLCM(a, b); 
  
    ll a_divisor = n / a - (m - 1) / a; 
    ll b_divisor = n / b - (m - 1) / b; 
  
    // Find common divisor by using LCM 
    ll common_divisor = n / lcm - (m - 1) / lcm; 
  
    ll ans = a_divisor + b_divisor - common_divisor; 
    return ans; 
} 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a,b,c,d,a1,a2,a3,b1,b2,b3;
  cin>>a>>b>>c>>d;
  ll ans=0;
  ans=ppm(a,b,c,d);
  cout<<(b-a+1)-ans<<el;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define int long long

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

    int n, m;
    cin >> n >> m;

    vector<int> s(m), c(m);
    for (int i = 0; i < m; i++)
        cin >> s[i] >> c[i];

    string ans = string(n, 'X');

    for (int i = 0; i < m; i++)
    {
        if (ans[s[i] - 1] == 'X')
        {
            ans[s[i] - 1] = c[i] + '0';
        }
        else if (ans[s[i] - 1] != c[i] + '0')
        {
            ans = "-1";
            break;
        }
    }

    if (n <= 1 && ans[0] == 'X')
        ans = "0";
    if (n > 1 && ans[0] == '0')
        ans = "-1";
    if (ans[0] == 'X')
        ans[0] = '1';

    for (auto &&i : ans)
    {
        if (i == 'X')
            i = '0';
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define PI 3.14159265359
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<int> Eratosthenes(const int N)
{
    vector<bool> is_prime(N+1, true);
    vector<int> P;
    for(int i=2; i<=N; i++) {
        if (is_prime[i]) {
            for(int j=2*i; j<=N; j+=i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}
 
int main() {
    ll n;
    cin >> n;
    map<string,ll> mp;
    string s;
    rep(i,n) {
        cin >> s;
        sort(all(s));
        mp[s]++;
    }
    ll cnt = 0;
    for(auto x:mp) {
        cnt += x.second*(x.second-1)/2;
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    ll A, B, C;
    cin >> A >> B >> C;

    // 例外処理
    if (A % 2 == 0 && B % 2 == 0 && C % 2 != 0)
    {
        cout << "NO" << endl;
        return 0;
    }

    ll temp = A;
    for (ll i = 2;; i++)
    {
        A = temp * i;
        if (A > INF)
        {
            cout << "NO" << endl;
            break;
        }
        else if (A % B == C)
        {
            // printf("%d %d = %d\n", i, B, C);
            cout << "YES" << endl;
            break;
        }
    }
    // cout << "No" << endl;
    return (0);
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n)　for(int i=(k);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    return (x*y);
}

#define WA printf("WA\n");
int main()
{
    ll n,max=0;
    ss s;
    cin >> n >> s;

    for(ll i=1;i<n;i++){
        ll count = 0;
        for(char c='a';c<='z';c++){
            bool r=false,l=false;
            rep(j,i)
                if(s[j] == c)r=true;
            for(ll j=i;j<n;j++)
                if(s[j] == c)l=true;

            if(r == true && l == true)count++;
        }

        if(max <= count)max=count;
    }

    cout << max << endl;
    return 0;
}


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

int main(){
  int x_0,x_i,y_0,y_i;cin>>x_0>>y_0>>x_i>>y_i;
  int delta_x = x_i - x_0;
  int delta_y = y_i - y_0;
  x_i = x_i - delta_y;
  y_i = y_i + delta_x;
  cout << x_i << ' ' << y_i << ' ';
  x_i = x_i - delta_x;
  y_i = y_i - delta_y;
  cout << x_i << ' ' << y_i << ' ';
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

int N;
int A[110];
int F[110];
vector<int> V,V2,V3;

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
		V2.push_back(A[i]);
	}
	REP(i,N){
		int c=-1;
		REP(j,V2.size()){
			if(V2[j]==j+1){
				c=j;
			}
		}
		if(c==-1){
			cout<<-1<<endl;
			return 0;
		}
		V.push_back(V2[c]);
		V2.erase(V2.begin()+c);
	}
	reverse(V.begin(),V.end());
	REP(i,V.size()){
		cout<<V[i]<<endl;
	}
	return 0;
}


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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
using Graph = vector<vector<char>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}


int main(){
  int N,A,B;
  cin >> N >> A >> B;
  if((B-A-1)%2) cout << "Alice" << endl;
  else cout << "Borys" << endl;
}

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

int main() {
    int tsc,a1=0,a2=0,a3=0,a4=0;
    string s;
    cin >> tsc;
    while(tsc--)
    {
        cin >> s;
        if(s=="AC")
            a1++;
        else if(s=="WA")
            a2++;
        else if(s=="TLE")
            a3++;
        else
            a4++;
    }
    cout << "AC x " << a1 << "\n";
    cout << "WA x " << a2 << "\n";
    cout << "TLE x " << a3 << "\n";
    cout << "RE x " << a4;
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
std::string S, T;
int s[100010], t[100010];
int q;
int main() {
	std::cin >> S >> T >> q;
	for (int i = 0; i < S.size(); i++) {
		s[i + 1] += s[i];
		s[i + 1]++;
		if (S[i] == 'B')s[i + 1]++;
	}
	for (int i = 0; i < T.size(); i++) {
		t[i + 1] += t[i];
		t[i + 1]++;
		if (T[i] == 'B')t[i + 1]++;
	}
	for (int i = 0; i < q; i++) {
		int a, b, c, d;
		std::cin >> a >> b >> c >> d;
		int sa = (s[b] - s[a - 1]) % 3;
		int ta = (t[d] - t[c - 1]) % 3;
		std::cout << (sa == ta ? "YES" : "NO") << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1664
def solve(N, Ss):
    a = 0
    b = 0
    both = 0
    ans = 0
    for s in Ss:
        ans += s.count("AB")
        if s[-1] == "A" and s[0] == "B":
            both += 1
        else:
            if s[-1] == "A":
                a += 1
            if s[0] == "B":
                b += 1

    if both > 0:
        ans += both - 1

    if both > 0 and a > 0:
        ans += 1
        a -= 1

    if both > 0 and b > 0:
        ans += 1
        b -= 1

    ans += min(a, b)
    return ans

if __name__ == "__main__":
    N = int(input())
    Ss = [input() for _ in range(N)]
    print(solve(N, Ss))


Measured memory_bytes: 3700
n = int(input())
d = [0]*n

for i in range(n):
  d[i] = input().split()
  
c = 0

for i in range(n):
  #print(c)
  if d[i][0] == d[i][1]:
    c += 1
    if c == 3:
      print("Yes")
      exit()
  else:
    c = 0

print("No")

Measured memory_bytes: 62180
#include <stdio.h>

typedef enum {false, true} bool;


bool trace(long long xy[][2], long long basis, long long xor_basis, int N, int num, int ctr, int index)
{
    int i, j;
    static int record[15];
    static bool flag;
    
    
    if(num == ctr)
    {
        flag = true;
        xor_basis = xor_basis ^ basis;
        
        for(i=0; i<num; i++)
        {
            if((xy[record[i]][1] & basis) != basis || ((xy[record[i]][0] ^ xor_basis) & xor_basis) != xor_basis)
            {
                flag = false;
                
                break;
            }
        }
    }
    else
    {
        for(j=index; j<=N-(num-ctr); j++)
        {
            if(ctr == 0)
                basis = 0;
            
            record[ctr] = j;
            
            if(trace(xy, basis | 1<<(N-j-1), xor_basis, N, num, ctr+1, j+1))
                return true;
        }
    }
    
    if(flag)
        return true;
    else
        return false;
}

int main(void)
{
    char c;
    int N;
    int A, x, y;
    
    long long xy[15][2], temp, temp2;
    
    int i, j;
    
    
    scanf("%d%c", &N, &c);
    
    
    for(i=0; i<N; i++)
    {
        scanf("%d%c", &A, &c);
        
        xy[i][0] = 1<<(N-i-1);
        
        xy[i][1] = 1;
        for(j=1; j<N; j++)
            xy[i][1] = xy[i][1]<<1 | 1;
        
        temp = xy[i][1];
        
        for(j=0; j<A; j++)
        {
            scanf("%d%c%d%c", &x, &c, &y, &c);
            
            if(y == 0)
            {
                temp2 = temp ^ 1<<(N-x);
                xy[i][1] &= temp2;
            }
            if(y == 1)
                xy[i][0] |= 1<<(N-x);
        }
    }
    
    for(i=N; i>0; i--)
    {
        if(trace(xy, 0, temp, N, i, 0, 0))
            break;
    }
    
    
    printf("%d\n", i);
    
    
    /**/system("pause");
    
    return 0;
}


Measured memory_bytes: 376
while True:
    a, op, b = raw_input().split()
    if op == "?":
        break
    else:
        if op == '+':
            print int(a) + int(b)
        elif op == '-':
            print int(a) - int(b)
        elif op == '*':
            print int(a) * int(b)
        elif op == '/':
            print int(a) / int(b)
        else:
            print "error"

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

int main(){
    vector<int>  A(3) ;
    rep(i,3) cin >> A.at(i) ;
    sort(A.begin(),A.end()) ;
    cout << A.at(0)+A.at(1) << endl;
}
 

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


int main()
{
 int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    long long int res=0;
    for(int i=1;i<n;i++)
    {
      if(arr[i]<arr[i-1])
      {
            res+=arr[i-1]-arr[i];
             arr[i]=arr[i-1];
      }    
    }
    cout<<res<<endl;
  
}

Measured memory_bytes: 4392
#include<iostream>
int main(void){
    int n,ans=1;
    scanf("%d",&n);
    char s[n];
    scanf("%s",&s);
    for(int i=0;i<=n-2;i++){
        if(s[i]!=s[i+1]){ans++;}
    }
    printf("%d",ans);
}

Measured memory_bytes: 384
<?php
$numbers = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
$n = intval($numbers[0]);
$q = intval($numbers[1]);
$n = decbin($n);
$q = decbin($q);

for ($i = strlen($n); $i <= 31; $i++) { 
    $n = '0' . $n;
}
for ($i = strlen($q); $i <= 31; $i++) { 
    $q = '0' . $q;
}

$n1 = '';
for ($i = 0; $i < strlen($n); $i++) { 
    if(substr($n, $i, 1) == 1 && substr($q, $i, 1) == 1){
        $n1 .= '1';
    } else {
        $n1 .= '0';
    }
}

for ($i = strlen($n1); $i <= 31; $i++) { 
    $n1 = '0' . $n1;
}
print $n1;
print "\n";

$n2 = '';
for ($i = 0; $i < strlen($n); $i++) { 
    if(substr($n, $i, 1) == 1 || substr($q, $i, 1) == 1){
        $n2 .= '1';
    } else {
        $n2 .= '0';
    }
}

for ($i = strlen($n2); $i <= 31; $i++) { 
    $n2 = '0' . $n2;
}
print $n2;
print "\n";

$n3 = '';
for ($i = 0; $i < strlen($n); $i++) { 
    if(substr($n, $i, 1) == 0 && substr($q, $i, 1) == 1){
        $n3 .= '1';
    } else if (substr($n, $i, 1) == 1 && substr($q, $i, 1) == 0){
        $n3 .= '1';
    } else {
        $n3 .= '0';
    }
}

for ($i = strlen($n3); $i <= 31; $i++) { 
    $n3 = '0' . $n3;
}
print $n3;
print "\n";


Measured memory_bytes: 9384
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

int par[1001];
int curr[1001];

void init(){
	for(int i=0;i<=1000;i++){
		par[i] = i;
		curr[i] = -1;
	}
}

bool isSat(string question,map<int,string>& name,map<string,int>& num){
	string str;
	stringstream ss(question);
	vector<string> v;
	while(ss >> str){
		v.push_back(str);
	}

	string X = v[0];
	string Y = v[5].substr(0,v[5].size()-1);

	//X is a child of Y.
	//X is the parent of Y.
	//X is a sibling of Y.
	//X is a descendant of Y.
	//X is an ancestor of Y.

	if(v[3] == "child"){
		return (par[num[X]] == num[Y] && num[Y] != -1);
	}
	else if(v[3] == "parent"){
		return (par[num[Y]] == num[X] && num[X] != -1);
	}
	else if(v[3] == "sibling"){
		return (par[num[Y]] == par[num[X]] && par[num[X]] != -1);
	}
	else if(v[3] == "ancestor"){
		while(par[num[Y]] != -1){
			Y = name[par[num[Y]]];
			if(X == Y) return true;
		}
		return false;
	}
	else if(v[3] == "descendant"){
		while(par[num[X]] != -1){
			X = name[par[num[X]]];
			if(X == Y) return true;
		}

		return false;
	}

	return false;
}

int main(){
	string str;

	while(getline(cin,str)){
		init();
		stringstream ss(str);
		ss >> str;
		int n = atoi(str.c_str());
		ss >> str;
		int m = atoi(str.c_str());


		if(n==0 && m==0) break;

		map<int,string> name;
		map<string,int> num;

		for(int i=0;i<n;i++){
			getline(cin,str);

			
			int j=0;
			while(str[j] == ' ') j++;
			name[i] = str.substr(j,str.size()-j);
			num[str.substr(j,str.size()-j)] = i;

			if(j==0){
				par[i] = -1;
			}
			else par[i] = curr[j-1];
			//cout << str << endl;

			curr[j] = i;
		}

		for(int i=0;i<m;i++){
			getline(cin,str);
			if(isSat(str,name,num)){
				printf("True\n");
			}
			else{
				printf("False\n");
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 1440
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, result = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++) {
        if (c % i == 0){
            result++;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int k = sc.nextInt();

		int sum = 0;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			sum += k - x < x ? (k - x) * 2 : x * 2;
		}
		System.out.println(sum);
		sc.close();
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
vector<int>tab[2011];
int cnt[2011][2];//0表示mdep,1表示mdep+1
int n,k; 
void dfs(int fa,int now,int dep,int mdep)
{
	int sz=tab[now].size();
	cnt[now][0]=cnt[now][1]=0;
	for(int i=0;i<sz;++i)
	{
		if(tab[now][i]!=fa)
		{
			dfs(now,tab[now][i],dep+1,mdep);
			cnt[now][0]+=cnt[tab[now][i]][0];
			cnt[now][1]+=cnt[tab[now][i]][1];
		}
	}
	if(dep>mdep)cnt[now][0]++;
	if(dep>mdep+1)cnt[now][1]++;
}
int solve(int x)
{
	dfs(x,x,0,k/2);
	if(k%2==1)
	{
		int sz=tab[x].size();
		int minans=999999999;
		for(int i=0;i<sz;++i)
		{
			minans=min(minans,cnt[x][0]-cnt[tab[x][i]][0]+cnt[tab[x][i]][1]);
		}
		return minans;
	}else
	{
		return cnt[x][0];
	}
	
} 
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;++i)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		tab[a].push_back(b);
		tab[b].push_back(a);
	}
	int ans=99999999;
	for(int i=1;i<=n;++i)
	{
		ans=min(ans,solve(i)); 
	}
	printf("%d",ans);
	return 0; 
}

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

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
int main() {
 
	string s;
	cin >> s;
	deque<char> st;
	for (int i=0; i<s.size(); i++) st.push_back(s[i]);
	
	int q;
	
	bool fw = true;
	
	cin >> q;
	for (int i=0; i<q; i++) {
		int a;
		cin >> a;
		if (a == 1) {
			fw = 1 - fw;
		}
		else {
			int a;
			string x;
			cin >> a >> x;
			if ((a == 1 && fw) || (a == 2 && !fw)) {
				st.push_front(x[0]);
			}
			else {
				st.push_back(x[0]);
			}
		}
	}
	
	if (fw) {
		
		for (int i=0; i<st.size(); i++) {
			cout << st[i];
		}
		cout << endl;
	}
	
	else {
		for (int i=st.size()-1; i>=0; i--) {
			cout << st[i];
		}
		cout << endl;
	}
 
}


Measured memory_bytes: 896
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        int min = Integer.MAX_VALUE;
        for(int i = 1; i<n; i++) {
            int a1 = 0;
            int b1 = 0;
            for(int j = 0; j<n; j++) {
                if(j<i) a1 += a[j];
                else b1 += a[j];
            }
            min = Math.min(min, Math.abs(a1-b1));
        }

        System.out.println(min);


    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int n,k; cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  int g = a[0];
  int ma = a[0];
  for(int i = 1; i<n;i++){
    g = gcd(g,a[i]); chmax(ma,a[i]);
  }
  
  //printf("%d %d",g,ma);
  if(k%g == 0 && ma >= k) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return 0;
}

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

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

int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i,n) cin >> a[i];
    int g = a[0];
    for(int i = 1; i < n; i++) g = gcd(g,a[i]);
    bool can = false;
    rep(i,n){
        if(a[i]-k >= 0 && !((a[i]-k) % g)) can = true;
    }
    cout << (can? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}


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

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    cout << ((e - a > k) ? ":(" : "Yay!") << endl;
}


Measured memory_bytes: 256
import math
K=int(input())
total = 0

for a in range(1,K+1):
  for b in range(a+1,K+1):
    for c in range(b+1,K+1):
      total += math.gcd(a, math.gcd(b,c) ) * 6
      
for a in range(1,K+1):
  for b in range(a+1,K+1):
    total += math.gcd(a, b)*6

for a in range(1,K+1):
  total += a

print(total)


Measured memory_bytes: 9196
#include<iostream>
#include<algorithm>
#include<vector>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <cmath>
#include <unordered_set>
#include <sstream>
#define Endl endl
#define inf 0x3f3f3f3f
 
using namespace std;
typedef long long  ll;
 
const double pi=acos(-1);
ll GCD(ll a,ll b){return b==0?a:GCD(b,a%b);}




int main(){
    
    int n;cin>>n;
    int a,b;cin>>a>>b;
    int f=0;
    for (int i=1; i<=1000; i++) {
        if (i*n>=a&&i*n<=b) {
            f=1;
            break;
        }
        
    }
    if (f) {
        cout<<"OK"<<endl;
    }else cout<<"NG"<<endl;
  
    
    return 0;
    
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <set>

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<string>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
using namespace std;

int main(void){
  int n, c;
  cin>>n>>c;
  vector<vi > tl(c,vi(100000));
  int tm = 0;
  rep(i,n){
    int s,t,ch;
    cin>>s>>t>>ch;
    ch --; s --; tm = max(t,tm);
    loop(j,max(s,0),t)tl[ch][j] = 1;
  }

  for(int i = c-1 ; i >= 0 ; i --){
    rep(j,tm){
      if(tl[i][j] == 1){
        rep(k, i){
          if(tl[k][j] == 0){
            tl[k][j] = 1;
            tl[i][j] = 0;
            break;
          }
        }
      }
    }
  }
  int ret = 0;
  rep(i,c){
    bool f = false;
    rep(j,tm)f += tl[i][j];
    ret += f;
  }
  cout<<ret<<endl;
}

Measured memory_bytes: 12416
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, N, L);
    i64 sum = 0;
    rep(i, 0, N) { sum += L + i; }

    i64 ans = 0;
    i64 diff = INF;
    rep(i, 0, N) {
        const i64 a = sum - (L + i);
        if (abs(sum - a) < diff) {
            diff = abs(sum - a);
            ans = a;
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  vector<int> P(N), Q(N), A(N);
  REP(i, N) cin >> P[i];
  REP(i, N) cin >> Q[i];
  for (int i = 1; i <= N; i++) A[i - 1] = i;
  int p, q;
  int cnt = 1;
  do {
    bool t = true;
    REP(i, N) {
      if (A[i] != P[i]) t = false;
    }
    if (t) p = cnt;
    t = true;
    REP(i, N) {
      if (A[i] != Q[i]) t = false;
    }
    if (t) q = cnt;
    cnt++;
  } while (next_permutation(A.begin(), A.end()));
  cout << abs(p - q) << endl;
}

Measured memory_bytes: 256
# by the authority of GOD     author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase

def main():
    n = int(input())
    maxi_pl = 0
    mini_pl = 10**10
    maxi_mi = -10**10
    mini_mi = 10**10
    for _ in range(n):
        x,y = map(int,input().split())
        maxi_pl = max(maxi_pl,x+y)
        mini_pl = min(mini_pl,x+y)
        maxi_mi = max(maxi_mi,x-y)
        mini_mi = min(mini_mi,x-y)
    print(max(maxi_pl-mini_pl,maxi_mi-mini_mi))

#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 89092
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def fac(n):
    if n== 1 or n == 0:
        return 1
    return n * fac(n-1)

def comb(n, k):
    if k >n:
        return 0
    return fac(n)/(fac(k) * fac(n-k))

def solve():
    n, a, b = f()
    v = f()
    
    v = sorted(v, reverse = True)

    c = v[a-1]

    cnt1 = 0
    total = 0

    for i in range(n):
        if v[i] == c:
            total += 1
            if i < a:
                cnt1 += 1


    print("{:.7f}".format(sum(v[0:a])/a))
    if v[0] == c:
        ans = 0
        for i in range(a, b+1):
            ans += comb(total, i)
        print(int(ans))
    else:
        print(int(comb(total, cnt1)))

solve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
          string s[]= {"Sunny","Cloudy","Rainy"};
          string t;
          cin>>t;
          if(t[0]=='S')
          {
              cout<<s[1]<<endl;
          }
          else
            if(t[0]=='C')
            {
              cout<<s[2]<<endl;
            }
          else
          { 
            cout<<s[0]<<endl;
          }
      
    }

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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long
const int INF = 1000000000;
const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

typedef pair<int, int> P;

int main() {
    int H, W; cin >> H >> W;
    char field[H][W];
    ll d[H][W];
    int dx[2] = { 0, 1 }, dy[2] = { 1, 0 };

    queue<P> que;

    rep(i, H) rep(j, W) {
        d[i][j] = INF;
        cin >> field[i][j];
    }

    que.push(P(0, 0));
    d[0][0] = 0;

    while(que.size()) {
        P p = que.front(); que.pop();

        rep(i, 2) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
            ll distance = d[p.first][p.second] + 1;
            if (nx < H && ny < W) {
                if (field[p.first][p.second] == '#' && field[nx][ny] == '.') ++distance;

                if (distance < d[nx][ny]) {
                    que.push(P(nx, ny));
                    d[nx][ny] = distance;
                }
            }
        }
    }

    if (field[H-1][W-1] == '#') d[H-1][W-1]++;

//    rep(i, H) {
//        rep(j, W) {
//            cout << d[i][j];
//        }
//        cout << endl;
//    }

    cout << d[H-1][W-1] - (H-1) - (W-1) << endl;
}


Measured memory_bytes: 384
N = int(input())

div = []
i = 1
while i * i <= N:
    if N % i == 0:
        div.append(i)
    if N // i != i:
        div.append(N // i)
    i += 1
div.sort()
prev = 0
ans = 0
for d in div:
    m = N // d - 1
    if m > 0 and N // m == N % m:
        ans += m

print(ans)


Measured memory_bytes: 99948
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int s, w;
	cin >> s >> w;
	if (w >= s)
		cout << "unsafe" << endl;
	else
		cout << "safe" << endl;
}



Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)==3 && a>=1&& a<=9&& b>=1&&b<=9&& c>=1&&c<=9)
    {if(a<b) {int t=b;b=a;a=t;}
    if(b<c) {int t=c;c=b;b=t;}
    if(a<b) {int t=b;b=a;a=t;}
    break;
    }   
    printf("%d\n",a*10+b+c);
    return 0;
}

Measured memory_bytes: 128