akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define N 200005
#define LL long long
#define pii pair<int,int>
#define mp make_pair

int n,ci;
LL ans;
int a[N],b[N];
priority_queue<pii> q;

int main()
{
	ios_base::sync_with_stdio(0);
	
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<n;i++)
		q.push(mp(b[i],i));
	while(!q.empty())
	{
		ci++;
		if(ci>=1e7) return cout<<"-1\n",0;
		int x=q.top().second;
		q.pop();
		if(b[x]==a[x]) continue;
		int pa,pb;
		if(x) pa=b[x-1];
		else pa=b[n-1];
		if(x!=n-1) pb=b[x+1];
		else pb=b[0];
		if(max(max(pa,pb),a[x])+pa+pb<b[x])
		{
			ans+=(b[x]-max(max(pa,pb),a[x]))/(pa+pb);
			b[x]-=(b[x]-max(max(pa,pb),a[x]))/(pa+pb)*(pa+pb);
		}
		else b[x]-=pa+pb,ans++;
		if(b[x]<a[x]) return cout<<"-1\n",0;
		q.push(mp(b[x],x));
	}
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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 (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

ll calc(ll x, ll y)
{
        return (x - y) * (x - y);
}

int main()
{
        ll N;
        cin >> N;
        vll a(N);
        rep(i, 0, N) cin >> a[i];

        ll ans = inf;
        rep(i, -100, 101) {
                ll sm = 0;
                rep(j, 0, N) {
                        sm += calc(i, a[j]);
                }
                chmin(ans, sm);
        }
        cout << ans << endl;
}

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

template<typename T>
struct edge {
    int src, to;
    T cost;
};

template<typename T>
using Graph = vector<vector<edge<T>>>;

using State = string::const_iterator;

ll number(State &begin) {
    ll ret = 0;
    while ('0' <= *begin and *begin <= '9') {
        ret *= 10;
        ret += *begin - '0';
        ++begin;
    }
    return ret;
}

ll parse(State &begin, map<char,int>& pri, int p);

ll factor(State &begin, map<char,int>& pri) {
    if (*begin == '(') {
        ++begin;
        ll ret = parse(begin, pri, 3);
        assert(*begin == ')');
        ++begin;
        return ret;
    }
    return number(begin);
}

ll parse(State &begin, map<char,int>& pri, int p) {
    if (p == 0) {
        return factor(begin, pri);
    }
    ll ret = parse(begin, pri, p-1);
    while (pri[*begin] == p) {
        char op = *begin; ++begin;
        if (op == '+') {
            ret += parse(begin, pri, p-1);
        }
        if (op == '-') {
            ret -= parse(begin, pri, p-1);
        }
        if (op == '*') {
            ret *= parse(begin, pri, p-1);
        }
    }
    return ret;
}

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

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    string s; cin >> s;

    ll ans = numeric_limits<ll>::min();
    FOR(a, 1, 4) {
        FOR(b, 1, 4) {
            FOR(c, 1, 4) {
                map<char,int> pri;
                pri['+'] = a;
                pri['-'] = b;
                pri['*'] = c;
                State begin = s.begin();
                chmax(ans, parse(begin, pri, 3));
            }
        }
    }
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 3228
N, K, Q=map(int, input().split())
A=[int(input()) for i in range(Q)]
point=[K]*(N+1)

for i in range(Q):
  point[A[i]]+=1
  
for i in range(1, N+1):
  if point[i]>Q:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 55896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int q;
    cin >> q;
    priority_queue<int> pql;
    priority_queue<int, vector<int>, greater<int>> pqr;
    ll mn = 0;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int a, b;
            cin >> a >> b;
            mn += b;
            pql.push(a);
            pqr.push(a);
            if (pql.top() > pqr.top()) {
                int x = pql.top(), y = pqr.top();
                pql.pop(); pqr.pop();
                mn += x - y;
                pql.push(y); pqr.push(x);
            }
        } else {
            cout << pql.top() << " " << mn << endl;
        }
    }
}

Measured memory_bytes: 3828
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<vector>
#include<bitset>
#include<algorithm>
using namespace std;

const int MAXN=110000;
const int INF=0x3f3f3f3f;
typedef long long ll;
typedef unsigned long long ull;
int mymax(int x,int y) {return x>y?x:y;}
int mymin(int x,int y) {return x<y?x:y;}
int myabs(int x) {return x>0?x:-x;}

const ll MOD=1e9+7;
char s[MAXN];
ll a[MAXN],c[MAXN],wen[MAXN];
ll three[MAXN];

