akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull B = 100000007;
int mod = 1000000007;

class Solution {
public:
    int ac, tle, wa, re;
    void b(int n) {
        ac = tle = wa = re = 0;
        for(int i = 0; i < n; ++i) {
            string tmp;
            cin >> tmp;
            if(tmp == "AC") {
                ac++;
            } else if(tmp == "WA") {
                wa++;
            } else if(tmp == "TLE") {
                tle++;
            } else if(tmp == "RE") {
                re++;
            }
        }

        cout << "AC x " << ac << endl;
        cout << "WA x " << wa << endl;
        cout << "TLE x " << tle << endl;
        cout << "RE x " << re << endl;

    }
};

int main() {
    int n;
    cin >> n;
    Solution zhy;
    zhy.b(n);

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
bool eq(ld a, ld b) {
	return (abs(a - b) < eps);
}
ld dot(Point a, Point b) {
	return real(conj(a)*b);
}
ld cross(Point a, Point b) {
	return imag(conj(a)*b);
}
class Line {
public:
	Point a, b;
};
class Circle {
public:
	Point p;
	ld r;
};
vector<Point> is_cc(Circle c1, Circle c2) {
	vector<Point> res;
	ld d = abs(c1.p - c2.p);
	ld rc = (d*d + c1.r*c1.r - c2.r*c2.r) / (2 * d);
	ld dfr = c1.r*c1.r - rc * rc;
	if (abs(dfr) < eps)dfr = 0.0;
	if (dfr < 0.0)return res;
	ld rs = sqrt(dfr);
	Point diff = (c2.p - c1.p) / d;
	res.push_back(c1.p + diff * Point(rc, rs));
	if (dfr != 0.0)res.push_back(c1.p + diff * Point(rc, -rs));
	return res;
}
ld dis(Point x, Point y) {
	return sqrt(dot(y - x, y - x));
}
int main() {
	int n;
	while (cin >> n, n) {
		Point a[300];
		rep(i, n) {
			ld x, y; cin >> x >> y; a[i] = { x,y };
		}
		int ma = 1;
		rep(i, n) {
			Rep(j, i + 1, n) {
				Circle s = { a[i],(ld)1.0 };
				Circle t = { a[j],(ld)1.0 };
				vector<Point> v = is_cc(s, t);
				rep(l, (int)v.size()) {
					int cnt = 0;
					rep(k, n) {
						if (dis(a[k], v[l]) <= (ld)1.0 + eps)cnt++;
					}
					ma = max(ma, cnt);
				}
			}
		}
		cout << ma << endl;
	}
	return 0;
}


Measured memory_bytes: 3228
import sys
input = lambda: sys.stdin.readline().rstrip()
from itertools import combinations_with_replacement as cwr , combinations , permutations ,product
from math import sqrt
a=[]
for _ in range(int(input())):
    a.append([int(i) for i in input().split()])
p=list(permutations(a))
ans=[]
for i in p:
    cur=0
    for j in range(len(i)-1):
        cur+=sqrt((i[j+1][0]-i[j][0])**2+(i[j+1][1]-i[j][1])**2)
    ans.append(cur)
print(sum(ans)/len(ans))
    


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

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

    long double r;
    cin>>r;
    long double ans=2*M_PI*r;
    cout<<ans;
    
	return 0;
}

Measured memory_bytes: 3808
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll n;cin>>n;
  vll a(n);
  rep(i,0,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  ll ans,m=-1;
  rep(i,0,n-1){
    if(min(a[i],a[n-1]-a[i])>m){
      m=a[i];
    }
  }
  cout<<a[n-1]<<" "<<m<<endl;
}



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

int main() {
    int n,ans=0; cin>>n;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
  int count=0;
    rep (i,n-1) {
        if(h[i]>=h[i+1]) count++;
        else count=0;
        ans=max(ans,count);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
n,k = map(int,input().split())
p = list(map(float,input().split()))

for i in range(n) :
  p[i] = (p[i]+1)/2

# ans[i] = iを含めてk個前までの期待値の総和
ans = [0 for i in range(n)]
ans[k-1] = sum(p[0:k])
for i in range(k,n) :
  ans[i] = ans[i-1] + p[i] - p[i-k]
  
print(max(ans))

Measured memory_bytes: 77320
#include <stdio.h>
#include<ctype.h>
#include <string.h>

int main(void){
    char w[10], c[1000];
    int wn=0, cn=0, i, count=0;
    
    scanf("%s", w);
    while(w[wn] != '\0') wn++;
    
    while(scanf("%s", c)){
        if(strcmp(c, "END_OF_TEXT") == 0) break;
        
        cn = 0;
        while(c[cn] != '\0') cn++;
        
        for(i=0; i<cn; i++){
            if(c[i]>='A' && c[i]<='Z')
            c[i] = tolower(c[i]);
        }
        if(wn >= cn){
            for(i=0; i<wn; i++){
                if(w[i] != c[i]) break;
                if(i==wn-1){
                    count++;
                }
            }
        }
    }
    
    printf("%d\n", count);
    
    return 0;
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n,t;
	cin>>n>>t;
	vi a(n);
	rep(i,n)cin>>a[i];
	sort(all(a));
	ll ans=1;
	rep(i,n){
	    ans=ans*(i+1-(lower_bound(all(a),a[i]-t)-a.begin()))%MOD;
	}
	cout<<ans<<endl;
	
	return 0;
}



Measured memory_bytes: 3272
#include<iostream>
#include<vector>
#include<cstdlib>

using namespace std;

int main()
{
	int *a;
	int n, cnt;
  	long long int sum, min;
	cnt = 0;
	sum = 0;
	min = 100000;
	
	cin >> n;
	a = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] < 0) {
			cnt++;
		}
		
		if (abs(a[i]) < min) {
			min = abs(a[i]);
		}
	}
	
	if (cnt%2) {
		for (int i = 0; i < n; i++) {
			sum += abs(a[i]);
		}
      	sum = sum - 2*min;
	} else {
		for (int i = 0; i < n; i++) {
			sum += abs(a[i]);
		}
	}
	
	cout << sum;
	

    return 0;
}

