akhauriyash/Code-Regression huggingface dataset:
// abc074_b
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define FOR(i, a) for (auto i : a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define show1d(v)                                                              \
  rep(i, v.size()) cout << " " << v[i];                                        \
  cout << endl << endl;
#define show2d(v)                                                              \
  rep(i, v.size()) {                                                           \
    rep(j, v[i].size()) cout << " " << v[i][j];                                \
    cout << endl;                                                              \
  }                                                                            \
  cout << endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def, Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def, pii> pip;
typedef vector<pip> vip;
template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  int n, k, sum = 0, x;
  cin >> n >> k;
  rep(i, n) {
    cin >> x;
    sum += min((k - x) * 2, x * 2);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,m;
    cin >> n >> m;
    
    vector<ll>x(m);
    REP(i,m)cin >> x[i];
    if(n >= m){
        cout << 0 << endl;
        return 0;
    }
    vector<ll>diff(m-1);
    SORT(x);
    ll all = x[m-1]-x[0];
    REP(i,m-1)diff[i]=x[i+1]-x[i];
    SORT(diff);
    reverse(ALL(diff));
    REP(i,n-1){
        all-=diff[i];
    }
    cout << all << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool flag=false;
  char C;

  for (int i=0; i<N; i++) {
    cin >> C;
    if (C=='Y') {
      flag=true;
      break;
    }
  }

  if (flag) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }

}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
      int n=Integer.parseInt(line);
      line=sc.nextLine();
      String s[]=line.split(" ",0);
      int num[]=new int[n];
      for(int i=0;i<n;i++){
      	num[i]=Integer.parseInt(s[i]);
      }
      int ans=0;
      for(int i=0;i<n;i++)ans+=num[i];
      
        System.out.println((ans-n));
    }
}

Measured memory_bytes: 25556
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC140B()
{
	int N;
	cin >> N;
	vector<int> A(N), B(N), C(N);
	for (auto& x : A)
	{
		cin >> x;
	}
	for (auto& x : B)
	{
		cin >> x;
	}
	for (auto& x : C)
	{
		cin >> x;
	}
	int x = 0;
	for (int i = 0; i < N; ++i)
	{
		x += B[A[i]-1];
		if (i > 0 && A[i - 1] + 1 == A[i])
		{
			x += C[A[i-1]-1];
		}
	}
	cout << x << endl;
}