int main()
{
    three[0]=1;for(int i=1;i<MAXN;i++) three[i]=(three[i-1]*3)%MOD;

    scanf("%s",s+1);
    int len=strlen(s+1);
    for(int i=1;i<=len;i++)
    {
        a[i]=a[i-1]+(s[i]=='A');
        c[i]=c[i-1]+(s[i]=='C');
        wen[i]=wen[i-1]+(s[i]=='?');
    }

    ll ans=0;
    for(int i=1;i<=len;i++)
        if(s[i]=='B')
        {
            ans+=a[i-1]*(c[len]-c[i])%MOD*three[wen[len]]%MOD;ans%=MOD;//(a,b,c)
            ans+=wen[i-1]*(c[len]-c[i])%MOD*three[wen[len]-1]%MOD;ans%=MOD;//(?,b,c)
            ans+=a[i-1]*(wen[len]-wen[i])%MOD*three[wen[len]-1]%MOD;ans%=MOD;//(a,b,?)
            ans+=wen[i-1]*(wen[len]-wen[i])%MOD*three[wen[len]-2]%MOD;ans%=MOD;//(?,b,?)
        }
        else if(s[i]=='?')
        {
            ans+=a[i-1]*(c[len]-c[i])%MOD*three[wen[len]-1]%MOD;ans%=MOD;//(a,?,c)
            ans+=wen[i-1]*(c[len]-c[i])%MOD*three[wen[len]-2]%MOD;ans%=MOD;//(?,?,c)
            ans+=a[i-1]*(wen[len]-wen[i])%MOD*three[wen[len]-2]%MOD;ans%=MOD;//(a,?,?)
            ans+=wen[i-1]*(wen[len]-wen[i])%MOD*three[wen[len]-3]%MOD;ans%=MOD;//(?,?,?)
        }
    printf("%lld",ans);
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	int w=(n-1)*(n-2)/2;
	if(w<k)printf("-1");
	else{
		int m=(n-1)+(w-k);
		printf("%d\n",m);
		for(int i=2;i<=n;++i)printf("1 %d\n",i);
		if(w!=k){
			for(int i=2;i<=n;++i){
				for(int j=i+1;j<=n;++j){
					printf("%d %d\n",i,j);w--;
					if(w==k)break;
				}
				if(w==k)break;
			}
		}
	}	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

  int n,a[20],v[20],b=0;

  cin >>n;

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

  for(int i=0 ; i < n ; i++){
    if(v[b] < v[i]){
      b=i;
    }else if(v[b] == v[i] && a[b] > a[i]){
      b=i;
    }
    
  }
  
  cout <<a[b]<<" "<<v[b]<<endl;

  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define fi first
#define se second
#define be begin()
#define en end()
#define reverse
const int mod=1000000007;
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
template<typename T> T abs(T a,T b){
  return max(a,b)-min(a,b);
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int s,w;
  cin>>s>>w;
  if(s<=w) cout<<"unsafe\n";
  else cout<<"safe\n";
}


Measured memory_bytes: 3692
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 805;
const int MM = 1000000007;

char D[MX][MX];
int vst[MX][MX];
int H, W, K;

int main()
{
	scanf("%d%d%d", &H, &W, &K);
	for(int i = 1; i <= H; i++) scanf("%s", D[i]+1);
	int a, b;
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			if( D[i][j] == 'S' ) a = i, b = j;
		}
	}
	queue<pii> Q;
	vst[a][b] = 1;
	Q.emplace(a, b);
	while(Q.size()){
		pii p = Q.front(); Q.pop();
		for(int i = 0; i < 4; i++){
			int px = p.first + "1102"[i] - '1', py = p.second + "2011"[i] - '1';
			if( px < 0 || px > H+1 || py < 0 || py > W+1 || D[px][py] == '#' || vst[px][py] ) continue;
			vst[px][py] = vst[p.first][p.second] + 1;
			Q.emplace(px, py);
		}
	}
	int ans = 1e9;
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			if( !vst[i][j] || vst[i][j] > K+1 ) continue;
			ans = min(ans, 1 + (min({H-i, i-1, j-1, W-j}) + K-1) / K);
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3456
#include <cstdio>

using namespace std;

int main()
{
	int n;
	
	while (scanf("%d", &n), n != 0){
		int ice[10] = {0};
		int ice_n;
		for (int i = 0; i < n; i++){
			scanf("%d", &ice_n);
			ice[ice_n]++;
		}
		
		for (int i = 0; i < 10; i++){
			if (ice[i] == 0){
				puts("-");
			}
			else {
				while (ice[i]-- != 0){
					printf("*");
				}
				puts("");
			}
		}
	}
}

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

#define fi first
#define se second

const int N = 200200;
const long long mod = 1e9 + 7;

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;
int m;
int q;
int p[N];
vector < int > v[N], backup;
bool used[N];

