akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var nw = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var list = new List<Tuple<int, int>>();
        for (int i = 0; i < nw[0]; i++)
        {
            var line = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            list.Add(new Tuple<int, int>(line[0], line[1]));
        }
        var dp = new long[nw[0] + 1][];
        for (int i = 0; i <= nw[0]; i++)
        {
            dp[i] = new long[nw[1] + 1];
        }
        for (int i = 1; i <= nw[0]; i++)
        {
            for (int j = 0; j <= nw[1]; j++)
            {
                long chk = (j - list[i - 1].Item1 >= 0) ? dp[i - 1][j - list[i - 1].Item1] + list[i - 1].Item2 : 0;
                dp[i][j] = Math.Max(dp[i - 1][j], chk);
            }
        }
        Console.WriteLine(dp[nw[0]][nw[1]]);
    }
}

Measured memory_bytes: 90688
n = gets.to_i
a, b = gets.split.map(&:to_i)
problems = gets.split.map(&:to_i)
easy = problems.select { |problem| problem <= a }
normal = problems.select { |problem| problem > a && problem <= b }
hard = problems.select { |problem| problem > b }
puts [easy.size, normal.size, hard.size].min


Measured memory_bytes: 14368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int n, d, x;
	cin >> n >> d >> x;
	vector<int> choco(n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> choco[i];
	}
	for (int i = 0; i < n; i++) {
		int count = 0;
		int temp = 1;
		while (temp <= d) {
			temp += choco[i];
			count++;
		}
		ans += count;
		
	}
	cout << x + ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math
import numpy as np

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

h_deg = (h*60 + m) * (math.pi*2 / 720)
m_deg = m * (math.pi*2 / 60)

a_x = a * math.cos(h_deg)
a_y = a * math.sin(h_deg)
b_x = b * math.cos(m_deg)
b_y = b * math.sin(m_deg)

x_vec = np.array([a_x-b_x,a_y-b_y])

print(np.linalg.norm(x_vec, ord=2))

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

int main()
{
    long long N, K, s=0;

    cin >> N >> K;


    for (int i = K; i <= N; ++i) {
        s += (N - i + 1) * i+1;
    }

    cout << (s+1) % 1000000007 << endl;

}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int N;
cin >> N;
vector<pair<int,int>> a(N);
for(int i = 0; i < N; i++){
    cin >> a.at(i).first;
    a.at(i).second=i+1;
}
sort(a.begin(),a.end());
for(int i = 0; i < N; i++){
    cout << a.at(i).second << endl;
}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
 
#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl
 
using namespace std;
using ll = long long;
 
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}
 
template <typename T>
istream& operator>>(istream& is, vector<T>& v)
{
    for (auto& e : v) {
        is >> e;
    }
    return is;
}
 
template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}
 
 
constexpr ll MOD = (ll)1e9 + 7LL;
 
template <typename T>
constexpr T INF = 1LL << 62;
 
 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll K;
    cin >> N >> K;
    vector<ll> w(N);
    vector<ll> d(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> d[i];
    }
 
    ll inf = 0;
    ll sup = INF<ll>;
    auto check = [=](const ll mid) {
        unsigned long long n = 0;
        for (int i = 0; i < N; i++) {
            n += (mid < w[i]) ? 0LL : (ll)((mid - w[i]) / d[i] + 1);
        }
        return n >= K;
    };
    while (inf < sup - 1) {
        const ll mid = (inf + sup) / 2;
        if (check(mid)) {
            sup = mid;
        } else {
            inf = mid;
        }
    }
    if (check(sup - 1)) {
        cout << sup - 1 << endl;
    } else {
        cout << sup << endl;
    }
    return 0;
}

Measured memory_bytes: 3456
import sys

x = int(input())
if x == 2:
	print(2)
	sys.exit()

import math

def Judge_PrimeNum(n):
    t = []
    d = math.ceil(n**(1/2))
    for i in range(2,d+1):
        if n%i == 0:
            t.append(i)
            
    if len(t) == 0:
        return -1
    else:
        return t

