akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(h,n);
    vector<pair<int,int>> vec(n);
    rep(i,n){
        in(vec[i].first,vec[i].second);
    }
    vector<int> dp(h+1,2000000000);
    dp[0]=0;
    for(int i=1;i<=h;i++){
        rep(j,n){
            if(i-vec[j].first>=0)dp[i]=min(dp[i],vec[j].second+dp[i-vec[j].first]);
            else dp[i]=min(dp[i],vec[j].second);
        }
    }
    out(dp[h]);
}

Measured memory_bytes: 3804
//#include "stdc++.h"
#include <bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
//#define sz(x) (int)(x.size())
#define ff first
#define ss second
#define endl "\n"
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p;}
const ll MOD =1000000007 ;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
#define pi 3.141592653589793238462
#define int  long long

int32_t main()
{
    IOS;
    int n,k;
    cin>>n>>k;ldb ans=0,ans1=0,x,z,y;
    if(n>=k)
    {
        ans=(ldb)(n-k+1)/n;
    }
    for(int i=1;i<=min(n,k-1);i++)
    {
        y=ceil((ldb)k/i);
        z=ceil((ldb)log2(y));
        x=pow((ll)2,z);
   // cout<<x<<endl;
        ans1+=(ldb)1.0/x;
        
    }
    ans1=(ldb)ans1/n;
    ans=ans+ans1;
    cout<<setprecision(20);
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    string s;
    int answer = 0;
    for (int i = a; i <= b; i++)
    {
        s = to_string(i);
        if ((s.at(0) == s.at(4)) && (s.at(1) == s.at(3)))
            answer++;
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[100000],n,k,s,ans;
int main(){
	while(true){
	cin>>n>>k;
	if(!n&&!k)break;
	s=0,ans;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i<k)s+=a[i];
	}
	ans=s;
	for(int i=k;i<n;i++)s+=a[i]-a[i-k],ans=max(s,ans);
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int m = 1000000007; 

int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

 	char ch;
 	cin >> ch;

 	if (ch >= 'A' && ch <= 'Z')
 		cout << 'A' << endl;
 	else 
 		cout << 'a' << endl;
	return 0;
}




Measured memory_bytes: 3632
import sys
input = sys.stdin.buffer.readline

def main():
	N = int(input())
	
	ans = 0
	a1 = int(input())
	ans += a1-1

	base = 2
	for _ in range(N-1):
		a = int(input())
		if a < base:
			continue
		elif a == base:
			base += 1
		else:
			ans += (a-base-1)//base+1
	
	print(ans)

if __name__ == "__main__":
	main()

Measured memory_bytes: 40468
#include "bits/stdc++.h"
#include <random>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int D;

int c[27];
int s[366][27];
int last[27];

const ll INF = 1e9;

vector<int> ans;
ll ans_score;

ll calcScore(){
    ll score = 0;
    for(int d = 1; d <= D; ++d){
        int t = ans[d];
        score += s[d][t];
        last[t] = d;
        for(int i = 1; i <= 26; ++i){
            score -= c[i] * (d - last[i]);
        }
    }
    return score;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> D;
    for(int i = 1; i <= 26; ++i) cin >> c[i];
    for(int i = 1; i <= D; ++i){
        for(int j = 1; j <= 26; ++j){
            cin >> s[i][j];
        }
    }
    ans_score = 0;
    //greedy
    for(int d = 1; d <= D; ++d){
        ll score = -INF;
        int id = 1;
        for(int t = 1; t <= 26; ++t){
            ll new_score = s[d][t];
            last[t] = d;
            for(int i = 1; i <= 26; ++i){
                new_score -= c[i] * (d - last[i]);
            }
            if(score < new_score){
                id = t;
                score = new_score;
            }
        }
        ans.push_back(id);
        ans_score += score;
    }
    //local search
    std::random_device rnd;
    std:: mt19937 mt(rnd());
    std::uniform_int_distribution<> randD(1,D);
    std::uniform_int_distribution<> randA(1,26);
    rep(_,1000){
        int d = randD(mt);
        int q = randA(mt);
        int old = ans[d];
        ans[d] = q;
        ll score = calcScore();
        if(ans_score > score){
            ans[d] = old;
        }
        else{
            ans_score = score;
        }
    }
    rep(i,D) cout << ans[i] << endl;
    return 0;
}


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

//累積和

int main(){
    int N;
    string S;
    cin  >> N >> S;
    vector<int> West(N+1,0) , East(N+1,0);

    for(int i = 0;i < N;i++){
        West[i+1] += West[i];
        if(S[i] == 'W')West[i+1] += 1;
        East[i+1] += East[i];
        if(S[i] == 'E')East[i+1] += 1;
    }
    int ans = INT32_MAX;
    int tmp = 0;

    for(int i = 0;i < N;i++){
        tmp = West[i] + (East[N] - East[i+1]);
        if(ans > tmp) ans = tmp;
    }

    cout << ans << endl;
}

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

using namespace std;

#define endl "\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1n(i, n) for (int i = 1; i < (int)(n); ++i)
#define forln(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define forl1n(i, n) for (long long i = 1; i < (long long)(n); ++i)


const ll maxLONG = 9223372036854775807;
const int maxINT = 2147483647;
const ll mod = 1000000007;
const ld EPS = 1e-9;
const int N = 1e5 + 9;
const ll INF = LONG_LONG_MAX;

ll GetMod(ll n, ll z) { // func to get mod for positive num and negitive nums
    return (n % z + z) % z;
}

//          U   R  D  L
int dx[] = {-1, 0, 1, 0, -1, +1, +1, -1}; // dx for the 8 adjacent places in matrix
int dy[] = {0, 1, 0, -1, +1, +1, -1, -1};// dy for the 8 adjacent places in matrix
int n, k;
vector<int> v;
int dp[N] = {};

int check(int pos) {

    if (pos == v.size() - 1)return 0;
    if (dp[pos] != -1)return dp[pos];
    int u = 1e9;
    for (int i = 1; i <= k; i++) {
        if (pos + i < v.size())
            u = min(u, abs(v[pos] - v[pos + i]) + check(pos + i));
        else
            break;
    }

    dp[pos] = u;
    return dp[pos];
}

int main() {

    ios_base::sync_with_stdio(false), cin.tie(NULL);
    cin >> n;
    cin >> k;
    v.resize(n);
    forn(i, n)cin >> v[i];
    fill(dp, dp + N, -1);
    cout << check(0);
}

Measured memory_bytes: 8832
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int N,H; cin>>N>>H;
    vector<ip> k(N);
    rep(i,N)cin>>k[i].second>>k[i].first;
    int hi = 0;
    rep(i,N)hi = max(hi, k[i].second);
    sort(k.begin(),k.end());
    int ans = 0;
    for(int i = N-1;i>=0; --i){
        if(k[i].first>hi){H-=k[i].first; ans++;}
        if(H<=0){cout<<ans<<endl; return 0;}
    }
    ans += ceil(H/(double)hi);
    cout<<ans<<endl; return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

bool can(string s, string t) {
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i] && s[i] != '?')
            return false;
    }
    return true;
}

