akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <list>

class Point {
public:
    int x;
    int y;
};

class Pair {
public:
    Point red;
    Point blue;
};

bool cmpYDescendant(const Point &left, const Point &right) {
    return left.y > right.y;
}

bool cmpXAscendant(const Point &left, const Point &right) {
    return left.x < right.x;
}

int N;
std::list<Point> reds;
std::list<Point> blues;
std::list<Pair> pairs;
typedef std::list<Point>::iterator ItP;

int main() {
    Point p;

    std::cin >> N;

    for (int i = 1; i <= N; ++i) {
        std::cin >> p.x >> p.y;
        reds.push_back(p);
    }

    for (int i = 1; i <= N; ++i) {
        std::cin >> p.x >> p.y;
        blues.push_back(p);
    }

    reds.sort(cmpYDescendant);
    blues.sort(cmpXAscendant);
    ItP it_b = blues.begin();

    while(it_b != blues.end()) {
        bool found = false;
        ItP it_r = reds.begin();

        while(it_r != reds.end()) {
            if ((*it_r).x < (*it_b).x && (*it_r).y < (*it_b).y) {
                Pair p;

                found = true;
                p.red = *it_r;
                p.blue = *it_b;
                pairs.push_back(p);
                reds.erase(it_r);
                break;
            }

            ++it_r;
        }

        if (found) {
            it_b = blues.erase(it_b);
        } else {
            ++it_b;
        }
    }

    std::cout << pairs.size() << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

char CC[100000][6];
int CN[100000];

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint(int i) {
	int A = 0;
	int pn = 1;
	int kazu = 0;
	if (ci - cn + 16 > cm) {
		if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); CC[i][kazu] = '-'; kazu++; }
		A = ct - '0';
		CC[i][kazu] = ct; 
		kazu++;
		while ((ct = getcha()) >= '0') { A = A * 10 + ct - '0'; CC[i][kazu] = ct; kazu++; }
		CN[i] = kazu;
		return pn * A;
	}
	else {
		if ((ct = *ci++) == '-') { pn = -1; ct = *ci++;  CC[i][kazu] = '-'; kazu++;	}
		A = ct - '0';
		CC[i][kazu] = ct;
		kazu++;
		while ((ct = *ci++) >= '0') { A = A * 10 + ct - '0'; CC[i][kazu] = ct; kazu++; }
		CN[i] = kazu;
		return pn * A;
	}
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putintsp(int X) {
	if (X < 0) {
		*di++ = '-';
		X = -X;
	}
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}
inline void putint(int X) {
	if (X < 0) {
		*di++ = '-';
		X = -X;
	}
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint(0);
	int A[100000];
	int saidai = -1e9;
	int saishou = 1e9;
	int isaidai, isaishou;
	rep(i, N) {
		A[i] = getint(i);
		if (A[i] > saidai) {
			saidai = A[i];
			isaidai = i;
		}
		else if (A[i] < saishou) {
			saishou = A[i];
			isaishou = i;
		}
	}
	for (int i = 0; i < N; i++) {
		if (i != isaidai && i != isaishou) {
			if (A[i] < 0) {
				putintsp(saidai);
				rep(j, CN[i]) *di++ = CC[i][j];
				*di++ = '\n';
				saidai -= A[i];
			}
			else {
				putintsp(saishou);
				rep(j, CN[i])* di++ = CC[i][j];
				*di++ = '\n';
				saishou -= A[i];
			}
		}
	}
	putintsp(saidai);
	putint(saishou);

	int X = saidai - saishou;

	if (X == 0) {
		putchar_unlocked('0');
		putchar_unlocked('\n');
	}
	else {
		if (X < 0) {
			putchar_unlocked('-');
			X = -X;
		}
		int keta = 0;
		char C[10];
		while (X) {
			*(C + keta) = '0' + X % 10;
			X /= 10;
			keta++;
		}
		for (int i = keta - 1; i >= 0; i--) putchar_unlocked(*(C + i));
		putchar_unlocked('\n');
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 5120
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  ll a; string b; cin >> a >> b;
  int B = stoi(b.substr(0, b.length() - 3) + b.substr(b.length() - 2, 2));
  cout << a * B / 100 << '\n';
  return 0;
}


Measured memory_bytes: 3660
from sys import stdin

M, D = map(int, stdin.readline().rstrip().split())

if M < 4 or D < 22:
    print(0)
    exit(0)

cnt = 0
for i in range(21, D + 1):
    mod = i % 10
    if mod > 1 and mod * (i // 10) <= M:
        cnt += 1

print(cnt)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

bool kaibun(string s){
    size_t len = s.length();
    for(int i = 0; i < len/2; i++){
        if(s[i] != s[len-i-1]) return false;
    }
    return true;
}

void Kitei(int N,int K, vector<int> & v){
    int sho = N/K;
    int amari= N%K;
    v.push_back(amari);
    if(sho==0){
        return;
    }
    Kitei(sho,K,v);
}

int main(){
    int N =0;
    cin >> N;
    for(int i=0; i<N; i++){
        int tmp=0;
        cin >> tmp;
        if(tmp%2 == 0){
            if( (tmp%3 != 0) && (tmp%5 != 0)){cout <<"DENIED"<<endl;return 0;}
        }
    }
    cout << "APPROVED"<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

def str2num(s):
    d = {}
    ret = []
    idx = 0
    for ch in s:
        if ch not in d:
            d[ch] = idx
            idx += 1
        ret.append(d[ch])
    return ret

if str2num(S) == str2num(T):
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 6832
//        THIS IS MY NINJA WAY
#include<bits/stdc++.h>
#include<ctime>
#include<vector>
#include<algorithm>

#define str string
#define dbl double
#define ll long long
#define vl vector<ll> 
#define vs vector<str>
#define pll  pair<ll,ll> 
#define vll vector<pll>
#define sl set<ll>
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define fr(i,a,b) for(long long i=a; i<b; i++)
#define nfr(i,a,b) for(long long i=a; i<=b; i++)
#define psl pair<str,ll>
#define pls pair<ll,str>
#define pss pair<str,str>
#define ALL(a) a.begin(),a.end()
#define stl stack<ll>
#define coml complex<ll>
#define INF 0x3f3f3f3f3f3f3f3f
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
const ll MOD = 1e9+7;


using namespace std;
int main()
{
	fast
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r" , stdin);
		freopen("output.txt", "w" , stdout);
	#endif*/
    
    ll n;
    cin>>n;
    vl v(n);
    fr(i,0,n)cin>>v[i];
    vl dp(n);//as we want minimum number thus setting all to infinity
    dp[0];
    dp[1]=abs(v[1]-v[0]);
    fr(i,2,n){
    	dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    }
    cout<<dp[n-1];
	return 0;
}
	

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, p;
  scanf("%d %d", &n, &p);

  vector<int> v;
  SV(n,v);

  llong dp[51][5001] = {};

  dp[0][0] = 1;

  REP(i,n){
    REP(j,5001){
      if(j - v[i] >= 0){
        dp[i + 1][j] = dp[i][j] + dp[i][j - v[i]];
      }else{
        dp[i + 1][j] = dp[i][j];
      }
    }
  }

  llong ans = 0;
  REP(i,5001){
    if(i % 2 == p){
      ans += dp[n][i];
    }
  }

  printf("%lld\n", ans);
  return 0;
}


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

typedef long long ll;
#define int ll
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;


void solve() {
	int n;
	cin >> n;
	if(n >= 30) cout << "Yes";
	else cout << "No";
}


int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}



Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const long long int INF=1e16;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<long long int> > x(3, vector<long long int>(N));
    for(int n=0; n<N; n++) {
        for(int i=0; i<3; i++) {
            cin >> x[i][n];
        }
    }
    // cout << endl;
    
    long long int ans=0;
    for(int bit=0; bit<(1<<3); bit++) {
        vector<long long int> vec(N, 0);
        for(int i=0; i<3; i++) {
            for(int n=0; n<N; n++) {
                if(bit & (1<<i)) {
                    vec[n] -= x[i][n];
                } else {
                    vec[n] += x[i][n];
                }
                if(i==2) {
                    // cout << vec[n] << " ";
                }
            }
        }
        // cout << endl;

        vector<vector<long long int> > memo(N+1, vector<long long int>(M+1, -INF));
        memo[0][0]=0;
        for(int n=1; n<N+1; n++) {
            memo[n][0] = 0;
            for(int m=1; m<M+1; m++) {
                if(memo[n-1][m-1]==-INF) break;
                if(memo[n-1][m-1]!=INF) {
                    memo[n][m] = memo[n-1][m];
                }
                memo[n][m] = max(memo[n][m], memo[n-1][m-1]+vec[n-1]);
                
                // cout << memo[n][m] << " ";
            }
            // cout << endl;
        }
        // cout << endl;
        
        ans = max(ans, memo[N][M]);
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 8200
#include<bits/stdc++.h>
using namespace std;
int main() { 
    int N, M;
    cin>>N>>M;
    int a[N];
    for(int i=0;i<N;i++){
      a[i] = 0;
    }
    for(int i=0;i<M;i++){
        int x,y;
        cin>>x>>y;
        a[x - 1]++;
        a[y - 1]++;
    }
    bool ans=true;
    for(int i=0;i<N;i++){
        if(a[i]%2!=0){
          ans = false;
        }
    }
    if(ans){
      cout << "YES" << endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if (T[u].p == NIL) cout << "root, ";
  else if (T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";
  for (i = 0, c = T[u].l; c!= NIL; i++, c = T[c].r) {
    if (i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

int rec(int u, int p) {
  D[u] = p;
  if (T[u].r != NIL) rec(T[u].r, p);
  if (T[u].l != NIL) rec(T[u].l, p+1);
}

int main() {
  int i, j, d, v, c, l, r;
  cin >> n;
  for (i = 0; i < n; ++i) T[i].p = T[i].l = T[i].r = NIL;

  for (i = 0; i < n; ++i) {
    cin >> v >> d;
    for (j = 0; j < d; ++j) {
      cin >> c;
      if (j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for (i = 0; i < n; i++) {
    if (T[i].p == NIL) r = i;
  }
  rec(r, 0);
  for (i = 0; i < n; i++) print(i);
  return 0;
}



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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> b(N);
    for (int i=0;i<N;i++) {
        cin >> b[i];
        b[i]--;
    }
    vector<int> step;
    while (b.size() > 0){
        bool flag = false;
        for (int i=b.size()-1;i>=0;i--){
            if (i==b[i]) {
                step.push_back(i);
                b.erase(b.begin()+i);
                flag = true;
                break;
            }
        }
        if (!flag){
            cout << -1 << "\n";
            return 0;
        }
    }
    for (int i=step.size()-1;i>=0;i--){
        cout << step[i]+1 << "\n";
    }

    return 0;
}

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

int main()
{
    int n, min, max, a[200];

    while( cin >> n >> min >> max )
    {
        if( n + min + max == 0 )
            break;

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

        int max_distance = 0, j = 0;
        for( int i = min; i <= max; i++ )
            if( a[i-1] - a[i] >= max_distance )
            {
                max_distance = a[i-1] - a[i];
                j = i;
            }

        cout << j << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

int main() {
  int N;
  cin >> N;

  repp(i, 1, 9) {
    repp(j, 1, 9) {
      if (i * j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << 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 = Integer.parseInt(sc.next());
		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		long c = a - b;

		long[] h = new long[n];

		for (int i = 0; i < n; i++) {
			h[i] = Long.parseLong(sc.next());
		}

		long right = h[0] / b;
		long left = 0;

		while (left < right) {
			long sum = 0;

			for (int i = 0; i < n; i++) {
				if (h[i] - b * right <= 0)
					continue;

				long t = h[i] - b * right;

				if (t % c == 0)
					sum += t / c;
				else
					sum += t / c + 1;

			}

			if (sum <= right) {
				right = (right + left) / 2;
			} else {
				left = right;
				right = sum;
			}

		}

		if (left == right)
			right++;
		System.out.println(right);

	}

}


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

using namespace std;

const int ms = 1e5 + 17;
const int mod = 1e9 + 7;

int sum(int n)
{
    int answer = 0;

    while(n)
    {
        answer += n % 10;
        n /= 10;
    }

    return answer;
}

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

    int n;
    cin >> n;

    int sumn = sum(n);

    if(n % sumn)
        cout << "No\n";
    else
        cout << "Yes\n";


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k - 1] = (s[k - 1] - ('A' - 'a'));
    cout << s << endl;
    return 0;
}

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

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

int mod = 1e9 + 7;


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

    int N;
    cin >> N;

    vector<int> C(N), dp(N + 1), pos(200005, -1);
    REP(i, N) cin >> C[i];

    dp[0] = 1;
    REP(i, C.size()) {
        int prev = pos[C[i]];
        pos[C[i]] = i;
        if (i > 0 && C[i] == C[i - 1]) {
            dp[i + 1] = dp[i];
            continue;
        }
        dp[i + 1] = dp[i];
        if (prev == -1 || prev == i - 1) continue;
        dp[i + 1] += dp[prev + 1];
        dp[i + 1] %= mod;
    }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>

const int MAXN = 1e5 + 5;

using namespace std;

int n,v[MAXN],dp[MAXN][4],a[MAXN],b[MAXN],c[MAXN];

int main()
{
    cin>>n;
    for(int i = 1; i <= n; i++)
        cin>>a[i]>>b[i]>>c[i];
    dp[1][1] = a[1],dp[1][2] = b[1],dp[1][3] = c[1];
    for(int i = 2; i <= n; i++){
        dp[i][1] = max(dp[i - 1][2],dp[i - 1][3]) + a[i];
        dp[i][2] = max(dp[i - 1][1],dp[i - 1][3]) + b[i];
        dp[i][3] = max(dp[i - 1][1],dp[i - 1][2]) + c[i];
    }
    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
    return 0;
}


Measured memory_bytes: 2944
from collections import deque

N, M = map(int, input().split())

dist = [-1] * (N+1)
dist[1] = 0
connection = [[] for _ in range(N+1)]
ans = [-1] * (N+1)

for quel in range(M):
    a, b = map(int, input().split())
    connection[a].append(b)
    connection[b].append(a)

que = deque()
que.append(1)

while que:
    v = que.popleft()

    for i in connection[v]:
        if dist[i] != -1:continue

        dist[i] = dist[v] + 1
        que.append(i)
        ans[i] = v

#print(dist)
print('Yes')
for j in range(2, N+1):
    print(ans[j])

Measured memory_bytes: 34764
#include<stdio.h>

int main()
{
    int s, cnt = 1;
    scanf("%d", &s);
    if((s == 1) || (s == 2))
    {
        printf("4");} else {
    while(1)
    {
        switch(s % 2)
        {
            case 0:
                s = s / 2;
                break;
            case 1:
                s = s * 3 + 1;
                break;
        }
        cnt++;
        if(s == 1) break;
    }
    cnt += 1;
    printf("%d", cnt);
    }
    return 0;
}


Measured memory_bytes: 128
N,A,B = map(int,input().split())
M = 2**(N-1)

if N==1:
    print('YES')
    print(A,B)
    exit()

gray = [0]
for i in range(1,M):
    gray.append(gray[-1] ^ (i&(-i)))
grid = [gray, [a+M for a in gray]]

for i,row in enumerate(grid):
    if A in row:
        sx,sy = row.index(A),i
    if B in row:
        gx,gy = row.index(B),i

if (abs(sx-gx) + abs(sy-gy)) % 2:
    print('YES')
else:
    print('NO')
    exit()

ans = [A]

x,y = sx,sy
while (gx-x)%M != 1:
    x += 1
    x %= M
    ans.append(grid[y][x])
y = 1-y
ans.append(grid[y][x])
while x != sx:
    x -= 1
    x %= M
    ans.append(grid[y][x])

if x != gx:
    while 1:
        x -= 1
        x %= M
        ans.append(grid[y][x])
        y = 1-y
        ans.append(grid[y][x])
        if x==gx: break

print(*ans)

Measured memory_bytes: 12436
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意


#n = int(input())
n,m = [int(i) for i in readline().split()]
x = [int(i) for i in readline().split()]
y = [int(i) for i in readline().split()]

MOD = 10**9+7

si = 0
for i in range(n-1):
    si += (x[i+1]-x[i])*(i+1)*(n-i-1)
    si %= MOD

sj = 0
for j in range(m-1):
    sj += (y[j+1]-y[j])*(j+1)*(m-j-1)
    sj %= MOD


#print(si,sj)

print(si*sj%MOD)

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

int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.length();i++){
        if(i%2==0){
            if('R'==s[i] || 'U'==s[i] || 'D'==s[i]) continue;
            else{
                printf("No");
                return 0;
            }
        }
        else{
            if('L'==s[i] || 'U'==s[i] || 'D'==s[i]) continue;
            else{
                printf("No");
                return 0;
            }
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        cnt = 0
        if not i%2:
            continue
        for j in range(1, i+1):
            if i%j==0:
                cnt += 1
        if cnt == 8:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin>>n;
	vector<long long int> aa(n);
	long long a = 1;
	for(size_t i = 0; i<n; i++)
	{
		cin>>aa[i];
		if(aa[i]==0)
		{
			a = 0;
		}
	}
	int tf = 1;
	if(a==0)
	{
		cout<<0<<endl;
		return 0;
	}
	else
	{
		for(size_t i = 0; i<n; i++)
		{
			if(1000000000000000000/a>=aa[i])
			{
				a *= aa[i];
			}
			else
			{
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	cout<<a<<endl;
	return 0;
}

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


int main() {
  int N;
  cin >> N;

  map<string, vector<P>> sp;
  rep(i,N) {
    string S;
    int P;
    cin >> S >> P;
    sp[S].push_back(make_pair(P, i+1));
  }

  for(auto d: sp) {
    auto v = d.second;
    sort(v.rbegin(), v.rend());
    for(auto p: v) cout << p.second << endl;
  }

  return 0;
}


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

int main(){
	int n, m, k;
	cin >> n >> m >> k;
	for(int i = 0; i <= n; i++){
		int ri = n - i;
		for(int j = 0; j <= m; j++){
			int rj = m - j;
			if(i * j + ri* rj == k){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
const int MOD = 1e9 + 7;
using namespace std;
int main() {
    int n;
    string s;
    cin >> n >> s;
    if(n%2 == 1)
        cout << "No";
    else
    {
        int flag = 0;
        for (int i = 0; i < n/2; ++i)
        {
            if(s[i] != s[n/2+i])
            {
                flag = 1;
                break;
            }
        }
        if (flag == 1)
            cout << "No\n";
        else
            cout << "Yes\n";    
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	long long ans=0;
	if(a%2==0||b%2==0||c%2==0)
	  printf("0");
	else
	  {
	  	ans=a*b;
	  	ans=min(ans,a*c);
	  	ans=min(ans,b*c);
		printf("%lld",ans);
	  }
	
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define unsort(vec) sort(vec); rever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(!(a%2*b%2*c%2)) cout<<0<<endl;
  else cout<<min({a*b,b*c,c*a})<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;

int main()
{
  int n[3]; 
  int a = 0, b = 0, c = 0;
  while(true)
  {
    cin >> n[0] >> n[1] >> n[2];
    sort(n, n + 3);
    if(n[0] + n[1] <= n[2])
    {
      printf("%d %d %d %d\n", a + b + c, a, b, c);
      return 0;
    }
    double d = pow(n[0], 2) + pow(n[1], 2), v = pow(n[2], 2);
    
    if(d == v)
      a++;
    else if(d > v)
      b++;
    else if(d < v)
      c++;
  }
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll r = in(), g = in(), b = in();
	cout << ((r * 100 + g * 10 + b) % 4 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

l = [A[0]]
s = {A[0]}
a = A[0] - 1
for _ in range(K):
    if A[a] not in s:
        l.append(A[a])
        s.add(A[a])
        a = A[a] - 1
    else:
        a = A[a]
        break
n = len(l)
b = 0
for i in range(n):
    if l[i] == a:
        del l[0:i]
        b = i
        break
T = len(l)
S = (K - b) % T
ans = l[S - 1]

print(ans)


Measured memory_bytes: 32456
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.Set;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();


		Set<Integer> adj[] = new HashSet[n+1];
		for(int i = 1; i<adj.length; i++) {
			adj[i] = new HashSet<Integer>();
		}


		for(int i = 0; i < m; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();

			adj[a].add(b);
			adj[b].add(a);
		}

		int[] dist = new int[n+1];
		dist[0] = 0;
		int[] ans = new int[n+1];

		int[] end = new int[n+1];
		end[1]++;
		ArrayDeque<Integer> q = new ArrayDeque<>();
		q.add(1);

		while(!q.isEmpty()) {

			int v1 = q.poll();

			int tdist = dist[v1] + 1;

			Iterator<Integer> adjit = adj[v1].iterator();
			while(adjit.hasNext()) {
				int v2 = adjit.next();
				if(end[v2]<1) {
					q.add(v2);
					end[v2]++;

					dist[v2] = tdist;
					ans[v2] = v1;
				}
			}
		}

		System.out.println("Yes");
		for(int i = 2; i < n+1; i++) {
			System.out.println(ans[i]);
		}
	}

}


Measured memory_bytes: 96972
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;
using ll = long long;


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    ll mode=0;
    ll cnt=1;
    for(ll i=0;i<n-1;i++){
        if(a[i]<a[i+1]&&mode==-1){
                cnt++;
                mode=0;
        }
        else if(a[i]>a[i+1]&&mode==1){
                cnt++;
                mode=0;
        }
        else if(a[i]<a[i+1])    mode=1;
        else if(a[i]>a[i+1])    mode=-1;
    }
    cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<pair<int,int>> A(N+1);
    for(int i = 1;i < N+1;i++){
        int a;
        cin >> a;
        A[i] = make_pair(a,i);
    }
    sort(A.begin(),A.end());
    for(int i = 1;i < N+1;i++){
        cout << A[i].second << ' ';
    }
}

Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main(void) {
	int n, m, a;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> a;
		n -= a;
	}
	if (n < 0) n = -1;
	cout << n;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int cost[10][10],c[10][10],a[202][202];
void init(){
    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            if (i == j) cost[i][j] = 0;
            else cost[i][j] = MM;
        }
    }
}
void floyd(){
    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            for (int k = 0; k < 10; k++){
                cost[i][k] = min(cost[i][k], min(c[i][j] + c[j][k], min(cost[i][j] + c[j][k], c[i][j] + cost[j][k])));
            }
        }
    }
}

int main(){
    int H,W; cin >> H >> W;
    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cin >> a[i][j];
        }
    }
    int sum = 0;
    init();
    floyd();
    floyd();
    floyd();
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (a[i][j] == -1 || a[i][j] == 1) continue;
            sum += cost[a[i][j]][1];
        }
    }
    cout << sum << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];

	vector<ll> sum(n+1, 0);
	rep(i,n) sum[i+1] = sum[i] + v[i];
	map<ll, ll> mp;
	rep(i,n+1) mp[sum[i]]++;
	ll ans = 0;
	for (auto p: mp) ans += p.second * (p.second - 1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 17912
#include <iostream>
#include <vector>
#include <list>
#include<utility>
#include <new>
#include <string>
#include<cmath>
#include<unordered_set>
#include<iomanip>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define forloop(i,x,z) for (int i=x;i<z;i++)
using ll = unsigned long long int;
/*bool cmp(pair<ll,ll>a,pair<ll,ll>b){
return a.second<b.second;
}*/
int main()
{int n,k;
	cin >> n>>k;
        int A[n];
        forloop(i,0,n){
                cin>>A[i];
        }

        for(int i=k;i<n;i++){
            if(A[i]>A[i-k]){
                cout<<"Yes"<<endl;
            }else{
                    cout<<"No"<<endl;
            }
        }
	return 0;
}


Measured memory_bytes: 4396
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
import math
N = int(input())
A = prime_factorize(N)
B = list(set(A))
kosuu = [0]*len(B)
ans = 0
for i in range(len(B)):
    kosuu[i] = A.count(B[i])
for i in range(len(kosuu)):
    for j in range(1, int(math.sqrt(N))):
        kosuu[i] -= j
        if kosuu[i] >= 0:
            ans += 1
        else:
            break
print(ans)
        
        


Measured memory_bytes: 63076
n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
key=[]
n_in=0
n_out=0
ans=0
#k%=(10**9+7)
for i in range(n):
    try:
        d[a[i]]+=1
    except:
        d[a[i]]=1
        key.append(a[i])
        key.sort()
    ind=key.index(a[i])
    for j in range(ind+1,len(key)):
        n_in+=d[key[j]]
for val in a:
    ind=key.index(val)
    for j in range(ind+1,len(key)):
        n_out+=d[key[j]]

ans+=n_in*k
ans+=n_out*(k-1)*k//2
ans%=10**9+7
print(ans)


Measured memory_bytes: 9276
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10;
main()
{
	int n,a;
	cin>>n>>a;
	if(n%500<=a)return cout<<"Yes",0;
	cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std ;
int read() {
  int x = 0 , f = 1 ;
  char c = getchar() ;
  while(c < 48 || c > 57) {
    if(c == '-') f = -1 ;
    c = getchar() ;
  }
  while(c > 47 && c < 58) {
    x = (x << 1) + (x << 3) + (c & 15) ;
    c = getchar() ;
  }
  return x * f ;
}
void print(int x) {
  if(x < 0) x = -x , putchar('-') ;
  if(! x) { putchar('0') ; }
  static char st[30] ; int stp = 0 ;
  while(x) { st[++ stp] = x % 10 ^ 48 ; x /= 10 ;}
  while(stp) { putchar(st[stp --]) ; }
  putchar('\n') ;
}
signed main() {
  int sum = read() + read() + read() ;
  if(sum < 22) puts("win") ;
  else puts("bust") ;
  return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}




int main() {
  int n;
  cin >> n;
  vi t(n);
  int total=0;
  REP(i,n) {
    cin >> t[i];
    total+=t[i];
  }
  int m;
  cin >> m;
  REP(i,m) {
    int p,x;
    cin >> p >> x;
    p--;
    int ans = total-t[p]+x;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3580
#include<iostream>
using namespace std;
int a[100010]={0};
int main(){
	int n,q,i,l,r;
	string s;
	cin >> n >> q >> s;
	for(i=1;i<n;i++){
		if(s[i]=='C' && s[i-1]=='A'){
			a[i]=a[i-1]+1;
		}
		else{
			a[i]=a[i-1];
		}
	}
	for(i=0;i<q;i++){
		cin >> l >> r;
		cout << a[r-1]-a[l-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 1408
// Ok it's fine bro  
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		fn{
			cin >> ar[i];
		}
		sort(ar,ar+n);
		int ans =1;
		fn{
			if(ans > 1e18L/ar[i])
				return cout<<"-1",0;
			ans*=ar[i];
			if(ans==0)break;
		}
		cout <<ans;
	
	
	}
	return 0;
}

Measured memory_bytes: 4404
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int t=0;
	int a=s.length();
	for(int i=1;i<a;i++)
	{
		if(s[i]==s[i-1])
		{
			t++;
			int m=(s[i]-'0'+1)%2;
			s[i]=m+'0';
		}
	}
	cout<<t<<endl;
 } 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3588
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

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

		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();

		long[] dp = new long[2001];

		dp[0]=0;
		dp[1]=0;
		dp[2]=0;
		dp[3]=1;
		dp[4]=1;
		dp[5]=1;
		for(int i = 6;i<=S ; i++) {
			dp[i]=(dp[i-1]+dp[i-3])%1000000007;
		}


		System.out.println(dp[S]);
	}

	//素数判定
	public static boolean isPrime(long num) {
		if (num < 2) return false;
		else if (num == 2) return true;
		else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

		double sqrtNum = Math.sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2)
		{
			if (num % i == 0)
			{
				// 素数ではない
				return false;
			}
		}

		// 素数である
		return true;
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


Measured memory_bytes: 35660
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());

    int count = 0;
   for (int i = 1; i <= n; i++) {
      if (i % 2 != 0) {
        count++;
      }
  }

    BigDecimal bd = new BigDecimal(String.valueOf(n));
    BigDecimal bd2 = new BigDecimal(String.valueOf(count));
    System.out.println(bd2.divide(bd, 10, RoundingMode.HALF_EVEN));
  }

}


Measured memory_bytes: 23124
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	A, B, C := make([]int, N), make([]int, N), make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = scanInt()
	}
	for i := 0; i < N; i++ {
		B[i] = scanInt()
	}
	for i := 0; i < N; i++ {
		C[i] = scanInt()
	}
	sort.Ints(A)
	sort.Ints(B)
	sort.Ints(C)

	ans := 0
	for _, b := range B {
		aindex := sort.SearchInts(A, b)
		cindex := sort.SearchInts(C, b+1)
		ans += aindex * (N - cindex)
	}

	fmt.Println(ans)
}


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

class AtCoder {
  static void Main() {
    var I = int.Parse(Console.ReadLine().Trim());
    var answer = "No";
    for(var i = 9; i > 0; i--) {
      if(I % i == 0 && I / i <= 9) {
        answer = "Yes";
        break;
      }
    }
    Console.WriteLine(answer);
  }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
using namespace std;
string s[1001];
vector<int>G[1001];
int n;
void f(int i,int d)
{
	cout<<string(d,'.')<<s[i]<<endl;
	for(int j=0;j<G[i].size();j++)f(G[i][j],d+1);
}
main()
{
	cin>>n;
	for(int i=0;i++<n;)
	{
		int k;cin>>k>>s[i];
		G[k].push_back(i);
	}
	f(1,0);
}



Measured memory_bytes: 3388
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_e

import sys
input=sys.stdin.readline
MOD=10**9+7

def main():
    N=int(input())
    A=list(map(int,input().split()))
    cnt=[0]*N
    ans=1
    for i in range(N):
        if A[i]==0:
            ans*=3-cnt[0]
            ans%=MOD
            cnt[A[i]]+=1
        else:
            ans*=cnt[A[i]-1]-cnt[A[i]]
            ans%=MOD
            cnt[A[i]]+=1
    print(ans)
        
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 20540
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long
ll gcd(ll a,ll b){
    ll s=1,c;
    while(a&&b){
        if((~a&1)&&(~b&1))
            a>>=1,b>>=1,s<<=1;
        else if(~a&1)a>>=1;
        else if(~b&1)b>>=1;
        else if(a>b)a=a-b;
        else c=b-a,b=a,a=c;
    }
    if(!a)return b*s;
    if(!b)return a*s;
}
using namespace std;
int main(){
	double n,ans;
	cin>>n;
	ans=n/3;
	ans=pow(ans,3);
	printf("%.12lf",ans);
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, MIN = 0, x_i;
  
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    cin >> x_i;
    if (x_i <= K - x_i) {
      // タイプA
      MIN += x_i * 2;
    }
    else {
      // タイプB
      MIN += (K - x_i) * 2;
    }
  }
  cout << MIN << endl;
}

Measured memory_bytes: 764
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

ll dp[105][4][4][4];

int main()
{
    ll n;
    cin >> n;
    dp[0][3][3][3]=1;
    rep(len,n){
        rep(i,4){
            rep(j,4){
                rep(k,4){
                    rep(a,4){
                        if(a==2 && k==1 && j==0) continue;
                        if(a==1 && k==2 && j==0) continue;
                        if(a==2 && k==0 && j==1) continue;
                        if(a==2 && k==1 && i==0) continue;
                        if(a==2 && j==1 && i==0) continue;
                        dp[len+1][a][k][j]+=dp[len][k][j][i];
                        dp[len+1][a][k][j]%=mod;
                    }
                }
            }
        }
    }
    ll ans=0;
    rep(i,4){
        rep(j,4){
            rep(k,4){
                ans+=dp[n][i][j][k];
                ans%=mod;
            }
        }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256