akhauriyash/Code-Regression huggingface dataset:
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "abc169_b.cpp"

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

  int n;
  cin >> n;
  vl a(n);
  REP(i, n) { cin >> a[i]; }

  REP(i, n) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll sum = 1;
  REP(i, n) {
    if (sum <= (ll)1e18 / a[i]) {
      sum *= a[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << sum << endl;
}


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

using namespace std;

typedef long long ll;

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

bool is_need(vector<int>& A, int ix, int N ,int K)
{
  vector<bool> dp(K + 5, false);
  dp[0] = true;
  for (int i = 0; i < N; ++i) {
    if (i == ix) { continue; }
    for (int j = K; j >= 0; --j) {
      if (j >= A[i] and dp[j - A[i]]) {
        dp[j] = true;
      }
    }
  }
  for (int sum = max(0, K - A[ix]); sum < K; ++sum) {
    if (dp[sum]) { return true; }
  }
  return false;
}

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  sort(A.begin(), A.end(), greater<int>());

  int left = -1, right = N;
  while (right - left > 1) {
    int mid = (right + left) / 2;
    if (is_need(A, mid, N, K)) {
      left = mid;
    }
    else {
      right = mid;
    }
  }

  int ans = N - left - 1;
  printf("%d\n", ans);
  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n,k;cin >> n >> k;
    vector<int> p(n);
    REP(i,n)cin >> p[i];
    sort(p.begin(),p.end());
    int ans = 0;
    REP(i,k){
        ans += p[i];
    }
    COUT(ans);
    return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader buff = null;
		buff = new BufferedReader(new InputStreamReader(System.in));


		int A = 0, B = 0, C = 0;
		long X = 0, Y = 0;
		String[] box = buff.readLine().split(" ");
		A = Integer.parseInt(box[0]);
		B = Integer.parseInt(box[1]);
		C = Integer.parseInt(box[2]);
		X = Long.parseLong(box[3]);
		Y = Long.parseLong(box[4]);
		long ans = 0;

		double pre_X = X, pre_Y = Y;
		long countAB = 0, countA = 0, countB = 0;
		/*while((pre_X > 0) || (pre_Y > 0)){
			if(pre_X >= 0.5 && pre_Y >= 0.5){
				long half = (A/2) + (B/2);
				if(half < C){
					ans += half;
				} else {
					ans += C;
				}
				pre_X -= 0.5;
				pre_Y -= 0.5;
				countAB++;
			} else if(pre_X >= 1){
				ans += A;
				pre_X--;
				countA++;
			} else if(pre_Y >= 1){
				ans += B;
				pre_Y--;
				countB++;
			}
		}*/
		if(X < Y){
			ans += X * 2 * C;
			ans += (Y - X) * B;
			//System.out.println("A1: " + (X * 2) + " " + (Y - X) + " " + ans);
		}else{
			ans += Y * 2 * C;
			ans += (X - Y) * A;
			//System.out.println("A2: " + (Y * 2) + " " + (X - Y) + " "  + ans);
		}
		long over = 0;
		if(X > Y){
			over = X * 2 * C;
			//System.out.println("B1: " + X * 2 + " " + over);
		} else {
			over = Y * 2 * C;
			//System.out.println("B2: " + Y * 2 + " " + over);
		}
		if(ans > over){
			ans = over;
		}

		long usu = X * A + Y * B;
		//System.out.println("C: " + X + " " + Y + " " + usu);
		if(ans > usu){
			ans = usu;
		}

		System.out.println(ans);
	}

	static long f() {
		long ans = 0;


		return ans;
	}
}

Measured memory_bytes: 22484
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	string S;
	int f = 0;
	cin >> S;

	for (int i = 0; i < S.size(); i++)
	{
		if ((i + 1) % 2 == 0)
		{
			if (S[i] == 'R') { f = 1; }
		}
		else
		{
			if (S[i] == 'L') { f = 1; }
		}
	}

	if (f == 1) { cout << "No" << endl; }
	else { cout << "Yes" << endl; }

}

Measured memory_bytes: 256
import sys, itertools
readline = sys.stdin.readline
write = sys.stdout.write
N, V = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())
*D, = map(int, input().split())

AB = {}
for a, b in itertools.product(A, B):
    AB[a+b] = AB.get(a+b, 0) + 1
key0 = sorted(AB)
CD = {}
for c, d in itertools.product(C, D):
    CD[c+d] = CD.get(c+d, 0) + 1