int main()
{
	ABC140B();
	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, T;
  cin >> N >> T;

  int ans = 1e9;
  REP(i,N){
    int c, t;
    cin >> c >> t;
    if(t <= T)
      mini(ans, c);
  }

  if(ans == 1e9) cout << "TLE" << endl;
  else cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np

a = [[0] * 3 for i in range(3)]
for i in range(3):
    a[i] = list(map(int, input().split(' ')))

n = int(input())

for i in range(n):
    b = int(input())
    
    for r in range(3):
        for c in range(3):
            if a[r][c] == b:
                a[r][c] = 0

a = np.array(a)
sum1 = a.sum(axis=0)
sum2 = a.sum(axis=1)
naname1 = a[0][0] + a[1][1] + a[2][2]
naname2 = a[0][2] + a[1][1] + a[2][0]

if 0 in sum1 or 0 in sum2 or naname1 == 0 or naname2 == 0:
    print('Yes')
else:
    print('No')

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

//#define   M             100005
#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   inf           (int)1e9

typedef   pair<int,int> P;

map<char,int> mp;

char a[1005];

int main() {

	int n;
	scanf("%d",&n);
	ll M,R,A,C,H,mm,mr,ma,mc,mh;
	
	M=R=A=C=H=0;
	mm=mr=ma=mc=mh=0;
	
	while(n--) {
		scanf("%s",a);
		
		if(a[0] == 'M') M++,mm=1;
		if(a[0] == 'R') R++,mr=1;
		if(a[0] == 'A') A++,ma=1;
		if(a[0] == 'C') C++,mc=1;
		if(a[0] == 'H') H++,mh=1;
	}
	
	if(mm + mr + ma + mc + mh >= 3) {
		printf("%lld\n",M*R*C + M*R*H + M*R*A + M*C*H + M*C*A + M*H*A + R*C*H + R*C*A + R*H*A + C*H*A);
	}
	else
		puts("0");
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111



int main(void) {
  cin >> s;
  cin >> n;
  
  ll pos = inf;

  rep(i, s.length()) {
	if (s[i] != '1') {
	  pos = i + 1;
	  ans = s[i] - '0';
	  break;
	}
  }

  if (n < pos) cout << "1" << endl;
  else cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

signed main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    
    int c = 0;
    rep(i,n){
        if(a[i]>=b[i])continue;
        int t = (b[i]-a[i]+1)/2;
        a[i] += t*2;
        c += t;
    }
    int d = 0;
    rep(i,n){
        assert(a[i]>=b[i]);
        d+=a[i]-b[i];
    }

    if(c>=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

#define mp(x, y) make_pair(x, y)

const int maxn = 5e5 + 10;

int nex1[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}, nex2[20][2] = {{1, 1}, {1, -1}, {-1, 1}, {-1, -1}, {-2, -2}, {-2, -1}, {-2, 0}, {-2, 1}, {-2, 2}, {-1, 2}, {-1, -2}, {0, 2}, {0, -2}, {1, 2}, {1, -2}, {2, 2}, {2, 1}, {2, 0}, {2, -1}, {2, -2}};
int d[1005][1005];
char Map[10005][1005];
int n, m;
int check(int x, int y)
{
  if (x <= 0 || x > n || y <= 0 || y > m || Map[x][y] == '#')
    return 0;
  return 1;
}
void bfs(int a, int b)
{
  d[a][b] = 0;
  deque<pair<int, int> > que;
  que.push_back(mp(a, b));
  while (!que.empty())
  {
    int x, y;
    x = que.front().first, y = que.front().second;
    que.pop_front();
    for (int i = 0; i < 4; i++)
    {
      int _x = x + nex1[i][0], _y = y + nex1[i][1];
      if (check(_x, _y) && d[_x][_y]>d[x][y])
      {
        que.push_front(mp(_x, _y));
        d[_x][_y] = d[x][y];
      }
    }
    for (int i = 0; i < 20; i++)
    {
      int _x = x + nex2[i][0], _y = y + nex2[i][1];
      if (check(_x, _y) && d[_x][_y] > d[x][y]+1)
      {
        d[_x][_y] = d[x][y] + 1;
        que.push_back(mp(_x, _y));
      }
    }
  }
}
void init()
{
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      d[i][j] = 1e9;
}
void solve()
{
  cin>>n>>m;
  int x, y, tox, toy;
  cin>>x>>y>>tox>>toy;
  init();
  getchar();
  for (int i = 1; i <= n; i++)
    scanf("%s", Map[i] + 1);
  bfs(x, y);
  if (d[tox][toy] == 1e9)
    cout << -1 << endl;
  else
    cout << d[tox][toy] << endl;
}
signed main()
{
  solve();
  return 0;
}

Measured memory_bytes: 8652
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(void) {
	int n, a, b;

	cin >> n >> a  >> b;

	if (n*a > b)
		cout << b << endl;
	else
		cout << n*a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for(char c:s)pcu(c);}
//_vo(string s){for(char c:s)pcu(c);}
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
//_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	auto read = [](int n) {
		vector<int> v;
		while (n--)
			v.push_back(in());
		return move(v);
	};
	vector<int> a = read(in()), b = read(in()), r;
	set_union(a.begin(), a.end(), b.begin(), b.end(), inserter(r, r.end()));
	for (int x: r)
		outl(x);
}


Measured memory_bytes: 5920
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[n - 1] - a[0]);
    }
}

Measured memory_bytes: 20820
#include <iostream>
#include <sstream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const double PI = 3.14159265358979323846264338327950;
const LL MOD = 1000000007;

#define PrintLn(X) cout << X << endl
#define Loop(n) for(int loop_ = n; loop_; --loop_)
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, a, b) for(int i = a; i < (int)(b); ++i)

int main(void)
{
	int N;
	cin >> N;
	int a[1000];
	Rep(i, N){
		cin >> a[i];
	}

	int min = 1000000;
	For(j, -100, 101){
		int sum = 0;
		Rep(i, N){
			sum += (a[i] - j) * (a[i] - j);
		}
		if(sum < min){
			min = sum;
		}
	}
	PrintLn(min);
	return 0;
}


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

