akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll x, a, b;
    cin >> x >> a >> b;

    x -= a;
    p(x%b);
        
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, a, b, sum2 int
	fmt.Scan(&n, &a, &b)

	for i := 1; i <= n; i++ {
		sum1 := 0
		for j := i; j != 0; j /= 10 {
			sum1 += j % 10
		}
		if a <= sum1 && sum1 <= b {
			sum2 += i
		}

	}
	fmt.Println(sum2)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define fr first
#define sc second
#define mp make_pair
#define All(v) v.begin(),v.end()
using namespace std;


int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
      scanf("%d",&a[i]);
  }
  if(n%2 == 0)
  {
     for(int i=n-1;i>=0;i-=2)
     {
         cout<<a[i]<< " ";
     }
     for(int i=0;i<n;i+=2)
     {
         cout<<a[i]<<" ";
     }
  }
  else
  {
      vector < int > v1 , v2;
      int ok = 1;
      for(int i=1;i<n;i++)
      {

          if(ok)
            v1.push_back(a[i]);
          else
            v2.push_back(a[i]);
          ok = !ok;
      }
      for(int i=v2.size()-1;i>=0;i--)
        cout<<v2[i]<< " ";
      cout<<a[0]<< " ";
      for(int i=0;i<v1.size();i++)
        cout<<v1[i]<< " ";
  }
}



Measured memory_bytes: 3956
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

int main(void){
    int X, Y, Z; cin >> X >> Y >> Z;
    int sum = 0, cnt = 0;
    while (true) {
        sum += Y + Z;
        if (sum + Z > X) break;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)
int t[1000001];

int main() {
	int N;
	cin >> N;
	repeq(i, 2, 1e6) {
		if (t[i]==0) {
			for (int j = i; j <= 1e6; j += i) {
				if (t[j]==0) {
					t[j] = i;
				}
			}
		}
	}

	map<int, int> dic;
	rep(i, 0, N) {
		int A;
		cin >> A;
		set<int> st;
		while (A > 1) {
			st.insert(t[A]);
			A /= t[A];
		}
		for (auto x : st) {
			dic[x]++;
		}
	}

	int cnt = 1;
	for (auto x : dic) {
		cnt = max(cnt, x.second);
	}

	if (cnt == 1) {
		cout << "pairwise coprime" << endl;
	}
	else if (cnt < N) {
		cout << "setwise coprime" << endl;
	}
	else {
		cout << "not coprime" << endl;
	}
	return 0;
}


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

int main(){
  int i;
  cin >> i;
  if(i < 105){
    cout << "0" << endl;
  }
  else if(i >= 105 && i <= 134){
    cout << "1" << endl;
  }
  else if(i > 134 && i < 165){ 
    cout << "2" << endl;
  }
  else if(i >= 165 && i < 189){
    cout << "3" << endl;
  }
  else if(i >= 189 && i < 195){
    cout << "4" << endl;
  }
  else{
    cout << "5" << endl;
  }

}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,r[200000],max,i,j,min;

  scanf("%d",&n);
  while(n<2||n>200000)  scanf("%d",&n);

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

  max=r[1]-r[0];
  min=r[0];
  for(j=1;j<n;j++){
      if((r[j]-min)>max) max=r[j]-min;
      if(min>r[j])min=r[j];
  }
  printf("%d\n",max);

  return 0;
}




Measured memory_bytes: 2508
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
int n;
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
int main(){
    int h , a;
    cin >> h >> a;
    if(h%a==0) cout << h/a << endl;
    else cout << h/a+1 << endl;
}

    



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