key1 = sorted(CD, reverse=1)

it = iter(key1); v1 = next(it, None)
ans = 0
for v0 in key0:
    while v1 is not None and v0 + v1 > V:
        v1 = next(it, None)
    if v1 is not None and v0 + v1 == V:
        ans += AB[v0] * CD[v1]
write("%d\n" % ans)



Measured memory_bytes: 211632
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



int main() {
    string s;
    cin >> s;
    
    int c[3] = {};
    REP(i, s.size()){
        c[s[i] - 'a']++;
    }
    
    if(*max_element(c, c + 3) - *min_element(c, c + 3) <= 1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String cards = in.readLine();
			if (cards.equals("-")) {
				break;
			}
			int num = cards.length();
			int time = Integer.parseInt(in.readLine());
			for (int i = 0; i < time; i++) {
				int shuffle = Integer.parseInt(in.readLine());

				cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle);
			}
			System.out.println(cards);
		}
	}
}

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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int s,w;
    cin>>s>>w;
    if(w>=s)
    {
        cout<<"unsafe";
    }
    else
    {
        cout<<"safe";
    }
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;

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

int main() {
    int  n,r;
    cin >> n >> r;
    if(n >= 10) {
        cout << r;
        return 0;
    }else {
        cout << r+100*(10-n);
        return 0;
    }
}



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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    string a,b;
    cin >> a >> b;
    a += b;
    int x = stoi(a);
    int q = sqrt(x);

    if(q*q==x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import fractions
from functools import reduce

n = int(input())

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

dp = [[a[0]],[-10**10]]

for i in range(n-1):
    dp[0].append(max(dp[0][i] +a[i+1], dp[1][i] + a[i+1]))
    dp[1].append(max(dp[0][i] - a[i+1]- 2*a[i], dp[1][i]-a[i+1] + 2*a[i]))

print(max(dp[0][n-1],dp[1][n-1]))

Measured memory_bytes: 20160
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;

int main()
{
    string s;
    cin >> s;

    vector<string> list(3);

    string s1 = s.substr(0, 1);
    string s2 = s.substr(1, 1);
    string s3 = s.substr(2, 1);

    int ans = 0;
    rep(i, 3)
    {
        list[i] = s.substr(i, 1);
    }

    rep(i, 3)
    {
        if (i == 0 && list[i] == "R")
        {
            ans = 1;
            continue;
        }

        if (list[i - 1] == "R" && list[i] == "R")
        {
            ans++;
        }
        if (list[i - 1] != "R" && list[i] == "R")
        {
            ans = 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

template <class A>ostream &operator<<(ostream &o, const vector<A>&p) { o << "{"; for (int i = 0; i < (int)p.size(); ++i)o << (i > 0 ? ", " : "") << p[i]; o << "}"; return o; }
template <class A, class B>ostream &operator<<(ostream &o, const pair<A, B>&p) { o << "{" << p.first << ", " << p.second << "}"; return o; }
template <class A, class B>ostream &operator<<(ostream &o, const map<A, B>&p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
template <class A>ostream &operator<<(ostream &o, const set<A>&p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
void print() { cerr << endl; }
template <class H> void print(H&& h) { cerr << h << endl; }
template <class H, class... T> void print(H&& h, T&&... t) { cerr << h << " "; print(forward<T>(t)...); }

int main() {
	LL n, q; cin >> n >> q;
	VL a(n); rep(i, n)cin >> a[i];

	rep(loop, q) {
		LL x, ans = 0;
		cin >> x;

		LL r = 0, sum = 0;
		rep(l, n) {
			while (r < n && sum + a[r] <= x) {
				sum += a[r]; r++;
			}
			ans += r - l;

			if (l == r)r++;
			else sum -= a[l];
		}

		Cout(ans);
	}
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
const int MOD = 1000000007;

int main()
{
    int k, s;
    cin >> k >> s;

    int ans = 0;
    rep(x, k + 1)
    {
        rep(y, k + 1)
        {
            int z = s - x - y;
            if (x + y + z == s && z >= 0 && z <= k)
            {
                ans++;
                //cout << x << ":" << y << ":" << z << endl;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int binc[100005];
int father[100005];
int find(int x){
	if(binc[x]==x) return x;
	binc[x]=find(binc[x]);return binc[x];
}
void toge(int a,int b){
	int c=find(a),d=find(b);
	if(c==d) return ;
	binc[d]=c;
}
int main(){
	int n,m,a,b,ans=-1;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) binc[i]=i;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a,&b);
		toge(a,b);
	}
	for(int i=1;i<=n;i++) father[find(i)]=1;
	for(int i=1;i<=n;i++) ans+=father[i];
	printf("%d",ans);
	return 0;
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  map<int,int>mm;
  fori(i,3){
    int va;cin>>va;
    mm[va]++;
  }
  if(mm[5]==2 && mm[7]==1)puts("YES");
  else puts("NO");

  return 0;
}



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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> button(n);
  for(int i=0;i<n;i++){
    cin >> button[i];
  }
  int num=1,cnt=1;
  while(cnt<=n){
    /*
    cout <<"num:"<<num<<endl;
    cout <<"cnt:"<<cnt<<endl;
    cout <<"button:"<<button[num-1]<<endl<<endl;
    */
    if(button[num-1]==2){
      cout << cnt << endl;
      return 0;
    }else{
      num = button[num-1];
    }
    cnt++;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

long n;

int main ()
{
	cin>>n;
	
	long l0 = 2, l1 = 1, aux;

	n=n-1;
	while (n)
	{
		aux = l1+l0;
		l0=l1;
		l1=aux;
		n--;
	}

	cout<<l1;
	return 0;
}

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

int main() {
    int N = 0;
    cin >> N;
    vector<int> freq(8);
    int anyc = 0;
    for (int n = 0; n != N; ++n){
        int a;
        cin >> a;
        if (a >= 3200) {
            ++anyc;
        }else{
            freq[a/400] = 1;
        }
    }
    auto total = accumulate(freq.begin(), freq.end(), 0);
    if (total == 0){
        cout << 1 << " " << anyc << endl;
        return 0;
    }
    cout << total << " " << total + anyc << endl;
    return 0;
}


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

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  int a[n+1];
  for(i=1;i<=n;i++)cin>>a[i];
  for(i=1;i<=n;i++){
    if(a[a[i]]==i)cnt++;
  }
  cout<<cnt/2;
}

Measured memory_bytes: 640
from collections import defaultdict, deque, Counter
import sys
input = sys.stdin.readline


def getPrimes(n):
    isPrime = [True] * n
    ret = []
    for p in range(2, n):
        if not isPrime[p]:
            continue
        ret.append(p)
        for i in range(p, n, p):
            isPrime[i] = False
    return ret


def main():
    N = int(input())
    P = getPrimes(N)
    C = Counter()

    for i in range(1, N + 1):
        cnt = Counter()
        for p in P:
            while i % p == 0:
                i //= p
                cnt[p] += 1
        C += cnt

    d = {3: 0, 5: 0, 15: 0, 25: 0, 75: 0}
    for k in d.keys():
        for v in C.values():
            if v >= k - 1:
                d[k] += 1

    ans = 0
    ans += (d[5] * (d[5] - 1) // 2) * (d[3] - 2)
    ans += d[15] * (d[5] - 1)
    ans += d[25] * (d[3] - 1)
    ans += d[75]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    if (a<1200) {
      System.out.println("ABC");
    } else if (a<2800) {
      System.out.println("ARC");
    } else {
      System.out.println("AGC");
    }
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int ans = 0;
  bool zero = true;
  while(accumulate(ALL(h), 0) != 0){
    zero = true;
    rep(i, n){
      if(zero && h[i] != 0){
        zero = false;
        ++ans;
      }else if(!zero && h[i] == 0){
        zero = true;
      }
      h[i] = max(0, h[i] - 1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

struct Edge {
    long from;
    long to;
    long cost;
};

int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld%ld", &n, &m);

    vector<Edge> zz(m);
    long i;
    for(i=0; i<m; i++) {
        long a,b,c;
        scanf("%ld%ld%ld", &a, &b, &c);
        Edge e = {a-1,b-1,-c};
        zz[i] = e;
    }

    vector<ll> dist(n, LINF);
    dist[0]= 0;
    long count=0;
    ll   ans_save =0;
    while( 1 ) {
        bool update = false;
        for(i=0; i<m; i++) {
            Edge e = zz[i];
            if(dist[e.from] != LINF && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                update = true;
            }
        }
        if( !update ) break;

        count++;
        if(count==n) {
            ans_save = -dist[n-1];
        }
        else if (count>2*n) {
            if( ans_save != -LINF && ans_save == -dist[n-1] ) {
                printf("%lld\n", ans_save);
                return 0;
            }

            printf("inf\n");
            return 0;
        }
    }
    printf("%lld\n", -dist[n-1]);

    return 0;
}


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

int main()
{
  int N, M;
  cin >> N;
  vector<string> blue(N);
  for(int i = 0; i < N; i++)
    cin >> blue.at(i);
  cin >> M;
  vector<string> red(M);
  for(int i = 0; i < M; i++)
    cin >> red.at(i);
  
  int res;
  int maxres = 0;
  for(int i = 0; i < N; i++)
  {
    res = 0;
    for(int j = 0; j < N; j++)
    {
      if(blue.at(j) == blue.at(i))
        res++;
    }
    for(int j = 0; j < M; j++)
    {
      if(red.at(j) == blue.at(i))
        res--;
    }
    if(res > maxres)
      maxres = res;
  }
  cout << maxres << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string A,C;
  cin >>A>>C;
  int B=A.size(),D=0;
  for(int i=0;i<B;i++){
    if(A==C){
      D=1;
      break;
    }else{
      A.insert(A.begin(),A[B-1]);
      A.pop_back();
    }
  }
  if(D)cout <<"Yes" << endl;
  else cout <<"No" << endl;
}
      


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

typedef long long ll;

const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long m)
{
    long long ans = 1;
    while (n)
    {
        if (n & 1)
        {
            ans = (ans * a) % m;
        }
        a = (a * a) % m;
        n >>= 1;
    }
    return ans;
}
long long combi(long long n, long long a)
{
    long long ans = 1, ans1 = 1;
    for (long long i = n - a + 1; i <= n; i++)
    {
        ans *= i % MOD;
        ans %= MOD;
    }

    for (long long i = 2; i <= a; i++)
        ans1 = (ans1 * i) % MOD;
    ans1 = modpow(ans1, MOD - 2, MOD);
    return ((ans % MOD) * ans1) % MOD;
}

void dfs(string s, char mx, ll N)
{
    if (s.length() == N)
    {
        cout << s.c_str() << endl;
    }
    else
    {
        for (char c = 'a'; c <= mx; c++)
        {
            dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx), N);
        }
    }
}

int bfs(int i, int j, int h, int w, char tmp[][21])
{
    int ans[21][21] = {0};
    char c[21][21] = {0};
    queue<pair<int, int>> s;

    for (int i = 0; i<=h; i++){
        for(int j=0; j<=w; j++){
            c[i][j] = tmp[i][j];
        }
    }

        s.push(make_pair(i, j));

    while (s.size() > 0)
    {

        pair<int, int> tmp = s.front();
        s.pop();
        c[tmp.first][tmp.second] = '#';
        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                if (tmp.first + i < 1 || tmp.first + i > h)
                {
                    continue;
                }
                if (tmp.second + j < 1 || tmp.second + j > w)
                {
                    continue;
                }
                if (i != 0 && j != 0)
                {
                    continue;
                }
                if (i == 0 && j == 0)
                {
                    continue;
                }
                if (c[tmp.first + i][tmp.second + j] == '#')
                {
                    continue;
                }
                c[tmp.first + i][tmp.second + j] = '#';
                if (ans[tmp.first + i][tmp.second + j] == 0)
                {
                    ans[tmp.first + i][tmp.second + j] = ans[tmp.first][tmp.second] + 1;
                }
                else
                {
                    ans[tmp.first + i][tmp.second + j] = min(ans[tmp.first + i][tmp.second + j], ans[tmp.first][tmp.second] + 1);
                }
                s.push(make_pair(tmp.first + i, tmp.second + j));
            }
        }
    }

    int a = 0;

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            a = max(a, ans[i][j]);
        }
    }

    return a;
}


int main()
{
    ll l, r;
    cin >> l >> r;
	ll m = 2018;
	for(ll i=l; i<r; i++){
      for(ll j=l+1; j<=r; j++){
        if((i*j)%2019==0){
          cout << 0 << endl;
          return 0;
        }
        m = min(m, (i*j)%2019);
      }
    }
  
  	
	cout << m << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Comparable;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x=sc.next();
		String y=sc.next();
		if(x.compareTo(y)==0) {
			System.out.println("=");
		}else if(x.compareTo(y)<0) {
			System.out.println("<");
		}else if(x.compareTo(y)>0){
			System.out.println(">");
		}
		sc.close();
		
	}

}

Measured memory_bytes: 22868
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<queue>

using namespace std;

long long gcd(long long x, long long y) {
	if (y > x) return gcd(y, x);
	if (x % y == 0) return y;
	return gcd(y, x % y);
}

int main(void) {
	int T;
	cin >> T;
	for (int t = 0; t < T; t++) {
		long long A, B, C, D;
		cin >> A >> B >> C >> D;
		if (A < B || D < B) {
			cout << "No" << endl;
			continue;
		}
		else if (B <= C) {
			cout << "Yes" << endl;
			continue;
		}
		long long g = gcd(B, D);
		//cout << g << " ";
		long a = A % g;
		long c = C % g;
		if (a <= c) a += g;
		a += (C - c);
		if (a < B) cout << "No" << endl;
		else cout << "Yes" << endl;
	}


	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<stdio.h>

int main()
{

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

   if(a<b) {
      if(b<c) printf("Yes\n");
      if(c<b) printf("No\n");
   } else {
      printf("No\n");
   }

   return 0;
}

Measured memory_bytes: 2612
use List::Util qw(max min sum);

my ($n) = split(/\s+/, <>);
my (@a) = (0, split(/\s+/, <>));
my @b = ();
push @b, 0 for (0..$n);

for (my $i=$n; $i>0; $i--) {
    my $sum=$a[$i];
    for (my $j=$i*2; $j<=$n; $j+=$i) {
	$sum += $b[$j];
    }
    $b[$i] = $sum % 2;
}
print sum(@b), "\n";
for (1..$n) {
    print "$_ " if $b[$_];
}
print "\n";


Measured memory_bytes: 30176
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long ans = 0;

        ans += (n / (a + b)) * a;
        n %= (a + b);
        ans += Math.min(a, n);
        System.out.println(ans);
    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

}


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

int main()
{
  int h[101][101] {};
  int n;
  cin >> n;
  int px[n], py[n], ph[n];
  for (auto i = 0; i < n; i++) {
    cin >> px[i] >> py[i] >> ph[i];
  }
  for (auto i = 0; i < n; i++) {
    if (ph[i] > 0) {
      for (auto y = 0; y <= 100; y++) {
	for (auto x = 0; x <= 100; x++) {
	  if (h[y][x] < 0) continue;
	  int t = ph[i] + abs(x - px[i]) + abs(y - py[i]);
	  if (h[y][x] == 0) {
	    h[y][x] = t;
	    continue;
	  }
	  if (h[y][x] != t) {
	    h[y][x] = -1;
	    continue;
	  }
	}
      }
    }
  }
  for (auto i = 0; i < n; i++) {
    if (ph[i] == 0) {
      for (auto y = 0; y <= 100; y++) {
	for (auto x = 0; x <= 100; x++) {
	  if (h[y][x] < 0) continue;
	  int t = abs(x - px[i]) + abs(y - py[i]);
	  if (t - h[y][x] < 0) {
	    h[y][x] = -1;
	    continue;
	  }
	}
      }
    }
  }
  for (auto y = 0; y <= 100; y++) {
    for (auto x = 0; x <= 100; x++) {
      if (h[y][x] > 0) {
	cout << x << " " << y << " " << h[y][x] << endl;
      }
    }
  }
}


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

long h[int(1e5)];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    long min = long(1e14);
    cin >> N >> K;
    for(int n=0; n<N; n++)cin >> h[n];
    sort(h, h+N);
    for(int n=0; n<N-K+1; n++){
        if(h[n+K-1] - h[n] < min)min = h[n+K-1] - h[n];
        //cout << h[n] << " " << h[n+K-1] << " " << h[n+K-1] - h[n] << "\n";
    }
    cout << min << "\n";
    return 0;
}

Measured memory_bytes: 1024
NM = list(map(int,input().split()))
N=NM[0]
M=NM[1]
a=[]
b=[]
c=[]
d=[]
for i in range(N):
    a1,b1=[int(i) for i in input().split()]
    a.append(a1)
    b.append(b1)

for j in range(M):
    c1,d1=[int(j) for j in input().split()]
    c.append(c1)
    d.append(d1)

distance=[]
chkpnt=[]

for k in range(N):
    for l in range(M):
        distance.append(abs(a[k]-c[l])+abs(b[k]-d[l]))
    chkpnt.append(str(distance.index(min(distance))+1))
    distance=[]

print('\n'.join(chkpnt))


Measured memory_bytes: 3064
N = int(input())
txy = [input() for i in range(N)]
txy = [list(map(int, txy[i].split())) for i in range(len(txy))]

ans = "Yes"
for i in range(N):
    if i == 0:
        last = [0, 0, 0]
    else:
        last = txy[i-1]

    t = txy[i][0] - last[0]
    x = abs(txy[i][1] - last[1])
    y = abs(txy[i][2] - last[2])

    if x+y > t or not t%2 == (x+y)%2:
        ans = "No"
        break

print(ans)

Measured memory_bytes: 34460
S = input()

def sumS(nums):
    p = 0
    if len(nums) == len(S)-1:
        num = int(S[0])
        for n, s in zip(nums, S[1:]):
            if n == 0:
                num = num * 10 + int(s)
            else:
                p += num
                num = int(s)
        p += num
        return p
    
    for i in range(2):
        nums.append(i)
        p += sumS(nums)
        nums.pop()
    return p

print(sumS([]))
            

Measured memory_bytes: 3064
n = int(input())
s = [0]*n
t = [0]*n
for i in range(n):
    s[i],t[i] = map(str,input().split())
    t[i] = int(t[i])
x = input()
a = s.index(x)
ans = sum(t[a+1:])
print(ans)

Measured memory_bytes: 9156
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e6+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p,ll mod)
{
	if(p==0) return 1;
	ll z=powN(a,p/2,mod);
	z=(z*z)%mod;
	if(p%2) z=(z*a)%mod;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vector<int> MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

int main()
{
	int x,y;
	cin>>x>>y;
	// a+b=x
	// 2a+4b=y

	//b = (y-2x)/2;
	//a = x - (y-2x)/2 = (4x-y)/2

	int a2 = 4*x-y;
	int b2 = y-2*x;

	if(a2>=0&&b2>=0&&a2%2==0&&b2%2==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}		

Measured memory_bytes: 7028
#include <stdio.h>
int main(void){
int a,b,c;
  int min=0;
  scanf("%d %d %d",&a,&b,&c);
min=a+b;
    if(min>a+c){min=a+c;}
    if(min>b+c){min=b+c;}
  printf("%d",min);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    #define ll long long
    using namespace std;
    int main(){
        int n,m,p;
        string s;
        cin>>n>>m;
        vector <int> v(n+1,0),x(n+1,0);
        int pen=0,c=0;
        for (int i=0;i<m;i++){
            cin>>p;
            cin>>s;
            if (s=="WA" && x[p]==0){
                v[p]++;
            }
            else if(s=="AC" && v[p]!=0 && x[p]==0){
                pen+=v[p];
                x[p]=1;
                c++;
            }
            else if (s=="AC" && v[p]==0 && x[p]==0){
                c++;
                x[p]=1;
            }
        }
        cout<<c<<" "<<pen<<endl;
        return 0;
    }

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

int main(){
    string S;
    cin >> S;
    size_t n = S.length();
    for(int i=0; i<n; i+=2){
        S.pop_back(); S.pop_back();
        size_t half = S.length()/2;
        if(S.substr(0, half)==S.substr(half, half)){
            cout << half*2 << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,e,f,g,h,i,j;
    long long int x,y;
    cin>>a>>b>>c>>x>>y;
  d=a+b;
  e=2*c;
    e=min(d,e);
    f=min(x,y);
    x-=f;
    y-=f;
    g=min(a,2*c);
    h=min(b,2*c);
    long long int ans=0,sum=0;
    ans=f*e;

    if(x>0)
    {
        ans+=g*x;
    }
    if(y>0)
    {
        ans+=h*y;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=3e3+10;

int N;
double DP[maxm][maxm],P[maxm];

int main(){
	register int i,j;
	register double Ans=0;
	scanf("%d",&N);
	DP[0][0]=1;
	for(i=1;i<=N;i++) scanf("%lf",P+i);
	for(i=1;i<=N;i++) DP[i][0]=DP[i-1][0]*(1-P[i]);
	for(i=1;i<=N;i++){
		for(j=1;j<=i;j++){
			DP[i][j]=DP[i-1][j-1]*P[i]+DP[i-1][j]*(1-P[i]);
		}
	}
	for(i=(N+1>>1);i<=N;i++){
		Ans+=DP[N][i];
	}
	printf("%.10lf",Ans);
	return 0;
}

Measured memory_bytes: 69120
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
#include<string>
using namespace std;
typedef long long ll;
ll N = 1000;

bool query(ll x){
	char c;
	cout << "? " << x << endl << flush;
	cin >> c;
	return c == 'Y';

	/*
	string xs = to_string(x);
	string ns = to_string(N);
	return (x <= N && xs <= ns) || (x > N && xs > ns);
	*/
}

int main(){
	int ndigit = -1;
	ll x = 1;
	for(int i=0; i<11; i++){
		if(!query(x)){
			ndigit = i;
			break;
		}
		x *= 10;
	}

	if(ndigit < 0){
		x = 1;
		for(int i=0; i<11; i++){
			if(query(2*x)){
				ndigit = i+1;
				cout << "! " << x << endl;
				return 0;
			}
			x *= 10;
		}
	}

	x = 1;
	for(int i=1; i<ndigit; i++){
		x *= 10;
	}
	ll ub = 10*x-1;
	ll lb = x;

	for(int i=0; i<30 && ub-lb>1; i++){
		ll m = (lb+ub)/2;
		if(query(10*m)){
			ub = m;
		}
		else{
			lb = m;
		}
	}

	cout << "! " << ub << endl << flush;

	return 0;
}


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


void solve(long long N, long long K, std::vector<long long> p){
    vector<long double> e(1001);
    long long sump=0;
    for(long long i=1;i<1001;i++){
        sump += i;
        e[i]=sump/(double)(i);
    }
    long double ans = 0;
    long double current = 0;
    for(long long i=0;i<K;i++){
        current += e[p[i]];
    }
    ans = current;
    cerr << ans << endl;
    for(long long i=K;i<N;i++){
        current = current-e[p[i-K]]+e[p[i]];
        ans = max(ans,current);

    }
    cout <<fixed;
    cout << setprecision(10)<<ans << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string.h>
using namespace std ;

int main()
{
	char get[20] ;
	cin >> get ;

	int i = 0 ;
	char output[20] ;
	while( (strlen(get)-i) > 0 )
	{
		output[i] = get[strlen(get)-i-1] ;
		i ++ ;
	}

	output[strlen(get)] = '\0' ;
	cout << output << endl ;

	return 0 ;
}

Measured memory_bytes: 1136
s = list(input())
a = []
b = []

for i in range(1, len(s)+1):
  a.append(i%2)     # 101010
  b.append((i+1)%2) # 010101

c = 0
d = 0

s = list(map(int, s))

for i in range(len(s)):
  if a[i] != s[i]:
    c += 1
  if b[i] != s[i]:
    d += 1

if c > d:
  print(d)
else:
  print(c)

Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
int n, a[20], o = 0;

int main(){
    cin >> n;
    for (int i = 0; i < n; i ++){
        cin >> a[i];
    }
    for (int i = 1; i < n - 1; i ++){
        if (((a[i-1] < a[i])&&(a[i] < a[i+1]))||((a[i-1] > a[i])&&(a[i] > a[i+1]))){
            o++;
        }
    }
    cout << o;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    string o,e;cin >> o >> e;
    vector<char> ans;
    ans.resize(sz(o)+sz(e));
    for (int i = 0; i < sz(o) + sz(e); i++)
    {
        if(i%2==0)
        {
            ans[i] = o[i/2];
        }else
        {
            ans[i] = e[(i-1)/2];
        }
        
    }

    rep(i, sz(o) + sz(e))
    {
        cout << ans[i];
    }
    cout << endl;
    
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

int main() {
   
 int N,K;
 cin>>N>>K;
 if(N%K==0){
 	ce("0");
 }else{
 	ce("1");
 }

}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Card[] c1 = new Card[N];
		Card[] c2 = new Card[N];
		for (int i = 0; i < N; i++) {
			c1[i] = new Card();
			c2[i] = new Card();
		}
		for (int i = 0; i < N; i++) {
			String strC = sc.next();
			char[] chrC = strC.toCharArray();
			c1[i].setSuit(chrC[0]);
			c1[i].setValue(chrC[1]);
		}
		for (int i = 0; i < N; i++) {
			c2[i] = c1[i];
		}
		bubbleSort(c1, N);
		selectionSort(c2, N);
		print(c1, N);
		System.out.println("Stable");
		print(c2, N);
		if (isStable(c1, c2, N)) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
		sc.close();
	}

	public static void bubbleSort(Card[] A, int N) {
		for (int i = 0; i < N; i++) {
			for (int j = N - 1; j >= i + 1; j--) {
				if (A[j].getValue() < A[j - 1].getValue()) {
					Card t = A[j];
					A[j] = A[j - 1];
					A[j - 1] = t;
				}
			}
		}
	}

	public static void selectionSort(Card[] A, int N) {
		for (int i = 0; i < N; i++) {
			int minj = i;
			for (int j = i; j < N; j++) {
				if (A[j].getValue() < A[minj].getValue()) {
					minj = j;
				}
			}
			Card t = A[i];
			A[i] = A[minj];
			A[minj] = t;
		}
	}

	public static void print(Card A[], int N) {
		for (int i = 0; i < N; i++) {
			if (i > 0) {
				System.out.print(" ");
			}
			System.out.print(A[i].getSuit() + "" + A[i].getValue());
		}
		System.out.printf("\n");
	}

	public static boolean isStable(Card[] c1, Card[] c2, int N) {
		for (int i = 0; i < N; i++) {
			if (c1[i].getSuit() != c2[i].getSuit()) {
				return false;
			}
		}
		return true;
	}
}

class Card implements Cloneable {

	private char suit;
	private char value;

	public char getSuit() {
		return suit;
	}

	public void setSuit(char suit) {
		this.suit = suit;
	}

	public char getValue() {
		return value;
	}

	public void setValue(char value) {
		this.value = value;
	}
}



Measured memory_bytes: 26296
#include<iostream>
using namespace std;
double xa,ya,xb,yb,xc,yc,xd,yd;

int main(){
    while(cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd){
        !((xb-xa)*(xd-xc)+(yb-ya)*(yd-yc))?cout<<"YES"<<endl:cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 1216
N = input()

ans = 0

while True:
    if len(N) == 6:
        N = str(99999)
    if len(N) == 5:
        ans += int(N) - 9999
        N = str(999)
    if len(N) == 4:
        N = str(999)
    if len(N) == 3:
        ans += int(N) - 99
        N = str(9)
    if len(N) == 2:
        N = str(9)
    if len(N) == 1:
        ans += int(N)
        break
    
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

int getAbs(int x);

int main(){
    int n;
    cin >> n;
    bool travelable = true;
    int currentTime = 0, currentX = 0, currentY = 0;
    for(int i = 0; i < n; i++){
        int t, x, y;
        cin >> t >> x >> y;
        int steps = t - currentTime;
        int distX = getAbs(x - currentX);
        int distY = getAbs(y - currentY);

        currentTime = t;
        currentX = x;
        currentY = y;

        if(travelable){
            if(distX + distY > steps){
                travelable = false;
            }else{
                if((steps - (distX + distY)) % 2 == 1) travelable = false;
            }
        }
    }

    string ans = (travelable)? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

int getAbs(int x){
    return (x > 0)? x : -x;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,w;
	cin>>n>>w;
	vector<vector<ll> > dp(n+1,vector<ll>(w+1,0));
	for(int i=1;i<=n;i++)
	{
		ll weight,value;
		cin>>weight>>value;
		for(int j=1;j<=w;j++)
		{
			dp[i][j] = max(dp[i-1][j],j-weight>=0?dp[i-1][j-weight]+value:0);
		}
	}
	cout<<dp[n][w]<<endl;
}

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

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

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

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define FORE(i,c) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

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

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

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

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

///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////

int N, A, B;

int main(){
    scan(N,A,B);
    bool ans;
    if((B-A) % 2 == 0) ans = true;
    else ans = false;
    printf(ans ? "Alice\n" : "Borys\n");
}


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

int main() {
  long long N,ans=0;
  cin>>N;
  for(int i=1;i<=N;i++){
    if(!(i%3==0||i%5==0)){
      ans+=i;
      //cout<<i<<endl;
    }
  }
  cout<<ans;
  
  
}

Measured memory_bytes: 3652
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

po = input()[:-1]
ma = 0
co = 0

for a in po:
    if a == "I":
        co += 1
    else:
        co -= 1
    ma = max(ma,co)
print(ma)

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++) cin >> a.at(i);
  
  int max=0;
  int max_at=0;
  int alice=0;
  int bob=0;
  
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(a.at(j)>max){
        max=a.at(j);
        max_at=j;
      }
    }
    if(i%2==0) alice+=max;
    else bob+=max;
    a.at(max_at)=0;
    max=0;
    max_at=0;
  }
  cout << alice-bob << endl;
  return 0;
}

Measured memory_bytes: 256