bool dfs(int x)
{
        used[x] = true;
        backup.push_back(x);
        for(int y: v[x]){
                if(p[y] == -1){
                        p[y] = x;
                        return true;
                } else if(!used[p[y]] && dfs(p[y])){
                        p[y] = x;
                        return true;
                }
        }
        return false;
}

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> q >> n >> m;
        for(int i = 1; i <= n + m; i++){
                p[i] = -1;
        }
        vector < pair < int, int > > qu;
        for(int i = 1; i <= q; i++){
                int x, y, w;
                cin >> x >> y >> w;
                v[i].push_back(x);
                v[i].push_back(y + n);
                qu.push_back({w, i});

                shuffle(v[i].begin(), v[i].end(), rng);
        }
        sort(qu.begin(), qu.end());
        reverse(qu.begin(), qu.end());
        long long res = 0;
        for(auto g: qu){
                if(dfs(g.se)){
                        res += g.fi;
                        while(!backup.empty()){
                                used[backup.back()] = false;
                                backup.pop_back();
                        }
                }
        }
        cout << res << "\n";
}


Measured memory_bytes: 14580
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        if (c - a - b >= 0 && 4 * a * b < (c - a - b) * (c - a - b)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD=1000000007;
int MAX=100000;
vector<ll> fac(MAX), finv(MAX), inv(MAX);
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main (){ 
    ll N, K;
    cin>>N>>K;
    vector<ll> A(N);
    for(int i=0; i<N; i++){
        cin>>A[i];
    }
  	COMinit();
    sort(A.begin(), A.end());
    ll Sum=0;
    ll rSum=0;
    for(int i=0; i<N-K+1; i++){
        rSum += A[i]*COM(N-i-1, K-1);
        rSum%=MOD;
    }
    for(int i=K-1; i<N; i++){
        Sum += A[i]*COM(i, K-1);
        Sum%=MOD;
    }
    Sum+=MOD-rSum;
    Sum%=MOD;
    cout<<Sum;
  	//cout<<Comb(4, 2);
}




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

using namespace std;
using ll = long long;

int main()
{
   int n;
   cin>>n;
   double a, t, h;
   cin>>t>>a;
   int flag=0;
   double min_diff = DBL_MAX, diff;
   for (int i = 0; i < n; i++)
   {
       cin>>h;
       diff = a - t + 0.006 * h;
       if (abs(diff)<min_diff)
       {
           min_diff = abs(diff);
           flag = i;
       }
       
   }
   cout<<flag+1;
   
   return 0;
}


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

public class Main {

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

        AObj[] a = new AObj[n];
        for (int i = 0; i < n; i++) {
            a[i] = new AObj(i, Integer.parseInt(scan.next()));
        }
        scan.close();

        Arrays.sort(a, (x, y) -> y.value_ - x.value_);

        long[][] dp = new long[n + 1][n + 1];
        dp[0][0] = 0;

        for (int i = 0; i < n; i++) {
            for (int x = 0; x <= i; x++) {
                int y = i - x;
                dp[x + 1][y] = Math.max(dp[x + 1][y], dp[x][y] + Math.abs(x - a[i].index_) * (long)a[i].value_);
                dp[x][y + 1] = Math.max(dp[x][y + 1], dp[x][y] + Math.abs(a.length - 1 - y - a[i].index_) * (long)a[i].value_);
            }
        }

        long sum = 0;
        for (int i = 0; i < n; i++) {
            if (sum < dp[i][n - i]) {
                sum = dp[i][n - i];
            }
        }
        System.out.println(sum);
    }

}

class AObj {
    int index_;
    int value_;

    public AObj(int index, int value) {
        index_ = index;
        value_ = value;
    }
}

Measured memory_bytes: 85492
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pl pair<ll, ll>
#define vl vector<ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);


int main()
{
    ll n;cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    map<ll,ll>m;ll cnt=0;
    for(ll i=0;i<n;i++)
    {
        if(m[a[i]]==0)
        {
            cnt+=1;m[a[i]]+=1;
        }
        else if(m[a[i]]>0)
        {
            cnt-=1;m[a[i]]-=1;
        }
    }
    cout<<cnt<<"\n";
}


Measured memory_bytes: 10516
import java.util.Scanner;

public class Main { //YES! (Pay attention to indexing variables when debugging)
	//You tend to get them mixed up; Don't doubt your algorithmic thinking cuz you're a beast!

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int M = input.nextInt();
		int X = input.nextInt();
		long[][] data = new long[N][M+1]; //Extra slot for cost
		for (int i = 0; i < N; i++) {
			data[i][0] = input.nextInt();
			for (int j = 1; j <= M; j++) {
				data[i][j] = input.nextInt();
			}
		}
		long cost = Integer.MAX_VALUE;
		String[] possibilities = Recur(N).split(" ");
		for (int i = 0; i < possibilities.length; i++) {
			String x = possibilities[i];
			long[] cmp = new long[M];
			long curcost = 0;
			for (int j = 0; j < N; j++) {
				if (x.charAt(j)=='Y') {
					curcost+=data[j][0];
					for (int k = 1; k<=M; k++) {
						cmp[k-1]+=data[j][k];
					}
				}
			}
			boolean exceeded = true;
			for (int j = 0; j < M; j++) {
				if (cmp[j]<X) {
					exceeded=false;
					break;
				}
			}
			if (exceeded) cost = Math.min(cost, curcost);
		}
		if (cost!=Integer.MAX_VALUE) System.out.println(cost);
		else System.out.println(-1);
	}
	public static String Recur(int N) {
		if (N==1) return "Y N ";
		String[] arr = Recur(N-1).trim().split(" ");
		String ans = "";
		for (int i = 0; i < arr.length; i++) {
			ans+=arr[i]+"Y ";
		}
		for (int i = 0; i < arr.length; i++) {
			ans+=arr[i]+"N ";
		}
		return ans.trim();
	}
}


