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

#define M_PI       3.14159265358979323846

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

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

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

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

#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};

typedef vector<vector<Edge>> AdjList;
AdjList graph;

int n, t;
int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    int N; cin >> N;
    cout << N *N*N << endl;
    return 0;

}

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

int main(){
  int N, A, B, sum;
  cin >> N >> A >> B;
  sum = 0;
  for (int i=1; i<=N; i++) {
    if (A <= i%10 + (i/10)%10 + (i/100)%10 + (i/1000)%10 + i/10000 && B >= i%10 + (i/10)%10 + (i/100)%10 + (i/1000)%10 + i/10000)
      sum += i;
  }
  cout << sum << endl;
}

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

const int maxn = 100010;
int n, m, u[maxn], v[maxn], d[maxn], fa[maxn];
bool tmp[maxn], vis[maxn];
set<pair<int, int> > ans;
vector<int> V, G[maxn];

void dfs1(int v, int f) {
    vis[v] = 1, fa[v] = f;
    for (int u : G[v]) {
        if (!vis[u]) d[v]++, ans.insert({v, u}), dfs1(u, v);
        else if (!ans.count({u, v})) d[v]++, ans.insert({v, u});
    }
}

void dfs2(int v) {
    vis[v] = 1;
    for (int u : G[v]) if (!vis[u]) {
        dfs2(u), tmp[v] ^= tmp[u];
    }
    if (tmp[v]) {
        assert(v != 1);
        ans.erase({fa[v], v});
        ans.insert({v, fa[v]});
    }
}

int main() {
    scanf("%d %d", &n, &m);
    if (m & 1) {
        printf("-1\n"), exit(0);
    }
    for (int i = 1; i <= m; i++) {
        scanf("%d %d", &u[i], &v[i]);
        G[u[i]].push_back(v[i]), G[v[i]].push_back(u[i]);
    }
    dfs1(1, 0);
    assert(accumulate(d + 1, d + n + 1, 0) == m);
    for (int i = 1; i <= n; i++) {
        if (d[i] & 1) V.push_back(i);
    }
    assert(V.size() % 2 == 0);
    for (int i = 0; i < V.size(); i += 2) {
        tmp[V[i]] ^= 1, tmp[V[i + 1]] ^= 1;
    }
    memset(vis, 0, sizeof(vis)), dfs2(1);
    memset(d, 0, sizeof(d));
    for (auto p : ans) {
        printf("%d %d\n", p.first, p.second);
        d[p.first]++;
    }
    for (int i = 1; i <= n; i++) {
        assert(d[i] % 2 == 0);
    }
    return 0;
}

Measured memory_bytes: 20092
#include <iostream>