int main() {

    string s, t, b = "~";
    cin >> s >> t;

    int n = s.size() - t.size() + 1;
    int i = 0, cnt = 0;
    bool tmp;
    for(i = 0; i < max(0, n); i++) {
        string u = s.substr(i, t.size());
        if (can(u, t) == true) {
            string v = s;
            for (int j = i; j < i + t.size(); j++)
                v[j] = t[j-i];
            for (int j = 0; j < i; j++) {
                if (v[j] == '?')
                    v[j] = 'a';
            }
            for (int j = i + t.size(); j < v.size(); j++) {
                if (v[j] == '?')
                    v[j] = 'a';
            }
            b = min(b, v);         
        }
    }

    if (b == "~")
        cout << "UNRESTORABLE" << endl;
    else
        cout << b << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*
import java.math.*

fun main(args: Array<String>) {
    var (A,B,C) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val S = readLine()!!
//    val D = readLine()!!.split(" ").map { it.toLong() }
    var ans = C-(A-B)
    println(if (ans < 0) 0 else ans)
}


Measured memory_bytes: 37900
#include<stdio.h>
#include<math.h>
int main(void){
	double x1,x2,y1,y2,c;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	c=sqrt(pow((x2-x1),2)+pow((y2-y1),2));
	printf("%lf\n",c);
	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> G(h, vector<char>(w));
    for(int x=0; x<=h-1; x++){
        for(int y=0; y<=w-1; y++){
                cin >> G[x][y];
        }
    }
    // for(int x=0; x<=h-1; x++){
    //     for(int y=0; y<=w-1; y++){
    //         cout << G[x][y];
    //     }
    //     cout << endl;
    // }

    vector<vector<int>> G1(h, vector<int>(w,0));
    vector<vector<int>> G2(h, vector<int>(w,0));
    vector<vector<int>> G3(h, vector<int>(w,0));
    vector<vector<int>> G4(h, vector<int>(w,0));
    for(int x=0; x<=h-1; x++){
        int tumi = 0;
        for(int y=0; y<=w-1; y++){
            if (G[x][y]=='#'){
                tumi=0;
            }
            else{
                tumi+=1;
            }
            G1[x][y] = tumi;
        }
    }
    for(int x=0; x<=h-1; x++){
        int tumi = 0;
        for(int y=w-1; 0<=y; y--){
            if (G[x][y]=='#'){
                tumi=0;
            }
            else{
                tumi+=1;
            }
            G2[x][y] = tumi;
        }
    }
    for(int y=0; y<=w-1; y++){
        int tumi=0;
        for(int x=0; x<=h-1; x++){
            if (G[x][y]=='#'){
                tumi=0;
            }
            else{
                tumi+=1;
            }
            G3[x][y] = tumi;
        }
    }
    for(int y=0; y<=w-1; y++){
        int tumi=0;
        for(int x=h-1; 0<=x; x--){
            if (G[x][y]=='#'){
                tumi=0;
            }
            else{
                tumi+=1;
            }
            G4[x][y] = tumi;
        }
    }
    ll ma = -1;
    for(int x=0; x<=h-1; x++){
        for(int y=0; y<=w-1; y++){
            if(G[x][y]=='#') {
                // cout << ' ';
                continue;
            }
            else{
                int t = G1[x][y]+G2[x][y]-1 + G3[x][y]+G4[x][y]-1 -1;
                if (t>ma) ma = t;
            }
        }
            // cout << endl;
    }
    // for(int x=0; x<=h-1; x++){
    //     for(int y=0; y<=w-1; y++){
    //         cout << G1[x][y] << " ";
    //     }
    //     cout << endl;
    // }
    
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 67072
#include <bits/stdc++.h>
using namespace std ;
template < class R > inline void Readin( R &K ) {
	K = 0 ; bool F = false ; char C = getchar() ; while( C < '0' or C > '9' ) { if( C == '-' ) F = true ; C = getchar() ; }
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ; if( F ) K = -K ;
}
template < class R > inline void Checkmax( R &A , R B ) {
	if( A < B ) A = B ;
}
template < class R > inline void Checkmin( R &A , R B ) {
	if( A > B ) A = B ;
}
const int Mod = 1e9 + 7 ;
const int MaxN = 100000 + 10 ;
inline void Moding( int &A ) {
	if( A >= Mod ) A -= Mod ;
	if( A < 0 ) A += Mod ;
}
inline int Pow( int A , int B ) {
	register int Ans = 1 ;
	while( B ) {
		if( B & 1 ) Ans = 1ll * Ans * A % Mod ;
		A = 1ll * A * A % Mod ;
		B >>= 1 ;
	}
	return Ans ;
}
int __Fac[MaxN] , __Inv[MaxN] ;
inline void __C_Init() {
	register int N = MaxN - 10 ;
	__Fac[0] = __Inv[0] = 1 ;
	for(register int i = 0 ; ++i <= N ; )
		__Fac[i] = 1ll * __Fac[i-1] * i % Mod ;
	__Inv[N] = Pow( __Fac[N] , Mod - 2 ) ;
	for(register int i = N ; --i ; )
		__Inv[i] = 1ll * __Inv[i+1] * (i+1) % Mod ;
}
inline int __C( int N , int M ) {
	return 1ll * __Fac[M] * __Inv[N] % Mod * __Inv[M-N] % Mod ;
}
int N , K ;
int Mid ;
int Last , Now ;
int main() {
	Readin( N ) ;
	Readin( K ) ;
	Readin( Last ) ;
	for(register int i = 0 ; ++i < N ; ) {
		Readin( Now ) ;
		if( Last + Now >= K ) {
			Mid = i ;
			break ;
		}
		Last = Now ;
	}
	if( Mid ) {
		printf( "Possible\n" ) ;
		for(register int i = 0 ; ++i < Mid ; )
			printf( "%d\n" , i ) ;
		for(register int i = N ; --i > Mid ; )
			printf( "%d\n" , i ) ;
		return not printf( "%d\n" , Mid ) ;
	}
	return not printf( "Impossible\n" ) ;
}

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

int main(){

    int t=0,ans=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C') t++;
        else{
            ans=max(ans,t);
            t=0;
        }
    }
    ans=max(ans,t);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int p[30];
int q[30];
int r[30];
int tmp[30];
int ans[30];
int m;
int used[30];
int ret;
void dfs(int a,int b,int c){
	if(ret<b){
		ret=b;
		for(int j=0;j<30;j++)ans[j]=tmp[j];
	}else if(ret==b){
		bool ok=false;
		for(int j=0;j<30;j++){
			if(!~ans[j]||ans[j]<tmp[j]){ok=false;break;}
			if(!~tmp[j]||ans[j]>tmp[j]){ok=true;break;}
		}
		if(ok)for(int j=0;j<30;j++)ans[j]=tmp[j];
	}
	for(int i=0;i<m;i++){
		if(used[i])continue;
		if(p[i]==a){
			used[i]=1;
			tmp[c+1]=q[i];
			dfs(q[i],b+r[i],c+1);
			used[i]=0;
		}else if(q[i]==a){
			used[i]=1;
			tmp[c+1]=p[i];
			dfs(p[i],b+r[i],c+1);
			used[i]=0;
		}
	}
}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		m=b;
		for(int i=0;i<b;i++){
			scanf("%d%d%d",p+i,q+i,r+i);
			p[i]--;q[i]--;
		}
		ret=0;
		for(int i=0;i<a;i++){
			for(int j=0;j<30;j++)used[j]=0;
			for(int j=0;j<30;j++)tmp[j]=-1;
			tmp[0]=i;
			dfs(i,0,0);
		}
		printf("%d\n",ret);
		for(int i=0;~ans[i];i++){
			if(i)printf(" ");
			printf("%d",ans[i]+1);
		}printf("\n");
	}
}