Measured memory_bytes: 640
import sys

N, M = map(int, sys.stdin.readline().split())
xy_s = []
for i in range(M):
    x, y = map(int, sys.stdin.readline().split())
    xy_s.append((x-1, y-1))

flags = [False] * N
ns = [1] * N
flags[0] = True

for x, y in xy_s:
    if flags[x]:
        if ns[x] == 1:
            flags[x] = False
        flags[y] = True
    ns[x] -= 1
    ns[y] += 1

res = 0
for f in flags:
    if f:
        res += 1

print res



Measured memory_bytes: 19188
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)
#define int long long

signed main(){
    int N,C,K; cin >> N >> C >> K;
    vector<int> T(N);
    rep(i,N) cin >> T[i];
    sort(all(T));
    int cnt = 0;
    int ans = 0;
    int front = -1;
    for(int i=0;i<N;++i){
        if(front >= T[i] && cnt < C) ++cnt;
        else ++ans,cnt = 1,front = T[i] + K;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define INFTY 1000000000
#define N 500000

void merge(int [],int,int,int);
void mergesort(int [],int,int);

int cnt=0;

int main()
{
  int n,s[N],i;

  scanf("%d",&n);
  for(i=0 ; i<n ; i++)
  {
    scanf("%d",&s[i]);
  }

  mergesort(s,0,n);

  for(i=0 ; i<n-1 ; i++)
  {
    printf("%d ",s[i]);
  }
  printf("%d\n",s[n-1]);
  printf("%d\n",cnt);

  return 0;
}

void merge(int A[],int left,int mid,int right)
{
  int n1,n2,i,j,k;

  n1 = mid - left;
  n2 = right - mid;

  int L[n1],R[n2];

  for(i=0 ; i<n1 ; i++)
  {
    L[i] = A[left + i];
  }

  for(i=0 ; i<n2 ; i++)
  {
    R[i] = A[mid + i];
  }

  L[n1] = INFTY;
  R[n2] = INFTY;

  i=0;
  j=0;

  for(k = left ; k<right ; k++)
  {
    if(L[i] <= R[j])
    {
      A[k] = L[i];
      i = i+1;
      cnt++;
    }
    else
    {
      A[k]=R[j];
      j = j+1;
      cnt++;
    }
  }
}

void mergesort(int A[],int left,int right)
{
  int mid;
  if(left+1 < right)
  {
    mid = (left + right) / 2;
    mergesort(A, left, mid);
    mergesort(A, mid, right);
    merge(A,left,mid,right);
  }
}



Measured memory_bytes: 5688
// マニ

#include<bits/stdc++.h>
#define ll            long long 
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define rrep(i,a,b) for(ll int i=a;i>=b;i--)
#define all(a)      (a).begin(),(a).end()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define PI 3.14159265358979323846
#define tr(i, cont) for(auto i=cont.begin();i!=cont.end();i++)
#define ios            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define trace(x)                 cerr << #x << ": " << x << "\n";
#define trace1(x)                cerr << #x << ": " << x << "\n";
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << "\n";
#define ar array
#define endl "\n"
using namespace std;

int main(){
    ios;
    ll n;
    cin>>n;
    map<string,ll> m;
    rep(i,0,n){
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

signed main() {
  ll k; cin >> k;
  ll s = 0;
  for(ll i = 0; i <= k+1; i++) {
    s += 7 * modpow(10,i,k);
    s %= k;
    if(s < 0) s += k;
    if(s==0) {
      cout << i+1 << endl;
      return 0;
    }
  } 
  cout << -1 << endl;
}


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

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    char S[N];
    rep(i, N) cin >> S[i];
    int passa = 0;
    int passb = 0;

    rep(i, N){
        if (S[i] == 'c'){
            cout << "No" << endl;
        }else if (S[i] == 'a'){
            if (passa + passb < A + B){
                cout << "Yes" << endl;
                passa++;
            }else{
                cout << "No" << endl;
            }
        }else if (S[i] == 'b'){
            if ( (passa + passb < A + B) && (passb < B) ){
                cout << "Yes" << endl;
                passb++;
            }else{
                cout << "No" << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3704
n,m = map(int,input().split())
ab_input = [list(map(int,input().split())) for i in range(n)]
cd_input = [list(map(int,input().split())) for i in range(m)]

for i in range(n):
    a,b = map(int,ab_input[i])
    
    tmp=float('inf')
    for j in range(m):
        c,d = map(int,cd_input[j])
        dist=abs(a-c)+abs(b-d)
        if tmp>dist:
            tmp=dist
            ans=j
    print(ans+1)



Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int w = in.nextInt();
            int[] weights = new int[n];
            int[] values = new int[n];
            for (int i = 0; i < n; i++) {
                weights[i] = in.nextInt();
                values[i] = in.nextInt();
            }
            long[][] dp = new long[n + 1][w + 1];
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= w; j++) {
                    if (i == 0 || j == 0)
                        dp[i][j] = 0;
                    else if (weights[i - 1] <= j) {
                        dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][j - weights[i - 1]] + values[i - 1]);
                    } else
                        dp[i][j] = dp[i - 1][j];
                }
            }
            out.println(dp[n][w]);
        }

    }
}



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