int main() {
  int64_t N,D;
  int ans =0;
  cin>>N>>D;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    int64_t a,b;
    cin>>a>>b;
    vec.at(i) = a*a+b*b;
  }
  for(int i=0; i<N; i++){
    if(D*D>=vec.at(i))
      ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4788
def main():
    N, M = (int(i) for i in input().split())
    c = [0 for i in range(N)]
    for i in range(M):
        a, b = (int(i) for i in input().split())
        c[a-1] += 1
        c[b-1] += 1
    print(*c, sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38504
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+3+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int tc = 1; //cin >> tc;
	while (tc--)
	{
		int i, j, n;
		cin >> n;
		vector <int> given (n), tests (3*MAXN, 0);
		trav (a, given) cin >> a;
		for (i = -MAXN; i < 2*MAXN; ++i)
			for (j = 0; j < n; ++j)
				tests[i + MAXN] += (given[j] - i)*(given[j] - i);
		int ans = INF;
		trav (a, tests)
			ans = min (ans, a);
		cout << ans << '\n';
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a , b , c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0];
}


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

int main() {
    int N; cin >> N;
    vector<long long> vx(N), vy(N), vh(N);
    int si = -1;
    for (int i = 0; i < N; ++i) {
        cin >> vx[i] >> vy[i] >> vh[i];
        if (vh[i] > 0) si = i;
    }
    
    long long resx = -1, resy = -1, resh = -1;
    for (long long x = 0; x <= 100; ++x) {
        for (long long y = 0; y <= 100; ++y) {
            long long h = vh[si] + abs(x - vx[si]) + abs(y - vy[si]);
            bool ok = true;
            for (int i = 0; i < N; ++i) {
                if (vh[i] > 0 && h - vh[i] != abs(x - vx[i]) + abs(y - vy[i]))
                    ok = false;
                if (vh[i] == 0 && h > abs(x - vx[i]) + abs(y - vy[i]))
                    ok = false;
            }
            if (ok) resx = x, resy = y, resh = h;
        }
    }
    cout << resx << " " << resy << " " << resh << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,a;
  bool f=1;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a;
    if(a%2==0){
      if(a%3==0||a%5==0)f=1;
      else{
        f=0;
        cout << "DENIED" << endl;
        break;
      }
    }
  }
  if(f==1)cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int R = sc.nextInt();

		if (10 >= N) {
			System.out.println(R + 100 * (10 - N));
		} else {
			System.out.println(R);
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<pair<ll, ll>> LR(N);
  for (ll i = 0; i < N; i++)
  {
    ll x, l;
    cin >> x >> l;
    LR.at(i) = make_pair(x - l, x + l);
  }
  sort(LR.begin(), LR.end(), greater<pair<ll, ll>>());

  ll ans = N;
  ll L = INF, R = -INF;
  for (ll i = 0; i < N; i++)
  {
    ll l = LR.at(i).first, r = LR.at(i).second;

    if (L < r)
      ans--;
    else
      L = l, R = r;
  }
  cout << ans << endl;
}

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

int main () {
  int a , b ;
  cin >> a >> b ;
  
  if ( a % 3 == 0 || b % 3 == 0 || ( a + b ) % 3 == 0 ) {
    cout << "Possible" << endl ;
  } else {
    cout << "Impossible" << endl ;
  }
}


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

public class Main {

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

	int N = 8;
	int[] row = new int[N];
	boolean[] col = new boolean[N];
	boolean[] dpos = new boolean[2 * N - 1];
	boolean[] dneg = new boolean[2 * N - 1];

	boolean[][] map = new boolean[N][N];

	void initialize() {
		Arrays.fill(row, -1);
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		initialize();
		int k = scanner.nextInt();
		for (int i = 0; i < k; i++) {
			int r = scanner.nextInt();
			int c = scanner.nextInt();
			row[r] = c;
			col[c] = dpos[r + c] = dneg[r - c + N - 1] = true;
		}
		recurisve(0);

	}

	private void recurisve(int i) {
		if (i == N) {
			printBoard();
			return;
		}
		if (row[i] != -1) {
			recurisve(i + 1);
		}
		for (int j = 0; j < N; j++) {
			if (col[j] || dpos[i + j] || dneg[i - j + N - 1] || row[i] != -1)
				continue;
			row[i] = j;
			col[j] = dpos[i + j] = dneg[i - j + N - 1] = true;
			recurisve(i + 1);
			row[i] = -1;
			col[j] = dpos[i + j] = dneg[i - j + N - 1] = false;
		}
	}

	private void printBoard() {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				System.out.print(row[i] == j ? "Q" : ".");
			}
			System.out.println();
		}
	}

}

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