while True:
	ans = Judge_PrimeNum(x)
	if ans == -1:
		ans = x
		break
	else:
		x += 1
		continue

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
typedef long long ll;
using namespace std;
ll A[100000 + 7];
int k;
int main()
{
    cin >> k;
    for(int i = 1; i <= k; ++i) {
        scanf("%lld",&A[i]);
    }
    ll l = 2LL,r = 2LL;
    for(int i = k; i > 0; --i) {
        if(l%A[i]!=0) l = (l/A[i] + 1)*A[i];
        r = (r/A[i] + 1)*A[i] - 1;

        //cout << l << ' '<< r << endl;
        if(l > r) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << l << ' '<< r << endl;
    return 0;
}


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

using namespace std;

int main(void){
    string s;
    cin >> s;
    map<char,int> a;
    bool flag = true;
    for(int i = 0; i < 4; i++){
        if(a.count(s[i]) == 0){
            a.insert(make_pair(s[i], 1));
        }else{
            if(a.at(s[i]) == 1){
                a.at(s[i])++;
            }else{
                flag = false;
            }
        }
    }
    if(flag && a.size() == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF INT_MAX
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll
#define P pair<int,int>

string alpha="abcdefghijklmnopqrstuvwxyz";
vector<int> cnt[26];
vector<int> cnt_t[26];

signed main(){
  string s,t;
  cin>>s>>t;
  set<char> s_char;
  for(int i=0; i<s.size(); i++){
    for(int j=0; j<26; j++){
      if(s[i]==alpha[j]) cnt[j].push_back(i);
      if(t[i]==alpha[j]) cnt_t[j].push_back(i);
    }
  }
  
  for(int i=0; i<26; i++){
    if(cnt_t[i].size()>=2){
      for(int j=1; j<cnt_t[i].size(); j++){
        if(s[cnt_t[i][0]]!=s[cnt_t[i][j]]){
          cout<<"No"<<en;
          RE;
        }
      }
    }
    if(cnt[i].size()<2) continue;
    for(int j=1; j<cnt[i].size(); j++){
      if(t[cnt[i][0]]!=t[cnt[i][j]]){
        cout<<"No"<<en;
        RE;
      }
    }
  }
  
  cout<<"Yes"<<en;
}

Measured memory_bytes: 4616
#include <iostream>
#include <string>
#include <cmath>
 
int main(void){
  std::string A, B;
  std::cin >> A >> B;
  int A_range_min = std::ceil((double)(std::stoi(A) * 100) / 8.);
  int A_range_max = std::floor((double)((std::stoi(A)+1) * 100) / 8.);
  int B_range_min = std::ceil((double)(std::stoi(B) * 100) / 10.);
  int B_range_max = std::floor((double)((std::stoi(B)+1) * 100) / 10.);
  int min = std::max(A_range_min, B_range_min);
  int max = std::min(A_range_max, B_range_max);
  if (min >= max || max <= 0)
    std::cout << "-1";
  else
    std::cout << min;
  return 0;
}

Measured memory_bytes: 256
x,n = map(int, input().split())
if n == 0:
    print(x)
    exit()
P = list(map(int, input().split()))
P.sort()
if x in P:
    for i in range(1,101):
        if not (x - i in P):
            print(x-i)
            exit()
        elif not (x + i in P):
            print(x+i)
            exit()
else:
    print(x)

Measured memory_bytes: 9204
a,b,x = map(int,input().split())
import math

if (x <= a*a*b/2):
    theta = math.atan(a*b*b/(2*x)) *180/math.pi
else:
    theta = math.atan(2*(a*a*b-x)/(a*a*a)) * 180/math.pi
print(theta)



Measured memory_bytes: 2940
#include<stdio.h>
#define MAX 1000001
#define INF 20000000

typedef struct{
  int A;
  char C;
}Card;


Card A[MAX];
Card B[MAX];

Card L[MAX/2+2],R[MAX/2+2];

void quickSort(int,int);
int partition(int,int);

void merge(int,int,int,int);
void mergeSort(int,int,int);

int main(){
  int i;
  int n;
  int c;
  int flag=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%c",&c);
    scanf("%c%d",&A[i].C,&A[i].A);
    B[i].A=A[i].A;
    B[i].C=A[i].C;
  }

  quickSort(0,n-1);
  mergeSort(n,0,n);
  
  for(i=0;i<n;i++){
    if(B[i].A==A[i].A&&B[i].C!=A[i].C){
      flag=0;
      break;
    }
  }

  if(flag==1)printf("Stable\n");
  else if(flag==0)printf("Not stable\n");

  for(i=0;i<n;i++)printf("%c %d\n",A[i].C,A[i].A);
  return 0;
}

int partition(int p,int r){
  int i,j;
  int x;
  Card t;

  x=A[r].A;
  i=p-1;
  
  for(j=p;j<r;j++){
    if(x>=A[j].A){
      t=A[j];
      A[j]=A[i+1];
      A[i+1]=t;
      i++;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
 
  return i+1;
}

void quickSort(int p,int r){
  int q;
  
  if(p<r){
    q=partition(p,r);
    quickSort(p,q-1);
    quickSort(q+1,r);
  }
}

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

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

  for(i=0;i<n1;i++) L[i]=B[left+i];
  for(i=0;i<n2;i++) R[i]=B[mid+i];

  L[n1].A=INF;
  R[n2].A=INF;

  i=0;
  j=0;

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

void mergeSort(int n,int left,int right){
  int mid;

  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(n,left,mid);
    mergeSort(n,mid,right);
    merge(n,left,mid,right);
  }
}

Measured memory_bytes: 11628
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && a == c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
#define llint long long

using namespace std;

llint n, m;
vector<llint> vec[100005];
priority_queue<llint> Q;

int main(void)
{
	cin >> n >> m;
	llint a, b;
	for(int i = 1; i <= n; i++){
		cin >> a >> b;
		vec[a].push_back(b);
	}
	
	llint ans = 0;
	for(int i = 1; i <= m; i++){
		for(int j = 0; j < vec[i].size(); j++) Q.push(vec[i][j]);
		if(Q.size()){
			ans += Q.top();
			Q.pop();
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

#define int long long int
#define REDBULL ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define endl "\n"

// bool isPerfectSquare(long double x) 
// {   
  
//   long double sr = sqrt(x);
//   return ((sr - floor(sr)) == 0); 
// } 
// bool isPrime(int n) 
// { 
//     // Corner case 
//     if (n <= 1) 
//         return false; 
  
//     // Check from 2 to n-1 
//     for (int i = 2; i < n; i++) 
//         if (n % i == 0) 
//             return false; 
  
//     return true; 
// } 
  
int32_t main()
{
	REDBULL
	int n,temp=0;
	cin>>n;
	for(int i=1;i<=9;i++)
	{
		for(int j=i;j<=9;j++)
		{
			if(j*i==n)
			{
				temp=1;
				cout<<"Yes"<<endl;
				break;
			}
		}
		if(temp==1)
		break;
	}
	if(temp==0)
	{
		cout<<"No"<<endl;;
	}
	
    return 0;
}

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

int G[MAX_N][MAX_N];
int n,m;
bool visited[MAX_N];

int dfs(int u, bool visited2[MAX_N]){
    bool flag = true;
    for(int i = 0; i < n; i++){
        if( !visited2[i] ){
            flag = false;
            break;
        }
    }
    if(flag) return 1;
    
    int res = 0;
    for(int v = 0; v < n; v++ ){
        if( G[u][v] == 0 )continue;
        if( !visited[v] ){
            visited2[v] = true;
            res += dfs( v, visited2);
            visited2[v] = false;
        }
    } 
    visited2[u] = true;
    return res;
}

int main(){
    cin>> n >> m;
    for(int i=0; i<m; i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a][b] = G[b][a] = 1;
    }
    
    visited[0] = true;
    int ans = dfs(0,visited);

    cout<< ans <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

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

   int mae = ctoi(S[0]) * 10 + ctoi(S[1]);
   int ato = ctoi(S[2]) * 10 + ctoi(S[3]);

   if (1 <= mae && mae <= 12 && 1 <= ato && ato <= 12) cout << "AMBIGUOUS" << endl;
   else if (1 <= mae && mae <= 12) cout << "MMYY" << endl;
   else if (1 <= ato && ato <= 12) cout << "YYMM" << endl;
   else cout << "NA" << endl;

     
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
long long n,m;
signed main()
{
	scanf("%lld%lld",&n,&m);int ans(0);
	for(;n<=m;ans++){n<<=1;}
	printf("%d",ans);
	return putchar(10),0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
for i in range(1,3501):
    for j in range(1,3501):
        if not (4*i*j - n*j - n*i):
            continue
        tmp = (n*i*j) / (4*i*j - n*j - n*i)
        if tmp.is_integer() and tmp > 0:
            print(i,j,int(tmp))
            quit()

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

using namespace std;
#define int long long
int a,b,c;


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

	cin >> a >> b >> c;
	if (abs(b-c) <= 1)
	{
		cout << b+c;
		return 0;
	}
	int res = 0;
	int cur = max(b,c) - min(b,c) - 1;
	res += 2*(min(b,c))+1;
	res += min(cur,a);
	cout << res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }
 
    // 素数である
    return 1;
}


 
int main(){
   lint N;
    lint ans;
   cin>>N;
   rep(i,sqrt(N)+1){
       if(i==0)continue;
        if(N%i==0)ans=N/i;
   }
    cout<<(int)log10(ans)+1;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int start_apple[200],start_peach[200],flag1=0,flag2=0,judge1=0,judge2=0,i,j,k;
	char alternative[]="pop'n";
	char apple[]="apple";
	char peach[]="peach";
	char buf[1001];
	fgets(buf,1000,stdin);
	for(i=0;i<996;i++){
		for(j=0;j<5;j++){
			if(buf[i+j]==apple[j]){judge1++;}
			if(buf[i+j]==peach[j]){judge2++;}
		}
		if(judge1==5){start_apple[flag1]=i; flag1++; judge1=0; judge2=0;}
			else if(judge2==5){start_peach[flag2]=i; flag2++; judge1=0; judge2=0;}
			else{judge1=0; judge2=0;}
	}
		for(j=0;j<5;j++){
			for(k=0;k<flag1;k++){
				if(start_apple[0]==0&&flag1==0)break;
				buf[start_apple[k]+j]=peach[j];
			}
			for(k=0;k<flag2;k++){
				if(start_peach[0]==0&&flag2==0)break;
				buf[start_peach[k]+j]=apple[j];
			}
		}
		buf[1000]='\n';
	printf("%s",buf);
	return 0;
}

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



int main()
{
        ll N;
        cin >> N;

        ll ans = 1;
        rep(i, 1, N+1) {
                if (i * i > N) break;
                ans = i;
        }
        cout << ans*ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    double a,b;
    
    cin>>a;
    cin>>b;
    
    if(a>b){
        cout<<"GREATER"<<endl;
    }
    if(a<b){
        cout<<"LESS"<<endl;
    }
    if(a==b){
        cout<<"EQUAL"<<endl;
    }
    return 0;
    
}


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

using namespace std;

#define N 300000

int n,a[N],b[N];

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	for (int i=1;i<=n;++i){
		int k=lower_bound(b+1,b+n+1,a[i])-b;
		if (k<=n/2) printf("%d\n",b[n/2+1]);
		else printf("%d\n",b[n/2]);
	}
	
	return 0;
}
			

Measured memory_bytes: 3712
S = input()
if len(S) % 2 == 0:
    ans = 0
    A = len(S)//2
    S1 = S[A:]
    S2 = S[:A]
    S1= S1[::-1]
    for i in range(len(S1)):
        if S1[i] != S2[i]:
            ans+=1
else:
    ans = 0
    S1 = S[len(S)//2+1:]
    S2 = S[:len(S)//2]
    S1 = S1[::-1]
    for i in range(len(S1)):
        if S1[i] != S2[i]:
            ans += 1
print(ans)

Measured memory_bytes: 38384
import java.io.*;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n=Integer.parseInt(br.readLine());
        String[] str=br.readLine().split(" ");
        int[] S=new int[n];
        for(int i=0;i<n;i++)
            S[i]=Integer.parseInt(str[i]);
         
        int q=Integer.parseInt(br.readLine());
        str=br.readLine().split(" ");
        int[] T=new int[q];
        for(int i=0;i<q;i++)
            T[i]=Integer.parseInt(str[i]);
         
        System.out.println(method(S,T));
         
 
    }
    static int method(int[] s,int[] t){
        if(s.length<t.length){
            int[] tmp=s;
            s=t;
            t=tmp;
        }
        
        int count=0;
        for(int i=0;i<t.length;i++){
        	if(s[s.length/2]==t[i]){count++;continue;}
        	else if(s[s.length/2]<t[i]){
        		for(int j=s.length/2;j<s.length;j++)
        			if(t[i]==s[j]){count++;break;}}
        	
        	else
        		for(int j=0;j<s.length/2;j++)
        			if(t[i]==s[j]){count++;break;}
        	
        
                   
            
        }
         
        return count;
    }
 
}

Measured memory_bytes: 42448
#![allow(unused_imports)]
#![allow(dead_code)]

use std::collections::*;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let p: Vec<usize> = sc.vec(n);
    let mut uf: UnionFind = UnionFind::new(n);
    for _ in 0..m {
        let x: usize = sc.read();
        let y: usize = sc.read();
        uf.unite(x - 1, y - 1);
    }
    let mut ans = 0;
    for i in 0..n {
        if uf.is_same(i, p[i] - 1) {
            ans += 1;
        }
    }
    println!("{}", ans);
}

#[derive(Debug, Copy, Clone)]
enum UFdata {
    Child(usize),
    Root(usize),
}
struct UnionFind {
    data: Vec<UFdata>,
}
impl UnionFind {
    pub fn new(n: usize) -> Self {
        UnionFind {
            data: vec![UFdata::Root(1); n],
        }
    }
    fn root(&mut self, x: usize) -> usize {
        match self.data[x] {
            UFdata::Child(p) => {
                let res = self.root(p);
                self.data[x] = UFdata::Child(res);
                res
            }
            UFdata::Root(_) => x,
        }
    }
    pub fn size(&mut self, x: usize) -> usize {
        match self.data[x] {
            UFdata::Root(m) => m,
            UFdata::Child(_) => {
                let r = self.root(x);
                self.size(r)
            }
        }
    }
    pub fn unite(&mut self, x: usize, y: usize) -> bool {
        let (mut u, mut v) = (self.root(x), self.root(y));
        if u == v {
            false
        } else {
            if self.size(u) < self.size(v) {
                std::mem::swap(&mut u, &mut v);
            }
            self.data[u] = UFdata::Root(self.size(u) + self.size(v));
            self.data[v] = UFdata::Child(u);
            true
        }
    }
    pub fn is_same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

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

using namespace std;

using ll = long long;


int main(){
  ll A, B, K;
  cin >> A >> B >> K;
  
  if(A>=K){
    cout << A-K << " " << B << endl; 
    return 0;
  }
  
  if(A<K){
    K = K-A;
    
    if(B<=K){
      cout << 0 << " " << 0 << endl;
    }else{
      cout << 0 << " " << B-K << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3576
from fractions import gcd
import sys
input = sys.stdin.readline
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    A = list(map(int, input().split()))

    l = A[0]
    for i in range(1, N):
        l = l * A[i] // gcd(l, A[i])

    print(sum([l // a for a in A]) % MOD)


if __name__ == '__main__':
    main()


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    long long N;
    string S;
    long long r = 0, g = 0, b = 0;
    int i,j,k;
    cin >> N;
    cin >> S;
    rep(i,N) {
        if (S[i] == 'R') {
            r++;
        } else if (S[i] == 'G') {
            g++;
        } else {
            b++;
        }
    }
    long long ans = r*g*b;
    for (i = 0; i < N; i++) {
        for (j = i+1; j < N; j++) {
            k = 2*j-i;
            if (k >= N) break;
            if ( S[i]!=S[j] && S[j]!=S[k] && S[k]!=S[i] ) ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;

  vector<int> ans(n);
  vector<int> a(m);
  vector<int> b(m);
  for(int i=0; i<m; i++){
    cin >> a[i];
    cin >> b[i];
    ans[a[i]-1]++;
    ans[b[i]-1]++;
  }
  for(int i=0; i<n; i++){
    cout << ans[i] << endl;
  }
}

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

Measured memory_bytes: 256
n,y=map(int,input().split())
flag=False
if 10000*n<y:
    print('-1 -1 -1')
elif 10000*n==y:
    print(n,0,0)
else:
    for i in range(n+1):
        if flag:
            break
        for j in range(n-i+1):
            if 10000*i+5000*j+1000*(n-i-j)==y:
                print(i,j,n-i-j)
                flag=True
                break
    else:
        print('-1 -1 -1')


Measured memory_bytes: 3060
n = int(input())
p = list(map(int, input().split()))

ans=0

for i in range(1, n-1):
    if p[i] <= p[i+1] and p[i-1] <= p[i]:
        ans += 1
    elif p[i+1] <= p[i] and p[i] <= p[i-1]:
        ans += 1

print(ans)

Measured memory_bytes: 3060
p = 10**9+7
N,M = map(int,input().split())
a = 1
for i in range(2,N+1):
    a = (a*i)%p
b = 1
for i in range(2,M+1):
    b = (b*i)%p
if M==N:
    n = (2*a*b)%p
elif M==N-1 or N==M-1:
    n = (a*b)%p
else:
    n = 0
print(n)

Measured memory_bytes: 39856
from itertools import permutations
class WarshallFloyd:
    def __init__(self,n):
        self.n = n
        self.inf = float('inf')
        self.d = [[self.inf for _ in range(n)] for _ in range(n)]
        for i in range(self.n):
            self.d[i][i] = 0
    def register(self,v1,v2,l,multiple=True):
        self.d[v1][v2] = l
        if multiple:
            self.d[v2][v1] = l
    def solve(self):
        for i in range(self.n):
            for j in range(self.n):
                for k in range(self.n):
                    self.d[j][k] = min(self.d[j][k],self.d[j][i]+self.d[i][k])
        return self.d
N,M,R = map(int,input().split())
v = list(map(int,input().split()))
Edges = [[] for i in range(N)]
W = WarshallFloyd(N)
for i in range(M):
    a,b,c = map(int,input().split())
    a,b = a-1,b-1
    W.register(a,b,c)
D = W.solve()
a = permutations(v,R)
ans = 100000000000
for e in a:
    value = 0
    for e1,e2 in zip(e[:-1],e[1:]):
        value += D[e1-1][e2-1]
    ans = min(ans,value)
print(ans)

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll ans = 0;//左から順にたおそう
    rep(i,n) {
        int first = min(a[i], b[i]);
        a[i]-=first; b[i]-=first; ans+=first;

        int second = min(a[i+1], b[i]);
        ans+=second; a[i+1]-=second; b[i]-=second;
    }
    cout << ans << endl;
    return 0;
}

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

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

    s += s;
    int n = (int)s.size();
    vector<vector<int>> cnt(26);
    for (int i = 0; i < n; i++) {
        cnt[s[i] - 'a'].push_back(i + 1);
    }

    long long res = 0;
    int now = 0;
    for (int i = 0; i < t.size(); i++) {
        int toFind = t[i] - 'a';
        if (cnt[toFind].empty()) {
            cout << -1 << endl;
            return 0;
        }

        now = *upper_bound(cnt[toFind].begin(), cnt[toFind].end(), now);
        if (now > n / 2) {
            now -= n / 2;
            res += n / 2;
        }
    }
    res += now;

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

Measured memory_bytes: 1784
import java.util.Scanner;

public class Main {

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

		for(int i=0;i<m;i++) {
			a[i]=scan.nextInt();
			b[i]=scan.nextInt();
		}
		int[] count = new int[n];
		for(int i=1;i<n+1;i++) {
			//都市iが配列a,bの中に何回登場するかカウントすればよい
			for(int l=0;l<m;l++) {
				if(a[l]==i) {
					count[i-1]++;
				}
				if(b[l]==i) {
					count[i-1]++;
				}
			}
		}

		for(int i=0;i<n;i++) {
			System.out.println(count[i]);
		}
	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <queue>
#include <vector>
#include <functional>

using namespace std;

const int INF = 10000000;

int city[101][101];

int solve( int s, int d, int c, int n ){
	int dist[11][101];
	int history[11][101];

	for( int i = 0;i < 11;i++ ){
		for( int j = 1;j < 101;j++ ){
			dist[i][j] = INF;
			history[i][j] = 0;
		}
	}


	dist[c][s] = 0;

	typedef pair<int,int> data;
	typedef pair<int,data> graph;
	priority_queue<graph,vector<graph>,greater<graph> > q;

	q.push( graph( 0, data( s, c ) ) );

	while( !q.empty() ){
		graph a = q.top();
		int u = a.second.first;
		int uc = a.second.second;
		q.pop();
		history[uc][u] = 1;

		for( int i = 1;i <= n;i++ ){

			if( history[uc][i] ) continue;
			if( dist[uc][i] > dist[uc][u] + city[u][i] ){
				dist[uc][i] = dist[uc][u] + city[u][i];
				q.push( graph( dist[uc][i], data( i, uc ) ) );
			}

			if( uc && dist[uc - 1][i] > dist[uc][u] + city[u][i] / 2 ){
				dist[uc - 1][i] = dist[uc][u] + city[u][i] / 2;
				q.push( graph( dist[uc - 1][i], data( i, uc - 1 ) ) );
			}
		}
	}
	int answer = INF;
	for( int i = 0;i < 11;i++ ) answer = min( dist[i][d], answer );
	return answer;

}

int main(int argc, char const* argv[])
{
	int c,n,m,s,d;

	while( cin >> c >> n >> m >> s >> d && c != 0 ){
		int a,b,f;
		for( int i = 1;i < 101;i++ ){
			for( int j = 1;j < 101;j++ ){
				city[i][j] = INF * 2;
			}
		}
		for( int i = 0;i < m;i++ ){
			cin >> a >> b >> f;
			city[a][b] = f;
			city[b][a] = f;
		}

		cout << solve( s, d, c, n ) << endl;
	}

	return 0;
}

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

// よく愛用しています
bool chmin(int &a, int b) { if (a > b) {a = b; return true; } else return false; }

const int MAX_N = 110000;
int dp[MAX_N]; // dp[i] が i についての答え

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

	// 初期化
	for (int i = 0; i < MAX_N; ++i) dp[i] = N; // INF
	dp[0] = 0;
	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
	que.push(make_pair(0, 0));

	// Dijkstra 法
	while (!que.empty()) {
		int cur = que.top().first; // 現在の距離
		int v = que.top().second; // 現在のノード
		que.pop();

		// Dijkstra 法でよくやる枝刈り
		if (cur > dp[v]) continue;

		for (int pow6 = 1; v + pow6 <= N; pow6 *= 6) {
			int nv = v + pow6; // 遷移先
			if (chmin(dp[nv], dp[v] + 1)) que.push(make_pair(dp[nv], nv));
		}
		for (int pow9 = 1; v + pow9 <= N; pow9 *= 9) {
			int nv = v + pow9; // 遷移先
			if (chmin(dp[nv], dp[v] + 1)) que.push(make_pair(dp[nv], nv));
		}
	}

	cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define rep(i, n) for(int i=0; i<(int)(n); i++)

int pt[300000], sum[300000];

int main() {
    for(int i=2; i<300000; i++) if(pt[i]==0) {
        if(i<10000) for(int j=i*i; j<300000; j+=i) pt[j] = i;
    }
    rep(i, 280000) sum[i+1] = sum[i] + (pt[i]==0);
    for(;;) {
        int n;
        scanf("%d", &n);
        if(n==0) return 0;
        printf("%d\n", sum[2*n+1]-sum[n+1]);
    }
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N = int(input())
G = [[] for _ in range(N+1)]
for _ in range(N-1):
    A, B = map(int, input().split())
    G[A].append(B)
    G[B].append(A)
K = int(input())
num = [-1] * (N+1)
for _ in range(K):
    V, P = map(int, input().split())
    num[V] = P

# check parity
stack = [1]
depth = [-1] * (N+1)
depth[1] = 0
while stack:
    v = stack.pop()
    for c in G[v]:
        if depth[c] == -1:
            depth[c] = depth[v] + 1
            stack.append(c)
parity = [set(), set()]
for i in range(1, N+1):
    if num[i] != -1:
        parity[depth[i] % 2].add(num[i] % 2)
if len(parity[0]) == 2 or len(parity[1]) == 2:
    print('No')
    exit()

INF = 10**9
lb = [-INF] * (N+1)
ub = [INF] * (N+1)

def dfs1(v, p):
    for c in G[v]:
        if c == p:
            continue
        dfs1(c, v)
        lb[v] = max(lb[v], lb[c] - 1)
        ub[v] = min(ub[v], ub[c] + 1)
    if num[v] != -1:
        lb[v] = ub[v] = num[v]

dfs1(1, 0)

def dfs2(v, p):
    for c in G[v]:
        if c == p:
            continue
    for c in G[v]:
        if c == p:
            continue
        lb[c] = max(lb[c], lb[v] - 1)
        ub[c] = min(ub[c], ub[v] + 1)
        dfs2(c, v)

dfs2(1, 0)

for i in range(1, N+1):
    if lb[i] > ub[i]:
        print('No')
        exit()

print('Yes')

def dfs3(v, p):
    for c in G[v]:
        if c == p:
            continue
        if lb[c] <= num[v] - 1:
            num[c] = num[v] - 1
        else:
            num[c] = num[v] + 1
        dfs3(c, v)

num[1] = lb[1]
dfs3(1, 0)

print(*num[1:], sep='\n')

Measured memory_bytes: 233768
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    sort_A = sorted(A)
    sort_B = sorted(B)
    sort_C = sorted(C)
    cnt = 0
    for b in sort_B:
        a = bisect.bisect_left(sort_A, b)
        c = N - bisect.bisect_right(sort_C, b)
        cnt += a * c

    print(cnt)

main()

Measured memory_bytes: 107108
#include <stdio.h>

int main(){
	char a[1000];
	int i;
	scanf("%[^\n]", a);
	for(i=0;i<1000;i++)
	{
		if(a[i]>=97 && a[i]<=122)
		{
			a[i]=a[i]-32;
		}
	}
	printf("%s\n", a);
	return 0;
}

Measured memory_bytes: 520
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
X,Y,A,B,C = map(int, input().split())
#L = [int(input()) for i in range(N)]
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
p=P[:X]
q=Q[:Y]


ans=0
countp=0
countq=0
countr=0
count=0
r=0
pt=0
qt=0
lR=len(R)
#print(p)
#print(q)
while count<X+Y:
    if countr<lR and r==0:
        r=R[countr]
        countr+=1


    if countp<X and pt==0:
        pt=p[countp]
        countp+=1
    

    if countq<Y and qt==0:
        qt=q[countq]
        countq+=1



    #print(pt,qt,r)
    ans+=max(r,pt,qt)
    if r>=pt and r>=qt:
        r=0
    elif pt>=r and pt>=qt:
        pt=0
    else:
        qt=0
    
    count+=1


print(ans)

Measured memory_bytes: 100276
#include <stdio.h>

#define N 500
#define M 500

int main() {
	static int aa[N][M], ii[N * M][4];
	int n, m, i, j, cnt;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			scanf("%d", &aa[i][j]), aa[i][j] %= 2;
	cnt = 0;
	for (i = 0; i < n; i++)
		for (j = 0; j < m - 1; j++)
			if (aa[i][j]) {
				aa[i][j] ^= 1, aa[i][j + 1] ^= 1;
				ii[cnt][0] = i;
				ii[cnt][1] = j;
				ii[cnt][2] = i;
				ii[cnt][3] = j + 1;
				cnt++;
			}
	j = m - 1;
	for (i = 0; i < n - 1; i++)
		if (aa[i][j]) {
			aa[i][j] ^= 1, aa[i + 1][j] ^= 1;
			ii[cnt][0] = i, ii[cnt][1] = j;
			ii[cnt][2] = i + 1, ii[cnt][3] = j;
			cnt++;
		}
	printf("%d\n", cnt);
	for (i = 0; i < cnt; i++)
		printf("%d %d %d %d\n", ii[i][0] + 1, ii[i][1] + 1, ii[i][2] + 1, ii[i][3] + 1);
	return 0;
}


Measured memory_bytes: 6784
module S = Set.Make(String)

let words str = Str.split (Str.regexp " ") str

let () =
  let _ = read_int () in
  let s = read_line () |> words |> S.of_list in
  let _ = read_int () in
  let t = read_line () |> words in
  List.fold_left
    (fun acc e -> match S.mem e s with true -> acc+1 | false -> acc)
    0 t
  |> Printf.printf "%d\n"

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

int main() {
    
    string s;
    cin >> s;
    int left= 0, right = 0;
    int cnt = 0;
    while (left < s.size()) {
        if (s[right] == 'A' || s[right] == 'T' || s[right] == 'G' || s[right] ==  'C') {
            if (right+1 <= s.size())
                right++;
            cnt = max(cnt, right - left);
        }
        else {
            right++;
            left = right;
        }
    }
    cout << cnt << '\n';
    
}


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

using namespace std;

struct Restaurant
{
	string name;
	int index;
	int value;
};

bool Compare(Restaurant a, Restaurant b)
{
	if (a.name == b.name)
	{
		return a.value > b.value;
	}

	return a.name < b.name;
}

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

	vector<Restaurant> arr(n);
	for (int i = 0; i < n; i++)
	{
		string name;
		int value;
		cin >> name >> value;

		arr[i] = { name, i + 1, value };
	}

	sort(arr.begin(), arr.end(), Compare);

	for (auto it : arr)
	{
		cout << it.index << endl;
	}

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll v;
ll a[5][1005];
ll b[1005*1005];
ll c[1005*1005];
int main(){
	cin>>n>>v;
	for(int i=0;i<4;i++)for(int j=0;j<n;j++)cin>>a[i][j];
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)b[i*n+j]=a[0][i]+a[1][j],c[i*n+j]=a[2][i]+a[3][j];
	sort(b,b+n*n);sort(c,c+n*n);
	ll ans=0;
	for(int i=0;i<n*n;i++){
		pair<ll*,ll*>res=equal_range(c,c+n*n,v-b[i]);
		ans+=res.second-res.first;
	}
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 18808
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n, a[300010];
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= 3 * n; i ++)
		scanf("%d", &a[i]);
	sort(a + 1, a + 3 * n + 1);
	ll ans = 0;
	int now = 3 * n - 1;
	while(n --)
	{
		ans += (ll)a[now];
		now -= 2;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
	char op;
	int a, b;
	while (1)
	{
		cin >> a >> op >> b;
		if (op == '?')break;

		if (op == '+'){
			cout << a + b << endl;
		}
		else if (op == '-'){
			cout << a - b << endl;
		}
		else if (op == '*'){
			cout << a*b << endl;
		}
		else if (op == '/'){
			cout << a / b << endl;
		}
		else{

		}


	}


	return 0;
}

Measured memory_bytes: 3080
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0): # 四捨五入
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def round_up(a): # 切り上げ
    return int(a + 0.9)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n,m = map(int,input().split())
    if n == m:
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38636
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
signed main(){
    bool ans=false;
    int n;
    cin>>n;
    int p[50];
    int q[50];
    for(int i=0;i<n;i++){
        cin>>p[i];
        q[i]=p[i];
    }
    sort(q,q+n);
    bool a=true;
    for(int i=0;i<n;i++){
        if(q[i]!=p[i])a=false;
    }
    if(a==true)ans=true;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            bool t=true;
            for(int k=0;k<n;k++){
                int s;
                if(k==i){
                    s=p[j];
                }else if(k==j){
                    s=p[i];
                }else {
                    s=p[k];
                }
                if(q[k]!=s)t=false;
            }
            if(t==true){
                ans=true;
            }
        }
    }
    if(ans==true)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

int main(){

    int n;
    cin >> n;

    vector<pair<int,int> > ab(n),cd(n);

    rep(i,n) cin >> ab[i].first >> ab[i].second;

    rep(i,n) cin >> cd[i].second >> cd[i].first;

    sort(ab.begin(),ab.end(),greater<pair<int,int> >());
    sort(cd.begin(),cd.end());

    int ans=0;
    rep(i,n){
        rep(j,ab.size()){
            if(ab[j].first<cd[i].second&&ab[j].second<cd[i].first){
                ans++;
                ab.erase(ab.begin()+j);
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    //1がplus、0がminusとみなした場合の絶対値
    vector<vector<vector<vector<ll>>>> plusMinusAbs(2, vector<vector<vector<ll>>>(2, vector<vector<ll>>(2, vector<ll>(0))));
    for (int i = 0; i < N; i++)
    {
        ll x, y, z;
        cin >> x >> y >> z;
        plusMinusAbs.at(1).at(1).at(1).push_back(x + y + z);
        plusMinusAbs.at(1).at(1).at(0).push_back(x + y - z);
        plusMinusAbs.at(1).at(0).at(1).push_back(x - y + z);
        plusMinusAbs.at(1).at(0).at(0).push_back(x - y - z);
        plusMinusAbs.at(0).at(1).at(1).push_back(-1 * x + y + z);
        plusMinusAbs.at(0).at(1).at(0).push_back(-1 * x + y - z);
        plusMinusAbs.at(0).at(0).at(1).push_back(-1 * x - y + z);
        plusMinusAbs.at(0).at(0).at(0).push_back(-1 * x - y - z);
    }
    ll answer = 0;
    for (int i = 0; i <= 1; i++)
    {
        for (int j = 0; j <= 1; j++)
        {
            for (int k = 0; k <= 1; k++)
            {
                sort(plusMinusAbs.at(i).at(j).at(k).begin(), plusMinusAbs.at(i).at(j).at(k).end(), greater<ll>());
                ll tmpAnswer = 0;
                for (int l = 0; l < M; l++)
                {
                    tmpAnswer += plusMinusAbs.at(i).at(j).at(k).at(l);
                }
                answer = max(answer, tmpAnswer);
            }
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 384
N=int(input())
W=list(map(int,input().split()))
total=0
total_sub=0
t=[]
for i in range(N):
    total+=W[i]
for i in range(N):
    total_sub+=W[i]
    t.append(abs(total-2*total_sub))
t=sorted(t)
print(t[0])

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int n,q;
main()
{
	cin>>n>>q;
	vector<vector<int> >a(n);
	for(int i=0;i<q;i++)
	{
		int c;cin>>c;
		if(c==0)
		{
			int t,x;cin>>t>>x;
			a[t].push_back(x);
		}
		else if(c==1)
		{
			int p;cin>>p;int f=0;
			for(int j:a[p])cout<<(f++?" ":"")<<j;
			cout<<endl;
		}
		else
		{
			int t;cin>>t;
			a[t].clear();
		}
	}
}


Measured memory_bytes: 5764
#include<iostream>
using namespace std;
int main(){
  int r,c,sr,sc;
  cin >> r >> c;
  sr=0;
  sc=0;
  int hyou[101][101];
  
  
  for(int i=0;i<r+1;i++){
    for(int j=0;j<c+1;j++){
      hyou[i][j]=0;}
  }
    
    for(int i=0;i<r;i++){
      for(int j=0;j<c;j++){
	cin >> hyou[i][j];
      }}
      for(int i=0;i<r;i++){
      for(int j=0;j<c;j++){
	hyou[i][c]+=hyou[i][j];
      
      }
      }
  

      for(int i=0;i<c+1;i++){
	for(int j=0;j<r;j++){
	  hyou[r][i]+=hyou[j][i];
	}}

      for(int i=0;i<r+1;i++){
	for(int j=0;j<c+1;j++){
	  cout << hyou[i][j] ;
	  if(j==c){
	    cout << endl ;}
	  else{
	    cout << " " ;}
	}}
	  



      return 0;
    }

Measured memory_bytes: 1196