akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int bit(int x) {
    int res = 0;
    for(;0 < x;) {
        res += x&1;
        x /= 2;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> v(N);
    REP(i, N) {
        int a;
        cin >> a;
        v[i].resize(a);
        REP(j, a) {
            int x, y;
            cin >> x >> y;
            v[i][j] = make_pair(x - 1, y);
        }
    }
    int res = -1;
    REP(i, 1<<N) {
        bool check = true;
        REP(j, N) {
            if((i>>j)&1) {
                for(auto k : v[j]) {
                    bool x = ((i>>k.first)&1) == k.second;
                    check = check && x;
                }
            }
        }
        if(check) {
            res = max(res, bit(i));
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

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

int main(void){
	int N;
	scanf("%d",&N);
	if(N==3){
		printf("2 5 63");
	}else{
		printf("2 4 3 9");
		N-=4;
		reg(i,1,4999){
			if(N>1){
				printf(" %d %d",i*6+2,i*6+4);
				N-=2;
			}else{
				break;
			}
		}
		reg(i,1,2499){
			if(N>1){
				printf(" %d %d",i*12+3,i*12+9);
				N-=2;
			}else{
				break;
			}
		}
		reg(i,1,N){
			printf(" %d",i*6);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 384
from sys import stdin, exit

def l2(num):
    return 0 if num == 1 else l2(num // 2) + 1

def go(x, y, lv):
    return (
            '' if x == y == 0
            else go(x, y - (1 << lv), lv - 1) + 'U' if abs(y) > abs(x) and y > 0
            else go(x, y + (1 << lv), lv - 1) + 'D' if abs(y) > abs(x) and y < 0
            else go(x + (1 << lv), y, lv - 1) + 'L' if abs(x) > abs(y) and x < 0
            else go(x - (1 << lv), y, lv - 1) + 'R'
    )

n = int(stdin.readline())
a = [list(map(int, stdin.readline().split())) for i in range(n)]

parity = (a[0][0] + a[0][1]) % 2
for (x, y) in a:
    if (x + y) % 2 != parity:
        print("-1")
        exit(0)

base_ans = ''
d = []
if parity == 0:
    base_ans = 'U'
    d.append(1)
    a = list(map(lambda u: (u[0], u[1] - 1), a))

mx = max(map(lambda u: abs(u[0]) + abs(u[1]), a))
max_lv = l2(mx)
d.extend(1 << i for i in range(max_lv + 1))

print(len(d))
print(' '.join(map(str, d)))
for (x, y) in a:
    print(base_ans + go(x, y, max_lv))
    



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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

}

signed main() {
	ll n, w;

	cin >> n >> w;

	vector<ll> wei(n + 1, 0);
	vector<ll> val(n + 1, 0);
	vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, -INF));

	REP(i, n) {
		cin >> wei[i + 1] >> val[i + 1];
	}

	REP(i, w + 1) {
		dp[0][i] = 0;
	}

	FOR(i, 1, n + 1) {
		FOR(j, wei[i], w + 1) {
			dp[i][j] = max(dp[i][j], dp[i - 1][j - wei[i]] + val[i]);
		}
		REP(j, w + 1) {
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);
		}
	}

	cout << dp[n][w] << endl;
}

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

int main() {
  int h,w;
  ll ans = 0;
  cin >> h >> w;
  vector<string>data(h);
  vector<vector<int>>sx(h,vector<int>(w,0));
  vector<vector<int>>sy(h,vector<int>(w,0));
  rep(i,h) cin >> data[i];
  int s,sum = 0;
  rep(i,h){
    s = 0;
    sum = 0;
    rep(j,w){
      if(data[i][j] == '.') sum++;
      if(data[i][j] == '#' || j == w-1){
        for(int k = s;k <= j;k++) if(data[i][k] != '#') sx[i][k] = sum;
        s = j;
        sum = 0;
      }
    }
  }
  rep(i,w){
    s = 0;
    sum = 0;
    rep(j,h){
      if(data[j][i] == '.') sum++;
      if(data[j][i] == '#' || j == h-1){
        for(int k = s;k <= j;k++) if(data[k][i] !='#') sy[k][i] = sum;
        s = j;
        sum = 0;
      }
    }
  }
  rep(i,h){
    rep(j,w){
      if(ans < sx[i][j]+sy[i][j]-1) ans = sx[i][j]+sy[i][j]-1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 35712
#include "bits/stdc++.h"
using namespace std;

struct Solver {
	void solve() {
		int N;
		string S;
		cin >> N >> S;

		vector<int> b( N+1 ), w( N+1 );
		for( int i = 0; i < N; ++i ) {
			b[i+1] = b[i] + (S[i] == '#');
			w[i+1] = w[i] + (S[i] == '.');
		}

		int ans = INT_MAX;
		for( int i = 0; i <= N; ++i ) {
			int x = b[i];
			int y = w[N] - w[i];
			ans = min( ans, x+y );
		}

		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();

	return 0;
}


Measured memory_bytes: 2196
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#define EPS 1e-10
using namespace std;
typedef long long llong;
class Team {
public:
	int num;
	int pro;
	int rank;

	bool operator<(const Team r) {
		if (pro != r.pro)return pro > r.pro;
		else return num < r.num;
	}
};
bool f(Team a, Team b) {
	if (a.pro != b.pro)return a.pro > b.pro;
	else return a.num < b.num;
}
void print_Team(vector<Team>t) {
	for (vector<Team>::iterator it = t.begin(); it != t.end(); it++) {
		cout << it->num << " ";
	}
	cout << endl;
}
int main() {
	vector<Team> t;
	int p, s;
	char c;
	while (1) {
		cin >> p >> c >> s;
		if (p == 0 && s == 0)break;
		Team z;
		z.num = p; z.pro = s;
		t.push_back(z);
	}
	//cout << "Before" << endl;
	//print_Team(t);
	sort(t.begin(), t.end());
	//cout << "After" << endl;
	//print_Team(t);
	int g = 1;
	t[0].rank = g;
	for (vector<Team>::iterator it = t.begin()+1; it != t.end(); it++) {
		if ((it - 1)->pro != it->pro)it->rank = ++g;
		else it->rank = g;
	}
	int q;
	while (cin >> q) {
		for (vector<Team>::iterator it = t.begin(); it != t.end(); it++) {
			if (it->num == q) {
				cout << it->rank << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3152
#n=int(input())
x,k,d=[int(c) for c in input().split()]


if k*d< abs(x):
     print(abs(x)-(k*d))

elif (k*d)==abs(x):
    print(0)

else:

    x=abs(x)

    r=(x//d)

    p=x-r*d

    q=abs(p-d)

    k=k-r

    if k%2==1:
        print(q)
    else:
      print(p)    

Measured memory_bytes: 61796
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    int A,B;
    cin>>A>>B;
    cout<<A*B<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair

using namespace std;
//map <ll,ll> fc;
ll ans(ll x){
	if(x==1)return 1;
	else return 2ll*ans((x/2ll))+1ll;
}

void run(){
ll h,n;
cin>>h>>n;
ll s=0;
for(ll i=0;i<n;i++){
	ll x;cin>>x;
	s+=x;
}
if(s>=h){
	cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int x;
  cin >> x;
  if(x == 0) cout << "1" << endl;
  else cout << "0" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

void yes() {
    cout << "Yes" << endl;
}
void no() {
    cout << "No" << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> a;
    unordered_map<int, int> count;
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        count[temp]++;
        if (count[temp] == 1) {
            a.push_back(temp);
        }
    }
    if (a.size() > 2) {
        no();
    } else if (a.size() == 2) {
        int M = max(a[0], a[1]), m = min(a[0], a[1]);
        int k = count[m];
        if (M - m == 1) {
            if (M - k >= 1 && 2 * (M - k) <= n - k) {
                yes();
            } else {
                no();
            }
        } else {
            no();
        }
    } else {
        int m = a[0];
        if (m == n - 1 || 2 * m <= n) {
            yes();
        } else {
            no();
        }
    }
    return 0;
}

Measured memory_bytes: 4764
n = int(input())
a = map(int, input().split())

flag = -1
odd = 0
m4 = 0
for i in a:
    if i % 4 == 0:
        m4 += 1
    elif i % 2 == 0:
        flag = 0
    else:
        odd += 1

print('Yes' if m4 >= odd + flag else 'No')


Measured memory_bytes: 11096
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;

	if (abs(a - c) <= d) {
		cout << "Yes" << endl;
		return 0;
	}
	else if (abs(a - b) <= d && abs(b - c) <= d) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum ^= a[i];
    }
    rep(i, n) {
        if(i) cout << " ";
        cout << (a[i] ^ sum);
    }
    cout << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 4704
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stack>
using namespace std;

struct Point {
    Point() {x=0,y=0;}
    Point(int _x,int _y){x  =_x,y=_y;}

    int x,y;
};

// 重载相应的比较运算符
bool operator < (Point a, Point b)
{
    return a.x == b.x ? a.y < b.y : a.x < b.x;
}
long long gcd(long a, long b) {
    return b ? gcd(b, a % b) : a;
}

int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};
char dc[] = {'R', 'L', 'D', 'U'};
char dcc[] = {'L', 'R', 'U', 'D'};

int k,n,m;

void solvee(){
    cin >> n >> m;
    vector<long long> c(n+1);
    vector<long long> res(n+1);
    vector<vector<long long> > nxt(n+1);
    for(int i = 1; i <= n; i++) scanf("%lld", &c[i]);
    for(int i = 0; i < m; i++) {
        int u,v;
        scanf("%d%d", &u,&v);
        res[u] += c[v];
        nxt[v].push_back(u);
    }
    long long ans = res[1];
    for(int i = 1; i <= n; i++) {

        for(int j = 1; j < (1<<nxt[i].size()); j++) {
            cout << i<< ' '<< j<<endl;
            long long sum = c[i];
            for(int k = 0; k < nxt[i].size(); k++) {
                if(j&(1<<k)) {
                    sum += res[nxt[i][k]]-c[i];
                }
            }
            cout << "sum = " <<sum<<endl;
            ans = gcd(ans, sum);
        }
    }

    cout << ans <<endl;
}

char s[1000000+10];

int main() {
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB") {
        puts("No");
    }else {
        puts("Yes");
    }
}




Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 4e2 + 10;
int dp[N][N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	MEM(dp, 0x3f);
	dp[0][0] = 0;
	int n, ma, mb;
	cin >> n >> ma >> mb;
	int suma = 0, sumb = 0;
	while (n--)
	{
		int a, b, c;
		cin >> a >> b >> c;
		suma += a;
		sumb += b;
		for (int i = suma; i >= a; i--)
		{
			for (int j = sumb; j >= b; j--)
			{
				dp[i][j] = min(dp[i - a][j - b] + c, dp[i][j]);
			}
		}
	}
	int ans = 0x3f3f3f3f;
	for (int i = 1; ma * i <= suma && mb * i <= sumb; i++)
	{
		ans = min(ans, dp[ma * i][mb * i]);
	}
	if (ans == 0x3f3f3f3f) ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int main(void){
	ll a,b,c;
	cin>>a>>b>>c;
	if(c-a-b<0){
		cout<<"No";
	}
	else{
		if(4*a*b<(c-a-b)*(c-a-b))cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

const ll INF = 1e18;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  ll x;
  cin >> N >> x;
  ll a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  // 魔法を唱える回数を固定して全色を揃えるのにかかる時間を求める。それらの最小値が答え。
  ll ans = 0;
  ll dp[N][N]; // スライムjを飼うのにかかる時間を定数時間で求めるDP
  for (int i = 0; i < N; i++) {
    ans += a[i];
    dp[0][i] = a[i];
  }
  for (int i = 1; i < N; i++) { // 魔法を唱える回数
    ll cost = 0;
    for (int j = 0; j < N; j++) { // それぞれのスライム
      int idx = (j - i < 0 ? N + (j - i) : j - i);
      dp[i][j] = min(dp[i-1][j], a[idx]);
      // ll mini = INF;
      // for (int k = 0; k <= i; k++) { // j - k ~ jまでの中から、jを飼うまでにかかる時間の最小値を求める
      //   int idx = (j - k < 0 ? N + (j - k) : j - k);
      //   mini = min(mini, a[idx]);
      // }
      cost += dp[i][j];
    }
    ans = min(ans, cost + i * x);
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
typedef complex<double> pt;

typedef vector<P> poly;
const double EPS = 1e-9;
#define x real()
#define y imag()

int n,m;
int L[15]; pt p[15][20];
pt h[15];
vector<pair<pt,pt> >LL;
bool eq(double a,double b){
  return (-EPS < a-b && b-a < EPS);
}
double dot(pt a,pt b){
	return (conj(a)*b).x;
}
double cross(pt a,pt b){
	return (conj(a)*b).y;
}
pt crossPoint(pt a,pt b,pt c,pt d){
	double A = cross(b-a,d-c);
	double B = cross(b-a,b-c);
	if( fabs(A) < EPS && fabs(B) < EPS ) return c;
	else if(fabs(A) >= EPS ) return c+B/A*(d-c);
	else pt(1e9,1e9);
}
int ccw(pt a,pt b,pt c){
	b -= a; c -= a;
	if(cross(b,c) > EPS) return 1; // counter clockwise
	if(cross(b,c) < -EPS) return -1; // clockwise
	if(dot(b,c) < -EPS) return 2; //c-a-b
	if(norm(b) < norm(c)) return -2; //a-b-c
	return 0; //a-c-b
}
bool intersect(pt a,pt b,pt c,pt d){
	return (ccw(a,b,c)*ccw(a,b,d) <= 0 && ccw(c,d,a)*ccw(c,d,b) <= 0);
}
bool on_segment(pair<pt,pt> a,pt p){
  return eq(abs(a.first-a.second)-abs(a.first-p)-abs(a.second-p),0);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",&L[i]);
		for(int j=0;j<L[i];j++){
			double s,t;
			scanf("%lf%lf",&s,&t); p[i][j] = pt(s,t);
		}
	}
	for(int i=0;i<m;i++){
		double s,t; scanf("%lf%lf",&s,&t); h[i] = pt(s,t);
	}
	//human_vertex path
	for(int i=0;i<n;i++){
		for(int j=0;j<L[i];j++){
			for(int k=0;k<m;k++){
				LL.pb(mp(p[i][j],h[k]));
			}
		}
	}
	vector<pt>C;
	for(int i=0;i<LL.size();i++){
		for(int j=i+1;j<LL.size();j++){
			pt cand = crossPoint(LL[i].fi,LL[i].sc,LL[j].fi,LL[j].sc);
			//cout << cand.x << " " << cand.y << endl;
			if(cand.x > 1e8) continue;
			if(abs(ccw(LL[i].fi,LL[i].sc,cand))%2!=0) continue;
			if(abs(ccw(LL[j].fi,LL[j].sc,cand))%2!=0) continue;//cout << "K" << endl;
			//cout << cand.x << " " << cand.y << endl;
			for(int k=0;k<n;k++){
				for(int l=0;l<L[k];l++){
					if(ccw(p[k][l],p[k][(l+1)%L[k]],cand) != 1){
						//in polygon
						goto ok;
					}
				}
			}
			//cout << cand.x << " " << cand.y << endl;
			ok:; C.pb(cand); //cout << cand.x << " " << cand.y << endl;
		}
	}
	int ret = 1;
	for(int i=0;i<C.size();i++){
		int num = 0;
		for(int j=0;j<m;j++){
			//candidate_human path
			for(int k=0;k<n;k++){
				for(int l=0;l<L[k];l++){
					if(!intersect(C[i],h[j],p[k][l],p[k][(l+1)%L[k]])){
						continue;
					}
					else{
						pt cr = crossPoint(C[i],h[j],p[k][l],p[k][(l+1)%L[k]]);
						if(abs(p[k][l]-cr) < EPS) continue;
						if(abs(p[k][(l+1)%L[k]]-cr) < EPS) continue;
						if(abs(C[i]-cr) < EPS) continue;
						if(abs(h[j]-cr) < EPS) continue;
					}
					goto fail;
				}
			}
			num++; fail:;
		}
		ret = max(ret,num);
	}
	cout << ret << endl;
}

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

using namespace std;

typedef long long ll;
const int maxn = 1e5 + 5;

int top, N, Q;
ll a[maxn], c[maxn], tim[maxn];

void solve(int p, ll x, ll t) {
  tim[p] += t * (x / a[p]), x %= a[p];
  p = upper_bound(a + 1, a + p + 1, x) - a;
  if (p == 1) return c[1] += t, c[x + 1] -= t, void();
  solve(p - 1, x, t);
}

int main() {
  scanf("%d%d", &N, &Q), a[++top] = N;
  for (int i = 1; i <= Q; i++) {
    ll x = 0;
    scanf("%lld", &x);
    while (a[top] >= x && top) top--;
    a[++top] = x;
  }
  tim[top] = 1;
  for (int i = top; i > 1; i--) solve(i - 1, a[i], tim[i]);
  for (int i = 1; i <= a[1]; i++) c[i] += c[i - 1];
  for (int i = 1; i <= a[1]; i++) printf("%lld\n", c[i] + tim[1]);
  N -= a[1];
  while (N--) puts("0");
  return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

string s;

LL mask(int x) {
    return 1LL << x;
}

bool contains(LL s, int x) {
    return s & mask(x);
}

int main() {
    cin >> s; int sz = s.size();

    LL res = 0;

    FORN(i, mask(sz-1)) {
        LL curr = 0;

        for (int j = 0; j < sz; j++) {
            curr = 10 * curr + (s[j] - '0');

            if (j < sz-1 && contains(i, j)) {
                res += curr;
                curr = 0;
            }
        }
        
        res += curr;
    }

    cout << res << "\n";

    return 0;
}

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

int _main(){
    
    int h,w;
    cin >> h >> w;  
    int _sx,_sy,sx,sy;
    cin >> _sy >> _sx;  
    int _gx,_gy,gx,gy;
    cin >> _gy >> _gx;
    sx = _sx-1; sy = _sy-1;
    gx = _gx-1; gy = _gy-1;

    vector<vector<bool>> road(w, vector<bool>(h));
    for (int y=0; y<h; y++) {
        for (int x=0; x<w; x++) {
            char c;
            cin >> c;
            if(c=='.'){
                road[x][y]=true;
            }else{
                road[x][y]=false;
            }
        }
    }

    vector<vector<int>> cost(w, vector<int>(h,INFINITY));
    queue<tuple<int,int>> searchfrom;
    vector<vector<int>> searched_b(w, vector<int>(h,false));
    searchfrom.push(tuple<int,int>(sx,sy));
    int costnow = 0;
    while(true){
        queue<tuple<int,int>> searching = queue<tuple<int,int>>(searchfrom);
        queue<tuple<int,int>> searched  = queue<tuple<int,int>>();
        searchfrom = queue<tuple<int,int>>();
        while(searching.size()>0){
            tuple<int,int> coord = searching.front();
            int cx = get<0>(coord); int cy = get<1>(coord);
            searching.pop();
            if(cx==gx && cy==gy){
                return costnow;
            }

            for(int x=max(0,cx-1); x<=min(w-1,cx+1); x++){
                for(int y=max(0,cy-1); y<=min(h-1,cy+1); y++){
                    int lenSu = abs(x-cx)+abs(y-cy);
                    if(road[x][y] && costnow<cost[x][y]){
                        if(lenSu==0){
                            cost[x][y] = costnow;
                            searched_b[x][y]=true;
                            searched.push(tuple<int,int>(x,y));
                        }else if(lenSu==1 && !searched_b[x][y]){
                            searched_b[x][y]=true;
                            searching.push(tuple<int,int>(x,y));
                        }
                    }
                }
            }
        }
        while(searched.size()>0){
            tuple<int,int> coord = searched.front();
            int cx = get<0>(coord); int cy = get<1>(coord);
            searched.pop();

            for(int x=max(0,get<0>(coord)-2); x<=min(w-1,get<0>(coord)+2); x++){
                for(int y=max(0,get<1>(coord)-2); y<=min(h-1,get<1>(coord)+2); y++){
                    if(road[x][y] && costnow<cost[x][y]){
                        searchfrom.push(tuple<int,int>(x,y));
                    }
                }
            }
        }
        if(searchfrom.size()==0) return -1;
        costnow++;
    }
}

int main(){
    int result = _main();
    cout << result;
    return 0;
}

Measured memory_bytes: 11736
#include <stdio.h>
int main(void) {
 
  int x,y,t;
  int i;
 
  while(1) {
  scanf("%d %d",&x,&y);
  if(x*y == 0) break;
 
  if(y >=x) {
    t = y;
    y = x;
    x = t;
  }
 
 
  i= 0;
  while(1) {
    i++;
    x = x % y;
 
    t =x;
    x = y;
    y = t;
 
    if(y == 0) break;
 
  }
 
  printf("%d %d\n",x,i);
 
  }
 
  return 0;
 
}



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

int main()
{
  string s;
  cin>>s;
  
  int arr[2]={0};
  
  for(int i=0;i<s.length();i++)
  {
    if(s[i]=='A')
      arr[0]++;
    else if(s[i]=='B')
      arr[1]++;
  }
  
  if(arr[0]>=1 && arr[1]>=1)
    cout<<"Yes";
  else
    cout<<"No";
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int x;
    cin >> x;
    for (int i = x; i >= 1; i--) {
        for (int j = 2; j * j <= i; j++) {
            int n = i;
            while (n > 1 && n % j == 0) {
                n /= j;
            }
            if (n == 1) {
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << 1 << endl;
}


Measured memory_bytes: 3560
a,b,c = map(int,input().split())
if 1 <= a and a <= 10000 and 1 <= b and b <= 10000 and 1 <= c and c <= 10000:
    if a <= b and b <= c: # a<b<c
        d = a
        e = b
        f = c
    elif a <= c and c <= b: # a<c<b
        d = a
        e = c
        f = b
    elif b <= a and a <= c: # b<a<c
        d = b
        e = a
        f = c
    elif b <= c and c <= a: # b<c<a
        d = b
        e = c
        f = a
    elif c <= a and a <= b: # c<a<b
        d = c
        e = a
        f = b
    elif c <= b and b <= a: # c<b<a
        d = c
        e = b
        f = a
    print(str(d) + " " + str(e) + " " + str(f))


Measured memory_bytes: 5592
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
int ans[1005];
int main()
{
    string s;
    while (getline(cin, s))
    {
        int ls = s.size();
        for (int i = 0; i < ls; ++i)
        {
            if (isupper(s[i]))
                ++ans[s[i] - 'A'];
            if (islower(s[i]))
                ++ans[s[i] - 'a'];
        }
    }
    for (int i = 0; i < 26; ++i)
        printf("%c : %d\n", (char)(i + 'a'), ans[i]);
    return 0;
}



Measured memory_bytes: 3252
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
const int MAX_N = (1<<18);

// 遅延評価セグメント木
struct RUP {
	int n;
	// dat:区間の最小値を管理する, laz:区間の値を管理する
	vector<int> dat, laz;
	const int def = INT_MAX;
	RUP() {}
	RUP(int n_){init(n_); }

	// 初期化
	void init(int n_) {
		n = 1;
		while(n < n_) n*=2;
		dat.clear();
		dat.resize(2*n-1,def);
		laz.clear();
		laz.resize(2*n-1,-1);
	}

	// 遅延を伝搬する
	inline void eval(int len, int k) {
		if(laz[k]<0) return;
		if (k * 2 + 1 < n * 2 - 1) {
			laz[k*2+1]=laz[k];
			laz[k*2+2]=laz[k];
		}
		dat[k] = laz[k];
		laz[k] = -1;
	}

	// [a,b)を x に変更する
	int update(int a, int b, int x, int k, int l, int r) {
		// 遅延評価
		eval(r-1,k);
		if(r<=a || b<=l) return dat[k];
		if(a<=l && r<=b) return laz[k] = x;
		eval(r-1,k);
		dat[k] = min(update(a,b,x,k*2+1,l,(l+r)/2), update(a,b,x,k*2+2,(l+r)/2,r));
		return dat[k];
	}

	// [a,b)の最小値を求める
	int query(int a, int b, int k, int l, int r) {
		eval(r-1,k);
		if(r<=a || b<=l) return def;
		if(a<=l && r<=b) return dat[k];

		int vl = query(a,b,k*2+1,l,(l+r)/2);
		int vr = query(a,b,k*2+2,(l+r)/2,r);
		return min(vl,vr);
	}

	void update(int a, int b, int x) {
		update(a,b,x,0,0,n);
	}

	int query(int a, int b) {
		return query(a,b,0,0,n);
	}


};

int main() {
	int n, q;
	cin >> n >> q;
	RUP rup(n);
	for (int i = 0; i < q; i++) {
		int f;
		cin >> f;
		if (!f) {
			int s, t, x;
			cin >> s >> t >> x;
			rup.update(s,t+1,x);
		}
		else {
			int s, t;
			cin >> s >> t;
			cout << rup.query(s,t+1) << endl;
		}
	}

}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n+1),b(n+1);
  for(ll i=1;i<=n;i++){
    cin >> a[i] >> b[i];
  }
  
  ll ans=0;
  ll times=0;
  for(ll i=n;i>=1;i--){
    ll tmp = (a[i]+times) % b[i];
    //cout << b[i] - tmp << endl;
    if(tmp != 0){
      ans += b[i] - tmp;
      times += (b[i] - tmp);
    }
  }

  cout << ans << endl;
  
  return(0);
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[a.size() - 1] - a[0] << endl;
    return 0;
}

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

int main(){
    int n, ans = 1;
    cin >> n;
    while(ans <= n) ans *= 2;
    cout << ans / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
unordered_map<long long,long long> mp;
long long n,a,mx1=0,mx2=0,mx=0;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a);
		++mp[a];
		if(mp[a]==2)
		{
			if(a>mx1)
			{
				mx2=mx1;
				mx1=a;
			}else
			{
				if(a>mx2)
				{
					mx2=a;
				}
			}
		}else if(mp[a]==4)
		{
			mx=max(mx,a*a);
		}
		mx=max(mx,mx1*mx2);
	}
	printf("%lld\n",mx);
}

Measured memory_bytes: 7420
#define _CRT_SECURE_NO_WARINGS
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <fstream>
#include <map>
#include <unordered_map>
using namespace std;
typedef int me;
typedef long long ll;
typedef unsigned long long ull;
#define andrew               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define endl '\n'
#define sz(v) (int)(v.size())
#define all(v) v.begin(), v.end()
#define PI 3.1415926535
#define sin(i) (long double)sin(i *PI / 180.0)
#define cos(i) (long double)cos(i * PI/ 180.0)
ll gcd(ll x, ll y)
{
    return (y == 0) ? x : gcd(y, x % y);
}
ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }
int dy8[] = { 0, 0, 1, -1, 1, -1, -1, 1 };
int dx8[] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int id8[] = { 0, 1, 2, 3, 4, 5, 6, 7 };

int n, m;
vector<vector<char>>v;
vector<vector<ll>>mem;
ll solve(int i, int j)
{
    if (i >= n || j >= m || v[i][j] == '#')
        return 0;

    if (i == n - 1 && j == m - 1)
        return 1;

    if (mem[i][j] != -1)
        return mem[i][j];

    return  mem[i][j] = ((solve(i + 1, j) % 1000000007) + (solve(i, j + 1) % 1000000007)) % 1000000007;



}
int main()
{
    andrew;
    cin >> n >> m;
    v.resize(n, vector<char>(m));
    mem.resize(n, vector<ll>(m));

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            mem[i][j] = -1;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> v[i][j];
    cout << solve(0, 0) << endl;

    
  
}
/*
3
0 6
6 0
3 4
*/

Measured memory_bytes: 12044
#include<cstdio>
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

const int CMax = 100002;

int n, A[CMax], B[CMax], ma, mi;

int main(){
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d %d", &A[i], &B[i]);
        if (A[i] > ma){
           ma = A[i];
           mi = i;
        }
    }

    printf("%d\n", A[mi] + B[mi]);
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            int K = Integer.valueOf(reader.readLine());
            String S = reader.readLine();
            int Slen = S.length();
            String ans;
            if(Slen>K){
                ans = S.substring(0,K)+"...";
            }else{
                ans = S;
            }
            System.out.println(ans);
        }catch(IOException e){
            System.out.println("aaaa");
        }
    }
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

#include "bits/stdc++.h"
struct UnionFind {
	std::vector<int> par;
	std::vector<int> sizes;

	UnionFind(int n) {
		par.resize(n);
		sizes.resize(n);
		for (int i = 0; i < n; ++i) {
			par[i] = i;
			sizes[i] = 1;
		}
	}

	int root(int a) {
		return par[a] == a ? a : par[a] = root(par[a]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y)return;
		if (sizes[x] < sizes[y]) std::swap(x, y);

		par[y] = x;
		sizes[x] += sizes[y];
	}
	int size(int x) {
		return sizes[root(x)];
	}
};


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	REP(i, m) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		uf.unite(a, b);
	}
	set<int> st;
	REP(i, n)st.insert(uf.root(i));
	cout << st.size() << endl;
}

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

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

int main() {
    int n, t, a, h; cin >> n >> t >> a;
    vector<pair<double, int>> p(n);
    rep(i, n){
        cin >> h;
        double diff = a - (t-h*0.006);
        p[i] = make_pair(diff * diff, i+1);
    } 
    sort(p.begin(), p.end());
    cout << p[0].second << endl;
    return 0;
}


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

int main()
{
    int a,b;
    cin>>a>>b;
     
    if(a==2||b==2)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
/* Those who cannot remember the past are condemned to repeat it.*/
/* author:Ajeet */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define ll long long int
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int sz=1e7;
#define mod 1000000007
#define ull unsigned long long int

int main()
{

    int n;
    cin>>n;
    int w;
    cin>>w;
    ll weight[n],profit[n];
    for(int i=0;i<n;i++) cin>>weight[i]>>profit[i];
    ll dp[n+1][w+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            ll weightWithoutCurr=dp[i-1][j];
            ll weightWithCurr=0;
            ll currWeight=weight[i-1];
            if(i==0 or j==0){
                dp[i][j]=0;
                continue;
            }
            else if(currWeight<=j){
                weightWithCurr=profit[i-1];
                ll remain=j-currWeight;
                weightWithCurr+=dp[i-1][remain];
            }

            dp[i][j]=max(weightWithoutCurr,weightWithCurr);
        }

    }


    cout<<dp[n][w]<<endl;

    return 0;

}


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

using namespace std;
using ll = long long;

#define rep(countName, left, right, up) for (ll countName = left; countName < right; countName += up)
#define rev(countName, right, left, down) for (ll countName = right - 1; countName >= left; countName -= down)

auto solve1(void)
{
    string str;
    int count = 0, n;
    cin >> n >> str;

    rep(i, 2, (ll)str.length(), 1)
    {
        //cout << str[i] << endl;
        if (str[i] == 'C')
        {
            if (str[i - 1] == 'B')
            {
                if (str[i - 2] == 'A')
                {
                    ++count;
                }
                i += 2;
            }
            else
            {
                ++i;
            }
        }
    }

    return count;
}

int main(void)
{
    cout << solve1() << endl;
    return 0;
}

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

int main(void){
        int a,b,c,x;
        int z(0); //組合せ数
        cin>>a>>b>>c>>x;
        for(int i(0);i<=a;i++){
                for(int j(0);j<=b;j++){
                        for(int k(0);k<=c;k++){
                                if(500*i+100*j+50*k==x){
                                        z++;
                                        break;
                                }
                        }
                }
        }
        cout<<z;
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define enter "\n"

typedef long long ll;


int abc101_c(){
    //入力
    int n,k;
    cin >> n >> k;

    int ans = RUP(n-1,k-1);
    
    //出力
    cout << ans << enter;
    return 0;
}

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
//using System.Collections;
using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      int a = int.Parse(Console.ReadLine());
      List<int>[] num = new List<int>[a];
      Dice[] dice = new Dice[a];
      for (int i = 0; i < a; i++)
      {
        num[i] = new List<int>() { 0 }.Concat(Console.ReadLine().Split().Select(int.Parse).ToList()).ToList();
        dice[i] = new Dice(num[i]);

      }
      string str = "";
      for (int i = 0; i < a - 1; i++)
      {
        for (int j = i + 1; j < a; j++)
        {
          str = Check(dice[i], dice[j]);
          if (str == "No") goto EXIT;
        }
      }
    EXIT:;
      Console.WriteLine(str);
    }
    public static string Check(Dice d1, Dice d2)
    {
      string roll = "NNNNENNNNENNNNENNNENNNEENNN";
      string ss = "Yes";
      foreach (var x in roll)
      {
        int count = 0;
        for (int i = 1; i <= 6; i++)
        {
          if (d1.face[i] == d2.face[i]) count++;
        }
        if (count == 6) { ss = "No"; break; }
        d2.Roll(x);
      }
      return ss;
    }
  }

  public class Dice
  {
    public List<int> face;
    public Dice(List<int> face)
    {
      this.face = face;
    }
    public void Roll(char r)
    {
      int temp;
      switch (r)
      {
        case 'N':
          temp = face[1]; face[1] = face[2]; face[2] = face[6]; face[6] = face[5]; face[5] = temp;
          break;
        case 'E':
          temp = face[1]; face[1] = face[4]; face[4] = face[6]; face[6] = face[3]; face[3] = temp;
          break;
        case 'W':
          temp = face[1]; face[1] = face[3]; face[3] = face[6]; face[6] = face[4]; face[4] = temp;
          break;
        case 'S':
          temp = face[1]; face[1] = face[5]; face[5] = face[6]; face[6] = face[2]; face[2] = temp;
          break;
      }
    }
  }
}








Measured memory_bytes: 9448
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<stack>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main(){
	stack<int> S1;
	stack<pair<int, int> > S2;
	char slope;
	int i = 0;
	int sum = 0;
	while (cin >> slope){
		if (slope == '\\'){
			S1.push(i);
		}
		else if (slope == '/'&&S1.size() > 0){
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j){
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j, a));
		}
		i++;
	}
	vector<int> ans;
	int t = 0;
	while (S2.size() > 0){
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size(); i++){
		cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int h, n;
  cin >> h >> n;

  vector<int> dp(h + 10, 1e9);
  dp[0] = 0;
  rep(i, 0, n) {
    int a, b;
    cin >> a >> b;
    for (int j = 1; j < h + 10; j++) {
      if (j <= a) {
        dp[j] = min(dp[j], b);
      } else {
        dp[j] = min(dp[j], dp[j - a] + b);
      }
    }
  }

  cout << dp[h] << endl;
}


Measured memory_bytes: 3684
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
struct SCC{
    vector<vector<int>> g, gr;
    int n, k;
    vector<int> cmp, vs;
    vector<bool> used;
    void dfs(int x){
        used[x]=1;
        for(auto y:g[x]){
            if(!used[y]) dfs(y);
        }
        vs.push_back(x);
    }
    void rdfs(int v, int k){
        used[v]=1;
        cmp[v]=k;
        for(auto y:gr[v]){
            if(!used[y]) rdfs(y, k);
        }
    }
    SCC(const vector<vector<int>> &g):g(g), n(g.size()), cmp(n), used(n){
        gr.resize(n);
        for(int x=0; x<n; x++) for(auto y:g[x]) gr[y].push_back(x);
        for(int i=0; i<n; i++){
            if(!used[i]) dfs(i);
        }
        fill(used.begin(), used.end(), 0);
        k=0;
        for(int i=vs.size()-1; i>=0; i--){
            if(!used[vs[i]]) rdfs(vs[i], k++);
        }
    }
};
int main()
{
    int n, d;
	scanf("%d %d", &n, &d);
	int x[2][1010];
	for(int i=0; i<n; i++) scanf("%d %d", &x[0][i], &x[1][i]);
	vector<vector<int>> g(2*n);
	for(int i=0; i<n; i++){
		for(int j=0; j<i; j++){
			for(int k=0; k<2; k++) for(int l=0; l<2; l++){
				if(abs(x[k][i]-x[l][j])<d){
					g[i+k*n].push_back(j+(l^1)*n);
					g[j+l*n].push_back(i+(k^1)*n);
				}
			}
		}
	}
	SCC scc(g);
	for(int i=0; i<n; i++){
		if(scc.cmp[i]==scc.cmp[i+n]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	for(int i=0; i<n; i++){
		if(scc.cmp[i]<scc.cmp[i+n]){
			printf("%d\n", x[1][i]);
		}else{
			printf("%d\n", x[0][i]);
		}
	}
    return 0;
}


Measured memory_bytes: 4136
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <stack>
#include <cmath>
#include <string>
#define SIZE 100005
#define INF 100000000000000000LL

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

int A[SIZE];
int tp[SIZE];
char str[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	ll ret=0;
	scanf("%lld",&ret);
	n--;
	for(int i=0;i<n;i++)
	{
		scanf("%s",&str);
		int a;
		scanf("%d",&a);
		if(str[0]=='-') tp[i]=0;
		else tp[i]=1;
		A[i]=a;
	}
	bool up=true;
	vector <P> vx;
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		if(up&&tp[i]==1)
		{
			ret+=A[i];
		}
		else
		{
			if(up)
			{
				up=false;
				vx.push_back(P(A[i],0));
				sum=0;
			}
			else if(tp[i]==0)
			{
				vx[vx.size()-1].second=sum;
				vx.push_back(P(A[i],0));
				sum=0;
			}
			else
			{
				sum+=A[i];
			}
		}
	}
	if(up)
	{
		printf("%lld\n",ret);
		return 0;
	}
	vx[vx.size()-1].second=sum;
	ll all=0;
	for(int i=0;i<vx.size();i++) all+=vx[i].first+vx[i].second;
	ll now=-INF;
	for(int i=0;i<vx.size();i++)
	{
		all-=vx[i].first+vx[i].second;
		now=max(now,all-(vx[i].first+vx[i].second));
		all-=vx[i].first;
		all+=vx[i].second;
	}
	now=max(now,all);
	printf("%lld\n",ret+now);
	return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define LL long long
#define rep(a,b) for(int a=0;a<b;a++)
#define pb push_back
#define str string
#define INF 100000000
using namespace std;
LL sub_string(const string& s1,const string& s2,LL l1,LL l2){
    LL len=min(s1.length()-l1,s2.length()-l2);
    LL lon=0;
    LL ans=0;
    for(int j=0;j<len;j++){
        if(s1[l1+j]==s2[l2+j]){
            lon++;
        }else{
            ans=max(ans,lon);
            lon=0;
        }
    }return max(ans,lon);
}
int main(){
    str s1,s2;
    LL ans=0;
    int i=0;
    while(1){
    s1="";
    s2="";
    if(!(cin >> s1 >> s2)){break;}
    LL l1=s1.length();
    LL l2=0;
    ans=0;
        while(l1!=0||l2<=s2.length()){
            if(l1!=0){
                l1--;
            }else{
                l2++;
            }
            ans=max(ans,sub_string(s1,s2,l1,l2));
        }
        cout << ans << endl;
    }
return 0;
}

Measured memory_bytes: 1208
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);
    int ans = a.sum();

    if (ans % 2 == 0) {
        writeln(ans / 2);
        return;
    }
    
    a.sort();
    foreach (i ; 0 .. n) {
        if (a[i] % 2 == 1) {
            ans -= a[i];
            break;
        }
    }

    ans /= 2;
    writeln(ans);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 2500
import java.io.PrintWriter

fun solve(out: PrintWriter): Boolean = with(out) {
    val a = readLine()!!.toInt()
    val s = if (a < 3200) "red" else readLine()!!
    println(s)

    return false
}

fun main(args: Array<String>) = with(PrintWriter(System.out)){
    while(solve(this));
    flush()
}

Measured memory_bytes: 33612