Measured memory_bytes: 1032
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  auto doit = [] (vector<pair<int, int>>& v) -> long long {
    sort(v.rbegin(), v.rend());
    int pos = (int) v.size() - 1;
    long long res = 0;
    priority_queue<long long> que;
    int it = 0;
    while (pos >= 0) {
      while (it < (int) v.size() && v[it].first >= pos) {
        que.push(v[it++].second);
      }
      if (!que.empty()) {
        res += que.top();
        que.pop();
      }
      pos--;
    }
    return res;
  };
  auto solve = [&] () -> long long {
    int n;
    cin >> n;
    vector<pair<int, int>> type1, type2;
    long long res = 0;
    for (int i = 0; i < n; i++) {
      int k, l, r;
      cin >> k >> l >> r;
      if (l >= r) {
        k--;
        res += r;
        type1.emplace_back(k, l - r);
      } else {
        k = n - k;
        k--;
        res += l;
        type2.emplace_back(k, r - l);
      }
    }
    return res + doit(type1) + doit(type2);
  };
  int t;
  cin >> t;
  while (t--) cout << solve() << '\n';
  return 0;
}

Measured memory_bytes: 6452
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
int main()
{
  int h,w,m; cin >> h >> w >> m;
  vector<ll> x(m),y(m);
  rep(i,m) {
    cin >> x[i] >> y[i];
    x[i]--; y[i]--;
  }

  vector<pi> xx(h,{0,0}), yy(w,{0,0});
  rep(i,h) xx[i].S = i;
  rep(i,w) yy[i].S = i;  
  rep(i,m) {
    xx[x[i]].F--;
    yy[y[i]].F--;
  }

  sort(xx.begin(), xx.end());
  sort(yy.begin(), yy.end());
  ll cnx = 0, cny = 0;
  set<int> stx, sty;
  while(cnx < xx.size() && xx[0].F == xx[cnx].F) {
    stx.insert(xx[cnx].S);
    cnx++;
  }
  while(cny < yy.size() && yy[0].F == yy[cny].F) {
    sty.insert(yy[cny].S);
    cny++;
  }  

  if(cnx * cny > m) cout << - xx[0].F - yy[0].F << "\n";
  else {
    ll cnt = 0;
    rep(i,m) {
      if(stx.find(x[i]) != stx.end() && sty.find(y[i]) != sty.end()) {
	cnt++;
      }
    }
    if(cnt >= cnx*cny) cout << - xx[0].F - yy[0].F - 1 << "\n";
    else cout << - xx[0].F - yy[0].F << "\n";
  }
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    map<string, int> mp;
    rep(i,n) {
        cin >> s[i];
        mp[s[i]] = 0;
        // O(NlogN)
        /*
        auto itr = mp.find(s[i]);
        if (itr != mp.end()) itr->second++;
        else mp[s[i]] = 0;
        */
    }
    rep(i,n) {
        mp[s[i]]++;
    }
    int cnt = 0;
    vector<string> ans;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if (cnt < itr->second) {
            cnt = itr->second;
            ans = vector<string> (0);
            ans.push_back(itr->first);
        } else if (cnt == itr->second) ans.push_back(itr->first);
    }
    sort(ans.begin(), ans.end());
    rep(i,ans.size()) cout << ans[i] << endl;

    return 0;
}

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