int main(int argc, char const *argv[]) {
	int a, b;
	scanf("%d\n", &a);
	scanf("%d\n", &b);

	int res = a+b;

	if (a+b > a-b) {
		res = a+b;
	} else {
		res = a-b;
	}

	if (a*b > res) {
		res = a*b;
	}

	printf("%d\n", res);

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
  double r;
  cin >> r;
  double area = M_PI * r * r;
  double circumference = M_PI * r * 2.0;
  cout << fixed << setprecision(6)
       << area << ' ' << circumference << endl;
  return 0;
}



Measured memory_bytes: 3212
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int r;
  int ans = 0;
  string s;

  cin >> r;

  cout << 3* r * r << endl;

}


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

int main() {
	int N, K;
	cin >> N >> K;
	cin.ignore();
	string s;
	getline(cin, s);
	if ((N - K) % (K - 1) == 0) {
		cout << (N - K) / (K - 1) + 1 << endl;
	}
	else {
		cout << (N - K) / (K - 1) + 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 1412
def submit():
    h, w = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(h)]

    stroke = []
    direction = 1
    for i in range(w):
        if direction == 1:
            st, ed = 0, h
        else:
            st, ed = h - 1, -1
        for j in range(st, ed, direction):
            stroke.append((j, i))
        st, ed = ed, st
        direction *= -1

    moves = []
    cnt = 0
    for s, e in zip(stroke, stroke[1:]):
        if a[s[0]][s[1]] % 2:
            cnt += 1
            moves.append((s, e))
            a[e[0]][e[1]] += 1
    
    print(cnt)
    for s, e in moves:
        print("{} {} {} {}".format(s[0] + 1, s[1] + 1, e[0] + 1, e[1] + 1))


submit()

Measured memory_bytes: 38140
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    HashMap<String, Integer> hashMap = new HashMap<>();

    for (int i = 0; i < N; i++) {
      String s = sc.next();
      String[] s_ = s.split("");
      Arrays.sort(s_);
      String ss_ = "";
      for (int j = 0; j < s_.length; j++) {
        ss_ += s_[j];
      }
      if (hashMap.containsKey(ss_)) {
        int v_ = hashMap.get(ss_);
        hashMap.put(ss_, v_ + 1);
      } else {
        hashMap.put(ss_, 1);
      }
    }

    sc.close();

    long count = 0;

    for (Integer value : hashMap.values()) {
      if (1 < value) {
        for (int i = 2; i <= value; i++) {
          count += i - 1;
        }
      }
    }

    System.out.println(count);

  }

}