int n,q,i,j,a[200005],b[200005],p[200005];
vector<int> v[200005];
long long x[200005],y[200005]={0};
bool used[200005]={0};

void dfs(int node){
	used[node]=true;
	for(int ii=0;ii<v[node].size();ii++){
		if(!used[v[node][ii]]){
			y[v[node][ii]]+=y[node];
			dfs(v[node][ii]);
		}
	}
}

int main() {
	// your code goes here
	cin >> n >> q;
	for(i=0;i<n-1;i++){
		cin >> a[i] >> b[i];
		v[b[i]].push_back(a[i]);
		v[a[i]].push_back(b[i]);
	}
	for(i=0;i<q;i++){
		cin >> p[i] >> x[i];
		y[p[i]]+=x[i];
	}
	dfs(1);
	for(i=1;i<=n;i++){
		cout << y[i];
		if(i!=n) cout << " ";
		else cout << endl;
	}
	return 0;
}

Measured memory_bytes: 28416
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
int W,H,x,y,r;
int main(void){
	cin>>W>>H>>x>>y>>r;
	if(0 > y - r || H < y + r) cout<<"No"<<endl; //?????´???????????????????????????????????????
	else if(0 > x - r || W < x + r) cout<<"No"<<endl; //?°´??????????????????????????????????¢??????????
	else cout<<"Yes"<<endl;

}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int h,n,i,sum=0,x;
	cin >> h >> n;
	for(i=0;i<n;i++)
	{
		cin >> x;
		sum += x;
	}
	if(h>sum)
		cout <<"No\n";
	else
		cout <<"Yes\n";
	return 0;
}

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

#define inRange(x,a,b) (a <= x && x <= b)

int main(){
    string s;
    cin >> s;

    bool num = false, low = false, upp = false, len = s.length() >= 6;
    for(char c : s){
        num |= inRange(c, '0', '9');
        low |= inRange(c, 'a', 'z');
        upp |= inRange(c, 'A', 'Z');
    }

    if(num && low && upp && len)    cout << "VALID" << endl;
    else                            cout << "INVALID" << endl;

    return 0;
}


Measured memory_bytes: 3232
n=int(input())
a=[int(i) for i in input().split()]

diff=[]

for i,x in enumerate(a,1):
    diff.append(x-i)
diff.sort()

n=n//2
b=diff[n]

ans=0
for i,x in enumerate(a,1):
    ans+=abs(x-(b+i))

print(ans)

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

int main() {
   vector<int> a(3);
   rep(i, 3) {
       cin >> a[i];
   }

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

   if (a[0] == a[1] && a[1] == a[2]) {
       cout << 1 << endl;
   } else if (a[0] == a[1] || a[1] == a[2]) {
       cout << 2 << endl;
   } else {
       cout << 3 << endl;
   }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn = 2e5+5;
int cnt[maxn],a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
    }
    ll s = 0;
    for(int i=1;i<=n;i++)
    {
        ll t = cnt[i];
        s += t*(t-1)/2;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<s-cnt[a[i]]+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>    
#include <unordered_map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cerr<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define endl "\n"
#define fo(i,n) for(int i=0;i<n;i++)
#define foo(i,x,n) for(int i=x;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define w(x) int x;cin>>x;while(x--)
#define display(a,n) {fo(i,n) {cout<<a[i]<<" ";}cout<<endl;}
#define fil(a,n,val) {fo(i,n) a[i]=val; }
#define sp(x,y) cout<<fixed<<setprecision(y)<<x<<endl;
const ll MOD   = 1000*1000*1000+7;
const ll MOD2  = 998244353;
const ll N = 1000*1000+5;
const double PI  = 3.14159265;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
ll search(vl arr, ll l, ll r, ll x){if (r >= l) {ll mid = l + (r - l) / 2;if (arr[mid] == x)return mid;if (arr[mid] > x)return search(arr, l, mid - 1, x);return search(arr, mid + 1, r, x);} return -1;}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/ gcd(a,b);}
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p; } return res; }
ll modInverse(ll n, ll p){return power(n, p-2, p);}
const int maxn=3001;