using namespace std;
int main()
{
    while(true) {
        int loop;
        cin >> loop;
        int p1=0,p2=0;
        if(loop==0)break;
        while(loop--)
        {
            int a,b;
            cin >> a >> b ;
            if(a > b) {
                p1 = p1 + a + b;
            }else if(a==b) {
                p1 += a;
                p2 += b;
            }
            else {
                p2 = p2 + a + b;
            }
        }
        cout << p1 << " " << p2 << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> s(N,0);
  for(int i=0; i<K; ++i){
    int d;
    cin >> d;
    for(int j=0; j<d; ++j){
      int a;
      cin >> a;
      s[a-1] = 1;
    }
  }
  int ans = 0;
  for(int i=0; i<N; ++i){
    if(s[i]==0) ++ans;
  }
  cout << ans << endl;
}


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

int main() {
  int N,ans=1000000000;
  cin>>N;
  rep(i,N){
    int A,cnt=0;
    cin>>A;
    while (A%2==0) {
      A/=2;
      cnt+=1;
    }
    if (cnt<ans) {
      ans=cnt;
      }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int a[5];
  int mi = 10;
  int miIndex = -1;
  int sum = 0;
  rep (i, 5) {
    cin >> a[i];
    sum += a[i];
    int tmp = a[i] % 10;
    if (tmp != 0) {
      if (mi > tmp) {
        mi = tmp;
        miIndex = i;
      }
    }
  }
  if (mi == 10) P(sum);
  else {
    // P(miIndex);
    rep (i, 5) {
      if (i == miIndex) continue;
      if (a[i] % 10 == 0) continue;
      sum += (10 - a[i] % 10);
    }
    P(sum);
  }


  return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m,i,max,sam;
	scanf("%d %d",&n,&m);
	for(i=1;i<=1000;i++){
		if(n%i==0&&m%i==0) max=i;
	}
	n=n/max;
	m=m/max;
	sam=(n+m-1)*max+1;
	printf("%d\n",sam);
	return 0;
}


Measured memory_bytes: 2760
H, W = [int(i) for i in input().split()]
S = [input() for _ in range(H)]
inf = 1000000
dist = [[-1]*(W*H) for _ in range(W*H)]

def bfs(s):
    seen = set()
    stk = [(s, 0)]
    while stk:
        pt, dst = stk.pop()
        ph, pw = pt//W, pt%W
        if(pt in seen):
            continue
        seen.add(pt)

        if(S[ph][pw]=='#'):
            dist[s][pt] = 0
            continue

        for x,y in ((1,0), (-1,0), (0, 1), (0,-1)):
            if((not(0<=pw+x<W))or (not(0<=ph+y<H))):
                continue
            else:
                ns = (ph+y)*W + (pw+x)
                stk.insert(0, (ns, dst+1))
        dist[s][pt] = dst
        
ans = 0
for s in range(H*W):
    h, w = s//W, s%W
    if(S[h][w]=='#'):
        continue
    bfs(s)
    
    ans = max(ans, max(dist[s]))

print(ans)



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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#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 fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	string S;
	string T;
	cin >> S >> T;
	T.pop_back();
	if (S == T)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 3656
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) {if(y < x) x = y;}
template<typename T, typename U> inline void mxze(T &x, U y) {if(x < y) x = y;}

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

ll MOD = 1e9+7;

inline ll Msum(ll x){return x;}
template<typename... Rest>
inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

inline ll Mprod(ll x){return x;}
template<typename... Rest>
inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

int S(ll n){
	int ret=0;
	while(n){
		ret += n%10;
		n/=10;
	}
	return ret;
}

ll nextsnuk(ll m){
	ll pot=1;
	int sm = S(m);
	ll n;
	while(pot <= m){
		n = m-pot;
		if(n*sm <= m*S(n)) return n;
		pot *= 10;
	}
	assert(false);
}

int main(){
	ll n=999999999999999;
	vll snu;
	snu.pb(n);
	while(n>1){
		n = nextsnuk(n);
		snu.pb(n);
	}
	reverse(all(snu));
	int K; scan(K);
	assert(K <= (int) snu.size());
	for(int i=0; i<K; i++) printf("%lld\n", snu[i]);
}


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

int main(){
    int n;cin>>n;
    int a = n % 10;
    int b = n % 100 - a; b /= 10;
    int c = n-b-a; c /= 100;
    if(a == 7 || b == 7 || c == 7){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

#define int long long
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define endl "\n"
#define e "\n"
#define show(arr) REP(i,arr.size()){cout<<arr[i]<<" ";}
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

#define N 5010

void solve()
{
    int x,y,count=0;
    cin >> x>> y;
    for (int i=0; i<x; i++){
        string z;
        cin >> z;
        for (int j=0; j<y; j++){
            if (z[j]=='#') count++;
        }
    }
    cout<<(count==x+y-1?"Possible":"Impossible");
}

signed main()
{
    int t=1;
    //cin>>t;
    WL(t)solve();

    return 0;
}




Measured memory_bytes: 3628
#include <iostream>
#include <limits.h>
using namespace std;

int main() {
	long long k;
	int notone = 0;
	char s[110];
	cin >> s;
	cin >> k;
	for (int i = 0; i < k && i < 100; i++) {
	    if (s[i] != '1'){
	        cout << s[i];
	        notone++;
	        break;
	    }
	}
	if (notone == 0) cout << "1";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
  string s; cin >> s;
  int a = s[0]-'0', b = s[1]-'0', c = s[2]-'0', d = s[3]-'0';
  if(a-b-c-d==7) printf("%d-%d-%d-%d=7\n", a, b, c, d);
  else if(a-b-c+d==7) printf("%d-%d-%d+%d=7\n", a, b, c, d);
  else if(a-b+c-d==7) printf("%d-%d+%d-%d=7\n", a, b, c, d);
  else if(a-b+c+d==7) printf("%d-%d+%d+%d=7\n", a, b, c, d);
  else if(a+b-c-d==7) printf("%d+%d-%d-%d=7\n", a, b, c, d);
  else if(a+b-c+d==7) printf("%d+%d-%d+%d=7\n", a, b, c, d);
  else if(a+b+c-d==7) printf("%d+%d+%d-%d=7\n", a, b, c, d);
  else if(a+b+c+d==7) printf("%d+%d+%d+%d=7\n", a, b, c, d);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int tmp;
char str[1213];
int main()
{
	scanf("%d",&tmp);
	sprintf(str,"%d",tmp);
	for(int i=0;i<strlen(str);i++)
	{
		if(str[i]=='9')
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    string S;
    cin >> S;
    int number_1 = 0;
    int number_0 = 0;
    rep(i,S.size()) {
        if (S.at(i) == '1') {
            number_1++;
        }
        if (S.at(i) == '0') {
            number_0++;
        }
    }
    int hoge = min(number_1,number_0);
    cout << 2*hoge << endl;
}

Measured memory_bytes: 512
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;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());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;




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


	int N; cin >> N;
	int K, Q; cin >> K >> Q;
	vector<int>v(N);
	REP(i, N) {
		v[i] = K - Q;
	}
	REP(i, Q) {
		int x; cin >> x; x--;
		v[x]++;
	}
	REP(i, N) {
		if (v[i] > 0) {
			print("Yes");
		}
		else print("No");
	}
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Br = list(reversed(B))

NG = []
for i in range(N):
    if A[i]==Br[i]:
        NG.append(i)
        NGnumber = Br[i]
NGcnt = len(NG)

if NGcnt==0:
    print("Yes")
    print(*Br)
else:
    OK = []
    for i in range(N):
        if Br[i]!=NGnumber and A[i]!=NGnumber:
            OK.append(i)
    OKcnt = len(OK)

    if NGcnt>OKcnt:
        print("No")
    else:
        for i in range(NGcnt):
            Br[NG[i]],Br[OK[i]]=Br[OK[i]],Br[NG[i]]
        print("Yes")
        print(*Br)

Measured memory_bytes: 115760
#include<stdio.h>
#include<string.h>
int main(void)
{
	char str[20],rstr[20],len;
	scanf("%s",&str);
	len=strlen(str);
	for(int f1=len;f1>0;f1--){
		printf("%c",str[f1-1]);
	}
	printf("\n");
	scanf("%d");
	return 0;
}

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

int main(){
    int N,K; cin >> N >> K;
    int ans=1;
    int tmp=N;
    while(1){
        if(tmp<K) break;
        tmp/=K;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF 4505

using namespace std;
int n,a,b,c;
int d[10][10];
int main()
{
    while(cin>>n&&n)
    {
        int m=-1;
        for(int i=0;i<10;i++)
            for(int j=0;j<10;j++)
        {
            if(i==j) d[i][j]=0;
            else d[i][j]=INF;
        }
        for(int i=0;i<n;i++)
        {
            cin>>a>>b>>c;
            m=max(m,max(a,b));
            d[a][b]=d[b][a]=c;
        }
        for(int k=0;k<=m;k++)
            for(int i=0;i<=m;i++)
            for(int j=0;j<=m;j++)
        {
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
        }
        int p,minsum=INF;
        for(int i=0;i<=m;i++)
        {
            int sum=0;
            for(int j=0;j<=m;j++)
                sum+=d[i][j];
            if(minsum>sum)
            {
                p=i;
                minsum=sum;
            }
        }
        cout<<p<<" "<<minsum<<endl;
    }
    return 0;
}



Measured memory_bytes: 3052
s = input()
if s=="SUN":
    print(7)
elif s=="MON":
    print(6)
elif s=="TUE":
    print(5)
elif s=="WED":
    print(4)
elif s=="THU":
    print(3)
elif s=="FRI":
    print(2)
else:
    print(1)

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int a,b,maxi=-10000;
  cin>>a>>b;
  cout<<max(max(max(maxi,a+b),a-b),a*b)<<endl;
return 0;}


Measured memory_bytes: 256
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = int
printer = unlines . (:[])

solver n = if n >= 1000 then "ABD" else "ABC"

Measured memory_bytes: 508
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>

using namespace std;

int n;

typedef struct _point {
    double x;
    double y;
} Point;

void print_point(Point p) {
    printf("%.8f %.8f\n", p.x, p.y);
}

void koch_curve(Point p1, Point p2, int i) {
    if (i == n) {
        return;
    }

    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;
    s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
    s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
    t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
    t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch_curve(p1, s, i + 1);
    print_point(s);
    koch_curve(s, u, i + 1);
    print_point(u);
    koch_curve(u, t, i + 1);
    print_point(t);
    koch_curve(t, p2, i + 1);
}

int main() {
    cin >> n;

    Point start = {0, 0};
    Point end = {100, 0};

    print_point(start);
    koch_curve(start, end, 0);
    print_point(end);
}


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

int main() {
  int N, M, A, B;
  cin >> N >> M >> A >> B;
  vector<string> S(N);
  for(auto& i: S) for(auto j=0; j<M; ++j) i += ".";

  if(N&1) {
    for(auto i=0; i+1<M; i+=2) {
      if(A==0) break;
      --A;
      S[N-1][i] = '<';
      S[N-1][i+1] = '>';
    }
  }
  if(M&1) {
    for(auto i=0; i+1<N; i+=2) {
      if(B==0) break;
      --B;
      S[i][M-1] = '^';
      S[i+1][M-1] = 'v';
    }
  }
  if(N&1 && M&1) if(A&1 && B&1) {
    A-=1;
    B-=1;
    S[N-3][M-3] = '^';
    S[N-2][M-3] = 'v';
    S[N-1][M-3] = '<';
    S[N-1][M-2] = '>';
    S[N-1][M-1] = 'v';
    S[N-2][M-1] = '^';
    S[N-3][M-1] = '>';
    S[N-3][M-2] = '<';
  }

  for(auto i=0; i+1<N; i+=2) for(auto j=0; j+1<M; j+=2) {
    if(S[i][j]!='.') continue;
    if(S[i][j+1]!='.') continue;
    if(S[i+1][j]!='.') continue;
    if(S[i+1][j+1]!='.') continue;
    if(1<A) {
      A-=2;
      S[i][j] = '<';
      S[i][j+1] = '>';
      S[i+1][j] = '<';
      S[i+1][j+1] = '>';
      continue;
    }
    if(1<B) {
      B-=2;
      S[i][j] = '^';
      S[i+1][j] = 'v';
      S[i][j+1] = '^';
      S[i+1][j+1] = 'v';
      continue;
    }
    if(A) {
      --A;
      S[i][j] = '<';
      S[i][j+1] = '>';
      continue;
    }
    if(B) {
      --B;
      S[i][j] = '^';
      S[i+1][j] = 'v';
      continue;
    }
  }

  if(A || B) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    for(auto i: S) cout << i << "\n";
  }
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n[10];
    for(int i=0;i<10;i++)
      cin>>n[i];
  sort(n,n+10);
  for(int i=9;i>=7;i--){
    cout<<n[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3156
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

const int INF = 1e9 + 5;

vector <int> h;
vector <int> dp;
int n;

int main(){

    scanf("%d",&n);
    dp.assign(n,INF);
    
    for(int i=0;i<n;i++){
        int height;
        scanf("%d",&height);
        h.push_back(height);
    }

    dp[0] = 0;

    for(int i=0;i<n;i++){
        for(int j=i+1; j<=i+2; j++){
            if(j < n){
                dp[j] = min(dp[j],dp[i] + abs(h[i] - h[j]));
            }
        }
    }

    printf("%d\n",dp[n-1]);
    return 0;
}

Measured memory_bytes: 1276
#include<iostream>
using namespace std;
int main(){
	int a,b,c,ans1,ans2,ans3;
	cin>>a>>b>>c;
	ans1=a+b;
	ans2=a+c;
	ans3=b+c;
	if(ans1<=ans2 && ans2<ans3){
		cout<<ans1<<endl;
	}
	else if(ans1<ans3 && ans3<ans2){
		cout<<ans1<<endl;
	}
	else if(ans2<=ans1 && ans1<ans3){
		cout<<ans2<<endl;
	}
	else if(ans2<ans3 && ans3<ans1){
		cout<<ans2<<endl;
	}
	else if(ans3<=ans1 && ans1<ans2){
		cout<<ans3<<endl;
	}
	else if(ans3<ans2 && ans2<ans1){
		cout<<ans3<<endl;
	}
	else if(ans1==ans2 && ans2==ans3){
		cout<<ans1<<endl;
	}
	return 0;
}

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++)
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; }
vector<ll> prime_factorize(ll x){
    // e.g.) prime_factorize(12) -> {2, 2, 3}
    vector<ll> res;
    ll y=x;

    for(ll i=2; i*i<=x; i++){
        while(y%i==0){
            y/=i;
            res.push_back(i);
        }
    }
    if(y>1) res.push_back(y);

    return res;
}

ll pow(ll n, ll x, ll mod){
    // return (n^x)%mod
    if(x==0) return 1;
    if(x%2==0){
        ll t=pow(n, x/2, mod);
        return (t*t)%mod;
    }else{
        return (n*pow(n, x-1, mod))%mod;
    }
}

ll gcd(ll a, ll b){
    if(a<b) swap(a,b);
    if(a%b==0) return b;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}

ll euler_phi(ll x){
    // return Euler's phi function
    // (the number of i in [1, x] that is coprime with x)
    ll res=x;
    for(ll i=2; i*i<=x; i++){
        if(x%i>0) continue;
        while(x%i==0) x/=i;
        res/=i;
        res*=i-1;
    }
    if(x>1){
        res/=x;
        res*=x-1;
    }

    return res;
}


int main(){
    ll n; cin>>n;
    cout<<euler_phi(n)<<endl;
    return 0;
}


Measured memory_bytes: 3112
N=int(input())
INF=10**10
dp=[[-1]*3 for i in range(N)]
for i in range(N):
  abc=list(map(int,input().split()))
  if i==0:
    dp[0][0]=abc[0]
    dp[0][1]=abc[1]
    dp[0][2]=abc[2]
    continue
  for j in range(3):
    for k in range(3):
      if j==k:continue
      dp[i][j]=max(dp[i][j],dp[i-1][k]+abc[j])
print(max(dp[-1]))

Measured memory_bytes: 86304
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for(int i = 1; i <= n; i++){
			if(i % 2 != 0)
				count++;
		}
		double ans = (double)count / n;
		System.out.println(ans);
		
	}

	}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// dp[x]:= Kで割った余りがxの集合の中で、桁数和最小
ll dp[100005];

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

    vector<ll> dp(100005, longinf);

    priority_queue<P_ii, vector<P_ii>, greater<P_ii>> que;
    for(ll i = 1; i <= 9; i++){
        chmin(dp[i % K], i);
        que.push({dp[i % K], i});
    }

    while(!que.empty()){
        ll x = que.top().second;
        ll cost = que.top().first; 
        que.pop();

        if(dp[x] != cost) continue;

        REP(y, 10){
            if(dp[(10 * x + y) % K] > cost + y){
                dp[(10 * x + y) % K] = cost + y;
                que.push({dp[(10 * x + y) % K], (x * 10 + y) % K});
            }
        }
    }

    cout << dp[0] << endl;


    return 0;
}

Measured memory_bytes: 7280
import sys
sys.setrecursionlimit(10**6)
def f(x):
	global hashi
	if(x in hashi):
		return hashi[x]
	if(adj[x]==[]):
		return 0
	mino=0
	for i in adj[x]:
		mino=max(mino,f(i))
	hashi[x]=mino+1
	return mino+1
l=input().split()
n=int(l[0])
m=int(l[1])
adj=[[] for i in range(n+1)]
for i in range(m):
	l=input().split()
	u=int(l[0])
	v=int(l[1])
	adj[u].append(v)
maxa=0
hashi=dict()
for i in range(1,n+1):
	maxa=max(maxa,f(i))
print(maxa)


Measured memory_bytes: 163916
#include <iostream>
#include <vector>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <complex>
#include <cmath>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef long double R;
typedef complex<R> P;

const R EPS = 1e-10;
const R PI = acos((R)(-1));

int sgn(R a) {
    if (a < -EPS) return -1;
    if (a > EPS) return 1;
    return 0;
}

int sgn(R a, R b) { return sgn(b-a); }


const int MN = 110;
int w, h, n;
P p[2*MN];

R check(R y) {
    vector<R> v;
    for (int i = 0; i < 2*n; i++) {
        v.push_back(arg(p[i] - P(0, y)));
    }
    sort(v.begin(), v.end());
    R miarg = arg(P(w, 0) - P(0, y));
    R maarg = arg(P(w, h) - P(0, y));
    R a1 = v[n-1], a2 = v[n];
    a1 = max(a1, miarg);
    a2 = min(a2, maarg);
    if (a2 < a1) return 0;
    return (tan(a2)-tan(a1))*w;
}


bool solve() {
    cin >> w >> h >> n;
    if (!w && !h && !n) return false;
    vector<R> ch = {0, (R)h};
    vector<P> buf;
    for (int i = 0; i < 2*n; i++) {
        int x, y;
        cin >> x >> y;
        p[i] = P(x, y);
        if (x == 0) {
            ch.push_back(y);
            continue;
        }
        buf.push_back(p[i]);
    }
    buf.push_back(P(w, 0));
    buf.push_back(P(w, h));

    int m = (int)buf.size();

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
            P a = buf[i], b = buf[j];
            if (!sgn(a.real(), b.real())) continue;
            R c = a.imag()-tan(arg(b-a))*a.real();
            if (sgn(c, 0) == 1) continue;
            if (sgn(h, c) == 1) continue;
            ch.push_back(c);
        }
    }
    sort(ch.begin(), ch.end());

    int l = (int)ch.size();
    R sm = 0;
    for (int i = 0; i < l-1; i++) {
        sm += (ch[i+1]-ch[i]) * check((ch[i+1]+ch[i])/2);
    }

    printf("%.20Lf\n", sm / h / h);
    return true;
}