Measured memory_bytes: 107768
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#define ll long long
#define db double
#define rint register int
#define re register
#define eps 1e-10
#define mk make_pair
#define fs first
#define pint pair<int,int>
#define sd second
#define inf 1ll<<58
#define N 3005
using namespace std;
inline char get(){const int TOP=1<<20;static char T[TOP],*x=T,*y=T;return x==y&&(y=(x=T)+fread(T,1,TOP,stdin),x==y)?EOF:*x++;}
inline int read (){register int num,sign=1;register char c;
while (((c=get())<'0'||c>'9')&&c!='-');c=='-'?num=sign=0:num=c-48;while ((c=get())>='0'&&c<='9')num=(num<<3)+(num<<1)+(c-48);return sign?num:-num;}
int n,mod,tmp,ans;
int s[N][N],c[N][N];
inline int power(rint x,rint k,rint mod){rint ans=1;while(k){if(k&1)ans=1ll*ans*x%mod;x=1ll*x*x%mod;k>>=1;}return ans;}
int main(){
	n=read();mod=read();c[0][0]=1;
	for(rint i=1;i<=n;++i){
		c[i][0]=c[i][i]=1;
		for(rint j=1;j<i;++j)c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	for(rint i=0;i<=n;++i){
		s[i][0]=1;
		for(rint j=1;j<=i;++j)s[i][j]=(s[i-1][j-1]+1ll*(j+1)*s[i-1][j]%mod)%mod;
	}
	for(rint i=0;i<=n;++i){
	 	int tmp=((i&1?-c[n][i]:c[n][i])+mod)%mod,res=power(2,power(2,n-i,mod-1),mod),sum=0;
		for(rint j=0,x=power(2,n-i,mod),now=1;j<=i;++j,now=1ll*now*x%mod){sum=(sum+1ll*s[i][j]*now%mod)%mod;}
		ans=(ans+1ll*sum*res%mod*tmp%mod)%mod;
	}printf("%d\n",ans);
}


Measured memory_bytes: 69376
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9+5

int main()
{
        int n,k;    cin>>n>>k;
        vector<int> a(n);   for(auto &i:a)  cin>>i;
        vector<int> dp(n,inf);  dp[0]=0;

        for(int i=0 ; i<n ; i++)
        {
            for(int j=i ; j>= max(i-k , 0); j--)
                dp[i] = min(abs(a[i]-a[j])+dp[j] , dp[i]);
        }
        //for(auto i:dp)     cout<<i<<" ";   cout<<endl;
        cout<<dp[n-1];
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define f first
#define s second
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s,h="";
	cin>>s;
	h+= s[0];
	bool flag =0;
	for(int i = 1;i<s.length() ; i++)
	{
		if(s[i]==s[i-1])
		{
			cout<<i<<" "<<i+1<<endl;
			flag =1;
			break;
		}
		else
		{
			h+= s[i];
			string f="";
			if(i>1)
				f = s.substr(i-2,3);//+= s[i-2]+s[i-1]+s[i];
			else
				f = h;
			sort(h.begin(),h.end());
			for(int j =0; j<2; j++)
			{
				if(h[j]==h[j+1])
				{
					cout<<i-1<<" "<<i+1<<endl;
					flag = 1;
					break;
				}
			}
			if(f.length()==3)
				h = f.substr(1,2);
			if(flag)
				break;
		}
	}
	if(!flag)
		cout<<-1<<" "<<-1<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;


int main(){
    int N;cin >> N;
    LL a[N][N];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> a[i][j];
        }
    }
    vector<LL> c(1<<N,0);
    for (int k = 0; k < 1<<N; k++) {
        for (int i = 0; i < N; i++) {
            if(k&(1<<i)){
                for (int j = i+1; j < N; j++) {
                    if(k&(1<<j)) c[k]+=a[i][j];
                }
            }
        }
    }
    vector<LL> dp((1<<N)+1,0);
    for (int k = 0; k < 1<<N; k++) {
        int mask=(1<<N)-1;
        int S=k^mask;
        for (int T=S; ; T=(T-1)&S) {
            if (T==0) break;
            dp[k|T]=max(dp[k|T],dp[k]+c[T]);
        }
    }
    cout << dp[(1<<N)-1] << endl;
    return 0;
}



Measured memory_bytes: 1408
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		String out;

		out = a * b % 2 == 0 ? "Even" : "Odd";

		System.out.println(out);
	}
}

Measured memory_bytes: 20820
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include<string>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;
typedef vector <int> ivector;

int main(){
	
	for (int i = 1; i <= 9; i++){
		for (int j = 1; j <= 9; j++){
			cout << i << "x" << j <<"="<< i*j << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0031
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            double pN = Math.Sqrt((double)N);

            long result = long.MaxValue;

            for (long i = 1; i <= pN; i++)
            {
                if (N % i == 0)
                {
                    long tmp = 0;
                    var n = N / i;

                    if (n.ToString().Length <= i.ToString().Length)
                    {
                        tmp = i.ToString().Length;
                    }
                    else
                    {
                        tmp = n.ToString().Length;
                    }

                    if (result > tmp)
                    {
                        result = tmp;
                    }
                }
            }

            Console.WriteLine(result);

        }
    }
}


Measured memory_bytes: 27420
def max(a,b); a > b ? a : b;end
  
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
S = Array.new(N + 1, 0.0)
(1 .. N).each do |i|
  a = A[i - 1]
  e = (a * (a + 1) / 2).to_f / a
  S[i] = S[i - 1] + e
end
ans = (K .. N).inject(0.0) do |m, i|
  max(m, S[i] - S[i - K])
end
puts ans


Measured memory_bytes: 16524
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    string s;
    cin >> s;
    int cnt = 0, res = s.size();
    per(i, s.size()){
      if(s[i] == 'T'){
        ++cnt;
      }else{
        if(cnt > 0){
          --cnt;
          res -= 2;
        }
      }
    }

    pri(res);
/*/

//*/ break;
  }
  return 0;
}


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

