akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

int dif[35][35];
int num[3][35];
int n,m;

int check(int a,int b,int c){
	int z[3]={a,b,c};
	int s=0;
	int i,j,k;
	for(i=0;i<3;i++){
		for(j=0;j<m;j++){
			s+=dif[j][z[i]]*num[i][j];
		}
	}
	return s;
}

int main(){
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	for(i=0;i<m;i++){
		for(j=0;j<m;j++){
			cin>>dif[i][j];
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cin>>a;
			a--;
			num[(i+j)%3][a]++;
		}
	}
	b=1e9;
	for(i=0;i<m;i++){
		for(j=0;j<m;j++){
			if(i==j)continue;
			for(k=0;k<m;k++){
				if(i==k || j==k)continue;
				a=check(i,j,k);
				if(a<b)b=a;
			}
		}
	}
	cout<<b<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< pii > A(N);
	rep(i, N) cin >> A[i].first;
	rep(i, N) A[i].second = i;
	sort(A.rbegin(), A.rend());
	vector< vector< int > > dp(N + 1, vector< int >(N + 1, 0));
	rep(i, N) {
		pii p = A[i];
		int a = p.first;
		int x = p.second;
		for (int l = 0; l <= i; l++) {
			int r = i - l;
			chmax(dp[l + 1][r], dp[l][r] + a * abs(x - l));
			chmax(dp[l][r + 1], dp[l][r] + a * abs((N - 1 - r) - x));
		}
	}
	int ans = 0;
	rep(l, N + 1) chmax(ans, dp[l][N - l]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34680
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int dis[100010],k;
typedef pair<int,int> P;
priority_queue<P,vector<P>,greater<P> >Q;
int main(){
  cin>>k;
  lol(i,k)dis[i]=mod;
  Q.push(make_pair(0,0));
  int ans=mod;
  while(!Q.empty()){
    int cost=Q.top().first;
    int now=Q.top().second;
    Q.pop();
    if(!now&&cost)ans=min(ans,cost);
    if(dis[now]<=cost)continue;
    dis[now]=cost;
    Q.push(make_pair(cost,now*10%k));
    Q.push(make_pair(cost+1,(now+1)%k));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1784
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<bitset>
#include<queue>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<ll> vec(n);
  ll sum = 0;
  ll mod = 1000000007;
  rep(i,n){
    cin >> vec.at(i);
    sum += vec.at(i);
    sum %= mod;
  }
  ll ans;
  for (int i=0; i<n-1; i++){
    sum -= vec.at(i);
    if (sum < 0) sum += mod;
    ans += vec.at(i) * sum % mod;
  }
  cout << ans % mod << endl;
}


Measured memory_bytes: 4768
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
#include <deque>
#define int long long
using namespace std;
int INF = 1e18;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k, ai;
    cin >> n >> k;
    vector<int> data;
    data.push_back(0);
    for (int i=0; i < k; i++){
        cin >> ai;
        data.push_back(ai);
    }
    data.push_back(INF);
    int q;
    cin >> q;
    vector<pair<int, int> > qv(q);
    for (int i=0; i < q; i++){
        int f, s;
        cin >> f >> s;
        pair<int, int> p = make_pair(f, s);
        qv[i] = p;
    }
    int l = 0;
    int r = n;
    int uf = 1, us = 1;
    int u = 0;
    bool mins = true;
    vector<int> answers(q);
    for (int i=1; i <= k+1; i++){
        while (u < q && qv[u].first < data[i]){
            int diff = qv[u].first - data[i-1];
            int old;
            if (r == l) old = l;
            else{
                if (qv[u].second < uf) old = l;
                else if (qv[u].second > n - us) old = r;
                else old = l + (qv[u].second - uf) + 1;
            }
            if (mins) old -= diff;
            else old += diff;
            if (old < 0) old = 0;
            if (old > n) old = n;
            answers[u] = old;
            u++;
        }
        if (i > k) break;
        if (mins){
            l -= (data[i] - data[i-1]);
            if (l < 0){
                uf -= l;
                l = 0;
            }
            r -= (data[i] - data[i-1]);
            if (r < 0) r = 0;
        }
        else{
            r += (data[i] - data[i-1]);
            if (r > n){
                us += (r - n);
                r = n;
            }
            l += (data[i] - data[i-1]);
            if (l > n) l = n;
        }
        mins ^= 1;
    }
    for (int i=0; i < q; i++){
        cout << answers[i] << endl;
    }
    return 0;
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;
ll comb(ll a, ll b);
int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    ll x;
    ll ans = 0;
    cin >> x;
    ll index = 0;
    for (int i = 1; ans < x; i++)
    {
        ans += i;
        index = i;
    }
    //
    c(index);
    //

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

using namespace std;
typedef long long int64;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n,k;
  int r,s,p;
  string t;
  cin>>n>>k>>r>>s>>p>>t;

  int score=0;
  string hand;
  for(auto c:t){
    if(c=='r'){
      hand.push_back('p');
      score+=p;
    }else if(c=='s'){
      hand.push_back('r');
        score+=r;

    }else{
      hand.push_back('s');
      score+=s;
    }
  }

  for(int start=0;start<k;start++){
    string str;
    for(int i=0;i<n;i+=1){
      if(start+i*k>=n) break;
      str.push_back(hand[start+i*k]);
    }

    for(int i=0;i<str.size()-1;i++){
      if(str[i]==str[i+1]){
        if(str[i]=='r'){
          score-=r;
        }else if(str[i]=='s'){
          score-=s;
        }else{
          score-=p;
        }
        i++;

      }
    }

  }

  cout<<score<<endl;








  return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define _for(i, a, b) for(int i = (a);i < (b); ++i)
#define _rep(i, a, b) for(int i = (a);i <= (b); ++i)
#define b_e(a) begin(a), end(a)
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pLL;
typedef pair<int, string> pis;

//int nextInt() { int x; scanf("%d", &x); return x; }
LL nextLL() { LL x; scanf("%lld", &x); return x; }
//double nextDouble() { double x; scanf("%lf", &x); return x; }
//string nextString() { string s; cin >> s; return s; }
//auto cmp = [](const int& a, const int& b) {return a > b;};
const int INF = 1e9;
const int MAXN = 100000;
const int dx[4] = { 0, 0, 1, -1 };
const int dy[4] = { 1, -1, 0, 0 };
vector<pLL> a;
LL sum[MAXN + 10];
LL rsum[MAXN + 10];
LL max1[MAXN + 10];
LL max2[MAXN + 10];
int main() {
	LL n = nextLL(), c = nextLL();
	_for(i, 0, n) {
		LL x = nextLL(), y = nextLL();
		a.emplace_back(x, y);
	}
	sort(b_e(a));
	_for(i, 0, n) {
		sum[i + 1] = sum[i] + a[i].second;
		rsum[n - i - 1] = rsum[n - i] + a[n - i - 1].second;
	}
	_for(k, 0, n) {
		int i = n - k - 1;
		max1[i] = max(max1[i + 1], rsum[i] - (c - a[i].first));
		max2[i] = max(max2[i + 1], rsum[i] - (c - a[i].first) * 2);
	}
	LL ans = 0;
	_for(i, 0, n) {
		LL temp = sum[i + 1] - a[i].first;
		ans = max(ans, temp);
		ans = max(ans, max1[i]);
		ans = max(ans, temp - a[i].first + max1[i + 1]);
		ans = max(ans, temp + max2[i + 1]);
	}
	printf("%lld", ans);
}

Measured memory_bytes: 5104
N = int(input())
S_list = []

for i in range(N):
    s = list(input())
    s.sort()
    s1 = ''.join(s)
    S_list.append(s1)

S_list.sort()
s_compare = S_list[0]
ans = 0
count = 1

for i in range(1,N):
    if S_list[i] == s_compare:
        count += 1
    else:
        ans += count * (count - 1) / 2
        count = 1
        s_compare = S_list[i]

ans += count * (count - 1) / 2
print(int(ans))

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll h, w; cin >> h >> w;
    ll ans;
    if(h == 1 || w == 1){
        ans = 1;
    }else{
        ans = ((w + 1) / 2) * ((h + 1) / 2) + (w - (w + 1) / 2) * (h - (h + 1) / 2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int m[4]={6000,4000,3000,2000};
	int n,k,i;
	for(i=0;i<4;i++){
		scanf("%d %d",&n,&k);
		printf("%d\n",m[n-1]*k);
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main(){
  int n, i;
  scanf("%d", &n);
  int a[n];

  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);

  int max = a[0], min = a[0];
  long long total = a[0];
  for(i = 1; i < n; i++){
    if(max < a[i])
      max = a[i];
    if(min > a[i])
      min = a[i];
    total += a[i];
  }

  printf("%d %d %lld\n", min, max, total);
  return 0;
}


Measured memory_bytes: 2148
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int n; cin >> n;
    string s[n];
    map<string, int> m;
    rep(i, n) cin >> s[i], m[s[i]]++;
    string g[4] = {"AC", "WA", "TLE", "RE"};
    rep(i, 4) {
        cout << g[i] << " x " << m[g[i]] << endl;
    }
}


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

int main() {
  set<int> paint;
  rep(i, 3) {
    int num;
    cin >> num;
    paint.insert(num);
  }
  cout << paint.size() << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  int n;  cin >> n;
  vector<ll> v(n);
  rep(i,0,n){
    cin >> v[i];
  }
  ll cnt=0;
  rep(i,0,n){
    ll x= v[i]/2;
    cnt += x;
    if(x>0) v[i] -= 2*x;
    if(i<n-1){
      ll y=min(v[i], v[i+1]);
      cnt += y;
      v[i] -= y;
      v[i+1] -= y;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s = "CODEFESTIVAL2016", w;
  int ans = 0;
  cin >> w;
  for(int i = 0;i < (int)s.size();i++){
    if(s[i] != w[i]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)


int main(){
    int N;
    cin >> N;
    ll ans =0;
    vector<ll> A(N);

    for(int i = 0;i < N;i++)
        cin >> A.at(i);
    
    sort(A.begin(),A.end());

    ans = A.at(N-1) - A.at(0);

    cout << ans << endl;


}

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

using namespace std;
using ll=long long;

int main()
{
    int n,l;cin >>n >>l;
    int sum=0;
    int mint=100000;
    int k=mint;
    for(int i=0;i<n;i++){
        sum+=l+i;
        if(mint>abs(l+i))k=l+i;
        mint=min(mint,abs(l+i));
    }
    cout <<sum-k<< endl;
    return 0;
}


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

int main() {

    int n, p;
    scanf("%d", &n);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &p);
        if (p != i + 1) {
            cnt++;
        }
        if(cnt==3){
            printf("NO");
            return 0;
        }

    }

    printf("YES");
    return 0;
} 

Measured memory_bytes: 128
//IncubatorMan
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
char gap = 32;
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for (const auto &x : v) os << gap << x;
    return os << '}';
}
template<typename A, typename B>
ostream& operator<<(ostream &os, const pair<A, B> &p) {
    return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
        int,
        null_type,
        less<int>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(){
    enum{tin=3,R='R',G='G',B='B'};
    ll n;
    cin>>n;
    string data;
    cin>>data;
    vvi cnt(tin,vi(n+1,0));
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<3;j++) cnt[j][i]+=cnt[j][i+1];
        if(data[i]==R) cnt[0][i]++;
        else if(data[i]==G) cnt[1][i]++;
        else cnt[2][i]++;
    }
    ll ans=0;
    map<char,int> f;
    f[R]=0;
    f[G]=1;
    f[B]=2;
    map<int,char> de;
    de[0]=R;
    de[1]=G;
    de[2]=B;
    //cout<<cnt<<endl;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            if(data[i]==data[j])continue;
            int lol=3 - (f[data[i]]+f[data[j]]);
            char ter= de[lol];
            ans += cnt[lol][j+1];
            int bes=(2*j-i);
            //bes =+ j;
            if(bes<n && data[bes]==ter) ans--;
        }
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int test=1;
    //read(test);
    while(test--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int main(){
	bool ans=true;
	string S;
	int cnt[128]={};

	cin >> S;
	for(auto c: S){
		cnt[c]++;
	}
	if( cnt['N'] > 0 && cnt['S'] == 0 ) ans = false;
	if( cnt['N'] == 0 && cnt['S'] > 0 ) ans = false;
	if( cnt['W'] > 0 && cnt['E'] == 0 ) ans = false;
	if( cnt['W'] == 0 && cnt['E'] > 0 ) ans = false;

	cout << (ans?"Yes":"No") << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

temp = [t-hh*0.006 for hh in h]

dist = float('inf')
ans = -1
for i, t in enumerate(temp):
    if abs(t-a) <= dist:
        ans = i+1
        dist = abs(t-a)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
struct SOL
{
    int p;
    int x;
};
int main(void)
{
    int N;
    cin >> N;
    vector<int> t;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        t.push_back(tmp);
    }
    int M;
    cin >> M;
    SOL *pair1;
    pair1 = new SOL[M];
    for (int i = 0; i < M; i++)
    {
        cin >> pair1[i].p >> pair1[i].x;
    }
    int *sum;
    sum = new int[M];
    for (int i = 0; i < M; i++)
    {
        sum[i] = 0;
    }
    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (pair1[i].p == j + 1)
            {
                sum[i] += pair1[i].x;
            }
            else
            {
                sum[i] += t[j];
            }
        }
    }
    for (int i = 0; i < M; i++)
    {
        cout << sum[i] << endl;
    }
    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto X=vecin(N);
	auto Y(X);
	sort(ALL(Y));
	int medL=Y[N/2-1],medR=Y[N/2];
	REP(i,N){
		if(X[i]<=medL) out(medR);
		else out(medL);
	}

	return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y>>z;
if(x%z==0)n=x/z-1;
else n=x/z;
if(y%z==0)m=y/z;
else m=y/z;
std::cout << m-n << '\n';
}


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

T = [[] for i in range(n)]

for i in range(n):
  T[i] = list(map(int, input().split()))

TA = [[-1 for i in range(20)] for j in range(n)]

for i in range(n):
  TA[i][0] = i
  k = T[i][1]
  if k >0:
    for j in range(k):
      TA[T[i][2+j]][1] = T[i][0]

for i in range(18):
  for j in range(n):
    if TA[j][1+i] >= 0:
      TA[j][2+i] = TA[TA[j][1+i]][1]

TB = [[] for i in range(n)]

TC = [[] for i in range(n)]

for i in range(n):
  a = T[i][0]
  TC[a] = T[i]

for i in range(n):
  if TA[i][1] == -1:
    TB[i] = ["node " + str(i) + ": parent = -1,", "depth = 0,", "root,", TC[i][2:] ]
  elif TC[i][1] == 0:
    dep = TA[i].index(-1)-1
    TB[i] = ["node " + str(i) + ": parent = " + str(TA[i][1]) + ",", "depth = " + str(dep) + ",", "leaf,", "[]"]
  else:
    dep = TA[i].index(-1)-1
    TB[i] = ["node " + str(i) + ": parent = " + str(TA[i][1]) + ",", "depth = " + str(dep) + ",", "internal node,", TC[i][2:]]

for i in range(n):
  print(" ".join(map(str, TB[i])))


Measured memory_bytes: 81724
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9 + 7, INF = 1e18;
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 dp[100010][101];

signed main(){
	int N;
	cin>>N;
	map<int,int>mp;
	vector<int> x(N);
	REP(i,N){
		int t;
		cin >> t;
		x[i] = t;
		mp[t] = i;
	}
	int L,Q;
	cin>>L>>Q;
	REP(i,N)dp[i][0] = upper_bound(ALL(x),x[i]+L) - 1 - x.begin();
	REP(j,100)REP(i,N)dp[i][j+1] = dp[dp[i][j]][j];
	auto f =[&](int x,int now){
		RREP(i,60)if((x>>i)&1)now = dp[now][i];
		return now;
	};
	vector<int>ans;
	REP(i,Q){
		int a,b;
		cin>>a>>b;
		a--;b--;
		if(b < a)swap(a,b);
		int l = -1, r = N + 1;
		while(r - l > 1){
			int c = (l + r) / 2;
			if(f(c,a)>=b) r = c;
			else l = c;
		}
		ans.push_back(r);
	}
	for(auto e:ans)cout<<e<<endl;
}


Measured memory_bytes: 87672
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
	int x, y, z, e, m;
	while (cin >> e && e > 0){
		m = 10000000;
		for (y = 0; y*y <= e; y++) {
			for (z = 0; z*z*z <= e; z++) {
				int x = e - y*y - z*z*z;
				if (x >= 0)
					m = min (m, x + y + z);
			}
		}
		cout << m << endl;
	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N,M;	cin>>N>>M;
	int A[100050][2]={};
	int p;
	string S;
	while(M--){
		cin>>p>>S;
		if(!A[p][0])	{
			if(S=="WA"){
				A[p][1]++;
			}
			if(S=="AC"){
				A[p][0]++;
			}
		}
	}
	ull sum1=0,sum2=0;
	FOR(i,0,N+1){
		if(A[i][0]){
          sum1++;
          sum2+=A[i][1];
    	}
	}

	cout<<sum1<<" "<<sum2<<endl;

    return 0;
}




Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;



int main() {
	vector<int> v(26, 0);
	string s;
	while (getline(cin, s)) {

		for (auto itr = s.begin(); itr != s.end(); itr++) {
			for (int i = 0; i < 26; i++) {
				if ('a' + i == *itr) v[i]++;
				if ('A' + i == *itr) v[i]++;
			}
		}
	}

	REP(i, 0, 26) {
		cout << (char)('a' + i) << " " << ':' << " " << v[i] << endl;
	}
	
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  a = a % 500;
  if (a <= b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

const int N=2009;

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

int n,a[N];
int g[N][N];
bool vis[N];
int ind[N];
vector<int> e[N];

inline void dfs(int u)
{
	for(int i=1;i<=n;i++)
		if(g[u][i]>1 && !vis[i])
		{
			vis[i]=1;
			e[u].push_back(i);
			ind[i]++;
			dfs(i);
		}
}

int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();

	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			g[i][j]=g[j][i]=__gcd(a[i],a[j]);

	priority_queue<int,vector<int>,less<int> > q;

	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			vis[i]=1;
			dfs(i);
		}

	for(int i=1;i<=n;i++)
		if(!ind[i])
			q.push(i);

	while(!q.empty())
	{
		int u=q.top();
		q.pop();
		printf("%d ",a[u]);
		for(int i=0,ed=e[u].size();i<ed;i++)
			if(--ind[e[u][i]]==0)
				q.push(e[u][i]);
	}
	puts("");

	return 0;
}


Measured memory_bytes: 16256
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  2000007
#define md 998244353ll
///////////////////////////
///////////////////////////
///


int main(){
    int n;
    I(n);
    int res = 0;

    for(int i = 1; i<= n; i++){
        int x;
        I(x);
        if(x % 2 == 1 && i % 2 == 1){
            res ++;
        }
    }
    PI(res), NL;
    return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

ll dp[3010][3010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h) cin >> s[i];

  dp[0][0] = 1;
  REP(i, h) REP(j, w) {
    if(i+1 < h && s[i+1][j] != '#') (dp[i+1][j] += dp[i][j]) %= MOD;
    if(j+1 < w && s[i][j+1] != '#') (dp[i][j+1] += dp[i][j]) %= MOD;
  }
  cout << dp[h-1][w-1] << endl;

  return 0;
}


Measured memory_bytes: 24832
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, a;
    
    scanf("%d", &n);
    
    a=25-n;
    
    printf("Christmas");
    
    while (a>0) {
        printf(" Eve");
        a--;
    }
    
    return 0;
}



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

public class Hello{
    public static void Main(){
        
        int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); 
        int W = nums[0];
        int H = nums[1];
        int N = nums[2];
        int minX = 0;
        int minY = 0;
        int maxX = W;
        int maxY = H;

        for(int i = 0; i < N; i++){
            nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            
            switch(nums[2]){
                case 1:
                    minX = Math.Max(minX, nums[0]);
                break;
                
                case 2:
                    maxX = Math.Min(maxX, nums[0]);
                break;
                
                case 3:
                    minY = Math.Max(minY, nums[1]);
                break;
                
                case 4:
                    maxY = Math.Min(maxY, nums[1]);
                break;
                
                default:
                break;
            }
        }
        
        int difX = maxX -minX;  //横の長さ
        int difY = maxY -minY;  //縦の長さ
        Console.WriteLine( difX >= 0 && difY >=0 ? (difX * difY) : 0);
    }
}


Measured memory_bytes: 11220
def main():
    n = int(input())
    p = list(map(int, input().split(" ")))
    ans = 0
    min = 2e5+1
    for i in range(n):
        if min > p[i]:
            min = p[i]
        if p[i] <= min:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)

