akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, cnt;

  cin >> n;

  vector<string> s(n);
  vector<int> p(n);
  vector<int> ans(n + 1);

  for (int i = 0; i < n; i++) {
    cin >> s.at(i) >> p.at(i);
  }

  for (int i = 0; i < n; i++) {
    cnt = 1;
    for (int j = 0; j < n; j++) {
      if (j == i && j < n - 1) {
        j++;
      }
      if (j == n) {
        break;
      }
      for (int k = 0; k < s[i].length() && k < s[j].length(); k++) {
        if (s[i][k] > s[j][k]) {
          cnt++;
          break;
        } else if (s[i][k] < s[j][k]) {
          break;
        }
        if (k == s[i].length() - 1 || k == s[j].length() - 1) {
          if (s[i].length() > s[j].length()) {
            cnt++;
            break;
          } else if (s[i].length() < s[j].length()) {
            break;
          }
          if (p[i] < p[j]) {
            cnt++;
          }
        }
      }
    }
    ans[cnt] = i + 1;
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    static double x;

    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		x = sc.nextDouble();

        double ok = Math.PI / 2.0;
        double ng = 0;
        int count = 0;
        for(int i = 0; i < 27 ; i++){
            double mid = (ok + ng) / 2.0;
            if(f(a, b, mid) < x) ok = mid;
            else ng = mid;
        }

        System.out.println(Math.toDegrees(ok));
    }

    static double f(double a, double b, double t){

        if(t > Math.PI / 2.0){
            return 0.0;
        }
        double ans;
        if(x >= a * a * b / 2){
            ans = a * a * b - a * a * a * Math.tan(t) / 2.0;
        }else{
            ans = a * b * b / Math.tan(t) / 2.0;
        }

        return ans;

    }

}


Measured memory_bytes: 24016
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int N;
vector<long> a;
long a1_dp[100001];
long a2_dp[100001];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  a.resize(3 * N);
  for (int i = 0; i < 3 * N; i++) {
    cin >> a[i];
  }

  // a1
  long a1_sum = 0;
  priority_queue<long, vector<long>, greater<long>> a1_pg;
  for (int i = 0; i < N; i++) {
    a1_sum += a[i];
    a1_pg.push(a[i]);
  }

  a1_dp[0] = a1_sum;
  for (int i = N; i < 2 * N; i++) {
    a1_pg.push(a[i]);
    long tmp = a1_pg.top();
    a1_pg.pop();
    a1_sum += a[i] - tmp;
    a1_dp[i - N + 1] = a1_sum;
  }

  // a2
  long a2_sum = 0;
  priority_queue<long> a2_pg;
  for (int i = 2 * N; i < 3 * N; i++) {
    a2_sum += a[i];
    a2_pg.push(a[i]);
  }

  a2_dp[N] = a2_sum;
  for (int i = 2 * N - 1; i >= N; i--) {
    a2_pg.push(a[i]);
    long tmp = a2_pg.top();
    a2_pg.pop();
    a2_sum += a[i] - tmp;
    a2_dp[i - N] = a2_sum;
  }

  // ans
  long ans = LONG_MIN;
  for (int i = 0; i <= N; i++) {
    ans = max(ans, a1_dp[i] - a2_dp[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5876
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int flag = 0;
  for(int i = 0; i < S.size() - 1; i++){
    if(S.substr(i, 2) == "AC")flag = 1;
  }
  if(flag == 0)cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007

int main() {
	ios;
	float a, b, c, d;
	cin>>a>>b>>c>>d;
	int x = ceil(a/d), y = ceil(c/b);
	if (x >= y) cout<<"Yes";
	else cout<<"No";
	
	return 0;
}


Measured memory_bytes: 3732
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int K, X;
	scanf("%d %d", &K, &X);
	int space = (K-1)*2;
	for(int i = X - K + 1; i < X + K; i++)
	{
		printf("%d", i);
		if (space > 0)	printf(" ");
		space--;
	}
	return 0;
}

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

using namespace std;

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

	ll n, ans=0;
	cin >> n;
	vector<ll> v(n);
	for(ll i=0; i<n; i++) cin >> v[i];
	sort(v.begin(), v.end());
	for(ll i=0; i<n; i++){
        for(ll j=i+1; j<n; j++){
            for(ll k=j+1; k<n; k++){
                if(v[i]+v[j]>v[k] && v[i]!=v[j] && v[i]!=v[k] && v[j]!=v[k])
                    ans++;
            }
        }
	}
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3660
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
sys.setrecursionlimit(10 ** 6)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
tmp = 1

for i in range(1,min(n,m)+1):
    tmp = tmp * i % (10**9+7)

if n == m:
    ans = tmp**2*2 % (10**9+7)
elif abs(n-m) == 1:
    ans = tmp**2*max(n,m) % (10**9+7)
else:
    ans = 0

print(ans)

Measured memory_bytes: 10040
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll L,n; cin >> L >> n;
    vector<ll> x(n); rep(i,n) cin >> x[i];

    ll ans = 0;
    rep(loop,2){
        vector<ll> rx(n);
        rep(i,n) rx[i] = L - x[n-1-i];
        vector<ll> sx(n+1,0),srx(n+1,0);
        for(int i=0;i<n;i++) sx[i+1] = sx[i] + x[i];        // sx[i] = x[0] + ... + x[i-1]
        for(int i=0;i<n;i++) srx[i+1] = srx[i] + rx[i];     // srx[i] = rx[0] + ... + rx[i-1]


        for(int i=0;i<n;i++){   // 反時計周りにi個の木を燃やし,燃やした後に方向を逆転しない
            const int r = (n-i+1)/2;
            const int l = n - i - r;

            ll cur = 2*(sx[i+r] - sx[i]);
            cur += 2*srx[l];

            if(l != r){ // 最後にr
                cur -= x[i+r-1];
            }else{      // 最後にl
                cur -= rx[l-1];
            }

            ans = max(ans,cur);
        }

        // 2回目は初手時計回り確定の処理をするが,座標を反転していけば同一処理を使いまわせる
        swap(x,rx);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6572
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=(ll)1<<60;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int n;
void dfs(string s,char tuika,char maxc){
    s.push_back(tuika);
    if(s.length()==n){
        cout<<s<<endl;
    }else{
        for(char c='a';c<=maxc+1;c++){
            dfs(s,c,max(maxc,c));
        }
    }
}

int main(){
    in(n);
    dfs("",'a','a');
}

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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

 bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            return false;
        }
    }
    return true;
}