const int N=5e5+10;
char s[N];
set<int>v[26];
int main()
{
    //ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int n;
    int q;
    scanf("%d%s",&n,s+1);
    //cin>>n>>s+1;
    for(int i=1;i<=n;i++){
        v[s[i]-'a'].insert(i);
    }
    scanf("%d",&q);
    //cin>>q;
    while(q--){
        int op;
        scanf("%d",&op);
        //cin>>op;
        if(op==1){
             int x;
             char c;
             scanf("%d %c",&x,&c);
             //cin>>x>>c;
             if(c==s[x])continue;
             v[s[x]-'a'].erase(x);
             v[c-'a'].insert(x);
             s[x]=c;
        }
        else{
            int l,r;
            scanf("%d%d",&l,&r);
            //cin>>l>>r;
            int ans=0;
            for(int i=0;i<26;i++){
                set<int>::iterator p=v[i].lower_bound(l);
                if(p!=v[i].end()&&*p<=r)ans++;
            }
            cout<<ans<<"\n";
        }
    }
    return 0;
}


Measured memory_bytes: 24192
#                         author:  kagemeka 
#                         created: 2019-11-07 23:33:56(JST)
## internal modules
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    a, b = (int(x) for x in sys.stdin.readline().split())
    ans = max(a + b, a - b, a * b)
    print(ans)
    


if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n, v[100], x;

    cin >> n >> x;

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

    int total = 0;
    int i = 0;
    while (total <= x) {
        total += v[i];
        i++;
    }

    cout << i << endl;

    


    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
listA = list(map(int,input().split()))
sumA = sum(listA)
tfList = []
listA.sort(reverse=True)
for i in range(m):
    if listA[i] >= sumA / (4*m):
        tfList.append('t')
    else:
        tfList.append('f')

if 'f' in tfList:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))
  val (A, B, C, D) = br.use { it.readLine().split(" ").map { it.toInt() } }

  fun isPushed(i: Int, a: Int, b: Int) = (a <= i) && (i < b)

  val ans = BooleanArray(101, { i ->
      isPushed(i, A, B) && isPushed(i, C, D)
    }
  ).fold(0) { acc, bool ->
    if(bool) acc + 1
    else acc
  }

  println(ans)
}

Measured memory_bytes: 35764
#ABC085-C
n,y = map(int,input().split())
flg = False
for i in range(n+1):
    for j in range(n+1):
        k = n - i - j
        if k >= 0:
            if 10000 * i + 5000 * j + 1000 * k == y:
                flg = True
                money = [i,j,k]
                break
if flg:
    print(*money)
else:
    print('-1 -1 -1')

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

using namespace std;

int main() {
  int n;
  cin >> n;
  deque<int> d;  
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    int idx = lower_bound(d.begin(), d.end(), a) - d.begin();
    if (idx == 0) {
      d.push_front(a);
    } else {
      d[idx - 1] = a;
    }
  }
  cout << d.size() << endl;
  return 0;
}



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