Measured memory_bytes: 45276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int h = scan.nextInt();
		int n = scan.nextInt();
		int ow = 0;
		int oh = 0;
		for (int i = 0; i < n; i++) {
			int x = scan.nextInt();
			int y = scan.nextInt();
			int a = scan.nextInt();
			if (a == 1 && x > ow) {
				ow = x;
			} else if (a == 2 && x < w) {
				w = x;
			} else if (a == 3 && y > oh) {
				oh = y;
			} else if (a == 4 && y < h) {
				h = y;
			}
			if (oh > h || ow > w) {
				System.out.println(0);
				return;
			}
		}
		System.out.println((oh - h) * (ow - w));

	}
}

Measured memory_bytes: 24020
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

MOD = 1000000007  # type: int

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    conn = [[] for _ in range(N)]
    for i in range(N - 1):
        conn[a[i] - 1].append(b[i] - 1)
        conn[b[i] - 1].append(a[i] - 1)

    def dfs(idx, cur, tmp, visited, ret):
        visited[idx] = True
        #print(idx, cur, tmp)

        #tmp[idx] = max(K - cur, 0)
        ret *= max(K - cur, 0)
        ret %= MOD

        cur = min(cur + 1, 2)
        for nex in conn[idx]:
            if not visited[nex]:
                ret = dfs(nex, cur, tmp, visited, ret)
                cur += 1
        return ret

    tmp = [0] * N
    visited = [False] * N
    ret = 1
    ret = dfs(0, 0, tmp, visited, ret)
    #print(tmp)

    #for t in tmp:
    #    ret *= t
    #    ret %= MOD

    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 114300
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//各種nil
template <class T>
constexpr T nil = static_cast<T>(-1);

constexpr int nil_i = nil<int>;
constexpr int nil_ll = nil<ll>;
constexpr double nil_d = nil<double>;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
struct Vec2D
{
    T x, y;
};

void solve()
{
    using namespace std;
    int n;
    cin >> n;
    vec<int> v(n);

    for (auto& x : v) cin >> x;

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

    cout << v[n - 1] - v[0] << endl;

}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int ans=1e9;
    for(char i='a'; i<='z'; ++i){
        if(s.find(i)==s.npos)continue;
        int cnt=0,mx=0;
        rep(j,n){
            if(s[j]==i)cnt=0;
            else mx=max(mx,++cnt);
        }
        ans=min(ans,mx);
    }
    cout<<ans<<endl;
}


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

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(a>b)swap(a,b);
    if(b>c)swap(b,c);
    if(a>b)swap(a,b);
    if(c%2==0)cout << 0 << endl;
    else cout << a*b << endl;
    return 0;
}


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

public class Main {

	/**
	 * @param args
	 */
	static Food[] f,ans;
	static int n;
	static double min;
	static Stack<Food> stack;
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		while(true){
			n=cin.nextInt();
			if(n==0)break;
			f=new Food[n];
			ans=new Food[n];
			min=1<<30;
			stack=new Stack<Food>();
			for(int i=0;i<n;i++){
				f[i]=new Food(cin.next(),cin.nextInt(),cin.nextInt());
			}
//			Arrays.sort(f);
			dfs(0,0);
			for(int i=0;i<n;i++){
				System.out.println(ans[i].name);
			}
		}
		
	}
	static void dfs(int sum,int depth){
//		System.out.println(sum+" "+depth);
		if(depth==n){
			int ue=0,sita=0;
			int cnt=n;
			for(Food food:stack){
				ue+=food.w*cnt;
				sita+=food.w;
				cnt--;
			}
			if(min>(double)ue/(double)sita){
				min=(double)ue/(double)sita;
				cnt=n-1;
				for(Food food:stack){
					ans[cnt--]=food;
				}
			}
			return;
		}
		for(int i=0;i<f.length;i++){
			if(f[i].f)continue;
			if(sum<=f[i].s){
				f[i].f=true;
				stack.add(f[i]);
				dfs(sum+f[i].w,depth+1);
				stack.pop();
				f[i].f=false;
			}
		}
	}
	static class Food implements Comparable<Food>{
		String name;
		int w,s;
		boolean f;
		Food(String s,int a,int b){
			name=s;
			w=a;
			this.s=b;
			f=false;
		}
		@Override
		public int compareTo(Food o) {
			
			return this.s-o.s;
		}
	}
}