int main(){
    int a[3];
    for(int i = 0; i < 3; i++) cin >> a[i];

    int ans = 0;
    while(1){
        sort(a, a+3);
        if(a[0] == a[1] && a[1] == a[2]){
            cout << ans << endl;
            break;
        }else if(a[0]+2 <= a[2]){
            a[0] += 2;
            ans++;
        }else{
            a[0]++;
            a[1]++;
            ans++;
        }
    }
    return 0;
}

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

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

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  ll ans = 0;
  REPI(i, 1, N + 1) {
    int keta = 0;
    int j = i;
    while (j > 0) {
      ++keta;
      j /= 10;
    }
    if (keta % 2 == 1) {
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce

N,M=map(int,input().split())
A=[int(x)//2 for x in input().split()]

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

LCM=lcm(*A)
for a in A:
  if LCM//a%2==0:
    print(0)
    break
else:
  print((M//LCM+1)//2)


Measured memory_bytes: 21224
#include<bits/stdc++.h>
using namespace std;
struct node
{
	int l,r;
}a[100005];
bool cmp(node x,node y)
{
	return x.r<y.r;
}
int n,ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		a[i].l=x-y;
		a[i].r=x+y;
	}
	sort(a,a+n,cmp);
	int j=0,cnt=-1e9;
	while(j<n)
	{
		if(a[j].l>=cnt)
		{
			cnt=a[j].r;
			ans++;
		}
		j++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
    
    int n, m, s = 0;
    cin >> n >> m;

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

    for(int i = 0; i < m; i++){
        s += v[i];
    }

    if(s > n)
        cout << "-1" << endl;
    else if(s == n)
        cout << "0" << endl;
    else
        cout << n - s << endl;

    return 0;
}


Measured memory_bytes: 3636
n = int(input())
ls = []
dic = {}
ans = 0
for i in range(n):
    ls.append(input())
for i in range(n):
    tmp = "".join(sorted(ls[i]))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)

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

using namespace std ;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<ll,ll> pll ;
typedef vector<pii> vpii ;
typedef vector<pll> vpll ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define CHI 1000000000000000003
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
//-----------------------------------------


const int MAX_V = 300 ;

int d[MAX_V][MAX_V] ;
int V ;

void war(){
  for(int k=0;k<V;k++){
    for(int i=0;i<V;i++){
      for(int j=0;j<V;j++){
        d[i][j] = min(d[i][j],d[i][k] + d[k][j]) ;
      }
    }
  }
}






//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m, r ;
  cin >> V >> m >> r ;
  vint num(r) ;
  REP(i,r){
    int a ;
    cin >> a ;
    num[i] = a-1 ;
  }
  
  REP(i,V){
    REP(j,V){
      d[i][j] = INF ;
    }
  }
  REP(i,V){
    d[i][i] = 0 ;
  }
  
  REP(i,m){
    int b, c, e ;
    cin >> b >> c >> e ;
    d[b-1][c-1] = e ;
    d[c-1][b-1] = e ;
  }
  
  war() ;
  
  sort(ALL(num)) ;
  
  ll ans = INF ;
  
  do{
    ll tmp = 0 ;
    REP(i,r-1){
      tmp += d[num[i]][num[i+1]] ;
    }
    ans = min(tmp,ans) ;
  }
  while(next_permutation(ALL(num))) ;
  
  cout << ans <<endl ;
    
  
  
  return 0 ;
}



Measured memory_bytes: 512
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            
            //入力
            string input = Console.ReadLine();
            int n = int.Parse(input);

            string s = Console.ReadLine();

            //偶数であればi文字目と、n/2+i文字目は一致しているので一致しない場合は除く
            for(int i = 0;i < s.Length;i++)
            {
                int c = Convert.ToInt32(s[i]);
                int temp = c + n;
                if(temp > 90)
                    c += n - 26;
                else
                    c += n;

                Console.Write((char)(c));
            }

            
                
        }
    }