int main(){
    int N, M;  cin >> N >> M;
    string S;  cin >> S;
    
    vector<int> ans;
    for(int i=N; i>=0; i--){
        if(i - M <= 0){
            ans.push_back(i);
            i = 0;
        }else{
            for(int j=i-M; j<=i-1; j++){
                if(S[j] == '0'){
                    // cout << i << " -> " << j << endl;
                    ans.push_back(i-j);
                    i = j + 1;
                    break;
                }
                if(j == i-1){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    for(int i=ans.size()-1; i>=0; i--){
        cout << ans[i] << " ";
    }cout << endl;
}


Measured memory_bytes: 1144
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}



void solve(){
    int n,m;
   cin >> n >> m;

   string s;
   cin >> s;
   int ans = 1;
   set<int> v;
   //s = 'R' + s + 'L';
   for(int i = 0;i<n-1;i++){
    if(s[i]!=s[i+1])ans++;
    
   }
   //cout << ans << endl;
   ans = max(ans - 2*m, 1LL);
  cout << n-ans << endl;
   
} 

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

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

class Info {
  public:
    int n;
    bool is_end;
    int children[26];
    Info(int n = 0) {
      this->n = n;
      is_end = false;
      for (int i = 0; i < 26; ++i) {
        children[i] = -1;
      }
    }
};

int main() {
  int n, q, k;
  std::vector<std::vector<std::vector<int>>> nums;
  char sin[400001];
  int nums2[100000] = {};
  std::string s[100000];
  std::string p;
  std::vector<Info> trie;
  trie.push_back(Info());
  std::scanf("%d", &n);
  trie.reserve(410000);
  nums.resize(n, std::vector<std::vector<int>>(26, std::vector<int>(26, 0)));
  for (int ni = 0; ni < n; ++ni) {
    int ptr = 0;
    std::scanf("%s", sin);
    s[ni] = sin;
    for (char c : s[ni]) {
      if (trie[ptr].children[c - 'a'] < 0) {
        trie[ptr].children[c - 'a'] = trie.size();
        trie.push_back(Info());
      }
      ++trie[ptr].n;
      ptr = trie[ptr].children[c - 'a'];
    }
    ++trie[ptr].n;
    trie[ptr].is_end = true;
  }
  for (int ni = 0; ni < n; ++ni) {
    int ptr = 0;
    for (auto c : s[ni]) {
      for (int a = 0; a < 26; ++a) {
        int x = trie[ptr].children[a];
        if (x >= 0 and 'a' + a != c) {
          nums[ni][a][c - 'a'] += trie[x].n;
        }
      }
      if (trie[ptr].is_end) {
        ++nums2[ni];
      }
      ptr = trie[ptr].children[c - 'a'];
    }
  }
  std::scanf("%d", &q);
  for (int qi = 0; qi < q; ++qi) {
    int ans = 1;
    std::scanf("%d%s", &k, sin);
    p = sin;
    for (int a = 0; a < 26; ++a) {
      for (int b = a + 1; b < 26; ++b) {
        ans += nums[k - 1][p[a] - 'a'][p[b] - 'a'];
      }
    }
    ans += nums2[k - 1];
    std::printf("%d\n", ans);
  }
  return 0;
}

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


int main(){
  int d;
  ll g;
  cin>>d>>g;
  vector<ll> p(d),c(d);
  rep(i,d) cin>>p[i]>>c[i];
  
  ll ans = 1005;
  rep(i,1<<d){
    ll res = 0;
    ll score = 0;
    rep(j,d){
      if(i>>j&1){
        score += 100*(j+1)*p[j]+c[j];
        res += p[j];
      }
    }
    if(score>=g){
      ans = min(ans,res);
      continue;
    }else{
      for(int j=d-1;j>=0;j--){
        if(!(i>>j&1)){
          rep(k,p[j]-1){
            score += (ll)100*(j+1);
            res++;
            if(score>=g){
              ans = min(ans,res);
              break;
            }
          }
        }
      }
    }        
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        static void Main(string[] args)
        {
          //入力を受け取る
          var WHxy = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
          double W = WHxy[0];
          double H = WHxy[1];
          double a = WHxy[2];
          double b = WHxy[3];
          
          Console.WriteLine(W*H/2);
          if(W == 2*a && H == 2*b){
            Console.WriteLine(1);
          }else{
            Console.WriteLine(0);
          }
        }
  
}


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

#define mod 998244353


int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll a,b,c; cin>>a>>b>>c;
	cout<<(a+b+c>=22 ? "bust" : "win");
	return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
//constexpr int inf = 3e18;

int D;
int C[26];
int A[365][26];
int con[10][365];
set<int>st[26];
int index_;
int score(){
	vector<int>last(26,-1);
	int res=0;
	rep(i,D){
		last[con[index_][i]]=i;
		res+=A[i][con[index_][i]];
		rep(j,26){
			res-=C[j]*(i-last[j]);
		}
	}
	return res;
}
int change(int x,int y){
	int res=A[x][y]-A[x][con[index_][x]];
	auto pre_old=--st[con[index_][x]].lower_bound(x);
	auto next_old=st[con[index_][x]].upper_bound(x);
	res+=(*next_old-x-1)*(*next_old-x)/2*C[con[index_][x]];
	res-=(x-*pre_old+*next_old-*pre_old-1)*(*next_old-x)/2*C[con[index_][x]];
	auto pre_new=--st[y].lower_bound(x);
	auto next_new=st[y].lower_bound(x);
	res+=(x-*pre_new+*next_new-*pre_new-1)*(*next_new-x)/2*C[y];
	res-=(*next_new-x-1)*(*next_new-x)/2*C[y];
	return res;
}
double rand_double(){
	return (double)rand()/RAND_MAX;
}
int solve(){
	rep(i,26){
		st[i].clear();
		st[i].insert(-1);st[i].insert(D);
	}
	rep(i,D){
		int mx=0,idx;
		rep(j,26){
			if(chmax(mx,A[i][j]))idx=j;
		}
		idx=rand()%26;
		con[index_][i]=idx;
		st[idx].insert(i);
	}
	int score_=0;
	double C=190*(index_+1)*20000;
	while(1000.*clock()/CLOCKS_PER_SEC<=190*(index_+1)){
		int x=rand()%D,y;
		do{
			y=rand()%26;
		}while(con[index_][x]==y);
		int diff=change(x,y);
		double ti=190*(index_+1)-1000.*clock()/CLOCKS_PER_SEC;

		if(diff>=0||ti/C>rand_double()){
			score_+=diff;
			st[con[index_][x]].erase(x);
			con[index_][x]=y;
			st[y].insert(x);
		}
	}
	//cerr<<score_<<endl;
	return score_;
}
signed main(){
  	cin.tie(0);ios::sync_with_stdio(false);
	cin>>D;
	rep(i,26){
		cin>>C[i];
	}
	rep(i,D)rep(j,26)cin>>A[i][j];
	int mx=0,idx;
	rep(i,10){
		index_=i;
		if(chmax(mx,solve()))idx=i;
	}
  	cerr<<mx<<endl;
	rep(i,D)cout<<con[idx][i]+1<<"\n";
	cout<<endl;
}


Measured memory_bytes: 3744
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var month = Convert.ToInt32(input[0]);
        var day = Convert.ToInt32(input[1]);

        if (month <= day) Console.WriteLine(month);
        else Console.WriteLine(month - 1);
    }
}


Measured memory_bytes: 11220
# include <bits/stdc++.h>
// #define INF 9223372036854775807
# define INF 1e9
using namespace std;

int main(){

  int N;
  cin >> N;
  int L[N];
  int max_L = 0;
  int tot_L = 0;
  for(int i=0; i<N; i++){
    cin >> L[i];
    tot_L += L[i];
    max_L = max(max_L, L[i]);
  }

  if(tot_L-max_L > max_L){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

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

double dist_Minkowski_finite(vector<double>, vector<double>, int);
double dist_Minkowski_infinite(vector<double>, vector<double>);

int main()
{
    vector<double> v1, v2;

    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        double temp;
        cin >> temp;
        v1.push_back(temp);
    }

    for (int i = 0; i < n; i++)
    {
        double temp;
        cin >> temp;
        v2.push_back(temp);
    }

    cout << fixed << setprecision(cout.precision()) << dist_Minkowski_finite(v1, v2, 1) << endl;
    cout << fixed << setprecision(cout.precision()) << dist_Minkowski_finite(v1, v2, 2) << endl;
    cout << fixed << setprecision(cout.precision()) << dist_Minkowski_finite(v1, v2, 3) << endl;
    cout << fixed << setprecision(cout.precision()) << dist_Minkowski_infinite(v1, v2) << endl;

    return 0;
}

double dist_Minkowski_finite(vector<double> v1, vector<double> v2, int p)
{
    double res = 0.0;
    for (int i = 0; i < (int) v1.size(); i++)
    {
        res += pow(abs(v1[i] - v2[i]), p);
    }
    return pow(res, 1.0 / p);
}

double dist_Minkowski_infinite(vector<double> v1, vector<double> v2)
{
    vector<double> res(v1.size(), 0.0);
    for (int i = 0; i < (int) v1.size(); i++)
    {
        res[i] = abs(v1[i] - v2[i]);
    }

    return *max_element(res.begin(), res.end());
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int A, B, C;
  cin >> A >> B >> C;
  if (A <= C && C <= B) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (stdIn.hasNextInt()) {
			int[] a = new int[4];
			int[] b = new int[4];
			for (int i = 0; i < 4; i++)
				a[i] = stdIn.nextInt();
			for (int i = 0; i < 4; i++)
				b[i] = stdIn.nextInt();
			int cou1 = 0;
			int cou2 = 0;
			for (int i = 0; i < 4; i++)
				if (a[i] == b[i])
					cou1++;
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					if (a[i] == b[j]) {
						cou2++;
					}
				}
			}
			if (0 < cou2)
				cou2 = cou2 - cou1;
			System.out.println(cou1 + " " + cou2);
		}
	}
}