double dp[maxn][maxn];
int n;
double a[maxn];

double solve(int i, int x){
	if(x<=0)
		return 1;
	if(i==0)
		return 0;
	if(dp[i][x]>-0.9)
		return dp[i][x];
	return dp[i][x]=a[i]*solve(i-1,x-1)+(1-a[i])*solve(i-1,x);
}


int main(){
	fastio();
	cin>>n;
	foo(i,1,n+1) cin>>a[i];
	fill(dp,-1);
	sp(solve(n,(n+1)/2), 10);
}

Measured memory_bytes: 74372
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){	
	long long int n, k, left, right;
	cin >> n >> k;
	long long int arr[n];
	rarr(arr, n);
	left = 0;
	for(int i = k; i < n; i++){
		if(arr[i] > arr[left]){
			cout << "Yes\n";
		}
		else{
			cout << "No\n";
		}
		left++;
	}
}

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

int md = 998244353;

int main() {
	int N, K;
	cin >> N >> K;
	vector<pair<int,int> > S(K,pair<int,int>(0,0));
	for(int k = 0; k < K; k++){
		int l,r;
		cin >> l >> r;
		S[k].first = l;
		S[k].second = r;
	}

	vector<int> M(N+1,0);
	M[1] = 1;
	vector<int> C(K,0); // cumm個数を入れておく
	for(int i = 2; i <= N; i++){
		for(int k = 0; k < K; k++){
			int r = i - S[k].first;
			int l = i - S[k].second;
			if(1 < l) C[k] = (md + C[k] - M[l-1]) % md;
			if(1 <= r) C[k] = (C[k] + M[r]) % md ;
			M[i] = ((M[i] % md) + (C[k] % md)) % md;
		}
	}
	cout << M[N] << endl;
	return(0);
}


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

int main() {
	int n;
	cin >> n;
	n *= 3;
	vl a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a.begin(), a.end());
	ll ans=0;
	for (int i = 0; i < n/3; i++) {
		ans += a[n - i * 2-2];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


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

    ll i,j,k;
    for(i=1; i<=3500; i++) {
        for(j=i; j<=3500; j++) {
            ll tmp0=n*i*j;
            ll tmp1=4*i*j-n*(i+j);
            if(tmp1>0 && tmp0%tmp1==0) {
                k = tmp0/tmp1;
                printf("%lld %lld %lld\n", i, j, k);
                return 0;
            }
        }
    }
    

    return 0;
}


Measured memory_bytes: 128
from collections import deque

N=int(input())
A=list(map(int,input().strip().split()))

A.sort(reverse=True)

dp=deque([A[1]])
point=A[0]
cnt=0
for n in range(2,len(A)):
    if cnt==0:
        p=dp.popleft()
        cnt+=1
        dp.append(A[n])
        point+=p
    else:
        cnt=0
        dp.append(A[n])
        point+=p

print(point)

Measured memory_bytes: 33396
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int a, b;
    cin >> a >> b;
    string ab(b, '0' + a), ba(a, '0' + b);
    cout << min(ab, ba) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[102][100005];
int main()
{
	ll n,W;
	cin>>n>>W;
	ll va[n+1],wt[n+1];
	for(int i=1;i<=n;i++)
	cin>>wt[i]>>va[i];
	for(int i=0;i<=n;i++)
	for(int j=1;j<=100000;j++)
	dp[i][j]=INT_MAX;
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		for(ll j=1;j<=100000;j++)
		{
			if(j<va[i])
			{
				dp[i][j]=dp[i-1][j];
				continue;
			}
			dp[i][j]=min(dp[i-1][j-va[i]]+wt[i],dp[i][j]);
			dp[i][j]=min(dp[i][j],dp[i-1][j]);
			if(dp[i][j]<=W)
			ans=max(ans,j);
		}
	}
	cout<<ans<<endl;
}

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

int main()
{
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    char i = 'a';
    char c;
    while(true){
        c = s[i - 'a'][0];
        s[i - 'a'].erase(0,1);
        if(s[c - 'a'].empty()) break;
        i = c;
     //   cout << s[i - 'a'] << endl;
    }
    cout << char(c + 'A' - 'a')<< endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i];
    if (i != vec.size() - 1) os << ',';
  }
  os << '}';
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
// constant
constexpr int INF = (1<<30) - 1;  // 1.073741823e9
constexpr int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
constexpr int MOD = 1000000007;