Measured memory_bytes: 43020
n = input()
a = raw_input()
a = [int(i) for i in a.split()]
min_cost = 1000000000
for i in range(min(a),max(a)+1):
    cost = 0
    for j in a:
        cost += (i-j)**2

    if(cost<min_cost):
        min_cost = cost

print min_cost

Measured memory_bytes: 2568
import java.util.Scanner;

public class Main
{

  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);

    while (sc.hasNextLine())
    {
      String[] input = sc.nextLine().split(" ");
      System.out.println(Integer.valueOf(input[0]) + Integer.valueOf(input[1]));
    }

    sc.close();
  }

}



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

using namespace std;

const int INF = 2 * 1e9;
const int MAX_N = 100;
const int MAX_V = 100;
int n, W, v[MAX_N], w[MAX_N], dp[MAX_N + 1][MAX_N * MAX_V + 1];

int main(void) {
    cin >> n >> W;
    for (int i = 0; i < n; i++)
        cin >> v[i] >> w[i];

    fill(dp[0], dp[0] + MAX_N * MAX_V + 1, INF);
    dp[0][0] = 0;
    
    for (int i = 0; i < n; i++)
        for (int j = 0; j <= MAX_N * MAX_V; j++) {
            if (j < v[i]) dp[i + 1][j] = dp[i][j];
            else dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
        }
    
    int res;
    for (int i = 0; i <= MAX_N * MAX_V; i++)
        if (dp[n][i] <= W) res = i;
    
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 7044
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.nextLine());
        String b = sc.nextLine();
        int max = 0;
        for(int i = 0;i <a;i++){
            String head = b.substring(0,i);
            String tail = b.substring(i);
            int count = 0;
            for(int j = 'a';j<='z';j++){
                if(head.indexOf(j)!= -1 && tail.indexOf(j) != -1){
                    count++;
                }
            }
            max = Math.max(count,max);
        }
    System.out.println(max);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const double INF = 1e12;

class Node{
public:
	int p, t; double c;
	Node(int p, int t, double c) : p(p), t(t), c(c) {}
	bool operator < (const Node &n) const { return c > n.c; }
};

int main(){
	int n, m, p, a, b;
	double dist[30][1<<8];
	double numh[8];
	int Gq[30][30];
	int Gc[30][30];
	while(cin >> n >> m >> p >> a >> b){
		if(!n) break;
		a--, b--;
		for(int i=0;i<n;i++) cin >> numh[i];
		vector< vector< pair<int,double> > > G(m);
		int x, y, z;
		int size[30] = {};
		for(int i=0;i<p;i++){
			cin >> x >> y >> z;
			x--, y--;
			Gq[x][size[x]] = y; Gc[x][size[x]++] = z;
			Gq[y][size[y]] = x; Gc[y][size[y]++] = z;
		}
		int S = 1<<n;
		for(int i=0;i<m;i++)
			for(int j=0;j<S;j++) dist[i][j] = INF;
		priority_queue<Node> qu;
		qu.push(Node(a,S-1,0));
		while(!qu.empty()){
			Node nd = qu.top(); qu.pop();
			int pos = nd.p, ticket = nd.t;
			double cost = nd.c;
			if(dist[pos][ticket]!=INF) continue;
			dist[pos][ticket] = cost;
			if(ticket==0) continue;
			if(pos == b) break;
			for(int i=0;i<size[pos];i++){
				int q = Gq[pos][i], r = Gc[pos][i];
				for(int j=0;j<n;j++){
					if(ticket&(1<<j)){
						if(dist[q][ticket-(1<<j)]>cost+r/numh[j])
							qu.push(Node(q,ticket-(1<<j),cost+r/numh[j]));
					}
				}
			}
		}
		double ans = INF;
		for(int i=0;i<S;i++) ans = min(ans, dist[b][i]);
		if(ans != INF) printf("%.3f\n", ans);
		else cout << "Impossible" << endl;
	}
}

Measured memory_bytes: 9332
from functools import reduce

mod = 924844033
frac = [1]*5555
for i in range(2,5555):
    frac[i] = i * frac[i-1]%mod
fraci = [None]*5555
fraci[-1] = pow(frac[-1], mod -2, mod)
for i in range(-2, -5555, -1):
    fraci[i] = fraci[i+1] * (5555 + i + 1) % mod

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