Measured memory_bytes: 18136
from fractions import gcd

def f(x):
    res = 0
    while x % 2 == 0:
        x //= 2 
        res += 1
    return res

def lcm(n, m):
    return n * m // gcd(n, m)


n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
    if a[i] % 2 == 1:
        print(0)
        exit()
    else:
        a[i] //= 2

t = f(a[0])
for i in range(n):
    if t != f(a[i]):
        print(0)
        exit()
l = 1
for i in range(n):
    l = lcm(l, a[i])
    if l > m:
        print(0)
        exit()

m //= l

ans = (m+1) // 2

print(ans)


Measured memory_bytes: 16320
#include<stdio.h>

#include<algorithm>


using namespace std ;

typedef long long llong ;

typedef struct
{
	llong size ;
	llong value ;

} Data ;

#define N_MAX 500000
Data art[ N_MAX ] ;

inline bool cmp( const Data& a ,const Data& b )
{
	return a.size == b.size ? a.value < b.value : a.size < b.size ;
}

inline llong Max( llong a ,llong b )
{
	return a > b ? a : b ;
}


int main( void )
{
	int N ;
	scanf( "%d" ,&N ) ;

	int i ;
	for( i = 0 ; i < N ; ++i )
	{
		scanf( "%lld %lld" ,&art[ i ].size ,&art[ i ].value ) ;
	}

	sort( art ,art + N ,cmp ) ;

	llong min_size	= art[ 0 ].size		;
	llong sum_value	= art[ 0 ].value	;

	llong ans = art[ 0 ].value ;
	for( i = 1 ; i < N ; ++i )
	{
		llong value	= art[ i ].value	;
		llong size	= art[ i ].size		;

		llong tmp =  sum_value + value  - ( size -  min_size ) ;
		if( tmp < value )
		{
			ans = Max( ans ,value ) ;

			sum_value	= value	;
			min_size	= size	;
		}

		else
		{
			ans = Max( ans ,tmp ) ;

			sum_value += value ;
		}
	}

	printf( "%lld\n" ,ans ) ;

	return 0 ;
}


Measured memory_bytes: 10584
#include <bits/stdc++.h>
#define maxn (int)(1e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;