Measured memory_bytes: 13268
S = input()
MOD = 10**9 + 7
dp = [[0, 0, 0] for i in range(len(S)+1)]

base = 1
for i, s in enumerate(S, 1):
  dp[i][0] = dp[i-1][0]
  dp[i][1] = dp[i-1][1]
  dp[i][2] = dp[i-1][2]
  if s == 'A':
    dp[i][0] += base
    dp[i][0] %= MOD
  elif s == 'B':
    dp[i][1] += dp[i-1][0]
    dp[i][1] %= MOD
  elif s == 'C':
    dp[i][2] += dp[i-1][1]
    dp[i][2] %= MOD
  else: # s == '?'
    dp[i][0] += 2*dp[i-1][0] + base
    dp[i][1] += 2*dp[i-1][1] + dp[i-1][0]
    dp[i][2] += 2*dp[i-1][2] + dp[i-1][1]
    dp[i][0] %= MOD
    dp[i][1] %= MOD
    dp[i][2] %= MOD
    base *= 3
    base %= MOD

print(dp[-1][2])

Measured memory_bytes: 22780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll A,B,C,X,Y;

int main(){
  cin>>A>>B>>C>>X>>Y;
  ll ans=(1LL<<60);
  for(ll i=0;i<=max(X,Y)*2;i+=2){
    ll cost=C*i;
    ll nx=max(0LL,X-i/2LL);
    ll ny=max(0LL,Y-i/2LL);
    cost += nx*A;
    cost += ny*B;
    ans=min(ans,cost);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
        long long int n;
        cin>>n;
        long long int a,f=0;
        for(long long int i=0;i<n;i++)
        {
            cin>>a;
            if(a%2==0)
                f++;
        }
        if(f==n)
            cout<<"second"<<endl;
        else
            cout<<"first"<<endl;
        return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << "\n"

void solve(){
    ll N;
    cin >> N;
    ll D[110][2];
    rep(i,0,N){
        rep(j,0,2){
            cin >> D[i][j];
        }
    }
    ll ans = 0;
    ll cur = 0;
    rep(i,0,N){
        if(D[i][0] == D[i][1]){
            cur++;
        }else{
            ans = max(ans, cur);
            cur = 0;
        }
    }
    ans = max(ans, cur);
    if(ans >= 3){
        print("Yes");
    }else{
        print("No");
    }
    

}

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

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(var) (var).begin(), (var).end()
#define sz(x) (int)x.size()
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int d,t,s;
	cin >> d >> t >> s;

	if(d <= s * t)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += v[i];
	}
	cout << ans;
}



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