dp = [[[0]*3 for _ in range(N)] for _ in range(-(-N//(2*K)) + 1)]

def merge(A, B):
    C = [0]*(len(A) + len(B) - 1)
    for i in range(len(A)):
        for j in range(len(B)):
            C[i+j] = (C[i+j] + A[i]*B[j]) % mod
    return C

for j in range(min(N, 2*K)):
    dp[0][j][2] = 1
    if j + K <= N-1:
        dp[1][j][0] = 1
    if j - K >= 0:
        dp[1][j][1] = 1

for i in range(-(-N//(2*K)) + 1):
    for j in range(N):
        if j + 2*K > N - 1:
            break
        r = dp[i][j][0]
        l = dp[i][j][1]
        n = dp[i][j][2]
        if i == -(-N//(2*K)):
            dp[i][j+2*K][2] = (dp[i][j+2*K][2] + r + l + n) % mod
            continue
        if j + 3*K <= N - 1:
            dp[i+1][j+2*K][0] = (dp[i+1][j+2*K][0] + r + l + n) % mod
        dp[i][j+2*K][2] = (dp[i][j+2*K][2] + r + l + n) % mod
        dp[i+1][j+2*K][1] = (dp[i+1][j+2*K][1] + l + n) % mod
Ans = []
for j in range(min(2*K, N)):
    j = - 1 - j
    Ans.append([sum(dp[i][j]) for i in range(-(-N//(2*K)) + 1)])

A = reduce(merge, Ans)
A = [((-1)**i * frac[N - i] * a)%mod for i, a in enumerate(A)]
print(sum(A)%mod)


Measured memory_bytes: 215668
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N,M,a,b;cin>>N>>M;
  vector<int> ans(N,0);
  REP(m,0,M){
    cin>>a>>b;
    a--;b--;
    ans[a]++;ans[b]++;
  }
  each(e,ans){
    print(e);
  }

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int i;
  	string s;
  	cin >> s;
  	for(i=0;i<s.size();i++){
    	if(s[i]==','){
        	cout << ' ';
        }
      	else{
        	cout << s[i];
        }
    }
  	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define M 100005
#define N 1005
#define ll long long
#define oo 1000000000
#define mod 5557
using namespace std;
int n,m,res[M];
vector<int >vec[M];
void dfs(int now,int f){  
	for(int i=0;i<vec[now].size();i++){
		int y=vec[now][i];
		if(y==f)continue;
		dfs(y,now);
		res[now]=res[now]^(1+res[y]);
	}
}  
int main(){
	int i,j,a,b;
	cin>>n;
	for(i=1;i<n;i++){
		scanf("%d %d",&a,&b);
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	dfs(1,0);
	if(res[1])puts("Alice");
	else puts("Bob");
	return 0;
}

Measured memory_bytes: 13952
<?php
fscanf(STDIN, '%d %d %d', $n, $k, $q);
for ($i=0; $i<$q; $i++) {
  fscanf(STDIN, '%d', $answerer_s[$i]);
}

for ($j=0; $j<$n; $j++) {
  $def_score_s[] = $k;
}

$diff = $k - $q;
if ($diff > 0) {
  for ($j=0; $j<$n; $j++) {
    echo 'Yes';
    if ($j != $n-1) {
      echo "\n";
    }
  }
  exit;
}

$counted_answerer_s = array_count_values($answerer_s);

foreach ($counted_answerer_s as $answerer => $count) {
  if ($count > abs($diff)) {
    $pass[$answerer] = 1;
  }
}

for ($j=1; $j<=$n; $j++) {
  if ($pass[$j] == 1) {
    echo 'Yes';
    
  } else {
    echo 'No';
  }
  if ($j != $n) {
    echo "\n";
  }
}

Measured memory_bytes: 18928
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    int N;
    read(N);

    vector<int> a(N);
    rep(i, N) read(a[i]);

    print(all_of(all(a), [](int n){ return (n % 2 == 0); }) ? "second" : "first");

    return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
double ret;
double a, x;

int main() {
	scanf("%d %lf %lf", &N, &a, &x);

	while (true) {
		ret += (a + a + x * (N * 2 - 1)) / 2;
		double na = ((N * 2 + 2) * a + 5 * x) / (N * 2);
		double nx = (N * 2 + 4) * x / (N * 2);

		a = na; x = nx;
		if (--N == 0) break;
	}

	printf("%.10f\n", ret);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
    int a, b;
    cin >> a >> b;
    string ans;

    if (a == 1 || b == 1) {
        if (a == 1 && b == 1) {
            ans = "Draw";
        }
        else if (a == 1) {
            ans = "Alice";
        }
        else {
            ans = "Bob";
        }
    }
    else {
        if (a < b) {
            ans = "Bob";
        }
        else if (a > b) {
            ans = "Alice";
        }
        else {
            ans = "Draw";
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
        using namespace std;
        #define pi 3.14159
         
        int main(){
          int N,M;
          cin >> N>>M;
          int ans =0;
          for(int i=0 ;i<M;i++){
         int a;
            cin >> a;
            ans += a;
          }
          ans = (ans-N)*(-1);
         
          if(ans>=0){
          
          cout << ans<<endl;
          }else{
            cout << -1<<endl;
          }
          return 0;  
        }  

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

int main(){
  string s;
  cin >> s;
  int l=s.size();
  int ans=0;
  for(int i=0;i<l/2;i++){
    if(s.at(i)!=s.at(l-1-i)){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
    int a,i,j,k=0,m=0;
    char s[101],t[101],tmp;

    scanf("%s %s",s,t);

    a=strlen(s);

    for(i=0;i<a;i++){
        for(j=0;j<a;j++){
            if((j+k<a&&s[j+k]==t[j])||(j+k>=a&&s[j+k-a]==t[j])){
                m++;
            }
        }
        if(m==a){
            printf("Yes\n");

            return 0;
        }
        m=0;
        k++;
    }

    printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
 
using namespace std;
 
int main(){
	
	int K;
	int T;
	cin >> K >> T;
	vector<int> aa(T);
 
 
	for(int i=0;i<T;i++){
		cin >> aa[i];
	}
	sort(aa.begin(),aa.end());
	reverse(aa.begin(),aa.end());
 
	int count =0;
	int i=0,j=1;
	while(true){
		if(j==T)
			break;
		if(aa[i]>aa[j]){
			aa[i]-=aa[j];
			j++;
		}else if(aa[i]<=aa[j]){
			aa[j]-=aa[i];
			i=j;
			j++;
		}
	}
	if(aa[i]>0)aa[i]--;
	cout << aa[i] << endl;
 
 
 
 
	return 0;
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve()
{
	ll a,b,k;cin>>a>>b>>k;
	if(a>=k)
	cout<<a-k<<" "<<b<<endl;
	else{
		ll x=max(0LL,b-(k-a));cout<<0<<" "<<x<<endl;
	}
}
int main()
{
//	int t;cin>>t;
//	while(t--)
	solve();
}


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

const int MAXN = 100010;
int n, x;
int a[MAXN*3];
bool vis[MAXN*3];

int main() {
	cin >> n >> x;
	if(x == 1 || x == (n<<1)-1) {
		printf("No\n");
		return 0;
	}
	if(n == 2) {
		printf("Yes\n");
		for(int i = 1; i <= 3; i++) printf("%d\n", i);
		return 0;
	}
	if(x == 2) {
		a[n-2] = x+1;
		a[n-1] = x;
		a[n] = x-1;
		a[n+1] = x+2;
		vis[x+1] = vis[x] = vis[x-1] = vis[x+2] = true;
	}
	else {
		a[n-2] = x-1;
		a[n-1] = x;
		a[n] = x+1;
		a[n+1] = x-2;
		vis[x-1] = vis[x] = vis[x+1] = vis[x-2] = true;
	}
	int cur = 1;
	for(int i = 1; i <= (n<<1)-1; i++) {
		if(a[i]) continue;
		while(vis[cur]) cur++;
		a[i] = cur;
		vis[cur] = true;
	}
	printf("Yes\n");
	for(int i = 1; i <= 2*n-1; i++)
		printf("%d\n", a[i]);
	return 0;
}


Measured memory_bytes: 2432
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    s = list(_ for _ in input())
    left = -1
    right = -1
    for i in range(len(s)-1):
        if(s[i+1]==s[i]):
            left = i+1
            right = i+2
            break
        
    for i in range(len(s)-2):
        if(s[i+2]==s[i]):
            left = i+1
            right = i+3
            break
    print(left,right)
if __name__ == '__main__':
    main()


Measured memory_bytes: 4580
#include<bits/stdc++.h>
using namespace std;
char a[10000];
int main()
{
	cin>>a;
	int k=strlen(a);
	for(int i=0;i<=k;i++)
	{
		if(a[i]=='C')
		{
			for(int j=i+1;j<=k;j++)
			{
				if(a[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				 }
			}
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main() {
  int debt, n;
  debt = 100000;
  cin >> n;

  while(n-- > 0) {
    debt += debt*0.05;
    if(debt%1000 != 0)
      debt += 1000 - debt%1000;
  }

  cout << debt << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  ll a,b,c=0,d=0,e,n,m,ans=0;
  string s,t;
  cin>>n;
  rep(i,1,n+1){
    if(i%3!=0 && i%5!=0) c+=i;
  }
  co(c);
  
  return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

const int MOD = 1e9+7;

int main(void){
        int n, m;
        scanf("%d %d", &n, &m);
        int a[n+1];
        for(int i=0; i<=n; i++) a[i]=1;
        for(int i=0; i<m; i++){
                int tmp;
                scanf("%d", &tmp);
                a[tmp] = 0;
        }

        long dp[n+1];
        for(int i=0; i<=n; i++) dp[i] = (i==0);
        for(int i=0; i<=n; i++){
                if(i>0) dp[i] = (dp[i] + dp[i-1]) * a[i] % MOD;
                if(i>1) dp[i] = (dp[i] + dp[i-2]) * a[i] % MOD;
        }

        printf("%ld ", dp[n]);
        return 0;
}

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

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;

    vector<int> cnt;
    int c = 0;
    char now = 'L';
    for (int i = 0; i < N; i++) {
        if (S[i] == now) {
            c++;
        } else {
            cnt.push_back(c);
            c = 1;
        }
        now = S[i];
    }
    if (c) cnt.push_back(c);

    int left = 0, right = 0, sum = 0, maxLen = 0;
    int maxStart = 0, maxEnd = 0;
    int addCnt = 2 * K + 1;
    for (int i = 0; i < cnt.size(); i++) {
        int nextLeft = i;
        int nextRight = min(i + addCnt, (int)cnt.size());

        while (left < nextLeft) {
            sum -= cnt[left++];
        }
        while (right < nextRight) {
            sum += cnt[right++];
        }

        if (sum > maxLen) {
            maxLen = sum;
            maxStart = left;
            maxEnd = right - 1;
        }
    }

    int res = maxLen - 1;
    for (int i = 0; i < cnt.size(); i++) {
        if ((i < maxStart || i > maxEnd) && cnt[i]) {
            res += cnt[i] - 1;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1020
//team04 lyt

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
//#include <io.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <sstream>
#include <fstream>

using namespace std;

const long long mod=1000000007ll;
char s[2][100];

int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        scanf("%s%s",s[0],s[1]);
        bool flag=false;
        long long ans;
        if(s[0][0]==s[1][0])
            ans=3ll;
        else
            ans=2ll;
        for(int i=0;i<n;)
        {
            if(s[0][i]==s[1][i])
            {
                if(flag)
                {
                    ans=ans*2%mod;
                }
                flag=true;
                i++;
            }
            else
            {
                if(flag)
                    ans=ans*2%mod;
                else
                    ans=ans*3%mod;
                flag=false;
                i+=2;
            }
        }
        printf("%lld\n",ans);


    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? LLONG_MAX : INT_MAX;
const int MOD = 1000000007;
const long double EPS = 1e-8;

int fun(int b, int n) {
	return b < 2 ? INF
							 : n < b ? n
							 : fun(b, n / b) + n % b;
}

signed main() {
	int n, s;
	cin >> n >> s;
	if (n == s) {
		cout << n + 1 << endl;
		return 0;
	}
	int ans = INF;
	range (b, 2, sqrt(n) + 1) {
		int tmp = fun(b, n);
		if (s == tmp) ans = min(ans, b);
	}
	range (p, 1, sqrt(n)) {
		int b = (n - s) / p + 1;
		if (fun(b, n) == s) ans = min(ans, b);
	}
	cout << (ans == INF ? -1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;



public class Main {

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

		List<String> strlist = new ArrayList<String>();

 		for (int i = 0; i < N; i++) {
			strlist.add(sc.next());
		}
 		Collections.sort(strlist);
 		StringBuilder sb = new StringBuilder();
 		for (String string : strlist) {
 			sb.append(string);
		}

 		System.out.println(sb.toString());

	}

}

Measured memory_bytes: 37288
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

double const pi = 3.1415926535;
int const mod = 1000000007;
int const inf = 2147483647;

int ans;

int main() {

	int a[3]; cin >> a[0] >> a[1] >> a[2];
	bool flag = true; //偶奇ちがうならtrue
	if (a[0] % 2 == a[1] % 2 && a[1] % 2 == a[2] % 2)flag = false; //偶奇おなじならfalse
	if (flag) {
		if (a[0] % 2 == a[1] % 2) {
			a[0]++;
			a[1]++;
			ans++;
			goto HERE;
		}
		if (a[1] % 2 == a[2] % 2) {
			a[1]++;
			a[2]++;
			ans++;
			goto HERE;
		}
		if (a[0] % 2 == a[2] % 2) {
			a[0]++;
			a[2]++;
			ans++;
			goto HERE;
		}
	}
	HERE:
		sort(a, a + 3);
		ans += (2 * a[2] - a[1] - a[0]) / 2;
	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <stack>
#include <array>
#include <fstream>
#include <deque>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPS(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#define REVERSE(i,n) for(int (i) = n-1;(i) >= 0 ; --i)
#define ALL(c) (c).begin() , (c).end()
#define EACH(it,c) for(auto(it,(c).begin());it != (c).end();)
#define cx real()
#define cy imag()
#define px first
#define py second
#define LL long long
#define int LL
#define inf  (1LL << 60)
#define mod 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
#define lower lower_bound
#define upper upper_bound
#define ZERO(c,n) memset(&c[0],0,sizeof(int)*n)
#define ZERO2(c,n) memset(&c[0][0],0,sizeof(int)*n
#define pl(a) cout << ""#a": " << a << endl;
#ifdef _DEBUG
#define debug_io fstream cin("input.txt");ofstream cout("output.txt");
#else
#define debug_io ;
#endif
#define debug_input debug_io
#define pb(a) push_back(a)
template<class T>void scan(vector<T>& a, int n, istream& cin)
{
	T c; REP(i, n) { cin >> c; a.push_back(c); }
}
using vs = vector<string>; using vi = vector<int>; using pii = pair<int, int>;
using psi = pair<string, int>; using vvi = vector<vi>; using pss = pair<string, string>;
template<class T>bool valid(T x, T w) { return 0 <= x&&x < w; }
int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 };
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------


signed main()
{
	QUICK_CIN;
	debug_input;

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

	if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}


	return 0;
}

Measured memory_bytes: 256