using namespace std;

const int N = 1e5 + 5;
int n, dp[N][2], score[N]; //0 rock, 1 paper
string s;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin >> s;
    n = s.length();

    if(s[0] == 'g'){
        dp[1][0] = 1;
        dp[1][1] = 0;
        score[1] = 0;
    } else {
        dp[1][0] = 1;
        dp[1][1] = 0;
        score[1] = 0;
    }

    for(int i = 2; i <= n; i++){
        if(s[i - 1] == 'g'){
            if(dp[i - 1][1] + 1 <= dp[i - 1][0]){
                score[i] = score[i - 1] + 1;
                dp[i][1] = dp[i - 1][1] + 1;
                dp[i][0] = dp[i - 1][0];
            } else {
                dp[i][0] = dp[i - 1][0] + 1;
                dp[i][1] = dp[i - 1][1];
                score[i] = score[i - 1];
            }
        } else {
            if(dp[i - 1][1] + 1 <= dp[i - 1][0]){
                score[i] = score[i - 1];
                dp[i][1] = dp[i - 1][1] + 1;
                dp[i][0] = dp[i - 1][0];
            } else {
                dp[i][0] = dp[i - 1][0] + 1;
                dp[i][1] = dp[i - 1][1];
                score[i] = score[i - 1] - 1;
            }
        }
    }
    cout << score[n] << '\n';
    return 0;
}

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

        int main()
        {   int n,m,i,j,a,b,c,d;
            while(~scanf("%d %d %d %d",&a,&b,&c,&d))
            {   n=0,m=0;
                if(a<=b)
                {
                    n=a*c;
                }
                else
                {
                    m=(a-b)*d+b*c;
                }
                printf("%d\n",n+m);
            }
            return 0;
        }


