akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for ( auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);blockTime.second;\
debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define li long long int
#define ld long double
#define eb push_back
#define pb pop_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define size(a) a.size()
#define rev(a) reverse(a.begin(),a.end())
#define len(a) a.length()
#define f first
#define s second
#define sort(a) sort(a.begin(),a.end())
#define vli vector<li>
#define vvli vector<vli >
#define pli pair<li,li>
#define vpli vector<pli>
#define inp(t) li t;cin>>t; while(t--)
using namespace std;
const li mod = 1e9+7;
#define MAXN 1000005 

li power(li a, li b) { a%=mod; li ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
li add(li a,li b) { return (((a%mod)+(b%mod))%mod);}
li sub(li a,li b) { return (((a%mod)-(b%mod))%mod);}
li mul(li a,li b) { return (((a%mod)*(b%mod))%mod);}

bool isprime(li n)
{
  if (n == 1)
    return false;
  int i = 2;
  while (i*i <= n){
      if (n % i == 0)return false;
      i += 1;
  }
  return true;
}

li lcm(li a,li b)
{
    return ((a*b)/__gcd(a,b));
}

void solve()
{
  int arr[105] = {0};

  li x,n;
  cin>>x>>n;

  rep(i,0,n)
  {
    li num;
    cin>>num;
    arr[num] = 1;
  }  

  li ans = INF;
  li diff = INF;
  rep(i,0,105)
  {
    if(diff>abs(x-i) && arr[i]!=1)
    {
      diff = abs(x-i);
      // cout<<i<<endl;
      ans = i;
    }
  }

  cout<<ans<<endl;
  return;
}
int main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    solve();
    return 0;
}

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

int main(){
    char c;
    cin>>c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
}


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

int main()
{
	int n;
	cin >> n;
	
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i];
	}
	
	sort(v.begin(), v.end());
	priority_queue<double, vector<double>, greater<double>> ans;
	
	for (int i = 0; i < n; ++i)
	{
		ans.push(v[i]);
	}
	
	double x,y;
	for (int i = 0; i < n-1; ++i)
	{
		x = (double)ans.top();
		ans.pop();
		y = (double)ans.top();
		ans.pop();
		
		//cout << "x :" << x << endl;
		//cout << "y :" << y << endl;
		
		ans.push((x + y)/2);
		
		//cout << "(x + y)/2 :" << (x + y)/2 << endl;
		
		//sort(ans.begin(), ans.end());
	}
	cout << (double)ans.top() << endl;
	
	return 0;
}

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

int main(void)
{
    int number = 0;
	int i;
    char sentence[1000];
	char word[10];

    scanf("%s", word);

    for(i = 0; i < 10; i++){
		word[i] = tolower(word[i]);
	}

    while(1){
        scanf("%s", sentence);
        if(strcmp(sentence,"END_OF_TEXT") == 0){
			break;
		}

        for(i = 0; i < 1000; i++){
			sentence[i] = tolower(sentence[i]);
		}

        if(strcmp(sentence, word) == 0){
			number++;
		}
    }

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

    return 0;
}

Measured memory_bytes: 552
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a[] = new int[3];
        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[0] + a[1]);
        sc.close();
    }
}

Measured memory_bytes: 23636
using System;

namespace ITP1_8_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            if (input.Length < 1200)
            {
                foreach(var i in input)
                {
                    char c = i;
                    if (64 < (int)i && (int)i < 91) c += (char)32;
                    else if (96 < (int)i && (int)i < 123) c -= (char)32;
                    Console.Write(c);
                }
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("Error. The string size is over 1200");
                Environment.Exit(0);
            }
        }
    }
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N,K;
ll A[200005];

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>K;
rep1(i,N+1) cin>>A[i];
for(ll i=K+1; i<=N; i++){
	A[i-K]<A[i]?puts("Yes"):puts("No");
}


}
	

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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 2e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<int> a(A), b(B), c(C);
    c.reserve(X+Y+C);
    for (int i = 0; i < A; i++)
        cin >> a[i];
    for (int i = 0; i < B; i++)
        cin >> b[i];
    for (int i = 0; i < C; i++)
        cin >> c[i];

    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    a.resize(X); b.resize(Y);

    c.insert(c.end(), a.begin(), a.end());
    c.insert(c.end(), b.begin(), b.end());

    sort(c.rbegin(), c.rend());

    long long ans = 0;
    for (int i = 0; i < X+Y; i++)
        ans += c[i];

    cout << ans << endl;


    return 0;