int solve(string s, int n){
    //generate_divisors(n);
    int cnt = 1, ans = n;
    for(int i=0;i<n;i++){
        int l = i;
        while(i+1 < n and s[i+1]==s[i]){
            i++;
            cnt++;
        }
        if(cnt) ans-= (cnt-1);
        cnt = 1; 
    }
    if(cnt) ans-= (cnt-1);
    return ans;
}
int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    // */
  
    int n;
    string s;
    while(scanf("%d",&n)==1){
        getchar();
        cin>>s;
        printf("%d\n", solve(s,n));
    }    
    return 0;
}

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

int main() {
    set<string> S;
    int n; cin >> n;
    while (n--) {
        string com, word;
        cin >> com >> word;
        if (com[0] == 'i') {
            S.insert(word);
        } else {
            cout << (S.count(word) ? "yes" : "no") << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 32116
import java.util.*;
public class Main {
	public static void main(String[] args){
		int MOD = 1000000007;
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		boolean f = s.equals("a") || s.equals("i") || s.equals("u") || s.equals("e") || s.equals("o");

		System.out.println(f ? "vowel" : "consonant");
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pi 3.14
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<long long,int> pli;
typedef pair<int,long long> pil;
const int INF=1000000007;
const int MOD=1000000007;
const int nmax=101234;

int dp[nmax];

int main()
{
    int x;
    scanf("%d",&x);
    dp[0]=1;
    for(int i=0;i<6;++i)
        for(int j=0;j+100+i<=x;++j)
            dp[j+100+i]|=dp[j];
    printf("%d\n",dp[x]);
    return 0;
}


Measured memory_bytes: 640
n,T=map(int,input().split())
INF=10**9
cost=INF
flag=0
for i in range(n):
  c,t=map(int,input().split())
  if t<=T:
    cost=min(cost,c)
    flag=1
if flag:
  print(cost)
else:
  print('TLE')

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	int ans=0;
	cin>>a>>b>>c;
	if(a!=b)ans+=1;
	if(a!=c)ans+=1;
	if(b!=c)ans+=1;
	if(a==b&&a==c&&b==c)ans+=1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(x,n) for(int i=x;i<n;i++)
#define REP(y,n) for(int j=y;j<n;j++)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
signed main(){
  double a,b,c,C,S,L,h;
  cin>>a>>b>>C;
  c=sqrt(a*a+b*b-2*a*b*cos(C*M_PI/180));
  L=a+b+c;
  S=0.5*a*b*sin(C*M_PI/180);
  h=S*2/a;
  printf("%.5f\n",S);
  printf("%.5f\n",L);
  printf("%.5f\n",h);
}



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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n;
	cin>>n;
	if (n>=1000){
		cout<<"ABD";
	}
	else {
		cout<<"ABC";
	}
	return 0;
}

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

flag = False
for i in range(len(S)-len(T),-1,-1):
    count = 0
    for j in range(len(T)):
        #print(T[j],S[i:i+len(T)][j])
        if T[j] == S[i+j] or S[i+j] == '?':
            count += 1
        else:
            break
    
    if count == len(T):
        flag = True
        for j in range(len(T)):
            S[i+j] = T[j]
        break

if not flag:
    print('UNRESTORABLE')
    exit()

for i in range(len(S)):
    if S[i] == '?':
        S[i] = 'a'

print("".join(S))

Measured memory_bytes: 3064
#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>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
   int n;cin>>n;
   vector<int> a(n);
   rep(i,n){
       cin>>a[i];
   }
   sort(ALL(a));
   reverse(ALL(a));
   int al,bo;
   al=0;bo=0;
   rep(i,n){
       if(i%2){
           bo+=a[i];
       }else{
           al+=a[i];
       }
   }
   cout<<al-bo<<endl;
    return 0;
}

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


#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define repd(i, a, b) for(int i = a; i > b; i--)

#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound

	typedef long long ll;

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		ll sale[4096] = { 0 };
		bool ok = true;
		rep(i, n) {
			ll s, h, u;
			cin >> s >> h >> u;
			if (sale[s] < 1000000) {
				sale[s] += h * u;
				if (sale[s] >= 1000000) {
					cout << s << endl;
					ok = false;
				}
			}
		}

		if (ok) cout << "NA" << endl;
	}
}

Measured memory_bytes: 1204
n = int(input())
s = input()
mod = 10**9+7
dp = []
imos = [0 for _ in range(n*2+1)]
now = 0
for i in range(n*2):
    c = 1 if s[i]=='B' else 0
    if c==now%2:
        imos[i]-=1
        dp.append(-1)
    else:
        imos[i]+=1
        dp.append(1)
    now+=imos[i]
if sum(dp)!=0:
    print(0)
    exit()
ans = 1
cnt = 0
for i in dp:
    if i==1:
        cnt+=1
    else:
        ans*=cnt
        ans%=mod
        cnt-=1
for i in range(1,n+1):
    ans*=i
    ans%=mod
print(ans)

Measured memory_bytes: 6760