int main() {
  int N;
  cin >> N;
  vector<int64_t> data(N);
  for(int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  reverse(data.begin(), data.end());
  int64_t ans = 0;
  if(N % 2 == 0) {
    for(int i = 0; i < N / 2; i++) {
      if(i == 0) {
        ans += data.at(0);
      }
      else {
        ans += data.at(i) * 2;
      }
    }
  }
  else {
    for(int i = 0; i < N / 2 + 1; i++) {
      if(i == 0 || i == N / 2) {
        ans += data.at(i);
      }
      else {
        ans += data.at(i) * 2;
      }
    }
  } 
  cout << ans << endl;
}


Measured memory_bytes: 4820
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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


int main(void) {
	int N, K, ans;
	scanf("%d %d", &N, &K);
	ans = K;
	for (int i = 1; i < N; i++) {
		ans *= K - 1;
	}
	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,i;
	long t,ont,ontb,ans=0;
	scanf("%d%ld",&n,&t);
	scanf("%ld",&ontb);
	ans+=t;
	for(i=1;i<n;i++){
		scanf("%ld",&ont);
		if(ontb+t<=ont){
			ans+=t;
		}else {
			ans+=ont-ontb;
		}
		ontb=ont;
	}
	printf("%ld",ans);
	return 0;
}

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

using namespace std;

#define INF 1e9
#define prev(x) ((x - 1 + (M+1)) % (M+1))
#define next(x) ((x + 1) % (M+1))

int main(){
    int N,M,p;
    cin >> N >> M >> p;
    vector<int> d(M+1);
    for(int i = 0 ; i < M ; i++){
        cin >> d[i];
    }
    d[M] = p;
    for(int i = 0 ; i <= M ; i++){
        d[i] -= p;
        if(d[i] < 0) d[i] += N;
    }
    sort(d.begin(),d.end());
    int res = min(d[prev(0)],N-d[next(0)]);
    for(int i = 1 ; i <= M ; i++){
        int pr = d[prev(i)],ne = d[next(i)];
        int pc = (N-d[i])*2 + pr,nc = d[i]*2+(N-ne);
        res = min(res,pc);
        res = min(res,nc);
    }
    cout << res*100 << endl;
    return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

template<typename T>
bool CompareBySecond(pair<T, T> a, pair<T, T> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

void solve() {
  int n, q; cin >> n >> q;
  string s; cin >> s;

  vi dp(n, 0);
  rep1(i,n-1) {
    if (s[i-1] == 'A' && s[i] == 'C') dp[i] = dp[i-1] + 1;
    else dp[i] = dp[i-1];
  }

  while (q--) {
    int l, r; cin >> l >> r; --l; --r;
    cout << dp[r] - dp[l] << endl;
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


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

int main()
{
    string s, t;
    int i;
    int res = 0;
    cin >> s >> t;

    for (i = 0; s[i] != '\0'; i++)
    {
        if (s[i] != t[i])
            res++;
    }

    cout << res;
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n, m;
  cin >> n >> m;
  cout << (n ^ m) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[])
{
	int w, n;
	scanf("%d", &w);
	scanf("%d", &n);
	vector<int> ans;
	REP(i, w)
		ans.push_back(i+1);
	REP(i, n)
	{
		int a,b;
		scanf("%d,%d", &a, &b);
		int temp = ans[a-1];
		ans[a-1] = ans[b-1];
		ans[b-1] = temp;
	}
	REP(i, SZ(ans))
	{
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 3236
#include<stdio.h>
int main(){
    int X,i,n,j,N,Max=0;
    scanf("%d",&X);
    for(i=X;i>0;i--){
        if(X==1){
            printf("%d\n",1);
            return 0;
        }
       for(n=2;n<35;n++){
           N=i;
           j=0;
           while(N>n){
               if(N%n==0){
                   N=N/n;
                   j++;
               }
               else{
                   break;
               }
               }
               if(N==n && j>0){
                   printf("%d\n",i);
                   return 0;
           }
       } 
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define ll long long int
#define sci(x) scanf("%d",&x);
#define scl(x) scanf("%lld",&x);
#define scd(x) scanf("%lf",&x);
#define pb(x) push_back(x)
#define FasterIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mkp(x,y) make_pair(x,y)
#define pii pair<int , int>



int main()
{
    int n;
    cin>>n;
    int a[n+4]={0};
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)
        {
            for(int k=1;k<=100;k++)
            {
                int m= i*(i+j)+j*(j+k)+k*(k+i);
                if(m<=n)
                {
                    a[m]++;
                }
            }
        }
    }
    for(int i=1;i<=n;i++)
        cout<<a[i]<<endl;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int h,w;
char c[101][101];
int ans[101][101];
void k(int i,int j,bool q,int e){
	if(j>=w){
		return;
	}
	if(c[i][j]=='c'){
		ans[i][j]=0;
		q=true;
		e=0;
		k(i,j+1,q,e+1);
	}else if(q){
		ans[i][j]=e;
		k(i,j+1,q,e+1);
	}else{
		ans[i][j]=-1;
		k(i,j+1,q,e);
	}
}
int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>c[i][j];
		}
	}
	for(int i=0;i<h;i++){
		k(i,0,false,0);
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w-1;j++){
			cout<<ans[i][j]<<" ";
		}
		cout<<ans[i][w-1]<<endl;
	}
}


Measured memory_bytes: 3136
N,X,Y = map(int,input().split())
li = [0]*(N-1)
for i in range(0,N-1):
    for j in range(i+1,N):
        dis = min(j-i,abs(i-(X-1))+1+abs(j-(Y-1)))
        li[dis-1] += 1
for ans in li:
    print(ans)

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

Measured memory_bytes: 3080
<?php
fscanf(STDIN, "%d %d", $n, $x);
$arr = explode(" ", trim(fgets(STDIN)));
array_unshift($arr, 0);
$jump = 0;
$count =0;
for($i=0; $i<$n+1; $i++){
    $jump += $arr[$i];
    if($jump <= $x){
        $count++;
    }
}
echo $count;
?>


Measured memory_bytes: 5240
N,W = map(int,input().split())
goods = [list(map(int,input().split())) for _ in range(N)]

dp = [[0 for _ in range(W)] for _ in range(N)]

for i,[w,v] in enumerate(goods):
  for j in range(W):
    if i == 0:
      if j >= goods[0][0]-1:
        dp[0][j] = goods[0][1]
    else:
      if w <= j:
        dp[i][j] = max(v+dp[i-1][j-w],dp[i][j-1],dp[i-1][j])
      else:
        dp[i][j] = max(dp[i-1][j],dp[i][j-1])

print(dp[N-1][W-1])

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 2e2 + 1;

int N;

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

  cin >> N;
  vector< int > a(N);
  REP(i, N) {
    cin >> a[i];
  }

  int ans = INF;
  FOR(i, -100, 101) {
    int tmp = 0;
    REP(j, N) {
      tmp += (a[j] - i) * (a[j] - i);
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);

int main(){
  int n, m;
  cin >> n >> m;
  map<int,int> mp;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    mp[a]++;
    mp[b]++;
  }
  for (auto e : mp) {
    if (e.second & 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 4352
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class ARedOrNot {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int a; cin >> a;
      if (a<3200) {
        cout << "red" << endl;
        return;
      }
      string s; cin >> s;
      cout << s << endl;

    }
};

signed main() {
  ARedOrNot solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <numeric>
std::vector<int> read();
std::vector<std::vector<std::string>> make_rectangle(int, int);
void draw(std::vector<std::vector<std::string>>);

int main()
{
	std::vector<int> height;
	std::vector<int> width;
	std::vector<int> input;
	int count = 0;

	while (true)
	{
		input = read();

		if (input[0] == 0 && input[1] == 0)	break;

		height.emplace_back(input[0]);
		width.emplace_back(input[1]);

		++count;
	}

	for (int i = 0; i < count; i++)
	{
		std::vector<std::vector<std::string>> rectangle = make_rectangle(height[i], width[i]);
		draw(rectangle);
	}

	return 0;
}

std::vector<int> read()
{
	std::vector<int> input(2);
	std::cin >> input[0] >> input[1];

	return input;
}

std::vector<std::vector<std::string>> make_rectangle(int height, int width)
{
	std::vector<std::vector<std::string>> rectangle(height, std::vector<std::string>(width));

	for (int i = 0; i < height; i++)
	{
		for (int j = 0; j < width; j++)
		{
			rectangle[i][j] = "#";
		}
	}

	return rectangle;
}

void draw(std::vector<std::vector<std::string>> rectangle)
{
	for (auto line : rectangle)
	{
		for (auto point : line)
		{
			std::cout << point;
		}
		std::cout << std::endl;
	}
	std::cout << std::endl;
}



Measured memory_bytes: 4284
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

void dfs(int idx, vector< vector< int > > & p, int prev[], bool isLeaf[])
{
  for (auto n : p[idx]) {
    if (prev[n] != -2) continue;
    prev[n] = idx;
    isLeaf[idx] = false; isLeaf[n] = true;
    dfs(n, p, prev, isLeaf);
  }
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  vector< vector< int > > p(n);
  for (int i = 0; i < n-1; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    p[a].push_back(b);
    p[b].push_back(a);
  }
  int prev[n], cnum[n];
  bool isLeaf[n], shortest[n];
  for (int i = 0; i < n; ++i) {
    prev[i] = -2;
    isLeaf[i] = false;
    shortest[i] = false;
    cnum[i] = 0;
  }
  prev[0] = -1;
  isLeaf[0] = true;
  dfs(0, p, prev, isLeaf);
  int idx = n-1;
  shortest[idx] = true;
  while (idx!=-1) {
    idx = prev[idx];
    shortest[idx] = true;
  }
  bool iscounted[n];
  for (int i = 0; i < n; ++i) iscounted[i] = false;
  for (int i = 0; i < n; ++i) {
    if (!isLeaf[i]) continue;
    int cnt = 0;
    int lidx = i;
    while (!shortest[lidx]) {
      if (!iscounted[lidx]) {
        cnt++;
        iscounted[lidx] = true;
      }
      lidx = prev[lidx];
    }
    cnum[lidx] += cnt;
  }
  vector< int > cnode;
  idx = n-1;
  cnode.push_back(cnum[idx]);
  while (prev[idx]!=-1) {
    idx = prev[idx];
    cnode.push_back(cnum[idx]);
  }
  int fennec = 0, snuke = 0;
  for (int i = 0; i < cnode.size()/2; ++i) {
    snuke+=cnode[i]+1;
  }
  for (int i = cnode.size()/2; i < cnode.size(); ++i) {
    fennec+=cnode[i]+1;
  }
  int f = fennec-snuke;
  if (f>0) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
  return 0;
}


Measured memory_bytes: 15228
from collections import deque
n,q=map(int,input().split())
counter=[0]*(n)
edge=[[] for i in range(n+1)]
for i in range(n-1):
  a,b=map(int,input().split())
  edge[a].append(b)
  edge[b].append(a)
  
for j in range(q):
  p,x=map(int,input().split())
  counter[p-1]+=x

def bfs(x,counter):
  qu=deque([])
  qu.append(x)
  qu.append(0)
  while qu:
    now=qu.popleft()
    pre=qu.popleft()
    if now!=1:
      counter[now-1]+=counter[pre-1]
    for i in edge[now]:
      if i!=pre:
        qu.append(i)
        qu.append(now)#あとであとのノードなるもの
      else:continue
  return counter
bfs(1,counter)
print(*counter)

Measured memory_bytes: 54552
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

bool isPrime(const int);

int main(int argc, char *argv[])
{
    int n, tmp, cnt = 0;
    cin >> n;
    while (n-- > 0)
    {
        cin >> tmp;
        if (isPrime(tmp))
        {
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

bool isPrime(const int x)
{
    if (x < 2)
    {
        return false;
    }
    if (x == 2)
    {
        return true;
    }
    if (x % 2 == 0)
    {
        return false;
    }
    int i = 3;
    while (i <= sqrt(x))
    {
        if (x % i == 0)
        {
            return false;
        }
        i += 2;
    }
    return true;
}



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

#define pii pair<int,int>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define deb(x) cerr<<#x" = "<<x<<nl
#define in() ( { int a ; scanf("%d",&a); a; } )

const int N=3e5+9;

string s[]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int32_t main()
{
    string p;
    cin>>p;
    int ans=0;
    for(int i=0;i<7;i++) if(s[i]==p){
        for(i=(i+1)%7;s[i]!="SUN";i=(i+1)%7) ans++;
        cout<<ans+1<<nl;
        return 0;
    }
    return 0;
}



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

int main(void)
{
  std::string str;

  std::getline(std::cin, str);

  for (int i = 0; i < str.length(); i++) {
    if (str.at(i) >= 'a' && str.at(i) <= 'z') {
      str.at(i) = str.at(i) - 'a' + 'A';
    }
  }

  std::cout << str << std::endl;

  return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {

 int n;
 cin >> n;
 
 vector<int> vec(n);
 
 int64_t ans = 0;
 
 for (int i = 0; i < n; i++) {
     cin >> vec.at(i);
     ans += vec.at(i);
 }
 
 sort(vec.begin(),vec.end());
 
 cout << vec.at(0) << " " << vec.at(n - 1) << " " << ans <<endl;
}


Measured memory_bytes: 3192
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define inputv(arr,n) for(ll i=0;i<n;i++){ll value;cin>>value;arr.pb(value);}
#define sz(a) ((ll)(a).size())
#define len(a) ((ll)(a).length())
#define precise cout<<fixed<<setprecision(0); 
#define F first
#define S second
#define vi vector <int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define YES cout<<"Yes\n"
#define NO cout<<"No\n"
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b)
{if(b==0) return a;a%=b;return gcd(b,a);}
#define nl cout<<"\n"
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
// hashing for pairs
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};
//sort in reverse order
bool compare(ll x, ll y){
    return x>y;
}
vl adj[(ll)2e5+10];
ll cnt=0;
bool vis[(ll)2e5+10];
unordered_set<pll,HASH>chk;
void dfs(ll node)
{
  vis[node]=1;
  cnt++;
  for(auto i : adj[node])
  {
    if(!vis[i])dfs(i);
  }
}
void solve()
{
  ll n,m;
  cin>>n>>m;
  rep(i,m)
  {
    ll a,b;
    cin>>a>>b;
    adj[a].pb(b);
    adj[b].pb(a);
  }
  ll ans= 0;
  loop(i,1,n)
  {
    cnt=0;
    if(vis[i]==0)
    {
      dfs(i);
   //   cout<<"dfs "<<i<<" gave cnt "<<cnt;nl;
      ans = max(ans,cnt);
    }
  }
  cout<<ans;nl;
  return;
}
int main()
{
    IOS;
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 21160
def selection_sort size, raw_array
  target_array = raw_array.dup
  size.times {|i|
    unsorted = target_array[i..(size - 1)]
    min = unsorted.min{|a, b| a[/\d+/] <=> b[/\d+/]}
    index_min = unsorted.index(min)
    if min[/\d+/] < target_array[i][/\d+/]
      target_array[i], target_array[i + index_min] = target_array[i + index_min], target_array[i]
    end
  }
  target_array
end

def bubble_sort size, raw_array
  target_array = raw_array.dup
  swapped = true
  while swapped do
    swapped = false
    (size - 1).downto(1) do |i|
      if target_array[i][/\d+/] < target_array[i - 1][/\d+/]
        target_array[i], target_array[i - 1] = target_array[i - 1], target_array[i]
        swapped = true
      end
    end
  end
  target_array
end

def stable? unsorted_array, sorted_array
  unsorted_array = unsorted_array.dup
  sorted_array = sorted_array.dup
  until unsorted_array.size == 0
    # ????????°?????????????????????????????????
    target_num = card_to_s(unsorted_array[0])
    unsorted_target = unsorted_array.select {|i| card_to_s(i) == target_num }
    sorted_target = sorted_array.select      {|i| card_to_s(i) == target_num }
    # ??????????????£????????????????????????
   # p unsorted_target
   # p sorted_target
    return 'Not stable' unless unsorted_target == sorted_target
    # ?????????????????????????????????
    unsorted_array = unsorted_array - unsorted_target
  end
  return 'Stable'

end

def card_to_s card
  card[/\d+/].to_i
end

size = STDIN.gets.chomp.to_i
raw_array = STDIN.gets.chomp.split(' ')

bubbled_array = bubble_sort size, raw_array
selected_array = selection_sort size, raw_array

puts bubbled_array.join ' '
puts stable? raw_array, bubbled_array
puts selected_array.join ' '
puts stable? raw_array, selected_array

Measured memory_bytes: 8848
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

LL getDistance(LL pos, LL first, LL second) {
	if(first > second)	swap(first, second);
	if(pos <= first)	return	second - pos;
	else if(first <= pos && pos <= second)	return second - first + min(pos - first, second - pos);
	else if(pos > second)	return	pos - first;
	return 0;
}

int main() {
	sll(a); sll(b); sll(q);
	LL shrines[a], temples[b];
	rep(i, 0, a)	shrines[i] = scanLong();
	rep(i, 0, b)	temples[i] = scanLong();

	rep(i, 0, q) {
		sll(pos);
		LL shr = lower_bound(shrines, shrines+a, pos) - shrines;
		LL tem = lower_bound(temples, temples+b, pos) - temples;
		LL ans = LONG_MAX;
		// S - L, T - L
		if(shr > 0 && tem > 0)	ans = min(ans, getDistance(pos, shrines[shr - 1], temples[tem - 1]));
		// S - R, T - R
		if(shr < a && tem < b)	ans = min(ans, getDistance(pos, shrines[shr], temples[tem]));
		// S - R, T - L
		if(shr < a && tem > 0)	ans = min(ans, getDistance(pos, shrines[shr], temples[tem - 1]));
		// S - L, T - R
		if(shr > 0 && tem < b)	ans = min(ans, getDistance(pos, shrines[shr - 1], temples[tem]));

		pll(ans); nl;
	}

}


Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
	static char[] AZ = {'A','Z'};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int idx = sc.nextInt();
		String str = sc.next();
		sc.close();
		char[] c = str.toCharArray();
		for(int i=0;i<c.length;i++) {
			System.out.print(slide(c[i], idx));
		}
	}
	static char slide(char c, int key)
	{
	    int ret = c + key;
	    if(ret>AZ[1]) {
	    	ret = ret - AZ[1] + AZ[0] -1;
	    	return (char)ret;
	    }
	    return (char)ret;
	}
}


Measured memory_bytes: 25804
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}

const int MAX_N = 100005;
int n, ans = 0;
int cand[3] = {3, 5, 7};
void input() {
    RI(n);
}

void rec(LL x, int cnt[3]) {
	if(x > n) return;
	if(cnt[0] > 0 && cnt[1] > 0 && cnt[2] > 0) ans++;
	for(int i = 0; i < 3; i++) {
		cnt[i]++;
		rec(x*10+cand[i], cnt);
		cnt[i]--;
	}
}

void solve() {
	if(n < 357) {
		printf("0\n");
		return;
	}
	int cnt[3] = {0,0,0};
	rec(0, cnt);
	printf("%d\n", ans);
}

int main( int argc, char *argv[] ) {
	input();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
long long int sum=0;
using namespace std;
int main(){
	int n,a;
	int min=1000001,max=-10000001,i;
	cin >> n;
	if(n==0) cout << 0<<' '<<0<<' '<<0<<endl;
	else {
		for(i=0;i<n;i++){
			cin>>a;
			if(a < min) min=a;
			if(a > max) max=a;
			sum+=a;
		}
		cout << min <<' '<< max/*<<' '<< sum<<endl*/;
		printf(" %lld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 1196
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
string s[11];
int w[11], l[11], d[11], p[11];
bool used[11];


bool f;
int main() {
	while (cin >> n&&n) {
		if (f)cout << endl;;
		f = true;
		REP(i, n) {
			used[i] = false;
			cin >> s[i] >> w[i] >> l[i] >> d[i];
			p[i] = 3 * w[i] + d[i];
		}
		REP(i, n) {
			int maxp = -2;
			string maxc;
			int maxj = 0;
			REP(j, n) {
				if (maxp < p[j]&&!used[j]) {
					maxp = p[j];
					maxc = s[j];
					maxj = j;
				}
			}
			cout << maxc << "," << maxp << endl;
			used[maxj] = true;
		}
	}
}


Measured memory_bytes: 3116
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int X,N,A[100]={};
    scanf("%d %d",&X,&N);
    
    for(int i = 0; i < N; i++)
    {
        scanf("%d",&A[i]);
    }
    
    int kaburiflag = 0;
    int sa = 0;
    while(1)
    {
        kaburiflag = 0;
        //printf("target:%d\n",X-sa);
        for(int i = 0; i < N && kaburiflag == 0; i++)
        {
            if(A[i] == X-sa)
            {
                //printf("kaburi:%d\n",A[i]);
                kaburiflag = 1;
            }
        }
        if(kaburiflag == 0)
        {
            printf("%d\n",X-sa);
            break;
        }
        
        kaburiflag = 0;
        //printf("target:%d\n",X+sa);
        for(int i = 0; i < N && kaburiflag == 0; i++)
        {
            if(A[i] == X+sa)
            {
                //printf("kaburi:%d\n",A[i]);
                kaburiflag = 1;
            }
        }
        if(kaburiflag == 0)
        {
            printf("%d\n",X+sa);
            break;
        }
        sa++;
    }
}


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

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

  
  


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.StringBuilder
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)
    val h = sc.nextLong()
    val w = sc.nextLong()
    if (h == 1L || w == 1L) {
        println(1)
    } else if (h % 2 == 0L || w % 2 == 0L) {
        println(h * w / 2)
    } else {
        println(h * w / 2 + 1)
    }
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 31136
import java.util.*;
import java.io.*;

public class Main {

    private static final int M = 1_000_000_007;

    public Main(FastScanner in, PrintWriter out, int test) {
        int n = in.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextLong();
            if (a[i] == 0) {
                out.println(0);
                return;
            }
        }

        final long limit = (long)1e18;
        long prod = 1;
        for (long x : a) {
            if (x <= limit / prod)
                prod *= x;
            else {
                out.println(-1);
                return;
            }
        }
        out.println(prod);
    }

    private long pow(int x, int p) {
        long res = 1, a = x;
        while (p > 1) {
            if (p % 2 == 1)
                res = res * a % M;

            a = a * a % M;
            p /= 2;
        }
        res  = res * a % M;
        return res;
    }

    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        // int T = in.nextInt();
        for (int t = 1; t <= 1; t++) {
            Main sol = new Main(in, out, t);
        }

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


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

typedef long long ll;
const int N = 2e5;

int n,k;
ll h[N+5];

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%lld",&h[i]);
	}
	if(n<=k){
		printf("0\n");
		return 0;
	}
	sort(h+1,h+n+1);
	ll ans = 0ll;
	for(int i=1;i<=n-k;i++){
		ans+=h[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
//Segment Tree
// RMQ
#include<iostream>
#include<climits>
#include<cstdio>
using namespace std;
// const int MAX_N = 1 << 17;
const int MAX_N = 200022;

int n, dat[2 * MAX_N - 1];

int init(int n_){
	n = 1;
	
	while(n < n_) n *= 2;
	
	for(int i = 0; i < 2 * n - 1; i++) dat[i] = INT_MAX;
	
	return n;
}

void update(int k, int a){
	k += n - 1;
	dat[k] = a;
	while(k > 0){
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
}

int query(int a, int b, int k, int l, int r){
	// cout<<a<<" ----- "<<b<<" "<<k<<" "<<l<<" "<<r<<endl;
	if(r <= a || b <= l){
		// cout<<a<<" DD "<<b<<" "<<k<<" "<<l<<" "<<r<<endl;
		return INT_MAX;
	}
	
	if(a <= l && r <= b){
		// cout<<a<<" c "<<b<<" "<<k<<" "<<l<<" "<<r<<endl;
		// cout<<dat[k]<<endl;
		return dat[k];
	}else {
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2 );
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		// cout<<a<<" b "<<b<<" "<<k<<" "<<l<<" "<<r<<endl;
		// cout<<vl<<" b "<<vr<<endl;
		return min(vl, vr);
	}
}

int main(){
	int n, q, com, x, y;
	
	cin>>n>>q;
	
	n = init(n);
	
	for(int i = 0; i < q; i++){
		scanf("%d %d %d", &com, &x, &y);
		if(com){
			printf("%d\n",query(x,y+1,0,0,n));
		}else{
			update(x,y);
		}
		//for(int i = 0; i < n*2; i++)
			//cout<<i<<" "<<dat[i]<<endl;
		
	}
	
	return 0;
}


Measured memory_bytes: 4228
import java.util.*;
import java.util.function.Predicate;

public class Main {

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        Scanner cin = new Scanner(System.in);
        N = cin.nextInt();
        M = cin.nextInt();
        Q = cin.nextInt();
        L = new int[M];
        R = new int[M];
        for (int i = 0; i < M; i++) {
            L[i] = cin.nextInt();
            R[i] = cin.nextInt();
        }
        p = new int[Q];
        q = new int[Q];
        for (int i = 0; i < Q; i++) {
            p[i] = cin.nextInt();
            q[i] = cin.nextInt();
        }

        dp = new int[N + 1][N + 1];
        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= N; j++) {
                dp[i][j] = -1;
            }
        }

        calc();
    }

    int N, M, Q;
    int[] L, R;
    int[] p, q;
    int[][] table;
    int[][] dp; // subquery(l, r)の結果をメモする。

    void calc() {
        //table[i][j] : L=i, R=jとなる列車がいくつあるか
        table = new int[N + 1][N + 1];
        for (int i = 0; i < M; i++) {
            table[L[i]][R[i]]++;
        }

        for (int i = 0; i < Q; i++) {
            System.out.println(query(p[i], q[i]));
        }
    }

    //区間[l, r]に含まれる列車の数を返す
    int query(int p, int q) {
        int ans = 0;
        //L,Rが両方ともp以上q以下であるものを、サブクエリで計算する
        return subquery(q, q) - subquery(q, p - 1) - subquery(p - 1, q) + subquery(p - 1, p - 1);
    }

    // Lがl以下、Rがr以下の個数を返す
    int subquery(int l, int r) {
        // lかrが0であれば、条件に当てはまる列車が存在しないので0を返す
        if (l == 0 || r == 0) return 0;
        //すでに計算済みであれば答えを返す
        if (dp[l][r] != -1) return dp[l][r];
        //subqueryを使って計算する
        int ans = subquery(l - 1, r) + subquery(l, r - 1) - subquery(l - 1, r - 1) + table[l][r];
        return dp[l][r] = ans;
    }
}


Measured memory_bytes: 154548