akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int j(int* a,int* b){
	return *a-*b;
}
int main(){
	int t,h;
	int a[3];
	t=h=0;
	while(~scanf("%d,%d,%d",&a[0],&a[1],&a[2])){
	//	qsort(a,3,sizeof(int),j);
		if(a[2]*a[2]==a[0]*a[0]+a[1]*a[1]){
			t++;
		}else if(a[1]==a[0]){
			h++;
		}
	}
	printf("%d\n%d\n",t,h);
	return 0;
}

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

int BubbleSort(int A[],int N){
	bool flag=1;
	int i;
	int j;
	int sw=0;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = N - 1; j >= i+1; j--) {
			if (A[j - 1] > A[j]) {
				swap(A[j - 1], A[j]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main() {
	int N;
	int A[100];
	int sw;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	
	sw = BubbleSort(A, N);

	for (int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
		cout << endl;
		cout << sw << endl;
	}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

int main(){fastio
    ll n;cin>>n;
    ll a[n][n];
    rep(i,0,n-1){
        rep(j,0,n-2){
            cin>>a[i][j];a[i][j]--;
        }
    }
    ll pos[n];memset(pos,0,sizeof(pos));
    ll ans=0;
    while(1){
        bool flag=true;
        set<ll>v;
        rep(i,0,n-1){
            if(pos[i]>=n-1)continue;
            ll opo=a[i][pos[i]];
            if(pos[opo]<=n-2&&a[opo][pos[opo]]==i){
                v.insert(i);
                v.insert(opo);
                flag=false;
            }
        }
        for(auto x:v){
            pos[x]++;
        }
        ans++;
        if(flag)break;
        //cout<<ans<<endl;
    }
    rep(i,0,n-1){
        if(pos[i]!=n-1){
            cout<<-1<<endl;return 0;
        }
    }
    cout<<ans-1<<endl;
    
    
    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    cout << abs(a[0]-a[n-1]) << endl;

    return 0;
}

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

int main()
{
    char ms[26], mt[26];
    string s,t;
    cin>>s>>t;
    bool check;
    for(int i=0; i<26; i++)
    {
        ms[i]='-';
        mt[i]='-';
    }
    int idx;
    check=true;
    for(int i=0; i<s.length(); i++)
    {
        idx=(int)s[i]-(int)'a';
        if(ms[idx]!='-'&&ms[idx]!=t[i])
        {
            check=false;
            break;
        }
        else ms[idx]=t[i];
        idx=(int)t[i]-(int)'a';
        if(mt[idx]!='-'&&mt[idx]!=s[i])
        {
            check=false;
            break;
        }
        else mt[idx]=s[i];
        
    }
    
    if(check) cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 776
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        String s = stdin.next();
        
        Deque<Tuple> stack = new ArrayDeque<>();
        stack.push(new Tuple("", s));
        long ans = 0;
        while (!stack.isEmpty()) {
            Tuple t = stack.removeFirst();
            
            if (t.rest.isEmpty()) {
                ans += Arrays.stream(t.form.split("@")).mapToLong(Long::parseLong).sum();
            } else {
                if (!t.form.isEmpty()) {
                    stack.addFirst(new Tuple(t.form + "@" + t.rest.substring(0, 1), t.rest.substring(1)));
                }
                stack.addFirst(new Tuple(t.form + t.rest.substring(0, 1), t.rest.substring(1)));
            }
        }
        
        System.out.println(ans);
    }
    
    public static class Tuple {
        private String form;
        private String rest;
        
        public Tuple(String form, String rest) {
            this.form = form;
            this.rest = rest;
        }
        
    }
}

Measured memory_bytes: 28756
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

ll dp[50];

int main() {
  int n;
  cin >> n;
  dp[0] = dp[1] = 1;
  FOR(i, 2, n+1) dp[i] =  dp[i-1] + dp[i-2];
  cout << dp[n] << endl;
  
  return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}

int main(){
  int r;
  cin>>r;
  if(r<1200)cout<<"ABC"<<endl;
  else if(r<2800)cout<<"ARC"<<endl;
  else cout<<"AGC"<<endl;
    
    
  return 0;
}


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

void printCards(const std::vector<std::pair<char, int>> &cards) {
  auto len = cards.size();
  for (auto i=0; i<len-1; ++i)
    std::cout << cards[i].first << cards[i].second << " ";
  std::cout << cards.back().first << cards.back().second << std::endl;
}

void BubbleSort(std::vector<std::pair<char, int>> &cards) {
  auto len = cards.size();
  
  for (auto i=0; i<len-1; ++i) {
    for (auto j=len-1; j>=i+1; --j) {
      if (cards.at(j).second < cards.at(j-1).second)
        std::swap(cards.at(j), cards.at(j-1));
    }
  }
}

void SelectionSort(std::vector<std::pair<char, int>> &cards) {
  auto len = cards.size();
  
  for (auto i=0; i<len-1; ++i) {
    auto min_idx = i;
    for (auto j=i+1; j<len; ++j) {
      if (cards.at(j).second < cards.at(min_idx).second) {
        min_idx = j;
      }
    }
    std::swap(cards.at(i), cards.at(min_idx));
  }
}

int main() {
  int n;
  std::cin >> n;
  
  std::vector<std::pair<char, int>> cards;
  std::vector<char> suit;
  
  std::string card;
  
  for (auto i=0; i<n; ++i) {
    std::cin >> card;
    cards.emplace_back(card[0], card[1]-'0');
    suit.emplace_back(card[0]);
  }
  
  auto cards_cp1 = cards;
  BubbleSort(cards_cp1);
  
  printCards(cards_cp1);
  std::cout << "Stable" << std::endl;
  
  auto cards_cp2 = cards;
  SelectionSort(cards_cp2);
  
  printCards(cards_cp2);
  std::cout << (cards_cp2 == cards_cp1 ? "Stable" : "Not stable") << std::endl;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
 
int main(){
  string temp;
  string x,y,z;
  cin >> x >> y >> z;
  while(1){
    if(temp=="a"){
      if(x.size()==0){
        cout << "A" << endl;
        return 0;
      }
      temp=x[0];
      x=x.substr(1,x.size()-1);
    }
    else if(temp=="b"){
      if(y.size()==0){
        cout << "B" << endl;
        return 0;
      }
      temp=y[0];
      y=y.substr(1,y.size()-1);
    }
    else{
      if(z.size()==0){
        cout << "C" << endl;
        return 0;
      }
      temp=z[0];
      z=z.substr(1,z.size()-1);
    }
  }
  return 0;
}

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

int main(){
    std::string s,ans="";
    std::cin >> s;
    int n;
    n=s.length();
    for(int i=0;i<n;++i){
        if(s[i]=='0') ans+='0';
        if(s[i]=='1') ans+='1';
        if(s[i]=='B' && ans.empty()==false) {
            int l=ans.length();
            ans.erase(l-1);
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n; char s[300010];
int sum[300010];
int main() {
  scanf("%d%s", &n, s+1);
  for(int i=1; i<=n; i++) {
    sum[i] = sum[i-1] + (s[i] == 'W');
  }
  int res = 1e9;
  for(int i=1; i<=n; i++) {
    res = min(res, sum[i-1] + n - i - (sum[n] - sum[i]));
  }
  printf("%d", res);
  return 0;
}

Measured memory_bytes: 1664
N = int(input())
A = [0] * N
for i in range(0, N):
	A[i] = int(input())

c = 0
if A[0] != 0:
	c = -1
else:
	for i in range(0, N):
		if A[i] == 0:
			c = c
		elif A[i] == 1:
			c = c + 1
		elif i >= 1 and A[i] == A[i-1] + 1:
			c = c + 1
		elif i >= 1 and A[i] <= A[i-1]:
			c = c + A[i]
		else:
			c = -1
			break;

print(c)

Measured memory_bytes: 10996
#include <iomanip>
#include <iostream>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

  map<int, int> mapA;
  rep(i, N) {
    int A;
    cin >> A;
    auto itr = mapA.lower_bound(A);
    if (itr != mapA.begin()) {
      --itr;
      itr->second--;
      if (itr->second == 0) mapA.erase(itr);
    }
    mapA[A] += 1;
  }

  int answer = 0;
  for (auto& A : mapA) {
    answer += A.second;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 4864
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using IP = pair<int, int>;


#define INF 999999999
#define atcoder(int)1e9+7
#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

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

bool br[60][60], j[100];
int n, m;

void dfs(int v) {//深さ優先探索
	j[v] = true;

	for (int i = 0; i < n; i++) {
		if (br[v][i] == false)continue;
		if (j[i])continue;
		dfs(i);
	}
}

int main() {

	int ans = 0;
	int a[60], b[60];

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		br[a[i]][b[i]] = br[b[i]][a[i]] = true;
	}
	

	for (int i = 0; i < m; i++) {

		br[a[i]][b[i]] = br[b[i]][a[i]] = false;

		for (int k = 0; k < n; k++)
			j[k] = false;

		dfs(0);

		bool c = false;
		for (int k = 0; k < n; k++) if (j[k] == false) c = true;
		if(c)ans++;

		br[a[i]][b[i]] = br[b[i]][a[i]] = true;

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N, M;
    cin >> N >> M;
    vector<ll> a[3]; // a[0]=綺麗さ a[1]=おいしさ a[2]=人気度
    rep(i, N)
    {
        rep(j, 3)
        {
            ll tmp;
            cin >> tmp;
            a[j].emplace_back(tmp);
        }
    }

    ll maxv = 0;
    for (int bit = 0; bit < (1 << 3); ++bit) {
        vector<ll> b;
        rep(i, N)
        {
            ll tmp = 0;
            rep(j, 3)
            {
                if (bit & (1 << j)) {
                    tmp += a[j][i];
                } else {
                    tmp -= a[j][i];
                }
            }
            b.emplace_back(tmp);
        }
        sort(b.begin(), b.end());
        reverse(b.begin(), b.end());
        ll sum = 0;
        rep(i, M)
        {
            sum += b[i];
        }
        maxv = max(maxv, sum);
    }
    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
ll mod=1e9+7;
int main()
{
IOS
ll n,m,k;
cin>>n>>m>>k;
vector<ll> a(n),b(m),dp(m);
for(ll i=0;i<n;i++)
{
  cin>>a[i];
}
for(ll i=0;i<m;i++)
{
    cin>>b[i];
    if(i==0)
        dp[i]=b[i];
    else
        dp[i]=dp[i-1]+b[i];
}
ll maxi=0;
ll c=lower_bound(dp.begin(),dp.end(),k)-dp.begin()+1;
/*for(ll i=0;i<m;i++)
{

        cout<<dp[i]<<" ";
}*/

if(dp[c-1]==k && c-1<m)
maxi=c;
else
    maxi=c-1;
ll p=0;
for(ll i=0;i<n;i++)
{
    p+=a[i];
    if(p>k)
        break;
    ll pos=lower_bound(dp.begin(),dp.end(),k-p)-dp.begin()+1;
if(dp[pos-1]==k-p && pos-1<m)
maxi=max(maxi,i+1+pos);
else
 maxi=max(maxi,i+pos);
}
cout<<maxi;
return 0;
}


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

using namespace std;
int n,m;
int a,b;
bool check(int x)
{
    int sum=0;
    while(true)
    {
        sum+=x%10;
        x=x/10;
        if(x==0)break;
    }
    if(a<=sum&&sum<=b)
       return 1;
    return 0;
}
int main()
{
 cin>>n>>a>>b;
 if(a>b)swap(a,b);
 int sum=0;
 for(int i=1;i<=n;i++)
 {
     if(check(i))sum+=i;
 }
 cout<<sum;
}


Measured memory_bytes: 256
// * It's time to PLAY !

#include <bits/stdc++.h>

using namespace std;

#ifdef EXILE
#include "prettyprint.hpp"
#define debug(args) cerr << #args << " = " << args << endl;
#else
#define debug(args) 20040119
#endif

#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

void OPEN(string str)
{
    freopen((str + ".inp").c_str(), "r", stdin);
    freopen((str + ".out").c_str(), "w", stdout);
}

const int N = 1e5 + 7, K = 107, mod = 1e9 + 7;

int dp[K][N], a[N];

void update(int row, int l, int r, int val)
{
    (dp[row][l] += val) %= mod;
    ((dp[row][r + 1] -= val) += mod) %= mod;
}

void process(int row)
{
    for (int i = 1; i < N; ++i)
        (dp[row][i] += dp[row][i - 1]) %= mod;
}

void PLAY()
{
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    update(1, 0, a[1], 1);
    process(1);
    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j <= k; ++j)
        {
            update(i + 1, j, min(j + a[i + 1], k), dp[i][j]);
        }
        process(i + 1);
    }
    cout << dp[n][k];
}

signed main()
{
    fastio;
    PLAY();
    return 0;
}

Measured memory_bytes: 40448
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int n; // number of nodes
vector<vector<int>> adj; // adjacency list of graph
int sum = 0;

vector<bool> visited;
vector<int> tin, low;
int timer;

void dfs(int v, int p = -1) {
    // cout << "Salut" << endl;
    visited[v] = true;
    tin[v] = low[v] = timer++;
    for (int to : adj[v]) {
        if (to == p) continue;
        if (visited[to]) {
            low[v] = min(low[v], tin[to]);
        } else {
            dfs(to, v);
            low[v] = min(low[v], low[to]);
            if (low[to] > tin[v])
                sum++; //IS_BRIDGE(v, to);
        }
    }
}

void find_bridges() {
    timer = 0;
    visited.assign(n, false);
    tin.assign(n, -1);
    low.assign(n, -1);
    for (int i = 0; i < n; ++i) {
        if (!visited[i])
            dfs(i);
    }
}

int main()
{
    int m;
    cin >> n >> m;
    adj.resize(n);
    rep(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    find_bridges();
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
module DoublyLinkedList = struct
  type t = {
    mutable data : int;
    mutable next : t;
    mutable prev : t;
  }

  let make () =
    let rec head = { data = 0; next = head; prev = head } in
    head

  let insert data head =
    let x = { data = data; next = head.next; prev = head } in
    head.next.prev <- x;
    head.next <- x

  let delete x =
    x.next.prev <- x.prev;
    x.prev.next <- x.next

  let delete_first head = delete head.next

  let delete_last head = delete head.prev

  let delete_node data head =
    let rec doit ite =
      if ite == head then None
      else if ite.data = data then Some ite
      else doit ite.next
    in
    match doit head.next with
    | None -> ()
    | Some ite -> delete ite

  let iteri head ~f =
    let rec doit i ite =
      if ite != head then (f i ite.data; doit (i + 1) ite.next)
    in doit 0 head.next
end

module L = DoublyLinkedList

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc)
  in doit str []

let () =
  let n = read_int () in
  let head = L.make () in
  let rec read i =
    if i < n then begin
      match split (read_line ()) ' ' with
      | ["insert"; n] -> (L.insert (int_of_string n) head; read (i + 1))
      | ["delete"; n] -> (L.delete_node (int_of_string n) head; read (i + 1))
      | ["deleteFirst"] -> (L.delete_first head; read (i + 1))
      | ["deleteLast"] -> (L.delete_last head; read (i + 1))
      | _ -> exit 1
    end in
  read 0;
  L.iteri head ~f:(fun i n -> if i <> 0 then print_string " "; print_int n);
  print_newline ()

Measured memory_bytes: 39072
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
const int SIZE=5+3*1e5;
const int INF=10+1e9;
const LL p =7+1e9;
const LL c= 1<<30;
LL A[SIZE];
int N;
LL gcd(LL a, LL b){
	if(a%b==0) return b;
	return gcd(b,a%b);
}
bool solve(){
	LL gcds=A[0]/2*2;
	LL sum=0;
	int odds=0;
	bool isEnd=false;
	REP(i,N){
		sum+=A[i]-1;	
		if(A[i]%2) odds++;		
		if(A[i]==1) isEnd=true;
		else gcds=gcd(gcds,A[i]/2*2);
	}	
	sum%=2;
	bool isFirst=sum;
	if(N==2 or isEnd or odds>=2 ) return isFirst;
	if(isFirst) return isFirst;
	REP(i,N)
		A[i]/=gcds;	
	return !solve();
	
}
int main(){
	cin >> N;
	REP(i,N)
		cin >> A[i];	
	if(solve()) cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
int main(){
    ll n;
    std::cin >> n;
    VEC(ll,a,n);
    if(n%2==0){
        std::vector<ll> s1,s2;
        s1.pb(0);
        s2.pb(0);
        rep(i,n){
            if(i%2==0)s1.pb(s1[s1.size()-1]+a[i]);
        }
        reverse(all(a));
        rep(i,n){
            if(i%2==0)s2.pb(s2[s2.size()-1]+a[i]);
        }
        ll ans=-INF64;
        rep(i,n/2+1){
            ans=max(ans,s1[i]+s2[n/2-i]);
        }
        std::cout << ans << std::endl;
    }
    else if(n==3){
        std::cout << max({a[0],a[1],a[2]}) << std::endl;
    }
    else {
        vvector(dp,ll,n+1,3,-INF64);
        dp[0][0]=0;
        dp[0][1]=0;
        dp[0][2]=0;
        dp[1][0]=a[0];
        dp[2][1]=a[1];
        dp[3][2]=a[2];
        
        rep(i,n+1){
            rep(j,3){
                if(i-2>=0){
                    dp[i][j]=max(dp[i][j],dp[i-2][j]+a[i-1]);
                    if(j!=0&&i-3>=0){
                        dp[i][j]=max(dp[i][j],dp[i-3][j-1]+a[i-1]);
                    }
                }
                
            }
        }
        std::cout << max({dp[n][2],dp[n-1][1],dp[n-2][0]}) << std::endl;
    }
    
}


Measured memory_bytes: 15604
N=int(input())
ans=0
say=[]
for _ in range(N):
    A=int(input())
    text=[]
    for _ in range(A):
        text.append(list(map(int,input().split())))
    say.append(text)

for i in range(2**N):
    people=[]
    for k in range(N):
        people.append(i%2)
        i//=2

    flag=True    
    for n in range(N):
        for t in say[n]:
            if people[n]!=0 and people[t[0]-1]!=t[1]:
                flag=False    
    if flag and sum(people)>ans:
        ans=sum(people)
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
struct node{
  node *prev;
  int key;
  node *next;
};
node L;
node *nil=&L;

node* find(int x){
  node *i;
  for(i=nil;i->next->key!=x&&i->next!=nil;i=i->next);
  return i->next;
}
void del(int x){
  node *a;
  if(x==-1)a=nil->next;
  else if(x==-2)a=nil->prev;
  else a=find(x);
  if(a==nil)return;
  a->prev->next=a->next;
  a->next->prev=a->prev;
  free(a);
}
void in(int x){
  node *a;
  a=(node *)malloc(sizeof(node));
  a->next=nil->next;
  nil->next->prev=a;
  nil->next=a;
  a->prev=nil;
  a->key=x;
}
int main(){
  int n;
  string s;
  L.prev=nil,L.next=nil;
  scanf("%d\n",&n);
  while(n--){
    getline(cin,s);
    int t=0;
    for(int i=7;i<s.size();i++)t*=10,t+=s[i]-'0';
    if(s[0]=='i')in(t);
    else{
       if(s[6]=='F')del(-1);
      else if(s[6]=='L')del(-2);
      else del(t);
    } 
  }
  node *i;
  for(i=nil;i->next->next!=nil;i=i->next)cout<<i->next->key<<' ';
  cout<<i->next->key<<endl;
  return 0;
}

Measured memory_bytes: 32476
s=input()
k=int(input())
cnt = 0
ans = set([])
head  = sorted(list(set(list(s))),reverse=True)
while cnt < k:
    tmp_h = head.pop()
    for n,i in enumerate(s):
        if i==tmp_h:
            for j in range(min(k,len(s)-n)):
                ans.add(s[n:n+j+1])
    cnt = len(ans)
ans = sorted(list(ans))
print(ans[k-1])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

typedef long long int ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vint;
typedef vector<pii> vpii;
typedef vector<vint> det1;
typedef vector<vpii> det2;

const int MAXN = 100000;

int N;
int A[MAXN], B[MAXN];

int main()
{
    cin >> N;
    rep(i, N) { cin >> A[i] >> B[i]; }

    vector<pii> C(N);

    rep(i, N) { C[i].first = A[i] + B[i]; C[i].second = i; }

    sort(C.begin(), C.end(), greater<pii>());

    ll ans = 0;

    rep(i, N)
    {
        ans += (i % 2) == 0 ? A[C[i].second] : -B[C[i].second];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    long double A,B,H,M;cin>>A>>B>>H>>M;
    long double ans;
    long double angl = 360*(M/60.0);
    long double angs = 360*(H/12.0) + 30*(M/60.0);
    long double angdif = min(fabs(angl-angs),fabs(angs-angl));
    angdif = angdif*3.141592653589/180.0; 
    ans = sqrt(pow(A,2)+pow(B,2)-2*A*B*cos(angdif));
    cout << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 4168
#include <stdio.h>
long long min(long long x,long long y){
    if(x<y) return x;
    else return y;
}
int main(void){
    long long a,b,n;
    scanf("%lld%lld%lld",&n,&a,&b);
    printf("%lld",a*(n/(a+b))+min(a,(n%(a+b))));
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  VLL a(n);
  rep(i,n) cin >> a[i];
  VLL aa(n,0);
  ll ans = 0;
  ll sum = 0;
  ll add;
  do{
    add = 0;
    rep(i,n){
      ll tmp = ( a[i] + (sum - aa[i])) / n;
      ll tmp2 = ( a[i] + (sum - aa[i])) % n;

      ans   += tmp;
      add   += tmp;
      aa[i] =  tmp;
      a[i]  =  tmp2;
    }
    sum = add;
  }while(add>0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf = 1001001001;
int main(){
	string str;
  	cin >> str;
  	vector<int> num;
  	for(int i=0;i<str.size();i++){
      num.push_back(str.at(i)-'0');
    }
  	
  	reverse(num.begin(),num.end());
  	num.push_back(0);
  	int n=num.size();	
  
  	// 下からi桁目までに使用する紙幣の最小
  	// j=0のときは繰り下がりなし、j=1のときは繰り下がりあり
  	vector<vector<int>> dp(n+1,vector<int>(2));
  	for(int i=0;i<n+1;i++){
      for(int j=0;j<2;j++){
        dp.at(i).at(j) = inf;
      }
    }
  	dp.at(0).at(0) = 0;
  
  	//状態(i,j)が確定しているときに状態(ni,nj)を計算する
  	for(int i=0;i<n;i++){
      for(int j=0;j<2;j++){
        int x = num.at(i);
        x += j;
        for(int a=0;a<10;a++){
          int ni = i+1;
          int nj = 0;
          int b = a-x;
          if(b<0){
            b += 10;
            nj = 1;
          }
          dp.at(ni).at(nj) = min( dp.at(ni).at(nj), dp.at(i).at(j)+a+b );
        }
      }
    }
  
  	//n桁全て確定したときに繰り下がりはあってはいけない
  	cout << dp.at(n).at(0) << endl;
  
  	return(0);
}

Measured memory_bytes: 59896
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
g=int(input())
h=int(input())
i=int(input())
j=int(input())
k=int(input())
l=int(input())
m=int(input())
n=int(input())
o=int(input())
p=int(input())
q=int(input())
r=int(input())
s=int(input())
t=int(input())
u=int(input())
v=int(input())
w=int(input())
x=int(input())
y=int(input())
z=int(input())
wa=int(input())
ke=int(input())

cc=list(range(1,31))
dd=[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,wa,ke]

ee=list(set(cc)-set(dd))
ee.sort()
print(ee[0])
print(ee[1])



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int n;
    cin >> n;
    vector<string> w(n);
    rep(i,n) cin >> w[i];
    vector<string> a(n);
    a =w;
    sort(ALL(a));
    a.erase(unique(ALL(a)),a.end());
    if(a.size()!=w.size()){
        cout << "No" << endl;
        return 0;
    }
    rep(i,n-1){
        if(w[i][w[i].size()-1]!=w[i+1][0]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll X;
    cin >> X;

    ll ans = 1;
    for (ll b = 2; b * b <= X; b++) {
        ll t = b * b;
        while (t <= X) {
            ans = max(ans, t);
            t *= b;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K;
	int con = 0;
	
	cin>>N>>K;
	
	for(int i = 0; i < N; i++){
		int h;
		
		cin>>h;
		
		if(h >= K) con++;
	}
	
	cout<<con<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    int alice=0;
    int bob=0;
    for (int i = 0; i < n;i+=2){
        alice += a[i];
        if(i+1<n){
            bob += a[i + 1];
        }
    }
    cout<<alice-bob<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;

int value[1001];
int cost[1001];
int dp[1001][1001];

void cut(string s,int& a,int& b){
	for(int i=0; i<s.size(); ++i){
		if(s[i]==','){
			string tmp1=s.substr(0,i);
			string tmp2=s.substr(i+1);
			a=atoi(tmp1.c_str());
			b=atoi(tmp2.c_str());
			break;
		}
	}
}

int main(){
	int W,N,cnt=1;
	while(cin>>W&&W){
		cin >> N;
		for(int i=0; i<N; ++i){
			for(int j=0; j<=1000; ++j){
				dp[i][j]=-1;
			}
		}
		for(int i=0; i<N; ++i){
			string tmp;
			cin >> tmp;
			cut(tmp,value[i],cost[i]);
			//cout << value[i] << " " << cost[i] << "\n";
		}
		dp[0][cost[0]]=value[0];
		dp[0][0]=0;
		for(int i=1; i<N; ++i){
			for(int j=0; j<=W; ++j){
				if(j-cost[i]>=0){
					dp[i][j]=max(dp[i-1][j],dp[i-1][j-cost[i]]+value[i]);
				} else {
					dp[i][j]=dp[i-1][j];
				}
			}
		}
		int ans_v=-1;
		int ans_c;
		for(int i=0; i<=W; ++i){
			if(dp[N-1][i]>ans_v){
				ans_v=dp[N-1][i];
				ans_c=i;
			}
		}
		cout << "Case " << cnt << ":\n" << ans_v << "\n" << ans_c << "\n";
		++cnt;
	}
	return 0;
}

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

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk(a, b) make_pair(a, b)
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int N, M, R, d[220][220], r[220], dp[1000][220];

int dfs(int bit, int pos)
{
    if(bit == (1 << R) - 1){
        return 0;
    }
    if(~dp[bit][pos]){
        return dp[bit][pos];
    }
    int res = INF;
    for(int i = 0; i < R; i++){
        if(!(bit & (1 << i))){
            res = min(res, dfs(bit | (1 << i), r[i]) + d[pos][r[i]]);
        }
    }
    return dp[bit][pos] = res;
}

signed main()
{
    cin >> N >> M >> R;
    for(int i = 0; i < R; i++){
        cin >> r[i];
    }
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            if(i == j)continue;
            d[i][j] = INF;
        }
    }
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
    }
    for(int k = 1; k <= N; k++){
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= N; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    int ans = INF;
    for(int i = 0; i < R; i++){
        ans = min(ans, dfs(1 << i, r[i]));
    }
    cout << ans << endl;

    return 0;
}



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

using namespace std;

int main()
{
   long long n,k;
   cin >> n >> k;
   long long d;
   set <int> s;
   while(k--)
   {
       cin >> d;
       long long a[d];
       int i,temp;
       for(i=0;i<d;i++)
       {
           cin >> temp;
           s.insert(temp);
       }
   }
   cout << n - s.size();
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  int total = 0;
  for(int i=0; i < n; i++) {
    cin >> v[i];
    total += v[i];
  }
  int count = 0;
  for(int i=0; i < n; i++) {
    if(total <= v[i]*4*m) count++;
  }
  cout << (m <= count ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import math

A, B, H, M = map(int, input().split())
angle_hour = (H + M / 60) * 30
angle_min = 6 * M
angle = min(abs(angle_hour - angle_min), 360 - abs(angle_hour - angle_min))
ans = math.sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * math.cos(math.radians(angle)))
print(ans)

Measured memory_bytes: 9504
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 110;

int n, m, cnt[N];
char S[N];

int main(){
	scanf("%d%d", &n, &m);
	For(i, 1, n){
		scanf("%s", S + 1);
		For(j, 1, m) cnt[S[j] - 'a']++;
	}
	int c4 = (n / 2) * (m / 2), c1 = (n & 1) && (m & 1), c2 = (n * m - c4 * 4 - c1) / 2;
	For(i, 0, 25){
		while(cnt[i] >= 4 && c4) cnt[i] -= 4, --c4;
		while(cnt[i] >= 2 && c2) cnt[i] -= 2, --c2;
		while(cnt[i] && c1) cnt[i]--, --c1;
		if(cnt[i]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)

int i, j, k;



int main() {
	int N;
	vector<int> a;
	cin >> N;
	rep(i, 0, N) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());

	int ans = 0;
	int b = 0;
	rep(i, 0, N) {
		if (b < a[i]) {
			ans++;
			b = a[i];
		}
	}
	cout << ans;
	return 0;
}



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

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

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back

constexpr auto inf = numeric_limits<int>().max() - 1;
constexpr auto llinf = numeric_limits<ll>().max() - 1LL;

template<typename ForwardIterator>
void dump(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << *it << " ";
	}
	cout << endl;
}

template<typename ForwardIterator>
void dump_map(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << (*it).first << ":" << (*it).second << " ";
	}
	cout << endl;
}
template<typename T>
void debug(initializer_list<T> list) {
  for (auto el : list) {
    cout << el << " ";
  }
  cout << endl;
}

constexpr ll mod = ll(1e9 + 7);

ll mult(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }

ll power(ll a, ll b) {
	ll result = 1LL;
	while (b) {
		if (b % 2LL) result = mult(result, a);
		a = mult(a, a);
		b /= 2LL;
	}
	return result;
}

ll divide(ll a, ll b) { return mult(a, power(b, mod - 2)); }

ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }

ll subtract(ll a, ll b) { return ((a - b) % mod + mod) % mod; }

int n;

void solve() {
	cin >> n;
	set<string> stuff;
	rep(i, n) {
		string s;
		cin >> s;
		stuff.insert(s);
	}
	cout << sz(stuff);
	cout << "\n";
}

#define REPEAT 0
#define CASE 0

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#if REPEAT
		int t;
		cin >> t;
		repa(i, 1, t) {
			#if CASE
				cout << "Case #" << i << ": ";
			#endif
			solve();
		}
	#else
		solve();
	#endif
	return 0;
}


Measured memory_bytes: 19140
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>

using namespace std;

vector<string> g;
int h, w;

bool check(int i, int j){
    if(i > 0 && g[i-1][j] == '#'){
        return true;
    }
    else if(j < w-1 && g[i][j+1] == '#'){
        return true;
    }
    else if(i < h-1 && g[i+1][j] == '#'){
        return true;
    }
    else if(j > 0 && g[i][j-1] == '#'){
        return true;
    }
    else {
        return false;
    }
}
int main()
{
    cin >> h >> w;
    string answer = "Yes";
    g.resize(h);
    for(int i=0; i<h; ++i){
        cin >> g[i];
    }
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            if(g[i][j] == '.'){
                continue;
            }
            else if(g[i][j] == '#'){
                if(!check(i, j)){
                    answer = "No";
                }
            }
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  string S, change;
  cin >> N >> K >> S;
  if (S.at(K - 1) == 'A') {
    change = "a";
  }
  else if (S.at(K - 1) == 'B') {
    change = "b";
  }
  else {
    change = "c";
  }
  for (int i = 0; i < K - 1; i++) {
    cout << S.at(i);
  }
  cout << change;
  for (int i = K; i < N; i++) {
    cout << S. at(i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int r, c, data[126][126] = { 0 }, sum[126] = { 0 }, total[126] = { 0 }, i, j;
	scanf("%d %d", &r, &c);

	for (i = 1; i <= r; i++)
	{

		for (j = 1; j <= c; j++)
		{

			scanf("%d", &data[i][j]);
			sum[i] = sum[i] + data[i][j];
			total[j] = total[j] + data[i][j];

		}


	}


	
	for (i = 1; i <= r; i++)
	{

		for (j = 1; j <= c; j++)
		{

			printf("%d ", data[i][j]);

		}

		printf("%d\n", sum[i]);
		total[c + 1] = total[c + 1] + sum[i];
	}

	for (j = 1; j <= c; j++)
	{

		printf("%d ", total[j]);

	}

	printf("%d\n", total[c + 1]);

	return 0;

}


Measured memory_bytes: 2116
n, d = map(int, input().split())
dots = [list(map(int, input().split())) for _ in range(n)]

def culc_dist(dot1, dot2):
    dist = 0
    for i in range(len(dot1)):
        dist += (dot1[i] - dot2[i]) ** 2
    dist = dist ** (0.5)
    return dist

ans = 0

for i in range(n):
    for j in range(i + 1, n):
        dist = culc_dist(dots[i], dots[j])
        if dist.is_integer():
            ans += 1

print(ans)


Measured memory_bytes: 3064
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());
    long[][] nums = new long[n][];
    long memo = 1;
    long answer = 1;
		for(long i = 0; i < n; i++)
    {
      nums[i] = new long[2];
      nums[i][0] = long.Parse(Console.ReadLine());
      nums[i][1] = i;
    }

    Array.Sort(nums, (a, b) => a[0].CompareTo(b[0]));

    for(long i = 1; i < n; i++)
    {
      if(nums[i][1] > nums[i-1][1]) memo++;
      else memo = 1;
      answer = Math.Max(answer, memo);
    }
    
		Console.WriteLine(n - answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 30032
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    int k=a[n-1];
    vector<int> v;
    if(k%2==0){
        for(int i=k;i>=k/2+1;i--){
            v.push_back(i);v.push_back(i);
        }
        v.push_back(k/2);
    }
    else{
        for(int i=k;i>=(k+1)/2;i--){
            v.push_back(i);v.push_back(i);
        }
    }
    sort(v.begin(),v.end());
    int idx=0;
    bool f=true;
    for(int i=0;i<(int)v.size();i++){
        bool tmp=false;
        for(;idx<n;idx++){
            if(a[idx]==v[i]){
                tmp=true;
                a[idx]= -1;
                break;
            }
        }
        if(!tmp) f=false;
    }
    for(int i=0;i<n;i++){
        if(a[i]==-1) continue;
        else{
            if(a[i]>=(k+1)/2+1) continue;
            else f=false;
        }
    }
    if(f) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}


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

const int MOD=1000000007;

std::vector<ll int> mfac(1000001);

void mfactorial(){
    mfac[0]=1;
    mfac[1]=1;
    for (ll int i = 2; i <= 1000000; i++) {
        mfac[i]=(mfac[i-1]*i)%MOD;
    }        
}

ll int mpow(ll int a,ll int b){
    if(b==0){
        return 1;
    }
    if(b%2==1){
        return ((mpow(a,b/2)*mpow(a,b/2))%MOD*a)%MOD;
    }else{
        return mpow(a,b/2)*mpow(a,b/2)%MOD;
    }
}

int cmb(int n,int r){
    // if(n==0 && r==0){
    //     return 0;
    // }else if(n<r ||n<0){
    //     return 1;
    // }
    ll int a=mfac[n];
    ll int b=mpow(mfac[r],MOD-2);
    ll int c=mpow(mfac[n-r],MOD-2);
    return a*b%MOD*c%MOD;
}

int main(void){
    int x,y;
    std::cin >> x >>y;
    if((x+y)%3!=0){
        std::cout << 0 << std::endl;
        return 0;
    }
    ll int n=(2*y-x)/3;
    ll int m=(2*x-y)/3;
    if(n<0 || m<0){
        std::cout << 0 << std::endl;
        return 0;
    }
    mfactorial();
    
    std::cout << cmb(n+m,n) << std::endl;
    
}

Measured memory_bytes: 8064
#include <iostream>
#include <queue>
#include <algorithm>
#include <climits>
#include <stack>
#include <vector>
#include <random>
#include <string.h>
#include <stdio.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef pair<int, int> ii;
typedef pair<long double, int> id;
typedef pair<long long, long long> llp;
const int N = 1e3+1, MOD = 1e9+7;
int n, m;
int dp[N][N], a[N][N];
bool check(int x, int y) {
    return (x>0&&x<=n&&y>0&&y<=m&&a[x][y]);
}
int main() {
    //freopen("ee.inp", "r", stdin);
    //freopen("ee.OUT", "w", stdout);
    fastIO;
    cin>>n>>m;
    string s;
    for(int i=1;i<=n&&cin>>s;i++)
        for(int j=1;j<=m;j++)
            a[i][j] = (s[j-1]=='#'?0:1);
    dp[n][m] = 1;
    for(int i=n;i>0;i--)
        for(int j=m;j>0;j--) {
            if (!a[i][j]) continue;
            if (check(i+1, j)) dp[i][j]+=dp[i+1][j]%MOD;
            if (check(i, j+1)) dp[i][j]+=dp[i][j+1]%MOD;
            dp[i][j]%=MOD;
        }
    cout << dp[1][1];
}


Measured memory_bytes: 11464
#include<bits/stdc++.h>
using namespace std;
int main(){
    double D, T, S;
    cin >> D >> T >> S;
    double time;
    time = D / S;
    if(time <= T){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

struct RU {
	using type1 = int;
	using type2 = int;
	static type1 id1() { return INT_MAX; }
	static type2 id2() { return -1; }
	static type1 op1(const type1& l, const type1& r) { return min(l, r); }
	static type1 op2(const type1& l, const type2& r) { return r == -1 ? l : r; }
	static type2 op3(const type2& l, const type2& r) { return r == -1 ? l : r; }
};

template <typename M>
class LazySegmentTree {
	using T1 = typename M::type1;
	using T2 = typename M::type2;
	const int n;
	vector<T1> data;
	vector<T2> lazy;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	void push(int node) {
		if (lazy[node] == M::id2()) return;
		if (node < n) {
			lazy[node * 2] = M::op3(lazy[node * 2], lazy[node]);
			lazy[node * 2 + 1] = M::op3(lazy[node * 2 + 1], lazy[node]);
		}
		data[node] = M::op2(data[node], lazy[node]);
		lazy[node] = M::id2();
	}
	void suc(int l, int r, int node, int lb, int ub, T2 val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			lazy[node] = M::op3(lazy[node], val);
			return;
		}
		push(node);
		int c = (lb + ub) / 2;
		suc(l, r, node * 2, lb, c, val);
		suc(l, r, node * 2 + 1, c, ub, val);
		data[node] = M::op1(M::op2(data[node * 2], lazy[node * 2]), M::op2(data[node * 2 + 1], lazy[node * 2 + 1]));
	}
	T1 sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return M::id1();
		if (l <= lb && ub <= r) return M::op2(data[node], lazy[node]);
		push(node);
		int c = (lb + ub) / 2;
		return M::op1(sub(l, r, node * 2, lb, c), sub(l, r, node * 2 + 1, c, ub));
	}
public:
	LazySegmentTree(int n_) : n(size(n_)), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {}
	void update(int l, int r, T2 val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	T1 find(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, type, s, t, x;
	cin >> n >> q;
	LazySegmentTree<RU> lst(n);
	while (q--) {
		cin >> type;
		if (type) {
			cin >> x;
			printf("%d\n", lst.find(x, x));
		}
		else {
			cin >> s >> t >> x;
			lst.update(s, t, x);
		}
	}
	return 0;
}

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

int main(){
	#ifdef LOCAL_DEFINE
		freopen("../a.in","r",stdin);
		freopen("../a.out", "w",stdout);
	#endif
	int a,b,c;
	cin >> a >> b >> c;
	int ans = b/a;
	if(ans>c){
		cout << c << endl;
	} else {
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256