int main(){
  int a,b,k;
  std::cin>>a>>b>>k;
  int temp = 0;
  int ans = 0;

  for(int i = std::min(a,b); i > 0; i--){
    if(a%i == 0 && b%i == 0){
      temp += 1;
    }
    if(temp == k){
      ans = i;
      break;
    }
  }

  std::cout<<ans<<std::endl;
  return 0;
}


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


public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		//?????????
		int n = Integer.parseInt(bf.readLine());
		String[] sString = bf.readLine().split(" ");
		int q = Integer.parseInt(bf.readLine());
		String[] tString = bf.readLine().split(" ");
	
		int count=0;
		

		
		for(int i=0;i<q;i++){
			int search = Integer.parseInt(tString[i]);
			int left=0;
			int right = n;
		while(left<right){
			int mid = (left+right)/2;
			if(Integer.parseInt(sString[mid])==search){
				count++;
				break;
			}else if(Integer.parseInt(sString[mid])>search){
				right=mid;
			}else if(Integer.parseInt(sString[mid])<search){
				left= mid+1;
			}
		}
		}
		System.out.println(count);
	}

 }

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

int main(){
  int n, i, j, mini;
  char c1[36][3], c2[36][3];
  char temp[3];

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s", c1[i]);
    strcpy(c2[i], c1[i]);
  }

  for(i=0; i<n-1; i++)
    for(j=n-1; j>i; j--)
      if(c1[j][1] < c1[j-1][1]){
	strcpy(temp, c1[j]);
	strcpy(c1[j], c1[j-1]);
	strcpy(c1[j-1], temp);
      }
  
  for(i=0; i<n-1; i++) printf("%s ", c1[i]);
  printf("%s\nStable\n", c1[i]);

  for(i=0; i<n; i++){
    mini = i;
    for(j=i; j<n; j++){
      if(c2[j][1] < c2[mini][1]) mini = j;
    }
    if(i != mini){
      strcpy(temp, c2[i]);
      strcpy(c2[i], c2[mini]);
      strcpy(c2[mini], temp);
    }
  }

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

  for(i=0; i<n; i++) if(strcmp(c1[i], c2[i]) != 0) break;
  printf("%s\n", i==n?"Stable":"Not stable");
  
  return 0;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x)     		(x).begin(),(x).end()
#define ub    			upper_bound
#define lb 				lower_bound
#define ins				insert
#define int 			long long
#define endl			'\n'
#define ff              first
#define ss              second
#define ull				unsigned long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define si 				set<int>
#define usi 			unordered_set<int>		
#define mii             map<int,int>
#define umii			unordered_map<int ,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,a,n)		for(int i=a;i<n;++i)
#define repd(i,a,n)		for(int i=a;i>n;--i)
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define deb(x)			cout<<#x <<"="<<x<<endl;
#define deb2(x,y)		cout<<#x<<"="<<x<<"  "<<#y<<"="<<y<<endl;
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int Pow(int a,int b){int res=1;while(b>0){if(b&1)res*=a;a*=a;b/=2;}return res;}
int MPow(int a,int  b){int res=1;while(b>0){if(b&1)res=(res*a)%Mod;a=(a*a)%Mod;b/=2;}return res%Mod;}
int log(int x){return 64-__builtin_clzll(x)-1;}

void c_p_p()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
}
struct Node
{
	int a,b,c,d;
	
};
bool cmp(Node A,Node B)
{
	return A.a<B.a;
}
const int Max=1e5+1;