double calc_triangle(double X1, double Y1, double X2, double Y2, double X3, double Y3) {
  return abs((X2 - X1) * (Y3 - Y1) - (Y2 - Y1) * (X3 - X1)) *  0.5;
}

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

  double X1, X2, X3, Y1, Y2, Y3;
  cin >> X1 >> Y1 >> X2 >> Y2 >> X3 >> Y3;
  double s = calc_triangle(X1, Y1, X2, Y2, X3, Y3);
  double h = 2 * s / max({hypot(X1 - X2, Y1 - Y2), hypot(X2 - X3, Y2 - Y3), hypot(X3 - X1, Y3 - Y1)}); 
  cout << setprecision(15)  << s / (0.5 * (hypot(X1 - X2, Y1 - Y2) + hypot(X2 - X3, Y2 - Y3) + hypot(X3 - X1, Y3 - Y1)) + h);

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int length,a;
  int count=0,result=0;
  cin >> length;
  while(length>count && cin >> a){
    while(a%2==0){
      a=a/2;
      result++;
      }
    count++;
    }
    cout << result <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!
 
// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long
 
//////////////////////
const int N = 100005;


int32_t main() {
 
    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
	int tt = 1;
	// cin/ >> tt;
	while(tt--) {
		int n;
		string st;
		cin >> n >> st;
		int cnt = 0;
		rep(i,n) if(st[i]=='A' and i+1<n and st[i+1]=='B' and i+2<n and st[i+2]=='C') cnt++;
		cout << cnt << '\n';
	}
}


Measured memory_bytes: 256
import sys
INFTY=sys.maxsize
sys.setrecursionlimit(100000)

def readinput():
    n=int(input())
    nList=[]
    for _ in range(n+1):
        nList.append([])
    for _ in range(1,n):
        u,v,w=map(int,input().split())
        nList[u].append((v,w))
        nList[v].append((u,w))

    return n,nList

WHITE=0
GRAY=1
BLACK=2
status=[]
color=[]

def dfs(s,nList):
    for u,w in nList[s]:
        if status[u]==WHITE:
            if w%2==0:
                color[u]=color[s]
            else:
                color[u]=(color[s]+1)%2
            status[u]=GRAY
            dfs(u,nList)
    status[s]=BLACK

def main(n,nList):
    global status
    global color

    status=[WHITE]*(n+1)
    color=[WHITE]*(n+1)
    dfs(1,nList)

    for i in range(1,n+1):
        print(color[i])
    

if __name__=='__main__':
    n,nList=readinput()
    main(n,nList)
    #print(ans)


Measured memory_bytes: 82112
#include<stdio.h>

int main()
{
  char n[50];
  int h=0;
  int n1[3];
  int temp=0;
  while(1)
    {
      for(int i = 0; i<3; i++)
	{
	  scanf("%d", &n1[i]);
	}
      if(n1[0] == -1 && n1[1] == -1 && n1[2] == -1)
	{
	  break;
	}
      temp = n1[0]+n1[1];
      if(n1[0] == -1 || n1[1] == -1)
	{
	  temp = 0;
	}
      if(temp >= 80)
	{
	  n[h] = 'A';
	  h++;
	}
      if(65<=temp && temp<80)
	{
	  n[h] = 'B';
	  h++;
	}
      if(50<=temp && temp <65)
	{
	  n[h] = 'C';
	  h++;
	}
      if(temp>=30 && temp <50)
	{
	  if(n1[2] >= 50)
	    {
	      n[h] = 'C';
	      h++;
	    }
	  else
	    {
	      n[h] = 'D';
	      h++;
	    }
	}
      if(temp<30)
	{
	  n[h] = 'F';
	  h++;
	}
    }
  for(int i = 0; i<h; i++)
    {
      printf("%c\n", n[i]);
    }
}



Measured memory_bytes: 2064
#include<iostream>
using namespace std;
int main()
{
	int L,R,d;
  	cin>>L>>R>>d;
  	int ans=0;
  	for(int i=L;i<=R;i++)
    {
      	if(i%d==0)ans++;
    }
  	cout<<ans;
  	return 0;
}