Measured memory_bytes: 128
const K=parse(Int,readline())
function f(X,Y)
	ret=Pair{Int,Int}[]
	if X+Y!=K
		l=max(div(X+Y+K-1,K),2)
		l+=(l*K-X-Y)%2
		T=div(l*K-X-Y,2)
		V=0
		if T>K
			V=T-K
			T=K
		end
		push!(ret,K-T=>-T)
		x=K-T
		y=-T
		for i=3:l
			if x+K<=X+V
				push!(ret,(x+=K)=>y)
			else
				p=X+V-x
				push!(ret,(x=X+V)=>(y+=K-p))
			end
		end
	end
	push!(ret,X=>Y)
	ret
end
function main()
	X,Y=map(x->parse(Int,x),split(readline()))
	x=abs(X)
	y=abs(Y)
	if K%2==0&&(x+y)%2==1
		println(-1)
		exit()
	end
	flag=false
	if x<y
		x,y=y,x
		flag=true
	end
	ret=f(x,y)
	println(length(ret))
	for (a,b)=ret
		if flag
			a,b=b,a
		end
		println("$(a*(X<0?-1:1)) $(b*(Y<0?-1:1))")
	end
end
main()


Measured memory_bytes: 156992
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define repi(i,a) for(auto i = a.begin(); i!= a.end() ;++i) 
#define repdi(i,a) for(auto i = a.rbegin(); i!=a.rend();++i) 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) (int)a.size() 
#define all(a) a.begin(),a.end()
#define mod 998244353
#define limit 1000
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;   

#define int long
typedef vector<int> vii;
typedef pair<ll,ll> pii;
typedef vector<pii> vpi;
typedef vector<vector<ll> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

string a,b;
int dp[3000][3000];
string ans;

int res(int i,int j) {
	if(i>=sz(a) or j>=sz(b)) return 0;
	if(dp[i][j]!=-1) return dp[i][j];
	if(a[i] == b[j]) {
		return dp[i][j] = 1 + res(i+1,j+1);
	}
	return dp[i][j] = max(res(i+1,j),res(i,j+1));
}

void solve() {
	cin >> a >> b ;
	fl(dp,-1);
	res(0,0);	
	int i = 0 , j = 0 ;
	while(i<sz(a) and j<sz(b) ) {
		if(a[i] == b[j]) ans += a[i] , ++i, ++j;
		else if(dp[i+1][j] > dp[i][j+1]) ++i;
		else ++j;
	}
	cout << ans ;
}

int32_t main() {
 
    fast; 
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

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

using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/

#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second

#define what_is(x)     cerr << #x << " is " << x << endl;

///*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout << endl ;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
int ini()
{
    int x;
    scanf("%d",&x);
    return x;
}
long long inl()
{
    long long x;
    scanf("%lld",&x);
    return x;
}

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);

int main()
{
  int n,m,x,y,r1=0,r2=INT_MAX;
  cin>>n>>m;

  for(int i=1;i<=m;i++){
    cin>>x>>y;
    if(x>y)swap(x,y);
    r1=max(r1,x);
    r2=min(r2,y);
  }
  int res=r2-r1+1;

  if(res<=0)cout<<0<<endl;
  else{
    cout<<res<<endl;
  }

    return 0;
}


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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i=1;i<=n;++i)
    cin >> a[i];
  
  vector<int> dp(n+1, 0);
  
  dp[1] = 0;
  dp[2] = abs(a[2] - a[1]);
  for(int i=3;i<=n;++i)
    dp[i] = min(abs(a[i] - a[i-1]) + dp[i-1], abs(a[i] - a[i-2]) + dp[i-2]);
  
  cout << dp[n] << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int INF=1e9;