int32_t main()
{
	c_p_p();
	int n;
	cin>>n;
	int A[n],sum=0;
	rep(i,0,n)cin>>A[i];
	sort(A,A+n,greater<int>());
	int ans=0,e=0,cnt=0,rem=n-1;
	vi V;
	rep(i,0,n)
	{
		
		if(rem<=e)break;
		ans+=A[i];
		//deb(ans);
		V.pb(A[i+1]);
		--rem;
		++e;
	}
	for(auto it:V)
	{
		ans+=it;
		
		rem--;
		if(rem==0)break;
	}
	if(n==2)cout<<A[0];
	else cout<<ans;


	return 0;
}
	

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using plglg = pair<ll, ll>;
using tlglglg = tuple<ll, ll, ll>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    int x; cin >> x;
    if (x >= 30) {
        yesno(true);
    } else {
        yesno(false);
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3648
let rec gain money fList =
    match fList with
    | [] -> money
    | [ _ ] -> money
    | (a :: b :: fList) ->
        if a < b then
            let num = money / a
            let newMoney = money + (b - a) * num
            gain newMoney (b :: fList)
        else
            gain money (b :: fList)


stdin.ReadLine()

stdin.ReadLine().Split(" ")
|> Array.map int64
|> Array.toList
|> gain (int64 1000)
|> printfn "%d"

Measured memory_bytes: 30060
{
  const run = (input: string) => {
    const s = input.trim()

    let result = 0
    let count = 0
    for (let i = 0; i < 3; i++) {
      if (s[i] === 'R') {
        count++
      } else {
        count = 0
      }

      if (result < count) {
        result = count
      }
    }

    return result
  }

  const Main = (input: string) => {
    console.log(run(input))
  };

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}


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

int main() {
	int R, G, B, N; cin >> R >> G >> B >> N;
	
	int ans = 0;
	
	for( int r = 0; R*r <= N; r++ )
	for( int g = 0; G*g + R*r <= N; g++ ){
		if( (N - R*r - G*g) % B == 0 )ans++;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
alphabet = "abcdefghijklmnopqrstuvwxyz".split("")
h = {}
for c in alphabet do
  h[c] = 0
end

while line = gets do
  s = line.chomp.downcase.split("")
  for i in 0..(s.length-1) do
    if alphabet.include?(s[i])
      h[s[i]] = h[s[i]] + 1
    end
  end
end

for c in alphabet do
  printf("%s : %d\n",c,h[c])
end


Measured memory_bytes: 6896
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	string a,b;
	cin>>a>>b;
	if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
open Scanf
open Printf
open String;;

(* sscanf (read_line ()) "%d %d" 
   (fun x y -> printf "%d" ((x-1)*(y-1)));; *)



(* let abb s = (sub s 0 1) 
            ^ (string_of_int (length s - 2))
            ^ (sub s (length s - 1) 1);;

sscanf (read_line ()) "%s"
          (fun s -> printf "%s" (abb s));; *)

(*

let judge l =
  let len = List.length l in
  let f l = List.fold_left 
              (fun (x,l') y -> if y mod 4==0 then (x+1,l') else (x,y::l')) (0,[]) l in
  let g l = List.fold_left (fun x y -> x + if y mod 2!=0 then 1 else 0) 0 l in
  let (four, fourl) = f l in
  four >= len/2 || g fourl <= four

let usage n = 
  let list = ref [] in
  for i = 1 to n do
    list := (scanf (if i < n then "%d " else "%d") (fun x -> x))::!list
  done; !list;;

sscanf (read_line ()) "%d" 
   (fun x -> printf "%s" (if judge (usage x) then "Yes" else "No"));;

*)

let usage n = 
  let list = ref [] in
  for i = 1 to n do
    list := (scanf (if i < n then "%d " else "%d") (fun x -> x))::!list
  done; List.rev !list;;

let rec print_list = function
    [x] -> print_endline (string_of_int x)
  | x::xs -> print_string ((string_of_int x) ^ " "); print_list xs

and print_ll = function
    [] -> ()
  | x::xs -> print_list x; print_ll xs;;

let rec make_list ini = function
    0 -> []
  | n -> ini :: make_list ini (n-1);;

let make_line l =
  let rec make col = function
      [] -> []
    | x::xs -> make_list col x :: make (col+1) xs
  in List.concat (make 1 l);;

let rec take n = function
    [] -> []
  | x :: rest when n = 0  -> [] 
  | x :: rest -> x :: take (n-1) rest;;

let rec drop n = function
    [] -> []
  | x :: rest when n <= 0 -> x :: drop (n-1) rest 
  | x :: rest -> drop (n-1) rest;;

let rec proc m n = function
  _ when n <= 0 || m <= 0 -> []
  | [] -> []
  | l when m mod 2 = 0 -> List.rev (take n l) :: proc (m-1) n (drop n l)
  | l when m mod 2 = 1 -> take n l :: proc (m-1) n (drop n l);;

sscanf (read_line ()) "%d %d" (fun m n ->
         sscanf (read_line ())  "%d" (fun x -> print_ll (proc m n (make_line (usage x)))));;






Measured memory_bytes: 14080
# AOJ 1051: Citation Format
# Python3 2018.7.7 bal4u

while True:
	n = int(input())
	if n == 0: break
	p = list(map(int, input().split())) + [-1]
	ans, s = [], p[0]
	for i in range(1, n+1):
		if p[i] != p[i-1]+1:
			if s == p[i-1]:	ans.append(str(s))
			else: ans.append(str(s)+'-'+str(p[i-1]))
			s = p[i]
	print(*ans)


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

bool is_connected[5][5];
std::vector<int> candidate = { 1, 2, 3, 4 };

bool solve_candidate()
{
  for (int i = 0; i < 3; i++) {
    if (!is_connected[candidate.at(i)][candidate.at(i+1)]) {
      return false;
    }
  }
  return true;
}

bool solve()
{
  do {
    if (solve_candidate()) {
      return true;
    }
  } while(std::next_permutation(candidate.begin(), candidate.end()));
  return false;
}

int main()
{
  for (int i = 0; i < 3; i++) {
    int dst, src;
    std::cin >> dst >> src;
    is_connected[dst][src] = true;
    is_connected[src][dst] = true;
  }
  if (solve()) {
    std::cout << "YES\n";
  } else {
    std::cout << "NO\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int n ;
  cin >> n  ;
  string s ;
  cin >> s  ;
 
  if(n%2 != 0){
  cout << "No" << endl ;
  return 0 ;  
  }
  
  string former , latter ;
  former = s.substr(0,n/2) ;
  latter = s.substr(n/2) ;
  
  if(former==latter){
      cout << "Yes" << endl ;
      return 0 ;  
  }else{
      cout << "No" << endl ;
      return 0 ;  
  }

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int sum = 0;
		ArrayList<Integer> w = new ArrayList<Integer>();
		for(int i=0; i<N; i++) {
			w.add(sc.nextInt());
			sum += w.get(i);
		}

		int l = w.get(0);
		int r = sum - w.get(0);
		int ans = Math.abs(l-r);
		for(int i=1; i<N-1; i++) {
			l += w.get(i);
			r -= w.get(i);
			ans = Math.min(ans, Math.abs(l-r));
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 35940
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
  int n; cin >> n;
  vector<int> b(n);
  rep(i, n){
    cin >> b[i];
    b[i]--;
  }
  vector<int> res;
  int m = n;
  rep(i, n){
    int pos = -1;
    for(int j = m - 1; j >= 0; j--){
      if(b[j] == j){
        pos = j;
        break;
      }
    }
    if(pos == -1){
      cout << -1 << endl;
      return 0;
    }
    res.push_back(pos);
    b.erase(b.begin() + pos);
    m--;
  }
  reverse(res.begin(), res.end());
  rep(i, n) cout << res[i] + 1 << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int s[M] = {}, tmps, k, p[M];
  for (int i = 0; i < M; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> tmps;
      s[i] |= 1 << (tmps - 1);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }

  int ans = 0;
  bool all_on;
  for (int i = 0; i < 1 << N; i++) {
    all_on = true;
    for (int j = 0; j < M; j++) {
      int sw_on = s[j] & i;
      int count = 0;
      for (int k = 0; k < N; k++) {
        if (sw_on & (1 << k)) count++;
      }
      if (count % 2 != p[j]) {
        all_on = false;
        break;
      }
    }
    if (all_on) ans++;
  }

  cout << ans << endl;

  return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    int n, h, w; cin>>n>>h>>w;
    vector<int> x(n);
    vector<int> window(w*n+10, 1);
    for(int i=0; i<n; i++){
        cin>>x[i];
        if(i%2==0){
            for(int j=i*w+1; j<=min(w*(n-1), i*w+x[i]); j++){
                window[j]--;
            }
            for(int j=i*w+x[i]+1; j<=min(w*n, (i+1)*w+x[i]); j++){
                window[j]++;
            }
        }
        else{
            for(int j=(i+1)*w; j>max(w-1, (i+1)*w-x[i]); j--){
                window[j]--;
            }
            for(int j=(i+1)*w-x[i]; j>max(0, i*w-x[i]); j--){
                window[j]++;
            }
        }

        /*
        for(int i=0; i<w*n; i++) cout << window[i] << " ";
        cout << endl;*/
    }

    ll ans=0;
    for(int i=1; i<=w*n; i++){
        if(window[i]<=0) ans+=h; 
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(){

	int A,B,C,D;
	cin >> A >> B >>C >>D;
	
	const int lower = max(A,C);
	const int upper = min(B,D);
	
	
	
	cout <<max(0,upper-lower) << endl;
	
	
	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	int i=1;
	while(i*0.08+i*0.1-200<=0){
		if(i*0.08-a<1&&i*0.08-a>=0&&i*0.1-b<1&&i*0.1-b>=0){
			printf("%d",i);
			return 0;
		}
		i++;
	}
	printf("-1");
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <P,P> PP;
typedef pair <int,PP> PPP;

static const double eps = 1e-8;

int main(){
	char a[32],b[32];
	while(~scanf("%s %s",a,b)){
		if(a[0]==b[0] && b[0] == '0') break;
		int hit=0;
		int brow=0;

		for(int i=0;i<4;i++){
			if(a[i]==b[i]){
				hit++;
				continue;
			}
			for(int j=0;j<4;j++){
				if(i==j) continue;
				if(b[i] == a[j]){
					brow++;
					break;
				}
			}

		}

		printf("%d %d\n",hit,brow);
	}
}

Measured memory_bytes: 3148
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    
    char text[] = "000";
    int count = 0;
    
    cin >> text[0] >> text[1] >> text[2];
    
    if(text[0] == '1'){
        count++;
    }
    if(text[1] == '1'){
        count++;
    }
    if(text[2] == '1'){
        count++;
    }
    
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<string>
typedef long long ll;
using namespace std;
#define INF (1 << 30)
#define INFLL (1LL << 60)
#define rep(i, n) for(int i=0; i<(n); ++i)


int main()
{
	int N; string S; cin >> N >> S;
	int hs = N;	//half S.size()
	vector<pair<string, string>> br;

	//文字列の半分までのパターンを全列挙
	rep(i, 1 << hs) {
		string b = "", r = "";
		//j番目のビットが立っているか
		rep(j, hs) {
			if (1 << j & i) b += S[j];
			else r += S[j];
		}
		reverse(r.begin(), r.end());
		br.emplace_back(b, r);
	}
	sort(br.begin(), br.end());

	ll ans = 0;
	//残り半分の文字パターンを全列挙する
	rep(i, 1 << hs) {
		string b = "", r = "";
		rep(j, hs) {
			if (1 << j & i) b += S[hs + j];
			else r += S[hs + j];
		}
		reverse(r.begin(), r.end());
		//(red, blue)と一致する組を、br(blue, red)から探す
		auto p = make_pair(r, b);
		auto it = lower_bound(br.begin(), br.end(), p);
		auto it2 = upper_bound(br.begin(), br.end(), p);
		ans += distance(it, it2);	//同じ文字列が複数あるときもカウントする
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 15348
def main():
    questions = int(input())
    a, b = map(int, input().split())
    score = list(map(int, input().split()))
    count_range = [0, 0, 0]
    for s in score:
        if s <= a:
            count_range[0] += 1
        elif s <= b:
            count_range[1] += 1
        else:
            count_range[2] += 1
    print(min(count_range))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
def main(str)
  nkc, s = str.split("\n")
  n, k, c = nkc.split(" ").map(&:to_i)
  s = s.split(//).map { |x| x == 'o' }
  a = greedy(s, k, c).map { |x| x + 1 }
  b = greedy(s.reverse, k, c).map { |x| n - x }.reverse
  a.zip(b).select { |x, y| x == y }.flatten.uniq.join("\n")
end

def greedy(s, k, c)
  i = 0
  results = []
  loop do
    return results if k == 0
    if s[i]
      results << i
      i += 1 + c
      k -= 1
    else
      i += 1
    end
  end
end

puts main($stdin.read.chomp)

Measured memory_bytes: 41800
z[9][101][101];n,m,t,c,b;char*f="%d%d%d%d\n";main(a){for(;scanf(f+4,&n,&m)*n;){for(memset(z,9,9e4);n--;z[0][a][b]=z[0][b][a]=c)scanf(f,&a,&b,&c,&t),z[1][a][b]=z[1][b][a]=t;for(t=m;t;--t)for(c=m;c;--c)for(b=m;b;--b)for(a=2;a--;)z[a][b][c]=fmin(z[a][b][c],z[a][b][t]+z[a][t][c]);for(scanf(f+6,&n);n--;printf(f+6,z[a][b][c]))scanf(f+2,&c,&b,&a);}}

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

int main(){
int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if((abs(a - c) <= d) || ((abs(a - b) <= d) && ((abs(c - b)) <= d))) 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 (int i = 0; i < (int)(n); i++)
int main(){
  int N;
  long long D;
  cin >> N >> D;
  long long X[N];
  long long Y[N];
  int Sum=0;
  long long k;
  int i=0;
  while(cin >> X[i] >> Y[i]){
    k=(X[i])*(X[i])+(Y[i])*(Y[i]);
    if(k<=D*D){Sum++;}
    i++;
  }
  cout << Sum << endl;
  return 0;
}



Measured memory_bytes: 6772
#include <stdio.h>

int main(void)
{
	int m, n;
	int i;
	int target;
	int now;
	int ans;
	
	while (scanf("%d", &target), target){
		now = 0;
		ans = -1;
		for (i = 0; i < 12; i++){
			scanf("%d %d", &m, &n);
			now += m - n;
			if (ans == -1 && now >= target){
				ans = i + 1;
			}
		}
		if (ans == -1){
			puts("NA");
		}
		else {
			printf("%d\n", ans);
		}
	}
	
	return (0);
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

int a[200123];

int main()
{
	int k, n;
	cin >> k >> n >> a[0];
	int ans = 0;
	Rep(i, (n-1)) {
		scanf("%d", a+i);
		ans = max(ans, a[i]-a[i-1]);
	}
	cout << k-max(ans, a[0]+k-a[n-1]) << endl;
	return 0;
}



Measured memory_bytes: 1024
import sys
n = int(input())
A=list(map(int,sys.stdin))
cnt = 0
G = [int((3**i-1)/2)for i in range(30,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
for g in G:
    insertionSort(A, n, g)
print(len(G))
print(*G)
print(cnt)
print(*A,sep='\n')


Measured memory_bytes: 53384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            List<int> lstA = new List<int>();
            List<int> lstB = new List<int>();
            lstA.Add(int.Parse(Console.ReadLine().Trim()));
            lstA.Add(int.Parse(Console.ReadLine().Trim()));
            lstB.Add(int.Parse(Console.ReadLine().Trim()));
            lstB.Add(int.Parse(Console.ReadLine().Trim()));

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstA.Sort();
            lstB.Sort();
            int iOut = lstA[0] + lstB[0];

            // 出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

const int maxn=2e5+10;

int n;
LL Ans=2e18;
multiset<int> A,B;

struct Point{
	int x,y;
	bool operator < (const Point &p) const {return x<p.x;}
}P[maxn];

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d%d",&P[i].x,&P[i].y);
		if (P[i].x>P[i].y) swap(P[i].x,P[i].y);
	}
	sort(P+1,P+n+1);
	for (i=1;i<=n;i++)
		A.insert(P[i].x),B.insert(P[i].y);
	for (i=0;i<n;i++)
	{
		if (i)
		{
			A.erase(A.find(P[i].x));
			B.erase(B.find(P[i].y));
			swap(P[i].x,P[i].y);
			A.insert(P[i].x);
			B.insert(P[i].y);
		}
		int X=*(--A.end())-*A.begin();
		int Y=*(--B.end())-*B.begin();
		Ans=min(Ans,(LL)X*Y);
	}
	printf("%lld\n",Ans);
}


Measured memory_bytes: 20736
use std::io;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main(){
let mut f = String::new();
io::stdin().read_line(&mut f);
let f:Vec<&str> = f.split_whitespace().collect();
let a:u32 = f[0].parse().unwrap_or(0);
let b:u32 = f[1].parse().unwrap_or(0);
let ans = if(a * b) % 2 == 0 {"Even"} else {"Odd"};
println!("{}",ans);
}

Measured memory_bytes: 4352
H, W, A, B = map(int, input().split())

mod = 10**9 + 7

# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, 2*10**5):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod-2, mod))


# 組み合わせ計算
def nCr(n, r):
    if n < r or n == 0 or r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod


check_point = []
for i in range(W-B):
    check_point.append(nCr(H-A-1+B+i, B+i))

ans = 0
for i in range(W-B):
    ans += (nCr(A-1+W-B-i-1, W-B-i-1) * check_point[i]) % mod
print(ans % mod)

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

int main(){
  int N;
  cin >> N;
  long long A,B;
  map<long long, long long> mp;
  for(int i=0;i<N;i++){
    cin >> A >> B;
    mp[A] = B;
  }
  int ans = mp.rbegin()->first;
  for(int i=mp.rbegin()->second -1;i>=0;i--) ans ++;
  cout << ans << endl;
}

Measured memory_bytes: 6528