Measured memory_bytes: 3624
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    auto A = new long[][](N);
    foreach (i; 0 .. N)
        A[i] = aryread();

    long ans;
    auto B = new long[][](N, N);
    foreach (i; 0 .. N)
        foreach (j; i + 1 .. N)
        {
            ans += A[i][j];
            bool b = true;
            foreach (k; 0 .. N)
            {
                if (i == k || j == k)
                    continue;
                if (A[i][j] == A[i][k] + A[k][j] && b)
                {
                    ans -= A[i][j];
                    b = false;
                }
                if (A[i][k] + A[k][j] < A[i][j])
                {
                    writeln(-1);
                    return;
                }
            }
        }
    writeln(ans);
}


Measured memory_bytes: 8728
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a =  Integer.parseInt(sc.next());
        int b =  Integer.parseInt(sc.next());      
        int c =  Integer.parseInt(sc.next());               
        int d =  Integer.parseInt(sc.next());
        int x = a*b;
        int y = c*d;
        if(x < y)System.out.println(y);
        else if (x > y ) System.out.println(x);
        else System.out.println(x);       
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll X, K, D;
	cin >> X >> K >> D;
	if (X > 0) {
		ll k = X / D;
		if (k >= K) {
			cout << abs(X - K*D) << endl;
		} else {
			X -= k*D;
			K -= k;
			if (K % 2 == 0) {
				cout << abs(X) << endl;
			} else {
				cout << abs(X - D) << endl;
			}
		}
	} else if (X < 0) {
		ll k = abs(X) / D;
		if (k >= K) {
			cout << abs(X + K*D) << endl;
		} else {
			X += k*D;
			K -= k;
			if (K % 2 == 0) {
				cout << abs(X) << endl;
			} else {
				cout << abs(X + D) << endl;
			}
		}
	} else {
		if (K % 2 == 0) {
			cout << abs(X) << endl;
		} else {
			cout << abs(D) << endl;
		}
	}
	
}



Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,max,c,d,e;
    scanf("%d%d",&a,&b);
    c=a+b;d=a-b;e=a*b;
    max=c;
    if(max<d)
        max=d;
    if(max<e)
        max=e;
    printf("%d",max);
    return 0;
}


Measured memory_bytes: 128
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;

 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	int x,y,z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y;
}

Measured memory_bytes: 3620
n = int(input())
an = list(map(int, input().split()))
ls = [0] * (n+1)
for i in an:
    ls[i] += 1
ms = [i*(i-1)/2 for i in ls]
kei = sum(ms)
for j in an:
    j=ls[j]
    ans = kei - j*(j-1)/2 + (j-2)*(j-1)/2
    print(int(ans))

Measured memory_bytes: 32260
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
inline int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	string s;
	cin>>s;
	cout<<s.substr(0,3);
	return 0;
}



Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>

struct Node{
  int key;
  struct Node *ri, *le, *pa;
};

struct Node *ro, *Nu;

struct Node *find(struct Node *u,int k){
  while(u!=Nu&&k!=u->key){
    if(k<u->key){
      u=u->le;
    }
    else{
      u=u->ri;
    }
  }

  return u;
}

void insert(int k){
  struct Node *y=Nu;
  struct Node *x=ro;
  struct Node *z;

  z=(struct Node*)malloc(sizeof(struct Node));
  z->key=k;
  z->le=Nu;
  z->ri=Nu;

  while(x!=Nu){
    y=x;
    if(z->key<x->key){
      x=x->le;
    }
    else{
      x=x->ri;
    }
  }

  z->pa=y;
  if(y==Nu){
    ro=z;
  }
  else{
    if(z->key<y->key){
      y->le=z;
    }
    else{
      y->ri=z;
    }
  }
}

void inorder(struct Node *u){
  if(u==Nu){
    return;
  }
  inorder(u->le);
  printf(" %d",u->key);
  inorder(u->ri);
}

void preorder(struct Node *u){
  if(u==Nu){
    return;
  }
  printf(" %d",u->key);
  preorder(u->le);
  preorder(u->ri);
}