%>

Measured memory_bytes: 2168
#include <iostream>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
int main(void){
    int n, a, b;
    cin >> n >> a >> b;
    if((b-a)%2 == 0){
        cout << "Alice" << endl;
    }
    else{
        cout << "Borys" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1000000007;
int p(int A,int B){
  if(A==0)
    return 1;
  if(A%2==0){
    int j=p(A/2,B);
    return j*j%N;
  }
  return B*p(A-1,B)%N;
}
signed main(){
  int n,a,b;
  cin>>n>>a>>b;
  int a1=1,a2=1,b1=1,b2=1;
  for(int i=n-a+1;i<=n;i++)
    a1=a1*i%N;
  for(int i=1;i<=a;i++)
    a2=a2*i%N;
  for(int i=n-b+1;i<=n;i++)
    b1=b1*i%N;
  for(int i=1;i<=b;i++)
    b2=b2*i%N;
  cout<<(p(n,2)-(a1*p(N-2,a2)%N+b1*p(N-2,b2)%N+1)+N*3)%N<<endl;
}

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

void solve(long long H, long long A)
{
    cout << (H - 1) / A + 1 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long H;
    scanf("%lld", &H);
    long long A;
    scanf("%lld", &A);
    solve(H, A);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,count=0,flag,i,ans1,ans2;
    cin>>n;
    ll a[n],b[n],c[n];
    for(i=0;i<n;i++){
        c[i]=i+1;
    }
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        cin>>b[i];
    }
    do{
        flag=0;
        count++;
        for(i=0;i<n;i++){
            if(a[i]!=c[i]){
                flag=1;
            }
        }
        if(flag==0){
            ans1=count;
        }
        flag=0;
        for(i=0;i<n;i++){
            if(b[i]!=c[i]){
                flag=1;
            }
        }
        if(flag==0){
            ans2=count;
        }
    }while(next_permutation(c,c+n));
    //cout<<ans1<<" "<<ans2<<endl;
    cout<<abs(ans1-ans2);
}

Measured memory_bytes: 256
# K - Stones
def main():
    N, K, *A = map(int, open(0).read().split())
    dp = [0] * (K + 1)
    for i in range(K):
        for a in A:
            if i + a > K:
                break
            dp[i + a] |= dp[i] ^ 1
    print("First" if dp[-1] else "Second")


if __name__ == "__main__":
    main()


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

#ifdef _DEBUG
#define debug(x) cout << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define debug(x)
#define INFILE
#endif

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL9_MOD = 1000000009LL;
static constexpr ll LL7_MOD = 1000000007LL;
static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

bool dp[100010][2];

int main(int argc, char* argv[]) {
  INFILE;

  ll n, k;
  cin >> n >> k;

  vector<int> stones(n);
  scan(stones);

  REP(i, 0, k + 1) {
    REP(j, 0, 2) {
      int opponent = !j;
      bool result = false;
      for (int stone : stones) {
        int num = i - stone;
        if (num < 0) continue;
        if (!dp[num][opponent]) {
          result = true;
          break;
        }
      }
      dp[i][j] = result;
    }
  }

  cout << (dp[k][1] ? "First" : "Second") << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a;
  cin >> a;
  if(a < 1200){
    cout << "ABC\n";
  }
  else{
    cout << "ARC\n";
  }
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_N=1e2,MIN_A=-1e2,MAX_A=1e2,INF=1e8;

int N;
int A[MAX_N];

int main(){
    scanf("%d",&N);
    REP(i,N){
        scanf("%d",&A[i]);
    }
    int ans=INF;
    FOR(i,MIN_A,MAX_A+1){
        int c=0;
        REP(j,N){
            c+=(A[j]-i)*(A[j]-i);
        }
        ans=min(ans,c);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int N,K;
    cin >> N >> K;
    string s;
    cin >> s;
    if(s[K-1] == 'A')s[K-1] = 'a';
    else if(s[K-1] == 'B')s[K-1] = 'b';
    else if(s[K-1] == 'C')s[K-1] = 'c';

    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
ll gcd(ll a,ll b)
{
	if(a%b==0)
		return b;
	else
		return gcd(b,a%b);
}
void solve()
{
    int n,k;
    cin>>n>>k;
    if(n>=2*k-1)
        cout<<"YES";
    else
        cout<<"NO";
}
int main()
{
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld  = long double;
using pll = pair<ll, ll> ;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=1LL<<60;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用（EPSより小さいと0と判定など）
 
#define gcd __gcd //llは受け取ってくれない
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define ALL(a) a.begin(),a.end() //sort(ALL(vec));
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define PB push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

//最大値、最小値を更新する。aよりbのが大きい（小さい）か等しければaを更新してtrueを返す。そうでなければ何もせずfalseを返す chmax(nowmax,x);
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
// ----- template end ---- //
 
// ------- library ------- //


//a>=bで渡す必要があるか？（そうしなくてもいいけど、そうした方が実行早いかも）
ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
 
//a>=bで渡す必要があるか？
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// ----- library end ----- //



int main() {

  ll N, X;
  cin >> N >> X;

  if (N==1){
    ll x1;
    cin >> x1;
    cout << abs(X-x1) << endl;
    return 0;
  }

  ll x;
  cin >> x;
  ll nowgcd = abs(X-x);
  while (cin >> x){
    nowgcd = GCD(nowgcd, abs(X-x));
  }

  cout << nowgcd << endl;

// -- main() end -- //
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

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


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

#define PI 4*atan(1)
#define INF 1e8

#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++)

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

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

int main(){
  string S;
  cin >> S;
  for(int i = 0; i < S.size() - 1; i++){
    if(S[i] == 'A' &&  S[i + 1] == 'C'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

long long a[100005],front[100005],back[100005];
long long max_gcd=-1;

int main()
{
	long long n,max_gcd;
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)
	{
		if (i==1)  front[i]=a[i];
		else front[i]=__gcd(front[i-1],a[i]);
	}
	for (int i=n;i>=1;i--)
	{
		if (i==n)  back[i]=a[i];
		else back[i]=__gcd(back[i+1],a[i]);
	} 
	for (int i=1;i<=n;i++)
	{
		if (i==1)  max_gcd=max(max_gcd,back[i+1]);
		else if (i==n)  max_gcd=max(max_gcd,front[i-1]);
		else max_gcd=max(max_gcd,__gcd(front[i-1],back[i+1]));
	}
	cout<<max_gcd<<endl;
	return 0;
}

Measured memory_bytes: 2560
import math
A, B, H, M = map(int, input().split())
pi = math.pi

angle = (M * pi)/360 + (H * pi)/6 - (M * pi)/30

X = A**2 + B**2 - 2 * A * B * math.cos(angle)

ans = math.sqrt(X)
print(ans)

Measured memory_bytes: 62480
#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++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

int h, w;

char field[2020][2020];
int cnth[2020][2020] = {}, cntw[2020][2020] = {};

int dfsh(int y, int x, int cnt){
  if(y >= h) return cnt-1;
  if(field[y][x] == '#') return cnt-1;
  cnth[y][x] = dfsh(y+1, x, cnt+1);
  return cnth[y][x];
}
int dfsw(int y, int x, int cnt){
  if(x >= w) return cnt-1;
  if(field[y][x] == '#') return cnt-1;
  cntw[y][x] = dfsw(y, x+1, cnt+1);
  return cntw[y][x];
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> h >> w;
  rep(i,h){
    rep(j,w){
      cin >> field[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      if(field[i][j] == '.' && cnth[i][j] == 0){
        dfsh(i,j, 1);
      }
    }
  }
  rep(i,h){
    rep(j,w){
      if(field[i][j] == '.' && cntw[i][j] == 0){
        dfsw(i,j, 1);
      }
    }
  }

  int ans = 0;
  rep(i,h)rep(j,w){
    ans = max(ans, cntw[i][j] + cnth[i][j] - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 36096
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	unsigned long long X;
	cin >> X;

	unsigned long long ans = 0;
	unsigned long long val = 100;

	double d = 0.0;
	while (val < X) {
		d = (double)val * 1.01;
		val = (unsigned long long)d;
		ans += 1;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3620
void main() {
    int n = readln.chomp.to!int;
    int people;
    foreach (i; 0 .. n) {
        int[] tmp = readln.split.to!(int[]);
        int l = tmp[0], r = tmp[1];
        people += r - l + 1;
    }
    people.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

#include <bits/stdc++.h>

using namespace std;

struct Edge {int to, cost; };
typedef pair<int, int> pint;

#define INF (1000 * 1000 * 1000)

class Dikstra {
private:
    int N;
    vector<vector<Edge>> edge_list;

public:
    Dikstra(vector< vector<Edge>> &edge_list) {
        this->edge_list = edge_list;
        this->N = edge_list.size();
    }

    vector<int> search(int s) {
        priority_queue<pint, vector<pint>, greater<pint> > que;
        vector<int> d(N, INF);
        d[s] = 0;
        que.push(make_pair(0, s));

        while (!que.empty()) {
            pint p = que.top();
            que.pop();

            int v = p.second;
            if (d[v] < p.first) continue;

            for (Edge e: edge_list[v]) {
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to], e.to));
                }
            }
        }

        return d;
    }
};

int idx(int h, int w, int W) {
    return h * W + w;
}

signed main() {
    int H, W;
    cin >> H >> W;

    int white = 0;

    vector< vector<int>> mp(H+2, vector<int>(W+2, 1));
    REPS(h, H) {
        string s;
        cin >> s;

        REPS(w, W) {
            mp[h][w] = (s[w-1] == '.') ? 0 : 1;
            white += 1 - mp[h][w];
        }
    }

    vector<vector<Edge>> edge_list(H*W, vector<Edge>());

    REPS(h, H) {
        REPS(w, W) {
            if (mp[h][w] == 0) {
                int i = idx(h-1, w-1, W);
                if (mp[h-1][w] == 0) {
                    int j = idx(h-1-1, w-1, W);
                    edge_list[i].pb(Edge{j, 1});
                    edge_list[j].pb(Edge{i, 1});
                }

                if (mp[h+1][w] == 0) {
                    int j = idx(h-1+1, w-1, W);
                    edge_list[i].pb(Edge{j, 1});
                    edge_list[j].pb(Edge{i, 1});
                }

                if (mp[h][w-1] == 0) {
                    int j = idx(h-1, w-1-1, W);
                    edge_list[i].pb(Edge{j, 1});
                    edge_list[j].pb(Edge{i, 1});
                }

                if (mp[h][w+1] == 0) {
                    int j = idx(h-1, w-1+1, W);
                    edge_list[i].pb(Edge{j, 1});
                    edge_list[j].pb(Edge{i, 1});
                }
            }
        }
    }

    Dikstra dks(edge_list);
    vector<int> distance = dks.search(0);

    if (distance[H*W-1] == INF) {
        cout << -1 << endl;
    } else {
        cout << white - (distance[H*W-1] + 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct SegmentTree {
private:
    int n;
    vector<ll> node;
 
public:
    SegmentTree() {
        int sz = 100050;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = 0;
        for(int i=n-2; i>=0; i--) node[i] = (node[2*i+1] + node[2*i+2]);
    }
 
    void add(int x, int val) {
        x += (n - 1);
        node[x] += val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = (node[2*x+1] + node[2*x+2]);
        }
    }
    // hannkaikukann 
    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];
 
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return (vl + vr);
    }
};
ll N;
ll a[100500];
deque<int> deq[105000];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
        deq[a[i]].push_back(i);
    }
    ll ans = 0;
    SegmentTree seg;
    for(int i = 1; i <= N; i++) seg.add(i, 1);
    for(int val = 1; val <= 1e5; val++) {
        while(!deq[val].empty()) {
            int l = deq[val].front();
            int r = deq[val].back();
            ll lcost = seg.getsum(0, l);
            ll rcost = seg.getsum(r + 1, 1e5+1);
            if(lcost < rcost) {
                ans += lcost;
                seg.add(l, -1);
                deq[val].pop_front();
            } else {
                ans += rcost;
                seg.add(r, -1);
                deq[val].pop_back();
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.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 sum = 0;
    for(int i = 0; i < k; i++) {
        sum += v[i];
    }
    cout << sum << "\n";
    
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << b * a / 2 << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int N,a[100],count=1;
  scanf("%d",&N);

  for(int i=0;i<N;i++){
    scanf("%d",&a[i]);
  }

  for(int j=0;j<N;j++){
    for(int k=j+1;k<N;k++){
      if(a[j]>a[k]){
        int tmp=a[j];
        a[j]=a[k];
        a[k]=tmp;
      }
    }
  }

  for(int l=0;l<N-1;l++){
    if(a[l]!=a[l+1]){
      count++;
    }
  }

  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int A[3];
    
    cin >> A[0] >> A[1] >> A[2];
    sort(A,A+3);
    
    cout << A[0] << " " << A[1] << " " << A[2] << endl;
    
    


}

Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>

using namespace std;

#define ll long long
#define MAX 10000000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007


int cnt[MAX + 5];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int i, j, n;
    ll ans = 0;
    cin >> n;
    for (i = 1; i <= n; ++i) {
        for (j = i; j <= n; j += i) {
            cnt[j]++;
        }
    }
    for (i = 1; i <= n; ++i) {
        ans += 1LL * i * cnt[i];
    }
    cout << ans;

    return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

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

    int ans = 0;
    for (int i=1; i<n-1; ++i) {
        vector<int> tmp(3);
        tmp[0] = p[i-1];
        tmp[1] = p[i];
        tmp[2] = p[i+1];
        sort(tmp.begin(), tmp.end());
        if (tmp[1] == p[i]) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
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() -> () {
    input!{
        x1: i32,
        y1: i32,
        x2: i32,
        y2: i32,
    }
    let dx = x2 - x1;
    let dy = y2 - y1;
    let x3 = x2 - dy;
    let y3 = y2 + dx;
    let x4 = x3 - dx;
    let y4 = y3 - dy;

    println!("{} {} {} {}", x3, y3, x4, y4);
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll L; cin >> L;
	ll size = 0;

	while ((1ll<<size) <= L) size++;
	
	vector<tuple<ll, ll, ll>> dats;
	int u = 1;
	while (L > 1) {
		dats.emplace_back(u, u+1, 0);
		dats.emplace_back(u, u+1, (L+1)/2);
		if (L&1) dats.emplace_back(u, size, L/2);
		u++;
		L >>= 1;
	}
	cout << size << " " << dats.size() << el;

	for (auto &d : dats) {
		ll a, b, c; tie(a, b, c) = d;
		cout << a << " " << b << " " << c << el;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3652
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i, 0, N) cin >> D[i];

    int ans = 0;
    rep(i, 0, N) rep(j, i+1, N) ans += D[i] * D[j];
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=3e2+5;
const ll p=998244353;

ll read()
{
	ll s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(ll x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(ll x,char c='\n')
{
	write(x);
	putchar(c);
}
ll dp[N][N][N],a[N],sum[N];
char s[N];

int main()
{
	
	memset(dp,0,sizeof(dp));
	memset(sum,0,sizeof(sum));
	scanf("%s",s+1);
	ll n=strlen(s+1),m=min(n,read()),cnt=1;
	for (ll i=1;i<=n;i++)
	if (s[i]=='1') a[cnt]++;
			  else cnt++;
	sum[0]=0;
	for (ll i=1;i<=cnt;i++) sum[i]=sum[i-1]+a[i];
	dp[0][0][0]=1;
	for (ll i=1;i<=cnt;i++)//前i个 
	for (ll j=sum[i];j<=sum[cnt];j++)//和为j 
	for (ll k=0;k<=m;k++)//共操作k次 
	for (ll l=0;l<=j;l++)//第i位填l 
	if (k>=max(l-a[i],0ll)) dp[i][j][k]=(dp[i][j][k]+dp[i-1][j-l][k-max(l-a[i],0ll)])%p;
	ll ans=0;
	for (ll i=0;i<=m;i++) ans=(ans+dp[cnt][sum[cnt]][i])%p;
	print(ans);

	return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a + b > c + d) {
    cout << "Left"
         << "\n";
  } else if (a + b < c + d) {
    cout << "Right"
         << "\n";
  } else {
    cout << "Balanced"
         << "\n";
  }
}

Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
K = ri()
S = rs()
print(S if len(S) <= K else S[:K] + '...')

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

using namespace std;

using ll = long long;

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]; ++a[i]; }

    int max_n = *max_element(a.begin(), a.end());
    vector<int> t(max_n + 2);
    for (int i = 0; i < n; ++i) {
        ++t[a[i]];
        ++t[a[i] - 1];
        ++t[a[i] + 1];
    }

    cout << *max_element(t.begin(), t.end()) << endl;

    return 0;
}


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

int main (){
	string a,b;
 	cin >> a >> b;
 	string c = a+b;
 	int d = stoi(c);
  	string ans = "No";
	for(int i = 0; i <= 10000 ; i++){
    	if(i*i == d){
        	ans = "Yes";
        }
    
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
def solve(s, t):
    n = len(s)
    m = len(t)
    if n < m:
        return 'UNRESTORABLE'
    for i in range(n-m+1)[::-1]:
        if all([s[i+j] == '?' or s[i+j] == t[j] for j in range(m)]):
            return s[:i].replace('?', 'a') + t + s[i+m:].replace('?', 'a')
    return 'UNRESTORABLE'


def main():
    s = input()
    t = input()
    print(solve(s, t))


if __name__ == "__main__":
    main()


Measured memory_bytes: 8996
input_lines = input().split(" ")
X = int(input_lines[0])
Y = int(input_lines[1])
Z = int(input_lines[2])

judge = X//(Y+Z)

if judge*(Y+Z)+Z>X:
    print(str(X//(Y+Z)-1))
else:
    print(str(X//(Y+Z)))


Measured memory_bytes: 2940
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    dp = [[0 for _ in range(3)] for _ in range(N)]

    H = list(zip(a,b,c))

    for j in range(3):
        dp[0][j] = H[0][j]

    for i in range(1,N):
        for j in range(3):
            for k in range(3):
                if j != k:
                    dp[i][j] = max(dp[i][j],dp[i-1][k] + H[i][j])

    print(max(dp[-1]))


    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, a, b, c)

if __name__ == '__main__':
    main()


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

int main() {
	int n;
	cin >> n;
	vector<int> x(n),x2(n);
	for (int i = 0;i < n;i++) {
		cin >> x[i];
		x2[i] = x[i];
	}
	sort(x2.begin(), x2.end());
	for (int i = 0;i < n;i++) {
		int left = x2[n / 2 - 1];
		int right = x2[n / 2];
		if (left >= x[i]) {
			cout << right << endl;
		}
		else {
			cout << left << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3712
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<vector>
using namespace std;

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

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int n, c, x;
int d[30][39];
int t[3][30];

int main(){
	cin >> n >> c;
	REP(i, c) REP(j, c) cin >> d[i][j];
	REP(i, n) REP(j, n) { cin >> x; t[(i+j)%3][x-1]++;}
	int res = 1<<30;
	REP(i, c) REP(j, c) if(i!=j) REP(k, c) if(i!=k&&j!=k){
		int tt = 0;
		REP(l, c) tt+=d[l][i]*t[0][l];
		REP(l, c) tt+=d[l][j]*t[1][l];
		REP(l, c) tt+=d[l][k]*t[2][l];
		res=min(res,tt);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a.at(i);
	}
 
	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a.at(i).at(j) == '#') {
				row.at(i) = true;
				col.at(j) = true;
			}
		}
	}
 
	for (int i = 0; i < h; i++) {
		if (row.at(i)) {
			for (int j = 0; j < w; j++) {
				if (col.at(j)) {
					cout << a.at(i).at(j);
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:usize,
    c:usize,
    }
    println!("{}",if a+b+1>=c{b+c}else{a+2*b+1})
}

Measured memory_bytes: 2124
n, m = (int(x) for x in input().split())
P = list(int(x) for x in input().split())
XY = [tuple(int(x) for x in input().split()) for _ in range(m)]

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    """
    n個の要素を0 ~ n - 1の番号で管理する。以下の属性およびメソッドを持つ。

    parents
    各要素の親要素の番号を格納するリスト
    要素が根（ルート）の場合は-(そのグループの要素数)を格納する

    find(x)
    要素xが属するグループの根を返す

    union(x, y)
    要素xが属するグループと要素yが属するグループとを併合する

    size(x)
    要素xが属するグループのサイズ（要素数）を返す

    same(x, y)
    要素x, yが同じグループに属するかどうかを返す

    members(x)
    要素xが属するグループに属する要素をリストで返す

    roots()
    すべての根の要素をリストで返す

    group_count()
    グループの数を返す

    all_group_members
    {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す

    __str__()
    print()での表示用
    ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す
    """

uf = UnionFind(n+1)
for x, y in XY:
    uf.union(x, y)

ans = 0
for i, p in enumerate(P, start=1):
    if uf.same(i, p):
        ans += 1
print(ans)

Measured memory_bytes: 98104
N = int(input())
S = list(range(N))
P = list(range(N))
SP = list(range(N))

for i in range(N):
  S[i], P[i] = input().split()
  P[i] = int(P[i])
  SP[i] = (S[i], P[i])

S_ = sorted(set(S))
P_ = sorted(set(P), reverse = True)

for n in range(len(S_)):
  for m in range(len(P_)):
    if (S_[n], P_[m]) in SP:
      print(SP.index((S_[n], P_[m])) + 1)

Measured memory_bytes: 3064
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

K = I()
A, B = LI()

a = 1
while True:
    if A <= a*K <= B:
        print("OK")
        break
    else:
        a += 1
    if B < a*K:
        print("NG")
        break

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

int main()
{

        int N;
        cin >> N;
        int X[N];
        int s[N];
        for (int i = 0; i < N; ++i) {
                cin >> X[i];
                s[i] = X[i];
        }
        sort(s, s+N);
        int right = s[N/2];
        int left = s[N/2-1];

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

                if (X[i] < right) {
                        cout << right << endl;
                }
                else {
                        cout << left << endl;
                }
        }





}


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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sort(v) sort(all(v))



/* constant */
const int inf = 100100100100100100;
const int mod = 1000000007;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


/* math_library */
int ceil(int a, int b){if(a % b == 0){return a/b;}else{return a/b + 1;}}


/* main */


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w; cin >> h >> w;

    int dp[h][w];
    rep(i,0,h){
        rep(j,0,w){
            if(input() == 0){
                dp[i][j] = inf;
            }else{
                dp[i][j] = 0;
            }
        }
    }

    int tx[3] = {-1, 0, -1};
    int ty[3] = {0, -1, -1};

    

    rep(i,0,h){
        rep(j,0,w){
            rep(k,0,3){
                int x = j + tx[k];
                int y = i + ty[k];
                chmin(dp[i][j], (-1 < x && -1 < y ? dp[y][x] + 1 : 1));
            }
        }
    }

    int ans = 0;
    rep(i,0,h){
        rep(j,0,w){
            chmax(ans, dp[i][j]);
        }
    }

    print(ans * ans);













   




}   



Measured memory_bytes: 18400
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

ll inv(ll x){
    // MOD=10e9+7
	ll n=MOD-2,a=1;
	while(n>0){
		if(n%2) a=a*x%MOD;
		x=x*x%MOD;
		n=n/2;
	}
	return a;
}

ll Comb(ll n,ll m){
    ll ans = 1; 
    for(int i=0;i < m; i++){
        ans *= ((n-i)*inv(i+1)) % MOD;
        ans %= MOD;
    }
    return ans;
}

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

    rep(i,1,K+1){
        cout<<(Comb(K-1,i-1)*Comb(N-K+1,i))%MOD<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
//----
const int N=55;
ll dp[N][N][N*N];
int a, n;
int x[N];
int main(){
	scanf("%d%d", &n, &a);
	rep(i, 1, n+1)scanf("%d", x+i);
	memset(dp, 0, sizeof(dp));
	dp[0][0][0]=1;
	rep(i, 1, n+1)rep(j, 0, i+1)rep(k, 0, N*N){
		dp[i][j][k]+=dp[i-1][j][k];
		if(k>=x[i]&&j)dp[i][j][k]+=dp[i-1][j-1][k-x[i]];
	}
	ll ans=0;
	rep(j, 1, N)ans+=dp[n][j][j*a];
	printf("%lld\n", ans);
	return 0;
}
/*
4 8
7 9 8 9
5

3 8
6 6 9
0

8 5
3 6 2 8 7 6 5 9
19

33 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
8589934591
*/


Measured memory_bytes: 71680