int main()
{
	ull a, p; cin >> a>>p;
	p += a * 3;
	cout << p / 2 << endl;

	return 0;
}

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



string A, B, C;
//-----------------------------------------------------------------------------------
int main() {
    cin >> A >> B >> C;

    if (A.back() == B.front() && B.back() == C.front())
        printf("YES\n");
    else printf("NO\n");
}

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

int main()
{
    int N;
    cin >> N;
    for(int i = 1; i <= 9; i++)
    {
        for(int j = 1; j <= 9; j++)
        {
            if(i * j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll INF = 1e18L;
const int N = 303;
ll mat[N][N], mat2[N][N];

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, m, l;
	scanf("%d%d%d", &n, &m, &l);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) mat[i][j] = INF;
	}

	for (int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		mat[a][b] = mat[b][a] = c;
	}

	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (mat[i][j] <= l)
				mat2[i][j] = 1;
			else
				mat2[i][j] = INF;
		}
	}

	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++)
				mat2[i][j] = min(mat2[i][j], mat2[i][k] + mat2[k][j]);
		}
	}

	int q;
	for (scanf("%d", &q); q > 0; q--) {
		int a, b;
		scanf("%d%d", &a, &b);
		printf("%lld\n", mat2[a][b] == INF? -1 : mat2[a][b] - 1);
	}
}