int main(){
  int n,i,x;
  char com[20];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      struct Node *t=find(ro,x);
      if(t!=Nu){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0]=='p'){
      inorder(ro);
      printf("\n");
      preorder(ro);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 20488
module IntSet = Set.Make (struct type t = int let compare = compare end)

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  Array.init n (fun _ -> Scanf.scanf "%d\n" (fun s -> s))
  |> Array.fold_left (fun set s ->
      IntSet.fold (fun s' set ->
        IntSet.add (s + s') set) set set) (IntSet.singleton 0)
  |> IntSet.elements
  |> List.filter (function 0 -> true | s -> s mod 10 <> 0)
  |> List.rev
  |> List.hd
  |> Printf.printf "%d\n"


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

typedef long long ll;
ll n,ans=0;
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    for(ll i=sqrt(n);i>=1;--i)
    {
    	if(n%i==0)
    	{
    		ll res=n/i;
    		while(res)
    		{
    			res/=10;
    			++ans;
    		}
    		break;
    	}
    }
    cout << ans << "\n";
    return 0;                             
}

Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<queue>
#include<algorithm>
using namespace std;
const int MAXN=500005;

int N,K,A[MAXN];
int pos[MAXN];
vector<int> adj[MAXN];
set<int> L,R;
priority_queue<int,vector<int>,greater<int> > Q;
vector<int> stk;
int pri[MAXN];
int deg[MAXN];

int main()
{
    scanf("%d%d",&N,&K);
    for(int i=1;i<=N;i++)
        scanf("%d",&A[i]),pos[A[i]]=i;
    for(int i=1;i<=K;i++)
        R.insert(A[i]);
    set<int>::iterator x,y;
    for(int i=1;i<=N;i++)
    {
        x=L.upper_bound(A[i]);
        y=R.upper_bound(A[i]);
        if(x!=L.end())
        {
            adj[i].push_back(pos[*x]);
            deg[pos[*x]]++;
        }
        if(y!=R.end())
        {
            adj[i].push_back(pos[*y]);
            deg[pos[*y]]++;
        }
        L.insert(A[i]);
        if(i-K+1>0)
            L.erase(A[i-K+1]);
        if(i+K<=N)
            R.insert(A[i+K]);
        R.erase(A[i]);
    }

    for(int i=1;i<=N;i++)
        if(deg[i]==0)
            Q.push(i);
    while(!Q.empty())
    {
        int u=Q.top();
        Q.pop();
        stk.push_back(u);
        for(int i=0;i<(int)adj[u].size();i++)
        {
            deg[adj[u][i]]--;
            if(deg[adj[u][i]]==0)
                Q.push(adj[u][i]);
        }
    }
    for(int i=0;i<N;i++)
        pri[stk[i]]=i+1;
    for(int i=1;i<=N;i++)
        printf("%d\n",pri[i]);

    return 0;
}



Measured memory_bytes: 64240
/**
 *    Author:   ElProfesor
 *	       
**/

#include<bits/stdc++.h>

using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
typedef vector <lli> vl;
typedef vector <string> vs;
typedef vector < pair <long, long> > vll;
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(lli i=0; i<n; i++)
#define rep(i,k,n) for (lli i = k; i < n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

// Printing Data :
#define pvec(v) forz(i,v.si) cout<<v[i]<<" "; cout<<endl;
#define parr(arr, n) forz(i,n) cout<<arr[i]<<" "; cout<<endl;
#define p1(i) cout<<i<<endl;
#define p2(i, j) cout<<i<<" "<<j<<endl;
#define p3(i, j, k) cout<<i<<" "<<j<<" "<<k<<endl;
#define p4(i, j, k, l) cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;

typedef pair <lli,lli> pll;
 
// CODE BEGINS :

int main()
{
    kira; 

    string s; cin>>s;

    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;

    return 0;
}




















































Measured memory_bytes: 3652
def Find(x, par):
    if par[x] < 0:
        return x
    else:
        par[x] = Find(par[x], par)
        return par[x]

def Unite(x, y, par, rank):
    x = Find(x, par)
    y = Find(y, par)

    if x != y:
        if rank[x] < rank[y]:
            par[y] += par[x]
            par[x] = y
        else:
            par[x] += par[y]
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

def Same(x, y, par):
    return Find(x, par) == Find(y, par)

def Size(x, par):
    return -par[Find(x, par)]

import sys
import io, os
#input = sys.stdin.buffer.readline
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n, q = map(int, input().split())
par = [-1]* n
rank = [0]*n
for i in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        Unite(u, v, par, rank)
    else:
        if Same(u, v, par):
            print(1)
        else:
            print(0)        


Measured memory_bytes: 83560