const ll MOD=1e9+7;

int N;
int a[105];

int main(){

cin>>N;

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

sort(a,a+N);

cout<<a[N-1]-a[0]<<endl;

}


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

double dist(vector<double> x, vector<double> y, double p) {
  double sum = 0;
  for (int i = 0; i < x.size(); i++) {
    sum += pow(fabs(x[i] - y[i]), p);
  }
  return pow(sum, 1.0 / p);
}

double chebyshev(vector<double> x, vector<double> y) {
  double ret = 0;
  for (int i = 0; i < x.size(); i++) {
    ret = max(ret, fabs(x[i] - y[i]));
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  vector<double> x(n), y(n);
  for (auto& e : x) cin >> e;
  for (auto& e : y) cin >> e;
  cout << fixed << setprecision(8)
       << dist(x, y, 1.0) << "\n"
       << dist(x, y, 2.0) << "\n"
       << dist(x, y, 3.0) << "\n"
       << chebyshev(x, y) << "\n";
}


Measured memory_bytes: 3436
#include <iostream>

using namespace std;

int main()
{
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int count = 0;
  for (int i = 0; i <= A; i++)
  {
    for (int j = 0; j <= B; j++)
    {
      for (int h = 0; h <= C; h++)
      {
        if (500 * i + 100 * j + 50 * h == X)
          count++;
      }
    }
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,m;
    cin >> n >> m;
    vi a(n);
    cin >> a;
    vvi G(n);
    rep(_,m) {
        int x,y;
        cin >> x >> y;
        G[x].pb(y);
        G[y].pb(x);
    }
    vi v,temp;
    int cnt = 0;
    ll ans = 0;
    vb seen(n);
    auto bfs = [&](int x) {
        queue<int> q;
        q.push(x);
        seen[x] = true;
        while(q.size()) {
            int now = q.front();
            q.pop();
            temp.pb(a[now]);
            for(int u : G[now]) {
                if(seen[u]) continue;
                seen[u] = true;
                q.push(u);
            }
        }
    };
    rep(i,n) {
        if(seen[i]) continue;
        temp.clear();
        bfs(i);
        cnt++;
        sort(all(temp));
        rep(j,temp.size()) {
            if(j == 0) ans += temp[j];
            else v.pb(temp[j]);
        }
    }
    if(cnt == 1) {
        cout << 0 << endl;
        return 0;
    }
    sort(all(v));
    int num = cnt-2;
    if(v.size() < num) {
        cout << "Impossible" << endl;
        return 0;
    }
    rep(i,num) ans += v[i];
    cout << ans << endl;
}


Measured memory_bytes: 10188
def nCk(_n,_k):
  return fact[_n]*ifact[_k]*ifact[_n-_k]%m

def main():
  for i in range(1,2001):
    fact[i]=fact[i-1]*i
    ifact[i]=pow(fact[i],m-2,m)
  n,k=map(int,input().split())
  for i in range(1,k+1):
    print(nCk(n-k+1,i)*nCk(k-1,i-1)%m if n-k>=i-1 else 0)

if __name__=='__main__':
  fact,ifact,m=[1]*2005,[1]*2005,10**9+7
  main()

Measured memory_bytes: 11584
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;



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

	int H,A;
	cin >> H >> A;

	int sum = 0;
	int cnt = 0;
	while (true) {
		if (sum >= H) {
			cout << cnt << endl;
			return 0;
		}
		else {
			sum += A;
			cnt++;
		}
	}


	return 0;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int k , l , r;

int main()
{
    _FastIO;
    cin >> k >> l >> r;
    bool flag = false;
    for(int i = l; i <= r; i++){
        if(i % k == 0){
            flag = true;
            break;
        }
    }
    if(flag)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}

// ***<ここから>****************************************************************



int main(void) {

	int N, K;
	cin >> N >> K;
	vi x(N);
	cin >> x;

	int r, l;
	r = 0, l = r + K - 1;

	ll ans = LLONG_MAX;
	while (l < N) {
		ans = min(ans, (ll)abs(x[l]) + x[l] - x[r]);
		ans = min(ans, (ll)abs(x[r]) + x[l] - x[r]);
		r++, l++;
	}
	cout << ans << endl;

	return 0;
}


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

namespace AGC009
{
    class A
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = new int[N];
            int[] B = new int[N];
            for (int i = 0; i < N; i++)
            {
                int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                A[i] = input[0];
                B[i] = input[1];
            }

            long plus = 0;
            for (int i = N - 1; i >= 0; i--)
            {
                long x = (A[i] + plus) % B[i];
                if (x != 0) { plus += B[i] - x; }
            }
            Console.WriteLine(plus);
        }
    }
}