Measured memory_bytes: 1920
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}

	result := 0
	for b := 0; b < 60; b++ {
		t := 0
		bs := (A[N-1] >> uint(b)) & 1
		for i := N - 2; i > -1; i-- {
			a := (A[i] >> uint(b)) & 1
			if a == 0 {
				t += bs
			} else {
				t += (N - (i + 1)) - bs
				bs++
			}
		}
		t %= 1000000007
		B := (1 << uint(b)) % 1000000007
		result += (t * B) % 1000000007
		result %= 1000000007
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 8960
#include<iostream>

using namespace std;


void printArray(int list[100], int n){

    int i;

    for(i=0;i<n;i++){
        if(i == 0){
            cout << list[i];
        }else{
            cout << " " << list[i];
        }
    }

    cout << endl;

}


void insertionSort (int A[100], int n) {

    int i, j, v;

    for (i=1;i<n;i++) {
        v = A[i];
        j = i - 1;

        while (j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        printArray(A, n);
    }

}


int main(){

    int i, n;
    int A[100] = {0};

    cin >> n;

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

    printArray(A, n);

    insertionSort(A, n);

    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007



void solve()
{
  int N;
  cin>>N;
  string S;
  cin>>S;
  for (int i = 0; i < S.size(); i++)
  {
    S[i] = (S[i] + N);
    if(S[i] > 'Z') S[i] -= ('Z' - 'A' + 1);
  }

  cout<<S<<endl;
  

  
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solve();
 
  return 0;
}

Measured memory_bytes: 256
use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        x: i32,
    }
    match x {
        400...599 => println!("8"),
        600...799 => println!("7"),
        800...999 => println!("6"),
        1000...1199 => println!("5"),
        1200...1399 => println!("4"),
        1400...1599 => println!("3"),
        1600...1799 => println!("2"),
        1800...1999 => println!("1"),
        _ => println!(""),
    }
}

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

int main() {
    int n, k; cin >> n >> k;
    if (k == 0) return !(cout << 1LL * n * n << endl);
    long long cnt = 0;
    for (int b = 1; b <= n; b++) {
        int q = n / b, r = n % b;
        cnt += 1LL * q * max(0, b - k) + max(0, r - k + 1);
    }
    cout << cnt << endl;
    return 0;
}


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

//#define FILEIO

using namespace std;

const int SZ = 100050;
const double EPS = 1e-9;
const int MOD = 100000008;
const int INF = ( 1 << 30 ) - 1;
const double PI = 2 * acos( 0.0 );

template <class T> T MIN(T a, T b) { return (a < b) ? a : b; }
template <class T> T MAX(T a, T b) { return (a > b) ? a : b; }
template <class T> void SWAP(T &a, T &b) { T c; c = a; a = b; b = c; }
template <class T> T GCD(T a, T b) { T c; while(b > 0) { c = a % b; a = b; b = c; } return a; }

bool CMP(int a, int b)
{
     return (a > b);
}

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

    int x, y, r, g, c, ra[SZ], ga[SZ], ca[SZ], i, sz;
    long long int ans, sum, a, b;
    vector <int> vc;

    cin >> x >> y >> r >> g >> c;

    for(i = 0; i < r; i++)
    {
        cin >> ra[i];
    }
    sort(ra, ra + r, CMP);
    for(i = 0; i < g; i++)
    {
        cin >> ga[i];
    }
    sort(ga, ga + g, CMP);
    for(i = 0; i < c; i++)
    {
        cin >> ca[i];
    }
    sort(ca, ca + c, CMP);
    vc.clear();
    for(i = 0; i < x; i++)
    {
        vc.push_back(ra[i]);
    }
    for(i = 0; i < y; i++)
    {
        vc.push_back(ga[i]);
    }
    sz = vc.size();
    sort(vc.begin(), vc.end());
    sum = 0;
    for(i = 0; i < sz; i++)
    {
        sum += vc[i];
    }
    a = 0;
    b = 0;
    ans = sum;
    for(i = 0; i < sz; i++)
    {
        if(i >= c)
        {
            break;
        }
        b -= vc[i];
        b += ca[i];
        a = sum + b;
        ans = MAX(ans, a);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define taskname "D"

//#define BeztDonkey
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

const int maxN = 51;

int a[maxN], n, Max, Min;
vector<pair<int, int>> ans;

int main()
{
    #ifdef BeztDonkey
    auto start = chrono::steady_clock::now();
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen(taskname".inp", "r", stdin);
    //freopen(taskname".out", "w", stdout);

    cin >> n >> a[Max = Min = 1];
    for (int i = 2; i <= n; ++i)
    {
        cin >> a[i];
        if (a[i] > a[Max]) Max = i;
        if (a[i] < a[Min]) Min = i;
    }
    if (abs(a[Max]) > abs(a[Min]))
    {
        for (int i = 1; i <= n; ++i)
        {
            if (a[i] < 0)
            {
                a[i] += a[Max];
                ans.push_back({Max, i});
            }
        }
        for (int i = 2; i <= n; ++i) ans.push_back({i - 1, i});
    }
    else
    {
        for (int i = n; i >= 1; --i)
        {
            if (a[i] > 0)
            {
                a[i] += a[Min];
                ans.push_back({Min, i});
            }
        }
        for (int i = n - 1; i > 0; --i) ans.push_back({i + 1, i});
    }
    cout << ans.size() << '\n';
    for (auto &t : ans) cout << t.first << ' ' << t.second << '\n';

    #ifdef BeztDonkey
    auto end = chrono::steady_clock::now();
    cerr << "In milliseconds : "
         << chrono::duration_cast<chrono::milliseconds>(end - start).count();
    cerr << '\n' << "In seconds : "
         << chrono::duration_cast<chrono::seconds>(end - start).count() << '\n';
    #endif
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

void solve(){
    int n,g;
    cin>>n>>g;
    
    int st=1,en=1e5;
    int flag=1;
    while(g-->0){
        int l,r;
        cin>>l>>r;
        // total overlap
        if(st>l && en<r){
            continue;
        }// no overlap
        else if(r<st || en<l){
            flag=0;
        }
        else{// partial overlap
            st=max(st,l);
            en=min(en,r);
        }
    }
    if(flag){
        cout<<en-st+1;
    }
    else{
        cout<<0;
    }
}



int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3640
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    s = collections.defaultdict(list)
    e = collections.defaultdict(list)
    for i in range(m):
        a, b = list(map(int, input().rstrip('\n').split()))
        if a == 1:
            s[b]
        if b == 1:
            s[a]
        if a == n:
            e[b]
        if b == n:
            e[a]
    for v in s.keys():
        if v in e:
            print("POSSIBLE")
            exit()
    print("IMPOSSIBLE")



if __name__ == '__main__':
    slove()


Measured memory_bytes: 67292
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    print(n*(n-1)//2-n//2)
    if n%2==1:
        for i in range(1,n):
            for j in  range(i+1,n+1):
                if j==n-i:continue
                print(i,j)
    else:
        for i in range(1,n):
            for j in  range(i+1,n+1):
                if j==n-i+1:continue
                print(i,j)        

if __name__=='__main__':
    main()

Measured memory_bytes: 3612
program shift_only
  implicit none
  integer :: n, a(200) = 0, i
  read(*,*) n
  read(*,*) a(1:n)
  write(*,'(i0)') minval(number_of_trailing_zeros(a(1:n)))
contains
  pure elemental integer function number_of_trailing_zeros(i) result(res)
    integer, intent(in) :: i
    integer :: x, y
    if (i == 0) then
      res = 32
      return
    end if
    res = 31
    x = i
    y = lshift(x, 16)
    if (y /= 0) then
      res = res - 16
      x = y
    end if
    y = lshift(x, 8)
    if (y /= 0) then
      res = res - 8
      x = y
    end if
    y = lshift(x, 4)
    if (y /= 0) then
      res = res - 4
      x = y
    end if
    y = lshift(x, 2)
    if (y /= 0) then
      res = res - 2
      x = y
    end if
    res = res - urshift(lshift(x, 1), 31)
  end
  pure elemental integer function urshift(i, n) result(res)
    integer, intent(in) :: i
    integer, intent(in) :: n
    if (n == 0) then
      res = i
    else
      res = rshift(ibclr(rshift(i, 1), 31), n - 1)
    end if
  end
end program shift_only

Measured memory_bytes: 2772
#include<stdio.h>

int main(void){
    register int i;
    int n;
    scanf("%d",&n);
    int a[n];
    for(i = 1;i < n;i++)scanf("%d",&a[i]);
    int cnt[n];
    for(i = 0;i < n;i++)cnt[i] = 0;
    for(i = 1;i < n;i++)cnt[a[i] - 1]++;
    for(i = 0;i < n;i++)printf("%d\n",cnt[i]);
}

Measured memory_bytes: 3264