int main() {
    while (true) {
        if (!solve()) break;
    }
    return 0;
}

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

unsigned long long lcm(unsigned long long a, unsigned long long b)
{
    unsigned long long g = __gcd(a, b);
    return (a / g * b);
}

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

    vector<unsigned long long> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    unsigned long long ans = 1;
    for(int i = 0; i < N; i++)
    {
        ans = lcm(ans, v[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long maxn=3e5+5;
const long long inf=(1LL<<62);
priority_queue<long long> q1,q2; 
long long a[maxn],maxv[maxn],minv[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long n;
	cin>>n;
	for(long long i=1;i<=3*n;i++)
		cin>>a[i];
	long long sum=0;
	for(long long i=1;i<=2*n;i++)
	{
		q1.push(-a[i]);
		sum+=a[i];
		if(i>n)
			sum+=q1.top(),q1.pop();
		maxv[i]=sum;
	}
	sum=0;
	for(long long i=3*n;i>=n+1;i--)
	{
		q2.push(a[i]);
		sum+=a[i];
		if(i<=2*n)
			sum-=q2.top(),q2.pop();
		minv[i]=sum;
	}
	long long ans=-inf;
	for(long long i=n;i<=2*n;i++)
		ans=max(ans,maxv[i]-minv[i+1]);
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 8180
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
const int mod=1e9+7;

int main(){
	string s;
	cin >> s;
	for(int i=1; i<s.size(); i++){
		if(s[i]==s[i-1]){
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

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


Measured memory_bytes: 3596
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	var n int
	if s == "RRR" {
		n = 3
	} else if strings.Index(s, "RR") != -1 {
		n = 2
	} else if strings.Index(s, "R") != -1 {
		n = 1
	} else {
		n = 0
	}

	fmt.Println(n)
}


Measured memory_bytes: 1836
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a;
    cin >> a;
    // スペース区切りの整数の入力
    //int b,c;
    //cin >> b >> c;
    // 文字列の入力
    string s;
    cin >> s;
    // 出力
    if (a < 3200){
     cout << "red" << endl; 
    } else {
     cout << s << endl; 
    }
    return 0;
}

Measured memory_bytes: 256
function Main(arg) {
 
    var A = arg.split(" ")[0] - 0;
    var B = arg.split(" ")[1] - 0;

    var kouyaku = [];
    var gcd = GCD(A, B);
    for (var i = 1; i*i <= gcd; i++) {
        if (gcd % i === 0) {
            kouyaku.push(i);
            var tmp = (gcd / i);
            if (i !== tmp) {
                kouyaku.push(tmp);
            }
        }
    }

    kouyaku = kouyaku.sort(compareNumbers);

    var ans = [];
    while (kouyaku.length > 0) {
        
        var tmp = kouyaku[0];
        kouyaku.shift();
        ans.push(tmp);

        if (tmp === 1) continue;
        if (kouyaku.length === 0) break;

        kouyaku = kouyaku.filter(val => val % tmp !== 0);
    }


    console.log(ans.length);
}

var GCD = function(a, b) {
    if ( ! b) {
        return a;
    }

    return GCD(b, a % b);
};

function compareNumbers(a, b) { //for sort
    return a - b;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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


class UnionFind {
public:
    // parent node index if not root index
    // minus size of the tree if root index
    std::vector<int> data;
    UnionFind( int n ) {
        data.resize( n, -1 );
    }
    int find( int x ) {
        if ( data[x] < 0 ) {
            return x;
        } else {
            int r = find( data[x] );
            data[x] = r;
            return r;
        }
    }
    void unite( int x, int y ) {
        int r = find( x );
        int s = find( y );
        if ( r != s ) {
            data[r] += data[s];
            data[s] = r;
        }
    }
    int size( int x ) {
        int r = find(x);
        return -data[r];
    }
};


ll solve() {
    ll N, M, a, b;
    cin >> N >> M;
    UnionFind uf(N);
    for ( int i = 0; i < M; i++ ) {
        cin >> a >> b;
        a--, b--;
        uf.unite(a,b);
    }

    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        ans = max(ans, (ll)uf.size(i));
    }

    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4588
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

const int MaxN = 1e5;
using namespace std;

int n;
map <int,int> s;

struct po{
	int x, y;
	int num;
}red[105], blu[105];
 
bool cmp(po a, po b)
{
	return a.num < b.num;
}
 
 
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> red[i].x >> red[i].y;
		red[i].num = 0;
	}
	for(int i = 1; i <= n; i++)
	{
		cin >> blu[i].x >> blu[i].y;
		blu[i].num = 0;
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(red[i].x < blu[j].x && red[i].y < blu[j].y)
			{
				red[i].num++;
				blu[j].num++;
			}
		}
	}
	sort(red + 1, red + 1 + n, cmp);
	sort(blu + 1, blu + 1 + n, cmp);
	int sum = 0;
	for(int i = 1; i <= n; i++)	
	{
		for(int j = 1; j <= n; j++)
		{
			if(red[i].x < blu[j].x && red[i].y < blu[j].y && s[j] == 0)
			{
				sum++;
				s[j] = 1;
				break;
			}
		}
	}
	cout << sum << endl;
	return 0;
}



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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    ll ans = 0;
    Repe(a,N,1){
        ans += (N-1)/a;
    }
    printf ("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 3824
#include<stdio.h>
#include<algorithm>

bool descend(long long a,long long b)
{
    return a>b;
}

int main()
{
    int x,y,a,b,c;

    scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);

    long long red[a],green[b],no_col[c];

    for(int i=0;i<a;i++)
        scanf("%lld",&red[i]);

    for(int i=0;i<b;i++)
        scanf("%lld",&green[i]);

    for(int i=0;i<c;i++)
        scanf("%lld",&no_col[i]);

    std::sort(red,red+a,descend);
    std::sort(green,green+b,descend);
    std::sort(no_col,no_col+c,descend);

    long long sum_red=0,sum_green=0;

    for(int i=0;i<x;i++)
        sum_red+=red[i];

    for(int i=0;i<y;i++)
        sum_green+=green[i];

    int i=x-1,j=y-1;

    for(int k=0;k<c;k++)
    {
        long long add_to_red;
        if(i>=0)
            add_to_red=no_col[k]-red[i];
        else
            add_to_red=-1;

        long long add_to_green;
        if(j>=0)
            add_to_green=no_col[k]-green[j];
        else
            add_to_green=-1;

        if(add_to_red==-1 && add_to_green==-1)
            break;

        if(add_to_red>0 && add_to_red>add_to_green)
        {
            sum_red+=add_to_red;
            i--;
        }
        else if(add_to_green>0)
        {
            sum_green+=add_to_green;
            j--;
        }
        else
            break;
    }

    printf("%lld",sum_red+sum_green);

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> v(h);
    for (auto &&i : v) cin >> i;
    int ans = INF<int>;
    auto dp = make_v(h, w, 0);
    vector<int> cnt(h);
    for (int a = 0; a < (1 << (h-1)); ++a) {
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                dp[i][j] = 0;
            }
            cnt[i] = 0;
        }
        int cur = 0;
        int ok = 1;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                dp[cur][j] += v[i][j] - '0';
            }
            if(a & (1 << i)) cur++;
        }
        int val = cur++;
        for (int j = 0; j < w; ++j) {
            int good = 1;
            for (int i = 0; i < cur; ++i) {
                cnt[i] += dp[i][j];
                if(cnt[i] > k){
                    good = 0;
                }
            }
            if(!good){
                val++;
                for (int i = 0; i < cur; ++i) {
                    cnt[i] = dp[i][j];
                    if(dp[i][j] > k) ok = 0;
                }
                if(!ok) break;
            }
        }
        if(ok){
            ans = min(ans, val);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define Sort(x) sort(x.begin(),x.end()); 
#define ll long long
int mod=1e9+7;
const int INF = 1e9;

using namespace std;



int main(void) {
	string s;
	cin >> s;
	vector<int> v(10, 0);
	

	if (s[0] == s[1] && s[1] == s[2]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (s[1] == s[2] && s[2] == s[3]) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int,input().split())
s=[[]for i in range(N)]
for i in range(M):
    L,R,D=map(int,input().split())
    s[L-1].append((R-1,D))
    s[R-1].append((L-1,-D))
sys.setrecursionlimit(200000)
l=[None]*N
a=1
def hu(n,x):
    global a
    for i in s[n]:
        if l[i[0]]==None:
            l[i[0]]=x+i[1]
            hu(i[0],x+i[1])
        else:
            if x+i[1]!=l[i[0]]:
                a=0
for i in range(N):
    if l[i]==None:
        l[i]=0
        hu(i,0)
print("Yes" if a else "No")

Measured memory_bytes: 131980
#include<bits/stdc++.h>
using namespace std;
const long MAXN=std::numeric_limits<long>::max(); 

int main()
{
	int n,i,j,k;
	cin>>n;
	int h[n+1];
	int dp[n+1];
	for(i=1;i<=n;i++)
		cin>>h[i];

	dp[0]=0;
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(i=3;i<=n;i++)
		dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
	
	cout<<dp[n]<<endl;
	
	
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();


		if(N<100 && N>=10) {
			N = N%10;
		}else if(N>=100){
			N = N%100%10;
		}

		switch(N){
			case 2:
			case 4:
			case 5:
			case 7:
			case 9:
				System.out.print("hon");
				break;
			case 0:
			case 1:
			case 6:
			case 8:
				System.out.print("pon");
				break;
			case 3:
				System.out.print("bon");
				break;

		}
	}

}


Measured memory_bytes: 35640
n = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)
ans = 0
cnt = 0
while true
  n.times do |i|
    if h[i] > 0
      cnt += 1
      h[i] -= 1
    else
      if cnt != 0
        ans += 1
        cnt = 0
      end
    end
  end
  ans += 1 if cnt != 0
  cnt = 0
  break if h.all?{|x| x == 0}
end
puts ans

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

struct edge{
	int to;
	long long cost;
};

int N,Q,K;
vector<edge> G[100010];
vector<long long> dist(100010);
vector<long long> ans;
queue<int> que;
vector<bool> visited(100010,false);

void BFS(){
	while(que.empty()==0){
		int f=que.front();
		que.pop();
		for(auto t:G[f]){
			if(!visited[t.to]){
				dist[t.to]=dist[f]+t.cost;
				visited[t.to]=true;
				que.push(t.to);
			}
		}
	}
}

int main(){
	cin >> N;
	for(int i=0;i<N-1;i++){
		int a,b;
		long long c;
		cin >> a >> b >> c;
		edge e;e.to=b;e.cost=c;
		G[a].push_back(e);
		e.to=a;
		G[b].push_back(e);
	}
	
	cin >> Q >> K;
	
	dist[K]=0;
	que.push(K);
	visited[K]=true;
	
	BFS();
	
	for(int i=0;i<Q;i++){
		int x,y;
		cin >> x >> y;
		long long a=dist[x]+dist[y];
		ans.push_back(a);
	}
	
	for(auto a:ans)cout << a << endl;
	return 0;
}

Measured memory_bytes: 11120
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

const int maxn = 1e5 + 5;
int n, k;
int a[maxn];

void chemthan() {
    cin >> n >> k;
    FOR(i, 0, n) cin >> a[i], a[i]--;
    FOR(i, 1, n + 1) {
        if ((long long) i * k - (i - 1) >= n) {
            cout << i << "\n";
            return;
        }
    }
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 640