Measured memory_bytes: 18012
// Never let them see you bleed...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn = 1e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;

ll sm[maxn], ans[maxn];
int p[maxn], pans[maxn];
bool mark[maxn];

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

    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
	cin >> sm[i];
    }
    for(int i = n; i >= 1; i--){
	sm[i]-= sm[i-1];
    }
    int m;
    ll q;
    cin >> m >> q;
    iota(p, p+n+1, 0);
    for(int i = 0; i < m; i++){
	int pos;
	cin >> pos;
	swap(p[pos], p[pos+1]);
    }
    for(int i = 1; i <= n; i++){
	if(mark[i] == 0){
	    vector<int> vec;
	    int tmp = i;
	    while(!mark[tmp]){
		vec.PB(tmp);
		mark[tmp] = 1;
		tmp = p[tmp];
	    }
	    for(int j = 0; j < sz(vec); j++){
		pans[vec[j]] = vec[(j + q) % sz(vec)];
	    }
	}
    }
    for(int i = 1; i <= n; i++){
	ans[i] = sm[pans[i]];
	ans[i]+= ans[i-1];
	cout << ans[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 3824
#include <stdio.h>
int main()
{
	int n,i,k,j=1;
	scanf("%d%d",&n,&k);
	int A[n];
	int B[n+1];
	for(i=0;i<n;i++) A[i]=0;
	for(i=0;i<n;i++) j*=2;
	B[0]=j;
	for(i=0;i<n;i++)
	{
		j=1;
		int temp;
		A[i]=1;
		for(temp=0;temp<n;temp++)
		{			
			switch(A[temp])
			{
				case 1:j*=2;break;
				case 0:j+=k;break;
			}
		}
		B[i+1]=j;
	}
	int a=B[0],b=B[1],c;
	if(a>b) c=b;
	else c=a;
	for(i=2;i<n+1;i++) 
	{
		a=B[i];
		if(c>a) c=a; 
	}
	printf("%d",c);
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, a, b) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << '\n';

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> pq;
  LL sum = 0;
  FI(i,1,n) {
    int x;
    scanf("%d", &x);
    sum += x;
    pq.push(x);
  }
  while (m--) {
    int x = pq.top();
    pq.pop();
    int y = x >> 1;
    sum += y - x;
    pq.push(y);
  }
  cout << sum << endl;
}


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

main(){
  int n,k;
  cin>>n>>k;
  int a[n+1];
  for(int i=1;i<=n;i++)
    cin>>a[i];
  int dp[n+1];
  //dp[0]=0;
  dp[1]=0;
 // dp[2]=a[2]-dp[1];
  for(int i=2;i<=n;i++){
    dp[i]=INT_MAX;
    for(int j=i-1;j>=1&&i-j<=k;j--){
     //if(i-j>=0){
       int subp=abs(a[i]-a[j])+dp[j];
       dp[i]=min(dp[i],subp);
     //}
  }
  }
  cout<<dp[n];
}


Measured memory_bytes: 4280
#include <iostream>
 using namespace std;
 int main(){
 char b;
   cin>>b;
   switch(b)
   {
     case 'A':cout<<'T';break;
     case 'T':cout<<'A';break;
     case 'G':cout<<'C';break;
     case 'C':cout<<'G';break;
   }
 }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>  
#include <cstdlib>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

int main() {
    int N;
    cin >> N;
    int ans = 0;
    if (N >= 9) {
        ans+=9;
        if(N >= 999) {
            ans+=900;
            if (N >= 99999)
            ans+=90000;
            else {
                ans+=max(0,N-9999);
                
            }
        } else {
            ans+=max(0,N-99);
            
        }
    } else {
        ans+=N;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  cout << max(max(a + a - 1, a + b), b + b - 1) << 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; }
int main(){
    ll n,k,c; cin>>n>>k>>c;
    string s; cin>>s;
    if(c==0){
        vector<ll> res;
        ll cnt=0;
        rep(i,n){
            if(s[i]=='o'){
                res.push_back(i+1);
                cnt++;
            }
        }
        if(cnt==k){
            for(ll X:res) cout<<X<<endl;
        }
        return 0;
    }

    
    vector<ll> res1, res2;
    ll tmp=0;
    while(true){
        if(tmp>=n) break;
        else if(s[tmp]=='x') tmp++;
        else{
            res1.push_back(tmp);
            tmp+=c+1;
        }
    }
    tmp=n-1;
    while(true){
        if(tmp<0) break;
        else if(s[tmp]=='x') tmp--;
        else{
            res2.push_back(tmp);
            tmp-=c+1;
        }
    }
    map<ll,ll> m;
    for(ll x:res2) m[x]++;
    for(ll x:res1){
        if(m[x]>0) cout<<x+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int main() {
	string str[3] = {"Sunny", "Cloudy" , "Rainy"};
	map<string ,int> mm;
	REP(i, 3) mm[str[i]] = i;
	
	string S;
	cin >> S;
	
	cout << str[(mm[S] + 1) % 3] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main()
{
	cin>>n>>s;
  	n=0;
  	for(auto a:s)n+=a=='R'?1:-1;
  	cout<<(n>0?"Yes":"No")<<endl;
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(1e5)+5
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << fim
#define max3(x, y, z) max(x, max(y, z))
#define ull unsigned long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll mod = 1e9+7;
ll expo(ll a, ll b){
    if(b == 0) 
		return 1;
    ll x = expo(a, b/2);
    return (b & 1 ? ((x*x)%mod*a)%mod : (x*x) % mod);
}

int main() {
	double n;
	cin >> n;
	double p = 0;
	for(int i = 1; i <= n; i++)
		if(i%2) p++;
	cout << fixed << setprecision(10) << p/n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

int main(){

    string a, b;
    cin >> a;
    cin >> b;

    if(a.size() < b.size()){
        cout << "LESS" << endl;
    }
    else if(a.size() > b.size()){
        cout << "GREATER" << endl;
    }
    else if(a < b){
        cout << "LESS" << endl;
    }
    else if(a > b){
        cout << "GREATER" << endl;
    }
    else{
        cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 768
#include<stdio.h>

int main()
{
int h,w,i,t;
while(1){
scanf("%d %d",&h,&w);
if(h==0&&w==0)break;
for(i=0;i<h;i++){
for(t=0;t<w;t++){
printf("#");
}
printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 572
n,wmax=map(int,input().split())
v=[0]*n
w=[0]*n
for i in range(n):
    w[i],v[i]=list(map(int,input().split()))
sv=sum(v)+1
dp=[[float('inf')]*sv for _ in range(n)]
dp[0][v[0]-1]=w[0]
for i in range(n):
    dp[i][0]=0
for i in range(n):
    for j in range(sv):
        dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i])
ans=float('inf')
for p in range(sv-1,-1,-1):
    if dp[n-1][p]!=ans and dp[n-1][p]<=wmax:
        ans=p
        break
print(ans)

Measured memory_bytes: 379728
//        VIVEK UPADHYAY
    //        MANIT, BHOPAL(M.P)


//                         JAB-TAK TODEGA NHI,
//                         TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 1e5 + 10 ;
const int MAX = 1e7 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 + 10 ;
ll mod = 1e9 + 7 ;
int main() {
    
    
    string s ;
    cin >> s ;

    if(s[0]!='A') cout<<"WA\n" ;
    else{
        int index = -1,cnt =0 ;
        for(int i=0;i<s.length();i++) if(s[i]=='C') {
            cnt++ ;
            index = i ;
        }
        if(cnt!=1 || index==0 || index==1 || index==s.length()-1) cout<<"WA\n" ;
        else {
            int uper=0 ;
            for(int i=0;i<s.length();i++)
                if(tolower(s[i])!=s[i]) uper++ ;
            if(uper!=2) cout<<"WA\n" ;
            else cout<<"AC\n" ;
        }
    }
    
    return 0 ;
}


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

using namespace std;

int main()
{
	string str;
	
	cin >> str;
	
	if ((int)str.find("9") == -1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	
	return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
const int N = 1e6 + 10 ;
typedef long long ll ;
const int mod = 1e9 + 7 ;
ll qmi(ll a , ll b)
{
  ll res =1 ;
  while(b)
   {
     if(b & 1) res = res * a % mod ;
     a = a * a % mod ;
     b >>= 1 ;
   }
   return res ;
}
ll get(ll n , ll m)
{
   ll res = 1 , ans = 1 ;
   n ++ , m ++ ;
   n += m ;
   for(int i = 1; i <= m ;i ++)
    res = res * i % mod , ans = ans * (n - i + 1) % mod ;
  return ans * qmi(res , mod - 2) % mod - 1 ;
}
int main()
{
  int r1 , r2 , c1 , c2 ;
  cin >> r1 >> c1 >> r2 >> c2 ;
  cout << ((get(r2 , c2) - get(r2 , c1 - 1) + mod - get(r1 - 1 , c2)  + mod + get(r1 - 1 , c1 - 1) % mod + mod ) % mod + mod )% mod << endl ;
  return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define E exit(0);
using namespace std;
int main(){
    int n,t,x,y;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>t>>x>>y;
        if(x+y>t)puts("No"),E
        if((x+y)%2==0&&t%2)puts("No"),E
        if((x+y)%2&&t%2==0)puts("No"),E
    }
    puts("Yes");E
}

Measured memory_bytes: 256